demo: Split supported device options by probe group.

This commit is contained in:
Bert Vermeulen 2014-01-12 22:36:39 +01:00
parent dc3b3be5cb
commit 7a1da33198
1 changed files with 49 additions and 24 deletions

View File

@ -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,20 +433,26 @@ 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;
}
if (!sdi)
return SR_ERR_ARG;
if (!probe_group) {
switch (key) {
case SR_CONF_DEVICE_OPTIONS: case SR_CONF_DEVICE_OPTIONS:
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32, *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
hwcaps, ARRAY_SIZE(hwcaps), sizeof(int32_t)); devopts, ARRAY_SIZE(devopts), sizeof(int32_t));
break; break;
case SR_CONF_SAMPLERATE: case SR_CONF_SAMPLERATE:
g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}")); g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
@ -452,12 +461,28 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
g_variant_builder_add(&gvb, "{sv}", "samplerate-steps", gvar); g_variant_builder_add(&gvb, "{sv}", "samplerate-steps", gvar);
*data = g_variant_builder_end(&gvb); *data = g_variant_builder_end(&gvb);
break; 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: case SR_CONF_PATTERN_MODE:
*data = g_variant_new_strv(logic_pattern_str, ARRAY_SIZE(logic_pattern_str)); 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; break;
default: default:
return SR_ERR_NA; return SR_ERR_NA;
} }
}
return SR_OK; return SR_OK;
} }