Commit 3433bf07 authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown

ASoC: rsrc-card: enable multi cpu/codec for DPCM

Current rsrc-card is assuming 1 FE (= CPU), 1 BE (= codec) on card.
But, it will support multi FE/BE card. This is prepare for it.
Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: default avatarKeita Kobayashi <keita.kobayashi.ym@renesas.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 3c7e64dd
...@@ -52,7 +52,6 @@ struct rsrc_card_dai { ...@@ -52,7 +52,6 @@ struct rsrc_card_dai {
struct clk *clk; struct clk *clk;
}; };
#define RSRC_FB_NUM 2 /* FE/BE */
#define IDX_CPU 0 #define IDX_CPU 0
#define IDX_CODEC 1 #define IDX_CODEC 1
#define DAI_NAME_NUM 32 #define DAI_NAME_NUM 32
...@@ -62,9 +61,10 @@ struct rsrc_card_priv { ...@@ -62,9 +61,10 @@ struct rsrc_card_priv {
struct rsrc_card_dai cpu_dai; struct rsrc_card_dai cpu_dai;
struct rsrc_card_dai codec_dai; struct rsrc_card_dai codec_dai;
char dai_name[DAI_NAME_NUM]; char dai_name[DAI_NAME_NUM];
} dai_props[RSRC_FB_NUM]; } *dai_props;
struct snd_soc_codec_conf codec_conf; struct snd_soc_codec_conf codec_conf;
struct snd_soc_dai_link dai_link[RSRC_FB_NUM]; struct snd_soc_dai_link *dai_link;
int dai_num;
u32 convert_rate; u32 convert_rate;
}; };
...@@ -395,12 +395,25 @@ static int rsrc_card_parse_of(struct device_node *node, ...@@ -395,12 +395,25 @@ static int rsrc_card_parse_of(struct device_node *node,
struct device *dev) struct device *dev)
{ {
const struct rsrc_card_of_data *of_data = rsrc_dev_to_of_data(dev); const struct rsrc_card_of_data *of_data = rsrc_dev_to_of_data(dev);
struct rsrc_card_dai_props *props;
struct snd_soc_dai_link *links;
int ret; int ret;
int i; int i, num;
if (!node) if (!node)
return -EINVAL; return -EINVAL;
num = of_get_child_count(node);
props = devm_kzalloc(dev, sizeof(*props) * num, GFP_KERNEL);
links = devm_kzalloc(dev, sizeof(*links) * num, GFP_KERNEL);
if (!props || !links)
return -ENOMEM;
priv->dai_props = props;
priv->dai_link = links;
priv->dai_num = num;
/* Parse the card name from DT */ /* Parse the card name from DT */
snd_soc_of_parse_card_name(&priv->snd_card, "card-name"); snd_soc_of_parse_card_name(&priv->snd_card, "card-name");
...@@ -408,7 +421,7 @@ static int rsrc_card_parse_of(struct device_node *node, ...@@ -408,7 +421,7 @@ static int rsrc_card_parse_of(struct device_node *node,
priv->snd_card.owner = THIS_MODULE; priv->snd_card.owner = THIS_MODULE;
priv->snd_card.dev = dev; priv->snd_card.dev = dev;
priv->snd_card.dai_link = priv->dai_link; priv->snd_card.dai_link = priv->dai_link;
priv->snd_card.num_links = RSRC_FB_NUM; priv->snd_card.num_links = num;
priv->snd_card.codec_conf = &priv->codec_conf; priv->snd_card.codec_conf = &priv->codec_conf;
priv->snd_card.num_configs = 1; priv->snd_card.num_configs = 1;
priv->snd_card.of_dapm_routes = of_data->routes; priv->snd_card.of_dapm_routes = of_data->routes;
...@@ -422,7 +435,7 @@ static int rsrc_card_parse_of(struct device_node *node, ...@@ -422,7 +435,7 @@ static int rsrc_card_parse_of(struct device_node *node,
priv->convert_rate); priv->convert_rate);
/* FE/BE */ /* FE/BE */
for (i = 0; i < RSRC_FB_NUM; i++) { for (i = 0; i < num; i++) {
ret = rsrc_card_dai_link_of(node, priv, i); ret = rsrc_card_dai_link_of(node, priv, i);
if (ret < 0) if (ret < 0)
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment