]> sigrok.org Git - libsigrok.git/blame - src/hardware/dreamsourcelab-dslogic/api.c
dreamsourcelab-dslogic: Drop an unneeded dslogic_ prefix.
[libsigrok.git] / src / hardware / dreamsourcelab-dslogic / api.c
CommitLineData
adcb9951
JH
1/*
2 * This file is part of the libsigrok project.
3 *
4 * Copyright (C) 2013 Bert Vermeulen <bert@biot.com>
5 * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#include <config.h>
adcb9951 22#include <math.h>
4bd770f5 23#include "protocol.h"
adcb9951
JH
24
25static const struct dslogic_profile supported_device[] = {
6c317a8d 26 /* DreamSourceLab DSLogic */
adcb9951
JH
27 { 0x2a0e, 0x0001, "DreamSourceLab", "DSLogic", NULL,
28 "dreamsourcelab-dslogic-fx2.fw",
44b46d70 29 0, "DreamSourceLab", "DSLogic", 256 * 1024 * 1024},
6c317a8d 30 /* DreamSourceLab DSCope */
adcb9951
JH
31 { 0x2a0e, 0x0002, "DreamSourceLab", "DSCope", NULL,
32 "dreamsourcelab-dscope-fx2.fw",
44b46d70 33 0, "DreamSourceLab", "DSCope", 256 * 1024 * 1024},
6c317a8d 34 /* DreamSourceLab DSLogic Pro */
adcb9951
JH
35 { 0x2a0e, 0x0003, "DreamSourceLab", "DSLogic Pro", NULL,
36 "dreamsourcelab-dslogic-pro-fx2.fw",
44b46d70 37 0, "DreamSourceLab", "DSLogic", 256 * 1024 * 1024},
6c317a8d 38 /* DreamSourceLab DSLogic Plus */
adcb9951
JH
39 { 0x2a0e, 0x0020, "DreamSourceLab", "DSLogic Plus", NULL,
40 "dreamsourcelab-dslogic-plus-fx2.fw",
44b46d70 41 0, "DreamSourceLab", "DSLogic", 256 * 1024 * 1024},
6c317a8d 42 /* DreamSourceLab DSLogic Basic */
adcb9951
JH
43 { 0x2a0e, 0x0021, "DreamSourceLab", "DSLogic Basic", NULL,
44 "dreamsourcelab-dslogic-basic-fx2.fw",
44b46d70 45 0, "DreamSourceLab", "DSLogic", 256 * 1024},
adcb9951
JH
46
47 ALL_ZERO
48};
49
50static const uint32_t drvopts[] = {
51 SR_CONF_LOGIC_ANALYZER,
52};
53
54static const uint32_t scanopts[] = {
55 SR_CONF_CONN,
56};
57
58static const uint32_t devopts[] = {
59 SR_CONF_CONTINUOUS | SR_CONF_SET | SR_CONF_GET,
60 SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET,
61 SR_CONF_VOLTAGE_THRESHOLD | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
62 SR_CONF_CONN | SR_CONF_GET,
63 SR_CONF_SAMPLERATE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
64 SR_CONF_TRIGGER_MATCH | SR_CONF_LIST,
65 SR_CONF_CAPTURE_RATIO | SR_CONF_GET | SR_CONF_SET,
66 SR_CONF_EXTERNAL_CLOCK | SR_CONF_GET | SR_CONF_SET,
67 SR_CONF_CLOCK_EDGE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
68};
69
70/* Names assigned to available edge slope choices. */
71static const char *const signal_edge_names[] = {
72 [DS_EDGE_RISING] = "rising",
73 [DS_EDGE_FALLING] = "falling",
74};
75
76static const struct {
adcb9951
JH
77 gdouble low;
78 gdouble high;
7962b129 79} voltage_thresholds[] = {
1ee70746
JH
80 { 0.7, 1.4 },
81 { 1.4, 3.6 },
adcb9951
JH
82};
83
84static const uint64_t samplerates[] = {
85 SR_KHZ(10),
86 SR_KHZ(20),
87 SR_KHZ(50),
88 SR_KHZ(100),
89 SR_KHZ(200),
90 SR_KHZ(500),
91 SR_MHZ(1),
92 SR_MHZ(2),
93 SR_MHZ(5),
94 SR_MHZ(10),
95 SR_MHZ(20),
96 SR_MHZ(25),
97 SR_MHZ(50),
98 SR_MHZ(100),
99 SR_MHZ(200),
100 SR_MHZ(400),
101};
102
103static gboolean is_plausible(const struct libusb_device_descriptor *des)
104{
105 int i;
106
107 for (i = 0; supported_device[i].vid; i++) {
108 if (des->idVendor != supported_device[i].vid)
109 continue;
110 if (des->idProduct == supported_device[i].pid)
111 return TRUE;
112 }
113
114 return FALSE;
115}
116
117static GSList *scan(struct sr_dev_driver *di, GSList *options)
118{
119 struct drv_context *drvc;
120 struct dev_context *devc;
121 struct sr_dev_inst *sdi;
122 struct sr_usb_dev_inst *usb;
123 struct sr_channel *ch;
124 struct sr_channel_group *cg;
125 struct sr_config *src;
126 const struct dslogic_profile *prof;
127 GSList *l, *devices, *conn_devices;
128 gboolean has_firmware;
129 struct libusb_device_descriptor des;
130 libusb_device **devlist;
131 struct libusb_device_handle *hdl;
132 int ret, i, j;
133 const char *conn;
134 char manufacturer[64], product[64], serial_num[64], connection_id[64];
135 char channel_name[16];
136
137 drvc = di->context;
138
139 conn = NULL;
140 for (l = options; l; l = l->next) {
141 src = l->data;
142 switch (src->key) {
143 case SR_CONF_CONN:
144 conn = g_variant_get_string(src->data, NULL);
145 break;
146 }
147 }
148 if (conn)
149 conn_devices = sr_usb_find(drvc->sr_ctx->libusb_ctx, conn);
150 else
151 conn_devices = NULL;
152
44b46d70 153 /* Find all DSLogic compatible devices and upload firmware to them. */
adcb9951
JH
154 devices = NULL;
155 libusb_get_device_list(drvc->sr_ctx->libusb_ctx, &devlist);
156 for (i = 0; devlist[i]; i++) {
157 if (conn) {
158 usb = NULL;
159 for (l = conn_devices; l; l = l->next) {
160 usb = l->data;
161 if (usb->bus == libusb_get_bus_number(devlist[i])
162 && usb->address == libusb_get_device_address(devlist[i]))
163 break;
164 }
165 if (!l)
166 /* This device matched none of the ones that
167 * matched the conn specification. */
168 continue;
169 }
170
44b46d70 171 libusb_get_device_descriptor(devlist[i], &des);
adcb9951
JH
172
173 if (!is_plausible(&des))
174 continue;
175
176 if ((ret = libusb_open(devlist[i], &hdl)) < 0) {
177 sr_warn("Failed to open potential device with "
178 "VID:PID %04x:%04x: %s.", des.idVendor,
179 des.idProduct, libusb_error_name(ret));
180 continue;
181 }
182
183 if (des.iManufacturer == 0) {
184 manufacturer[0] = '\0';
185 } else if ((ret = libusb_get_string_descriptor_ascii(hdl,
186 des.iManufacturer, (unsigned char *) manufacturer,
187 sizeof(manufacturer))) < 0) {
188 sr_warn("Failed to get manufacturer string descriptor: %s.",
189 libusb_error_name(ret));
190 continue;
191 }
192
193 if (des.iProduct == 0) {
194 product[0] = '\0';
195 } else if ((ret = libusb_get_string_descriptor_ascii(hdl,
196 des.iProduct, (unsigned char *) product,
197 sizeof(product))) < 0) {
198 sr_warn("Failed to get product string descriptor: %s.",
199 libusb_error_name(ret));
200 continue;
201 }
202
203 if (des.iSerialNumber == 0) {
204 serial_num[0] = '\0';
205 } else if ((ret = libusb_get_string_descriptor_ascii(hdl,
206 des.iSerialNumber, (unsigned char *) serial_num,
207 sizeof(serial_num))) < 0) {
208 sr_warn("Failed to get serial number string descriptor: %s.",
209 libusb_error_name(ret));
210 continue;
211 }
212
213 usb_get_port_path(devlist[i], connection_id, sizeof(connection_id));
214
215 libusb_close(hdl);
216
217 prof = NULL;
218 for (j = 0; supported_device[j].vid; j++) {
219 if (des.idVendor == supported_device[j].vid &&
220 des.idProduct == supported_device[j].pid &&
6c317a8d
JH
221 (!strcmp(manufacturer, supported_device[j].usb_manufacturer)) &&
222 (!strcmp(product, "USB-based Instrument") ||
223 !strcmp(product, supported_device[j].usb_product))) {
adcb9951
JH
224 prof = &supported_device[j];
225 break;
226 }
227 }
228
229 /* Skip if the device was not found. */
230 if (!prof)
231 continue;
232
233 sdi = g_malloc0(sizeof(struct sr_dev_inst));
234 sdi->status = SR_ST_INITIALIZING;
235 sdi->vendor = g_strdup(prof->vendor);
236 sdi->model = g_strdup(prof->model);
237 sdi->version = g_strdup(prof->model_version);
238 sdi->serial_num = g_strdup(serial_num);
239 sdi->connection_id = g_strdup(connection_id);
240
241 /* Logic channels, all in one channel group. */
242 cg = g_malloc0(sizeof(struct sr_channel_group));
243 cg->name = g_strdup("Logic");
244 for (j = 0; j < 16; j++) {
84f6d40a 245 sprintf(channel_name, "%d", j);
adcb9951
JH
246 ch = sr_channel_new(sdi, j, SR_CHANNEL_LOGIC,
247 TRUE, channel_name);
248 cg->channels = g_slist_append(cg->channels, ch);
249 }
250 sdi->channel_groups = g_slist_append(NULL, cg);
251
252 devc = dslogic_dev_new();
253 devc->profile = prof;
254 sdi->priv = devc;
255 devices = g_slist_append(devices, sdi);
256
257 devc->samplerates = samplerates;
258 devc->num_samplerates = ARRAY_SIZE(samplerates);
3c749da1 259 has_firmware = usb_match_manuf_prod(devlist[i], "DreamSourceLab", "USB-based Instrument");
adcb9951
JH
260
261 if (has_firmware) {
262 /* Already has the firmware, so fix the new address. */
44b46d70 263 sr_dbg("Found a DSLogic device.");
adcb9951
JH
264 sdi->status = SR_ST_INACTIVE;
265 sdi->inst_type = SR_INST_USB;
266 sdi->conn = sr_usb_dev_inst_new(libusb_get_bus_number(devlist[i]),
267 libusb_get_device_address(devlist[i]), NULL);
268 } else {
269 if (ezusb_upload_firmware(drvc->sr_ctx, devlist[i],
270 USB_CONFIGURATION, prof->firmware) == SR_OK)
271 /* Store when this device's FW was updated. */
272 devc->fw_updated = g_get_monotonic_time();
273 else
274 sr_err("Firmware upload failed for "
275 "device %d.%d (logical).",
276 libusb_get_bus_number(devlist[i]),
277 libusb_get_device_address(devlist[i]));
278 sdi->inst_type = SR_INST_USB;
279 sdi->conn = sr_usb_dev_inst_new(libusb_get_bus_number(devlist[i]),
280 0xff, NULL);
281 }
282 }
283 libusb_free_device_list(devlist, 1);
284 g_slist_free_full(conn_devices, (GDestroyNotify)sr_usb_dev_inst_free);
285
286 return std_scan_complete(di, devices);
287}
288
289static void clear_dev_context(void *priv)
290{
291 struct dev_context *devc;
292
293 devc = priv;
294 g_free(devc);
295}
296
297static int dev_clear(const struct sr_dev_driver *di)
298{
299 return std_dev_clear(di, clear_dev_context);
300}
301
302static int dev_open(struct sr_dev_inst *sdi)
303{
304 struct sr_dev_driver *di = sdi->driver;
305 struct sr_usb_dev_inst *usb;
306 struct dev_context *devc;
adcb9951
JH
307 int ret;
308 int64_t timediff_us, timediff_ms;
309
310 devc = sdi->priv;
311 usb = sdi->conn;
312
313 /*
314 * If the firmware was recently uploaded, wait up to MAX_RENUM_DELAY_MS
315 * milliseconds for the FX2 to renumerate.
316 */
317 ret = SR_ERR;
318 if (devc->fw_updated > 0) {
319 sr_info("Waiting for device to reset.");
320 /* Takes >= 300ms for the FX2 to be gone from the USB bus. */
321 g_usleep(300 * 1000);
322 timediff_ms = 0;
323 while (timediff_ms < MAX_RENUM_DELAY_MS) {
324 if ((ret = dslogic_dev_open(sdi, di)) == SR_OK)
325 break;
326 g_usleep(100 * 1000);
327
328 timediff_us = g_get_monotonic_time() - devc->fw_updated;
329 timediff_ms = timediff_us / 1000;
330 sr_spew("Waited %" PRIi64 "ms.", timediff_ms);
331 }
332 if (ret != SR_OK) {
333 sr_err("Device failed to renumerate.");
334 return SR_ERR;
335 }
336 sr_info("Device came back after %" PRIi64 "ms.", timediff_ms);
337 } else {
338 sr_info("Firmware upload was not needed.");
339 ret = dslogic_dev_open(sdi, di);
340 }
341
342 if (ret != SR_OK) {
343 sr_err("Unable to open device.");
344 return SR_ERR;
345 }
346
347 ret = libusb_claim_interface(usb->devhdl, USB_INTERFACE);
348 if (ret != 0) {
349 switch (ret) {
350 case LIBUSB_ERROR_BUSY:
351 sr_err("Unable to claim USB interface. Another "
352 "program or driver has already claimed it.");
353 break;
354 case LIBUSB_ERROR_NO_DEVICE:
355 sr_err("Device has been disconnected.");
356 break;
357 default:
358 sr_err("Unable to claim interface: %s.",
359 libusb_error_name(ret));
360 break;
361 }
362
363 return SR_ERR;
364 }
365
adcb9951 366
3566348b 367 if ((ret = dslogic_fpga_firmware_upload(sdi)) != SR_OK)
adcb9951
JH
368 return ret;
369
370 if (devc->cur_samplerate == 0) {
371 /* Samplerate hasn't been set; default to the slowest one. */
372 devc->cur_samplerate = devc->samplerates[0];
373 }
374
1ee70746
JH
375 if (devc->cur_threshold == 0.0)
376 devc->cur_threshold = 1.5;
377
adcb9951
JH
378 return SR_OK;
379}
380
381static int dev_close(struct sr_dev_inst *sdi)
382{
383 struct sr_usb_dev_inst *usb;
384
385 usb = sdi->conn;
386
387 if (!usb->devhdl)
388 return SR_ERR;
389
44b46d70 390 sr_info("Closing device on %d.%d (logical) / %s (physical) interface %d.",
adcb9951
JH
391 usb->bus, usb->address, sdi->connection_id, USB_INTERFACE);
392 libusb_release_interface(usb->devhdl, USB_INTERFACE);
393 libusb_close(usb->devhdl);
394 usb->devhdl = NULL;
395 sdi->status = SR_ST_INACTIVE;
396
397 return SR_OK;
398}
399
400static int config_get(uint32_t key, GVariant **data,
401 const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
402{
403 struct dev_context *devc;
404 struct sr_usb_dev_inst *usb;
405 GVariant *range[2];
1ee70746 406 unsigned int i, voltage_range;
adcb9951
JH
407 char str[128];
408
409 (void)cg;
410
411 if (!sdi)
412 return SR_ERR_ARG;
413
414 devc = sdi->priv;
415
416 switch (key) {
417 case SR_CONF_CONN:
418 if (!sdi->conn)
419 return SR_ERR_ARG;
420 usb = sdi->conn;
421 if (usb->address == 255)
422 /* Device still needs to re-enumerate after firmware
423 * upload, so we don't know its (future) address. */
424 return SR_ERR;
425 snprintf(str, 128, "%d.%d", usb->bus, usb->address);
426 *data = g_variant_new_string(str);
427 break;
428 case SR_CONF_VOLTAGE_THRESHOLD:
1ee70746
JH
429 if (!strcmp(devc->profile->model, "DSLogic")) {
430 voltage_range = 0;
431
7962b129
UH
432 for (i = 0; i < ARRAY_SIZE(voltage_thresholds); i++)
433 if (voltage_thresholds[i].low == devc->cur_threshold) {
1ee70746
JH
434 voltage_range = i;
435 break;
436 }
437
438 range[0] = g_variant_new_double(
7962b129 439 voltage_thresholds[voltage_range].low);
1ee70746 440 range[1] = g_variant_new_double(
7962b129 441 voltage_thresholds[voltage_range].high);
1ee70746
JH
442 } else {
443 range[0] = g_variant_new_double(devc->cur_threshold);
444 range[1] = g_variant_new_double(devc->cur_threshold);
adcb9951 445 }
1ee70746 446 *data = g_variant_new_tuple(range, 2);
adcb9951
JH
447 break;
448 case SR_CONF_LIMIT_SAMPLES:
449 *data = g_variant_new_uint64(devc->limit_samples);
450 break;
451 case SR_CONF_SAMPLERATE:
452 *data = g_variant_new_uint64(devc->cur_samplerate);
453 break;
454 case SR_CONF_CAPTURE_RATIO:
455 *data = g_variant_new_uint64(devc->capture_ratio);
456 break;
457 case SR_CONF_EXTERNAL_CLOCK:
458 *data = g_variant_new_boolean(devc->external_clock);
459 break;
460 case SR_CONF_CONTINUOUS:
461 *data = g_variant_new_boolean(devc->continuous_mode);
462 break;
463 case SR_CONF_CLOCK_EDGE:
464 i = devc->clock_edge;
465 if (i >= ARRAY_SIZE(signal_edge_names))
466 return SR_ERR_BUG;
467 *data = g_variant_new_string(signal_edge_names[0]);
468 break;
469 default:
470 return SR_ERR_NA;
471 }
472
473 return SR_OK;
474}
475
476/*
477 * Helper for mapping a string-typed configuration value to an index
478 * within a table of possible values.
479 */
480static int lookup_index(GVariant *value, const char *const *table, int len)
481{
482 const char *entry;
483 int i;
484
485 entry = g_variant_get_string(value, NULL);
486 if (!entry)
487 return -1;
488
489 /* Linear search is fine for very small tables. */
490 for (i = 0; i < len; i++) {
491 if (strcmp(entry, table[i]) == 0)
492 return i;
493 }
494
495 return -1;
496}
497
498static int config_set(uint32_t key, GVariant *data,
499 const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
500{
501 struct dev_context *devc;
502 uint64_t arg;
503 int i, ret;
504 gdouble low, high;
505
506 (void)cg;
507
508 if (!sdi)
509 return SR_ERR_ARG;
510
511 if (sdi->status != SR_ST_ACTIVE)
512 return SR_ERR;
513
514 devc = sdi->priv;
515
516 ret = SR_OK;
517
518 switch (key) {
519 case SR_CONF_SAMPLERATE:
520 arg = g_variant_get_uint64(data);
521 for (i = 0; i < devc->num_samplerates; i++) {
522 if (devc->samplerates[i] == arg) {
523 devc->cur_samplerate = arg;
524 break;
525 }
526 }
527 if (i == devc->num_samplerates)
528 ret = SR_ERR_ARG;
529 break;
530 case SR_CONF_LIMIT_SAMPLES:
531 devc->limit_samples = g_variant_get_uint64(data);
532 break;
533 case SR_CONF_CAPTURE_RATIO:
534 devc->capture_ratio = g_variant_get_uint64(data);
535 ret = (devc->capture_ratio > 100) ? SR_ERR : SR_OK;
536 break;
537 case SR_CONF_VOLTAGE_THRESHOLD:
538 g_variant_get(data, "(dd)", &low, &high);
1ee70746 539 if (!strcmp(devc->profile->model, "DSLogic")) {
7962b129
UH
540 for (i = 0; (unsigned int)i < ARRAY_SIZE(voltage_thresholds); i++) {
541 if (fabs(voltage_thresholds[i].low - low) < 0.1 &&
542 fabs(voltage_thresholds[i].high - high) < 0.1) {
1ee70746 543 devc->cur_threshold =
7962b129 544 voltage_thresholds[i].low;
1ee70746
JH
545 break;
546 }
adcb9951 547 }
1ee70746
JH
548 ret = dslogic_fpga_firmware_upload(sdi);
549 } else {
550 ret = dslogic_set_voltage_threshold(sdi, (low + high) / 2.0);
adcb9951 551 }
adcb9951
JH
552 break;
553 case SR_CONF_EXTERNAL_CLOCK:
554 devc->external_clock = g_variant_get_boolean(data);
555 break;
556 case SR_CONF_CONTINUOUS:
557 devc->continuous_mode = g_variant_get_boolean(data);
558 break;
559 case SR_CONF_CLOCK_EDGE:
560 i = lookup_index(data, signal_edge_names,
561 ARRAY_SIZE(signal_edge_names));
562 if (i < 0)
563 return SR_ERR_ARG;
564 devc->clock_edge = i;
565 break;
566 default:
567 ret = SR_ERR_NA;
568 }
569
570 return ret;
571}
572
573static int config_list(uint32_t key, GVariant **data,
574 const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
575{
1ee70746 576 struct dev_context *devc = NULL;
adcb9951
JH
577 GVariant *gvar, *range[2];
578 GVariantBuilder gvb;
579 unsigned int i;
1ee70746 580 double v;
adcb9951
JH
581
582 (void)cg;
583
584 switch (key) {
585 case SR_CONF_SCAN_OPTIONS:
586 *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
587 scanopts, ARRAY_SIZE(scanopts), sizeof(uint32_t));
588 break;
589 case SR_CONF_DEVICE_OPTIONS:
590 if (!sdi) {
591 *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
592 drvopts, ARRAY_SIZE(drvopts), sizeof(uint32_t));
593 } else {
594 devc = sdi->priv;
595 *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
596 devopts, ARRAY_SIZE(devopts), sizeof(uint32_t));
597 }
598 break;
599 case SR_CONF_VOLTAGE_THRESHOLD:
1ee70746
JH
600 if (sdi->priv)
601 devc = sdi->priv;
adcb9951 602 g_variant_builder_init(&gvb, G_VARIANT_TYPE_ARRAY);
1ee70746 603 if (devc && !strcmp(devc->profile->model, "DSLogic")) {
7962b129
UH
604 for (i = 0; i < ARRAY_SIZE(voltage_thresholds); i++) {
605 range[0] = g_variant_new_double(voltage_thresholds[i].low);
606 range[1] = g_variant_new_double(voltage_thresholds[i].high);
1ee70746
JH
607 gvar = g_variant_new_tuple(range, 2);
608 g_variant_builder_add_value(&gvb, gvar);
609 }
610 } else {
611 for (v = 0.0; v <= 5.0; v += 0.1) {
612 range[0] = g_variant_new_double(v);
613 range[1] = g_variant_new_double(v);
614 gvar = g_variant_new_tuple(range, 2);
615 g_variant_builder_add_value(&gvb, gvar);
616 }
adcb9951
JH
617 }
618 *data = g_variant_builder_end(&gvb);
619 break;
620 case SR_CONF_SAMPLERATE:
621 devc = sdi->priv;
622 g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
623 gvar = g_variant_new_fixed_array(G_VARIANT_TYPE("t"), devc->samplerates,
624 devc->num_samplerates, sizeof(uint64_t));
625 g_variant_builder_add(&gvb, "{sv}", "samplerates", gvar);
626 *data = g_variant_builder_end(&gvb);
627 break;
628 case SR_CONF_CLOCK_EDGE:
629 *data = g_variant_new_strv(signal_edge_names,
630 ARRAY_SIZE(signal_edge_names));
631 break;
632 default:
633 return SR_ERR_NA;
634 }
635
636 return SR_OK;
637}
638
44b46d70
UH
639static struct sr_dev_driver dreamsourcelab_dslogic_driver_info = {
640 .name = "dreamsourcelab-dslogic",
641 .longname = "DreamSourceLab DSLogic",
adcb9951
JH
642 .api_version = 1,
643 .init = std_init,
644 .cleanup = std_cleanup,
645 .scan = scan,
646 .dev_list = std_dev_list,
647 .dev_clear = dev_clear,
648 .config_get = config_get,
649 .config_set = config_set,
650 .config_list = config_list,
651 .dev_open = dev_open,
652 .dev_close = dev_close,
4bd770f5
JH
653 .dev_acquisition_start = dslogic_acquisition_start,
654 .dev_acquisition_stop = dslogic_acquisition_stop,
adcb9951
JH
655 .context = NULL,
656};
44b46d70 657SR_REGISTER_DEV_DRIVER(dreamsourcelab_dslogic_driver_info);