+ 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 != 0 && tmp_u64 != 1)
+ return SR_ERR;
+ g_free(devc->trigger_slope);
+ devc->trigger_slope = g_strdup(tmp_u64 ? "POS" : "NEG");
+ ret = set_cfg(sdi, ":TRIG:EDGE:SLOP %s", devc->trigger_slope);
+ break;
+ case SR_CONF_HORIZ_TRIGGERPOS:
+ t_dbl = g_variant_get_double(data);
+ if (t_dbl < 0.0 || t_dbl > 1.0)
+ return SR_ERR;
+ devc->horiz_triggerpos = t_dbl;
+ /* We have the trigger offset as a percentage of the frame, but
+ * need to express this in seconds. */
+ t_dbl = -(devc->horiz_triggerpos - 0.5) * devc->timebase * NUM_TIMEBASE;
+ ret = set_cfg(sdi, ":TIM:OFFS %.6f", t_dbl);
+ break;
+ case SR_CONF_TIMEBASE:
+ g_variant_get(data, "(tt)", &p, &q);
+ for (i = 0; i < ARRAY_SIZE(timebases); i++) {
+ if (timebases[i][0] == p && timebases[i][1] == q) {
+ devc->timebase = (float)p / q;
+ ret = set_cfg(sdi, ":TIM:SCAL %.9f", devc->timebase);
+ break;
+ }
+ }
+ if (i == ARRAY_SIZE(timebases))
+ ret = SR_ERR_ARG;
+ break;
+ case SR_CONF_TRIGGER_SOURCE:
+ tmp_str = g_variant_get_string(data, NULL);
+ for (i = 0; i < ARRAY_SIZE(trigger_sources); i++) {
+ if (!strcmp(trigger_sources[i], tmp_str)) {
+ g_free(devc->trigger_source);
+ devc->trigger_source = g_strdup(trigger_sources[i]);
+ if (!strcmp(devc->trigger_source, "AC Line"))
+ tmp_str = "ACL";
+ else if (!strcmp(devc->trigger_source, "CH1"))
+ tmp_str = "CHAN1";
+ else if (!strcmp(devc->trigger_source, "CH2"))
+ tmp_str = "CHAN2";
+ else
+ tmp_str = (char *)devc->trigger_source;
+ ret = set_cfg(sdi, ":TRIG:EDGE:SOUR %s", tmp_str);
+ break;
+ }
+ }
+ if (i == ARRAY_SIZE(trigger_sources))
+ ret = SR_ERR_ARG;
+ break;
+ case SR_CONF_VDIV:
+ g_variant_get(data, "(tt)", &p, &q);
+ for (i = 0; i < ARRAY_SIZE(vdivs); i++) {
+ if (vdivs[i][0] != p || vdivs[i][1] != q)
+ continue;
+ devc->vdiv[0] = devc->vdiv[1] = (float)p / q;
+ set_cfg(sdi, ":CHAN1:SCAL %.3f", devc->vdiv[0]);
+ ret = set_cfg(sdi, ":CHAN2:SCAL %.3f", devc->vdiv[1]);
+ break;
+ }
+ if (i == ARRAY_SIZE(vdivs))
+ ret = SR_ERR_ARG;
+ break;
+ case SR_CONF_COUPLING:
+ /* TODO: Not supporting coupling per channel yet. */
+ tmp_str = g_variant_get_string(data, NULL);
+ for (i = 0; i < ARRAY_SIZE(coupling); i++) {
+ if (!strcmp(tmp_str, coupling[i])) {
+ g_free(devc->coupling[0]);
+ g_free(devc->coupling[1]);
+ devc->coupling[0] = g_strdup(coupling[i]);
+ devc->coupling[1] = g_strdup(coupling[i]);
+ set_cfg(sdi, ":CHAN1:COUP %s", devc->coupling[0]);
+ ret = set_cfg(sdi, ":CHAN2:COUP %s", devc->coupling[1]);
+ break;
+ }
+ }
+ if (i == ARRAY_SIZE(coupling))
+ ret = SR_ERR_ARG;
+ break;