+ ret = SR_OK;
+ devc = sdi->priv;
+ switch (id) {
+ case SR_CONF_LIMIT_FRAMES:
+ devc->limit_frames = g_variant_get_uint64(data);
+ break;
+ case SR_CONF_TRIGGER_SLOPE:
+ tmp_u64 = g_variant_get_uint64(data);
+ if (tmp_u64 != SLOPE_NEGATIVE && tmp_u64 != SLOPE_POSITIVE)
+ ret = SR_ERR_ARG;
+ devc->triggerslope = tmp_u64;
+ break;
+ case SR_CONF_HORIZ_TRIGGERPOS:
+ tmp_double = g_variant_get_double(data);
+ if (tmp_double < 0.0 || tmp_double > 1.0) {
+ sr_err("Trigger position should be between 0.0 and 1.0.");
+ ret = SR_ERR_ARG;
+ } else
+ devc->triggerposition = tmp_double;
+ break;
+ case SR_CONF_BUFFERSIZE:
+ tmp_u64 = g_variant_get_uint64(data);
+ for (i = 0; i < 2; i++) {
+ if (devc->profile->buffersizes[i] == tmp_u64) {
+ devc->framesize = tmp_u64;
+ break;
+ }
+ }
+ if (i == 2)
+ ret = SR_ERR_ARG;
+ break;
+ case SR_CONF_TIMEBASE:
+ g_variant_get(data, "(tt)", &p, &q);
+ tmp_int = -1;
+ for (i = 0; i < ARRAY_SIZE(timebases); i++) {
+ if (timebases[i][0] == p && timebases[i][1] == q) {
+ tmp_int = i;
+ break;
+ }
+ }
+ if (tmp_int >= 0)
+ devc->timebase = tmp_int;
+ else
+ ret = SR_ERR_ARG;
+ break;
+ case SR_CONF_TRIGGER_SOURCE:
+ tmp_str = g_variant_get_string(data, NULL);
+ for (i = 0; trigger_sources[i]; i++) {
+ if (!strcmp(tmp_str, trigger_sources[i])) {
+ devc->triggersource = g_strdup(tmp_str);
+ break;
+ }
+ }
+ if (trigger_sources[i] == 0)
+ ret = SR_ERR_ARG;
+ break;
+ case SR_CONF_FILTER:
+ tmp_str = g_variant_get_string(data, NULL);
+ devc->filter_ch1 = devc->filter_ch2 = devc->filter_trigger = 0;
+ targets = g_strsplit(tmp_str, ",", 0);
+ for (i = 0; targets[i]; i++) {
+ if (targets[i] == '\0')
+ /* Empty filter string can be used to clear them all. */
+ ;
+ else if (!strcmp(targets[i], "CH1"))
+ devc->filter_ch1 = TRUE;
+ else if (!strcmp(targets[i], "CH2"))
+ devc->filter_ch2 = TRUE;
+ else if (!strcmp(targets[i], "TRIGGER"))
+ devc->filter_trigger = TRUE;
+ else {
+ sr_err("Invalid filter target %s.", targets[i]);
+ ret = SR_ERR_ARG;
+ }
+ }
+ g_strfreev(targets);
+ break;
+ case SR_CONF_VDIV:
+ /* TODO: Not supporting vdiv per channel yet. */
+ g_variant_get(data, "(tt)", &p, &q);
+ tmp_int = -1;
+ for (i = 0; i < ARRAY_SIZE(vdivs); i++) {
+ if (vdivs[i][0] == p && vdivs[i][1] == q) {
+ tmp_int = i;
+ break;
+ }
+ }
+ if (tmp_int >= 0) {
+ devc->voltage_ch1 = tmp_int;
+ devc->voltage_ch2 = tmp_int;
+ } else
+ ret = SR_ERR_ARG;
+ break;
+ case SR_CONF_COUPLING:
+ tmp_str = g_variant_get_string(data, NULL);
+ /* TODO: Not supporting coupling per channel yet. */
+ for (i = 0; coupling[i]; i++) {
+ if (!strcmp(tmp_str, coupling[i])) {
+ devc->coupling_ch1 = i;
+ devc->coupling_ch2 = i;
+ break;
+ }
+ }
+ if (coupling[i] == 0)
+ ret = SR_ERR_ARG;
+ break;
+ default:
+ ret = SR_ERR_NA;
+ break;
+ }