]> sigrok.org Git - libsigrok.git/commitdiff
asix-sigma: rephrase limits management, use sub structure
authorGerhard Sittig <redacted>
Sun, 17 May 2020 16:49:27 +0000 (18:49 +0200)
committerGerhard Sittig <redacted>
Sun, 31 May 2020 21:42:32 +0000 (23:42 +0200)
Move the acquisition limits related variables into a sub struct within
the device context. Over time they became numerous, and might grow more
in the future.

src/hardware/asix-sigma/api.c
src/hardware/asix-sigma/protocol.c
src/hardware/asix-sigma/protocol.h

index db148076bf279fe4b272f07203fc9de7e3413b68..ad711d60e47d57ed94a677a899592f384aef9e62 100644 (file)
@@ -248,7 +248,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
                devc->id.serno = serno_num;
                devc->id.prefix = serno_pre;
                devc->id.type = dev_type;
-               sr_sw_limits_init(&devc->cfg_limits);
+               sr_sw_limits_init(&devc->limit.config);
                devc->capture_ratio = 50;
                devc->use_triggers = FALSE;
 
@@ -316,7 +316,7 @@ static int config_get(uint32_t key, GVariant **data,
                break;
        case SR_CONF_LIMIT_MSEC:
        case SR_CONF_LIMIT_SAMPLES:
-               return sr_sw_limits_config_get(&devc->cfg_limits, key, data);
+               return sr_sw_limits_config_get(&devc->limit.config, key, data);
 #if ASIX_SIGMA_WITH_TRIGGER
        case SR_CONF_CAPTURE_RATIO:
                *data = g_variant_new_uint64(devc->capture_ratio);
@@ -375,7 +375,7 @@ static int config_set(uint32_t key, GVariant *data,
                break;
        case SR_CONF_LIMIT_MSEC:
        case SR_CONF_LIMIT_SAMPLES:
-               return sr_sw_limits_config_set(&devc->cfg_limits, key, data);
+               return sr_sw_limits_config_set(&devc->limit.config, key, data);
 #if ASIX_SIGMA_WITH_TRIGGER
        case SR_CONF_CAPTURE_RATIO:
                devc->capture_ratio = g_variant_get_uint64(data);
index 37bd9babb5259ace10889eec329adc3f0dc6eef4..1804f1dd72f7c871d627390c14fc08587616db4e 100644 (file)
@@ -933,10 +933,10 @@ SR_PRIV int sigma_set_acquire_timeout(struct dev_context *devc)
        uint64_t worst_cluster_time_ms;
        uint64_t count_msecs, acquire_msecs;
 
-       sr_sw_limits_init(&devc->acq_limits);
+       sr_sw_limits_init(&devc->limit.acquire);
 
        /* Get sample count limit, convert to msecs. */
-       ret = sr_sw_limits_config_get(&devc->cfg_limits,
+       ret = sr_sw_limits_config_get(&devc->limit.config,
                SR_CONF_LIMIT_SAMPLES, &data);
        if (ret != SR_OK)
                return ret;
@@ -947,7 +947,7 @@ SR_PRIV int sigma_set_acquire_timeout(struct dev_context *devc)
                count_msecs = 1000 * user_count / devc->clock.samplerate + 1;
 
        /* Get time limit, which is in msecs. */
-       ret = sr_sw_limits_config_get(&devc->cfg_limits,
+       ret = sr_sw_limits_config_get(&devc->limit.config,
                SR_CONF_LIMIT_MSEC, &data);
        if (ret != SR_OK)
                return ret;
@@ -967,13 +967,13 @@ SR_PRIV int sigma_set_acquire_timeout(struct dev_context *devc)
        worst_cluster_time_ms = 1000 * 65536 / devc->clock.samplerate;
        acquire_msecs += 2 * worst_cluster_time_ms;
        data = g_variant_new_uint64(acquire_msecs);
-       ret = sr_sw_limits_config_set(&devc->acq_limits,
+       ret = sr_sw_limits_config_set(&devc->limit.acquire,
                SR_CONF_LIMIT_MSEC, data);
        g_variant_unref(data);
        if (ret != SR_OK)
                return ret;
 
-       sr_sw_limits_acquisition_start(&devc->acq_limits);
+       sr_sw_limits_acquisition_start(&devc->limit.acquire);
        return SR_OK;
 }
 
@@ -1157,7 +1157,7 @@ static int alloc_submit_buffer(struct sr_dev_inst *sdi)
        if (!buffer->sample_data)
                return SR_ERR_MALLOC;
        buffer->write_pointer = buffer->sample_data;
-       sr_sw_limits_init(&devc->feed_limits);
+       sr_sw_limits_init(&devc->limit.submit);
 
        buffer->sdi = sdi;
        memset(&buffer->logic, 0, sizeof(buffer->logic));
@@ -1177,9 +1177,9 @@ static int setup_submit_limit(struct dev_context *devc)
        GVariant *data;
        uint64_t total;
 
-       limits = &devc->feed_limits;
+       limits = &devc->limit.submit;
 
-       ret = sr_sw_limits_config_get(&devc->cfg_limits,
+       ret = sr_sw_limits_config_get(&devc->limit.config,
                SR_CONF_LIMIT_SAMPLES, &data);
        if (ret != SR_OK)
                return ret;
@@ -1249,7 +1249,7 @@ static int addto_submit_buffer(struct dev_context *devc,
        int ret;
 
        buffer = devc->buffer;
-       limits = &devc->feed_limits;
+       limits = &devc->limit.submit;
        if (sr_sw_limits_check(limits))
                count = 0;
 
@@ -1759,7 +1759,7 @@ static int sigma_capture_mode(struct sr_dev_inst *sdi)
        struct dev_context *devc;
 
        devc = sdi->priv;
-       if (sr_sw_limits_check(&devc->acq_limits))
+       if (sr_sw_limits_check(&devc->limit.acquire))
                return download_capture(sdi);
 
        return TRUE;
index 171a3a66db36466f263eb4c21f199b6344ae5a86..e780de4225523bb8c4f5bd513aacd72f7d865130 100644 (file)
@@ -359,9 +359,16 @@ struct dev_context {
                size_t clock_pin;
                enum ext_clock_edge_t clock_edge;
        } clock;
-       struct sr_sw_limits cfg_limits; /* Configured limits (user specified). */
-       struct sr_sw_limits acq_limits; /* Acquisition limits (internal use). */
-       struct sr_sw_limits feed_limits; /* Datafeed limits (internal use). */
+       struct {
+               /*
+                * User specified configuration values, in contrast to
+                * internal arrangement of acquisition, and submission
+                * to the session feed.
+                */
+               struct sr_sw_limits config;
+               struct sr_sw_limits acquire;
+               struct sr_sw_limits submit;
+       } limit;
        enum sigma_firmware_idx firmware_idx;
        size_t num_channels;
        size_t samples_per_event;