topology: use snd_config_get_bool() instead own implementation

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Jaroslav Kysela 2019-12-14 13:50:04 +01:00
parent f373bf1f6e
commit 5925a6d870
4 changed files with 34 additions and 28 deletions

View file

@ -657,13 +657,10 @@ int tplg_parse_control_mixer(snd_tplg_t *tplg,
} }
if (strcmp(id, "invert") == 0) { if (strcmp(id, "invert") == 0) {
if (snd_config_get_string(n, &val) < 0) ival = snd_config_get_bool(n);
if (ival < 0)
return -EINVAL; return -EINVAL;
mc->invert = ival;
if (strcmp(val, "true") == 0)
mc->invert = 1;
else if (strcmp(val, "false") == 0)
mc->invert = 0;
tplg_dbg("\t%s: %d\n", id, mc->invert); tplg_dbg("\t%s: %d\n", id, mc->invert);
continue; continue;

View file

@ -479,8 +479,7 @@ int tplg_parse_dapm_widget(snd_tplg_t *tplg,
snd_config_iterator_t i, next; snd_config_iterator_t i, next;
snd_config_t *n; snd_config_t *n;
const char *id, *val = NULL; const char *id, *val = NULL;
int widget_type, err; int widget_type, err, ival;
int ival;
elem = tplg_elem_new_common(tplg, cfg, NULL, SND_TPLG_TYPE_DAPM_WIDGET); elem = tplg_elem_new_common(tplg, cfg, NULL, SND_TPLG_TYPE_DAPM_WIDGET);
if (!elem) if (!elem)
@ -531,11 +530,11 @@ int tplg_parse_dapm_widget(snd_tplg_t *tplg,
} }
if (strcmp(id, "no_pm") == 0) { if (strcmp(id, "no_pm") == 0) {
if (snd_config_get_string(n, &val) < 0) ival = snd_config_get_bool(n);
if (ival < 0)
return -EINVAL; return -EINVAL;
if (strcmp(val, "true") == 0) widget->reg = ival ? -1 : 0;
widget->reg = -1;
tplg_dbg("\t%s: %s\n", id, val); tplg_dbg("\t%s: %s\n", id, val);
continue; continue;

View file

@ -557,6 +557,7 @@ static int parse_tuple_set(snd_config_t *cfg,
unsigned int type, num_tuples = 0; unsigned int type, num_tuples = 0;
struct tplg_tuple *tuple; struct tplg_tuple *tuple;
unsigned long int tuple_val; unsigned long int tuple_val;
int ival;
snd_config_get_id(cfg, &id); snd_config_get_id(cfg, &id);
@ -607,25 +608,33 @@ static int parse_tuple_set(snd_config_t *cfg,
switch (type) { switch (type) {
case SND_SOC_TPLG_TUPLE_TYPE_UUID: case SND_SOC_TPLG_TUPLE_TYPE_UUID:
if (snd_config_get_string(n, &value) < 0)
continue;
if (get_uuid(value, tuple->uuid) < 0) if (get_uuid(value, tuple->uuid) < 0)
goto err; goto err;
break; break;
case SND_SOC_TPLG_TUPLE_TYPE_STRING: case SND_SOC_TPLG_TUPLE_TYPE_STRING:
if (snd_config_get_string(n, &value) < 0)
continue;
snd_strlcpy(tuple->string, value, snd_strlcpy(tuple->string, value,
SNDRV_CTL_ELEM_ID_NAME_MAXLEN); SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
tplg_dbg("\t\t%s = %s\n", tuple->token, tuple->string); tplg_dbg("\t\t%s = %s\n", tuple->token, tuple->string);
break; break;
case SND_SOC_TPLG_TUPLE_TYPE_BOOL: case SND_SOC_TPLG_TUPLE_TYPE_BOOL:
if (strcmp(value, "true") == 0) ival = snd_config_get_bool(n);
tuple->value = 1; if (ival < 0)
continue;
tuple->value = ival;
tplg_dbg("\t\t%s = %d\n", tuple->token, tuple->value); tplg_dbg("\t\t%s = %d\n", tuple->token, tuple->value);
break; break;
case SND_SOC_TPLG_TUPLE_TYPE_BYTE: case SND_SOC_TPLG_TUPLE_TYPE_BYTE:
case SND_SOC_TPLG_TUPLE_TYPE_SHORT: case SND_SOC_TPLG_TUPLE_TYPE_SHORT:
case SND_SOC_TPLG_TUPLE_TYPE_WORD: case SND_SOC_TPLG_TUPLE_TYPE_WORD:
if (snd_config_get_string(n, &value) < 0)
continue;
errno = 0; errno = 0;
/* no support for negative value */ /* no support for negative value */
tuple_val = strtoul(value, NULL, 0); tuple_val = strtoul(value, NULL, 0);
@ -1012,7 +1021,7 @@ int tplg_parse_data(snd_tplg_t *tplg, snd_config_t *cfg,
{ {
snd_config_iterator_t i, next; snd_config_iterator_t i, next;
snd_config_t *n; snd_config_t *n;
const char *id, *val = NULL; const char *id;
int err = 0, ival; int err = 0, ival;
struct tplg_elem *elem; struct tplg_elem *elem;

View file

@ -669,8 +669,8 @@ int tplg_parse_pcm(snd_tplg_t *tplg, snd_config_t *cfg,
struct tplg_elem *elem; struct tplg_elem *elem;
snd_config_iterator_t i, next; snd_config_iterator_t i, next;
snd_config_t *n; snd_config_t *n;
const char *id, *val = NULL; const char *id;
int err; int err, ival;
elem = tplg_elem_new_common(tplg, cfg, NULL, SND_TPLG_TYPE_PCM); elem = tplg_elem_new_common(tplg, cfg, NULL, SND_TPLG_TYPE_PCM);
if (!elem) if (!elem)
@ -709,11 +709,11 @@ int tplg_parse_pcm(snd_tplg_t *tplg, snd_config_t *cfg,
} }
if (strcmp(id, "compress") == 0) { if (strcmp(id, "compress") == 0) {
if (snd_config_get_string(n, &val) < 0) ival = snd_config_get_bool(n);
if (ival < 0)
return -EINVAL; return -EINVAL;
if (strcmp(val, "true") == 0) pcm->compress = ival;
pcm->compress = 1;
tplg_dbg("\t%s: %s\n", id, val); tplg_dbg("\t%s: %s\n", id, val);
continue; continue;
@ -1107,7 +1107,7 @@ int tplg_parse_hw_config(snd_tplg_t *tplg, snd_config_t *cfg,
snd_config_iterator_t i, next; snd_config_iterator_t i, next;
snd_config_t *n; snd_config_t *n;
const char *id, *val = NULL; const char *id, *val = NULL;
int ret; int ret, ival;
elem = tplg_elem_new_common(tplg, cfg, NULL, SND_TPLG_TYPE_HW_CONFIG); elem = tplg_elem_new_common(tplg, cfg, NULL, SND_TPLG_TYPE_HW_CONFIG);
if (!elem) if (!elem)
@ -1178,11 +1178,11 @@ int tplg_parse_hw_config(snd_tplg_t *tplg, snd_config_t *cfg,
if (strcmp(id, "bclk_invert") == 0 || if (strcmp(id, "bclk_invert") == 0 ||
strcmp(id, "invert_bclk") == 0) { strcmp(id, "invert_bclk") == 0) {
if (snd_config_get_string(n, &val) < 0) ival = snd_config_get_bool(n);
if (ival < 0)
return -EINVAL; return -EINVAL;
if (!strcmp(val, "true")) hw_cfg->invert_bclk = ival;
hw_cfg->invert_bclk = true;
continue; continue;
} }
@ -1209,11 +1209,11 @@ int tplg_parse_hw_config(snd_tplg_t *tplg, snd_config_t *cfg,
if (strcmp(id, "fsync_invert") == 0 || if (strcmp(id, "fsync_invert") == 0 ||
strcmp(id, "invert_fsync") == 0) { strcmp(id, "invert_fsync") == 0) {
if (snd_config_get_string(n, &val) < 0) ival = snd_config_get_bool(n);
if (ival < 0)
return -EINVAL; return -EINVAL;
if (!strcmp(val, "true")) hw_cfg->invert_fsync = ival;
hw_cfg->invert_fsync = true;
continue; continue;
} }
@ -1254,10 +1254,11 @@ int tplg_parse_hw_config(snd_tplg_t *tplg, snd_config_t *cfg,
if (strcmp(id, "pm_gate_clocks") == 0 || if (strcmp(id, "pm_gate_clocks") == 0 ||
strcmp(id, "clock_gated") == 0) { strcmp(id, "clock_gated") == 0) {
if (snd_config_get_string(n, &val) < 0) ival = snd_config_get_bool(n);
if (ival < 0)
return -EINVAL; return -EINVAL;
if (!strcmp(val, "true")) if (ival)
hw_cfg->clock_gated = hw_cfg->clock_gated =
SND_SOC_TPLG_DAI_CLK_GATE_GATED; SND_SOC_TPLG_DAI_CLK_GATE_GATED;
else else