X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Ffx2lafw%2Fapi.c;h=547f7229d4169c0741879d60857f7e28d9ef994e;hb=f1ba6b4b2c9a8ecf90bb31efb218752aa7e49d1a;hp=4348e680825af8c1f9be71ad8f344bd0a3607d2a;hpb=41812aca436805b0614f2a8f31cf2f8ce494aea0;p=libsigrok.git diff --git a/src/hardware/fx2lafw/api.c b/src/hardware/fx2lafw/api.c index 4348e680..547f7229 100644 --- a/src/hardware/fx2lafw/api.c +++ b/src/hardware/fx2lafw/api.c @@ -18,8 +18,9 @@ * along with this program. If not, see . */ +#include #include "protocol.h" -#include "dslogic.h" +#include static const struct fx2lafw_profile supported_fx2[] = { /* @@ -28,49 +29,29 @@ static const struct fx2lafw_profile supported_fx2[] = { * ARMFLY AX-Pro */ { 0x08a9, 0x0014, "CWAV", "USBee AX", NULL, - FIRMWARE_DIR "/fx2lafw-cwav-usbeeax.fw", - 0, NULL, NULL}, + "fx2lafw-cwav-usbeeax.fw", + DEV_CAPS_AX_ANALOG, NULL, NULL}, /* * CWAV USBee DX * XZL-Studio DX */ { 0x08a9, 0x0015, "CWAV", "USBee DX", NULL, - FIRMWARE_DIR "/fx2lafw-cwav-usbeedx.fw", + "fx2lafw-cwav-usbeedx.fw", DEV_CAPS_16BIT, NULL, NULL }, /* * CWAV USBee SX */ { 0x08a9, 0x0009, "CWAV", "USBee SX", NULL, - FIRMWARE_DIR "/fx2lafw-cwav-usbeesx.fw", + "fx2lafw-cwav-usbeesx.fw", 0, NULL, NULL}, - /* DreamSourceLab DSLogic (before FW upload) */ - { 0x2a0e, 0x0001, "DreamSourceLab", "DSLogic", NULL, - FIRMWARE_DIR "/dreamsourcelab-dslogic-fx2.fw", - DEV_CAPS_16BIT, NULL, NULL}, - /* DreamSourceLab DSLogic (after FW upload) */ - { 0x2a0e, 0x0001, "DreamSourceLab", "DSLogic", NULL, - FIRMWARE_DIR "/dreamsourcelab-dslogic-fx2.fw", - DEV_CAPS_16BIT, "DreamSourceLab", "DSLogic"}, - - /* DreamSourceLab DSCope (before FW upload) */ - { 0x2a0e, 0x0002, "DreamSourceLab", "DSCope", NULL, - FIRMWARE_DIR "/dreamsourcelab-dscope-fx2.fw", - DEV_CAPS_16BIT, NULL, NULL}, - /* DreamSourceLab DSCope (after FW upload) */ - { 0x2a0e, 0x0002, "DreamSourceLab", "DSCope", NULL, - FIRMWARE_DIR "/dreamsourcelab-dscope-fx2.fw", - DEV_CAPS_16BIT, "DreamSourceLab", "DSCope"}, - - /* DreamSourceLab DSLogic Pro (before FW upload) */ - { 0x2a0e, 0x0003, "DreamSourceLab", "DSLogic Pro", NULL, - FIRMWARE_DIR "/dreamsourcelab-dslogic-pro-fx2.fw", - DEV_CAPS_16BIT, NULL, NULL}, - /* DreamSourceLab DSLogic Pro (after FW upload) */ - { 0x2a0e, 0x0003, "DreamSourceLab", "DSLogic Pro", NULL, - FIRMWARE_DIR "/dreamsourcelab-dslogic-pro-fx2.fw", - DEV_CAPS_16BIT, "DreamSourceLab", "DSLogic"}, + /* + * CWAV USBee ZX + */ + { 0x08a9, 0x0005, "CWAV", "USBee ZX", NULL, + "fx2lafw-cwav-usbeezx.fw", + 0, NULL, NULL}, /* * Saleae Logic @@ -79,7 +60,7 @@ static const struct fx2lafw_profile supported_fx2[] = { * Robomotic BugLogic 3 */ { 0x0925, 0x3881, "Saleae", "Logic", NULL, - FIRMWARE_DIR "/fx2lafw-saleae-logic.fw", + "fx2lafw-saleae-logic.fw", 0, NULL, NULL}, /* @@ -88,17 +69,31 @@ static const struct fx2lafw_profile supported_fx2[] = { * Braintechnology USB Interface V2.x */ { 0x04B4, 0x8613, "Cypress", "FX2", NULL, - FIRMWARE_DIR "/fx2lafw-cypress-fx2.fw", + "fx2lafw-cypress-fx2.fw", DEV_CAPS_16BIT, NULL, NULL }, /* * Braintechnology USB-LPS */ { 0x16d0, 0x0498, "Braintechnology", "USB-LPS", NULL, - FIRMWARE_DIR "/fx2lafw-braintechnology-usb-lps.fw", + "fx2lafw-braintechnology-usb-lps.fw", + DEV_CAPS_16BIT, NULL, NULL }, + + /* + * sigrok FX2 based 8-channel logic analyzer + */ + { 0x1d50, 0x608c, "sigrok", "FX2 LA (8ch)", NULL, + "fx2lafw-sigrok-fx2-8ch.fw", + 0, NULL, NULL}, + + /* + * sigrok FX2 based 16-channel logic analyzer + */ + { 0x1d50, 0x608d, "sigrok", "FX2 LA (16ch)", NULL, + "fx2lafw-sigrok-fx2-16ch.fw", DEV_CAPS_16BIT, NULL, NULL }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0 } + ALL_ZERO }; static const uint32_t drvopts[] = { @@ -110,7 +105,7 @@ static const uint32_t scanopts[] = { }; static const uint32_t devopts[] = { - SR_CONF_CONTINUOUS | SR_CONF_SET, + SR_CONF_CONTINUOUS, SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET, SR_CONF_CONN | SR_CONF_GET, SR_CONF_SAMPLERATE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST, @@ -118,11 +113,6 @@ static const uint32_t devopts[] = { SR_CONF_CAPTURE_RATIO | SR_CONF_GET | SR_CONF_SET, }; -static const char *channel_names[] = { - "0", "1", "2", "3", "4", "5", "6", "7", - "8", "9", "10", "11", "12", "13", "14", "15", -}; - static const int32_t soft_trigger_matches[] = { SR_TRIGGER_ZERO, SR_TRIGGER_ONE, @@ -150,30 +140,18 @@ static const uint64_t samplerates[] = { SR_MHZ(24), }; -static const uint64_t dslogic_samplerates[] = { - SR_KHZ(10), - SR_KHZ(20), - SR_KHZ(50), - SR_KHZ(100), - SR_KHZ(200), - SR_KHZ(500), - SR_MHZ(1), - SR_MHZ(2), - SR_MHZ(5), - SR_MHZ(10), - SR_MHZ(20), - SR_MHZ(25), - SR_MHZ(50), - SR_MHZ(100), - SR_MHZ(200), - SR_MHZ(400), -}; +static gboolean is_plausible(const struct libusb_device_descriptor *des) +{ + int i; -SR_PRIV struct sr_dev_driver fx2lafw_driver_info; + for (i = 0; supported_fx2[i].vid; i++) { + if (des->idVendor != supported_fx2[i].vid) + continue; + if (des->idProduct == supported_fx2[i].pid) + return TRUE; + } -static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx) -{ - return std_init(sr_ctx, di, LOG_PREFIX); + return FALSE; } static GSList *scan(struct sr_dev_driver *di, GSList *options) @@ -182,6 +160,8 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) struct dev_context *devc; struct sr_dev_inst *sdi; struct sr_usb_dev_inst *usb; + struct sr_channel *ch; + struct sr_channel_group *cg; struct sr_config *src; const struct fx2lafw_profile *prof; GSList *l, *devices, *conn_devices; @@ -189,9 +169,11 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) struct libusb_device_descriptor des; libusb_device **devlist; struct libusb_device_handle *hdl; - int num_logic_channels, ret, i, j; + int ret, i, j; + int num_logic_channels = 0, num_analog_channels = 0; const char *conn; char manufacturer[64], product[64], serial_num[64], connection_id[64]; + char channel_name[16]; drvc = di->context; @@ -227,14 +209,17 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) continue; } - if ((ret = libusb_get_device_descriptor( devlist[i], &des)) != 0) { - sr_warn("Failed to get device descriptor: %s.", - libusb_error_name(ret)); + libusb_get_device_descriptor( devlist[i], &des); + + if (!is_plausible(&des)) continue; - } - if ((ret = libusb_open(devlist[i], &hdl)) < 0) + if ((ret = libusb_open(devlist[i], &hdl)) < 0) { + sr_warn("Failed to open potential device with " + "VID:PID %04x:%04x: %s.", des.idVendor, + des.idProduct, libusb_error_name(ret)); continue; + } if (des.iManufacturer == 0) { manufacturer[0] = '\0'; @@ -276,7 +261,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) des.idProduct == supported_fx2[j].pid && (!supported_fx2[j].usb_manufacturer || !strcmp(manufacturer, supported_fx2[j].usb_manufacturer)) && - (!supported_fx2[j].usb_manufacturer || + (!supported_fx2[j].usb_product || !strcmp(product, supported_fx2[j].usb_product))) { prof = &supported_fx2[j]; break; @@ -292,38 +277,45 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) sdi->vendor = g_strdup(prof->vendor); sdi->model = g_strdup(prof->model); sdi->version = g_strdup(prof->model_version); - sdi->driver = di; sdi->serial_num = g_strdup(serial_num); sdi->connection_id = g_strdup(connection_id); /* Fill in channellist according to this device's profile. */ num_logic_channels = prof->dev_caps & DEV_CAPS_16BIT ? 16 : 8; - for (j = 0; j < num_logic_channels; j++) - sr_channel_new(sdi, j, SR_CHANNEL_LOGIC, TRUE, - channel_names[j]); + num_analog_channels = prof->dev_caps & DEV_CAPS_AX_ANALOG ? 1 : 0; + + /* Logic channels, all in one channel group. */ + cg = g_malloc0(sizeof(struct sr_channel_group)); + cg->name = g_strdup("Logic"); + for (j = 0; j < num_logic_channels; j++) { + sprintf(channel_name, "D%d", j); + ch = sr_channel_new(sdi, j, SR_CHANNEL_LOGIC, + TRUE, channel_name); + cg->channels = g_slist_append(cg->channels, ch); + } + sdi->channel_groups = g_slist_append(NULL, cg); + + for (j = 0; j < num_analog_channels; j++) { + snprintf(channel_name, 16, "A%d", j); + ch = sr_channel_new(sdi, j + num_logic_channels, + SR_CHANNEL_ANALOG, TRUE, channel_name); + + /* Every analog channel gets its own channel group. */ + cg = g_malloc0(sizeof(struct sr_channel_group)); + cg->name = g_strdup(channel_name); + cg->channels = g_slist_append(NULL, ch); + sdi->channel_groups = g_slist_append(sdi->channel_groups, cg); + } devc = fx2lafw_dev_new(); devc->profile = prof; - devc->sample_wide = (prof->dev_caps & DEV_CAPS_16BIT) != 0; sdi->priv = devc; - drvc->instances = g_slist_append(drvc->instances, sdi); devices = g_slist_append(devices, sdi); - if (!strcmp(prof->model, "DSLogic") - || !strcmp(prof->model, "DSLogic Pro") - || !strcmp(prof->model, "DSCope")) { - devc->dslogic = TRUE; - devc->samplerates = dslogic_samplerates; - devc->num_samplerates = ARRAY_SIZE(dslogic_samplerates); - has_firmware = match_manuf_prod(devlist[i], "DreamSourceLab", "DSLogic") - || match_manuf_prod(devlist[i], "DreamSourceLab", "DSCope"); - } else { - devc->dslogic = FALSE; - devc->samplerates = samplerates; - devc->num_samplerates = ARRAY_SIZE(samplerates); - has_firmware = match_manuf_prod(devlist[i], - "sigrok", "fx2lafw"); - } + devc->samplerates = samplerates; + devc->num_samplerates = ARRAY_SIZE(samplerates); + has_firmware = usb_match_manuf_prod(devlist[i], + "sigrok", "fx2lafw"); if (has_firmware) { /* Already has the firmware, so fix the new address. */ @@ -333,8 +325,8 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) sdi->conn = sr_usb_dev_inst_new(libusb_get_bus_number(devlist[i]), libusb_get_device_address(devlist[i]), NULL); } else { - if (ezusb_upload_firmware(devlist[i], USB_CONFIGURATION, - prof->firmware) == SR_OK) + if (ezusb_upload_firmware(drvc->sr_ctx, devlist[i], + USB_CONFIGURATION, prof->firmware) == SR_OK) /* Store when this device's FW was updated. */ devc->fw_updated = g_get_monotonic_time(); else @@ -350,12 +342,21 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) libusb_free_device_list(devlist, 1); g_slist_free_full(conn_devices, (GDestroyNotify)sr_usb_dev_inst_free); - return devices; + return std_scan_complete(di, devices); +} + +static void clear_dev_context(void *priv) +{ + struct dev_context *devc; + + devc = priv; + g_slist_free(devc->enabled_analog_channels); + g_free(devc); } -static GSList *dev_list(const struct sr_dev_driver *di) +static int dev_clear(const struct sr_dev_driver *di) { - return ((struct drv_context *)(di->context))->instances; + return std_dev_clear(di, clear_dev_context); } static int dev_open(struct sr_dev_inst *sdi) @@ -363,7 +364,6 @@ static int dev_open(struct sr_dev_inst *sdi) struct sr_dev_driver *di = sdi->driver; struct sr_usb_dev_inst *usb; struct dev_context *devc; - char *fpga_firmware = NULL; int ret; int64_t timediff_us, timediff_ms; @@ -423,20 +423,6 @@ static int dev_open(struct sr_dev_inst *sdi) return SR_ERR; } - if (devc->dslogic) { - if (!strcmp(devc->profile->model, "DSLogic")) { - fpga_firmware = DSLOGIC_FPGA_FIRMWARE; - } else if (!strcmp(devc->profile->model, "DSLogic Pro")) { - fpga_firmware = DSLOGIC_PRO_FPGA_FIRMWARE; - } else if (!strcmp(devc->profile->model, "DSCope")) { - fpga_firmware = DSCOPE_FPGA_FIRMWARE; - } - - if ((ret = dslogic_fpga_firmware_upload(sdi, - fpga_firmware)) != SR_OK) - return ret; - } - if (devc->cur_samplerate == 0) { /* Samplerate hasn't been set; default to the slowest one. */ devc->cur_samplerate = devc->samplerates[0]; @@ -450,36 +436,21 @@ static int dev_close(struct sr_dev_inst *sdi) struct sr_usb_dev_inst *usb; usb = sdi->conn; + if (!usb->devhdl) - return SR_ERR; + return SR_ERR_BUG; sr_info("fx2lafw: Closing device on %d.%d (logical) / %s (physical) interface %d.", usb->bus, usb->address, sdi->connection_id, USB_INTERFACE); libusb_release_interface(usb->devhdl, USB_INTERFACE); libusb_close(usb->devhdl); usb->devhdl = NULL; - sdi->status = SR_ST_INACTIVE; return SR_OK; } -static int cleanup(const struct sr_dev_driver *di) -{ - int ret; - struct drv_context *drvc; - - if (!(drvc = di->context)) - return SR_OK; - - ret = std_dev_clear(di, NULL); - - g_free(drvc); - - return ret; -} - -static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi, - const struct sr_channel_group *cg) +static int config_get(uint32_t key, GVariant **data, + const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { struct dev_context *devc; struct sr_usb_dev_inst *usb; @@ -520,8 +491,8 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s return SR_OK; } -static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi, - const struct sr_channel_group *cg) +static int config_set(uint32_t key, GVariant *data, + const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { struct dev_context *devc; uint64_t arg; @@ -532,9 +503,6 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd if (!sdi) return SR_ERR_ARG; - if (sdi->status != SR_ST_ACTIVE) - return SR_ERR; - devc = sdi->priv; ret = SR_OK; @@ -556,11 +524,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd break; case SR_CONF_CAPTURE_RATIO: devc->capture_ratio = g_variant_get_uint64(data); - if (devc->capture_ratio > 100) { - devc->capture_ratio = 0; - ret = SR_ERR; - } else - ret = SR_OK; + ret = (devc->capture_ratio > 100) ? SR_ERR : SR_OK; break; default: ret = SR_ERR_NA; @@ -569,8 +533,8 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd return ret; } -static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi, - const struct sr_channel_group *cg) +static int config_list(uint32_t key, GVariant **data, + const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { struct dev_context *devc; GVariant *gvar; @@ -584,16 +548,16 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * scanopts, ARRAY_SIZE(scanopts), sizeof(uint32_t)); break; case SR_CONF_DEVICE_OPTIONS: - if (!sdi) + if (!sdi) { *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32, - drvopts, ARRAY_SIZE(drvopts), sizeof(uint32_t)); - else + drvopts, ARRAY_SIZE(drvopts), sizeof(uint32_t)); + } else { + devc = sdi->priv; *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32, - devopts, ARRAY_SIZE(devopts), sizeof(uint32_t)); + devopts, ARRAY_SIZE(devopts), sizeof(uint32_t)); + } break; case SR_CONF_SAMPLERATE: - if (!sdi->priv) - return SR_ERR_ARG; devc = sdi->priv; g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}")); gvar = g_variant_new_fixed_array(G_VARIANT_TYPE("t"), devc->samplerates, @@ -613,207 +577,29 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * return SR_OK; } -static int receive_data(int fd, int revents, void *cb_data) -{ - struct timeval tv; - struct drv_context *drvc; - - (void)fd; - (void)revents; - - drvc = (struct drv_context *)cb_data; - - tv.tv_sec = tv.tv_usec = 0; - libusb_handle_events_timeout(drvc->sr_ctx->libusb_ctx, &tv); - - return TRUE; -} - -static int start_transfers(const struct sr_dev_inst *sdi) -{ - struct dev_context *devc; - struct sr_usb_dev_inst *usb; - struct sr_trigger *trigger; - struct libusb_transfer *transfer; - unsigned int i, num_transfers; - int endpoint, timeout, ret; - unsigned char *buf; - size_t size; - - devc = sdi->priv; - usb = sdi->conn; - - devc->sent_samples = 0; - devc->acq_aborted = FALSE; - devc->empty_transfer_count = 0; - - if ((trigger = sr_session_trigger_get(sdi->session))) { - int pre_trigger_samples = 0; - if (devc->limit_samples > 0) - pre_trigger_samples = devc->capture_ratio * devc->limit_samples/100; - devc->stl = soft_trigger_logic_new(sdi, trigger, pre_trigger_samples); - if (!devc->stl) - return SR_ERR_MALLOC; - devc->trigger_fired = FALSE; - } else - devc->trigger_fired = TRUE; - - timeout = fx2lafw_get_timeout(devc); - - num_transfers = fx2lafw_get_number_of_transfers(devc); - size = fx2lafw_get_buffer_size(devc); - devc->submitted_transfers = 0; - - devc->transfers = g_try_malloc0(sizeof(*devc->transfers) * num_transfers); - if (!devc->transfers) { - sr_err("USB transfers malloc failed."); - return SR_ERR_MALLOC; - } - - timeout = fx2lafw_get_timeout(devc); - endpoint = devc->dslogic ? 6 : 2; - devc->num_transfers = num_transfers; - for (i = 0; i < num_transfers; i++) { - if (!(buf = g_try_malloc(size))) { - sr_err("USB transfer buffer malloc failed."); - return SR_ERR_MALLOC; - } - transfer = libusb_alloc_transfer(0); - libusb_fill_bulk_transfer(transfer, usb->devhdl, - endpoint | LIBUSB_ENDPOINT_IN, buf, size, - fx2lafw_receive_transfer, (void *)sdi, timeout); - if ((ret = libusb_submit_transfer(transfer)) != 0) { - sr_err("Failed to submit transfer: %s.", - libusb_error_name(ret)); - libusb_free_transfer(transfer); - g_free(buf); - fx2lafw_abort_acquisition(devc); - return SR_ERR; - } - devc->transfers[i] = transfer; - devc->submitted_transfers++; - } - - /* Send header packet to the session bus. */ - std_session_send_df_header(sdi, LOG_PREFIX); - - return SR_OK; -} - -static void LIBUSB_CALL dslogic_trigger_receive(struct libusb_transfer *transfer) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { - const struct sr_dev_inst *sdi; - struct dslogic_trigger_pos *tpos; - - sdi = transfer->user_data; - - if (transfer->status == LIBUSB_TRANSFER_COMPLETED - && transfer->actual_length == sizeof(struct dslogic_trigger_pos)) { - tpos = (struct dslogic_trigger_pos *)transfer->buffer; - sr_dbg("tpos real_pos %.8x ram_saddr %.8x", tpos->real_pos, tpos->ram_saddr); - g_free(tpos); - start_transfers(sdi); - } - - libusb_free_transfer(transfer); - -} - -static int dslogic_trigger_request(const struct sr_dev_inst *sdi) -{ - struct sr_usb_dev_inst *usb; - struct libusb_transfer *transfer; - struct dslogic_trigger_pos *tpos; - int ret; - - usb = sdi->conn; - - if ((ret = dslogic_stop_acquisition(sdi)) != SR_OK) - return ret; - - if ((ret = dslogic_fpga_configure(sdi)) != SR_OK) - return ret; - - if ((ret = dslogic_start_acquisition(sdi)) != SR_OK) - return ret; - - sr_dbg("Getting trigger."); - tpos = g_malloc(sizeof(struct dslogic_trigger_pos)); - transfer = libusb_alloc_transfer(0); - libusb_fill_bulk_transfer(transfer, usb->devhdl, 6 | LIBUSB_ENDPOINT_IN, - (unsigned char *)tpos, sizeof(struct dslogic_trigger_pos), - dslogic_trigger_receive, (void *)sdi, 0); - if ((ret = libusb_submit_transfer(transfer)) < 0) { - sr_err("Failed to request trigger: %s.", libusb_error_name(ret)); - libusb_free_transfer(transfer); - g_free(tpos); - return SR_ERR; - } - - return ret; -} - -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) -{ - struct sr_dev_driver *di; - struct drv_context *drvc; - struct dev_context *devc; - int timeout, ret; - - if (sdi->status != SR_ST_ACTIVE) - return SR_ERR_DEV_CLOSED; - - di = sdi->driver; - drvc = di->context; - devc = sdi->priv; - - devc->ctx = drvc->sr_ctx; - devc->cb_data = cb_data; - devc->sent_samples = 0; - devc->empty_transfer_count = 0; - devc->acq_aborted = FALSE; - - timeout = fx2lafw_get_timeout(devc); - usb_source_add(sdi->session, devc->ctx, timeout, receive_data, drvc); - - if (devc->dslogic) { - dslogic_trigger_request(sdi); - } - else { - start_transfers(sdi); - if ((ret = fx2lafw_command_start_acquisition(sdi)) != SR_OK) { - fx2lafw_abort_acquisition(devc); - return ret; - } - } - - return SR_OK; -} - -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) -{ - (void)cb_data; - fx2lafw_abort_acquisition(sdi->priv); return SR_OK; } -SR_PRIV struct sr_dev_driver fx2lafw_driver_info = { +static struct sr_dev_driver fx2lafw_driver_info = { .name = "fx2lafw", .longname = "fx2lafw (generic driver for FX2 based LAs)", .api_version = 1, - .init = init, - .cleanup = cleanup, + .init = std_init, + .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, - .dev_clear = NULL, + .dev_list = std_dev_list, + .dev_clear = dev_clear, .config_get = config_get, .config_set = config_set, .config_list = config_list, .dev_open = dev_open, .dev_close = dev_close, - .dev_acquisition_start = dev_acquisition_start, + .dev_acquisition_start = fx2lafw_start_acquisition, .dev_acquisition_stop = dev_acquisition_stop, .context = NULL, }; +SR_REGISTER_DEV_DRIVER(fx2lafw_driver_info);