hantek-4032l: Reduce indentation level a bit.
This commit is contained in:
parent
b8a954c586
commit
61803a29aa
|
@ -340,7 +340,8 @@ 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)
|
||||||
|
return SR_ERR_CHANNEL_GROUP;
|
||||||
if (!strcmp(cg->name, "A"))
|
if (!strcmp(cg->name, "A"))
|
||||||
*data = std_gvar_tuple_double(
|
*data = std_gvar_tuple_double(
|
||||||
devc->cur_threshold[0], devc->cur_threshold[0]);
|
devc->cur_threshold[0], devc->cur_threshold[0]);
|
||||||
|
@ -349,7 +350,6 @@ static int config_get(uint32_t key, GVariant **data,
|
||||||
devc->cur_threshold[1], devc->cur_threshold[1]);
|
devc->cur_threshold[1], devc->cur_threshold[1]);
|
||||||
else
|
else
|
||||||
return SR_ERR_CHANNEL_GROUP;
|
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,35 +390,34 @@ 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;
|
devc->sample_rate = idx;
|
||||||
break;
|
break;
|
||||||
}
|
case SR_CONF_CAPTURE_RATIO:
|
||||||
case SR_CONF_CAPTURE_RATIO: {
|
capture_ratio = g_variant_get_uint64(data);
|
||||||
uint64_t capture_ratio = g_variant_get_uint64(data);
|
|
||||||
if (capture_ratio > 99) {
|
if (capture_ratio > 99) {
|
||||||
sr_err("Invalid capture ratio.");
|
sr_err("Invalid capture ratio.");
|
||||||
return SR_ERR;
|
return SR_ERR;
|
||||||
}
|
}
|
||||||
devc->capture_ratio = capture_ratio;
|
devc->capture_ratio = capture_ratio;
|
||||||
break;
|
break;
|
||||||
}
|
case SR_CONF_LIMIT_SAMPLES:
|
||||||
case SR_CONF_LIMIT_SAMPLES: {
|
number_samples = g_variant_get_uint64(data);
|
||||||
uint64_t number_samples = g_variant_get_uint64(data);
|
|
||||||
number_samples += 511;
|
number_samples += 511;
|
||||||
number_samples &= 0xfffffe00;
|
number_samples &= 0xfffffe00;
|
||||||
if (number_samples < H4043L_NUM_SAMPLES_MIN ||
|
if (number_samples < H4043L_NUM_SAMPLES_MIN ||
|
||||||
|
@ -429,21 +428,18 @@ static int config_set(uint32_t key, GVariant *data,
|
||||||
}
|
}
|
||||||
cmd_pkt->sample_size = number_samples;
|
cmd_pkt->sample_size = number_samples;
|
||||||
break;
|
break;
|
||||||
}
|
case SR_CONF_VOLTAGE_THRESHOLD:
|
||||||
case SR_CONF_VOLTAGE_THRESHOLD: {
|
if (!cg)
|
||||||
double low, high;
|
return SR_ERR_CHANNEL_GROUP;
|
||||||
g_variant_get(data, "(dd)", &low, &high);
|
g_variant_get(data, "(dd)", &low, &high);
|
||||||
double threshold = (low + high) / 2.0;
|
threshold = (low + high) / 2.0;
|
||||||
if (cg) {
|
|
||||||
if (!strcmp(cg->name, "A"))
|
if (!strcmp(cg->name, "A"))
|
||||||
devc->cur_threshold[0] = threshold;
|
devc->cur_threshold[0] = threshold;
|
||||||
else if (!strcmp(cg->name, "B"))
|
else if (!strcmp(cg->name, "B"))
|
||||||
devc->cur_threshold[1] = threshold;
|
devc->cur_threshold[1] = threshold;
|
||||||
else
|
else
|
||||||
return SR_ERR_CHANNEL_GROUP;
|
return SR_ERR_CHANNEL_GROUP;
|
||||||
}
|
|
||||||
break;
|
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