Skip to content

Commit a6ff857

Browse files
morimotobroonie
authored andcommitted
ASoC: soc-pcm: merge DPCM and non-DPCM validation check
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>
1 parent 0e3dc8e commit a6ff857

1 file changed

Lines changed: 32 additions & 30 deletions

File tree

sound/soc/soc-pcm.c

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2822,7 +2822,11 @@ static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd,
28222822
{
28232823
struct snd_soc_dai_link *dai_link = rtd->dai_link;
28242824
struct snd_soc_dai *cpu_dai;
2825+
struct snd_soc_dai *codec_dai;
28252826
struct snd_soc_dai_link_ch_map *ch_maps;
2827+
struct snd_soc_dai *dummy_dai = snd_soc_find_dai(&snd_soc_dummy_dlc);
2828+
int cpu_capture;
2829+
int cpu_playback;
28262830
int has_playback = 0;
28272831
int has_capture = 0;
28282832
int i;
@@ -2832,40 +2836,38 @@ static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd,
28322836
return -EINVAL;
28332837
}
28342838

2835-
if (dai_link->dynamic || dai_link->no_pcm) {
2836-
2837-
for_each_rtd_ch_maps(rtd, i, ch_maps) {
2838-
cpu_dai = snd_soc_rtd_to_cpu(rtd, ch_maps->cpu);
2839-
2840-
if (snd_soc_dai_stream_valid(cpu_dai, SNDRV_PCM_STREAM_PLAYBACK))
2841-
has_playback = 1;
2842-
2843-
if (snd_soc_dai_stream_valid(cpu_dai, SNDRV_PCM_STREAM_CAPTURE))
2844-
has_capture = 1;
2845-
}
2846-
2847-
} else {
2848-
struct snd_soc_dai *codec_dai;
2839+
/* Adapt stream for codec2codec links */
2840+
cpu_capture = snd_soc_get_stream_cpu(dai_link, SNDRV_PCM_STREAM_CAPTURE);
2841+
cpu_playback = snd_soc_get_stream_cpu(dai_link, SNDRV_PCM_STREAM_PLAYBACK);
28492842

2850-
/* Adapt stream for codec2codec links */
2851-
int cpu_capture = snd_soc_get_stream_cpu(dai_link, SNDRV_PCM_STREAM_CAPTURE);
2852-
int cpu_playback = snd_soc_get_stream_cpu(dai_link, SNDRV_PCM_STREAM_PLAYBACK);
2843+
/*
2844+
* see
2845+
* soc.h :: [dai_link->ch_maps Image sample]
2846+
*/
2847+
for_each_rtd_ch_maps(rtd, i, ch_maps) {
2848+
cpu_dai = snd_soc_rtd_to_cpu(rtd, ch_maps->cpu);
2849+
codec_dai = snd_soc_rtd_to_codec(rtd, ch_maps->codec);
28532850

28542851
/*
2855-
* see
2856-
* soc.h :: [dai_link->ch_maps Image sample]
2852+
* FIXME
2853+
*
2854+
* DPCM Codec has been no checked before.
2855+
* It should be checked, but it breaks compatibility.
2856+
*
2857+
* For example there is a case that CPU have loopback capabilities which is used
2858+
* for tests on boards where the Codec has no capture capabilities. In this case,
2859+
* Codec capture validation check will be fail, but system should allow capture
2860+
* capabilities. We have no solution for it today.
28572861
*/
2858-
for_each_rtd_ch_maps(rtd, i, ch_maps) {
2859-
cpu_dai = snd_soc_rtd_to_cpu(rtd, ch_maps->cpu);
2860-
codec_dai = snd_soc_rtd_to_codec(rtd, ch_maps->codec);
2861-
2862-
if (snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_PLAYBACK) &&
2863-
snd_soc_dai_stream_valid(cpu_dai, cpu_playback))
2864-
has_playback = 1;
2865-
if (snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_CAPTURE) &&
2866-
snd_soc_dai_stream_valid(cpu_dai, cpu_capture))
2867-
has_capture = 1;
2868-
}
2862+
if (dai_link->dynamic || dai_link->no_pcm)
2863+
codec_dai = dummy_dai;
2864+
2865+
if (snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_PLAYBACK) &&
2866+
snd_soc_dai_stream_valid(cpu_dai, cpu_playback))
2867+
has_playback = 1;
2868+
if (snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_CAPTURE) &&
2869+
snd_soc_dai_stream_valid(cpu_dai, cpu_capture))
2870+
has_capture = 1;
28692871
}
28702872

28712873
if (dai_link->playback_only)

0 commit comments

Comments
 (0)