X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=hardware%2Fkecheng-kc-330b%2Fapi.c;h=57dafdfc6d6df4d4d8f7228a8c2bee1f6dae3d36;hb=13dd25bdb807217addc76e9c446485e28e6ec00a;hp=ded6357eaaf46be3d75ae16205829ef440069a7f;hpb=85ed4ab3bae4e5a6fbc741c4c8f8e2d9923e9594;p=libsigrok.git diff --git a/hardware/kecheng-kc-330b/api.c b/hardware/kecheng-kc-330b/api.c index ded6357e..57dafdfc 100644 --- a/hardware/kecheng-kc-330b/api.c +++ b/hardware/kecheng-kc-330b/api.c @@ -112,7 +112,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; GSList *usb_devices, *devices, *l; char *model; @@ -135,9 +135,9 @@ static GSList *scan(GSList *options) sdi->driver = di; sdi->inst_type = SR_INST_USB; sdi->conn = l->data; - if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "SPL"))) + if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "SPL"))) 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)))) { sr_dbg("Device context malloc failed."); @@ -168,16 +168,7 @@ static GSList *scan(GSList *options) static GSList *dev_list(void) { - struct drv_context *drvc; - - drvc = di->priv; - - return drvc->instances; -} - -static int dev_clear(void) -{ - return std_dev_clear(di, NULL); + return ((struct drv_context *)(di->priv))->instances; } static int dev_open(struct sr_dev_inst *sdi) @@ -249,19 +240,22 @@ 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; return ret; } -static int config_get(int key, GVariant **data, const struct sr_dev_inst *sdi) +static int config_get(int key, GVariant **data, const struct sr_dev_inst *sdi, + const struct sr_channel_group *cg) { struct dev_context *devc; GVariant *rational[2]; const uint64_t *si; - int tmp, ret; + + (void)cg; devc = sdi->priv; switch (key) { @@ -303,7 +297,8 @@ static int config_get(int key, GVariant **data, const struct sr_dev_inst *sdi) return SR_OK; } -static int config_set(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_channel_group *cg) { struct dev_context *devc; uint64_t p, q; @@ -311,6 +306,8 @@ static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi) int tmp, ret; const char *tmp_str; + (void)cg; + if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; @@ -380,13 +377,15 @@ static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi) return ret; } -static int config_list(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_channel_group *cg) { GVariant *tuple, *rational[2]; GVariantBuilder gvb; unsigned int i; (void)sdi; + (void)cg; switch (key) { case SR_CONF_DEVICE_OPTIONS: @@ -429,9 +428,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, struct sr_config *src; struct sr_usb_dev_inst *usb; GVariant *gvar, *rational[2]; - const struct libusb_pollfd **pfd; const uint64_t *si; - int stored_mqflags, req_len, buf_len, len, ret, i; + int stored_mqflags, req_len, buf_len, len, ret; unsigned char buf[9]; if (sdi->status != SR_ST_ACTIVE) @@ -491,15 +489,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, if (!(devc->xfer = libusb_alloc_transfer(0))) 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, - kecheng_kc_330b_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(drvc->sr_ctx, 10, + kecheng_kc_330b_handle_events, (void *)sdi); if (devc->data_source == DATA_SOURCE_LIVE) { buf[0] = CMD_GET_LIVE_SPL; @@ -572,7 +563,7 @@ SR_PRIV struct sr_dev_driver kecheng_kc_330b_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,