X-Git-Url: https://sigrok.org/gitweb/?p=libsigrok.git;a=blobdiff_plain;f=hardware%2Funi-t-ut32x%2Fapi.c;h=81024dc7cc0548afb6d2515d636bc96519c9f4db;hp=8d4e722125fffbe29fe35805b11bc30b5003009d;hb=43cd4637285833706f8a404ca027bcf0ee75b9ae;hpb=d3c74a6fb05118e32ad421443251b7b3288918f9 diff --git a/hardware/uni-t-ut32x/api.c b/hardware/uni-t-ut32x/api.c index 8d4e7221..81024dc7 100644 --- a/hardware/uni-t-ut32x/api.c +++ b/hardware/uni-t-ut32x/api.c @@ -28,7 +28,7 @@ static const int32_t hwcaps[] = { SR_CONF_DATA_SOURCE, }; -static char *probes[] = { +static char *channels[] = { "T1", "T2", "T1-T2", @@ -53,7 +53,7 @@ static GSList *scan(GSList *options) struct drv_context *drvc; struct dev_context *devc; struct sr_dev_inst *sdi; - struct sr_probe *probe; + struct sr_channel *ch; struct sr_config *src; GSList *usb_devices, *devices, *l; int i; @@ -75,7 +75,7 @@ static GSList *scan(GSList *options) return NULL; devices = NULL; - if ((usb_devices = sr_usb_find(drvc->sr_ctx->libusb_ctx, USB_CONN))) { + if ((usb_devices = sr_usb_find(drvc->sr_ctx->libusb_ctx, conn))) { /* We have a list of sr_usb_dev_inst matching the connection * string. Wrap them in sr_dev_inst and we're done. */ for (l = usb_devices; l; l = l->next) { @@ -86,12 +86,12 @@ static GSList *scan(GSList *options) sdi->inst_type = SR_INST_USB; sdi->conn = l->data; for (i = 0; i < 3; i++) { - if (!(probe = sr_probe_new(i, SR_PROBE_ANALOG, TRUE, - probes[i]))) { - sr_dbg("Probe malloc failed."); + if (!(ch = sr_channel_new(i, SR_CHANNEL_ANALOG, TRUE, + channels[i]))) { + sr_dbg("Channel malloc failed."); return NULL; } - sdi->probes = g_slist_append(sdi->probes, probe); + sdi->channels = g_slist_append(sdi->channels, ch); } if (!(devc = g_try_malloc(sizeof(struct dev_context)))) { @@ -116,11 +116,6 @@ static GSList *dev_list(void) return ((struct drv_context *)(di->priv))->instances; } -static int dev_clear(void) -{ - return std_dev_clear(di, NULL); -} - static int dev_open(struct sr_dev_inst *sdi) { struct drv_context *drvc; @@ -196,7 +191,8 @@ static int cleanup(void) /* Can get called on an unused driver, doesn't matter. */ return SR_OK; - ret = dev_clear(); + + ret = std_dev_clear(di, NULL); g_free(drvc); di->priv = NULL; @@ -204,11 +200,11 @@ static int cleanup(void) } static int config_get(int key, 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; - (void)probe_group; + (void)cg; devc = sdi->priv; switch (key) { @@ -229,13 +225,13 @@ static int config_get(int key, GVariant **data, const struct sr_dev_inst *sdi, } static int config_set(int key, 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; const char *tmp_str; - (void)probe_group; + (void)cg; if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; @@ -270,11 +266,11 @@ static int config_set(int key, 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) { (void)sdi; - (void)probe_group; + (void)cg; switch (key) { case SR_CONF_DEVICE_OPTIONS: @@ -297,8 +293,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, struct drv_context *drvc; struct dev_context *devc; struct sr_usb_dev_inst *usb; - const struct libusb_pollfd **pfd; - int len, ret, i; + int len, ret; unsigned char cmd[2]; if (sdi->status != SR_ST_ACTIVE) @@ -350,15 +345,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, return SR_ERR; } - pfd = libusb_get_pollfds(drvc->sr_ctx->libusb_ctx); - for (i = 0; pfd[i]; i++) { - /* Handle USB events every 10ms. */ - sr_source_add(pfd[i]->fd, pfd[i]->events, 10, - uni_t_ut32x_handle_events, (void *)sdi); - /* We'll need to remove this fd later. */ - devc->usbfd[i] = pfd[i]->fd; - } - devc->usbfd[i] = -1; + usb_source_add(sdi->session, drvc->sr_ctx, 10, + uni_t_ut32x_handle_events, (void *)sdi); return SR_OK; } @@ -385,7 +373,7 @@ SR_PRIV struct sr_dev_driver uni_t_ut32x_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,