diff mbox series

[v3,07/21] ASoC: soc-pcm.c: cleanup normal connection loop at soc_get_playback_capture() part2

Message ID 87edn0lzix.wl-kuninori.morimoto.gx@renesas.com (mailing list archive)
State New, archived
Headers show
Series ASoC: replace dpcm_playback/capture to playback/capture_only | expand

Commit Message

Kuninori Morimoto May 29, 2023, 1:03 a.m. UTC
soc_get_playback_capture() (A) is handling both DPCM (X) / Normal (Y)
connection.

(A)	static int soc_get_playback_capture(...)
	{
		...
 ^		if (dai_link->dynamic || dai_link->no_pcm) {
(X)			...
 v
 ^		} else {
 |			...
 |			for_each_rtd_codec_dais(rtd, i, codec_dai) {
 |				if (dai_link->num_cpus == 1) {
 |(a)					cpu_dai = ...
(Y)				} else if (dai_link->num_cpus == dai_link->num_codecs) {
 |(b)					cpu_dai = ...
 |				}
 |				...
 |			}
 |			...
 v		}
		...
	}

In Normal connection case (Y), it is checking number of CPU / Codec.
	(a) is for Single CPU case
	(b) is for Multi  CPU case

We can simply merge (a) and (b). Because it is doing
same judgement, same operation.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
---
 sound/soc/soc-pcm.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

Comments

Kuninori Morimoto May 30, 2023, 12:01 a.m. UTC | #1
Hi Mark, Pierre-Louis

> @@ -2795,11 +2795,7 @@ static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd,
>  			SNDRV_PCM_STREAM_CAPTURE : SNDRV_PCM_STREAM_PLAYBACK;
>  
>  		for_each_rtd_codec_dais(rtd, i, codec_dai) {
> -			if (dai_link->num_cpus == 1) {
> -				cpu_dai = asoc_rtd_to_cpu(rtd, 0);
> -			} else if (dai_link->num_cpus == dai_link->num_codecs) {
> -				cpu_dai = asoc_rtd_to_cpu(rtd, i);
> -			}
> +			cpu_dai = asoc_rtd_to_cpu(rtd, i);

Grr
I noticed that this patch is also wrong.
It doesn't care CPU:Codec = 1:N case.
Need v4 patch

Thank you for your help !!

Best regards
---
Kuninori Morimoto
Kuninori Morimoto May 30, 2023, 12:42 a.m. UTC | #2
Hi Mark, again

> > @@ -2795,11 +2795,7 @@ static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd,
> >  			SNDRV_PCM_STREAM_CAPTURE : SNDRV_PCM_STREAM_PLAYBACK;
> >  
> >  		for_each_rtd_codec_dais(rtd, i, codec_dai) {
> > -			if (dai_link->num_cpus == 1) {
> > -				cpu_dai = asoc_rtd_to_cpu(rtd, 0);
> > -			} else if (dai_link->num_cpus == dai_link->num_codecs) {
> > -				cpu_dai = asoc_rtd_to_cpu(rtd, i);
> > -			}
> > +			cpu_dai = asoc_rtd_to_cpu(rtd, i);
> 
> Grr
> I noticed that this patch is also wrong.
> It doesn't care CPU:Codec = 1:N case.
> Need v4 patch

The playable/capturable calculation are similar operation,
thus I had been thinking that it is possible to merge.
But there are many patterns and has difference, moreover complex
(therefor we noticed that lack of DPCM BE Codec check,
but not sure it is lack or intentional).

It seems that my posted patch-set has a high possibility to
contain some new bugs which is difficult to notice.

I'm still thinking that we can merge it and have more simple
and understandable code, but I'm starting to think that it
should more caution.

So, I will post first few small cleanup patches only instead
of v4 patch-set for this time.

Thank you for your help !!

Best regards
---
Kuninori Morimoto
diff mbox series

Patch

diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index b99c0aa98d09..c1ddd3fc71b0 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -2795,11 +2795,7 @@  static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd,
 			SNDRV_PCM_STREAM_CAPTURE : SNDRV_PCM_STREAM_PLAYBACK;
 
 		for_each_rtd_codec_dais(rtd, i, codec_dai) {
-			if (dai_link->num_cpus == 1) {
-				cpu_dai = asoc_rtd_to_cpu(rtd, 0);
-			} else if (dai_link->num_cpus == dai_link->num_codecs) {
-				cpu_dai = asoc_rtd_to_cpu(rtd, i);
-			}
+			cpu_dai = asoc_rtd_to_cpu(rtd, i);
 
 			if (snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_PLAYBACK) &&
 			    snd_soc_dai_stream_valid(cpu_dai,   cpu_playback))