* weighting. */
mode = devc->buf[2] & 0x0f;
switch (mode) {
- case 0x0:
- analog.mqflags |= SR_MQFLAG_SPL_FREQ_WEIGHT_A \
- | SR_MQFLAG_SPL_TIME_WEIGHT_F;
- break;
- case 0x1:
- analog.mqflags |= SR_MQFLAG_SPL_FREQ_WEIGHT_A \
- | SR_MQFLAG_SPL_TIME_WEIGHT_S;
- break;
- case 0x2:
- analog.mqflags |= SR_MQFLAG_SPL_FREQ_WEIGHT_C \
- | SR_MQFLAG_SPL_TIME_WEIGHT_F;
- break;
- case 0x3:
- analog.mqflags |= SR_MQFLAG_SPL_FREQ_WEIGHT_C \
- | SR_MQFLAG_SPL_TIME_WEIGHT_S;
- break;
- case 0x4:
- analog.mqflags |= SR_MQFLAG_SPL_FREQ_WEIGHT_FLAT \
- | SR_MQFLAG_SPL_TIME_WEIGHT_F;
- break;
- case 0x5:
- analog.mqflags |= SR_MQFLAG_SPL_FREQ_WEIGHT_FLAT \
- | SR_MQFLAG_SPL_TIME_WEIGHT_S;
- break;
- case 0x6:
- analog.mqflags |= SR_MQFLAG_SPL_PCT_OVER_ALARM \
- | SR_MQFLAG_SPL_FREQ_WEIGHT_A \
- | SR_MQFLAG_SPL_TIME_WEIGHT_F;
- break;
- case 0x7:
- analog.mqflags |= SR_MQFLAG_SPL_PCT_OVER_ALARM \
- | SR_MQFLAG_SPL_FREQ_WEIGHT_A \
- | SR_MQFLAG_SPL_TIME_WEIGHT_S;
- break;
- case 0x8:
- /* 10-second mean, but we don't have MQ flags to express it. */
- analog.mqflags |= SR_MQFLAG_SPL_LAT \
- | SR_MQFLAG_SPL_FREQ_WEIGHT_A \
- | SR_MQFLAG_SPL_TIME_WEIGHT_F;
- break;
- case 0x9:
- /* Mean over a time period between 11 seconds and 24 hours.
- * Which is so silly that there's no point in expressing
- * either this or the previous case. */
- analog.mqflags |= SR_MQFLAG_SPL_LAT \
- | SR_MQFLAG_SPL_FREQ_WEIGHT_A \
- | SR_MQFLAG_SPL_TIME_WEIGHT_F;
- break;
- case 0xa:
- /* 10-second mean. */
- analog.mqflags |= SR_MQFLAG_SPL_LAT \
- | SR_MQFLAG_SPL_FREQ_WEIGHT_A \
- | SR_MQFLAG_SPL_TIME_WEIGHT_S;
- break;
- case 0xb:
- /* Mean over a time period between 11 seconds and 24 hours. */
- analog.mqflags |= SR_MQFLAG_SPL_LAT \
- | SR_MQFLAG_SPL_FREQ_WEIGHT_A \
- | SR_MQFLAG_SPL_TIME_WEIGHT_S;
- break;
- case 0xc:
- /* Internal calibration on 1kHz sine at 94dB, not useful
- * to anything but the device. */
- analog.mqflags |= SR_MQFLAG_SPL_FREQ_WEIGHT_FLAT;
- break;
- case 0xd:
- /* Internal calibration on 1kHz sine at 94dB, not useful
- * to anything but the device. */
- analog.mqflags |= SR_MQFLAG_SPL_FREQ_WEIGHT_FLAT;
- break;
- default:
- sr_dbg("unknown configuration 0x%.2x", mode);
- return;
- break;
+ case 0x0:
+ analog.mqflags |= SR_MQFLAG_SPL_FREQ_WEIGHT_A \
+ | SR_MQFLAG_SPL_TIME_WEIGHT_F;
+ break;
+ case 0x1:
+ analog.mqflags |= SR_MQFLAG_SPL_FREQ_WEIGHT_A \
+ | SR_MQFLAG_SPL_TIME_WEIGHT_S;
+ break;
+ case 0x2:
+ analog.mqflags |= SR_MQFLAG_SPL_FREQ_WEIGHT_C \
+ | SR_MQFLAG_SPL_TIME_WEIGHT_F;
+ break;
+ case 0x3:
+ analog.mqflags |= SR_MQFLAG_SPL_FREQ_WEIGHT_C \
+ | SR_MQFLAG_SPL_TIME_WEIGHT_S;
+ break;
+ case 0x4:
+ analog.mqflags |= SR_MQFLAG_SPL_FREQ_WEIGHT_FLAT \
+ | SR_MQFLAG_SPL_TIME_WEIGHT_F;
+ break;
+ case 0x5:
+ analog.mqflags |= SR_MQFLAG_SPL_FREQ_WEIGHT_FLAT \
+ | SR_MQFLAG_SPL_TIME_WEIGHT_S;
+ break;
+ case 0x6:
+ analog.mqflags |= SR_MQFLAG_SPL_PCT_OVER_ALARM \
+ | SR_MQFLAG_SPL_FREQ_WEIGHT_A \
+ | SR_MQFLAG_SPL_TIME_WEIGHT_F;
+ break;
+ case 0x7:
+ analog.mqflags |= SR_MQFLAG_SPL_PCT_OVER_ALARM \
+ | SR_MQFLAG_SPL_FREQ_WEIGHT_A \
+ | SR_MQFLAG_SPL_TIME_WEIGHT_S;
+ break;
+ case 0x8:
+ /* 10-second mean, but we don't have MQ flags to express it. */
+ analog.mqflags |= SR_MQFLAG_SPL_LAT \
+ | SR_MQFLAG_SPL_FREQ_WEIGHT_A \
+ | SR_MQFLAG_SPL_TIME_WEIGHT_F;
+ break;
+ case 0x9:
+ /* Mean over a time period between 11 seconds and 24 hours.
+ * Which is so silly that there's no point in expressing
+ * either this or the previous case. */
+ analog.mqflags |= SR_MQFLAG_SPL_LAT \
+ | SR_MQFLAG_SPL_FREQ_WEIGHT_A \
+ | SR_MQFLAG_SPL_TIME_WEIGHT_F;
+ break;
+ case 0xa:
+ /* 10-second mean. */
+ analog.mqflags |= SR_MQFLAG_SPL_LAT \
+ | SR_MQFLAG_SPL_FREQ_WEIGHT_A \
+ | SR_MQFLAG_SPL_TIME_WEIGHT_S;
+ break;
+ case 0xb:
+ /* Mean over a time period between 11 seconds and 24 hours. */
+ analog.mqflags |= SR_MQFLAG_SPL_LAT \
+ | SR_MQFLAG_SPL_FREQ_WEIGHT_A \
+ | SR_MQFLAG_SPL_TIME_WEIGHT_S;
+ break;
+ case 0xc:
+ /* Internal calibration on 1kHz sine at 94dB, not useful
+ * to anything but the device. */
+ analog.mqflags |= SR_MQFLAG_SPL_FREQ_WEIGHT_FLAT;
+ break;
+ case 0xd:
+ /* Internal calibration on 1kHz sine at 94dB, not useful
+ * to anything but the device. */
+ analog.mqflags |= SR_MQFLAG_SPL_FREQ_WEIGHT_FLAT;
+ break;
+ default:
+ sr_dbg("unknown configuration 0x%.2x", mode);
+ return;
}
packet.type = SR_DF_ANALOG;
ret = SR_OK;
switch (key) {
- case SR_CONF_SAMPLERATE:
- arg = g_variant_get_uint64(data);
- for (i = 0; i < ARRAY_SIZE(samplerates); i++) {
- if (samplerates[i] == arg) {
- devc->cur_samplerate = arg;
- break;
- }
+ case SR_CONF_SAMPLERATE:
+ arg = g_variant_get_uint64(data);
+ for (i = 0; i < ARRAY_SIZE(samplerates); i++) {
+ if (samplerates[i] == arg) {
+ devc->cur_samplerate = arg;
+ break;
}
- if (i == ARRAY_SIZE(samplerates))
- ret = SR_ERR_ARG;
- break;
- case SR_CONF_LIMIT_SAMPLES:
- devc->limit_samples = g_variant_get_uint64(data);
- break;
- case SR_CONF_CAPTURE_RATIO:
- devc->capture_ratio = g_variant_get_uint64(data);
- if (devc->capture_ratio > 100) {
- devc->capture_ratio = 0;
- ret = SR_ERR;
- } else
- ret = SR_OK;
- break;
- default:
- ret = SR_ERR_NA;
+ }
+ if (i == ARRAY_SIZE(samplerates))
+ ret = SR_ERR_ARG;
+ break;
+ case SR_CONF_LIMIT_SAMPLES:
+ devc->limit_samples = g_variant_get_uint64(data);
+ break;
+ case SR_CONF_CAPTURE_RATIO:
+ devc->capture_ratio = g_variant_get_uint64(data);
+ if (devc->capture_ratio > 100) {
+ devc->capture_ratio = 0;
+ ret = SR_ERR;
+ } else
+ ret = SR_OK;
+ break;
+ default:
+ ret = SR_ERR_NA;
}
return ret;
case SR_MQ_CURRENT:
if (devc->scale1000 == -1) /* mA */
switch (range) {
- case 0: case 1: /* 100, 300 µA */
+ case 0:
+ case 1: /* 100, 300 µA */
devc->scale *= pow(10.0, -6);
break;
- case 2: case 3: /* 1, 3 mA */
+ case 2:
+ case 3: /* 1, 3 mA */
devc->scale *= pow(10.0, -5);
break;
- case 4: case 5: /* 10, 30 mA */
+ case 4:
+ case 5: /* 10, 30 mA */
devc->scale *= pow(10.0, -4);
break;
- case 6: case 7: /* 100, 300 mA */
+ case 6:
+ case 7: /* 100, 300 mA */
devc->scale *= pow(10.0, -3);
break;
}
else /* A */
switch (range) {
- case 0: case 1: /* 1, 3 A */
+ case 0:
+ case 1: /* 1, 3 A */
devc->scale *= pow(10.0, -5);
break;
case 2: /* 10 A */