ASoC: simple-card.c: enable multi Component support
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Mon, 10 Jul 2023 01:20:28 +0000 (10:20 +0900)
committerMark Brown <broonie@kernel.org>
Mon, 17 Jul 2023 05:15:47 +0000 (06:15 +0100)
If CPU/Codec driver keeps its DAI node, we can directly identify actual
DAI by using snd_soc_get_dai_via_args().
This means we can use multi Component.

This patch enables multi Component support for Simple Card

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/878rboo943.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/generic/simple-card.c

index a78babf44f38cb1502786329ffc9ea76ede08675..190f11366e84e0075625604f341d633f4b0075dd 100644 (file)
@@ -52,11 +52,13 @@ static int asoc_simple_parse_platform(struct device_node *node,
        return 0;
 }
 
-static int asoc_simple_parse_dai(struct device_node *node,
+static int asoc_simple_parse_dai(struct device *dev,
+                                struct device_node *node,
                                 struct snd_soc_dai_link_component *dlc,
                                 int *is_single_link)
 {
        struct of_phandle_args args;
+       struct snd_soc_dai *dai;
        int ret;
 
        if (!node)
@@ -70,6 +72,19 @@ static int asoc_simple_parse_dai(struct device_node *node,
        if (ret)
                return ret;
 
+       /*
+        * Try to find from DAI args
+        */
+       dai = snd_soc_get_dai_via_args(&args);
+       if (dai) {
+               dlc->dai_name = snd_soc_dai_name_get(dai);
+               dlc->dai_args = snd_soc_copy_dai_args(dev, &args);
+               if (!dlc->dai_args)
+                       return -ENOMEM;
+
+               goto parse_dai_end;
+       }
+
        /*
         * FIXME
         *
@@ -93,6 +108,7 @@ static int asoc_simple_parse_dai(struct device_node *node,
        if (ret < 0)
                return ret;
 
+parse_dai_end:
        if (is_single_link)
                *is_single_link = !args.args_count;
 
@@ -156,7 +172,7 @@ static int simple_parse_node(struct asoc_simple_priv *priv,
 
        simple_parse_mclk_fs(top, np, dai_props, prefix);
 
-       ret = asoc_simple_parse_dai(np, dlc, cpu);
+       ret = asoc_simple_parse_dai(dev, np, dlc, cpu);
        if (ret)
                return ret;