]> sigrok.org Git - libsigrok.git/blobdiff - hardware/zeroplus-logic-cube/api.c
zeroplus: Add getters for memory configuration
[libsigrok.git] / hardware / zeroplus-logic-cube / api.c
index bd94315426a6a770590290ea78635d43b0c07994..f865a1abb54b5e4849abe5f930c0f54a6e98a006 100644 (file)
@@ -45,11 +45,9 @@ static const struct zp_model zeroplus_models[] = {
        {0x0c12, 0x7002, "LAP-16128U",    16, 128,  200},
        {0x0c12, 0x7009, "LAP-C(16064)",  16, 64,   100},
        {0x0c12, 0x700a, "LAP-C(16128)",  16, 128,  200},
-       /* TODO: We don't know anything about these.
        {0x0c12, 0x700b, "LAP-C(32128)",  32, 128,  200},
        {0x0c12, 0x700c, "LAP-C(321000)", 32, 1024, 200},
        {0x0c12, 0x700d, "LAP-C(322000)", 32, 2048, 200},
-       */
        {0x0c12, 0x700e, "LAP-C(16032)",  16, 32,   100},
        {0x0c12, 0x7016, "LAP-C(162000)", 16, 2048, 200},
        { 0, 0, 0, 0, 0, 0 }
@@ -69,6 +67,8 @@ static const int32_t hwcaps[] = {
 static const char *probe_names[] = {
        "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7",
        "B0", "B1", "B2", "B3", "B4", "B5", "B6", "B7",
+       "C0", "C1", "C2", "C3", "C4", "C5", "C6", "C7",
+       "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7",
        NULL,
 };
 
@@ -120,7 +120,7 @@ const uint64_t samplerates_200[] = {
        SR_MHZ(200),
 };
 
-static int hw_dev_close(struct sr_dev_inst *sdi);
+static int dev_close(struct sr_dev_inst *sdi);
 
 #if 0
 static int configure_probes(const struct sr_dev_inst *sdi)
@@ -238,17 +238,17 @@ SR_PRIV int zp_set_samplerate(struct dev_context *devc, uint64_t samplerate)
        return SR_OK;
 }
 
-static int clear_instances(void)
+static int dev_clear(void)
 {
        return std_dev_clear(di, NULL);
 }
 
-static int hw_init(struct sr_context *sr_ctx)
+static int init(struct sr_context *sr_ctx)
 {
-       return std_hw_init(sr_ctx, di, "zeroplus: ");
+       return std_init(sr_ctx, di, LOG_PREFIX);
 }
 
-static GSList *hw_scan(GSList *options)
+static GSList *scan(GSList *options)
 {
        struct sr_dev_inst *sdi;
        struct sr_probe *probe;
@@ -308,10 +308,10 @@ static GSList *hw_scan(GSList *options)
                devc->prof = prof;
                devc->num_channels = prof->channels;
 #ifdef ZP_EXPERIMENTAL
-               devc->max_memory_size = 128 * 1024;
+               devc->max_sample_depth = 128 * 1024;
                devc->max_samplerate = 200;
 #else
-               devc->max_memory_size = prof->sample_depth * 1024;
+               devc->max_sample_depth = prof->sample_depth * 1024;
                devc->max_samplerate = prof->max_sampling_freq;
 #endif
                devc->max_samplerate *= SR_MHZ(1);
@@ -340,12 +340,12 @@ static GSList *hw_scan(GSList *options)
        return devices;
 }
 
-static GSList *hw_dev_list(void)
+static GSList *dev_list(void)
 {
        return ((struct drv_context *)(di->priv))->instances;
 }
 
-static int hw_dev_open(struct sr_dev_inst *sdi)
+static int dev_open(struct sr_dev_inst *sdi)
 {
        struct dev_context *devc;
        struct drv_context *drvc;
@@ -442,7 +442,7 @@ static int hw_dev_open(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-static int hw_dev_close(struct sr_dev_inst *sdi)
+static int dev_close(struct sr_dev_inst *sdi)
 {
        struct sr_usb_dev_inst *usb;
 
@@ -462,15 +462,18 @@ static int hw_dev_close(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-static int hw_cleanup(void)
+static int cleanup(void)
 {
-       return clear_instances();
+       return dev_clear();
 }
 
-static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi)
+static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi,
+               const struct sr_probe_group *probe_group)
 {
        struct dev_context *devc;
 
+       (void)probe_group;
+
        switch (id) {
        case SR_CONF_SAMPLERATE:
                if (sdi) {
@@ -481,6 +484,13 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi)
                } else
                        return SR_ERR;
                break;
+       case SR_CONF_CAPTURE_RATIO:
+               if (sdi) {
+                       devc = sdi->priv;
+                       *data = g_variant_new_uint64(devc->capture_ratio);
+               } else
+                       return SR_ERR;
+               break;
        default:
                return SR_ERR_NA;
        }
@@ -488,10 +498,13 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-static int config_set(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)
 {
        struct dev_context *devc;
 
+       (void)probe_group;
+
        if (sdi->status != SR_ST_ACTIVE)
                return SR_ERR_DEV_CLOSED;
 
@@ -514,12 +527,15 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-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_probe_group *probe_group)
 {
        struct dev_context *devc;
        GVariant *gvar;
        GVariantBuilder gvb;
 
+       (void)probe_group;
+
        switch (key) {
        case SR_CONF_DEVICE_OPTIONS:
                *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
@@ -554,7 +570,7 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
+static int dev_acquisition_start(const struct sr_dev_inst *sdi,
                void *cb_data)
 {
        struct dev_context *devc;
@@ -609,8 +625,8 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
        analyzer_read_start(usb->devhdl);
        /* Send the incoming transfer to the session bus. */
        n = get_memory_size(devc->memory_size);
-       if (devc->max_memory_size * 4 < n)
-               n = devc->max_memory_size * 4;
+       if (devc->max_sample_depth * 4 < n)
+               n = devc->max_sample_depth * 4;
        for (packet_num = 0; packet_num < n / PACKET_SIZE; packet_num++) {
                res = analyzer_read_data(usb->devhdl, buf, PACKET_SIZE);
                sr_info("Tried to read %d bytes, actually read %d bytes.",
@@ -634,7 +650,7 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
 }
 
 /* TODO: This stops acquisition on ALL devices, ignoring dev_index. */
-static int hw_dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
 {
        struct dev_context *devc;
        struct sr_usb_dev_inst *usb;
@@ -659,17 +675,17 @@ SR_PRIV struct sr_dev_driver zeroplus_logic_cube_driver_info = {
        .name = "zeroplus-logic-cube",
        .longname = "ZEROPLUS Logic Cube LAP-C series",
        .api_version = 1,
-       .init = hw_init,
-       .cleanup = hw_cleanup,
-       .scan = hw_scan,
-       .dev_list = hw_dev_list,
-       .dev_clear = hw_cleanup,
+       .init = init,
+       .cleanup = cleanup,
+       .scan = scan,
+       .dev_list = dev_list,
+       .dev_clear = dev_clear,
        .config_get = config_get,
        .config_set = config_set,
        .config_list = config_list,
-       .dev_open = hw_dev_open,
-       .dev_close = hw_dev_close,
-       .dev_acquisition_start = hw_dev_acquisition_start,
-       .dev_acquisition_stop = hw_dev_acquisition_stop,
+       .dev_open = dev_open,
+       .dev_close = dev_close,
+       .dev_acquisition_start = dev_acquisition_start,
+       .dev_acquisition_stop = dev_acquisition_stop,
        .priv = NULL,
 };