demo: Split supported device options by probe group.
This commit is contained in:
parent
dc3b3be5cb
commit
7a1da33198
|
@ -113,20 +113,23 @@ struct dev_context {
|
||||||
GSList *analog_probe_groups;
|
GSList *analog_probe_groups;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const int32_t hwopts[] = {
|
static const int32_t scanopts[] = {
|
||||||
SR_CONF_NUM_LOGIC_PROBES,
|
SR_CONF_NUM_LOGIC_PROBES,
|
||||||
SR_CONF_NUM_ANALOG_PROBES,
|
SR_CONF_NUM_ANALOG_PROBES,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const int hwcaps[] = {
|
static const int devopts[] = {
|
||||||
SR_CONF_LOGIC_ANALYZER,
|
SR_CONF_LOGIC_ANALYZER,
|
||||||
SR_CONF_DEMO_DEV,
|
SR_CONF_DEMO_DEV,
|
||||||
SR_CONF_SAMPLERATE,
|
SR_CONF_SAMPLERATE,
|
||||||
SR_CONF_PATTERN_MODE,
|
|
||||||
SR_CONF_LIMIT_SAMPLES,
|
SR_CONF_LIMIT_SAMPLES,
|
||||||
SR_CONF_LIMIT_MSEC,
|
SR_CONF_LIMIT_MSEC,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const int devopts_pg[] = {
|
||||||
|
SR_CONF_PATTERN_MODE,
|
||||||
|
};
|
||||||
|
|
||||||
static const uint64_t samplerates[] = {
|
static const uint64_t samplerates[] = {
|
||||||
SR_HZ(1),
|
SR_HZ(1),
|
||||||
SR_GHZ(1),
|
SR_GHZ(1),
|
||||||
|
@ -430,33 +433,55 @@ 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,
|
static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
|
||||||
const struct sr_probe_group *probe_group)
|
const struct sr_probe_group *probe_group)
|
||||||
{
|
{
|
||||||
|
struct sr_probe *probe;
|
||||||
GVariant *gvar;
|
GVariant *gvar;
|
||||||
GVariantBuilder gvb;
|
GVariantBuilder gvb;
|
||||||
|
|
||||||
(void)sdi;
|
(void)sdi;
|
||||||
(void)probe_group;
|
|
||||||
|
|
||||||
switch (key) {
|
if (key == SR_CONF_SCAN_OPTIONS) {
|
||||||
case SR_CONF_SCAN_OPTIONS:
|
|
||||||
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
|
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
|
||||||
hwopts, ARRAY_SIZE(hwopts), sizeof(int32_t));
|
scanopts, ARRAY_SIZE(scanopts), sizeof(int32_t));
|
||||||
break;
|
return SR_OK;
|
||||||
case SR_CONF_DEVICE_OPTIONS:
|
}
|
||||||
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
|
|
||||||
hwcaps, ARRAY_SIZE(hwcaps), sizeof(int32_t));
|
if (!sdi)
|
||||||
break;
|
return SR_ERR_ARG;
|
||||||
case SR_CONF_SAMPLERATE:
|
|
||||||
g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
|
if (!probe_group) {
|
||||||
gvar = g_variant_new_fixed_array(G_VARIANT_TYPE("t"), samplerates,
|
switch (key) {
|
||||||
ARRAY_SIZE(samplerates), sizeof(uint64_t));
|
case SR_CONF_DEVICE_OPTIONS:
|
||||||
g_variant_builder_add(&gvb, "{sv}", "samplerate-steps", gvar);
|
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
|
||||||
*data = g_variant_builder_end(&gvb);
|
devopts, ARRAY_SIZE(devopts), sizeof(int32_t));
|
||||||
break;
|
break;
|
||||||
case SR_CONF_PATTERN_MODE:
|
case SR_CONF_SAMPLERATE:
|
||||||
*data = g_variant_new_strv(logic_pattern_str, ARRAY_SIZE(logic_pattern_str));
|
g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
|
||||||
break;
|
gvar = g_variant_new_fixed_array(G_VARIANT_TYPE("t"), samplerates,
|
||||||
default:
|
ARRAY_SIZE(samplerates), sizeof(uint64_t));
|
||||||
return SR_ERR_NA;
|
g_variant_builder_add(&gvb, "{sv}", "samplerate-steps", gvar);
|
||||||
|
*data = g_variant_builder_end(&gvb);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return SR_ERR_NA;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
probe = probe_group->probes->data;
|
||||||
|
switch (key) {
|
||||||
|
case SR_CONF_DEVICE_OPTIONS:
|
||||||
|
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
|
||||||
|
devopts_pg, ARRAY_SIZE(devopts_pg), sizeof(int32_t));
|
||||||
|
break;
|
||||||
|
case SR_CONF_PATTERN_MODE:
|
||||||
|
if (probe->type == SR_PROBE_LOGIC)
|
||||||
|
*data = g_variant_new_strv(logic_pattern_str,
|
||||||
|
ARRAY_SIZE(logic_pattern_str));
|
||||||
|
else
|
||||||
|
*data = g_variant_new_strv(analog_pattern_str,
|
||||||
|
ARRAY_SIZE(analog_pattern_str));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return SR_ERR_NA;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
|
|
Loading…
Reference in New Issue