]>
Commit | Line | Data |
---|---|---|
b908f067 UH |
1 | /* |
2 | * This file is part of the sigrok project. | |
3 | * | |
4 | * Copyright (C) 2011-2012 Uwe Hermann <uwe@hermann-uwe.de> | |
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 | ||
21 | #include <ftdi.h> | |
22 | #include <glib.h> | |
23 | #include <string.h> | |
45c59c8b BV |
24 | #include "libsigrok.h" |
25 | #include "libsigrok-internal.h" | |
b908f067 UH |
26 | #include "driver.h" |
27 | ||
765ef2f7 BV |
28 | SR_PRIV struct sr_dev_driver chronovu_la8_driver_info; |
29 | static struct sr_dev_driver *cdi = &chronovu_la8_driver_info; | |
b908f067 | 30 | |
74e5f12d UH |
31 | /* |
32 | * The ChronoVu LA8 can have multiple PIDs. Older versions shipped with | |
33 | * a standard FTDI USB VID/PID of 0403:6001, newer ones have 0403:8867. | |
34 | */ | |
35 | static const uint16_t usb_pids[] = { | |
36 | 0x6001, | |
37 | 0x8867, | |
38 | }; | |
39 | ||
b908f067 UH |
40 | /* Function prototypes. */ |
41 | static int hw_dev_acquisition_stop(int dev_index, void *cb_data); | |
42 | ||
c4f3ed4b BV |
43 | static void clear_instances(void) |
44 | { | |
45 | GSList *l; | |
46 | struct sr_dev_inst *sdi; | |
47 | struct context *ctx; | |
48 | ||
49 | /* Properly close all devices. */ | |
50 | for (l = cdi->instances; l; l = l->next) { | |
51 | if (!(sdi = l->data)) { | |
52 | /* Log error, but continue cleaning up the rest. */ | |
53 | sr_err("la8: %s: sdi was NULL, continuing", __func__); | |
54 | continue; | |
55 | } | |
56 | if (sdi->priv) { | |
57 | ctx = sdi->priv; | |
58 | ftdi_free(ctx->ftdic); | |
59 | g_free(ctx); | |
60 | } | |
61 | sr_dev_inst_free(sdi); | |
62 | } | |
63 | g_slist_free(cdi->instances); | |
64 | cdi->instances = NULL; | |
65 | ||
66 | } | |
67 | ||
40dda2c3 | 68 | static int hw_init(void) |
61136ea6 BV |
69 | { |
70 | ||
71 | /* Nothing to do. */ | |
72 | ||
73 | return SR_OK; | |
74 | } | |
75 | ||
c4f3ed4b | 76 | static GSList *hw_scan(GSList *options) |
b908f067 UH |
77 | { |
78 | int ret; | |
79 | struct sr_dev_inst *sdi; | |
80 | struct context *ctx; | |
c4f3ed4b BV |
81 | GSList *devices; |
82 | ||
83 | (void)options; | |
84 | devices = NULL; | |
b908f067 | 85 | |
b908f067 UH |
86 | /* Allocate memory for our private driver context. */ |
87 | if (!(ctx = g_try_malloc(sizeof(struct context)))) { | |
88 | sr_err("la8: %s: struct context malloc failed", __func__); | |
89 | goto err_free_nothing; | |
90 | } | |
91 | ||
92 | /* Set some sane defaults. */ | |
93 | ctx->ftdic = NULL; | |
94 | ctx->cur_samplerate = SR_MHZ(100); /* 100MHz == max. samplerate */ | |
95 | ctx->limit_msec = 0; | |
96 | ctx->limit_samples = 0; | |
97 | ctx->session_dev_id = NULL; | |
98 | memset(ctx->mangled_buf, 0, BS); | |
99 | ctx->final_buf = NULL; | |
100 | ctx->trigger_pattern = 0x00; /* Value irrelevant, see trigger_mask. */ | |
101 | ctx->trigger_mask = 0x00; /* All probes are "don't care". */ | |
102 | ctx->trigger_timeout = 10; /* Default to 10s trigger timeout. */ | |
103 | ctx->trigger_found = 0; | |
104 | ctx->done = 0; | |
105 | ctx->block_counter = 0; | |
106 | ctx->divcount = 0; /* 10ns sample period == 100MHz samplerate */ | |
d67b663e | 107 | ctx->usb_pid = 0; |
b908f067 UH |
108 | |
109 | /* Allocate memory where we'll store the de-mangled data. */ | |
110 | if (!(ctx->final_buf = g_try_malloc(SDRAM_SIZE))) { | |
111 | sr_err("la8: %s: final_buf malloc failed", __func__); | |
112 | goto err_free_ctx; | |
113 | } | |
114 | ||
115 | /* Allocate memory for the FTDI context (ftdic) and initialize it. */ | |
116 | if (!(ctx->ftdic = ftdi_new())) { | |
117 | sr_err("la8: %s: ftdi_new failed", __func__); | |
118 | goto err_free_final_buf; | |
119 | } | |
120 | ||
121 | /* Check for the device and temporarily open it. */ | |
74e5f12d UH |
122 | for (i = 0; i < ARRAY_SIZE(usb_pids); i++) { |
123 | sr_dbg("la8: Probing for VID/PID %04x:%04x.", USB_VENDOR_ID, | |
124 | usb_pids[i]); | |
125 | ret = ftdi_usb_open_desc(ctx->ftdic, USB_VENDOR_ID, | |
126 | usb_pids[i], USB_DESCRIPTION, NULL); | |
127 | if (ret == 0) { | |
128 | sr_dbg("la8: Found LA8 device (%04x:%04x).", | |
129 | USB_VENDOR_ID, usb_pids[i]); | |
130 | ctx->usb_pid = usb_pids[i]; | |
131 | } | |
b908f067 | 132 | } |
74e5f12d UH |
133 | |
134 | if (ctx->usb_pid == 0) | |
135 | goto err_free_ftdic; | |
b908f067 UH |
136 | |
137 | /* Register the device with libsigrok. */ | |
138 | sdi = sr_dev_inst_new(0, SR_ST_INITIALIZING, | |
139 | USB_VENDOR_NAME, USB_MODEL_NAME, USB_MODEL_VERSION); | |
140 | if (!sdi) { | |
141 | sr_err("la8: %s: sr_dev_inst_new failed", __func__); | |
142 | goto err_close_ftdic; | |
143 | } | |
144 | ||
145 | sdi->priv = ctx; | |
146 | ||
c4f3ed4b | 147 | devices = g_slist_append(devices, sdi); |
765ef2f7 | 148 | cdi->instances = g_slist_append(cdi->instances, sdi); |
b908f067 UH |
149 | |
150 | sr_spew("la8: Device init successful."); | |
151 | ||
152 | /* Close device. We'll reopen it again when we need it. */ | |
153 | (void) la8_close(ctx); /* Log, but ignore errors. */ | |
154 | ||
c4f3ed4b | 155 | return devices; |
b908f067 UH |
156 | |
157 | err_close_ftdic: | |
158 | (void) la8_close(ctx); /* Log, but ignore errors. */ | |
159 | err_free_ftdic: | |
160 | free(ctx->ftdic); /* NOT g_free()! */ | |
161 | err_free_final_buf: | |
162 | g_free(ctx->final_buf); | |
163 | err_free_ctx: | |
164 | g_free(ctx); | |
165 | err_free_nothing: | |
166 | ||
c4f3ed4b | 167 | return NULL; |
b908f067 UH |
168 | } |
169 | ||
170 | static int hw_dev_open(int dev_index) | |
171 | { | |
172 | int ret; | |
173 | struct sr_dev_inst *sdi; | |
174 | struct context *ctx; | |
175 | ||
765ef2f7 | 176 | if (!(sdi = sr_dev_inst_get(cdi->instances, dev_index))) { |
b908f067 UH |
177 | sr_err("la8: %s: sdi was NULL", __func__); |
178 | return SR_ERR_BUG; | |
179 | } | |
180 | ||
181 | if (!(ctx = sdi->priv)) { | |
182 | sr_err("la8: %s: sdi->priv was NULL", __func__); | |
183 | return SR_ERR_BUG; | |
184 | } | |
185 | ||
186 | sr_dbg("la8: Opening LA8 device (%04x:%04x).", USB_VENDOR_ID, | |
74e5f12d | 187 | ctx->usb_pid); |
b908f067 UH |
188 | |
189 | /* Open the device. */ | |
190 | if ((ret = ftdi_usb_open_desc(ctx->ftdic, USB_VENDOR_ID, | |
74e5f12d | 191 | ctx->usb_pid, USB_DESCRIPTION, NULL)) < 0) { |
b908f067 UH |
192 | sr_err("la8: %s: ftdi_usb_open_desc: (%d) %s", |
193 | __func__, ret, ftdi_get_error_string(ctx->ftdic)); | |
194 | (void) la8_close_usb_reset_sequencer(ctx); /* Ignore errors. */ | |
195 | return SR_ERR; | |
196 | } | |
197 | sr_dbg("la8: Device opened successfully."); | |
198 | ||
199 | /* Purge RX/TX buffers in the FTDI chip. */ | |
200 | if ((ret = ftdi_usb_purge_buffers(ctx->ftdic)) < 0) { | |
201 | sr_err("la8: %s: ftdi_usb_purge_buffers: (%d) %s", | |
202 | __func__, ret, ftdi_get_error_string(ctx->ftdic)); | |
203 | (void) la8_close_usb_reset_sequencer(ctx); /* Ignore errors. */ | |
204 | goto err_dev_open_close_ftdic; | |
205 | } | |
206 | sr_dbg("la8: FTDI buffers purged successfully."); | |
207 | ||
208 | /* Enable flow control in the FTDI chip. */ | |
209 | if ((ret = ftdi_setflowctrl(ctx->ftdic, SIO_RTS_CTS_HS)) < 0) { | |
210 | sr_err("la8: %s: ftdi_setflowcontrol: (%d) %s", | |
211 | __func__, ret, ftdi_get_error_string(ctx->ftdic)); | |
212 | (void) la8_close_usb_reset_sequencer(ctx); /* Ignore errors. */ | |
213 | goto err_dev_open_close_ftdic; | |
214 | } | |
215 | sr_dbg("la8: FTDI flow control enabled successfully."); | |
216 | ||
217 | /* Wait 100ms. */ | |
218 | g_usleep(100 * 1000); | |
219 | ||
220 | sdi->status = SR_ST_ACTIVE; | |
221 | ||
222 | return SR_OK; | |
223 | ||
224 | err_dev_open_close_ftdic: | |
225 | (void) la8_close(ctx); /* Log, but ignore errors. */ | |
226 | return SR_ERR; | |
227 | } | |
228 | ||
229 | static int hw_dev_close(int dev_index) | |
230 | { | |
231 | struct sr_dev_inst *sdi; | |
232 | struct context *ctx; | |
233 | ||
765ef2f7 | 234 | if (!(sdi = sr_dev_inst_get(cdi->instances, dev_index))) { |
b908f067 UH |
235 | sr_err("la8: %s: sdi was NULL", __func__); |
236 | return SR_ERR_BUG; | |
237 | } | |
238 | ||
239 | if (!(ctx = sdi->priv)) { | |
240 | sr_err("la8: %s: sdi->priv was NULL", __func__); | |
241 | return SR_ERR_BUG; | |
242 | } | |
243 | ||
244 | sr_dbg("la8: Closing device."); | |
245 | ||
246 | if (sdi->status == SR_ST_ACTIVE) { | |
247 | sr_dbg("la8: Status ACTIVE, closing device."); | |
248 | /* TODO: Really ignore errors here, or return SR_ERR? */ | |
249 | (void) la8_close_usb_reset_sequencer(ctx); /* Ignore errors. */ | |
250 | } else { | |
251 | sr_spew("la8: Status not ACTIVE, nothing to do."); | |
252 | } | |
253 | ||
254 | sdi->status = SR_ST_INACTIVE; | |
255 | ||
256 | sr_dbg("la8: Freeing sample buffer."); | |
257 | g_free(ctx->final_buf); | |
258 | ||
259 | return SR_OK; | |
260 | } | |
261 | ||
262 | static int hw_cleanup(void) | |
263 | { | |
b908f067 | 264 | |
c4f3ed4b | 265 | clear_instances(); |
b908f067 | 266 | |
c4f3ed4b | 267 | return SR_OK; |
b908f067 UH |
268 | } |
269 | ||
270 | static const void *hw_dev_info_get(int dev_index, int dev_info_id) | |
271 | { | |
272 | struct sr_dev_inst *sdi; | |
273 | struct context *ctx; | |
274 | const void *info; | |
275 | ||
765ef2f7 | 276 | if (!(sdi = sr_dev_inst_get(cdi->instances, dev_index))) { |
b908f067 UH |
277 | sr_err("la8: %s: sdi was NULL", __func__); |
278 | return NULL; | |
279 | } | |
280 | ||
281 | if (!(ctx = sdi->priv)) { | |
282 | sr_err("la8: %s: sdi->priv was NULL", __func__); | |
283 | return NULL; | |
284 | } | |
285 | ||
286 | sr_spew("la8: %s: dev_index %d, dev_info_id %d.", __func__, | |
287 | dev_index, dev_info_id); | |
288 | ||
289 | switch (dev_info_id) { | |
290 | case SR_DI_INST: | |
291 | info = sdi; | |
292 | sr_spew("la8: %s: Returning sdi.", __func__); | |
293 | break; | |
294 | case SR_DI_NUM_PROBES: | |
295 | info = GINT_TO_POINTER(NUM_PROBES); | |
296 | sr_spew("la8: %s: Returning number of probes: %d.", __func__, | |
297 | NUM_PROBES); | |
298 | break; | |
299 | case SR_DI_PROBE_NAMES: | |
300 | info = probe_names; | |
301 | sr_spew("la8: %s: Returning probenames.", __func__); | |
302 | break; | |
303 | case SR_DI_SAMPLERATES: | |
304 | fill_supported_samplerates_if_needed(); | |
305 | info = &samplerates; | |
306 | sr_spew("la8: %s: Returning samplerates.", __func__); | |
307 | break; | |
308 | case SR_DI_TRIGGER_TYPES: | |
43be303c | 309 | info = TRIGGER_TYPES; |
b908f067 UH |
310 | sr_spew("la8: %s: Returning trigger types: %s.", __func__, |
311 | TRIGGER_TYPES); | |
312 | break; | |
313 | case SR_DI_CUR_SAMPLERATE: | |
314 | info = &ctx->cur_samplerate; | |
315 | sr_spew("la8: %s: Returning samplerate: %" PRIu64 "Hz.", | |
316 | __func__, ctx->cur_samplerate); | |
317 | break; | |
318 | default: | |
319 | /* Unknown device info ID, return NULL. */ | |
320 | sr_err("la8: %s: Unknown device info ID", __func__); | |
321 | info = NULL; | |
322 | break; | |
323 | } | |
324 | ||
325 | return info; | |
326 | } | |
327 | ||
328 | static int hw_dev_status_get(int dev_index) | |
329 | { | |
330 | struct sr_dev_inst *sdi; | |
331 | ||
765ef2f7 | 332 | if (!(sdi = sr_dev_inst_get(cdi->instances, dev_index))) { |
b908f067 UH |
333 | sr_err("la8: %s: sdi was NULL, device not found", __func__); |
334 | return SR_ST_NOT_FOUND; | |
335 | } | |
336 | ||
337 | sr_dbg("la8: Returning status: %d.", sdi->status); | |
338 | ||
339 | return sdi->status; | |
340 | } | |
341 | ||
342 | static const int *hw_hwcap_get_all(void) | |
343 | { | |
344 | sr_spew("la8: Returning list of device capabilities."); | |
345 | ||
346 | return hwcaps; | |
347 | } | |
348 | ||
349 | static int hw_dev_config_set(int dev_index, int hwcap, const void *value) | |
350 | { | |
351 | struct sr_dev_inst *sdi; | |
352 | struct context *ctx; | |
353 | ||
765ef2f7 | 354 | if (!(sdi = sr_dev_inst_get(cdi->instances, dev_index))) { |
b908f067 UH |
355 | sr_err("la8: %s: sdi was NULL", __func__); |
356 | return SR_ERR_BUG; | |
357 | } | |
358 | ||
359 | if (!(ctx = sdi->priv)) { | |
360 | sr_err("la8: %s: sdi->priv was NULL", __func__); | |
361 | return SR_ERR_BUG; | |
362 | } | |
363 | ||
364 | sr_spew("la8: %s: dev_index %d, hwcap %d", __func__, dev_index, hwcap); | |
365 | ||
366 | switch (hwcap) { | |
367 | case SR_HWCAP_SAMPLERATE: | |
368 | if (set_samplerate(sdi, *(const uint64_t *)value) == SR_ERR) { | |
369 | sr_err("la8: %s: setting samplerate failed.", __func__); | |
370 | return SR_ERR; | |
371 | } | |
372 | sr_dbg("la8: SAMPLERATE = %" PRIu64, ctx->cur_samplerate); | |
373 | break; | |
374 | case SR_HWCAP_PROBECONFIG: | |
375 | if (configure_probes(ctx, (const GSList *)value) != SR_OK) { | |
376 | sr_err("la8: %s: probe config failed.", __func__); | |
377 | return SR_ERR; | |
378 | } | |
379 | break; | |
380 | case SR_HWCAP_LIMIT_MSEC: | |
381 | if (*(const uint64_t *)value == 0) { | |
382 | sr_err("la8: %s: LIMIT_MSEC can't be 0.", __func__); | |
383 | return SR_ERR; | |
384 | } | |
385 | ctx->limit_msec = *(const uint64_t *)value; | |
386 | sr_dbg("la8: LIMIT_MSEC = %" PRIu64, ctx->limit_msec); | |
387 | break; | |
388 | case SR_HWCAP_LIMIT_SAMPLES: | |
389 | if (*(const uint64_t *)value < MIN_NUM_SAMPLES) { | |
390 | sr_err("la8: %s: LIMIT_SAMPLES too small.", __func__); | |
391 | return SR_ERR; | |
392 | } | |
393 | ctx->limit_samples = *(const uint64_t *)value; | |
394 | sr_dbg("la8: LIMIT_SAMPLES = %" PRIu64, ctx->limit_samples); | |
395 | break; | |
396 | default: | |
397 | /* Unknown capability, return SR_ERR. */ | |
398 | sr_err("la8: %s: Unknown capability.", __func__); | |
399 | return SR_ERR; | |
400 | break; | |
401 | } | |
402 | ||
403 | return SR_OK; | |
404 | } | |
405 | ||
406 | static int receive_data(int fd, int revents, void *cb_data) | |
407 | { | |
408 | int i, ret; | |
409 | struct sr_dev_inst *sdi; | |
410 | struct context *ctx; | |
411 | ||
412 | /* Avoid compiler errors. */ | |
413 | (void)fd; | |
414 | (void)revents; | |
415 | ||
416 | if (!(sdi = cb_data)) { | |
417 | sr_err("la8: %s: cb_data was NULL", __func__); | |
418 | return FALSE; | |
419 | } | |
420 | ||
421 | if (!(ctx = sdi->priv)) { | |
422 | sr_err("la8: %s: sdi->priv was NULL", __func__); | |
423 | return FALSE; | |
424 | } | |
425 | ||
426 | if (!ctx->ftdic) { | |
427 | sr_err("la8: %s: ctx->ftdic was NULL", __func__); | |
428 | return FALSE; | |
429 | } | |
430 | ||
431 | /* Get one block of data. */ | |
432 | if ((ret = la8_read_block(ctx)) < 0) { | |
433 | sr_err("la8: %s: la8_read_block error: %d", __func__, ret); | |
434 | hw_dev_acquisition_stop(sdi->index, sdi); | |
435 | return FALSE; | |
436 | } | |
437 | ||
438 | /* We need to get exactly NUM_BLOCKS blocks (i.e. 8MB) of data. */ | |
439 | if (ctx->block_counter != (NUM_BLOCKS - 1)) { | |
440 | ctx->block_counter++; | |
441 | return TRUE; | |
442 | } | |
443 | ||
444 | sr_dbg("la8: Sampling finished, sending data to session bus now."); | |
445 | ||
446 | /* All data was received and demangled, send it to the session bus. */ | |
447 | for (i = 0; i < NUM_BLOCKS; i++) | |
448 | send_block_to_session_bus(ctx, i); | |
449 | ||
450 | hw_dev_acquisition_stop(sdi->index, sdi); | |
451 | ||
452 | // return FALSE; /* FIXME? */ | |
453 | return TRUE; | |
454 | } | |
455 | ||
456 | static int hw_dev_acquisition_start(int dev_index, void *cb_data) | |
457 | { | |
458 | struct sr_dev_inst *sdi; | |
459 | struct context *ctx; | |
460 | struct sr_datafeed_packet packet; | |
461 | struct sr_datafeed_header header; | |
462 | struct sr_datafeed_meta_logic meta; | |
463 | uint8_t buf[4]; | |
464 | int bytes_written; | |
465 | ||
765ef2f7 | 466 | if (!(sdi = sr_dev_inst_get(cdi->instances, dev_index))) { |
b908f067 UH |
467 | sr_err("la8: %s: sdi was NULL", __func__); |
468 | return SR_ERR_BUG; | |
469 | } | |
470 | ||
471 | if (!(ctx = sdi->priv)) { | |
472 | sr_err("la8: %s: sdi->priv was NULL", __func__); | |
473 | return SR_ERR_BUG; | |
474 | } | |
475 | ||
476 | if (!ctx->ftdic) { | |
477 | sr_err("la8: %s: ctx->ftdic was NULL", __func__); | |
478 | return SR_ERR_BUG; | |
479 | } | |
480 | ||
481 | ctx->divcount = samplerate_to_divcount(ctx->cur_samplerate); | |
482 | if (ctx->divcount == 0xff) { | |
483 | sr_err("la8: %s: invalid divcount/samplerate", __func__); | |
484 | return SR_ERR; | |
485 | } | |
486 | ||
487 | sr_dbg("la8: Starting acquisition."); | |
488 | ||
489 | /* Fill acquisition parameters into buf[]. */ | |
490 | buf[0] = ctx->divcount; | |
491 | buf[1] = 0xff; /* This byte must always be 0xff. */ | |
492 | buf[2] = ctx->trigger_pattern; | |
493 | buf[3] = ctx->trigger_mask; | |
494 | ||
495 | /* Start acquisition. */ | |
496 | bytes_written = la8_write(ctx, buf, 4); | |
497 | ||
498 | if (bytes_written < 0) { | |
499 | sr_err("la8: Acquisition failed to start."); | |
500 | return SR_ERR; | |
501 | } else if (bytes_written != 4) { | |
502 | sr_err("la8: Acquisition failed to start."); | |
503 | return SR_ERR; /* TODO: Other error and return code? */ | |
504 | } | |
505 | ||
506 | sr_dbg("la8: Acquisition started successfully."); | |
507 | ||
508 | ctx->session_dev_id = cb_data; | |
509 | ||
510 | /* Send header packet to the session bus. */ | |
511 | sr_dbg("la8: Sending SR_DF_HEADER."); | |
512 | packet.type = SR_DF_HEADER; | |
513 | packet.payload = &header; | |
514 | header.feed_version = 1; | |
515 | gettimeofday(&header.starttime, NULL); | |
516 | sr_session_send(ctx->session_dev_id, &packet); | |
517 | ||
518 | /* Send metadata about the SR_DF_LOGIC packets to come. */ | |
519 | packet.type = SR_DF_META_LOGIC; | |
520 | packet.payload = &meta; | |
521 | meta.samplerate = ctx->cur_samplerate; | |
522 | meta.num_probes = NUM_PROBES; | |
523 | sr_session_send(ctx->session_dev_id, &packet); | |
524 | ||
525 | /* Time when we should be done (for detecting trigger timeouts). */ | |
526 | ctx->done = (ctx->divcount + 1) * 0.08388608 + time(NULL) | |
527 | + ctx->trigger_timeout; | |
528 | ctx->block_counter = 0; | |
529 | ctx->trigger_found = 0; | |
530 | ||
531 | /* Hook up a dummy handler to receive data from the LA8. */ | |
532 | sr_source_add(-1, G_IO_IN, 0, receive_data, sdi); | |
533 | ||
534 | return SR_OK; | |
535 | } | |
536 | ||
537 | static int hw_dev_acquisition_stop(int dev_index, void *cb_data) | |
538 | { | |
539 | struct sr_dev_inst *sdi; | |
540 | struct context *ctx; | |
541 | struct sr_datafeed_packet packet; | |
542 | ||
543 | sr_dbg("la8: Stopping acquisition."); | |
544 | ||
765ef2f7 | 545 | if (!(sdi = sr_dev_inst_get(cdi->instances, dev_index))) { |
b908f067 UH |
546 | sr_err("la8: %s: sdi was NULL", __func__); |
547 | return SR_ERR_BUG; | |
548 | } | |
549 | ||
550 | if (!(ctx = sdi->priv)) { | |
551 | sr_err("la8: %s: sdi->priv was NULL", __func__); | |
552 | return SR_ERR_BUG; | |
553 | } | |
554 | ||
555 | /* Send end packet to the session bus. */ | |
556 | sr_dbg("la8: Sending SR_DF_END."); | |
557 | packet.type = SR_DF_END; | |
558 | sr_session_send(cb_data, &packet); | |
559 | ||
560 | return SR_OK; | |
561 | } | |
562 | ||
563 | SR_PRIV struct sr_dev_driver chronovu_la8_driver_info = { | |
564 | .name = "chronovu-la8", | |
565 | .longname = "ChronoVu LA8", | |
566 | .api_version = 1, | |
567 | .init = hw_init, | |
568 | .cleanup = hw_cleanup, | |
61136ea6 | 569 | .scan = hw_scan, |
b908f067 UH |
570 | .dev_open = hw_dev_open, |
571 | .dev_close = hw_dev_close, | |
572 | .dev_info_get = hw_dev_info_get, | |
573 | .dev_status_get = hw_dev_status_get, | |
574 | .hwcap_get_all = hw_hwcap_get_all, | |
575 | .dev_config_set = hw_dev_config_set, | |
576 | .dev_acquisition_start = hw_dev_acquisition_start, | |
577 | .dev_acquisition_stop = hw_dev_acquisition_stop, | |
765ef2f7 | 578 | .instances = NULL, |
b908f067 | 579 | }; |