const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
{
struct dev_context *devc;
- uint64_t tmp;
(void)cg;
devc->limit_msec = g_variant_get_uint64(data);
break;
case SR_CONF_LIMIT_SAMPLES:
- tmp = g_variant_get_uint64(data);
- devc->limit_samples = tmp;
- devc->limit_msec = sigma_limit_samples_to_msec(devc, tmp);
+ devc->limit_samples = g_variant_get_uint64(data);
+ devc->limit_msec = sigma_limit_samples_to_msec(devc,
+ devc->limit_samples);
break;
#if ASIX_SIGMA_WITH_TRIGGER
case SR_CONF_CAPTURE_RATIO:
- tmp = g_variant_get_uint64(data);
- if (tmp > 100)
- return SR_ERR;
- devc->capture_ratio = tmp;
+ devc->capture_ratio = g_variant_get_uint64(data);
break;
#endif
default:
int num_channels;
int cur_channels;
int samples_per_event;
- int capture_ratio;
+ uint64_t capture_ratio;
struct sigma_trigger trigger;
int use_triggers;
struct sigma_state state;
return beaglelogic_set_triggerflags(devc);
case SR_CONF_CAPTURE_RATIO:
devc->capture_ratio = g_variant_get_uint64(data);
- if (devc->capture_ratio > 100)
- return SR_ERR;
- return SR_OK;
+ break;
default:
return SR_ERR_NA;
}
if ((trigger = sr_session_trigger_get(sdi->session))) {
int pre_trigger_samples = 0;
if (devc->limit_samples > 0)
- pre_trigger_samples = devc->capture_ratio * devc->limit_samples/100;
+ pre_trigger_samples = (devc->capture_ratio * devc->limit_samples) / 100;
devc->stl = soft_trigger_logic_new(sdi, trigger, pre_trigger_samples);
if (!devc->stl)
return SR_ERR_MALLOC;
break;
case SR_CONF_CAPTURE_RATIO:
devc->capture_ratio = g_variant_get_uint64(data);
- return (devc->capture_ratio > 100) ? SR_ERR : SR_OK;
+ break;
case SR_CONF_VOLTAGE_THRESHOLD:
if (!strcmp(devc->profile->model, "DSLogic")) {
if ((idx = std_double_tuple_idx(data, ARRAY_AND_SIZE(voltage_thresholds))) < 0)
break;
case SR_CONF_CAPTURE_RATIO:
devc->capture_ratio = g_variant_get_uint64(data);
- return (devc->capture_ratio > 100) ? SR_ERR : SR_OK;
+ break;
default:
return SR_ERR_NA;
}
if ((trigger = sr_session_trigger_get(sdi->session))) {
int pre_trigger_samples = 0;
if (devc->limit_samples > 0)
- pre_trigger_samples = devc->capture_ratio * devc->limit_samples/100;
+ pre_trigger_samples = (devc->capture_ratio * devc->limit_samples) / 100;
devc->stl = soft_trigger_logic_new(sdi, trigger, pre_trigger_samples);
if (!devc->stl)
return SR_ERR_MALLOC;
static int config_set(uint32_t key, GVariant *data,
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
{
- uint64_t samplerate, limit_samples, capture_ratio;
+ struct dev_context *devc;
+ uint64_t samplerate, limit_samples;
(void)cg;
+ devc = sdi->priv;
+
switch (key) {
case SR_CONF_LIMIT_SAMPLES:
limit_samples = g_variant_get_uint64(data);
samplerate = g_variant_get_uint64(data);
return sl2_set_samplerate(sdi, samplerate);
case SR_CONF_CAPTURE_RATIO:
- capture_ratio = g_variant_get_uint64(data);
- return sl2_set_capture_ratio(sdi, capture_ratio);
+ devc->capture_ratio = g_variant_get_uint64(data);
+ break;
default:
return SR_ERR_NA;
}
return SR_OK;
}
-SR_PRIV int sl2_set_capture_ratio(const struct sr_dev_inst *sdi,
- uint64_t capture_ratio)
-{
- struct dev_context *devc;
-
- devc = sdi->priv;
-
- if (capture_ratio > 100) {
- sr_err("Invalid capture ratio: %" PRIu64 " %%.", capture_ratio);
- return SR_ERR_ARG;
- }
-
- sr_info("Capture ratio set to %" PRIu64 " %%.", capture_ratio);
-
- devc->capture_ratio = capture_ratio;
-
- return SR_OK;
-}
-
SR_PRIV int sl2_set_after_trigger_delay(const struct sr_dev_inst *sdi,
uint64_t after_trigger_delay)
{
uint8_t trigger_channel;
uint8_t trigger_type;
- unsigned int capture_ratio;
+ uint64_t capture_ratio;
/* Time that the trigger will be delayed in milliseconds. */
uint16_t after_trigger_delay;
SR_PRIV int sl2_set_limit_samples(const struct sr_dev_inst *sdi,
uint64_t limit_samples);
SR_PRIV int sl2_convert_trigger(const struct sr_dev_inst *sdi);
-SR_PRIV int sl2_set_capture_ratio(const struct sr_dev_inst *sdi,
- uint64_t capture_ratio);
SR_PRIV int sl2_set_after_trigger_delay(const struct sr_dev_inst *sdi,
uint64_t after_trigger_delay);
SR_PRIV void sl2_calculate_trigger_samples(const struct sr_dev_inst *sdi);
return lls_set_samplerate(sdi, g_variant_get_uint64(data));
case SR_CONF_CAPTURE_RATIO:
devc->capture_ratio = g_variant_get_uint64(data);
- if (devc->capture_ratio > 100)
- return SR_ERR;
break;
default:
return SR_ERR_NA;
total_samples = devc->num_thousand_samples * 1000;
- pre_trigger_samples = total_samples * devc->capture_ratio / 100;
+ pre_trigger_samples = (total_samples * devc->capture_ratio) / 100;
post_trigger_samples = total_samples - pre_trigger_samples;
pre_trigger_tr = transform_sample_count(devc, pre_trigger_samples);
break;
case SR_CONF_CAPTURE_RATIO:
devc->capture_ratio = g_variant_get_uint64(data);
- if (devc->capture_ratio < 0 || devc->capture_ratio > 100)
- return SR_ERR;
- else
- return SR_OK;
break;
case SR_CONF_EXTERNAL_CLOCK:
if (g_variant_get_boolean(data)) {
uint64_t cur_samplerate;
uint32_t cur_samplerate_divider;
uint64_t limit_samples;
- int capture_ratio;
+ uint64_t capture_ratio;
int trigger_at;
uint32_t channel_mask;
uint32_t trigger_mask[NUM_TRIGGER_STAGES];
break;
case SR_CONF_CAPTURE_RATIO:
devc->capture_ratio = g_variant_get_uint64(data);
- if (devc->capture_ratio < 0 || devc->capture_ratio > 100)
- return SR_ERR;
- else
- return SR_OK;
break;
case SR_CONF_EXTERNAL_CLOCK:
if (g_variant_get_boolean(data)) {
uint32_t cur_samplerate_divider;
uint32_t max_samples;
uint64_t limit_samples;
- int capture_ratio;
+ uint64_t capture_ratio;
int trigger_at;
uint32_t channel_mask;
uint32_t trigger_mask[NUM_TRIGGER_STAGES];
break;
case SR_CONF_CAPTURE_RATIO:
devc->capture_ratio = g_variant_get_uint64(data);
- return (devc->capture_ratio > 100) ? SR_ERR : SR_OK;
+ break;
case SR_CONF_VOLTAGE_THRESHOLD:
if ((idx = std_double_tuple_idx(data, ARRAY_AND_SIZE(volt_thresholds))) < 0)
return SR_ERR_ARG;
if ((trigger = sr_session_trigger_get(sdi->session))) {
int pre_trigger_samples = 0;
if (devc->limit_samples > 0)
- pre_trigger_samples = devc->capture_ratio * devc->limit_samples/100;
+ pre_trigger_samples = (devc->capture_ratio * devc->limit_samples) / 100;
devc->stl = soft_trigger_logic_new(sdi, trigger, pre_trigger_samples);
if (!devc->stl)
return SR_ERR_MALLOC;
case SR_CONF_LIMIT_SAMPLES:
return set_limit_samples(devc, g_variant_get_uint64(data));
case SR_CONF_CAPTURE_RATIO:
- return set_capture_ratio(devc, g_variant_get_uint64(data));
+ devc->capture_ratio = g_variant_get_uint64(data);
+ break;
case SR_CONF_VOLTAGE_THRESHOLD:
g_variant_get(data, "(dd)", &low, &high);
return set_voltage_threshold(devc, (low + high) / 2.0);
return SR_OK;
}
-SR_PRIV int set_capture_ratio(struct dev_context *devc, uint64_t ratio)
-{
- if (ratio > 100) {
- sr_err("Invalid capture ratio: %" PRIu64 ".", ratio);
- return SR_ERR_ARG;
- }
-
- devc->capture_ratio = ratio;
-
- sr_info("Setting capture ratio to %d%%.", devc->capture_ratio);
-
- return SR_OK;
-}
-
SR_PRIV int set_voltage_threshold(struct dev_context *devc, double thresh)
{
if (thresh > 6.0)
trigger_depth = devc->limit_samples;
if (devc->trigger)
- triggerbar = trigger_depth * devc->capture_ratio / 100;
+ triggerbar = (trigger_depth * devc->capture_ratio) / 100;
else
triggerbar = 0;
//uint8_t trigger_value[NUM_TRIGGER_STAGES];
// uint8_t trigger_buffer[NUM_TRIGGER_STAGES];
int trigger;
- unsigned int capture_ratio;
+ uint64_t capture_ratio;
double cur_threshold;
const struct zp_model *prof;
};
SR_PRIV unsigned int get_memory_size(int type);
SR_PRIV int zp_set_samplerate(struct dev_context *devc, uint64_t samplerate);
SR_PRIV int set_limit_samples(struct dev_context *devc, uint64_t samples);
-SR_PRIV int set_capture_ratio(struct dev_context *devc, uint64_t ratio);
SR_PRIV int set_voltage_threshold(struct dev_context *devc, double thresh);
SR_PRIV void set_triggerbar(struct dev_context *devc);
return SR_ERR_ARG;
}
break;
+ case SR_CONF_CAPTURE_RATIO:
+ /* Capture ratio must always be between 0 and 100. */
+ if (op != SR_CONF_SET || !data)
+ break;
+ if (g_variant_get_uint64(data) > 100) {
+ sr_err("Capture ratio must be 0..100.");
+ return SR_ERR_ARG;
+ }
+ break;
}
if (sr_config_list(driver, sdi, cg, SR_CONF_DEVICE_OPTIONS, &gvar_opts) != SR_OK) {