]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
ASoC: soc-core: do rtd->id trick at snd_soc_add_pcm_runtime()
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Thu, 24 Oct 2024 01:29:52 +0000 (01:29 +0000)
committerMark Brown <broonie@kernel.org>
Fri, 1 Nov 2024 14:48:15 +0000 (14:48 +0000)
qcom/qdsp6 want to use irregular rtd->id because of its topology.
Current code is calculating it at soc_init_pcm_runtime() which calls
soc_new_pcm(), and it doesn't save it to rtd->id.

Let's calculate and save it to rtd at snd_soc_add_pcm_runtime()
which create rtd and connect related components.

But, this feature should be implemented by using "dai_link" instead
of "component". Add FIXME as comment.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://patch.msgid.link/87r086b84w.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/soc-core.c

index 233c91e60f0cbb846763ccff58979e09b80b1712..4f0bfe73fe15efb2f0105e239307fdcd89f7e11c 100644 (file)
@@ -1166,7 +1166,7 @@ static int snd_soc_add_pcm_runtime(struct snd_soc_card *card,
        struct snd_soc_pcm_runtime *rtd;
        struct snd_soc_dai_link_component *codec, *platform, *cpu;
        struct snd_soc_component *component;
-       int i, ret;
+       int i, id, ret;
 
        lockdep_assert_held(&client_mutex);
 
@@ -1225,6 +1225,28 @@ static int snd_soc_add_pcm_runtime(struct snd_soc_card *card,
                }
        }
 
+       /*
+        * Most drivers will register their PCMs using DAI link ordering but
+        * topology based drivers can use the DAI link id field to set PCM
+        * device number and then use rtd + a base offset of the BEs.
+        *
+        * FIXME
+        *
+        * This should be implemented by using "dai_link" feature instead of
+        * "component" feature.
+        */
+       id = rtd->id;
+       for_each_rtd_components(rtd, i, component) {
+               if (!component->driver->use_dai_pcm_id)
+                       continue;
+
+               if (rtd->dai_link->no_pcm)
+                       id += component->driver->be_pcm_base;
+               else
+                       id = rtd->dai_link->id;
+       }
+       rtd->id = id;
+
        return 0;
 
 _err_defer:
@@ -1457,8 +1479,7 @@ static int soc_init_pcm_runtime(struct snd_soc_card *card,
 {
        struct snd_soc_dai_link *dai_link = rtd->dai_link;
        struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0);
-       struct snd_soc_component *component;
-       int ret, id, i;
+       int ret, id;
 
        /* do machine specific initialization */
        ret = snd_soc_link_init(rtd);
@@ -1475,21 +1496,6 @@ static int soc_init_pcm_runtime(struct snd_soc_card *card,
 
        id = rtd->id;
 
-       /*
-        * most drivers will register their PCMs using DAI link ordering but
-        * topology based drivers can use the DAI link id field to set PCM
-        * device number and then use rtd + a base offset of the BEs.
-        */
-       for_each_rtd_components(rtd, i, component) {
-               if (!component->driver->use_dai_pcm_id)
-                       continue;
-
-               if (rtd->dai_link->no_pcm)
-                       id += component->driver->be_pcm_base;
-               else
-                       id = rtd->dai_link->id;
-       }
-
        /* create compress_device if possible */
        ret = snd_soc_dai_compress_new(cpu_dai, rtd, id);
        if (ret != -ENOTSUPP)