]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ASoC: soc-pcm: merge DPCM and non-DPCM validation check
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Sun, 20 Oct 2024 23:59:49 +0000 (23:59 +0000)
committerMark Brown <broonie@kernel.org>
Wed, 23 Oct 2024 12:02:05 +0000 (13:02 +0100)
DPCM and non-DPCM validation check are very similar. The big difference
is that DPCM doesn't check Codec validation. This is historical reason.
It should be checked, but it breaks existing driver/behavior.

Anyway, if we uses dummy DAI as Codec when DPCM case, there is no
difference between DPCM and non-DPCM. Let's merge these.

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

index 5142d1abbc7b0f88934824926d7ce5285d0858a9..678400e76e53b74576b118ca024f0bfe79895d9e 100644 (file)
@@ -2822,7 +2822,11 @@ static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd,
 {
        struct snd_soc_dai_link *dai_link = rtd->dai_link;
        struct snd_soc_dai *cpu_dai;
+       struct snd_soc_dai *codec_dai;
        struct snd_soc_dai_link_ch_map *ch_maps;
+       struct snd_soc_dai *dummy_dai = snd_soc_find_dai(&snd_soc_dummy_dlc);
+       int cpu_capture;
+       int cpu_playback;
        int has_playback = 0;
        int has_capture  = 0;
        int i;
@@ -2832,40 +2836,38 @@ static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd,
                return -EINVAL;
        }
 
-       if (dai_link->dynamic || dai_link->no_pcm) {
-
-               for_each_rtd_ch_maps(rtd, i, ch_maps) {
-                       cpu_dai   = snd_soc_rtd_to_cpu(rtd,   ch_maps->cpu);
-
-                       if (snd_soc_dai_stream_valid(cpu_dai, SNDRV_PCM_STREAM_PLAYBACK))
-                               has_playback = 1;
-
-                       if (snd_soc_dai_stream_valid(cpu_dai, SNDRV_PCM_STREAM_CAPTURE))
-                               has_capture = 1;
-               }
-
-       } else {
-               struct snd_soc_dai *codec_dai;
+       /* Adapt stream for codec2codec links */
+       cpu_capture  = snd_soc_get_stream_cpu(dai_link, SNDRV_PCM_STREAM_CAPTURE);
+       cpu_playback = snd_soc_get_stream_cpu(dai_link, SNDRV_PCM_STREAM_PLAYBACK);
 
-               /* Adapt stream for codec2codec links */
-               int cpu_capture  = snd_soc_get_stream_cpu(dai_link, SNDRV_PCM_STREAM_CAPTURE);
-               int cpu_playback = snd_soc_get_stream_cpu(dai_link, SNDRV_PCM_STREAM_PLAYBACK);
+       /*
+        * see
+        *      soc.h :: [dai_link->ch_maps Image sample]
+        */
+       for_each_rtd_ch_maps(rtd, i, ch_maps) {
+               cpu_dai   = snd_soc_rtd_to_cpu(rtd,   ch_maps->cpu);
+               codec_dai = snd_soc_rtd_to_codec(rtd, ch_maps->codec);
 
                /*
-                * see
-                *      soc.h :: [dai_link->ch_maps Image sample]
+                * FIXME
+                *
+                * DPCM Codec has been no checked before.
+                * It should be checked, but it breaks compatibility.
+                *
+                * For example there is a case that CPU have loopback capabilities which is used
+                * for tests on boards where the Codec has no capture capabilities. In this case,
+                * Codec capture validation check will be fail, but system should allow capture
+                * capabilities. We have no solution for it today.
                 */
-               for_each_rtd_ch_maps(rtd, i, ch_maps) {
-                       cpu_dai   = snd_soc_rtd_to_cpu(rtd,   ch_maps->cpu);
-                       codec_dai = snd_soc_rtd_to_codec(rtd, ch_maps->codec);
-
-                       if (snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_PLAYBACK) &&
-                           snd_soc_dai_stream_valid(cpu_dai,   cpu_playback))
-                               has_playback = 1;
-                       if (snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_CAPTURE) &&
-                           snd_soc_dai_stream_valid(cpu_dai,   cpu_capture))
-                               has_capture = 1;
-               }
+               if (dai_link->dynamic || dai_link->no_pcm)
+                       codec_dai = dummy_dai;
+
+               if (snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_PLAYBACK) &&
+                   snd_soc_dai_stream_valid(cpu_dai,   cpu_playback))
+                       has_playback = 1;
+               if (snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_CAPTURE) &&
+                   snd_soc_dai_stream_valid(cpu_dai,   cpu_capture))
+                       has_capture = 1;
        }
 
        if (dai_link->playback_only)