Remove SR_CONF_MAX_UNCOMPRESSED_SAMPLES again.

The maximum sample size that can be set on a device is now published
by sr_config_list(SR_CONF_LIMIT_SAMPLES). This returns a tuple of
uint64_t representing minimum and maximum number of samples.
This commit is contained in:
Bert Vermeulen 2014-01-19 17:18:59 +01:00
parent 9497f49ef8
commit f0de2dd0fa
6 changed files with 49 additions and 58 deletions

View File

@ -42,7 +42,6 @@ SR_PRIV const int32_t chronovu_la8_hwcaps[] = {
SR_CONF_SAMPLERATE,
SR_CONF_LIMIT_MSEC, /* TODO: Not yet implemented. */
SR_CONF_LIMIT_SAMPLES, /* TODO: Not yet implemented. */
SR_CONF_MAX_UNCOMPRESSED_SAMPLES,
};
/*
@ -280,9 +279,6 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi,
} else
return SR_ERR;
break;
case SR_CONF_MAX_UNCOMPRESSED_SAMPLES:
*data = g_variant_new_uint64(MAX_NUM_SAMPLES);
break;
default:
return SR_ERR_NA;
}
@ -339,7 +335,7 @@ static int config_set(int id, 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)
{
GVariant *gvar;
GVariant *gvar, *grange[2];
GVariantBuilder gvb;
(void)sdi;
@ -362,6 +358,11 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
g_variant_builder_add(&gvb, "{sv}", "samplerates", gvar);
*data = g_variant_builder_end(&gvb);
break;
case SR_CONF_LIMIT_SAMPLES:
grange[0] = g_variant_new_uint64(0);
grange[1] = g_variant_new_uint64(MAX_NUM_SAMPLES);
*data = g_variant_new_tuple(grange, 2);
break;
case SR_CONF_TRIGGER_TYPE:
*data = g_variant_new_string(TRIGGER_TYPE);
break;

View File

@ -25,7 +25,6 @@ static const int hwcaps[] = {
SR_CONF_LIMIT_SAMPLES,
SR_CONF_TRIGGER_TYPE,
SR_CONF_CAPTURE_RATIO,
SR_CONF_MAX_UNCOMPRESSED_SAMPLES,
};
SR_PRIV const uint64_t sl2_samplerates[NUM_SAMPLERATES] = {
@ -326,9 +325,6 @@ static int config_get(int key, GVariant **data, const struct sr_dev_inst *sdi,
case SR_CONF_CAPTURE_RATIO:
*data = g_variant_new_uint64(devc->capture_ratio);
break;
case SR_CONF_MAX_UNCOMPRESSED_SAMPLES:
*data = g_variant_new_uint64(MAX_SAMPLES);
break;
default:
return SR_ERR_NA;
}
@ -372,7 +368,7 @@ static int config_set(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)
{
GVariant *gvar;
GVariant *gvar, *grange[2];
GVariantBuilder gvb;
int ret;
@ -397,6 +393,11 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
case SR_CONF_TRIGGER_TYPE:
*data = g_variant_new_string(TRIGGER_TYPES);
break;
case SR_CONF_LIMIT_SAMPLES:
grange[0] = g_variant_new_uint64(0);
grange[1] = g_variant_new_uint64(MAX_SAMPLES);
*data = g_variant_new_tuple(grange, 2);
break;
default:
return SR_ERR_NA;
}

View File

@ -37,7 +37,6 @@ static const int32_t hwcaps[] = {
SR_CONF_PATTERN_MODE,
SR_CONF_SWAP,
SR_CONF_RLE,
SR_CONF_MAX_UNCOMPRESSED_SAMPLES,
};
#define STR_PATTERN_EXTERNAL "external"
@ -220,7 +219,6 @@ 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;
int num_channels, i;
(void)probe_group;
@ -247,24 +245,6 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi,
case SR_CONF_RLE:
*data = g_variant_new_boolean(devc->flag_reg & FLAG_RLE ? TRUE : FALSE);
break;
case SR_CONF_MAX_UNCOMPRESSED_SAMPLES:
if (devc->flag_reg & FLAG_RLE)
return SR_ERR_NA;
if (devc->max_samples == 0)
/* Device didn't specify sample memory size in metadata. */
return SR_ERR_NA;
/*
* Channel groups are turned off if no probes in that group are
* enabled, making more room for samples for the enabled group.
*/
ols_configure_probes(sdi);
num_channels = 0;
for (i = 0; i < 4; i++) {
if (devc->probe_mask & (0xff << (i * 8)))
num_channels++;
}
*data = g_variant_new_uint64(devc->max_samples / num_channels);
break;
default:
return SR_ERR_NA;
}
@ -363,10 +343,11 @@ static int config_set(int id, 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)
{
GVariant *gvar;
struct dev_context *devc;
GVariant *gvar, *grange[2];
GVariantBuilder gvb;
int num_channels, i;
(void)sdi;
(void)probe_group;
switch (key) {
@ -391,6 +372,29 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
case SR_CONF_PATTERN_MODE:
*data = g_variant_new_strv(patterns, ARRAY_SIZE(patterns));
break;
case SR_CONF_LIMIT_SAMPLES:
if (!sdi)
return SR_ERR_ARG;
devc = sdi->priv;
if (devc->flag_reg & FLAG_RLE)
return SR_ERR_NA;
if (devc->max_samples == 0)
/* Device didn't specify sample memory size in metadata. */
return SR_ERR_NA;
/*
* Channel groups are turned off if no probes in that group are
* enabled, making more room for samples for the enabled group.
*/
ols_configure_probes(sdi);
num_channels = 0;
for (i = 0; i < 4; i++) {
if (devc->probe_mask & (0xff << (i * 8)))
num_channels++;
}
grange[0] = g_variant_new_uint64(MIN_NUM_SAMPLES);
grange[1] = g_variant_new_uint64(devc->max_samples / num_channels);
*data = g_variant_new_tuple(grange, 2);
break;
default:
return SR_ERR_NA;
}

View File

@ -59,7 +59,6 @@ static const int32_t hwcaps[] = {
SR_CONF_CAPTURE_RATIO,
SR_CONF_VOLTAGE_THRESHOLD,
SR_CONF_LIMIT_SAMPLES,
SR_CONF_MAX_UNCOMPRESSED_SAMPLES,
};
/*
@ -506,16 +505,6 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi,
} else
return SR_ERR_ARG;
break;
case SR_CONF_MAX_UNCOMPRESSED_SAMPLES:
if (sdi) {
/* As long as this driver doesn't support compression,
* this is ok. When compression is enabled, this should
* return SR_ERR_NA instead. */
devc = sdi->priv;
*data = g_variant_new_uint64(devc->max_sample_depth);
} else
return SR_ERR;
break;
default:
return SR_ERR_NA;
}
@ -560,7 +549,7 @@ 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;
GVariant *gvar, *grange[2];
GVariantBuilder gvb;
double v;
GVariant *range[2];
@ -604,6 +593,14 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
}
*data = g_variant_builder_end(&gvb);
break;
case SR_CONF_LIMIT_SAMPLES:
if (!sdi)
return SR_ERR_ARG;
devc = sdi->priv;
grange[0] = g_variant_new_uint64(0);
grange[1] = g_variant_new_uint64(devc->max_sample_depth);
*data = g_variant_new_tuple(grange, 2);
break;
default:
return SR_ERR_NA;
}

