hantek-4032l: Reduce indentation level a bit.
This commit is contained in:
parent
b8a954c586
commit
61803a29aa
|
@ -340,16 +340,16 @@ static int config_get(uint32_t key, GVariant **data,
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case SR_CONF_VOLTAGE_THRESHOLD:
|
case SR_CONF_VOLTAGE_THRESHOLD:
|
||||||
if (cg) {
|
if (!cg)
|
||||||
if (!strcmp(cg->name, "A"))
|
return SR_ERR_CHANNEL_GROUP;
|
||||||
*data = std_gvar_tuple_double(
|
if (!strcmp(cg->name, "A"))
|
||||||
devc->cur_threshold[0], devc->cur_threshold[0]);
|
*data = std_gvar_tuple_double(
|
||||||
else if (!strcmp(cg->name, "B"))
|
devc->cur_threshold[0], devc->cur_threshold[0]);
|
||||||
*data = std_gvar_tuple_double(
|
else if (!strcmp(cg->name, "B"))
|
||||||
devc->cur_threshold[1], devc->cur_threshold[1]);
|
*data = std_gvar_tuple_double(
|
||||||
else
|
devc->cur_threshold[1], devc->cur_threshold[1]);
|
||||||
return SR_ERR_CHANNEL_GROUP;
|
else
|
||||||
}
|
return SR_ERR_CHANNEL_GROUP;
|
||||||
break;
|
break;
|
||||||
case SR_CONF_SAMPLERATE:
|
case SR_CONF_SAMPLERATE:
|
||||||
*data = g_variant_new_uint64(samplerates_hw[devc->sample_rate]);
|
*data = g_variant_new_uint64(samplerates_hw[devc->sample_rate]);
|
||||||
|
@ -390,60 +390,56 @@ static int config_get(uint32_t key, GVariant **data,
|
||||||
static int config_set(uint32_t key, GVariant *data,
|
static int config_set(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)
|
||||||
{
|
{
|
||||||
|
int idx;
|
||||||
struct dev_context *devc = sdi->priv;
|
struct dev_context *devc = sdi->priv;
|
||||||
struct h4032l_cmd_pkt *cmd_pkt = &devc->cmd_pkt;
|
struct h4032l_cmd_pkt *cmd_pkt = &devc->cmd_pkt;
|
||||||
int idx;
|
uint64_t sample_rate, capture_ratio, number_samples;
|
||||||
|
double low, high, threshold;
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case SR_CONF_SAMPLERATE: {
|
case SR_CONF_SAMPLERATE:
|
||||||
uint64_t sample_rate = g_variant_get_uint64(data);
|
idx = 0;
|
||||||
uint8_t i = 0;
|
sample_rate = g_variant_get_uint64(data);
|
||||||
while (i < ARRAY_SIZE(samplerates_hw) && samplerates_hw[i] != sample_rate)
|
while (idx < ARRAY_SIZE(samplerates_hw) && samplerates_hw[idx] != sample_rate)
|
||||||
i++;
|
idx++;
|
||||||
|
if (idx == ARRAY_SIZE(samplerates_hw) || sample_rate == 0) {
|
||||||
if (i == ARRAY_SIZE(samplerates_hw) || sample_rate == 0) {
|
sr_err("Invalid sample rate.");
|
||||||
sr_err("Invalid sample rate.");
|
return SR_ERR_SAMPLERATE;
|
||||||
return SR_ERR_SAMPLERATE;
|
|
||||||
}
|
|
||||||
devc->sample_rate = i;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case SR_CONF_CAPTURE_RATIO: {
|
devc->sample_rate = idx;
|
||||||
uint64_t capture_ratio = g_variant_get_uint64(data);
|
break;
|
||||||
if (capture_ratio > 99) {
|
case SR_CONF_CAPTURE_RATIO:
|
||||||
sr_err("Invalid capture ratio.");
|
capture_ratio = g_variant_get_uint64(data);
|
||||||
return SR_ERR;
|
if (capture_ratio > 99) {
|
||||||
}
|
sr_err("Invalid capture ratio.");
|
||||||
devc->capture_ratio = capture_ratio;
|
return SR_ERR;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case SR_CONF_LIMIT_SAMPLES: {
|
devc->capture_ratio = capture_ratio;
|
||||||
uint64_t number_samples = g_variant_get_uint64(data);
|
break;
|
||||||
number_samples += 511;
|
case SR_CONF_LIMIT_SAMPLES:
|
||||||
number_samples &= 0xfffffe00;
|
number_samples = g_variant_get_uint64(data);
|
||||||
if (number_samples < H4043L_NUM_SAMPLES_MIN ||
|
number_samples += 511;
|
||||||
number_samples > H4032L_NUM_SAMPLES_MAX) {
|
number_samples &= 0xfffffe00;
|
||||||
sr_err("Invalid sample range 2k...64M: %"
|
if (number_samples < H4043L_NUM_SAMPLES_MIN ||
|
||||||
PRIu64 ".", number_samples);
|
number_samples > H4032L_NUM_SAMPLES_MAX) {
|
||||||
return SR_ERR;
|
sr_err("Invalid sample range 2k...64M: %"
|
||||||
}
|
PRIu64 ".", number_samples);
|
||||||
cmd_pkt->sample_size = number_samples;
|
return SR_ERR;
|
||||||
break;
|
|
||||||
}
|
|
||||||
case SR_CONF_VOLTAGE_THRESHOLD: {
|
|
||||||
double low, high;
|
|
||||||
g_variant_get(data, "(dd)", &low, &high);
|
|
||||||
double threshold = (low + high) / 2.0;
|
|
||||||
if (cg) {
|
|
||||||
if (!strcmp(cg->name, "A"))
|
|
||||||
devc->cur_threshold[0] = threshold;
|
|
||||||
else if (!strcmp(cg->name, "B"))
|
|
||||||
devc->cur_threshold[1] = threshold;
|
|
||||||
else
|
|
||||||
return SR_ERR_CHANNEL_GROUP;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
cmd_pkt->sample_size = number_samples;
|
||||||
|
break;
|
||||||
|
case SR_CONF_VOLTAGE_THRESHOLD:
|
||||||
|
if (!cg)
|
||||||
|
return SR_ERR_CHANNEL_GROUP;
|
||||||
|
g_variant_get(data, "(dd)", &low, &high);
|
||||||
|
threshold = (low + high) / 2.0;
|
||||||
|
if (!strcmp(cg->name, "A"))
|
||||||
|
devc->cur_threshold[0] = threshold;
|
||||||
|
else if (!strcmp(cg->name, "B"))
|
||||||
|
devc->cur_threshold[1] = threshold;
|
||||||
|
else
|
||||||
|
return SR_ERR_CHANNEL_GROUP;
|
||||||
|
break;
|
||||||
case SR_CONF_EXTERNAL_CLOCK:
|
case SR_CONF_EXTERNAL_CLOCK:
|
||||||
devc->external_clock = g_variant_get_boolean(data);
|
devc->external_clock = g_variant_get_boolean(data);
|
||||||
break;
|
break;
|
||||||
|
@ -467,7 +463,6 @@ 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)
|
||||||
{
|
{
|
||||||
|
|
||||||
struct dev_context *devc = (sdi) ? sdi->priv : NULL;
|
struct dev_context *devc = (sdi) ? sdi->priv : NULL;
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
|
|
Loading…
Reference in New Issue