diff mbox

[05/21] ASoC: rsrc-card: enable multi cpu/codec for DPCM

Message ID 87mw01v6g7.wl%kuninori.morimoto.gx@renesas.com (mailing list archive)
State Accepted
Commit 3433bf0798356abf2e8b6145ac5633a610c0a8ec
Headers show

Commit Message

Kuninori Morimoto June 15, 2015, 6:22 a.m. UTC
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

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: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Keita Kobayashi <keita.kobayashi.ym@renesas.com>
---
 sound/soc/sh/rcar/rsrc-card.c | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)
diff mbox

Patch

diff --git a/sound/soc/sh/rcar/rsrc-card.c b/sound/soc/sh/rcar/rsrc-card.c
index cdd005b..ae99b36 100644
--- a/sound/soc/sh/rcar/rsrc-card.c
+++ b/sound/soc/sh/rcar/rsrc-card.c
@@ -52,7 +52,6 @@  struct rsrc_card_dai {
 	struct clk *clk;
 };
 
-#define RSRC_FB_NUM	2 /* FE/BE */
 #define IDX_CPU		0
 #define IDX_CODEC	1
 #define DAI_NAME_NUM	32
@@ -62,9 +61,10 @@  struct rsrc_card_priv {
 		struct rsrc_card_dai cpu_dai;
 		struct rsrc_card_dai codec_dai;
 		char dai_name[DAI_NAME_NUM];
-	} dai_props[RSRC_FB_NUM];
+	} *dai_props;
 	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;
 };
 
@@ -395,12 +395,25 @@  static int rsrc_card_parse_of(struct device_node *node,
 			      struct device *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 i;
+	int i, num;
 
 	if (!node)
 		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 */
 	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,
 	priv->snd_card.owner			= THIS_MODULE;
 	priv->snd_card.dev			= dev;
 	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.num_configs		= 1;
 	priv->snd_card.of_dapm_routes		= of_data->routes;
@@ -422,7 +435,7 @@  static int rsrc_card_parse_of(struct device_node *node,
 		priv->convert_rate);
 
 	/* 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);
 		if (ret < 0)
 			return ret;