2 * This file is part of the sigrok project.
4 * Copyright (C) 2010-2012 Bert Vermeulen <bert@biot.com>
5 * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
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.
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.
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/>.
27 #include "libsigrok.h"
28 #include "libsigrok-internal.h"
32 static const struct fx2lafw_profile supported_fx2[] = {
35 * EE Electronics ESLA201A
38 { 0x08a9, 0x0014, "CWAV", "USBee AX", NULL,
39 FIRMWARE_DIR "/fx2lafw-cwav-usbeeax.fw",
45 { 0x08a9, 0x0015, "CWAV", "USBee DX", NULL,
46 FIRMWARE_DIR "/fx2lafw-cwav-usbeedx.fw",
52 { 0x08a9, 0x0009, "CWAV", "USBee SX", NULL,
53 FIRMWARE_DIR "/fx2lafw-cwav-usbeesx.fw",
58 * EE Electronics ESLA100
60 * Robomotic BugLogic 3
62 { 0x0925, 0x3881, "Saleae", "Logic", NULL,
63 FIRMWARE_DIR "/fx2lafw-saleae-logic.fw",
67 * Default Cypress FX2 without EEPROM, e.g.:
69 * Braintechnology USB Interface V2.x
71 { 0x04B4, 0x8613, "Cypress", "FX2", NULL,
72 FIRMWARE_DIR "/fx2lafw-cypress-fx2.fw",
76 * Braintechnology USB-LPS
78 { 0x16d0, 0x0498, "Braintechnology", "USB-LPS", NULL,
79 FIRMWARE_DIR "/fx2lafw-braintechnology-usb-lps.fw",
82 { 0, 0, 0, 0, 0, 0, 0 }
85 static const int hwcaps[] = {
86 SR_HWCAP_LOGIC_ANALYZER,
89 /* These are really implemented in the driver, not the hardware. */
90 SR_HWCAP_LIMIT_SAMPLES,
96 * TODO: Different probe_names[] for each supported device.
98 static const char *probe_names[] = {
118 static const uint64_t supported_samplerates[] = {
138 static const struct sr_samplerates samplerates = {
142 supported_samplerates,
145 static GSList *dev_insts = NULL;
146 static libusb_context *usb_context = NULL;
148 static int hw_dev_config_set(int dev_index, int hwcap, const void *value);
149 static int hw_dev_acquisition_stop(int dev_index, void *cb_data);
152 * Check the USB configuration to determine if this is an fx2lafw device.
154 * @return TRUE if the device's configuration profile match fx2lafw
155 * configuration, FALSE otherwise.
157 static gboolean check_conf_profile(libusb_device *dev)
159 struct libusb_device_descriptor des;
160 struct libusb_device_handle *hdl;
162 unsigned char strdesc[64];
167 /* Assume the FW has not been loaded, unless proven wrong. */
168 if (libusb_get_device_descriptor(dev, &des) != 0)
171 if (libusb_open(dev, &hdl) != 0)
174 if (libusb_get_string_descriptor_ascii(hdl,
175 des.iManufacturer, strdesc, sizeof(strdesc)) < 0)
177 if (strncmp((const char *)strdesc, "sigrok", 6))
180 if (libusb_get_string_descriptor_ascii(hdl,
181 des.iProduct, strdesc, sizeof(strdesc)) < 0)
183 if (strncmp((const char *)strdesc, "fx2lafw", 7))
186 /* If we made it here, it must be an fx2lafw. */
195 static int fx2lafw_dev_open(int dev_index)
197 libusb_device **devlist;
198 struct libusb_device_descriptor des;
199 struct sr_dev_inst *sdi;
201 struct version_info vi;
205 if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
209 if (sdi->status == SR_ST_ACTIVE)
214 const int device_count = libusb_get_device_list(usb_context, &devlist);
215 if (device_count < 0) {
216 sr_err("fx2lafw: Failed to retrieve device list (%d)",
221 for (i = 0; i < device_count; i++) {
222 if ((ret = libusb_get_device_descriptor(devlist[i], &des))) {
223 sr_err("fx2lafw: Failed to get device descriptor: %d.",
228 if (des.idVendor != ctx->profile->vid
229 || des.idProduct != ctx->profile->pid)
232 if (sdi->status == SR_ST_INITIALIZING) {
233 if (skip != dev_index) {
234 /* Skip devices of this type that aren't the one we want. */
238 } else if (sdi->status == SR_ST_INACTIVE) {
240 * This device is fully enumerated, so we need to find
241 * this device by vendor, product, bus and address.
243 if (libusb_get_bus_number(devlist[i]) != ctx->usb->bus
244 || libusb_get_device_address(devlist[i]) != ctx->usb->address)
245 /* this is not the one */
249 if (!(ret = libusb_open(devlist[i], &ctx->usb->devhdl))) {
250 if (ctx->usb->address == 0xff)
252 * first time we touch this device after firmware upload,
253 * so we don't know the address yet.
255 ctx->usb->address = libusb_get_device_address(devlist[i]);
257 sr_err("fx2lafw: Failed to open device: %d.", ret);
261 ret = command_get_fw_version(ctx->usb->devhdl, &vi);
263 sr_err("fx2lafw: Failed to retrieve "
264 "firmware version information.");
268 ret = command_get_revid_version(ctx->usb->devhdl, &revid);
270 sr_err("fx2lafw: Failed to retrieve REVID.");
275 * Changes in major version mean incompatible/API changes, so
276 * bail out if we encounter an incompatible version.
277 * Different minor versions are OK, they should be compatible.
279 if (vi.major != FX2LAFW_REQUIRED_VERSION_MAJOR) {
280 sr_err("fx2lafw: Expected firmware version %d.x, "
281 "got %d.%d.", FX2LAFW_REQUIRED_VERSION_MAJOR,
286 sdi->status = SR_ST_ACTIVE;
287 sr_info("fx2lafw: Opened device %d on %d.%d "
288 "interface %d, firmware %d.%d, REVID %d.",
289 sdi->index, ctx->usb->bus, ctx->usb->address,
290 USB_INTERFACE, vi.major, vi.minor, revid);
294 libusb_free_device_list(devlist, 1);
296 if (sdi->status != SR_ST_ACTIVE)
302 static void close_dev(struct sr_dev_inst *sdi)
308 if (ctx->usb->devhdl == NULL)
311 sr_info("fx2lafw: Closing device %d on %d.%d interface %d.",
312 sdi->index, ctx->usb->bus, ctx->usb->address, USB_INTERFACE);
313 libusb_release_interface(ctx->usb->devhdl, USB_INTERFACE);
314 libusb_close(ctx->usb->devhdl);
315 ctx->usb->devhdl = NULL;
316 sdi->status = SR_ST_INACTIVE;
319 static int configure_probes(struct context *ctx, GSList *probes)
321 struct sr_probe *probe;
323 int probe_bit, stage, i;
326 for (i = 0; i < NUM_TRIGGER_STAGES; i++) {
327 ctx->trigger_mask[i] = 0;
328 ctx->trigger_value[i] = 0;
332 for (l = probes; l; l = l->next) {
333 probe = (struct sr_probe *)l->data;
334 if (probe->enabled == FALSE)
337 if (probe->index > 8)
338 ctx->sample_wide = TRUE;
340 probe_bit = 1 << (probe->index - 1);
341 if (!(probe->trigger))
345 for (tc = probe->trigger; *tc; tc++) {
346 ctx->trigger_mask[stage] |= probe_bit;
348 ctx->trigger_value[stage] |= probe_bit;
350 if (stage > NUM_TRIGGER_STAGES)
357 * We didn't configure any triggers, make sure acquisition
358 * doesn't wait for any.
360 ctx->trigger_stage = TRIGGER_FIRED;
362 ctx->trigger_stage = 0;
367 static struct context *fx2lafw_dev_new(void)
371 if (!(ctx = g_try_malloc0(sizeof(struct context)))) {
372 sr_err("fx2lafw: %s: ctx malloc failed.", __func__);
376 ctx->trigger_stage = TRIGGER_FIRED;
385 static int hw_init(const char *devinfo)
387 struct sr_dev_inst *sdi;
388 struct libusb_device_descriptor des;
389 const struct fx2lafw_profile *prof;
391 libusb_device **devlist;
396 /* Avoid compiler warnings. */
399 if (libusb_init(&usb_context) != 0) {
400 sr_warn("fx2lafw: Failed to initialize libusb.");
404 /* Find all fx2lafw compatible devices and upload firmware to them. */
405 libusb_get_device_list(usb_context, &devlist);
406 for (i = 0; devlist[i]; i++) {
408 if ((ret = libusb_get_device_descriptor(
409 devlist[i], &des)) != 0) {
410 sr_warn("fx2lafw: Failed to get device descriptor: %d.", ret);
415 for (j = 0; supported_fx2[j].vid; j++) {
416 if (des.idVendor == supported_fx2[j].vid &&
417 des.idProduct == supported_fx2[j].pid) {
418 prof = &supported_fx2[j];
422 /* Skip if the device was not found */
426 sdi = sr_dev_inst_new(devcnt, SR_ST_INITIALIZING,
427 prof->vendor, prof->model, prof->model_version);
431 ctx = fx2lafw_dev_new();
434 dev_insts = g_slist_append(dev_insts, sdi);
436 if (check_conf_profile(devlist[i])) {
437 /* Already has the firmware, so fix the new address. */
438 sr_dbg("fx2lafw: Found an fx2lafw device.");
439 sdi->status = SR_ST_INACTIVE;
440 ctx->usb = sr_usb_dev_inst_new
441 (libusb_get_bus_number(devlist[i]),
442 libusb_get_device_address(devlist[i]), NULL);
444 if (ezusb_upload_firmware(devlist[i], USB_CONFIGURATION,
445 prof->firmware) == SR_OK)
446 /* Remember when the firmware on this device was updated */
447 ctx->fw_updated = g_get_monotonic_time();
449 sr_err("fx2lafw: Firmware upload failed for "
450 "device %d.", devcnt);
451 ctx->usb = sr_usb_dev_inst_new
452 (libusb_get_bus_number(devlist[i]), 0xff, NULL);
457 libusb_free_device_list(devlist, 1);
462 static int hw_dev_open(int dev_index)
464 struct sr_dev_inst *sdi;
467 int64_t timediff_us, timediff_ms;
469 if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
474 * If the firmware was recently uploaded, wait up to MAX_RENUM_DELAY_MS
475 * milliseconds for the FX2 to renumerate.
478 if (ctx->fw_updated > 0) {
479 sr_info("fx2lafw: Waiting for device to reset.");
480 /* takes at least 300ms for the FX2 to be gone from the USB bus */
481 g_usleep(300 * 1000);
483 while (timediff_ms < MAX_RENUM_DELAY_MS) {
484 if ((ret = fx2lafw_dev_open(dev_index)) == SR_OK)
486 g_usleep(100 * 1000);
488 timediff_us = g_get_monotonic_time() - ctx->fw_updated;
489 timediff_ms = timediff_us / 1000;
490 sr_spew("fx2lafw: waited %" PRIi64 " ms", timediff_ms);
492 sr_info("fx2lafw: Device came back after %d ms.", timediff_ms);
494 ret = fx2lafw_dev_open(dev_index);
498 sr_err("fx2lafw: Unable to open device.");
503 ret = libusb_claim_interface(ctx->usb->devhdl, USB_INTERFACE);
506 case LIBUSB_ERROR_BUSY:
507 sr_err("fx2lafw: Unable to claim USB interface. Another "
508 "program or driver has already claimed it.");
511 case LIBUSB_ERROR_NO_DEVICE:
512 sr_err("fx2lafw: Device has been disconnected.");
516 sr_err("fx2lafw: Unable to claim interface: %d.", ret);
523 if (ctx->cur_samplerate == 0) {
524 /* Samplerate hasn't been set; default to the slowest one. */
525 if (hw_dev_config_set(dev_index, SR_HWCAP_SAMPLERATE,
526 &supported_samplerates[0]) == SR_ERR)
533 static int hw_dev_close(int dev_index)
535 struct sr_dev_inst *sdi;
537 if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) {
538 sr_err("fx2lafw: %s: sdi was NULL.", __func__);
548 static int hw_cleanup(void)
551 struct sr_dev_inst *sdi;
555 for (l = dev_insts; l; l = l->next) {
556 if (!(sdi = l->data)) {
557 /* Log error, but continue cleaning up the rest. */
558 sr_err("fx2lafw: %s: sdi was NULL, continuing.",
563 if (!(ctx = sdi->priv)) {
564 /* Log error, but continue cleaning up the rest. */
565 sr_err("fx2lafw: %s: sdi->priv was NULL, continuing",
572 sr_dev_inst_free(sdi);
575 g_slist_free(dev_insts);
579 libusb_exit(usb_context);
585 static const void *hw_dev_info_get(int dev_index, int dev_info_id)
587 struct sr_dev_inst *sdi;
590 if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
594 switch (dev_info_id) {
597 case SR_DI_NUM_PROBES:
598 return GINT_TO_POINTER(
599 (ctx->profile->dev_caps & DEV_CAPS_16BIT) ?
601 case SR_DI_PROBE_NAMES:
603 case SR_DI_SAMPLERATES:
605 case SR_DI_TRIGGER_TYPES:
606 return TRIGGER_TYPES;
607 case SR_DI_CUR_SAMPLERATE:
608 return &ctx->cur_samplerate;
614 static int hw_dev_status_get(int dev_index)
616 const struct sr_dev_inst *const sdi =
617 sr_dev_inst_get(dev_insts, dev_index);
620 return SR_ST_NOT_FOUND;
625 static const int *hw_hwcap_get_all(void)
630 static int hw_dev_config_set(int dev_index, int hwcap, const void *value)
632 struct sr_dev_inst *sdi;
636 if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
640 if (hwcap == SR_HWCAP_SAMPLERATE) {
641 ctx->cur_samplerate = *(const uint64_t *)value;
643 } else if (hwcap == SR_HWCAP_PROBECONFIG) {
644 ret = configure_probes(ctx, (GSList *) value);
645 } else if (hwcap == SR_HWCAP_LIMIT_SAMPLES) {
646 ctx->limit_samples = *(const uint64_t *)value;
655 static int receive_data(int fd, int revents, void *cb_data)
659 /* Avoid compiler warnings. */
664 tv.tv_sec = tv.tv_usec = 0;
665 libusb_handle_events_timeout(usb_context, &tv);
670 static void abort_acquisition(struct context *ctx)
674 ctx->num_samples = -1;
676 for (i = ctx->num_transfers - 1; i >= 0; i--) {
677 if (ctx->transfers[i])
678 libusb_cancel_transfer(ctx->transfers[i]);
682 static void finish_acquisition(struct context *ctx)
684 struct sr_datafeed_packet packet;
687 /* Terminate session */
688 packet.type = SR_DF_END;
689 sr_session_send(ctx->session_dev_id, &packet);
691 /* Remove fds from polling */
692 const struct libusb_pollfd **const lupfd =
693 libusb_get_pollfds(usb_context);
694 for (i = 0; lupfd[i]; i++)
695 sr_source_remove(lupfd[i]->fd);
696 free(lupfd); /* NOT g_free()! */
698 ctx->num_transfers = 0;
699 g_free(ctx->transfers);
702 static void free_transfer(struct libusb_transfer *transfer)
704 struct context *ctx = transfer->user_data;
707 g_free(transfer->buffer);
708 transfer->buffer = NULL;
709 libusb_free_transfer(transfer);
711 for (i = 0; i < ctx->num_transfers; i++) {
712 if (ctx->transfers[i] == transfer) {
713 ctx->transfers[i] = NULL;
718 ctx->submitted_transfers--;
719 if (ctx->submitted_transfers == 0)
720 finish_acquisition(ctx);
724 static void resubmit_transfer(struct libusb_transfer *transfer)
726 if (libusb_submit_transfer(transfer) != 0) {
727 free_transfer(transfer);
728 /* TODO: Stop session? */
729 /* TODO: Better error message. */
730 sr_err("fx2lafw: %s: libusb_submit_transfer error.", __func__);
734 static void receive_transfer(struct libusb_transfer *transfer)
736 gboolean packet_has_error = FALSE;
737 struct sr_datafeed_packet packet;
738 struct sr_datafeed_logic logic;
739 struct context *ctx = transfer->user_data;
740 int trigger_offset, i;
743 * If acquisition has already ended, just free any queued up
744 * transfer that come in.
746 if (ctx->num_samples == -1) {
747 free_transfer(transfer);
751 sr_info("fx2lafw: receive_transfer(): status %d received %d bytes.",
752 transfer->status, transfer->actual_length);
754 /* Save incoming transfer before reusing the transfer struct. */
755 uint8_t *const cur_buf = transfer->buffer;
756 const int sample_width = ctx->sample_wide ? 2 : 1;
757 const int cur_sample_count = transfer->actual_length / sample_width;
759 switch (transfer->status) {
760 case LIBUSB_TRANSFER_NO_DEVICE:
761 abort_acquisition(ctx);
762 free_transfer(transfer);
764 case LIBUSB_TRANSFER_COMPLETED:
765 case LIBUSB_TRANSFER_TIMED_OUT: /* We may have received some data though */
768 packet_has_error = TRUE;
772 if (transfer->actual_length == 0 || packet_has_error) {
773 ctx->empty_transfer_count++;
774 if (ctx->empty_transfer_count > MAX_EMPTY_TRANSFERS) {
776 * The FX2 gave up. End the acquisition, the frontend
777 * will work out that the samplecount is short.
779 abort_acquisition(ctx);
780 free_transfer(transfer);
782 resubmit_transfer(transfer);
786 ctx->empty_transfer_count = 0;
790 if (ctx->trigger_stage >= 0) {
791 for (i = 0; i < cur_sample_count; i++) {
793 const uint16_t cur_sample = ctx->sample_wide ?
794 *((const uint16_t*)cur_buf + i) :
795 *((const uint8_t*)cur_buf + i);
797 if ((cur_sample & ctx->trigger_mask[ctx->trigger_stage]) ==
798 ctx->trigger_value[ctx->trigger_stage]) {
799 /* Match on this trigger stage. */
800 ctx->trigger_buffer[ctx->trigger_stage] = cur_sample;
801 ctx->trigger_stage++;
803 if (ctx->trigger_stage == NUM_TRIGGER_STAGES ||
804 ctx->trigger_mask[ctx->trigger_stage] == 0) {
805 /* Match on all trigger stages, we're done. */
806 trigger_offset = i + 1;
809 * TODO: Send pre-trigger buffer to session bus.
810 * Tell the frontend we hit the trigger here.
812 packet.type = SR_DF_TRIGGER;
813 packet.payload = NULL;
814 sr_session_send(ctx->session_dev_id, &packet);
817 * Send the samples that triggered it, since we're
818 * skipping past them.
820 packet.type = SR_DF_LOGIC;
821 packet.payload = &logic;
822 logic.unitsize = sizeof(*ctx->trigger_buffer);
823 logic.length = ctx->trigger_stage * logic.unitsize;
824 logic.data = ctx->trigger_buffer;
825 sr_session_send(ctx->session_dev_id, &packet);
827 ctx->trigger_stage = TRIGGER_FIRED;
830 } else if (ctx->trigger_stage > 0) {
832 * We had a match before, but not in the next sample. However, we may
833 * have a match on this stage in the next bit -- trigger on 0001 will
834 * fail on seeing 00001, so we need to go back to stage 0 -- but at
835 * the next sample from the one that matched originally, which the
836 * counter increment at the end of the loop takes care of.
838 i -= ctx->trigger_stage;
840 i = -1; /* Oops, went back past this buffer. */
841 /* Reset trigger stage. */
842 ctx->trigger_stage = 0;
847 if (ctx->trigger_stage == TRIGGER_FIRED) {
848 /* Send the incoming transfer to the session bus. */
849 const int trigger_offset_bytes = trigger_offset * sample_width;
850 packet.type = SR_DF_LOGIC;
851 packet.payload = &logic;
852 logic.length = transfer->actual_length - trigger_offset_bytes;
853 logic.unitsize = sample_width;
854 logic.data = cur_buf + trigger_offset_bytes;
855 sr_session_send(ctx->session_dev_id, &packet);
857 ctx->num_samples += cur_sample_count;
858 if (ctx->limit_samples &&
859 (unsigned int)ctx->num_samples > ctx->limit_samples) {
860 abort_acquisition(ctx);
861 free_transfer(transfer);
866 * TODO: Buffer pre-trigger data in capture
867 * ratio-sized buffer.
871 resubmit_transfer(transfer);
874 static unsigned int to_bytes_per_ms(unsigned int samplerate)
876 return samplerate / 1000;
879 static size_t get_buffer_size(struct context *ctx)
883 /* The buffer should be large enough to hold 10ms of data and a multiple
885 s = 10 * to_bytes_per_ms(ctx->cur_samplerate);
886 return (s + 511) & ~511;
889 static unsigned int get_number_of_transfers(struct context *ctx)
893 /* Total buffer size should be able to hold about 500ms of data */
894 n = 500 * to_bytes_per_ms(ctx->cur_samplerate) / get_buffer_size(ctx);
896 if (n > NUM_SIMUL_TRANSFERS)
897 return NUM_SIMUL_TRANSFERS;
902 static unsigned int get_timeout(struct context *ctx)
905 unsigned int timeout;
907 total_size = get_buffer_size(ctx) * get_number_of_transfers(ctx);
908 timeout = total_size / to_bytes_per_ms(ctx->cur_samplerate);
909 return timeout + timeout / 4; /* Leave a headroom of 25% percent */
912 static int hw_dev_acquisition_start(int dev_index, void *cb_data)
914 struct sr_dev_inst *sdi;
915 struct sr_datafeed_packet packet;
916 struct sr_datafeed_header header;
917 struct sr_datafeed_meta_logic meta;
919 struct libusb_transfer *transfer;
920 const struct libusb_pollfd **lupfd;
925 if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
929 if (ctx->submitted_transfers != 0)
932 ctx->session_dev_id = cb_data;
933 ctx->num_samples = 0;
934 ctx->empty_transfer_count = 0;
936 const unsigned int timeout = get_timeout(ctx);
937 const unsigned int num_transfers = get_number_of_transfers(ctx);
938 const size_t size = get_buffer_size(ctx);
940 ctx->transfers = g_try_malloc0(sizeof(*ctx->transfers) * num_transfers);
944 ctx->num_transfers = num_transfers;
946 for (i = 0; i < num_transfers; i++) {
947 if (!(buf = g_try_malloc(size))) {
948 sr_err("fx2lafw: %s: buf malloc failed.", __func__);
949 return SR_ERR_MALLOC;
951 transfer = libusb_alloc_transfer(0);
952 libusb_fill_bulk_transfer(transfer, ctx->usb->devhdl,
953 2 | LIBUSB_ENDPOINT_IN, buf, size,
954 receive_transfer, ctx, timeout);
955 if (libusb_submit_transfer(transfer) != 0) {
956 libusb_free_transfer(transfer);
958 abort_acquisition(ctx);
961 ctx->transfers[i] = transfer;
962 ctx->submitted_transfers++;
965 lupfd = libusb_get_pollfds(usb_context);
966 for (i = 0; lupfd[i]; i++)
967 sr_source_add(lupfd[i]->fd, lupfd[i]->events,
968 timeout, receive_data, NULL);
969 free(lupfd); /* NOT g_free()! */
971 packet.type = SR_DF_HEADER;
972 packet.payload = &header;
973 header.feed_version = 1;
974 gettimeofday(&header.starttime, NULL);
975 sr_session_send(cb_data, &packet);
977 /* Send metadata about the SR_DF_LOGIC packets to come. */
978 packet.type = SR_DF_META_LOGIC;
979 packet.payload = &meta;
980 meta.samplerate = ctx->cur_samplerate;
981 meta.num_probes = ctx->sample_wide ? 16 : 8;
982 sr_session_send(cb_data, &packet);
984 if ((ret = command_start_acquisition (ctx->usb->devhdl,
985 ctx->cur_samplerate, ctx->sample_wide)) != SR_OK) {
986 abort_acquisition(ctx);
993 /* TODO: This stops acquisition on ALL devices, ignoring dev_index. */
994 static int hw_dev_acquisition_stop(int dev_index, void *cb_data)
996 struct sr_dev_inst *sdi;
998 /* Avoid compiler warnings. */
1001 if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
1004 abort_acquisition(sdi->priv);
1009 SR_PRIV struct sr_dev_driver fx2lafw_driver_info = {
1011 .longname = "fx2lafw (generic driver for FX2 based LAs)",
1014 .cleanup = hw_cleanup,
1015 .dev_open = hw_dev_open,
1016 .dev_close = hw_dev_close,
1017 .dev_info_get = hw_dev_info_get,
1018 .dev_status_get = hw_dev_status_get,
1019 .hwcap_get_all = hw_hwcap_get_all,
1020 .dev_config_set = hw_dev_config_set,
1021 .dev_acquisition_start = hw_dev_acquisition_start,
1022 .dev_acquisition_stop = hw_dev_acquisition_stop,