drivers: Factor out std_gvar_samplerates{,_steps}().
This commit is contained in:
parent
db944f1622
commit
463160cbca
|
@ -263,19 +263,12 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
||||||
static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
|
static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
|
||||||
const struct sr_channel_group *cg)
|
const struct sr_channel_group *cg)
|
||||||
{
|
{
|
||||||
GVariant *gvar;
|
|
||||||
GVariantBuilder gvb;
|
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case SR_CONF_SCAN_OPTIONS:
|
case SR_CONF_SCAN_OPTIONS:
|
||||||
case SR_CONF_DEVICE_OPTIONS:
|
case SR_CONF_DEVICE_OPTIONS:
|
||||||
return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
|
return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
|
||||||
case SR_CONF_SAMPLERATE:
|
case SR_CONF_SAMPLERATE:
|
||||||
g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
|
*data = std_gvar_samplerates_steps(samplerates, ARRAY_SIZE(samplerates));
|
||||||
gvar = g_variant_new_fixed_array(G_VARIANT_TYPE("t"), samplerates,
|
|
||||||
ARRAY_SIZE(samplerates), sizeof(uint64_t));
|
|
||||||
g_variant_builder_add(&gvb, "{sv}", "samplerate-steps", gvar);
|
|
||||||
*data = g_variant_builder_end(&gvb);
|
|
||||||
break;
|
break;
|
||||||
case SR_CONF_DATA_SOURCE:
|
case SR_CONF_DATA_SOURCE:
|
||||||
*data = g_variant_new_strv(data_sources, ARRAY_SIZE(data_sources));
|
*data = g_variant_new_strv(data_sources, ARRAY_SIZE(data_sources));
|
||||||
|
|
|
@ -235,18 +235,11 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
||||||
static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
|
static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
|
||||||
const struct sr_channel_group *cg)
|
const struct sr_channel_group *cg)
|
||||||
{
|
{
|
||||||
GVariant *gvar;
|
|
||||||
GVariantBuilder gvb;
|
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case SR_CONF_DEVICE_OPTIONS:
|
case SR_CONF_DEVICE_OPTIONS:
|
||||||
return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts);
|
return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts);
|
||||||
case SR_CONF_SAMPLERATE:
|
case SR_CONF_SAMPLERATE:
|
||||||
g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
|
*data = std_gvar_samplerates(samplerates, samplerates_count);
|
||||||
gvar = g_variant_new_fixed_array(G_VARIANT_TYPE("t"), samplerates,
|
|
||||||
samplerates_count, sizeof(samplerates[0]));
|
|
||||||
g_variant_builder_add(&gvb, "{sv}", "samplerates", gvar);
|
|
||||||
*data = g_variant_builder_end(&gvb);
|
|
||||||
break;
|
break;
|
||||||
#if ASIX_SIGMA_WITH_TRIGGER
|
#if ASIX_SIGMA_WITH_TRIGGER
|
||||||
case SR_CONF_TRIGGER_MATCH:
|
case SR_CONF_TRIGGER_MATCH:
|
||||||
|
|
|
@ -220,8 +220,6 @@ static int config_list(uint32_t key, GVariant **data,
|
||||||
const struct sr_channel_group *cg)
|
const struct sr_channel_group *cg)
|
||||||
{
|
{
|
||||||
uint32_t devopts_cg[MAX_DEVOPTS_CG];
|
uint32_t devopts_cg[MAX_DEVOPTS_CG];
|
||||||
GVariant *gvar;
|
|
||||||
GVariantBuilder gvb;
|
|
||||||
int num_devopts_cg = 0;
|
int num_devopts_cg = 0;
|
||||||
|
|
||||||
if (!cg) {
|
if (!cg) {
|
||||||
|
@ -229,12 +227,7 @@ static int config_list(uint32_t key, GVariant **data,
|
||||||
case SR_CONF_DEVICE_OPTIONS:
|
case SR_CONF_DEVICE_OPTIONS:
|
||||||
return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts);
|
return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts);
|
||||||
case SR_CONF_SAMPLERATE:
|
case SR_CONF_SAMPLERATE:
|
||||||
g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
|
*data = std_gvar_samplerates_steps(samplerates, ARRAY_SIZE(samplerates));
|
||||||
gvar = g_variant_new_fixed_array(G_VARIANT_TYPE("t"),
|
|
||||||
samplerates, ARRAY_SIZE(samplerates), sizeof(uint64_t));
|
|
||||||
g_variant_builder_add(&gvb, "{sv}",
|
|
||||||
"samplerate-steps", gvar);
|
|
||||||
*data = g_variant_builder_end(&gvb);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return SR_ERR_NA;
|
return SR_ERR_NA;
|
||||||
|
|
|
@ -240,19 +240,12 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
||||||
static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
|
static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
|
||||||
const struct sr_channel_group *cg)
|
const struct sr_channel_group *cg)
|
||||||
{
|
{
|
||||||
GVariant *gvar;
|
|
||||||
GVariantBuilder gvb;
|
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case SR_CONF_SCAN_OPTIONS:
|
case SR_CONF_SCAN_OPTIONS:
|
||||||
case SR_CONF_DEVICE_OPTIONS:
|
case SR_CONF_DEVICE_OPTIONS:
|
||||||
return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
|
return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
|
||||||
case SR_CONF_SAMPLERATE:
|
case SR_CONF_SAMPLERATE:
|
||||||
g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
|
*data = std_gvar_samplerates_steps(samplerates, ARRAY_SIZE(samplerates));
|
||||||
gvar = g_variant_new_fixed_array(G_VARIANT_TYPE("t"),
|
|
||||||
samplerates, ARRAY_SIZE(samplerates), sizeof(uint64_t));
|
|
||||||
g_variant_builder_add(&gvb, "{sv}", "samplerate-steps", gvar);
|
|
||||||
*data = g_variant_builder_end(&gvb);
|
|
||||||
break;
|
break;
|
||||||
case SR_CONF_TRIGGER_MATCH:
|
case SR_CONF_TRIGGER_MATCH:
|
||||||
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
|
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
|
||||||
|
|
|
@ -346,8 +346,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
||||||
static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
|
static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
|
||||||
const struct sr_channel_group *cg)
|
const struct sr_channel_group *cg)
|
||||||
{
|
{
|
||||||
GVariant *gvar, *grange[2];
|
GVariant *grange[2];
|
||||||
GVariantBuilder gvb;
|
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
|
|
||||||
devc = (sdi) ? sdi->priv : NULL;
|
devc = (sdi) ? sdi->priv : NULL;
|
||||||
|
@ -358,13 +357,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
|
return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
|
||||||
case SR_CONF_SAMPLERATE:
|
case SR_CONF_SAMPLERATE:
|
||||||
cv_fill_samplerates_if_needed(sdi);
|
cv_fill_samplerates_if_needed(sdi);
|
||||||
g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
|
*data = std_gvar_samplerates(devc->samplerates, ARRAY_SIZE(devc->samplerates));
|
||||||
gvar = g_variant_new_fixed_array(G_VARIANT_TYPE("t"),
|
|
||||||
devc->samplerates,
|
|
||||||
ARRAY_SIZE(devc->samplerates),
|
|
||||||
sizeof(uint64_t));
|
|
||||||
g_variant_builder_add(&gvb, "{sv}", "samplerates", gvar);
|
|
||||||
*data = g_variant_builder_end(&gvb);
|
|
||||||
break;
|
break;
|
||||||
case SR_CONF_LIMIT_SAMPLES:
|
case SR_CONF_LIMIT_SAMPLES:
|
||||||
if (!devc->prof)
|
if (!devc->prof)
|
||||||
|
|
|
@ -355,8 +355,6 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
const struct sr_channel_group *cg)
|
const struct sr_channel_group *cg)
|
||||||
{
|
{
|
||||||
struct sr_channel *ch;
|
struct sr_channel *ch;
|
||||||
GVariant *gvar;
|
|
||||||
GVariantBuilder gvb;
|
|
||||||
|
|
||||||
if (!cg) {
|
if (!cg) {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
|
@ -364,11 +362,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
case SR_CONF_DEVICE_OPTIONS:
|
case SR_CONF_DEVICE_OPTIONS:
|
||||||
return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
|
return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
|
||||||
case SR_CONF_SAMPLERATE:
|
case SR_CONF_SAMPLERATE:
|
||||||
g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
|
*data = std_gvar_samplerates_steps(samplerates, ARRAY_SIZE(samplerates));
|
||||||
gvar = g_variant_new_fixed_array(G_VARIANT_TYPE("t"), samplerates,
|
|
||||||
ARRAY_SIZE(samplerates), sizeof(uint64_t));
|
|
||||||
g_variant_builder_add(&gvb, "{sv}", "samplerate-steps", gvar);
|
|
||||||
*data = g_variant_builder_end(&gvb);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return SR_ERR_NA;
|
return SR_ERR_NA;
|
||||||
|
|
|
@ -583,11 +583,7 @@ static int config_list(uint32_t key, GVariant **data,
|
||||||
*data = g_variant_builder_end(&gvb);
|
*data = g_variant_builder_end(&gvb);
|
||||||
break;
|
break;
|
||||||
case SR_CONF_SAMPLERATE:
|
case SR_CONF_SAMPLERATE:
|
||||||
g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
|
*data = std_gvar_samplerates(devc->samplerates, devc->num_samplerates);
|
||||||
gvar = g_variant_new_fixed_array(G_VARIANT_TYPE("t"), devc->samplerates,
|
|
||||||
devc->num_samplerates, sizeof(uint64_t));
|
|
||||||
g_variant_builder_add(&gvb, "{sv}", "samplerates", gvar);
|
|
||||||
*data = g_variant_builder_end(&gvb);
|
|
||||||
break;
|
break;
|
||||||
case SR_CONF_CLOCK_EDGE:
|
case SR_CONF_CLOCK_EDGE:
|
||||||
*data = g_variant_new_strv(signal_edge_names,
|
*data = g_variant_new_strv(signal_edge_names,
|
||||||
|
|
|
@ -383,19 +383,12 @@ static int config_set(uint32_t key, GVariant *data,
|
||||||
static int config_list(uint32_t key, GVariant **data,
|
static int config_list(uint32_t key, GVariant **data,
|
||||||
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
|
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
|
||||||
{
|
{
|
||||||
GVariant *gvar;
|
|
||||||
GVariantBuilder gvb;
|
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case SR_CONF_SCAN_OPTIONS:
|
case SR_CONF_SCAN_OPTIONS:
|
||||||
case SR_CONF_DEVICE_OPTIONS:
|
case SR_CONF_DEVICE_OPTIONS:
|
||||||
return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
|
return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
|
||||||
case SR_CONF_SAMPLERATE:
|
case SR_CONF_SAMPLERATE:
|
||||||
g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
|
*data = std_gvar_samplerates_steps(samplerates, ARRAY_SIZE(samplerates));
|
||||||
gvar = g_variant_new_fixed_array(G_VARIANT_TYPE("t"),
|
|
||||||
samplerates, ARRAY_SIZE(samplerates), sizeof(uint64_t));
|
|
||||||
g_variant_builder_add(&gvb, "{sv}", "samplerate-steps", gvar);
|
|
||||||
*data = g_variant_builder_end(&gvb);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return SR_ERR_NA;
|
return SR_ERR_NA;
|
||||||
|
|
|
@ -532,8 +532,6 @@ static int config_list(uint32_t key, GVariant **data,
|
||||||
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
|
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
GVariant *gvar;
|
|
||||||
GVariantBuilder gvb;
|
|
||||||
|
|
||||||
devc = (sdi) ? sdi->priv : NULL;
|
devc = (sdi) ? sdi->priv : NULL;
|
||||||
|
|
||||||
|
@ -542,11 +540,7 @@ static int config_list(uint32_t key, GVariant **data,
|
||||||
case SR_CONF_DEVICE_OPTIONS:
|
case SR_CONF_DEVICE_OPTIONS:
|
||||||
return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
|
return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
|
||||||
case SR_CONF_SAMPLERATE:
|
case SR_CONF_SAMPLERATE:
|
||||||
g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
|
*data = std_gvar_samplerates(devc->samplerates, devc->num_samplerates);
|
||||||
gvar = g_variant_new_fixed_array(G_VARIANT_TYPE("t"), devc->samplerates,
|
|
||||||
devc->num_samplerates, sizeof(uint64_t));
|
|
||||||
g_variant_builder_add(&gvb, "{sv}", "samplerates", gvar);
|
|
||||||
*data = g_variant_builder_end(&gvb);
|
|
||||||
break;
|
break;
|
||||||
case SR_CONF_TRIGGER_MATCH:
|
case SR_CONF_TRIGGER_MATCH:
|
||||||
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
|
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
|
||||||
|
|
|
@ -458,8 +458,6 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
||||||
static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
|
static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
|
||||||
const struct sr_channel_group *cg)
|
const struct sr_channel_group *cg)
|
||||||
{
|
{
|
||||||
GVariantBuilder gvb;
|
|
||||||
GVariant *gvar;
|
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
|
|
||||||
devc = (sdi) ? sdi->priv : NULL;
|
devc = (sdi) ? sdi->priv : NULL;
|
||||||
|
@ -470,12 +468,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
case SR_CONF_DEVICE_OPTIONS:
|
case SR_CONF_DEVICE_OPTIONS:
|
||||||
return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
|
return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
|
||||||
case SR_CONF_SAMPLERATE:
|
case SR_CONF_SAMPLERATE:
|
||||||
g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
|
*data = std_gvar_samplerates(samplerates, ARRAY_SIZE(samplerates));
|
||||||
gvar = g_variant_new_fixed_array(G_VARIANT_TYPE("t"),
|
|
||||||
samplerates, ARRAY_SIZE(samplerates),
|
|
||||||
sizeof(uint64_t));
|
|
||||||
g_variant_builder_add(&gvb, "{sv}", "samplerates", gvar);
|
|
||||||
*data = g_variant_builder_end(&gvb);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return SR_ERR_NA;
|
return SR_ERR_NA;
|
||||||
|
|
|
@ -559,8 +559,6 @@ static int config_commit(const struct sr_dev_inst *sdi)
|
||||||
static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
|
static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
|
||||||
const struct sr_channel_group *cg)
|
const struct sr_channel_group *cg)
|
||||||
{
|
{
|
||||||
GVariantBuilder gvb;
|
|
||||||
GVariant *gvar;
|
|
||||||
GSList *l;
|
GSList *l;
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
|
@ -598,11 +596,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
devopts_cg, ARRAY_SIZE(devopts_cg), sizeof(uint32_t));
|
devopts_cg, ARRAY_SIZE(devopts_cg), sizeof(uint32_t));
|
||||||
break;
|
break;
|
||||||
case SR_CONF_SAMPLERATE:
|
case SR_CONF_SAMPLERATE:
|
||||||
g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
|
*data = std_gvar_samplerates(samplerates, ARRAY_SIZE(samplerates));
|
||||||
gvar = g_variant_new_fixed_array(G_VARIANT_TYPE("t"),
|
|
||||||
samplerates, ARRAY_SIZE(samplerates), sizeof(uint64_t));
|
|
||||||
g_variant_builder_add(&gvb, "{sv}", "samplerates", gvar);
|
|
||||||
*data = g_variant_builder_end(&gvb);
|
|
||||||
break;
|
break;
|
||||||
case SR_CONF_TRIGGER_SOURCE:
|
case SR_CONF_TRIGGER_SOURCE:
|
||||||
*data = g_variant_new_strv(trigger_sources, ARRAY_SIZE(trigger_sources));
|
*data = g_variant_new_strv(trigger_sources, ARRAY_SIZE(trigger_sources));
|
||||||
|
|
|
@ -300,19 +300,13 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
||||||
static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
|
static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
|
||||||
const struct sr_channel_group *cg)
|
const struct sr_channel_group *cg)
|
||||||
{
|
{
|
||||||
GVariant *gvar, *grange[2];
|
GVariant *grange[2];
|
||||||
GVariantBuilder gvb;
|
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case SR_CONF_DEVICE_OPTIONS:
|
case SR_CONF_DEVICE_OPTIONS:
|
||||||
return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts);
|
return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts);
|
||||||
case SR_CONF_SAMPLERATE:
|
case SR_CONF_SAMPLERATE:
|
||||||
g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
|
*data = std_gvar_samplerates(sl2_samplerates, ARRAY_SIZE(sl2_samplerates));
|
||||||
gvar = g_variant_new_fixed_array(G_VARIANT_TYPE("t"),
|
|
||||||
sl2_samplerates, ARRAY_SIZE(sl2_samplerates),
|
|
||||||
sizeof(uint64_t));
|
|
||||||
g_variant_builder_add(&gvb, "{sv}", "samplerates", gvar);
|
|
||||||
*data = g_variant_builder_end(&gvb);
|
|
||||||
break;
|
break;
|
||||||
case SR_CONF_TRIGGER_MATCH:
|
case SR_CONF_TRIGGER_MATCH:
|
||||||
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
|
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
|
||||||
|
|
|
@ -257,19 +257,11 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
||||||
static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
|
static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
|
||||||
const struct sr_channel_group *cg)
|
const struct sr_channel_group *cg)
|
||||||
{
|
{
|
||||||
GVariant *gvar;
|
|
||||||
GVariantBuilder gvb;
|
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case SR_CONF_DEVICE_OPTIONS:
|
case SR_CONF_DEVICE_OPTIONS:
|
||||||
return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts);
|
return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts);
|
||||||
case SR_CONF_SAMPLERATE:
|
case SR_CONF_SAMPLERATE:
|
||||||
g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
|
*data = std_gvar_samplerates(samplerates, ARRAY_SIZE(samplerates));
|
||||||
gvar = g_variant_new_fixed_array(G_VARIANT_TYPE("t"),
|
|
||||||
samplerates, ARRAY_SIZE(samplerates),
|
|
||||||
sizeof(uint64_t));
|
|
||||||
g_variant_builder_add(&gvb, "{sv}", "samplerates", gvar);
|
|
||||||
*data = g_variant_builder_end(&gvb);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return SR_ERR_NA;
|
return SR_ERR_NA;
|
||||||
|
|
|
@ -406,19 +406,11 @@ static int config_set(uint32_t key, GVariant *data,
|
||||||
static int config_list(uint32_t key, GVariant **data,
|
static int config_list(uint32_t key, GVariant **data,
|
||||||
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
|
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
|
||||||
{
|
{
|
||||||
GVariantBuilder vb;
|
|
||||||
GVariant *var;
|
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case SR_CONF_DEVICE_OPTIONS:
|
case SR_CONF_DEVICE_OPTIONS:
|
||||||
return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts);
|
return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts);
|
||||||
case SR_CONF_SAMPLERATE:
|
case SR_CONF_SAMPLERATE:
|
||||||
g_variant_builder_init(&vb, G_VARIANT_TYPE("a{sv}"));
|
*data = std_gvar_samplerates(samplerates, ARRAY_SIZE(samplerates));
|
||||||
var = g_variant_new_fixed_array(G_VARIANT_TYPE("t"),
|
|
||||||
samplerates, ARRAY_SIZE(samplerates),
|
|
||||||
sizeof(uint64_t));
|
|
||||||
g_variant_builder_add(&vb, "{sv}", "samplerates", var);
|
|
||||||
*data = g_variant_builder_end(&vb);
|
|
||||||
break;
|
break;
|
||||||
case SR_CONF_TRIGGER_MATCH:
|
case SR_CONF_TRIGGER_MATCH:
|
||||||
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
|
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
|
||||||
|
|
|
@ -288,18 +288,11 @@ 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,
|
static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
|
||||||
const struct sr_channel_group *cg)
|
const struct sr_channel_group *cg)
|
||||||
{
|
{
|
||||||
GVariant *gvar;
|
|
||||||
GVariantBuilder gvb;
|
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case SR_CONF_DEVICE_OPTIONS:
|
case SR_CONF_DEVICE_OPTIONS:
|
||||||
return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts);
|
return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts);
|
||||||
case SR_CONF_SAMPLERATE:
|
case SR_CONF_SAMPLERATE:
|
||||||
g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
|
*data = std_gvar_samplerates_steps(samplerates, ARRAY_SIZE(samplerates));
|
||||||
gvar = g_variant_new_fixed_array(G_VARIANT_TYPE("t"), samplerates,
|
|
||||||
ARRAY_SIZE(samplerates), sizeof(uint64_t));
|
|
||||||
g_variant_builder_add(&gvb, "{sv}", "samplerate-steps", gvar);
|
|
||||||
*data = g_variant_builder_end(&gvb);
|
|
||||||
break;
|
break;
|
||||||
case SR_CONF_TRIGGER_TYPE:
|
case SR_CONF_TRIGGER_TYPE:
|
||||||
*data = g_variant_new_string(TRIGGER_TYPE);
|
*data = g_variant_new_string(TRIGGER_TYPE);
|
||||||
|
|
|
@ -323,8 +323,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
const struct sr_channel_group *cg)
|
const struct sr_channel_group *cg)
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
GVariant *gvar, *grange[2];
|
GVariant *grange[2];
|
||||||
GVariantBuilder gvb;
|
|
||||||
int num_ols_changrp, i;
|
int num_ols_changrp, i;
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
|
@ -332,11 +331,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
case SR_CONF_DEVICE_OPTIONS:
|
case SR_CONF_DEVICE_OPTIONS:
|
||||||
return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
|
return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
|
||||||
case SR_CONF_SAMPLERATE:
|
case SR_CONF_SAMPLERATE:
|
||||||
g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
|
*data = std_gvar_samplerates_steps(samplerates, ARRAY_SIZE(samplerates));
|
||||||
gvar = g_variant_new_fixed_array(G_VARIANT_TYPE("t"), samplerates,
|
|
||||||
ARRAY_SIZE(samplerates), sizeof(uint64_t));
|
|
||||||
g_variant_builder_add(&gvb, "{sv}", "samplerate-steps", gvar);
|
|
||||||
*data = g_variant_builder_end(&gvb);
|
|
||||||
break;
|
break;
|
||||||
case SR_CONF_TRIGGER_MATCH:
|
case SR_CONF_TRIGGER_MATCH:
|
||||||
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
|
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
|
||||||
|
|
|
@ -334,19 +334,14 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
const struct sr_channel_group *cg)
|
const struct sr_channel_group *cg)
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
GVariant *gvar, *grange[2];
|
GVariant *grange[2];
|
||||||
GVariantBuilder gvb;
|
|
||||||
int num_pols_changrp, i;
|
int num_pols_changrp, i;
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case SR_CONF_DEVICE_OPTIONS:
|
case SR_CONF_DEVICE_OPTIONS:
|
||||||
return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts);
|
return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts);
|
||||||
case SR_CONF_SAMPLERATE:
|
case SR_CONF_SAMPLERATE:
|
||||||
g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
|
*data = std_gvar_samplerates_steps(samplerates, ARRAY_SIZE(samplerates));
|
||||||
gvar = g_variant_new_fixed_array(G_VARIANT_TYPE("t"), samplerates,
|
|
||||||
ARRAY_SIZE(samplerates), sizeof(uint64_t));
|
|
||||||
g_variant_builder_add(&gvb, "{sv}", "samplerate-steps", gvar);
|
|
||||||
*data = g_variant_builder_end(&gvb);
|
|
||||||
break;
|
break;
|
||||||
case SR_CONF_TRIGGER_MATCH:
|
case SR_CONF_TRIGGER_MATCH:
|
||||||
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
|
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
|
||||||
|
|
|
@ -350,19 +350,12 @@ static int config_set(uint32_t key, GVariant *data,
|
||||||
static int config_list(uint32_t key, GVariant **data,
|
static int config_list(uint32_t key, GVariant **data,
|
||||||
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
|
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
|
||||||
{
|
{
|
||||||
GVariant *gvar;
|
|
||||||
GVariantBuilder gvb;
|
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case SR_CONF_SCAN_OPTIONS:
|
case SR_CONF_SCAN_OPTIONS:
|
||||||
case SR_CONF_DEVICE_OPTIONS:
|
case SR_CONF_DEVICE_OPTIONS:
|
||||||
return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
|
return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
|
||||||
case SR_CONF_SAMPLERATE:
|
case SR_CONF_SAMPLERATE:
|
||||||
g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
|
*data = std_gvar_samplerates(samplerates, ARRAY_SIZE(samplerates));
|
||||||
gvar = g_variant_new_fixed_array(G_VARIANT_TYPE("t"),
|
|
||||||
samplerates, ARRAY_SIZE(samplerates), sizeof(uint64_t));
|
|
||||||
g_variant_builder_add(&gvb, "{sv}", "samplerates", gvar);
|
|
||||||
*data = g_variant_builder_end(&gvb);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return SR_ERR_NA;
|
return SR_ERR_NA;
|
||||||
|
|
|
@ -511,11 +511,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
case SR_CONF_DEVICE_OPTIONS:
|
case SR_CONF_DEVICE_OPTIONS:
|
||||||
return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
|
return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
|
||||||
case SR_CONF_SAMPLERATE:
|
case SR_CONF_SAMPLERATE:
|
||||||
g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
|
*data = std_gvar_samplerates(samplerates, ARRAY_SIZE(samplerates));
|
||||||
gvar = g_variant_new_fixed_array(G_VARIANT_TYPE("t"),
|
|
||||||
samplerates, ARRAY_SIZE(samplerates), sizeof(uint64_t));
|
|
||||||
g_variant_builder_add(&gvb, "{sv}", "samplerates", gvar);
|
|
||||||
*data = g_variant_builder_end(&gvb);
|
|
||||||
break;
|
break;
|
||||||
case SR_CONF_VOLTAGE_THRESHOLD:
|
case SR_CONF_VOLTAGE_THRESHOLD:
|
||||||
g_variant_builder_init(&gvb, G_VARIANT_TYPE_ARRAY);
|
g_variant_builder_init(&gvb, G_VARIANT_TYPE_ARRAY);
|
||||||
|
|
|
@ -600,8 +600,6 @@ static int config_list(uint32_t key, GVariant **data,
|
||||||
const struct sr_channel_group *cg)
|
const struct sr_channel_group *cg)
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
GVariant *gvar;
|
|
||||||
GVariantBuilder gvb;
|
|
||||||
|
|
||||||
devc = (sdi) ? sdi->priv : NULL;
|
devc = (sdi) ? sdi->priv : NULL;
|
||||||
|
|
||||||
|
@ -620,12 +618,7 @@ static int config_list(uint32_t key, GVariant **data,
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case SR_CONF_SAMPLERATE:
|
case SR_CONF_SAMPLERATE:
|
||||||
g_variant_builder_init(&gvb, G_VARIANT_TYPE_VARDICT);
|
*data = std_gvar_samplerates(devc->model->samplerates, devc->model->num_samplerates);
|
||||||
gvar = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT64,
|
|
||||||
devc->model->samplerates, devc->model->num_samplerates,
|
|
||||||
sizeof(devc->model->samplerates[0]));
|
|
||||||
g_variant_builder_add(&gvb, "{sv}", "samplerates", gvar);
|
|
||||||
*data = g_variant_builder_end(&gvb);
|
|
||||||
break;
|
break;
|
||||||
case SR_CONF_TRIGGER_MATCH:
|
case SR_CONF_TRIGGER_MATCH:
|
||||||
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
|
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
|
||||||
|
|
|
@ -401,22 +401,15 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts);
|
return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts);
|
||||||
case SR_CONF_SAMPLERATE:
|
case SR_CONF_SAMPLERATE:
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
|
if (devc->prof->max_sampling_freq == 100)
|
||||||
if (devc->prof->max_sampling_freq == 100) {
|
*data = std_gvar_samplerates(samplerates_100, ARRAY_SIZE(samplerates_100));
|
||||||
gvar = g_variant_new_fixed_array(G_VARIANT_TYPE("t"),
|
else if (devc->prof->max_sampling_freq == 200)
|
||||||
samplerates_100, ARRAY_SIZE(samplerates_100),
|
*data = std_gvar_samplerates(samplerates_200, ARRAY_SIZE(samplerates_200));
|
||||||
sizeof(uint64_t));
|
else {
|
||||||
} else if (devc->prof->max_sampling_freq == 200) {
|
|
||||||
gvar = g_variant_new_fixed_array(G_VARIANT_TYPE("t"),
|
|
||||||
samplerates_200, ARRAY_SIZE(samplerates_200),
|
|
||||||
sizeof(uint64_t));
|
|
||||||
} else {
|
|
||||||
sr_err("Internal error: Unknown max. samplerate: %d.",
|
sr_err("Internal error: Unknown max. samplerate: %d.",
|
||||||
devc->prof->max_sampling_freq);
|
devc->prof->max_sampling_freq);
|
||||||
return SR_ERR_ARG;
|
return SR_ERR_ARG;
|
||||||
}
|
}
|
||||||
g_variant_builder_add(&gvb, "{sv}", "samplerates", gvar);
|
|
||||||
*data = g_variant_builder_end(&gvb);
|
|
||||||
break;
|
break;
|
||||||
case SR_CONF_TRIGGER_MATCH:
|
case SR_CONF_TRIGGER_MATCH:
|
||||||
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
|
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
|
||||||
|
|
|
@ -958,6 +958,8 @@ SR_PRIV int std_opts_config_list(uint32_t key, GVariant **data,
|
||||||
|
|
||||||
SR_PRIV GVariant *std_gvar_tuple_array(const uint64_t (*a)[][2], unsigned int n);
|
SR_PRIV GVariant *std_gvar_tuple_array(const uint64_t (*a)[][2], unsigned int n);
|
||||||
SR_PRIV GVariant *std_gvar_tuple_rational(const struct sr_rational *r, unsigned int n);
|
SR_PRIV GVariant *std_gvar_tuple_rational(const struct sr_rational *r, unsigned int n);
|
||||||
|
SR_PRIV GVariant *std_gvar_samplerates(const uint64_t samplerates[], unsigned int n);
|
||||||
|
SR_PRIV GVariant *std_gvar_samplerates_steps(const uint64_t samplerates[], unsigned int n);
|
||||||
|
|
||||||
|
|
||||||
/*--- resource.c ------------------------------------------------------------*/
|
/*--- resource.c ------------------------------------------------------------*/
|
||||||
|
|
23
src/std.c
23
src/std.c
|
@ -578,3 +578,26 @@ SR_PRIV GVariant *std_gvar_tuple_rational(const struct sr_rational *r, unsigned
|
||||||
|
|
||||||
return g_variant_builder_end(&gvb);
|
return g_variant_builder_end(&gvb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GVariant *samplerate_helper(const uint64_t samplerates[], unsigned int n, const char *str)
|
||||||
|
{
|
||||||
|
GVariant *gvar;
|
||||||
|
GVariantBuilder gvb;
|
||||||
|
|
||||||
|
g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
|
||||||
|
gvar = g_variant_new_fixed_array(G_VARIANT_TYPE("t"), samplerates,
|
||||||
|
n, sizeof(uint64_t));
|
||||||
|
g_variant_builder_add(&gvb, "{sv}", str, gvar);
|
||||||
|
|
||||||
|
return g_variant_builder_end(&gvb);
|
||||||
|
}
|
||||||
|
|
||||||
|
SR_PRIV GVariant *std_gvar_samplerates(const uint64_t samplerates[], unsigned int n)
|
||||||
|
{
|
||||||
|
return samplerate_helper(samplerates, n, "samplerates");
|
||||||
|
}
|
||||||
|
|
||||||
|
SR_PRIV GVariant *std_gvar_samplerates_steps(const uint64_t samplerates[], unsigned int n)
|
||||||
|
{
|
||||||
|
return samplerate_helper(samplerates, n, "samplerate-steps");
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue