Unverified Commit a6ff8572 authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown
Browse files

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: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://patch.msgid.link/8734kq9vgq.wl-kuninori.morimoto.gx@renesas.com


Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 0e3dc8e4
Loading
Loading
Loading
Loading
+32 −30
Original line number Diff line number Diff line
@@ -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,24 +2836,9 @@ 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 */
		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);
	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);

	/*
	 * see
@@ -2859,6 +2848,20 @@ static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd,
		cpu_dai	  = snd_soc_rtd_to_cpu(rtd,   ch_maps->cpu);
		codec_dai = snd_soc_rtd_to_codec(rtd, ch_maps->codec);

		/*
		 * 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.
		 */
		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;
@@ -2866,7 +2869,6 @@ static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd,
		    snd_soc_dai_stream_valid(cpu_dai,   cpu_capture))
			has_capture = 1;
	}
	}

	if (dai_link->playback_only)
		has_capture = 0;