]> sigrok.org Git - libsigrok.git/blame - src/hardware/chronovu-la/api.c
config_list: Don't check for sdi->priv != NULL.
[libsigrok.git] / src / hardware / chronovu-la / api.c
CommitLineData
b908f067 1/*
50985c20 2 * This file is part of the libsigrok project.
b908f067 3 *
67f890d5 4 * Copyright (C) 2011-2015 Uwe Hermann <uwe@hermann-uwe.de>
b908f067
UH
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
6ec6c43b 21#include <config.h>
45e080b6 22#include "protocol.h"
b908f067 23
7b356712
UH
24SR_PRIV struct sr_dev_driver chronovu_la_driver_info;
25static struct sr_dev_driver *di = &chronovu_la_driver_info;
b908f067 26
67f890d5 27static const uint32_t drvopts[] = {
1bec72d2 28 SR_CONF_LOGIC_ANALYZER,
67f890d5
UH
29};
30
31static const uint32_t scanopts[] = {
32 SR_CONF_CONN,
33};
34
35static const uint32_t devopts[] = {
5827f61b
BV
36 SR_CONF_LIMIT_MSEC | SR_CONF_SET,
37 SR_CONF_LIMIT_SAMPLES | SR_CONF_SET | SR_CONF_LIST,
67f890d5 38 SR_CONF_CONN | SR_CONF_GET,
5827f61b
BV
39 SR_CONF_SAMPLERATE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
40 SR_CONF_TRIGGER_MATCH | SR_CONF_LIST,
1bec72d2
BV
41};
42
aeff7fa2
BV
43static const int32_t trigger_matches[] = {
44 SR_TRIGGER_ZERO,
45 SR_TRIGGER_ONE,
46 SR_TRIGGER_RISING,
47 SR_TRIGGER_FALLING,
48};
49
695dc859 50static int dev_acquisition_stop(struct sr_dev_inst *sdi);
b908f067 51
97900799 52static void clear_helper(void *priv)
c4f3ed4b 53{
1644fb24 54 struct dev_context *devc;
b172c130 55
97900799 56 devc = priv;
1644fb24 57
97900799
UH
58 ftdi_free(devc->ftdic);
59 g_free(devc->final_buf);
60}
c4f3ed4b 61
4f840ce9 62static int dev_clear(const struct sr_dev_driver *di)
97900799
UH
63{
64 return std_dev_clear(di, clear_helper);
c4f3ed4b
BV
65}
66
67f890d5
UH
67static int add_device(int model, struct libusb_device_descriptor *des,
68 const char *serial_num, const char *connection_id,
69 libusb_device *usbdev, GSList **devices)
b908f067 70{
00910580
UH
71 int ret;
72 unsigned int i;
b908f067 73 struct sr_dev_inst *sdi;
1644fb24
BV
74 struct drv_context *drvc;
75 struct dev_context *devc;
c4f3ed4b 76
00910580 77 ret = SR_OK;
f3a35908 78
41812aca 79 drvc = di->context;
4b97c74e 80
1644fb24 81 /* Allocate memory for our private device context. */
f57d8ffe 82 devc = g_malloc0(sizeof(struct dev_context));
b908f067
UH
83
84 /* Set some sane defaults. */
00910580
UH
85 devc->prof = &cv_profiles[model];
86 devc->ftdic = NULL; /* Will be set in the open() API call. */
87 devc->cur_samplerate = 0; /* Set later (different for LA8/LA16). */
1644fb24
BV
88 devc->limit_msec = 0;
89 devc->limit_samples = 0;
1644fb24
BV
90 memset(devc->mangled_buf, 0, BS);
91 devc->final_buf = NULL;
00910580
UH
92 devc->trigger_pattern = 0x0000; /* Irrelevant, see trigger_mask. */
93 devc->trigger_mask = 0x0000; /* All channels: "don't care". */
94 devc->trigger_edgemask = 0x0000; /* All channels: "state triggered". */
1644fb24
BV
95 devc->trigger_found = 0;
96 devc->done = 0;
97 devc->block_counter = 0;
00910580 98 devc->divcount = 0;
67f890d5
UH
99 devc->usb_vid = des->idVendor;
100 devc->usb_pid = des->idProduct;
00910580 101 memset(devc->samplerates, 0, sizeof(uint64_t) * 255);
b908f067
UH
102
103 /* Allocate memory where we'll store the de-mangled data. */
1644fb24 104 if (!(devc->final_buf = g_try_malloc(SDRAM_SIZE))) {
b172c130 105 sr_err("Failed to allocate memory for sample buffer.");
00910580 106 ret = SR_ERR_MALLOC;
1644fb24 107 goto err_free_devc;
b908f067
UH
108 }
109
00910580
UH
110 /* We now know the device, set its max. samplerate as default. */
111 devc->cur_samplerate = devc->prof->max_samplerate;
b908f067
UH
112
113 /* Register the device with libsigrok. */
aac29cc1 114 sdi = g_malloc0(sizeof(struct sr_dev_inst));
45884333 115 sdi->status = SR_ST_INACTIVE;
0af636be
UH
116 sdi->vendor = g_strdup("ChronoVu");
117 sdi->model = g_strdup(devc->prof->modelname);
67f890d5
UH
118 sdi->serial_num = g_strdup(serial_num);
119 sdi->connection_id = g_strdup(connection_id);
120 sdi->conn = sr_usb_dev_inst_new(libusb_get_bus_number(usbdev),
121 libusb_get_device_address(usbdev), NULL);
f3a35908 122 sdi->driver = di;
1644fb24 123 sdi->priv = devc;
b908f067 124
5e23fcab
ML
125 for (i = 0; i < devc->prof->num_channels; i++)
126 sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE,
0f34cb47 127 cv_channel_names[i]);
87ca93c5 128
00910580 129 *devices = g_slist_append(*devices, sdi);
1644fb24 130 drvc->instances = g_slist_append(drvc->instances, sdi);
b908f067 131
65c8d48f
BV
132 if (ret == SR_OK)
133 return SR_OK;
b908f067 134
1644fb24
BV
135err_free_devc:
136 g_free(devc);
b908f067 137
00910580
UH
138 return ret;
139}
140
4f840ce9 141static GSList *scan(struct sr_dev_driver *di, GSList *options)
00910580 142{
67f890d5
UH
143 int i, ret, model;
144 struct drv_context *drvc;
145 GSList *devices, *conn_devices, *l;
146 struct sr_usb_dev_inst *usb;
147 struct sr_config *src;
148 struct libusb_device_descriptor des;
149 libusb_device **devlist;
150 struct libusb_device_handle *hdl;
151 const char *conn;
152 char product[64], serial_num[64], connection_id[64];
00910580 153
67f890d5
UH
154 drvc = di->context;
155 drvc->instances = NULL;
156
157 conn = NULL;
158 for (l = options; l; l = l->next) {
159 src = l->data;
160 switch (src->key) {
161 case SR_CONF_CONN:
162 conn = g_variant_get_string(src->data, NULL);
163 break;
164 }
00910580 165 }
67f890d5
UH
166 if (conn)
167 conn_devices = sr_usb_find(drvc->sr_ctx->libusb_ctx, conn);
168 else
169 conn_devices = NULL;
00910580 170
67f890d5
UH
171 devices = NULL;
172 libusb_get_device_list(drvc->sr_ctx->libusb_ctx, &devlist);
173
174 for (i = 0; devlist[i]; i++) {
175 if (conn) {
176 for (l = conn_devices; l; l = l->next) {
177 usb = l->data;
178 if (usb->bus == libusb_get_bus_number(devlist[i])
179 && usb->address == libusb_get_device_address(devlist[i]))
180 break;
181 }
182 if (!l)
183 /* This device matched none of the ones that
184 * matched the conn specification. */
185 continue;
186 }
187
188 libusb_get_device_descriptor(devlist[i], &des);
189
190 if ((ret = libusb_open(devlist[i], &hdl)) < 0)
191 continue;
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 if (!strcmp(product, "ChronoVu LA8")) {
218 model = 0;
219 } else if (!strcmp(product, "ChronoVu LA16")) {
220 model = 1;
221 } else {
222 sr_spew("Unknown iProduct string '%s'.", product);
223 continue;
224 }
225
226 sr_dbg("Found %s (%04x:%04x, %d.%d, %s).",
227 product, des.idVendor, des.idProduct,
228 libusb_get_bus_number(devlist[i]),
229 libusb_get_device_address(devlist[i]), connection_id);
230
231 if ((ret = add_device(model, &des, serial_num, connection_id,
232 devlist[i], &devices)) < 0) {
00910580 233 sr_dbg("Failed to add device: %d.", ret);
67f890d5 234 }
00910580
UH
235 }
236
67f890d5
UH
237 libusb_free_device_list(devlist, 1);
238 g_slist_free_full(conn_devices, (GDestroyNotify)sr_usb_dev_inst_free);
00910580
UH
239
240 return devices;
b908f067
UH
241}
242
6078d2c9 243static int dev_open(struct sr_dev_inst *sdi)
b908f067 244{
1644fb24 245 struct dev_context *devc;
25a0f108 246 int ret;
b908f067 247
61c90858 248 devc = sdi->priv;
b908f067 249
00910580
UH
250 /* Allocate memory for the FTDI context and initialize it. */
251 if (!(devc->ftdic = ftdi_new())) {
252 sr_err("Failed to initialize libftdi.");
253 return SR_ERR;
254 }
255
256 sr_dbg("Opening %s device (%04x:%04x).", devc->prof->modelname,
257 devc->usb_vid, devc->usb_pid);
b908f067
UH
258
259 /* Open the device. */
00910580
UH
260 if ((ret = ftdi_usb_open_desc(devc->ftdic, devc->usb_vid,
261 devc->usb_pid, devc->prof->iproduct, NULL)) < 0) {
b172c130
UH
262 sr_err("Failed to open FTDI device (%d): %s.",
263 ret, ftdi_get_error_string(devc->ftdic));
00910580 264 goto err_ftdi_free;
b908f067 265 }
f3a35908 266 sr_dbg("Device opened successfully.");
b908f067
UH
267
268 /* Purge RX/TX buffers in the FTDI chip. */
1644fb24 269 if ((ret = ftdi_usb_purge_buffers(devc->ftdic)) < 0) {
b172c130
UH
270 sr_err("Failed to purge FTDI buffers (%d): %s.",
271 ret, ftdi_get_error_string(devc->ftdic));
00910580 272 goto err_ftdi_free;
b908f067 273 }
f3a35908 274 sr_dbg("FTDI buffers purged successfully.");
b908f067
UH
275
276 /* Enable flow control in the FTDI chip. */
1644fb24 277 if ((ret = ftdi_setflowctrl(devc->ftdic, SIO_RTS_CTS_HS)) < 0) {
b172c130
UH
278 sr_err("Failed to enable FTDI flow control (%d): %s.",
279 ret, ftdi_get_error_string(devc->ftdic));
00910580 280 goto err_ftdi_free;
b908f067 281 }
f3a35908 282 sr_dbg("FTDI flow control enabled successfully.");
b908f067
UH
283
284 /* Wait 100ms. */
285 g_usleep(100 * 1000);
286
287 sdi->status = SR_ST_ACTIVE;
288
65c8d48f
BV
289 if (ret == SR_OK)
290 return SR_OK;
b908f067 291
00910580
UH
292err_ftdi_free:
293 ftdi_free(devc->ftdic); /* Close device (if open), free FTDI context. */
294 devc->ftdic = NULL;
295 return ret;
b908f067
UH
296}
297
6078d2c9 298static int dev_close(struct sr_dev_inst *sdi)
b908f067 299{
00910580 300 int ret;
1644fb24 301 struct dev_context *devc;
b908f067 302
00910580
UH
303 if (sdi->status != SR_ST_ACTIVE)
304 return SR_OK;
b908f067 305
00910580 306 devc = sdi->priv;
b908f067 307
00910580
UH
308 if (devc->ftdic && (ret = ftdi_usb_close(devc->ftdic)) < 0)
309 sr_err("Failed to close FTDI device (%d): %s.",
310 ret, ftdi_get_error_string(devc->ftdic));
b908f067
UH
311 sdi->status = SR_ST_INACTIVE;
312
b908f067
UH
313 return SR_OK;
314}
315
584560f1 316static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
53b4680f 317 const struct sr_channel_group *cg)
b908f067 318{
1644fb24 319 struct dev_context *devc;
67f890d5
UH
320 struct sr_usb_dev_inst *usb;
321 char str[128];
b908f067 322
53b4680f 323 (void)cg;
8f996b89 324
584560f1 325 switch (key) {
67f890d5
UH
326 case SR_CONF_CONN:
327 if (!sdi || !(usb = sdi->conn))
328 return SR_ERR_ARG;
329 snprintf(str, 128, "%d.%d", usb->bus, usb->address);
330 *data = g_variant_new_string(str);
331 break;
123e1313 332 case SR_CONF_SAMPLERATE:
709468ba 333 if (!sdi)
b172c130 334 return SR_ERR_BUG;
709468ba 335 devc = sdi->priv;
b172c130 336 *data = g_variant_new_uint64(devc->cur_samplerate);
b908f067 337 break;
cfe8a84d 338 default:
bd6fbf62 339 return SR_ERR_NA;
b908f067
UH
340 }
341
6a2761fd 342 return SR_OK;
b908f067
UH
343}
344
584560f1 345static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
53b4680f 346 const struct sr_channel_group *cg)
b908f067 347{
1644fb24 348 struct dev_context *devc;
b908f067 349
53b4680f 350 (void)cg;
8f996b89 351
e73ffd42
BV
352 if (sdi->status != SR_ST_ACTIVE)
353 return SR_ERR_DEV_CLOSED;
354
b0baddef 355 devc = sdi->priv;
b908f067 356
584560f1 357 switch (key) {
1953564a 358 case SR_CONF_SAMPLERATE:
00910580 359 if (cv_set_samplerate(sdi, g_variant_get_uint64(data)) < 0)
b908f067 360 return SR_ERR;
b908f067 361 break;
1953564a 362 case SR_CONF_LIMIT_MSEC:
b172c130
UH
363 if (g_variant_get_uint64(data) == 0)
364 return SR_ERR_ARG;
1bec72d2 365 devc->limit_msec = g_variant_get_uint64(data);
b908f067 366 break;
1953564a 367 case SR_CONF_LIMIT_SAMPLES:
b172c130
UH
368 if (g_variant_get_uint64(data) == 0)
369 return SR_ERR_ARG;
1bec72d2 370 devc->limit_samples = g_variant_get_uint64(data);
b908f067
UH
371 break;
372 default:
bd6fbf62 373 return SR_ERR_NA;
b908f067
UH
374 }
375
376 return SR_OK;
377}
378
584560f1 379static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
53b4680f 380 const struct sr_channel_group *cg)
a1c743fc 381{
f0de2dd0 382 GVariant *gvar, *grange[2];
1bec72d2 383 GVariantBuilder gvb;
00910580 384 struct dev_context *devc;
a1c743fc 385
53b4680f 386 (void)cg;
a1c743fc
BV
387
388 switch (key) {
67f890d5 389 case SR_CONF_SCAN_OPTIONS:
584560f1 390 *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
67f890d5
UH
391 scanopts, ARRAY_SIZE(scanopts), sizeof(uint32_t));
392 break;
393 case SR_CONF_DEVICE_OPTIONS:
394 if (!sdi)
395 *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
396 drvopts, ARRAY_SIZE(drvopts), sizeof(uint32_t));
397 else
398 *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
399 devopts, ARRAY_SIZE(devopts), sizeof(uint32_t));
9a6517d1 400 break;
a1c743fc 401 case SR_CONF_SAMPLERATE:
4d399734 402 if (!sdi)
00910580 403 return SR_ERR_BUG;
4d399734 404 devc = sdi->priv;
00910580 405 cv_fill_samplerates_if_needed(sdi);
1bec72d2
BV
406 g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
407 gvar = g_variant_new_fixed_array(G_VARIANT_TYPE("t"),
00910580
UH
408 devc->samplerates,
409 ARRAY_SIZE(devc->samplerates),
1bec72d2
BV
410 sizeof(uint64_t));
411 g_variant_builder_add(&gvb, "{sv}", "samplerates", gvar);
412 *data = g_variant_builder_end(&gvb);
a1c743fc 413 break;
f0de2dd0 414 case SR_CONF_LIMIT_SAMPLES:
69bdcd8b
UH
415 if (!sdi || !sdi->priv || !(devc = sdi->priv) || !devc->prof)
416 return SR_ERR_BUG;
f0de2dd0 417 grange[0] = g_variant_new_uint64(0);
69bdcd8b
UH
418 if (devc->prof->model == CHRONOVU_LA8)
419 grange[1] = g_variant_new_uint64(MAX_NUM_SAMPLES);
420 else
421 grange[1] = g_variant_new_uint64(MAX_NUM_SAMPLES / 2);
f0de2dd0
BV
422 *data = g_variant_new_tuple(grange, 2);
423 break;
aeff7fa2 424 case SR_CONF_TRIGGER_MATCH:
00910580 425 if (!sdi || !sdi->priv || !(devc = sdi->priv) || !devc->prof)
13dd25bd 426 return SR_ERR_BUG;
af945a66 427 *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
aeff7fa2
BV
428 trigger_matches, devc->prof->num_trigger_matches,
429 sizeof(int32_t));
c50277a6 430 break;
a1c743fc 431 default:
bd6fbf62 432 return SR_ERR_NA;
a1c743fc
BV
433 }
434
435 return SR_OK;
436}
437
b908f067
UH
438static int receive_data(int fd, int revents, void *cb_data)
439{
440 int i, ret;
441 struct sr_dev_inst *sdi;
1644fb24 442 struct dev_context *devc;
b908f067 443
b908f067
UH
444 (void)fd;
445 (void)revents;
446
447 if (!(sdi = cb_data)) {
b172c130 448 sr_err("cb_data was NULL.");
b908f067
UH
449 return FALSE;
450 }
451
1644fb24 452 if (!(devc = sdi->priv)) {
b172c130 453 sr_err("sdi->priv was NULL.");
b908f067
UH
454 return FALSE;
455 }
456
1644fb24 457 if (!devc->ftdic) {
b172c130 458 sr_err("devc->ftdic was NULL.");
b908f067
UH
459 return FALSE;
460 }
461
462 /* Get one block of data. */
b172c130
UH
463 if ((ret = cv_read_block(devc)) < 0) {
464 sr_err("Failed to read data block: %d.", ret);
695dc859 465 dev_acquisition_stop(sdi);
b908f067
UH
466 return FALSE;
467 }
468
469 /* We need to get exactly NUM_BLOCKS blocks (i.e. 8MB) of data. */
1644fb24
BV
470 if (devc->block_counter != (NUM_BLOCKS - 1)) {
471 devc->block_counter++;
b908f067
UH
472 return TRUE;
473 }
474
f3a35908 475 sr_dbg("Sampling finished, sending data to session bus now.");
b908f067 476
b0efc84e
UH
477 /*
478 * All data was received and demangled, send it to the session bus.
479 *
480 * Note: Due to the method how data is spread across the 8MByte of
481 * SDRAM, we can _not_ send it to the session bus in a streaming
482 * manner while we receive it. We have to receive and de-mangle the
483 * full 8MByte first, only then the whole buffer contains valid data.
484 */
b908f067 485 for (i = 0; i < NUM_BLOCKS; i++)
695dc859 486 cv_send_block_to_session_bus(sdi, i);
b908f067 487
695dc859 488 dev_acquisition_stop(sdi);
b908f067 489
b908f067
UH
490 return TRUE;
491}
492
695dc859 493static int dev_acquisition_start(const struct sr_dev_inst *sdi)
b908f067 494{
1644fb24 495 struct dev_context *devc;
00910580
UH
496 uint8_t buf[8];
497 int bytes_to_write, bytes_written;
b908f067 498
e73ffd42
BV
499 if (sdi->status != SR_ST_ACTIVE)
500 return SR_ERR_DEV_CLOSED;
501
208c1d35 502 devc = sdi->priv;
b908f067 503
1644fb24 504 if (!devc->ftdic) {
b172c130 505 sr_err("devc->ftdic was NULL.");
b908f067
UH
506 return SR_ERR_BUG;
507 }
508
00910580 509 devc->divcount = cv_samplerate_to_divcount(sdi, devc->cur_samplerate);
1644fb24 510 if (devc->divcount == 0xff) {
b172c130 511 sr_err("Invalid divcount/samplerate.");
b908f067
UH
512 return SR_ERR;
513 }
514
aeff7fa2
BV
515 if (cv_convert_trigger(sdi) != SR_OK) {
516 sr_err("Failed to configure trigger.");
014359e3
BV
517 return SR_ERR;
518 }
519
b908f067 520 /* Fill acquisition parameters into buf[]. */
00910580
UH
521 if (devc->prof->model == CHRONOVU_LA8) {
522 buf[0] = devc->divcount;
523 buf[1] = 0xff; /* This byte must always be 0xff. */
524 buf[2] = devc->trigger_pattern & 0xff;
525 buf[3] = devc->trigger_mask & 0xff;
526 bytes_to_write = 4;
527 } else {
528 buf[0] = devc->divcount;
529 buf[1] = 0xff; /* This byte must always be 0xff. */
530 buf[2] = (devc->trigger_pattern & 0xff00) >> 8; /* LSB */
531 buf[3] = (devc->trigger_pattern & 0x00ff) >> 0; /* MSB */
532 buf[4] = (devc->trigger_mask & 0xff00) >> 8; /* LSB */
533 buf[5] = (devc->trigger_mask & 0x00ff) >> 0; /* MSB */
534 buf[6] = (devc->trigger_edgemask & 0xff00) >> 8; /* LSB */
535 buf[7] = (devc->trigger_edgemask & 0x00ff) >> 0; /* MSB */
536 bytes_to_write = 8;
537 }
b908f067
UH
538
539 /* Start acquisition. */
00910580 540 bytes_written = cv_write(devc, buf, bytes_to_write);
b908f067 541
00910580
UH
542 if (bytes_written < 0 || bytes_written != bytes_to_write) {
543 sr_err("Acquisition failed to start.");
afc88319 544 return SR_ERR;
b908f067
UH
545 }
546
4afdfd46 547 sr_dbg("Hardware acquisition started successfully.");
b908f067 548
102f1239 549 std_session_send_df_header(sdi, LOG_PREFIX);
b908f067 550
b908f067 551 /* Time when we should be done (for detecting trigger timeouts). */
00910580
UH
552 devc->done = (devc->divcount + 1) * devc->prof->trigger_constant +
553 g_get_monotonic_time() + (10 * G_TIME_SPAN_SECOND);
1644fb24
BV
554 devc->block_counter = 0;
555 devc->trigger_found = 0;
b908f067 556
b172c130 557 /* Hook up a dummy handler to receive data from the device. */
c650d3ec 558 sr_session_source_add(sdi->session, -1, 0, 0, receive_data, (void *)sdi);
b908f067
UH
559
560 return SR_OK;
561}
562
695dc859 563static int dev_acquisition_stop(struct sr_dev_inst *sdi)
b908f067 564{
f3a35908 565 sr_dbg("Stopping acquisition.");
102f1239 566 sr_session_source_remove(sdi->session, -1);
3be42bc2 567 std_session_send_df_end(sdi, LOG_PREFIX);
b908f067
UH
568
569 return SR_OK;
570}
571
7b356712
UH
572SR_PRIV struct sr_dev_driver chronovu_la_driver_info = {
573 .name = "chronovu-la",
574 .longname = "ChronoVu LA8/LA16",
b908f067 575 .api_version = 1,
c2fdcc25 576 .init = std_init,
700d6b64 577 .cleanup = std_cleanup,
6078d2c9 578 .scan = scan,
c01bf34c 579 .dev_list = std_dev_list,
3b412e3a 580 .dev_clear = dev_clear,
035a1078
BV
581 .config_get = config_get,
582 .config_set = config_set,
a1c743fc 583 .config_list = config_list,
6078d2c9
UH
584 .dev_open = dev_open,
585 .dev_close = dev_close,
586 .dev_acquisition_start = dev_acquisition_start,
587 .dev_acquisition_stop = dev_acquisition_stop,
41812aca 588 .context = NULL,
b908f067 589};