]> sigrok.org Git - libsigrok.git/blobdiff - hardware/hantek-dso/api.c
sr: add new analog output module
[libsigrok.git] / hardware / hantek-dso / api.c
index bf0fd9569426b13f9d5038c3be09fbb263b1260f..64dc0f98080af1b7f776337625d8cdd5b3c79a10 100644 (file)
@@ -200,13 +200,16 @@ static struct sr_dev_inst *dso_dev_new(int index, const struct dso_profile *prof
        return sdi;
 }
 
-static int configure_probes(struct dev_context *devc, const GSList *probes)
+static int configure_probes(const struct sr_dev_inst *sdi)
 {
+       struct dev_context *devc;
        const struct sr_probe *probe;
        const GSList *l;
 
+       devc = sdi->priv;
+
        devc->ch1_enabled = devc->ch2_enabled = FALSE;
-       for (l = probes; l; l = l->next) {
+       for (l = sdi->probes; l; l = l->next) {
                probe = (struct sr_probe *)l->data;
                if (probe->index == 0)
                        devc->ch1_enabled = probe->enabled;
@@ -218,7 +221,7 @@ static int configure_probes(struct dev_context *devc, const GSList *probes)
 }
 
 /* Properly close and free all devices. */
-static void clear_instances(void)
+static int clear_instances(void)
 {
        struct sr_dev_inst *sdi;
        struct drv_context *drvc;
@@ -247,6 +250,7 @@ static void clear_instances(void)
        g_slist_free(drvc->instances);
        drvc->instances = NULL;
 
+       return SR_OK;
 }
 
 static int hw_init(void)
@@ -343,6 +347,15 @@ static GSList *hw_scan(GSList *options)
        return devices;
 }
 
+static GSList *hw_dev_list(void)
+{
+       struct drv_context *drvc;
+
+       drvc = hdi->priv;
+
+       return drvc->instances;
+}
+
 static int hw_dev_open(struct sr_dev_inst *sdi)
 {
        struct dev_context *devc;
@@ -477,9 +490,6 @@ static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
        case SR_HWCAP_LIMIT_FRAMES:
                devc->limit_frames = *(const uint64_t *)value;
                break;
-       case SR_HWCAP_PROBECONFIG:
-               ret = configure_probes(devc, (const GSList *)value);
-               break;
        case SR_HWCAP_TRIGGER_SLOPE:
                tmp_u64 = *(const int *)value;
                if (tmp_u64 != SLOPE_NEGATIVE && tmp_u64 != SLOPE_POSITIVE)
@@ -847,6 +857,11 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
        devc = sdi->priv;
        devc->cb_data = cb_data;
 
+       if (configure_probes(sdi) != SR_OK) {
+               sr_err("hantek-dso: failed to configured probes");
+               return SR_ERR;
+       }
+
        if (dso_init(devc) != SR_OK)
                return SR_ERR;
 
@@ -899,6 +914,8 @@ SR_PRIV struct sr_dev_driver hantek_dso_driver_info = {
        .init = hw_init,
        .cleanup = hw_cleanup,
        .scan = hw_scan,
+       .dev_list = hw_dev_list,
+       .dev_clear = clear_instances,
        .dev_open = hw_dev_open,
        .dev_close = hw_dev_close,
        .info_get = hw_info_get,