X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=hardware%2Ffx2lafw%2Fapi.c;h=00b8ad5d0eefc6b78736bd92bed99dbd271e017f;hb=46641facd4ad8de4a93910d7089c7b289b412443;hp=d10b65434f8436615b9d4bf9cb4d18f85ef5e6ad;hpb=8f996b89481670219c7576e2c68b128a0a2ce026;p=libsigrok.git diff --git a/hardware/fx2lafw/api.c b/hardware/fx2lafw/api.c index d10b6543..00b8ad5d 100644 --- a/hardware/fx2lafw/api.c +++ b/hardware/fx2lafw/api.c @@ -87,7 +87,7 @@ static const int32_t hwcaps[] = { SR_CONF_CONTINUOUS, }; -static const char *probe_names[] = { +static const char *channel_names[] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", NULL, @@ -115,11 +115,6 @@ static const uint64_t samplerates[] = { SR_PRIV struct sr_dev_driver fx2lafw_driver_info; static struct sr_dev_driver *di = &fx2lafw_driver_info; -static int dev_clear(void) -{ - return std_dev_clear(di, NULL); -} - static int init(struct sr_context *sr_ctx) { return std_init(sr_ctx, di, LOG_PREFIX); @@ -131,13 +126,13 @@ static GSList *scan(GSList *options) struct dev_context *devc; struct sr_dev_inst *sdi; struct sr_usb_dev_inst *usb; - struct sr_probe *probe; + struct sr_channel *ch; struct sr_config *src; const struct fx2lafw_profile *prof; GSList *l, *devices, *conn_devices; struct libusb_device_descriptor des; libusb_device **devlist; - int devcnt, num_logic_probes, ret, i, j; + int devcnt, num_logic_channels, ret, i, j; const char *conn; drvc = di->priv; @@ -199,13 +194,13 @@ static GSList *scan(GSList *options) return NULL; sdi->driver = di; - /* Fill in probelist according to this device's profile. */ - num_logic_probes = prof->dev_caps & DEV_CAPS_16BIT ? 16 : 8; - for (j = 0; j < num_logic_probes; j++) { - if (!(probe = sr_probe_new(j, SR_PROBE_LOGIC, TRUE, - probe_names[j]))) + /* 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++) { + if (!(ch = sr_channel_new(j, SR_CHANNEL_LOGIC, TRUE, + channel_names[j]))) return NULL; - sdi->probes = g_slist_append(sdi->probes, probe); + sdi->channels = g_slist_append(sdi->channels, ch); } devc = fx2lafw_dev_new(); @@ -230,7 +225,7 @@ static GSList *scan(GSList *options) sr_err("Firmware upload failed for " "device %d.", devcnt); sdi->inst_type = SR_INST_USB; - sdi->conn = sr_usb_dev_inst_new (libusb_get_bus_number(devlist[i]), + sdi->conn = sr_usb_dev_inst_new(libusb_get_bus_number(devlist[i]), 0xff, NULL); } } @@ -291,7 +286,7 @@ static int dev_open(struct sr_dev_inst *sdi) ret = libusb_claim_interface(usb->devhdl, USB_INTERFACE); if (ret != 0) { - switch(ret) { + switch (ret) { case LIBUSB_ERROR_BUSY: sr_err("Unable to claim USB interface. Another " "program or driver has already claimed it."); @@ -342,7 +337,8 @@ static int cleanup(void) if (!(drvc = di->priv)) return SR_OK; - ret = dev_clear(); + + ret = std_dev_clear(di, NULL); g_free(drvc); di->priv = NULL; @@ -351,13 +347,13 @@ static int cleanup(void) } static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi, - const struct sr_probe_group *probe_group) + const struct sr_channel_group *cg) { struct dev_context *devc; struct sr_usb_dev_inst *usb; char str[128]; - (void)probe_group; + (void)cg; switch (id) { case SR_CONF_CONN: @@ -385,12 +381,12 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi, } static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi, - const struct sr_probe_group *probe_group) + const struct sr_channel_group *cg) { struct dev_context *devc; int ret; - (void)probe_group; + (void)cg; if (sdi->status != SR_ST_ACTIVE) return SR_ERR; @@ -411,13 +407,13 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi, } static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi, - const struct sr_probe_group *probe_group) + const struct sr_channel_group *cg) { GVariant *gvar; GVariantBuilder gvb; (void)sdi; - (void)probe_group; + (void)cg; switch (key) { case SR_CONF_SCAN_OPTIONS: @@ -468,7 +464,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) struct drv_context *drvc; struct sr_usb_dev_inst *usb; struct libusb_transfer *transfer; - const struct libusb_pollfd **lupfd; unsigned int i, timeout, num_transfers; int ret; unsigned char *buf; @@ -482,13 +477,14 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) usb = sdi->conn; /* Configures devc->trigger_* and devc->sample_wide */ - if (fx2lafw_configure_probes(sdi) != SR_OK) { - sr_err("Failed to configure probes."); + if (fx2lafw_configure_channels(sdi) != SR_OK) { + sr_err("Failed to configure channels."); return SR_ERR; } devc->cb_data = cb_data; - devc->num_samples = 0; + devc->sent_samples = 0; + devc->acq_aborted = FALSE; devc->empty_transfer_count = 0; timeout = fx2lafw_get_timeout(devc); @@ -524,17 +520,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) devc->submitted_transfers++; } - lupfd = libusb_get_pollfds(drvc->sr_ctx->libusb_ctx); - for (i = 0; lupfd[i]; i++); - if (!(devc->usbfd = g_try_malloc(sizeof(struct libusb_pollfd) * (i + 1)))) - return SR_ERR; - for (i = 0; lupfd[i]; i++) { - sr_source_add(lupfd[i]->fd, lupfd[i]->events, - timeout, receive_data, NULL); - devc->usbfd[i] = lupfd[i]->fd; - } - devc->usbfd[i] = -1; - free(lupfd); + devc->ctx = drvc->sr_ctx; + + usb_source_add(devc->ctx, timeout, receive_data, NULL); /* Send header packet to the session bus. */ std_session_send_df_header(cb_data, LOG_PREFIX); @@ -565,7 +553,7 @@ SR_PRIV struct sr_dev_driver fx2lafw_driver_info = { .cleanup = cleanup, .scan = scan, .dev_list = dev_list, - .dev_clear = dev_clear, + .dev_clear = NULL, .config_get = config_get, .config_set = config_set, .config_list = config_list,