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