summaryrefslogtreecommitdiff
path: root/sound/soc/generic/simple-card.c
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2019-03-20 07:56:36 +0300
committerMark Brown <broonie@kernel.org>2019-03-21 17:52:37 +0300
commit8f7f298a333761a528e103cda3b42f3a416ad1ee (patch)
treee5b79636bc0a7e7aa859e6791512aa1103db5ba2 /sound/soc/generic/simple-card.c
parent65a5056b21202eff7f54243e587183f4bb6ed352 (diff)
downloadlinux-8f7f298a333761a528e103cda3b42f3a416ad1ee.tar.xz
ASoC: simple-card-utils: separate asoc_simple_card_parse_dai()
The difference between simple-card / audio-graph are just using OF graph style, or not. In other words, other things should be same. This means, simple-card/audio-graph common functions should be implemented at simple-card-utils, and its own functions should be implemented at each files. Current simple-card / audio-graph are using asoc_simple_card_parse_dai() which is different implementation. But, these are implemanted at simple-card-utils. It should be implemanted at each files. This patch separate these into each files. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/generic/simple-card.c')
-rw-r--r--sound/soc/generic/simple-card.c58
1 files changed, 51 insertions, 7 deletions
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index 4e3e6b34593c..d8560fb1f5de 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -25,6 +25,52 @@ static const struct snd_soc_ops simple_ops = {
.hw_params = asoc_simple_hw_params,
};
+static int asoc_simple_card_parse_dai(struct device_node *node,
+ struct snd_soc_dai_link_component *dlc,
+ struct device_node **dai_of_node,
+ const char **dai_name,
+ int *is_single_link)
+{
+ struct of_phandle_args args;
+ int ret;
+
+ if (!node)
+ return 0;
+
+ /*
+ * Use snd_soc_dai_link_component instead of legacy style.
+ * It is only for codec, but cpu will be supported in the future.
+ * see
+ * soc-core.c :: snd_soc_init_multicodec()
+ */
+ if (dlc) {
+ dai_name = &dlc->dai_name;
+ dai_of_node = &dlc->of_node;
+ }
+
+ /*
+ * Get node via "sound-dai = <&phandle port>"
+ * it will be used as xxx_of_node on soc_bind_dai_link()
+ */
+ ret = of_parse_phandle_with_args(node, DAI, CELL, 0, &args);
+ if (ret)
+ return ret;
+
+ /* Get dai->name */
+ if (dai_name) {
+ ret = snd_soc_of_get_dai_name(node, dai_name);
+ if (ret < 0)
+ return ret;
+ }
+
+ *dai_of_node = args.np;
+
+ if (is_single_link)
+ *is_single_link = !args.args_count;
+
+ return 0;
+}
+
static void simple_parse_convert(struct device *dev,
struct device_node *np,
struct asoc_simple_card_data *adata)
@@ -110,8 +156,7 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv,
dai =
dai_props->cpu_dai = &priv->dais[li->dais++];
- ret = asoc_simple_card_parse_cpu(np, dai_link, DAI, CELL,
- &is_single_links);
+ ret = asoc_simple_card_parse_cpu(np, dai_link, &is_single_links);
if (ret)
return ret;
@@ -144,7 +189,7 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv,
cconf =
dai_props->codec_conf = &priv->codec_conf[li->conf++];
- ret = asoc_simple_card_parse_codec(np, dai_link, DAI, CELL);
+ ret = asoc_simple_card_parse_codec(np, dai_link);
if (ret < 0)
return ret;
@@ -242,16 +287,15 @@ static int simple_dai_link_of(struct asoc_simple_priv *priv,
simple_parse_mclk_fs(top, cpu, codec, dai_props, prefix);
- ret = asoc_simple_card_parse_cpu(cpu, dai_link,
- DAI, CELL, &single_cpu);
+ ret = asoc_simple_card_parse_cpu(cpu, dai_link, &single_cpu);
if (ret < 0)
goto dai_link_of_err;
- ret = asoc_simple_card_parse_codec(codec, dai_link, DAI, CELL);
+ ret = asoc_simple_card_parse_codec(codec, dai_link);
if (ret < 0)
goto dai_link_of_err;
- ret = asoc_simple_card_parse_platform(plat, dai_link, DAI, CELL);
+ ret = asoc_simple_card_parse_platform(plat, dai_link);
if (ret < 0)
goto dai_link_of_err;