From: Gerhard Sittig Date: Sun, 17 May 2020 16:49:27 +0000 (+0200) Subject: asix-sigma: rephrase limits management, use sub structure X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=156b6879e9ed8d4f1ee48e13b444822efc976420;p=libsigrok.git asix-sigma: rephrase limits management, use sub structure 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. --- diff --git a/src/hardware/asix-sigma/api.c b/src/hardware/asix-sigma/api.c index db148076..ad711d60 100644 --- a/src/hardware/asix-sigma/api.c +++ b/src/hardware/asix-sigma/api.c @@ -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); diff --git a/src/hardware/asix-sigma/protocol.c b/src/hardware/asix-sigma/protocol.c index 37bd9bab..1804f1dd 100644 --- a/src/hardware/asix-sigma/protocol.c +++ b/src/hardware/asix-sigma/protocol.c @@ -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; diff --git a/src/hardware/asix-sigma/protocol.h b/src/hardware/asix-sigma/protocol.h index 171a3a66..e780de42 100644 --- a/src/hardware/asix-sigma/protocol.h +++ b/src/hardware/asix-sigma/protocol.h @@ -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;