View File

@ -100,8 +100,6 @@ static struct sr_config_info sr_config_info_data[] = {
"Number of logic probes", NULL},
{SR_CONF_NUM_ANALOG_PROBES, SR_T_INT32, "analog_probes",
"Number of analog probes", NULL},
{SR_CONF_MAX_UNCOMPRESSED_SAMPLES, SR_T_UINT64, "max_uncompressed_samples",
"Maximum number of uncompressed samples", NULL},
{SR_CONF_OUTPUT_VOLTAGE, SR_T_FLOAT, "output_voltage",
"Current output voltage", NULL},
{SR_CONF_OUTPUT_VOLTAGE_MAX, SR_T_FLOAT, "output_voltage_max",
@ -118,6 +116,8 @@ static struct sr_config_info sr_config_info_data[] = {
"Over-voltage protection", NULL},
{SR_CONF_OVER_CURRENT_PROTECTION, SR_T_BOOL, "ocp",
"Over-current protection", NULL},
{SR_CONF_LIMIT_SAMPLES, SR_T_UINT64, "limit_samples",
"Sample limit", NULL},
{0, 0, NULL, NULL, NULL},
};

View File

@ -868,18 +868,6 @@ enum {
*/
SR_CONF_DATA_SOURCE,
/**
* On devices without sample compression (or compression turned off),
* this returns the maximum number of samples that can be stored. This
* can change as probes are disabled, depending on the hardware, so
* should be queried after such changes are made. If not applicable,
* fetching this value with sr_config_get() will return SR_ERR_NA.
*
* SR_CONF_LIMIT_SAMPLES should not be set to a higher value than
* this value, if applicable.
*/
SR_CONF_MAX_UNCOMPRESSED_SAMPLES,
/*--- Acquisition modes ---------------------------------------------*/
/**