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,
95 static const char *probe_names[] = {
115 static const uint64_t supported_samplerates[] = {
135 static const struct sr_samplerates samplerates = {
139 supported_samplerates,
142 static libusb_context *usb_context = NULL;
144 SR_PRIV struct sr_dev_driver fx2lafw_driver_info;
145 static struct sr_dev_driver *fdi = &fx2lafw_driver_info;
146 static int hw_dev_close(struct sr_dev_inst *sdi);
147 static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
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(struct sr_dev_inst *sdi)
197 libusb_device **devlist;
198 struct libusb_device_descriptor des;
200 struct version_info vi;
206 if (sdi->status == SR_ST_ACTIVE)
211 const int device_count = libusb_get_device_list(usb_context, &devlist);
212 if (device_count < 0) {
213 sr_err("fx2lafw: Failed to retrieve device list (%d)",
218 for (i = 0; i < device_count; i++) {
219 if ((ret = libusb_get_device_descriptor(devlist[i], &des))) {
220 sr_err("fx2lafw: Failed to get device descriptor: %d.",
225 if (des.idVendor != ctx->profile->vid
226 || des.idProduct != ctx->profile->pid)
229 if (sdi->status == SR_ST_INITIALIZING) {
230 if (skip != sdi->index) {
231 /* Skip devices of this type that aren't the one we want. */
235 } else if (sdi->status == SR_ST_INACTIVE) {
237 * This device is fully enumerated, so we need to find
238 * this device by vendor, product, bus and address.
240 if (libusb_get_bus_number(devlist[i]) != ctx->usb->bus
241 || libusb_get_device_address(devlist[i]) != ctx->usb->address)
242 /* this is not the one */
246 if (!(ret = libusb_open(devlist[i], &ctx->usb->devhdl))) {
247 if (ctx->usb->address == 0xff)
249 * first time we touch this device after firmware upload,
250 * so we don't know the address yet.
252 ctx->usb->address = libusb_get_device_address(devlist[i]);
254 sr_err("fx2lafw: Failed to open device: %d.", ret);
258 ret = command_get_fw_version(ctx->usb->devhdl, &vi);
260 sr_err("fx2lafw: Failed to retrieve "
261 "firmware version information.");
265 ret = command_get_revid_version(ctx->usb->devhdl, &revid);
267 sr_err("fx2lafw: Failed to retrieve REVID.");
272 * Changes in major version mean incompatible/API changes, so
273 * bail out if we encounter an incompatible version.
274 * Different minor versions are OK, they should be compatible.
276 if (vi.major != FX2LAFW_REQUIRED_VERSION_MAJOR) {
277 sr_err("fx2lafw: Expected firmware version %d.x, "
278 "got %d.%d.", FX2LAFW_REQUIRED_VERSION_MAJOR,
283 sdi->status = SR_ST_ACTIVE;
284 sr_info("fx2lafw: Opened device %d on %d.%d "
285 "interface %d, firmware %d.%d, REVID %d.",
286 sdi->index, ctx->usb->bus, ctx->usb->address,
287 USB_INTERFACE, vi.major, vi.minor, revid);
291 libusb_free_device_list(devlist, 1);
293 if (sdi->status != SR_ST_ACTIVE)
299 static int configure_probes(struct context *ctx, GSList *probes)
301 struct sr_probe *probe;
303 int probe_bit, stage, i;
306 for (i = 0; i < NUM_TRIGGER_STAGES; i++) {
307 ctx->trigger_mask[i] = 0;
308 ctx->trigger_value[i] = 0;
312 for (l = probes; l; l = l->next) {
313 probe = (struct sr_probe *)l->data;
314 if (probe->enabled == FALSE)
317 if (probe->index > 8)
318 ctx->sample_wide = TRUE;
320 probe_bit = 1 << (probe->index - 1);
321 if (!(probe->trigger))
325 for (tc = probe->trigger; *tc; tc++) {
326 ctx->trigger_mask[stage] |= probe_bit;
328 ctx->trigger_value[stage] |= probe_bit;
330 if (stage > NUM_TRIGGER_STAGES)
337 * We didn't configure any triggers, make sure acquisition
338 * doesn't wait for any.
340 ctx->trigger_stage = TRIGGER_FIRED;
342 ctx->trigger_stage = 0;
347 static struct context *fx2lafw_dev_new(void)
351 if (!(ctx = g_try_malloc0(sizeof(struct context)))) {
352 sr_err("fx2lafw: %s: ctx malloc failed.", __func__);
356 ctx->trigger_stage = TRIGGER_FIRED;
361 static int clear_instances(void)
364 struct sr_dev_inst *sdi;
369 for (l = fdi->instances; l; l = l->next) {
370 if (!(sdi = l->data)) {
371 /* Log error, but continue cleaning up the rest. */
372 sr_err("fx2lafw: %s: sdi was NULL, continuing.",
377 if (!(ctx = sdi->priv)) {
378 /* Log error, but continue cleaning up the rest. */
379 sr_err("fx2lafw: %s: sdi->priv was NULL, continuing",
386 sr_dev_inst_free(sdi);
389 g_slist_free(fdi->instances);
390 fdi->instances = NULL;
400 static int hw_init(void)
403 if (libusb_init(&usb_context) != 0) {
404 sr_warn("fx2lafw: Failed to initialize libusb.");
411 static GSList *hw_scan(GSList *options)
414 struct libusb_device_descriptor des;
415 struct sr_dev_inst *sdi;
416 const struct fx2lafw_profile *prof;
418 struct sr_probe *probe;
419 libusb_device **devlist;
420 int devcnt, num_logic_probes, ret, i, j;
422 /* Avoid compiler warnings. */
425 /* This scan always invalidates any previous scans. */
428 /* Find all fx2lafw compatible devices and upload firmware to them. */
430 libusb_get_device_list(usb_context, &devlist);
431 for (i = 0; devlist[i]; i++) {
433 if ((ret = libusb_get_device_descriptor(
434 devlist[i], &des)) != 0) {
435 sr_warn("fx2lafw: Failed to get device descriptor: %d.", ret);
440 for (j = 0; supported_fx2[j].vid; j++) {
441 if (des.idVendor == supported_fx2[j].vid &&
442 des.idProduct == supported_fx2[j].pid) {
443 prof = &supported_fx2[j];
447 /* Skip if the device was not found */
451 devcnt = g_slist_length(fdi->instances);
452 sdi = sr_dev_inst_new(devcnt, SR_ST_INITIALIZING,
453 prof->vendor, prof->model, prof->model_version);
458 /* Fill in probelist according to this device's profile. */
459 num_logic_probes = prof->dev_caps & DEV_CAPS_16BIT ? 16 : 8;
460 for (j = 0; j < num_logic_probes; j++) {
461 if (!(probe = sr_probe_new(j, SR_PROBE_LOGIC, TRUE,
464 sdi->probes = g_slist_append(sdi->probes, probe);
467 ctx = fx2lafw_dev_new();
470 fdi->instances = g_slist_append(fdi->instances, sdi);
471 devices = g_slist_append(devices, sdi);
473 if (check_conf_profile(devlist[i])) {
474 /* Already has the firmware, so fix the new address. */
475 sr_dbg("fx2lafw: Found an fx2lafw device.");
476 sdi->status = SR_ST_INACTIVE;
477 ctx->usb = sr_usb_dev_inst_new
478 (libusb_get_bus_number(devlist[i]),
479 libusb_get_device_address(devlist[i]), NULL);
481 if (ezusb_upload_firmware(devlist[i], USB_CONFIGURATION,
482 prof->firmware) == SR_OK)
483 /* Remember when the firmware on this device was updated */
484 ctx->fw_updated = g_get_monotonic_time();
486 sr_err("fx2lafw: Firmware upload failed for "
487 "device %d.", devcnt);
488 ctx->usb = sr_usb_dev_inst_new
489 (libusb_get_bus_number(devlist[i]), 0xff, NULL);
492 libusb_free_device_list(devlist, 1);
497 static int hw_dev_open(struct sr_dev_inst *sdi)
501 int64_t timediff_us, timediff_ms;
506 * If the firmware was recently uploaded, wait up to MAX_RENUM_DELAY_MS
507 * milliseconds for the FX2 to renumerate.
510 if (ctx->fw_updated > 0) {
511 sr_info("fx2lafw: Waiting for device to reset.");
512 /* takes at least 300ms for the FX2 to be gone from the USB bus */
513 g_usleep(300 * 1000);
515 while (timediff_ms < MAX_RENUM_DELAY_MS) {
516 if ((ret = fx2lafw_dev_open(sdi)) == SR_OK)
518 g_usleep(100 * 1000);
520 timediff_us = g_get_monotonic_time() - ctx->fw_updated;
521 timediff_ms = timediff_us / 1000;
522 sr_spew("fx2lafw: waited %" PRIi64 " ms", timediff_ms);
524 sr_info("fx2lafw: Device came back after %d ms.", timediff_ms);
526 ret = fx2lafw_dev_open(sdi);
530 sr_err("fx2lafw: Unable to open device.");
535 ret = libusb_claim_interface(ctx->usb->devhdl, USB_INTERFACE);
538 case LIBUSB_ERROR_BUSY:
539 sr_err("fx2lafw: Unable to claim USB interface. Another "
540 "program or driver has already claimed it.");
543 case LIBUSB_ERROR_NO_DEVICE:
544 sr_err("fx2lafw: Device has been disconnected.");
548 sr_err("fx2lafw: Unable to claim interface: %d.", ret);
555 if (ctx->cur_samplerate == 0) {
556 /* Samplerate hasn't been set; default to the slowest one. */
557 if (hw_dev_config_set(sdi, SR_HWCAP_SAMPLERATE,
558 &supported_samplerates[0]) == SR_ERR)
565 static int hw_dev_close(struct sr_dev_inst *sdi)
570 if (ctx->usb->devhdl == NULL)
573 sr_info("fx2lafw: Closing device %d on %d.%d interface %d.",
574 sdi->index, ctx->usb->bus, ctx->usb->address, USB_INTERFACE);
575 libusb_release_interface(ctx->usb->devhdl, USB_INTERFACE);
576 libusb_close(ctx->usb->devhdl);
577 ctx->usb->devhdl = NULL;
578 sdi->status = SR_ST_INACTIVE;
583 static int hw_cleanup(void)
587 ret = clear_instances();
590 libusb_exit(usb_context);
596 static int hw_info_get(int info_id, const void **data,
597 const struct sr_dev_inst *sdi)
608 case SR_DI_NUM_PROBES:
611 *data = GINT_TO_POINTER(
612 (ctx->profile->dev_caps & DEV_CAPS_16BIT) ?
617 case SR_DI_PROBE_NAMES:
620 case SR_DI_SAMPLERATES:
621 *data = &samplerates;
623 case SR_DI_TRIGGER_TYPES:
624 *data = TRIGGER_TYPES;
626 case SR_DI_CUR_SAMPLERATE:
629 *data = &ctx->cur_samplerate;
640 static int hw_dev_status_get(int dev_index)
642 const struct sr_dev_inst *const sdi =
643 sr_dev_inst_get(fdi->instances, dev_index);
646 return SR_ST_NOT_FOUND;
651 static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
659 if (hwcap == SR_HWCAP_SAMPLERATE) {
660 ctx->cur_samplerate = *(const uint64_t *)value;
662 } else if (hwcap == SR_HWCAP_PROBECONFIG) {
663 ret = configure_probes(ctx, (GSList *) value);
664 } else if (hwcap == SR_HWCAP_LIMIT_SAMPLES) {
665 ctx->limit_samples = *(const uint64_t *)value;
674 static int receive_data(int fd, int revents, void *cb_data)
678 /* Avoid compiler warnings. */
683 tv.tv_sec = tv.tv_usec = 0;
684 libusb_handle_events_timeout(usb_context, &tv);
689 static void abort_acquisition(struct context *ctx)
693 ctx->num_samples = -1;
695 for (i = ctx->num_transfers - 1; i >= 0; i--) {
696 if (ctx->transfers[i])
697 libusb_cancel_transfer(ctx->transfers[i]);
701 static void finish_acquisition(struct context *ctx)
703 struct sr_datafeed_packet packet;
706 /* Terminate session */
707 packet.type = SR_DF_END;
708 sr_session_send(ctx->session_dev_id, &packet);
710 /* Remove fds from polling */
711 const struct libusb_pollfd **const lupfd =
712 libusb_get_pollfds(usb_context);
713 for (i = 0; lupfd[i]; i++)
714 sr_source_remove(lupfd[i]->fd);
715 free(lupfd); /* NOT g_free()! */
717 ctx->num_transfers = 0;
718 g_free(ctx->transfers);
721 static void free_transfer(struct libusb_transfer *transfer)
723 struct context *ctx = transfer->user_data;
726 g_free(transfer->buffer);
727 transfer->buffer = NULL;
728 libusb_free_transfer(transfer);
730 for (i = 0; i < ctx->num_transfers; i++) {
731 if (ctx->transfers[i] == transfer) {
732 ctx->transfers[i] = NULL;
737 ctx->submitted_transfers--;
738 if (ctx->submitted_transfers == 0)
739 finish_acquisition(ctx);
743 static void resubmit_transfer(struct libusb_transfer *transfer)
745 if (libusb_submit_transfer(transfer) != 0) {
746 free_transfer(transfer);
747 /* TODO: Stop session? */
748 /* TODO: Better error message. */
749 sr_err("fx2lafw: %s: libusb_submit_transfer error.", __func__);
753 static void receive_transfer(struct libusb_transfer *transfer)
755 gboolean packet_has_error = FALSE;
756 struct sr_datafeed_packet packet;
757 struct sr_datafeed_logic logic;
758 struct context *ctx = transfer->user_data;
759 int trigger_offset, i;
762 * If acquisition has already ended, just free any queued up
763 * transfer that come in.
765 if (ctx->num_samples == -1) {
766 free_transfer(transfer);
770 sr_info("fx2lafw: receive_transfer(): status %d received %d bytes.",
771 transfer->status, transfer->actual_length);
773 /* Save incoming transfer before reusing the transfer struct. */
774 uint8_t *const cur_buf = transfer->buffer;
775 const int sample_width = ctx->sample_wide ? 2 : 1;
776 const int cur_sample_count = transfer->actual_length / sample_width;
778 switch (transfer->status) {
779 case LIBUSB_TRANSFER_NO_DEVICE:
780 abort_acquisition(ctx);
781 free_transfer(transfer);
783 case LIBUSB_TRANSFER_COMPLETED:
784 case LIBUSB_TRANSFER_TIMED_OUT: /* We may have received some data though */
787 packet_has_error = TRUE;
791 if (transfer->actual_length == 0 || packet_has_error) {
792 ctx->empty_transfer_count++;
793 if (ctx->empty_transfer_count > MAX_EMPTY_TRANSFERS) {
795 * The FX2 gave up. End the acquisition, the frontend
796 * will work out that the samplecount is short.
798 abort_acquisition(ctx);
799 free_transfer(transfer);
801 resubmit_transfer(transfer);
805 ctx->empty_transfer_count = 0;
809 if (ctx->trigger_stage >= 0) {
810 for (i = 0; i < cur_sample_count; i++) {
812 const uint16_t cur_sample = ctx->sample_wide ?
813 *((const uint16_t*)cur_buf + i) :
814 *((const uint8_t*)cur_buf + i);
816 if ((cur_sample & ctx->trigger_mask[ctx->trigger_stage]) ==
817 ctx->trigger_value[ctx->trigger_stage]) {
818 /* Match on this trigger stage. */
819 ctx->trigger_buffer[ctx->trigger_stage] = cur_sample;
820 ctx->trigger_stage++;
822 if (ctx->trigger_stage == NUM_TRIGGER_STAGES ||
823 ctx->trigger_mask[ctx->trigger_stage] == 0) {
824 /* Match on all trigger stages, we're done. */
825 trigger_offset = i + 1;
828 * TODO: Send pre-trigger buffer to session bus.
829 * Tell the frontend we hit the trigger here.
831 packet.type = SR_DF_TRIGGER;
832 packet.payload = NULL;
833 sr_session_send(ctx->session_dev_id, &packet);
836 * Send the samples that triggered it, since we're
837 * skipping past them.
839 packet.type = SR_DF_LOGIC;
840 packet.payload = &logic;
841 logic.unitsize = sizeof(*ctx->trigger_buffer);
842 logic.length = ctx->trigger_stage * logic.unitsize;
843 logic.data = ctx->trigger_buffer;
844 sr_session_send(ctx->session_dev_id, &packet);
846 ctx->trigger_stage = TRIGGER_FIRED;
849 } else if (ctx->trigger_stage > 0) {
851 * We had a match before, but not in the next sample. However, we may
852 * have a match on this stage in the next bit -- trigger on 0001 will
853 * fail on seeing 00001, so we need to go back to stage 0 -- but at
854 * the next sample from the one that matched originally, which the
855 * counter increment at the end of the loop takes care of.
857 i -= ctx->trigger_stage;
859 i = -1; /* Oops, went back past this buffer. */
860 /* Reset trigger stage. */
861 ctx->trigger_stage = 0;
866 if (ctx->trigger_stage == TRIGGER_FIRED) {
867 /* Send the incoming transfer to the session bus. */
868 const int trigger_offset_bytes = trigger_offset * sample_width;
869 packet.type = SR_DF_LOGIC;
870 packet.payload = &logic;
871 logic.length = transfer->actual_length - trigger_offset_bytes;
872 logic.unitsize = sample_width;
873 logic.data = cur_buf + trigger_offset_bytes;
874 sr_session_send(ctx->session_dev_id, &packet);
876 ctx->num_samples += cur_sample_count;
877 if (ctx->limit_samples &&
878 (unsigned int)ctx->num_samples > ctx->limit_samples) {
879 abort_acquisition(ctx);
880 free_transfer(transfer);
885 * TODO: Buffer pre-trigger data in capture
886 * ratio-sized buffer.
890 resubmit_transfer(transfer);
893 static unsigned int to_bytes_per_ms(unsigned int samplerate)
895 return samplerate / 1000;
898 static size_t get_buffer_size(struct context *ctx)
902 /* The buffer should be large enough to hold 10ms of data and a multiple
904 s = 10 * to_bytes_per_ms(ctx->cur_samplerate);
905 return (s + 511) & ~511;
908 static unsigned int get_number_of_transfers(struct context *ctx)
912 /* Total buffer size should be able to hold about 500ms of data */
913 n = 500 * to_bytes_per_ms(ctx->cur_samplerate) / get_buffer_size(ctx);
915 if (n > NUM_SIMUL_TRANSFERS)
916 return NUM_SIMUL_TRANSFERS;
921 static unsigned int get_timeout(struct context *ctx)
924 unsigned int timeout;
926 total_size = get_buffer_size(ctx) * get_number_of_transfers(ctx);
927 timeout = total_size / to_bytes_per_ms(ctx->cur_samplerate);
928 return timeout + timeout / 4; /* Leave a headroom of 25% percent */
931 static int hw_dev_acquisition_start(int dev_index, void *cb_data)
933 struct sr_dev_inst *sdi;
934 struct sr_datafeed_packet packet;
935 struct sr_datafeed_header header;
936 struct sr_datafeed_meta_logic meta;
938 struct libusb_transfer *transfer;
939 const struct libusb_pollfd **lupfd;
944 if (!(sdi = sr_dev_inst_get(fdi->instances, dev_index)))
948 if (ctx->submitted_transfers != 0)
951 ctx->session_dev_id = cb_data;
952 ctx->num_samples = 0;
953 ctx->empty_transfer_count = 0;
955 const unsigned int timeout = get_timeout(ctx);
956 const unsigned int num_transfers = get_number_of_transfers(ctx);
957 const size_t size = get_buffer_size(ctx);
959 ctx->transfers = g_try_malloc0(sizeof(*ctx->transfers) * num_transfers);
963 ctx->num_transfers = num_transfers;
965 for (i = 0; i < num_transfers; i++) {
966 if (!(buf = g_try_malloc(size))) {
967 sr_err("fx2lafw: %s: buf malloc failed.", __func__);
968 return SR_ERR_MALLOC;
970 transfer = libusb_alloc_transfer(0);
971 libusb_fill_bulk_transfer(transfer, ctx->usb->devhdl,
972 2 | LIBUSB_ENDPOINT_IN, buf, size,
973 receive_transfer, ctx, timeout);
974 if (libusb_submit_transfer(transfer) != 0) {
975 libusb_free_transfer(transfer);
977 abort_acquisition(ctx);
980 ctx->transfers[i] = transfer;
981 ctx->submitted_transfers++;
984 lupfd = libusb_get_pollfds(usb_context);
985 for (i = 0; lupfd[i]; i++)
986 sr_source_add(lupfd[i]->fd, lupfd[i]->events,
987 timeout, receive_data, NULL);
988 free(lupfd); /* NOT g_free()! */
990 packet.type = SR_DF_HEADER;
991 packet.payload = &header;
992 header.feed_version = 1;
993 gettimeofday(&header.starttime, NULL);
994 sr_session_send(cb_data, &packet);
996 /* Send metadata about the SR_DF_LOGIC packets to come. */
997 packet.type = SR_DF_META_LOGIC;
998 packet.payload = &meta;
999 meta.samplerate = ctx->cur_samplerate;
1000 meta.num_probes = ctx->sample_wide ? 16 : 8;
1001 sr_session_send(cb_data, &packet);
1003 if ((ret = command_start_acquisition (ctx->usb->devhdl,
1004 ctx->cur_samplerate, ctx->sample_wide)) != SR_OK) {
1005 abort_acquisition(ctx);
1012 /* TODO: This stops acquisition on ALL devices, ignoring dev_index. */
1013 static int hw_dev_acquisition_stop(int dev_index, void *cb_data)
1015 struct sr_dev_inst *sdi;
1017 /* Avoid compiler warnings. */
1020 if (!(sdi = sr_dev_inst_get(fdi->instances, dev_index)))
1023 abort_acquisition(sdi->priv);
1028 SR_PRIV struct sr_dev_driver fx2lafw_driver_info = {
1030 .longname = "fx2lafw (generic driver for FX2 based LAs)",
1033 .cleanup = hw_cleanup,
1035 .dev_open = hw_dev_open,
1036 .dev_close = hw_dev_close,
1037 .info_get = hw_info_get,
1038 .dev_status_get = hw_dev_status_get,
1039 .dev_config_set = hw_dev_config_set,
1040 .dev_acquisition_start = hw_dev_acquisition_start,
1041 .dev_acquisition_stop = hw_dev_acquisition_stop,