return SR_OK;
}
-gboolean config_key_has_cap(struct sr_dev_driver *driver,
- const struct sr_dev_inst *sdi, struct sr_channel_group *cg,
- uint32_t key, uint32_t capability)
-{
- GVariant *gvar_opts;
- const uint32_t *opts;
- gsize num_opts, i;
- gboolean result;
-
- if (sr_config_list(driver, sdi, cg, SR_CONF_DEVICE_OPTIONS,
- &gvar_opts) != SR_OK)
- return FALSE;
-
- opts = g_variant_get_fixed_array(gvar_opts, &num_opts, sizeof(uint32_t));
- result = FALSE;
- for (i = 0; i < num_opts; i++) {
- if ((opts[i] & SR_CONF_MASK) == key) {
- if ((opts[i] & capability) == capability)
- result = TRUE;
- else
- result = FALSE;
- break;
- }
- }
- g_variant_unref(gvar_opts);
-
- return result;
-}
-
int maybe_config_get(struct sr_dev_driver *driver,
const struct sr_dev_inst *sdi, struct sr_channel_group *cg,
uint32_t key, GVariant **gvar)
{
- if (config_key_has_cap(driver, sdi, cg, key, SR_CONF_GET))
+ if (sr_dev_config_capabilities(sdi, cg, key) & SR_CONF_GET)
return sr_config_get(driver, sdi, cg, key, gvar);
return SR_ERR_NA;
const struct sr_dev_inst *sdi, struct sr_channel_group *cg,
uint32_t key, GVariant *gvar)
{
- if (config_key_has_cap(driver, sdi, cg, key, SR_CONF_SET))
+ (void)driver;
+
+ if (sr_dev_config_capabilities(sdi, cg, key) & SR_CONF_SET)
return sr_config_set(sdi, cg, key, gvar);
return SR_ERR_NA;
const struct sr_dev_inst *sdi, struct sr_channel_group *cg,
uint32_t key, GVariant **gvar)
{
- if (config_key_has_cap(driver, sdi, cg, key, SR_CONF_LIST))
+ if (sr_dev_config_capabilities(sdi, cg, key) & SR_CONF_LIST)
return sr_config_list(driver, sdi, cg, key, gvar);
return SR_ERR_NA;
return SR_ERR;
}
- if (config_key_has_cap(driver, sdi, NULL, SR_CONF_LIMIT_MSEC, SR_CONF_SET)) {
+ if (sr_dev_config_capabilities(sdi, NULL, SR_CONF_LIMIT_MSEC)
+ & SR_CONF_SET) {
gvar = g_variant_new_uint64(time_msec);
if (sr_config_set(sdi, NULL, SR_CONF_LIMIT_MSEC, gvar) != SR_OK) {
g_critical("Failed to configure time limit.");
return SR_ERR;
}
- } else if (config_key_has_cap(driver, sdi, NULL, SR_CONF_SAMPLERATE,
- SR_CONF_GET | SR_CONF_SET)) {
+ } else if (sr_dev_config_capabilities(sdi, NULL, SR_CONF_SAMPLERATE)
+ & (SR_CONF_GET | SR_CONF_SET)) {
/* Convert to samples based on the samplerate. */
sr_config_get(driver, sdi, NULL, SR_CONF_SAMPLERATE, &gvar);
samplerate = g_variant_get_uint64(gvar);
struct sr_trigger *trigger;
struct sr_dev_inst *sdi;
uint64_t min_samples, max_samples;
- gsize n_elements, i;
- const uint32_t *dev_opts;
+ GArray *dev_opts;
+ guint i;
int is_demo_dev;
struct sr_dev_driver *driver;
const struct sr_transform *t;
driver = sr_dev_inst_driver_get(sdi);
- if (sr_config_list(driver, sdi, NULL, SR_CONF_DEVICE_OPTIONS, &gvar) != SR_OK) {
+ if (!(dev_opts = sr_dev_options(driver, sdi, NULL))) {
g_critical("Failed to query list device options.");
return;
}
- dev_opts = g_variant_get_fixed_array(gvar, &n_elements, sizeof(uint32_t));
-
is_demo_dev = 0;
- for (i = 0; i < n_elements; i++) {
- if (dev_opts[i] == SR_CONF_DEMO_DEV)
+ for (i = 0; i < dev_opts->len; i++) {
+ if (g_array_index(dev_opts, uint32_t, i) == SR_CONF_DEMO_DEV)
is_demo_dev = 1;
}
- g_variant_unref(gvar);
+ g_array_free(dev_opts, TRUE);
if (!is_demo_dev)
real_devices = g_slist_append(real_devices, sdi);
void show_drv_detail(struct sr_dev_driver *driver)
{
const struct sr_key_info *srci;
- GVariant *gvar_opts;
- const uint32_t *opts;
- gsize num_elements, i;
-
- if (sr_config_list(driver, NULL, NULL, SR_CONF_DEVICE_OPTIONS,
- &gvar_opts) == SR_OK) {
- opts = g_variant_get_fixed_array(gvar_opts, &num_elements,
- sizeof(uint32_t));
- if (num_elements) {
+ GArray *opts;
+ guint i;
+
+ if ((opts = sr_dev_options(driver, NULL, NULL))) {
+ if (opts->len > 0) {
printf("Driver functions:\n");
- for (i = 0; i < num_elements; i++) {
- if (!(srci = sr_key_info_get(SR_KEY_CONFIG, opts[i] & SR_CONF_MASK)))
+ for (i = 0; i < opts->len; i++) {
+ if (!(srci = sr_key_info_get(SR_KEY_CONFIG,
+ g_array_index(opts, uint32_t, i))))
continue;
printf(" %s\n", srci->name);
}
}
- g_variant_unref(gvar_opts);
+ g_array_free(opts, TRUE);
}
- if (sr_config_list(driver, NULL, NULL, SR_CONF_SCAN_OPTIONS,
- &gvar_opts) == SR_OK) {
- opts = g_variant_get_fixed_array(gvar_opts, &num_elements,
- sizeof(uint32_t));
- if (num_elements) {
+ if ((opts = sr_driver_scan_options(driver))) {
+ if (opts->len > 0) {
printf("Scan options:\n");
- for (i = 0; i < num_elements; i++) {
- if (!(srci = sr_key_info_get(SR_KEY_CONFIG, opts[i] & SR_CONF_MASK)))
+ for (i = 0; i < opts->len; i++) {
+ if (!(srci = sr_key_info_get(SR_KEY_CONFIG,
+ g_array_index(opts, uint32_t, i))))
continue;
printf(" %s\n", srci->id);
}
}
- g_variant_unref(gvar_opts);
+ g_array_free(opts, TRUE);
}
}
struct sr_channel *ch;
struct sr_channel_group *channel_group, *cg;
GSList *devices, *cgl, *chl, *channel_groups;
- GVariant *gvar_opts, *gvar_dict, *gvar_list, *gvar;
- gsize num_opts, num_elements;
+ GVariant *gvar_dict, *gvar_list, *gvar;
+ gsize num_elements;
double dlow, dhigh, dcur_low, dcur_high;
const uint64_t *uint64, p, q, low, high;
uint64_t tmp_uint64, mask, cur_low, cur_high, cur_p, cur_q;
- const uint32_t *opts;
+ GArray *opts;
const int32_t *int32;
uint32_t key, o, cur_mq, mq;
uint64_t cur_mqflags, mqflags;
select_channels(sdi);
channel_group = select_channel_group(sdi);
- if (sr_config_list(driver, sdi, channel_group, SR_CONF_DEVICE_OPTIONS,
- &gvar_opts) != SR_OK)
+ if (!(opts = sr_dev_options(driver, sdi, channel_group)))
/* Driver supports no device instance options. */
return;
printf(" on channel group %s", channel_group->name);
}
printf(":\n");
- opts = g_variant_get_fixed_array(gvar_opts, &num_opts, sizeof(uint32_t));
- for (o = 0; o < num_opts; o++) {
- key = opts[o] & SR_CONF_MASK;
+ for (o = 0; o < opts->len; o++) {
+ key = g_array_index(opts, uint32_t, o);
if (!(srci = sr_key_info_get(SR_KEY_CONFIG, key)))
continue;
g_variant_unref(gvar_list);
} else if (key == SR_CONF_LIMIT_SAMPLES
- && config_key_has_cap(driver, sdi, NULL, key, SR_CONF_LIST)) {
+ && (sr_dev_config_capabilities(sdi, NULL, key)
+ & SR_CONF_LIST)) {
/*
* If implemented in config_list(), this denotes the
* maximum number of samples a device can send. This
printf(" %s\n", srci->id);
}
}
- g_variant_unref(gvar_opts);
+ g_array_free(opts, TRUE);
sr_dev_close(sdi);