mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-04 13:30:08 -05:00
topology: avoid to use the atoi() directly when expected
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
9e2bbccfcc
commit
f373bf1f6e
9 changed files with 150 additions and 133 deletions
|
|
@ -80,8 +80,8 @@ int tplg_parse_channel(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;
|
||||||
struct snd_soc_tplg_channel *channel = private;
|
struct snd_soc_tplg_channel *channel = private;
|
||||||
const char *id, *value;
|
const char *id;
|
||||||
int channel_id;
|
int channel_id, value;
|
||||||
|
|
||||||
if (tplg->channel_idx >= SND_SOC_TPLG_MAX_CHAN)
|
if (tplg->channel_idx >= SND_SOC_TPLG_MAX_CHAN)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
@ -109,13 +109,13 @@ int tplg_parse_channel(snd_tplg_t *tplg, snd_config_t *cfg,
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* get value */
|
/* get value */
|
||||||
if (snd_config_get_string(n, &value) < 0)
|
if (tplg_get_integer(n, &value, 0) < 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (strcmp(id, "reg") == 0)
|
if (strcmp(id, "reg") == 0)
|
||||||
channel->reg = atoi(value);
|
channel->reg = value;
|
||||||
else if (strcmp(id, "shift") == 0)
|
else if (strcmp(id, "shift") == 0)
|
||||||
channel->shift = atoi(value);
|
channel->shift = value;
|
||||||
|
|
||||||
tplg_dbg("\t\t%s = %s\n", id, value);
|
tplg_dbg("\t\t%s = %s\n", id, value);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -286,7 +286,8 @@ static int tplg_parse_tlv_dbscale(snd_config_t *cfg, struct tplg_elem *elem)
|
||||||
snd_config_t *n;
|
snd_config_t *n;
|
||||||
struct snd_soc_tplg_ctl_tlv *tplg_tlv;
|
struct snd_soc_tplg_ctl_tlv *tplg_tlv;
|
||||||
struct snd_soc_tplg_tlv_dbscale *scale;
|
struct snd_soc_tplg_tlv_dbscale *scale;
|
||||||
const char *id = NULL, *value = NULL;
|
const char *id = NULL;
|
||||||
|
int val;
|
||||||
|
|
||||||
tplg_dbg(" scale: %s\n", elem->id);
|
tplg_dbg(" scale: %s\n", elem->id);
|
||||||
|
|
||||||
|
|
@ -310,18 +311,18 @@ static int tplg_parse_tlv_dbscale(snd_config_t *cfg, struct tplg_elem *elem)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get value */
|
/* get value */
|
||||||
if (snd_config_get_string(n, &value) < 0)
|
if (tplg_get_integer(n, &val, 0))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
tplg_dbg("\t%s = %s\n", id, value);
|
tplg_dbg("\t%s = %i\n", id, val);
|
||||||
|
|
||||||
/* get TLV data */
|
/* get TLV data */
|
||||||
if (strcmp(id, "min") == 0)
|
if (strcmp(id, "min") == 0)
|
||||||
scale->min = atoi(value);
|
scale->min = val;
|
||||||
else if (strcmp(id, "step") == 0)
|
else if (strcmp(id, "step") == 0)
|
||||||
scale->step = atoi(value);
|
scale->step = val;
|
||||||
else if (strcmp(id, "mute") == 0)
|
else if (strcmp(id, "mute") == 0)
|
||||||
scale->mute = atoi(value);
|
scale->mute = val;
|
||||||
else
|
else
|
||||||
SNDERR("error: unknown key %s\n", id);
|
SNDERR("error: unknown key %s\n", id);
|
||||||
}
|
}
|
||||||
|
|
@ -372,7 +373,7 @@ int tplg_parse_control_bytes(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 err;
|
int err, ival;
|
||||||
bool access_set = false, tlv_set = false;
|
bool access_set = false, tlv_set = false;
|
||||||
|
|
||||||
elem = tplg_elem_new_common(tplg, cfg, NULL, SND_TPLG_TYPE_BYTES);
|
elem = tplg_elem_new_common(tplg, cfg, NULL, SND_TPLG_TYPE_BYTES);
|
||||||
|
|
@ -398,37 +399,37 @@ int tplg_parse_control_bytes(snd_tplg_t *tplg,
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (strcmp(id, "base") == 0) {
|
if (strcmp(id, "base") == 0) {
|
||||||
if (snd_config_get_string(n, &val) < 0)
|
if (tplg_get_integer(n, &ival, 0))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
be->base = atoi(val);
|
be->base = ival;
|
||||||
tplg_dbg("\t%s: %d\n", id, be->base);
|
tplg_dbg("\t%s: %d\n", id, be->base);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(id, "num_regs") == 0) {
|
if (strcmp(id, "num_regs") == 0) {
|
||||||
if (snd_config_get_string(n, &val) < 0)
|
if (tplg_get_integer(n, &ival, 0))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
be->num_regs = atoi(val);
|
be->num_regs = ival;
|
||||||
tplg_dbg("\t%s: %d\n", id, be->num_regs);
|
tplg_dbg("\t%s: %d\n", id, be->num_regs);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(id, "max") == 0) {
|
if (strcmp(id, "max") == 0) {
|
||||||
if (snd_config_get_string(n, &val) < 0)
|
if (tplg_get_integer(n, &ival, 0))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
be->max = atoi(val);
|
be->max = ival;
|
||||||
tplg_dbg("\t%s: %d\n", id, be->max);
|
tplg_dbg("\t%s: %d\n", id, be->max);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(id, "mask") == 0) {
|
if (strcmp(id, "mask") == 0) {
|
||||||
if (snd_config_get_string(n, &val) < 0)
|
if (tplg_get_integer(n, &ival, 16))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
be->mask = strtol(val, NULL, 16);
|
be->mask = ival;
|
||||||
tplg_dbg("\t%s: %d\n", id, be->mask);
|
tplg_dbg("\t%s: %d\n", id, be->mask);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -598,7 +599,7 @@ int tplg_parse_control_mixer(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 err, j;
|
int err, j, ival;
|
||||||
bool access_set = false, tlv_set = false;
|
bool access_set = false, tlv_set = false;
|
||||||
|
|
||||||
elem = tplg_elem_new_common(tplg, cfg, NULL, SND_TPLG_TYPE_MIXER);
|
elem = tplg_elem_new_common(tplg, cfg, NULL, SND_TPLG_TYPE_MIXER);
|
||||||
|
|
@ -647,10 +648,10 @@ int tplg_parse_control_mixer(snd_tplg_t *tplg,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(id, "max") == 0) {
|
if (strcmp(id, "max") == 0) {
|
||||||
if (snd_config_get_string(n, &val) < 0)
|
if (tplg_get_integer(n, &ival, 0))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
mc->max = atoi(val);
|
mc->max = ival;
|
||||||
tplg_dbg("\t%s: %d\n", id, mc->max);
|
tplg_dbg("\t%s: %d\n", id, mc->max);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -426,7 +426,7 @@ int tplg_parse_dapm_graph(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;
|
||||||
int err;
|
int err;
|
||||||
const char *graph_id, *val = NULL;
|
const char *graph_id;
|
||||||
int index = -1;
|
int index = -1;
|
||||||
|
|
||||||
if (snd_config_get_type(cfg) != SND_CONFIG_TYPE_COMPOUND) {
|
if (snd_config_get_type(cfg) != SND_CONFIG_TYPE_COMPOUND) {
|
||||||
|
|
@ -445,9 +445,10 @@ int tplg_parse_dapm_graph(snd_tplg_t *tplg, snd_config_t *cfg,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(id, "index") == 0) {
|
if (strcmp(id, "index") == 0) {
|
||||||
if (snd_config_get_string(n, &val) < 0)
|
if (tplg_get_integer(n, &index, 0))
|
||||||
|
return -EINVAL;
|
||||||
|
if (index < 0)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
index = atoi(val);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(id, "lines") == 0) {
|
if (strcmp(id, "lines") == 0) {
|
||||||
|
|
@ -479,6 +480,7 @@ int tplg_parse_dapm_widget(snd_tplg_t *tplg,
|
||||||
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;
|
||||||
|
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)
|
||||||
|
|
@ -540,55 +542,55 @@ int tplg_parse_dapm_widget(snd_tplg_t *tplg,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(id, "shift") == 0) {
|
if (strcmp(id, "shift") == 0) {
|
||||||
if (snd_config_get_string(n, &val) < 0)
|
if (tplg_get_integer(n, &ival, 0))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
widget->shift = atoi(val);
|
widget->shift = ival;
|
||||||
tplg_dbg("\t%s: %d\n", id, widget->shift);
|
tplg_dbg("\t%s: %d\n", id, widget->shift);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(id, "reg") == 0) {
|
if (strcmp(id, "reg") == 0) {
|
||||||
if (snd_config_get_string(n, &val) < 0)
|
if (tplg_get_integer(n, &ival, 0))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
widget->reg = atoi(val);
|
widget->reg = ival;
|
||||||
tplg_dbg("\t%s: %d\n", id, widget->reg);
|
tplg_dbg("\t%s: %d\n", id, widget->reg);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(id, "invert") == 0) {
|
if (strcmp(id, "invert") == 0) {
|
||||||
if (snd_config_get_string(n, &val) < 0)
|
if (tplg_get_integer(n, &ival, 0))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
widget->invert = atoi(val);
|
widget->invert = ival;
|
||||||
tplg_dbg("\t%s: %d\n", id, widget->invert);
|
tplg_dbg("\t%s: %d\n", id, widget->invert);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(id, "subseq") == 0) {
|
if (strcmp(id, "subseq") == 0) {
|
||||||
if (snd_config_get_string(n, &val) < 0)
|
if (tplg_get_integer(n, &ival, 0))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
widget->subseq= atoi(val);
|
widget->subseq = ival;
|
||||||
tplg_dbg("\t%s: %d\n", id, widget->subseq);
|
tplg_dbg("\t%s: %d\n", id, widget->subseq);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(id, "event_type") == 0) {
|
if (strcmp(id, "event_type") == 0) {
|
||||||
if (snd_config_get_string(n, &val) < 0)
|
if (tplg_get_integer(n, &ival, 0))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
widget->event_type = atoi(val);
|
widget->event_type = ival;
|
||||||
tplg_dbg("\t%s: %d\n", id, widget->event_type);
|
tplg_dbg("\t%s: %d\n", id, widget->event_type);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(id, "event_flags") == 0) {
|
if (strcmp(id, "event_flags") == 0) {
|
||||||
if (snd_config_get_string(n, &val) < 0)
|
if (tplg_get_integer(n, &ival, 0))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
widget->event_flags = atoi(val);
|
widget->event_flags = ival;
|
||||||
tplg_dbg("\t%s: %d\n", id, widget->event_flags);
|
tplg_dbg("\t%s: %d\n", id, widget->event_flags);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -800,10 +800,10 @@ int tplg_parse_tokens(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, *value;
|
const char *id;
|
||||||
struct tplg_elem *elem;
|
struct tplg_elem *elem;
|
||||||
struct tplg_vendor_tokens *tokens;
|
struct tplg_vendor_tokens *tokens;
|
||||||
int num_tokens = 0;
|
int num_tokens = 0, value;
|
||||||
|
|
||||||
elem = tplg_elem_new_common(tplg, cfg, NULL, SND_TPLG_TYPE_TOKEN);
|
elem = tplg_elem_new_common(tplg, cfg, NULL, SND_TPLG_TYPE_TOKEN);
|
||||||
if (!elem)
|
if (!elem)
|
||||||
|
|
@ -830,12 +830,12 @@ int tplg_parse_tokens(snd_tplg_t *tplg, snd_config_t *cfg,
|
||||||
if (snd_config_get_id(n, &id) < 0)
|
if (snd_config_get_id(n, &id) < 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (snd_config_get_string(n, &value) < 0)
|
if (tplg_get_integer(n, &value, 0))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
snd_strlcpy(tokens->token[tokens->num_tokens].id, id,
|
snd_strlcpy(tokens->token[tokens->num_tokens].id, id,
|
||||||
SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
||||||
tokens->token[tokens->num_tokens].value = atoi(value);
|
tokens->token[tokens->num_tokens].value = value;
|
||||||
tplg_dbg("\t\t %s : %d\n", tokens->token[tokens->num_tokens].id,
|
tplg_dbg("\t\t %s : %d\n", tokens->token[tokens->num_tokens].id,
|
||||||
tokens->token[tokens->num_tokens].value);
|
tokens->token[tokens->num_tokens].value);
|
||||||
tokens->num_tokens++;
|
tokens->num_tokens++;
|
||||||
|
|
@ -1013,7 +1013,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, *val = NULL;
|
||||||
int err = 0;
|
int err = 0, ival;
|
||||||
struct tplg_elem *elem;
|
struct tplg_elem *elem;
|
||||||
|
|
||||||
elem = tplg_elem_new_common(tplg, cfg, NULL, SND_TPLG_TYPE_DATA);
|
elem = tplg_elem_new_common(tplg, cfg, NULL, SND_TPLG_TYPE_DATA);
|
||||||
|
|
@ -1071,10 +1071,10 @@ int tplg_parse_data(snd_tplg_t *tplg, snd_config_t *cfg,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(id, "type") == 0) {
|
if (strcmp(id, "type") == 0) {
|
||||||
if (snd_config_get_string(n, &val) < 0)
|
if (tplg_get_integer(n, &ival, 0))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
elem->vendor_type = atoi(val);
|
elem->vendor_type = ival;
|
||||||
tplg_dbg("\t%s: %d\n", id, elem->index);
|
tplg_dbg("\t%s: %d\n", id, elem->index);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -153,7 +153,7 @@ struct tplg_elem* tplg_elem_new_common(snd_tplg_t *tplg,
|
||||||
enum snd_tplg_type type)
|
enum snd_tplg_type type)
|
||||||
{
|
{
|
||||||
struct tplg_elem *elem;
|
struct tplg_elem *elem;
|
||||||
const char *id, *val = NULL;
|
const char *id;
|
||||||
int obj_size = 0;
|
int obj_size = 0;
|
||||||
void *obj;
|
void *obj;
|
||||||
snd_config_iterator_t i, next;
|
snd_config_iterator_t i, next;
|
||||||
|
|
@ -178,11 +178,14 @@ struct tplg_elem* tplg_elem_new_common(snd_tplg_t *tplg,
|
||||||
if (snd_config_get_id(n, &id))
|
if (snd_config_get_id(n, &id))
|
||||||
continue;
|
continue;
|
||||||
if (strcmp(id, "index") == 0) {
|
if (strcmp(id, "index") == 0) {
|
||||||
if (snd_config_get_string(n, &val) < 0) {
|
if (tplg_get_integer(n, &elem->index, 0)) {
|
||||||
|
free(elem);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (elem->index < 0) {
|
||||||
free(elem);
|
free(elem);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
elem->index = atoi(val);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (name != NULL)
|
} else if (name != NULL)
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ static int lookup_ops(const char *c)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* cant find string name in our table so we use its ID number */
|
/* cant find string name in our table so we use its ID number */
|
||||||
return atoi(c);
|
return strtol(c, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Parse Control operations. Ops can come from standard names above or
|
/* Parse Control operations. Ops can come from standard names above or
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,35 @@
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
#include "tplg_local.h"
|
#include "tplg_local.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get integer value
|
||||||
|
*/
|
||||||
|
int tplg_get_integer(snd_config_t *n, int *val, int base)
|
||||||
|
{
|
||||||
|
const char *str;
|
||||||
|
long lval;
|
||||||
|
int err;
|
||||||
|
|
||||||
|
switch (snd_config_get_type(n)) {
|
||||||
|
case SND_CONFIG_TYPE_INTEGER:
|
||||||
|
err = snd_config_get_integer(n, &lval);
|
||||||
|
if (err < 0)
|
||||||
|
return err;
|
||||||
|
if (lval < INT_MIN || lval > INT_MAX)
|
||||||
|
return -EINVAL;
|
||||||
|
*val = lval;
|
||||||
|
return err;
|
||||||
|
case SND_CONFIG_TYPE_STRING:
|
||||||
|
err = snd_config_get_string(n, &str);
|
||||||
|
if (err < 0)
|
||||||
|
return err;
|
||||||
|
*val = strtol(str, NULL, base);
|
||||||
|
return 0;
|
||||||
|
default:
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parse compound
|
* Parse compound
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -368,6 +368,24 @@ static int split_rate(struct snd_soc_tplg_stream_caps *caps, char *str)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int parse_unsigned(snd_config_t *n, unsigned int *dst)
|
||||||
|
{
|
||||||
|
int ival;
|
||||||
|
|
||||||
|
if (tplg_get_integer(n, &ival, 0) < 0)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
*dst = ival;
|
||||||
|
#if TPLG_DEBUG
|
||||||
|
{
|
||||||
|
const char *id;
|
||||||
|
if (snd_config_get_id(n, &id) >= 0)
|
||||||
|
tplg_dbg("\t\t%s: %d\n", id, *dst);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Parse pcm stream capabilities */
|
/* Parse pcm stream capabilities */
|
||||||
int tplg_parse_stream_caps(snd_tplg_t *tplg,
|
int tplg_parse_stream_caps(snd_tplg_t *tplg,
|
||||||
snd_config_t *cfg,
|
snd_config_t *cfg,
|
||||||
|
|
@ -402,10 +420,10 @@ int tplg_parse_stream_caps(snd_tplg_t *tplg,
|
||||||
if (id[0] == '#')
|
if (id[0] == '#')
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (snd_config_get_string(n, &val) < 0)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
if (strcmp(id, "formats") == 0) {
|
if (strcmp(id, "formats") == 0) {
|
||||||
|
if (snd_config_get_string(n, &val) < 0)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
s = strdup(val);
|
s = strdup(val);
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
@ -421,6 +439,9 @@ int tplg_parse_stream_caps(snd_tplg_t *tplg,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(id, "rates") == 0) {
|
if (strcmp(id, "rates") == 0) {
|
||||||
|
if (snd_config_get_string(n, &val) < 0)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
s = strdup(val);
|
s = strdup(val);
|
||||||
if (!s)
|
if (!s)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
@ -436,68 +457,68 @@ int tplg_parse_stream_caps(snd_tplg_t *tplg,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(id, "rate_min") == 0) {
|
if (strcmp(id, "rate_min") == 0) {
|
||||||
sc->rate_min = atoi(val);
|
if (parse_unsigned(n, &sc->rate_min))
|
||||||
tplg_dbg("\t\t%s: %d\n", id, sc->rate_min);
|
return -EINVAL;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(id, "rate_max") == 0) {
|
if (strcmp(id, "rate_max") == 0) {
|
||||||
sc->rate_max = atoi(val);
|
if (parse_unsigned(n, &sc->rate_max))
|
||||||
tplg_dbg("\t\t%s: %d\n", id, sc->rate_max);
|
return -EINVAL;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(id, "channels_min") == 0) {
|
if (strcmp(id, "channels_min") == 0) {
|
||||||
sc->channels_min = atoi(val);
|
if (parse_unsigned(n, &sc->channels_min))
|
||||||
tplg_dbg("\t\t%s: %d\n", id, sc->channels_min);
|
return -EINVAL;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(id, "channels_max") == 0) {
|
if (strcmp(id, "channels_max") == 0) {
|
||||||
sc->channels_max = atoi(val);
|
if (parse_unsigned(n, &sc->channels_max))
|
||||||
tplg_dbg("\t\t%s: %d\n", id, sc->channels_max);
|
return -EINVAL;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(id, "periods_min") == 0) {
|
if (strcmp(id, "periods_min") == 0) {
|
||||||
sc->periods_min = atoi(val);
|
if (parse_unsigned(n, &sc->periods_min))
|
||||||
tplg_dbg("\t\t%s: %d\n", id, sc->periods_min);
|
return -EINVAL;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(id, "periods_max") == 0) {
|
if (strcmp(id, "periods_max") == 0) {
|
||||||
sc->periods_max = atoi(val);
|
if (parse_unsigned(n, &sc->periods_max))
|
||||||
tplg_dbg("\t\t%s: %d\n", id, sc->periods_max);
|
return -EINVAL;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(id, "period_size_min") == 0) {
|
if (strcmp(id, "period_size_min") == 0) {
|
||||||
sc->period_size_min = atoi(val);
|
if (parse_unsigned(n, &sc->period_size_min))
|
||||||
tplg_dbg("\t\t%s: %d\n", id, sc->period_size_min);
|
return -EINVAL;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(id, "period_size_max") == 0) {
|
if (strcmp(id, "period_size_max") == 0) {
|
||||||
sc->period_size_max = atoi(val);
|
if (parse_unsigned(n, &sc->period_size_max))
|
||||||
tplg_dbg("\t\t%s: %d\n", id, sc->period_size_max);
|
return -EINVAL;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(id, "buffer_size_min") == 0) {
|
if (strcmp(id, "buffer_size_min") == 0) {
|
||||||
sc->buffer_size_min = atoi(val);
|
if (parse_unsigned(n, &sc->buffer_size_min))
|
||||||
tplg_dbg("\t\t%s: %d\n", id, sc->buffer_size_min);
|
return -EINVAL;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(id, "buffer_size_max") == 0) {
|
if (strcmp(id, "buffer_size_max") == 0) {
|
||||||
sc->buffer_size_max = atoi(val);
|
if (parse_unsigned(n, &sc->buffer_size_max))
|
||||||
tplg_dbg("\t\t%s: %d\n", id, sc->buffer_size_max);
|
return -EINVAL;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(id, "sig_bits") == 0) {
|
if (strcmp(id, "sig_bits") == 0) {
|
||||||
sc->sig_bits = atoi(val);
|
if (parse_unsigned(n, &sc->sig_bits))
|
||||||
tplg_dbg("\t\t%s: %d\n", id, sc->sig_bits);
|
return -EINVAL;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -674,11 +695,8 @@ int tplg_parse_pcm(snd_tplg_t *tplg, snd_config_t *cfg,
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (strcmp(id, "id") == 0) {
|
if (strcmp(id, "id") == 0) {
|
||||||
if (snd_config_get_string(n, &val) < 0)
|
if (parse_unsigned(n, &pcm->pcm_id))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
pcm->pcm_id = atoi(val);
|
|
||||||
tplg_dbg("\t%s: %d\n", id, pcm->pcm_id);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -784,30 +802,21 @@ int tplg_parse_dai(snd_tplg_t *tplg, snd_config_t *cfg,
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (strcmp(id, "id") == 0) {
|
if (strcmp(id, "id") == 0) {
|
||||||
if (snd_config_get_string(n, &val) < 0)
|
if (parse_unsigned(n, &dai->dai_id))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
dai->dai_id = atoi(val);
|
|
||||||
tplg_dbg("\t%s: %d\n", id, dai->dai_id);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(id, "playback") == 0) {
|
if (strcmp(id, "playback") == 0) {
|
||||||
if (snd_config_get_string(n, &val) < 0)
|
if (parse_unsigned(n, &dai->playback))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
dai->playback = atoi(val);
|
|
||||||
tplg_dbg("\t%s: %d\n", id, dai->playback);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (strcmp(id, "capture") == 0) {
|
if (strcmp(id, "capture") == 0) {
|
||||||
if (snd_config_get_string(n, &val) < 0)
|
if (parse_unsigned(n, &dai->capture))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
dai->capture = atoi(val);
|
|
||||||
tplg_dbg("\t%s: %d\n", id, dai->capture);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -949,11 +958,8 @@ int tplg_parse_link(snd_tplg_t *tplg,
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (strcmp(id, "id") == 0) {
|
if (strcmp(id, "id") == 0) {
|
||||||
if (snd_config_get_string(n, &val) < 0)
|
if (parse_unsigned(n, &link->id))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
link->id = atoi(val);
|
|
||||||
tplg_dbg("\t%s: %d\n", id, link->id);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -975,10 +981,8 @@ int tplg_parse_link(snd_tplg_t *tplg,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(id, "default_hw_conf_id") == 0) {
|
if (strcmp(id, "default_hw_conf_id") == 0) {
|
||||||
if (snd_config_get_string(n, &val) < 0)
|
if (parse_unsigned(n, &link->default_hw_config_id))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
link->default_hw_config_id = atoi(val);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1030,7 +1034,7 @@ int tplg_parse_cc(snd_tplg_t *tplg,
|
||||||
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;
|
||||||
|
|
||||||
elem = tplg_elem_new_common(tplg, cfg, NULL, SND_TPLG_TYPE_CC);
|
elem = tplg_elem_new_common(tplg, cfg, NULL, SND_TPLG_TYPE_CC);
|
||||||
if (!elem)
|
if (!elem)
|
||||||
|
|
@ -1054,11 +1058,8 @@ int tplg_parse_cc(snd_tplg_t *tplg,
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (strcmp(id, "id") == 0) {
|
if (strcmp(id, "id") == 0) {
|
||||||
if (snd_config_get_string(n, &val) < 0)
|
if (parse_unsigned(n, &link->id))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
link->id = atoi(val);
|
|
||||||
tplg_dbg("\t%s: %d\n", id, link->id);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1130,11 +1131,8 @@ int tplg_parse_hw_config(snd_tplg_t *tplg, snd_config_t *cfg,
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (strcmp(id, "id") == 0) {
|
if (strcmp(id, "id") == 0) {
|
||||||
if (snd_config_get_string(n, &val) < 0)
|
if (parse_unsigned(n, &hw_cfg->id))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
hw_cfg->id = atoi(val);
|
|
||||||
tplg_dbg("\t%s: %d\n", id, hw_cfg->id);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1173,10 +1171,8 @@ int tplg_parse_hw_config(snd_tplg_t *tplg, snd_config_t *cfg,
|
||||||
|
|
||||||
if (strcmp(id, "bclk_freq") == 0 ||
|
if (strcmp(id, "bclk_freq") == 0 ||
|
||||||
strcmp(id, "bclk_rate") == 0) {
|
strcmp(id, "bclk_rate") == 0) {
|
||||||
if (snd_config_get_string(n, &val) < 0)
|
if (parse_unsigned(n, &hw_cfg->bclk_rate))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
hw_cfg->bclk_rate = atoi(val);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1223,19 +1219,15 @@ int tplg_parse_hw_config(snd_tplg_t *tplg, snd_config_t *cfg,
|
||||||
|
|
||||||
if (strcmp(id, "fsync_freq") == 0 ||
|
if (strcmp(id, "fsync_freq") == 0 ||
|
||||||
strcmp(id, "fsync_rate") == 0) {
|
strcmp(id, "fsync_rate") == 0) {
|
||||||
if (snd_config_get_string(n, &val) < 0)
|
if (parse_unsigned(n, &hw_cfg->fsync_rate))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
hw_cfg->fsync_rate = atoi(val);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(id, "mclk_freq") == 0 ||
|
if (strcmp(id, "mclk_freq") == 0 ||
|
||||||
strcmp(id, "mclk_rate") == 0) {
|
strcmp(id, "mclk_rate") == 0) {
|
||||||
if (snd_config_get_string(n, &val) < 0)
|
if (parse_unsigned(n, &hw_cfg->mclk_rate))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
hw_cfg->mclk_rate = atoi(val);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1275,50 +1267,38 @@ int tplg_parse_hw_config(snd_tplg_t *tplg, snd_config_t *cfg,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(id, "tdm_slots") == 0) {
|
if (strcmp(id, "tdm_slots") == 0) {
|
||||||
if (snd_config_get_string(n, &val) < 0)
|
if (parse_unsigned(n, &hw_cfg->tdm_slots))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
hw_cfg->tdm_slots = atoi(val);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(id, "tdm_slot_width") == 0) {
|
if (strcmp(id, "tdm_slot_width") == 0) {
|
||||||
if (snd_config_get_string(n, &val) < 0)
|
if (parse_unsigned(n, &hw_cfg->tdm_slot_width))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
hw_cfg->tdm_slot_width = atoi(val);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(id, "tx_slots") == 0) {
|
if (strcmp(id, "tx_slots") == 0) {
|
||||||
if (snd_config_get_string(n, &val) < 0)
|
if (parse_unsigned(n, &hw_cfg->tx_slots))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
hw_cfg->tx_slots = atoi(val);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(id, "rx_slots") == 0) {
|
if (strcmp(id, "rx_slots") == 0) {
|
||||||
if (snd_config_get_string(n, &val) < 0)
|
if (parse_unsigned(n, &hw_cfg->rx_slots))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
hw_cfg->rx_slots = atoi(val);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(id, "tx_channels") == 0) {
|
if (strcmp(id, "tx_channels") == 0) {
|
||||||
if (snd_config_get_string(n, &val) < 0)
|
if (parse_unsigned(n, &hw_cfg->tx_channels))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
hw_cfg->tx_channels = atoi(val);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(id, "rx_channels") == 0) {
|
if (strcmp(id, "rx_channels") == 0) {
|
||||||
if (snd_config_get_string(n, &val) < 0)
|
if (parse_unsigned(n, &hw_cfg->rx_channels))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
hw_cfg->rx_channels = atoi(val);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -280,6 +280,8 @@ struct tplg_elem *tplg_elem_lookup(struct list_head *base,
|
||||||
struct tplg_elem* tplg_elem_new_common(snd_tplg_t *tplg,
|
struct tplg_elem* tplg_elem_new_common(snd_tplg_t *tplg,
|
||||||
snd_config_t *cfg, const char *name, enum snd_tplg_type type);
|
snd_config_t *cfg, const char *name, enum snd_tplg_type type);
|
||||||
|
|
||||||
|
int tplg_get_integer(snd_config_t *n, int *val, int base);
|
||||||
|
|
||||||
int tplg_parse_channel(snd_tplg_t *tplg ATTRIBUTE_UNUSED,
|
int tplg_parse_channel(snd_tplg_t *tplg ATTRIBUTE_UNUSED,
|
||||||
snd_config_t *cfg, void *private);
|
snd_config_t *cfg, void *private);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue