25 #include "sigrok-internal.h"
42 static int is_valid_samplerate(uint64_t samplerate)
46 for (i = 0; i < 255; i++) {
47 if (samplerate == (
SR_MHZ(100) / (i + 1)))
51 sr_warn(
"la8 out: %s: invalid samplerate (%" PRIu64
"Hz)",
52 __func__, samplerate);
68 static uint8_t samplerate_to_divcount(uint64_t samplerate)
70 if (samplerate == 0) {
71 sr_warn(
"la8 out: %s: samplerate was 0", __func__);
75 if (!is_valid_samplerate(samplerate)) {
76 sr_warn(
"la8 out: %s: can't get divcount, samplerate invalid",
81 return (
SR_MHZ(100) / samplerate) - 1;
92 sr_warn(
"la8 out: %s: o was NULL", __func__);
97 sr_warn(
"la8 out: %s: o->dev was NULL", __func__);
102 sr_warn(
"la8 out: %s: o->dev->driver was NULL", __func__);
106 if (!(ctx = g_try_malloc0(
sizeof(
struct context)))) {
107 sr_warn(
"la8 out: %s: ctx malloc failed", __func__);
115 for (l = o->
dev->
probes; l; l = l->next) {
136 static int event(
struct sr_output *o,
int event_type, uint8_t **data_out,
137 uint64_t *length_out)
143 sr_warn(
"la8 out: %s: o was NULL", __func__);
148 sr_warn(
"la8 out: %s: o->internal was NULL", __func__);
153 sr_warn(
"la8 out: %s: data_out was NULL", __func__);
157 switch (event_type) {
159 sr_dbg(
"la8 out: %s: SR_DF_TRIGGER event", __func__);
164 sr_dbg(
"la8 out: %s: SR_DF_END event", __func__);
165 if (!(outbuf = g_try_malloc(4 + 1))) {
166 sr_warn(
"la8 out: %s: outbuf malloc failed", __func__);
171 outbuf[0] = samplerate_to_divcount(ctx->
samplerate);
189 sr_warn(
"la8 out: %s: unsupported event type: %d", __func__,
199 static int data(
struct sr_output *o,
const uint8_t *data_in,
200 uint64_t length_in, uint8_t **data_out, uint64_t *length_out)
206 sr_warn(
"la8 out: %s: o was NULL", __func__);
211 sr_warn(
"la8 out: %s: o->internal was NULL", __func__);
216 sr_warn(
"la8 out: %s: data_in was NULL", __func__);
220 if (!(outbuf = g_try_malloc0(length_in))) {
221 sr_warn(
"la8 out: %s: outbuf malloc failed", __func__);
225 memcpy(outbuf, data_in, length_in);
228 *length_out = length_in;
234 .
id =
"chronovu-la8",
235 .description =
"ChronoVu LA8",