]> sigrok.org Git - libsigrok.git/blame_incremental - src/hardware/demo/api.c
device: introduce common helpers for channel group allocation
[libsigrok.git] / src / hardware / demo / api.c
... / ...
CommitLineData
1/*
2 * This file is part of the libsigrok project.
3 *
4 * Copyright (C) 2010 Uwe Hermann <uwe@hermann-uwe.de>
5 * Copyright (C) 2011 Olivier Fauchon <olivier@aixmarseille.com>
6 * Copyright (C) 2012 Alexandru Gagniuc <mr.nuke.me@gmail.com>
7 * Copyright (C) 2015 Bartosz Golaszewski <bgolaszewski@baylibre.com>
8 * Copyright (C) 2019 Frank Stettner <frank-stettner@gmx.net>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, see <http://www.gnu.org/licenses/>.
22 */
23
24#include <config.h>
25#include <stdlib.h>
26#include <string.h>
27#include <math.h>
28#include <libsigrok/libsigrok.h>
29#include "libsigrok-internal.h"
30#include "protocol.h"
31
32#define DEFAULT_NUM_LOGIC_CHANNELS 8
33#define DEFAULT_LOGIC_PATTERN PATTERN_SIGROK
34
35#define DEFAULT_NUM_ANALOG_CHANNELS 5
36
37/* Note: No spaces allowed because of sigrok-cli. */
38static const char *logic_pattern_str[] = {
39 "sigrok",
40 "random",
41 "incremental",
42 "walking-one",
43 "walking-zero",
44 "all-low",
45 "all-high",
46 "squid",
47 "graycode",
48};
49
50static const uint32_t scanopts[] = {
51 SR_CONF_NUM_LOGIC_CHANNELS,
52 SR_CONF_NUM_ANALOG_CHANNELS,
53 SR_CONF_LIMIT_FRAMES,
54};
55
56static const uint32_t drvopts[] = {
57 SR_CONF_DEMO_DEV,
58 SR_CONF_LOGIC_ANALYZER,
59 SR_CONF_OSCILLOSCOPE,
60};
61
62static const uint32_t devopts[] = {
63 SR_CONF_CONTINUOUS,
64 SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET,
65 SR_CONF_LIMIT_MSEC | SR_CONF_GET | SR_CONF_SET,
66 SR_CONF_LIMIT_FRAMES | SR_CONF_GET | SR_CONF_SET,
67 SR_CONF_SAMPLERATE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
68 SR_CONF_AVERAGING | SR_CONF_GET | SR_CONF_SET,
69 SR_CONF_AVG_SAMPLES | SR_CONF_GET | SR_CONF_SET,
70 SR_CONF_TRIGGER_MATCH | SR_CONF_LIST,
71 SR_CONF_CAPTURE_RATIO | SR_CONF_GET | SR_CONF_SET,
72};
73
74static const uint32_t devopts_cg_logic[] = {
75 SR_CONF_PATTERN_MODE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
76};
77
78static const uint32_t devopts_cg_analog_group[] = {
79 SR_CONF_AMPLITUDE | SR_CONF_GET | SR_CONF_SET,
80 SR_CONF_OFFSET | SR_CONF_GET | SR_CONF_SET,
81};
82
83static const uint32_t devopts_cg_analog_channel[] = {
84 SR_CONF_MEASURED_QUANTITY | SR_CONF_GET | SR_CONF_SET,
85 SR_CONF_PATTERN_MODE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
86 SR_CONF_AMPLITUDE | SR_CONF_GET | SR_CONF_SET,
87 SR_CONF_OFFSET | SR_CONF_GET | SR_CONF_SET,
88};
89
90static const int32_t trigger_matches[] = {
91 SR_TRIGGER_ZERO,
92 SR_TRIGGER_ONE,
93 SR_TRIGGER_RISING,
94 SR_TRIGGER_FALLING,
95 SR_TRIGGER_EDGE,
96};
97
98static const uint64_t samplerates[] = {
99 SR_HZ(1),
100 SR_GHZ(1),
101 SR_HZ(1),
102};
103
104static GSList *scan(struct sr_dev_driver *di, GSList *options)
105{
106 struct dev_context *devc;
107 struct sr_dev_inst *sdi;
108 struct sr_channel *ch;
109 struct sr_channel_group *cg, *acg;
110 struct sr_config *src;
111 struct analog_gen *ag;
112 GSList *l;
113 int num_logic_channels, num_analog_channels, pattern, i;
114 uint64_t limit_frames;
115 char channel_name[16];
116
117 num_logic_channels = DEFAULT_NUM_LOGIC_CHANNELS;
118 num_analog_channels = DEFAULT_NUM_ANALOG_CHANNELS;
119 limit_frames = DEFAULT_LIMIT_FRAMES;
120 for (l = options; l; l = l->next) {
121 src = l->data;
122 switch (src->key) {
123 case SR_CONF_NUM_LOGIC_CHANNELS:
124 num_logic_channels = g_variant_get_int32(src->data);
125 break;
126 case SR_CONF_NUM_ANALOG_CHANNELS:
127 num_analog_channels = g_variant_get_int32(src->data);
128 break;
129 case SR_CONF_LIMIT_FRAMES:
130 limit_frames = g_variant_get_uint64(src->data);
131 break;
132 }
133 }
134
135 sdi = g_malloc0(sizeof(struct sr_dev_inst));
136 sdi->status = SR_ST_INACTIVE;
137 sdi->model = g_strdup("Demo device");
138
139 devc = g_malloc0(sizeof(struct dev_context));
140 devc->cur_samplerate = SR_KHZ(200);
141 devc->num_logic_channels = num_logic_channels;
142 devc->logic_unitsize = (devc->num_logic_channels + 7) / 8;
143 devc->all_logic_channels_mask = 1UL << 0;
144 devc->all_logic_channels_mask <<= devc->num_logic_channels;
145 devc->all_logic_channels_mask--;
146 devc->logic_pattern = DEFAULT_LOGIC_PATTERN;
147 devc->num_analog_channels = num_analog_channels;
148 devc->limit_frames = limit_frames;
149 devc->capture_ratio = 20;
150 devc->stl = NULL;
151
152 if (num_logic_channels > 0) {
153 /* Logic channels, all in one channel group. */
154 cg = g_malloc0(sizeof(struct sr_channel_group));
155 cg->name = g_strdup("Logic");
156 for (i = 0; i < num_logic_channels; i++) {
157 sprintf(channel_name, "D%d", i);
158 ch = sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE, channel_name);
159 cg->channels = g_slist_append(cg->channels, ch);
160 }
161 sdi->channel_groups = g_slist_append(NULL, cg);
162 }
163
164 /* Analog channels, channel groups and pattern generators. */
165 devc->ch_ag = g_hash_table_new(g_direct_hash, g_direct_equal);
166 if (num_analog_channels > 0) {
167 /*
168 * Have the waveform for analog patterns pre-generated. It's
169 * supposed to be periodic, so the generator just needs to
170 * access the prepared sample data (DDS style).
171 */
172 demo_generate_analog_pattern(devc);
173
174 pattern = 0;
175 /* An "Analog" channel group with all analog channels in it. */
176 acg = g_malloc0(sizeof(struct sr_channel_group));
177 acg->name = g_strdup("Analog");
178 sdi->channel_groups = g_slist_append(sdi->channel_groups, acg);
179
180 for (i = 0; i < num_analog_channels; i++) {
181 snprintf(channel_name, 16, "A%d", i);
182 ch = sr_channel_new(sdi, i + num_logic_channels, SR_CHANNEL_ANALOG,
183 TRUE, channel_name);
184 acg->channels = g_slist_append(acg->channels, ch);
185
186 /* Every analog channel gets its own channel group as well. */
187 cg = g_malloc0(sizeof(struct sr_channel_group));
188 cg->name = g_strdup(channel_name);
189 cg->channels = g_slist_append(NULL, ch);
190 sdi->channel_groups = g_slist_append(sdi->channel_groups, cg);
191
192 /* Every channel gets a generator struct. */
193 ag = g_malloc(sizeof(struct analog_gen));
194 ag->ch = ch;
195 ag->mq = SR_MQ_VOLTAGE;
196 ag->mq_flags = SR_MQFLAG_DC;
197 ag->unit = SR_UNIT_VOLT;
198 ag->amplitude = DEFAULT_ANALOG_AMPLITUDE;
199 ag->offset = DEFAULT_ANALOG_OFFSET;
200 sr_analog_init(&ag->packet, &ag->encoding, &ag->meaning, &ag->spec, 2);
201 ag->packet.meaning->channels = cg->channels;
202 ag->packet.meaning->mq = ag->mq;
203 ag->packet.meaning->mqflags = ag->mq_flags;
204 ag->packet.meaning->unit = ag->unit;
205 ag->packet.encoding->digits = DEFAULT_ANALOG_ENCODING_DIGITS;
206 ag->packet.spec->spec_digits = DEFAULT_ANALOG_SPEC_DIGITS;
207 ag->packet.data = devc->analog_patterns[pattern];
208 ag->pattern = pattern;
209 ag->avg_val = 0.0f;
210 ag->num_avgs = 0;
211 g_hash_table_insert(devc->ch_ag, ch, ag);
212
213 if (++pattern == ARRAY_SIZE(analog_pattern_str))
214 pattern = 0;
215 }
216 }
217
218 sdi->priv = devc;
219
220 return std_scan_complete(di, g_slist_append(NULL, sdi));
221}
222
223static void clear_helper(struct dev_context *devc)
224{
225 GHashTableIter iter;
226 void *value;
227
228 demo_free_analog_pattern(devc);
229
230 /* Analog generators. */
231 g_hash_table_iter_init(&iter, devc->ch_ag);
232 while (g_hash_table_iter_next(&iter, NULL, &value))
233 g_free(value);
234 g_hash_table_unref(devc->ch_ag);
235}
236
237static int dev_clear(const struct sr_dev_driver *di)
238{
239 return std_dev_clear_with_callback(di, (std_dev_clear_callback)clear_helper);
240}
241
242static int config_get(uint32_t key, GVariant **data,
243 const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
244{
245 struct dev_context *devc;
246 struct sr_channel *ch;
247 struct analog_gen *ag;
248 GVariant *mq_arr[2];
249 int pattern;
250
251 if (!sdi)
252 return SR_ERR_ARG;
253
254 devc = sdi->priv;
255 switch (key) {
256 case SR_CONF_SAMPLERATE:
257 *data = g_variant_new_uint64(devc->cur_samplerate);
258 break;
259 case SR_CONF_LIMIT_SAMPLES:
260 *data = g_variant_new_uint64(devc->limit_samples);
261 break;
262 case SR_CONF_LIMIT_MSEC:
263 *data = g_variant_new_uint64(devc->limit_msec);
264 break;
265 case SR_CONF_LIMIT_FRAMES:
266 *data = g_variant_new_uint64(devc->limit_frames);
267 break;
268 case SR_CONF_AVERAGING:
269 *data = g_variant_new_boolean(devc->avg);
270 break;
271 case SR_CONF_AVG_SAMPLES:
272 *data = g_variant_new_uint64(devc->avg_samples);
273 break;
274 case SR_CONF_MEASURED_QUANTITY:
275 if (!cg)
276 return SR_ERR_CHANNEL_GROUP;
277 /* Any channel in the group will do. */
278 ch = cg->channels->data;
279 if (ch->type != SR_CHANNEL_ANALOG)
280 return SR_ERR_ARG;
281 ag = g_hash_table_lookup(devc->ch_ag, ch);
282 mq_arr[0] = g_variant_new_uint32(ag->mq);
283 mq_arr[1] = g_variant_new_uint64(ag->mq_flags);
284 *data = g_variant_new_tuple(mq_arr, 2);
285 break;
286 case SR_CONF_PATTERN_MODE:
287 if (!cg)
288 return SR_ERR_CHANNEL_GROUP;
289 /* Any channel in the group will do. */
290 ch = cg->channels->data;
291 if (ch->type == SR_CHANNEL_LOGIC) {
292 pattern = devc->logic_pattern;
293 *data = g_variant_new_string(logic_pattern_str[pattern]);
294 } else if (ch->type == SR_CHANNEL_ANALOG) {
295 ag = g_hash_table_lookup(devc->ch_ag, ch);
296 pattern = ag->pattern;
297 *data = g_variant_new_string(analog_pattern_str[pattern]);
298 } else
299 return SR_ERR_BUG;
300 break;
301 case SR_CONF_AMPLITUDE:
302 if (!cg)
303 return SR_ERR_CHANNEL_GROUP;
304 /* Any channel in the group will do. */
305 ch = cg->channels->data;
306 if (ch->type != SR_CHANNEL_ANALOG)
307 return SR_ERR_ARG;
308 ag = g_hash_table_lookup(devc->ch_ag, ch);
309 *data = g_variant_new_double(ag->amplitude);
310 break;
311 case SR_CONF_OFFSET:
312 if (!cg)
313 return SR_ERR_CHANNEL_GROUP;
314 /* Any channel in the group will do. */
315 ch = cg->channels->data;
316 if (ch->type != SR_CHANNEL_ANALOG)
317 return SR_ERR_ARG;
318 ag = g_hash_table_lookup(devc->ch_ag, ch);
319 *data = g_variant_new_double(ag->offset);
320 break;
321 case SR_CONF_CAPTURE_RATIO:
322 *data = g_variant_new_uint64(devc->capture_ratio);
323 break;
324 default:
325 return SR_ERR_NA;
326 }
327
328 return SR_OK;
329}
330
331static int config_set(uint32_t key, GVariant *data,
332 const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
333{
334 struct dev_context *devc;
335 struct analog_gen *ag;
336 struct sr_channel *ch;
337 GVariant *mq_tuple_child;
338 GSList *l;
339 int logic_pattern, analog_pattern;
340
341 devc = sdi->priv;
342
343 switch (key) {
344 case SR_CONF_SAMPLERATE:
345 devc->cur_samplerate = g_variant_get_uint64(data);
346 break;
347 case SR_CONF_LIMIT_SAMPLES:
348 devc->limit_msec = 0;
349 devc->limit_samples = g_variant_get_uint64(data);
350 break;
351 case SR_CONF_LIMIT_MSEC:
352 devc->limit_msec = g_variant_get_uint64(data);
353 devc->limit_samples = 0;
354 break;
355 case SR_CONF_LIMIT_FRAMES:
356 devc->limit_frames = g_variant_get_uint64(data);
357 break;
358 case SR_CONF_AVERAGING:
359 devc->avg = g_variant_get_boolean(data);
360 sr_dbg("%s averaging", devc->avg ? "Enabling" : "Disabling");
361 break;
362 case SR_CONF_AVG_SAMPLES:
363 devc->avg_samples = g_variant_get_uint64(data);
364 sr_dbg("Setting averaging rate to %" PRIu64, devc->avg_samples);
365 break;
366 case SR_CONF_MEASURED_QUANTITY:
367 if (!cg)
368 return SR_ERR_CHANNEL_GROUP;
369 for (l = cg->channels; l; l = l->next) {
370 ch = l->data;
371 if (ch->type != SR_CHANNEL_ANALOG)
372 return SR_ERR_ARG;
373 ag = g_hash_table_lookup(devc->ch_ag, ch);
374 mq_tuple_child = g_variant_get_child_value(data, 0);
375 ag->mq = g_variant_get_uint32(mq_tuple_child);
376 mq_tuple_child = g_variant_get_child_value(data, 1);
377 ag->mq_flags = g_variant_get_uint64(mq_tuple_child);
378 g_variant_unref(mq_tuple_child);
379 }
380 break;
381 case SR_CONF_PATTERN_MODE:
382 if (!cg)
383 return SR_ERR_CHANNEL_GROUP;
384 logic_pattern = std_str_idx(data, ARRAY_AND_SIZE(logic_pattern_str));
385 analog_pattern = std_str_idx(data, ARRAY_AND_SIZE(analog_pattern_str));
386 if (logic_pattern < 0 && analog_pattern < 0)
387 return SR_ERR_ARG;
388 for (l = cg->channels; l; l = l->next) {
389 ch = l->data;
390 if (ch->type == SR_CHANNEL_LOGIC) {
391 if (logic_pattern == -1)
392 return SR_ERR_ARG;
393 sr_dbg("Setting logic pattern to %s",
394 logic_pattern_str[logic_pattern]);
395 devc->logic_pattern = logic_pattern;
396 /* Might as well do this now, these are static. */
397 if (logic_pattern == PATTERN_ALL_LOW)
398 memset(devc->logic_data, 0x00, LOGIC_BUFSIZE);
399 else if (logic_pattern == PATTERN_ALL_HIGH)
400 memset(devc->logic_data, 0xff, LOGIC_BUFSIZE);
401 } else if (ch->type == SR_CHANNEL_ANALOG) {
402 if (analog_pattern == -1)
403 return SR_ERR_ARG;
404 sr_dbg("Setting analog pattern for channel %s to %s",
405 ch->name, analog_pattern_str[analog_pattern]);
406 ag = g_hash_table_lookup(devc->ch_ag, ch);
407 ag->pattern = analog_pattern;
408 } else
409 return SR_ERR_BUG;
410 }
411 break;
412 case SR_CONF_AMPLITUDE:
413 if (!cg)
414 return SR_ERR_CHANNEL_GROUP;
415 for (l = cg->channels; l; l = l->next) {
416 ch = l->data;
417 if (ch->type != SR_CHANNEL_ANALOG)
418 return SR_ERR_ARG;
419 ag = g_hash_table_lookup(devc->ch_ag, ch);
420 ag->amplitude = g_variant_get_double(data);
421 }
422 break;
423 case SR_CONF_OFFSET:
424 if (!cg)
425 return SR_ERR_CHANNEL_GROUP;
426 for (l = cg->channels; l; l = l->next) {
427 ch = l->data;
428 if (ch->type != SR_CHANNEL_ANALOG)
429 return SR_ERR_ARG;
430 ag = g_hash_table_lookup(devc->ch_ag, ch);
431 ag->offset = g_variant_get_double(data);
432 }
433 break;
434 case SR_CONF_CAPTURE_RATIO:
435 devc->capture_ratio = g_variant_get_uint64(data);
436 break;
437 default:
438 return SR_ERR_NA;
439 }
440
441 return SR_OK;
442}
443
444static int config_list(uint32_t key, GVariant **data,
445 const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
446{
447 struct sr_channel *ch;
448
449 if (!cg) {
450 switch (key) {
451 case SR_CONF_SCAN_OPTIONS:
452 case SR_CONF_DEVICE_OPTIONS:
453 return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
454 case SR_CONF_SAMPLERATE:
455 *data = std_gvar_samplerates_steps(ARRAY_AND_SIZE(samplerates));
456 break;
457 case SR_CONF_TRIGGER_MATCH:
458 *data = std_gvar_array_i32(ARRAY_AND_SIZE(trigger_matches));
459 break;
460 default:
461 return SR_ERR_NA;
462 }
463 } else {
464 ch = cg->channels->data;
465 switch (key) {
466 case SR_CONF_DEVICE_OPTIONS:
467 if (ch->type == SR_CHANNEL_LOGIC)
468 *data = std_gvar_array_u32(ARRAY_AND_SIZE(devopts_cg_logic));
469 else if (ch->type == SR_CHANNEL_ANALOG) {
470 if (strcmp(cg->name, "Analog") == 0)
471 *data = std_gvar_array_u32(ARRAY_AND_SIZE(devopts_cg_analog_group));
472 else
473 *data = std_gvar_array_u32(ARRAY_AND_SIZE(devopts_cg_analog_channel));
474 }
475 else
476 return SR_ERR_BUG;
477 break;
478 case SR_CONF_PATTERN_MODE:
479 /* The analog group (with all 4 channels) shall not have a pattern property. */
480 if (strcmp(cg->name, "Analog") == 0)
481 return SR_ERR_NA;
482
483 if (ch->type == SR_CHANNEL_LOGIC)
484 *data = g_variant_new_strv(ARRAY_AND_SIZE(logic_pattern_str));
485 else if (ch->type == SR_CHANNEL_ANALOG)
486 *data = g_variant_new_strv(ARRAY_AND_SIZE(analog_pattern_str));
487 else
488 return SR_ERR_BUG;
489 break;
490 default:
491 return SR_ERR_NA;
492 }
493 }
494
495 return SR_OK;
496}
497
498static int dev_acquisition_start(const struct sr_dev_inst *sdi)
499{
500 struct dev_context *devc;
501 GSList *l;
502 struct sr_channel *ch;
503 int bitpos;
504 uint8_t mask;
505 struct sr_trigger *trigger;
506
507 devc = sdi->priv;
508 devc->sent_samples = 0;
509 devc->sent_frame_samples = 0;
510
511 /* Setup triggers */
512 if ((trigger = sr_session_trigger_get(sdi->session))) {
513 int pre_trigger_samples = 0;
514 if (devc->limit_samples > 0)
515 pre_trigger_samples = (devc->capture_ratio * devc->limit_samples) / 100;
516 devc->stl = soft_trigger_logic_new(sdi, trigger, pre_trigger_samples);
517 if (!devc->stl)
518 return SR_ERR_MALLOC;
519
520 /* Disable all analog channels since using them when there are logic
521 * triggers set up would require having pre-trigger sample buffers
522 * for analog sample data.
523 */
524 for (l = sdi->channels; l; l = l->next) {
525 ch = l->data;
526 if (ch->type == SR_CHANNEL_ANALOG)
527 ch->enabled = FALSE;
528 }
529 }
530 devc->trigger_fired = FALSE;
531
532 /*
533 * Determine the numbers of logic and analog channels that are
534 * involved in the acquisition. Determine an offset and a mask to
535 * remove excess logic data content before datafeed submission.
536 */
537 devc->enabled_logic_channels = 0;
538 devc->enabled_analog_channels = 0;
539 for (l = sdi->channels; l; l = l->next) {
540 ch = l->data;
541 if (!ch->enabled)
542 continue;
543 if (ch->type == SR_CHANNEL_ANALOG) {
544 devc->enabled_analog_channels++;
545 continue;
546 }
547 if (ch->type != SR_CHANNEL_LOGIC)
548 continue;
549 /*
550 * TODO: Need we create a channel map here, such that the
551 * session datafeed packets will have a dense representation
552 * of the enabled channels' data? For example store channels
553 * D3 and D5 in bit positions 0 and 1 respectively, when all
554 * other channels are disabled? The current implementation
555 * generates a sparse layout, might provide data for logic
556 * channels that are disabled while it might suppress data
557 * from enabled channels at the same time.
558 */
559 devc->enabled_logic_channels++;
560 }
561 devc->first_partial_logic_index = devc->enabled_logic_channels / 8;
562 bitpos = devc->enabled_logic_channels % 8;
563 mask = (1 << bitpos) - 1;
564 devc->first_partial_logic_mask = mask;
565 sr_dbg("num logic %zu, partial off %zu, mask 0x%02x.",
566 devc->enabled_logic_channels,
567 devc->first_partial_logic_index,
568 devc->first_partial_logic_mask);
569
570 sr_session_source_add(sdi->session, -1, 0, 100,
571 demo_prepare_data, (struct sr_dev_inst *)sdi);
572
573 std_session_send_df_header(sdi);
574
575 if (devc->limit_frames > 0)
576 std_session_send_df_frame_begin(sdi);
577
578 /* We use this timestamp to decide how many more samples to send. */
579 devc->start_us = g_get_monotonic_time();
580 devc->spent_us = 0;
581 devc->step = 0;
582
583 return SR_OK;
584}
585
586static int dev_acquisition_stop(struct sr_dev_inst *sdi)
587{
588 struct dev_context *devc;
589
590 sr_session_source_remove(sdi->session, -1);
591
592 devc = sdi->priv;
593 if (devc->limit_frames > 0)
594 std_session_send_df_frame_end(sdi);
595
596 std_session_send_df_end(sdi);
597
598 if (devc->stl) {
599 soft_trigger_logic_free(devc->stl);
600 devc->stl = NULL;
601 }
602
603 return SR_OK;
604}
605
606static struct sr_dev_driver demo_driver_info = {
607 .name = "demo",
608 .longname = "Demo driver and pattern generator",
609 .api_version = 1,
610 .init = std_init,
611 .cleanup = std_cleanup,
612 .scan = scan,
613 .dev_list = std_dev_list,
614 .dev_clear = dev_clear,
615 .config_get = config_get,
616 .config_set = config_set,
617 .config_list = config_list,
618 .dev_open = std_dummy_dev_open,
619 .dev_close = std_dummy_dev_close,
620 .dev_acquisition_start = dev_acquisition_start,
621 .dev_acquisition_stop = dev_acquisition_stop,
622 .context = NULL,
623};
624SR_REGISTER_DEV_DRIVER(demo_driver_info);