]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ASoc: SOF: topology: connect DAI to a single DAI link
authorKai Vehmanen <kai.vehmanen@linux.intel.com>
Fri, 9 May 2025 08:53:18 +0000 (11:53 +0300)
committerMark Brown <broonie@kernel.org>
Fri, 9 May 2025 09:20:15 +0000 (18:20 +0900)
The partial matching of DAI widget to link names, can cause problems if
one of the widget names is a substring of another. E.g. with names
"Foo1" and Foo10", it's not possible to correctly link up "Foo1".

Modify the logic so that if multiple DAI links match the widget stream
name, prioritize a full match if one is found.

Fixes: fe88788779fc ("ASoC: SOF: topology: Use partial match for connecting DAI link and DAI widget")
Link: https://github.com/thesofproject/linux/issues/5308
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://patch.msgid.link/20250509085318.13936-1-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/topology.c

index dc9cb8324067831846b865f75e2f530c57e59062..14aa8ecc4bc426336a62ed0bc4998b3e5fd1bb91 100644 (file)
@@ -1063,7 +1063,7 @@ static int sof_connect_dai_widget(struct snd_soc_component *scomp,
                                  struct snd_sof_dai *dai)
 {
        struct snd_soc_card *card = scomp->card;
-       struct snd_soc_pcm_runtime *rtd;
+       struct snd_soc_pcm_runtime *rtd, *full, *partial;
        struct snd_soc_dai *cpu_dai;
        int stream;
        int i;
@@ -1080,12 +1080,22 @@ static int sof_connect_dai_widget(struct snd_soc_component *scomp,
        else
                goto end;
 
+       full = NULL;
+       partial = NULL;
        list_for_each_entry(rtd, &card->rtd_list, list) {
                /* does stream match DAI link ? */
-               if (!rtd->dai_link->stream_name ||
-                   !strstr(rtd->dai_link->stream_name, w->sname))
-                       continue;
+               if (rtd->dai_link->stream_name) {
+                       if (!strcmp(rtd->dai_link->stream_name, w->sname)) {
+                               full = rtd;
+                               break;
+                       } else if (strstr(rtd->dai_link->stream_name, w->sname)) {
+                               partial = rtd;
+                       }
+               }
+       }
 
+       rtd = full ? full : partial;
+       if (rtd) {
                for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
                        /*
                         * Please create DAI widget in the right order