struct graph_card_data {
struct snd_soc_card snd_card;
- struct snd_soc_codec_conf codec_conf;
struct graph_dai_props {
struct asoc_simple_dai *cpu_dai;
struct asoc_simple_dai *codec_dai;
struct snd_soc_dai_link_component codecs;
struct snd_soc_dai_link_component platform;
struct asoc_simple_card_data adata;
+ struct snd_soc_codec_conf *codec_conf;
} *dai_props;
struct snd_soc_dai_link *dai_link;
struct asoc_simple_dai *dais;
struct asoc_simple_card_data adata;
+ struct snd_soc_codec_conf *codec_conf;
};
#define graph_priv_to_card(priv) (&(priv)->snd_card)
static int asoc_graph_card_dai_link_of(struct device_node *cpu_ep,
struct device_node *codec_ep,
struct graph_card_data *priv,
- int *dai_idx, int link_idx, int is_fe)
+ int *dai_idx, int link_idx,
+ int *conf_idx, int is_fe)
{
struct device *dev = graph_priv_to_dev(priv);
struct snd_soc_dai_link *dai_link = graph_priv_to_link(priv, link_idx);
asoc_simple_card_canonicalize_cpu(dai_link,
of_graph_get_endpoint_count(dai_link->cpu_of_node) == 1);
} else {
+ struct snd_soc_codec_conf *cconf;
+
/* FE is dummy */
dai_link->cpu_of_node = NULL;
dai_link->cpu_dai_name = "snd-soc-dummy-dai";
dai =
dai_props->codec_dai = &priv->dais[(*dai_idx)++];
+ cconf =
+ dai_props->codec_conf = &priv->codec_conf[(*conf_idx)++];
+
ret = asoc_simple_card_parse_graph_codec(ep, dai_link);
if (ret < 0)
return ret;
return ret;
/* check "prefix" from top node */
- snd_soc_of_parse_audio_prefix(card,
- &priv->codec_conf,
+ snd_soc_of_parse_audio_prefix(card, cconf,
dai_link->codecs->of_node,
"prefix");
/* check "prefix" from each node if top doesn't have */
- if (!priv->codec_conf.of_node)
- snd_soc_of_parse_node_prefix(node,
- &priv->codec_conf,
+ if (!cconf->of_node)
+ snd_soc_of_parse_node_prefix(node, cconf,
dai_link->codecs->of_node,
PREFIX "prefix");
}
struct device_node *codec_ep;
struct device_node *codec_port;
struct device_node *codec_port_old;
- int dai_idx, link_idx, ret;
+ int dai_idx, link_idx, conf_idx, ret;
int rc, codec;
if (!node)
link_idx = 0;
dai_idx = 0;
+ conf_idx = 0;
codec_port_old = NULL;
for (codec = 0; codec < 2; codec++) {
/*
ret = asoc_graph_card_dai_link_of(cpu_ep, codec_ep,
priv, &dai_idx,
- link_idx++, !codec);
+ link_idx++, &conf_idx,
+ !codec);
if (ret < 0)
goto parse_of_err;
}
if (ret)
goto parse_of_err;
+ if ((card->num_links != link_idx) ||
+ (card->num_configs != conf_idx)) {
+ dev_err(dev, "dai_link or codec_config wrong (%d/%d, %d/%d)\n",
+ card->num_links, link_idx, card->num_configs, conf_idx);
+ ret = -EINVAL;
+ goto parse_of_err;
+ }
+
ret = 0;
parse_of_err:
struct asoc_simple_dai *dais;
struct device *dev = &pdev->dev;
struct snd_soc_card *card;
+ struct snd_soc_codec_conf *cconf;
int lnum = 0, dnum = 0, cnum = 0;
int ret, i;
dai_props = devm_kcalloc(dev, lnum, sizeof(*dai_props), GFP_KERNEL);
dai_link = devm_kcalloc(dev, lnum, sizeof(*dai_link), GFP_KERNEL);
dais = devm_kcalloc(dev, dnum, sizeof(*dais), GFP_KERNEL);
+ cconf = devm_kcalloc(dev, cnum, sizeof(*cconf), GFP_KERNEL);
if (!dai_props || !dai_link || !dais)
return -ENOMEM;
priv->dai_props = dai_props;
priv->dai_link = dai_link;
priv->dais = dais;
+ priv->codec_conf = cconf;
/* Init snd_soc_card */
card = graph_priv_to_card(priv);
card->dev = dev;
card->dai_link = priv->dai_link;
card->num_links = lnum;
- card->codec_conf = &priv->codec_conf;
- card->num_configs = 1;
+ card->codec_conf = cconf;
+ card->num_configs = cnum;
ret = asoc_graph_card_parse_of(priv);
if (ret < 0) {