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.
This commit is contained in:
parent
fb65ca09b7
commit
156b6879e9
|
@ -248,7 +248,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
|
||||||
devc->id.serno = serno_num;
|
devc->id.serno = serno_num;
|
||||||
devc->id.prefix = serno_pre;
|
devc->id.prefix = serno_pre;
|
||||||
devc->id.type = dev_type;
|
devc->id.type = dev_type;
|
||||||
sr_sw_limits_init(&devc->cfg_limits);
|
sr_sw_limits_init(&devc->limit.config);
|
||||||
devc->capture_ratio = 50;
|
devc->capture_ratio = 50;
|
||||||
devc->use_triggers = FALSE;
|
devc->use_triggers = FALSE;
|
||||||
|
|
||||||
|
@ -316,7 +316,7 @@ static int config_get(uint32_t key, GVariant **data,
|
||||||
break;
|
break;
|
||||||
case SR_CONF_LIMIT_MSEC:
|
case SR_CONF_LIMIT_MSEC:
|
||||||
case SR_CONF_LIMIT_SAMPLES:
|
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
|
#if ASIX_SIGMA_WITH_TRIGGER
|
||||||
case SR_CONF_CAPTURE_RATIO:
|
case SR_CONF_CAPTURE_RATIO:
|
||||||
*data = g_variant_new_uint64(devc->capture_ratio);
|
*data = g_variant_new_uint64(devc->capture_ratio);
|
||||||
|
@ -375,7 +375,7 @@ static int config_set(uint32_t key, GVariant *data,
|
||||||
break;
|
break;
|
||||||
case SR_CONF_LIMIT_MSEC:
|
case SR_CONF_LIMIT_MSEC:
|
||||||
case SR_CONF_LIMIT_SAMPLES:
|
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
|
#if ASIX_SIGMA_WITH_TRIGGER
|
||||||
case SR_CONF_CAPTURE_RATIO:
|
case SR_CONF_CAPTURE_RATIO:
|
||||||
devc->capture_ratio = g_variant_get_uint64(data);
|
devc->capture_ratio = g_variant_get_uint64(data);
|
||||||
|
|
|
@ -933,10 +933,10 @@ SR_PRIV int sigma_set_acquire_timeout(struct dev_context *devc)
|
||||||
uint64_t worst_cluster_time_ms;
|
uint64_t worst_cluster_time_ms;
|
||||||
uint64_t count_msecs, acquire_msecs;
|
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. */
|
/* 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);
|
SR_CONF_LIMIT_SAMPLES, &data);
|
||||||
if (ret != SR_OK)
|
if (ret != SR_OK)
|
||||||
return ret;
|
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;
|
count_msecs = 1000 * user_count / devc->clock.samplerate + 1;
|
||||||
|
|
||||||
/* Get time limit, which is in msecs. */
|
/* 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);
|
SR_CONF_LIMIT_MSEC, &data);
|
||||||
if (ret != SR_OK)
|
if (ret != SR_OK)
|
||||||
return ret;
|
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;
|
worst_cluster_time_ms = 1000 * 65536 / devc->clock.samplerate;
|
||||||
acquire_msecs += 2 * worst_cluster_time_ms;
|
acquire_msecs += 2 * worst_cluster_time_ms;
|
||||||
data = g_variant_new_uint64(acquire_msecs);
|
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);
|
SR_CONF_LIMIT_MSEC, data);
|
||||||
g_variant_unref(data);
|
g_variant_unref(data);
|
||||||
if (ret != SR_OK)
|
if (ret != SR_OK)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
sr_sw_limits_acquisition_start(&devc->acq_limits);
|
sr_sw_limits_acquisition_start(&devc->limit.acquire);
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1157,7 +1157,7 @@ static int alloc_submit_buffer(struct sr_dev_inst *sdi)
|
||||||
if (!buffer->sample_data)
|
if (!buffer->sample_data)
|
||||||
return SR_ERR_MALLOC;
|
return SR_ERR_MALLOC;
|
||||||
buffer->write_pointer = buffer->sample_data;
|
buffer->write_pointer = buffer->sample_data;
|
||||||
sr_sw_limits_init(&devc->feed_limits);
|
sr_sw_limits_init(&devc->limit.submit);
|
||||||
|
|
||||||
buffer->sdi = sdi;
|
buffer->sdi = sdi;
|
||||||
memset(&buffer->logic, 0, sizeof(buffer->logic));
|
memset(&buffer->logic, 0, sizeof(buffer->logic));
|
||||||
|
@ -1177,9 +1177,9 @@ static int setup_submit_limit(struct dev_context *devc)
|
||||||
GVariant *data;
|
GVariant *data;
|
||||||
uint64_t total;
|
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);
|
SR_CONF_LIMIT_SAMPLES, &data);
|
||||||
if (ret != SR_OK)
|
if (ret != SR_OK)
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -1249,7 +1249,7 @@ static int addto_submit_buffer(struct dev_context *devc,
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
buffer = devc->buffer;
|
buffer = devc->buffer;
|
||||||
limits = &devc->feed_limits;
|
limits = &devc->limit.submit;
|
||||||
if (sr_sw_limits_check(limits))
|
if (sr_sw_limits_check(limits))
|
||||||
count = 0;
|
count = 0;
|
||||||
|
|
||||||
|
@ -1759,7 +1759,7 @@ static int sigma_capture_mode(struct sr_dev_inst *sdi)
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
if (sr_sw_limits_check(&devc->acq_limits))
|
if (sr_sw_limits_check(&devc->limit.acquire))
|
||||||
return download_capture(sdi);
|
return download_capture(sdi);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
|
@ -359,9 +359,16 @@ struct dev_context {
|
||||||
size_t clock_pin;
|
size_t clock_pin;
|
||||||
enum ext_clock_edge_t clock_edge;
|
enum ext_clock_edge_t clock_edge;
|
||||||
} clock;
|
} clock;
|
||||||
struct sr_sw_limits cfg_limits; /* Configured limits (user specified). */
|
struct {
|
||||||
struct sr_sw_limits acq_limits; /* Acquisition limits (internal use). */
|
/*
|
||||||
struct sr_sw_limits feed_limits; /* Datafeed limits (internal use). */
|
* 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;
|
enum sigma_firmware_idx firmware_idx;
|
||||||
size_t num_channels;
|
size_t num_channels;
|
||||||
size_t samples_per_event;
|
size_t samples_per_event;
|
||||||
|
|
Loading…
Reference in New Issue