diff mbox series

[09/10] ASoC: soc-pcm: care Multi Codec at soc_dpcm_fe_runtime_update()

Message ID 87y2t7qfi9.wl-kuninori.morimoto.gx@renesas.com (mailing list archive)
State New, archived
Headers show
Series ASoC: soc-pcm cleanup step3 | expand

Commit Message

Kuninori Morimoto Feb. 13, 2020, 4:26 a.m. UTC
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

soc_dpcm_fe_runtime_update() doesn't care Multi Codec now.
We need to care it. This patch fixup it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/soc-pcm.c | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

Comments

Pierre-Louis Bossart Feb. 13, 2020, 4:10 p.m. UTC | #1
On 2/12/20 10:26 PM, Kuninori Morimoto wrote:
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> 
> soc_dpcm_fe_runtime_update() doesn't care Multi Codec now.
> We need to care it. This patch fixup it.

Humm, maybe a stupid question but for my education is there an actual 
case where a front-end dailink uses more that one codec_dai? All the 
examples I see for Intel rely on COMP_DUMMY().

> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
>   sound/soc/soc-pcm.c | 24 ++++++++++++++++++------
>   1 file changed, 18 insertions(+), 6 deletions(-)
> 
> diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
> index 95fe915f26b0..962fe6cb7d3e 100644
> --- a/sound/soc/soc-pcm.c
> +++ b/sound/soc/soc-pcm.c
> @@ -2614,8 +2614,10 @@ static int dpcm_run_old_update(struct snd_soc_pcm_runtime *fe, int stream)
>   
>   static int soc_dpcm_fe_runtime_update(struct snd_soc_pcm_runtime *fe, int new)
>   {
> +	struct snd_soc_dai *codec_dai;
>   	struct snd_soc_dapm_widget_list *list;
>   	int count, paths;
> +	int i;
>   
>   	if (!fe->dai_link->dynamic)
>   		return 0;
> @@ -2629,13 +2631,18 @@ static int soc_dpcm_fe_runtime_update(struct snd_soc_pcm_runtime *fe, int new)
>   		new ? "new" : "old", fe->dai_link->name);
>   
>   	/* skip if FE doesn't have playback capability */
> -	if (!snd_soc_dai_stream_valid(fe->cpu_dai,   SNDRV_PCM_STREAM_PLAYBACK) ||
> -	    !snd_soc_dai_stream_valid(fe->codec_dai, SNDRV_PCM_STREAM_PLAYBACK))
> +	if (!snd_soc_dai_stream_valid(fe->cpu_dai,   SNDRV_PCM_STREAM_PLAYBACK))
>   		goto capture;
> +	for_each_rtd_codec_dai(fe, i, codec_dai)
> +		if (!snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_PLAYBACK))
> +			goto capture;
>   
>   	/* skip if FE isn't currently playing */
> -	if (!fe->cpu_dai->playback_active || !fe->codec_dai->playback_active)
> +	if (!fe->cpu_dai->playback_active)
>   		goto capture;
> +	for_each_rtd_codec_dai(fe, i, codec_dai)
> +		if (!codec_dai->playback_active)
> +			goto capture;
>   
>   	paths = dpcm_path_get(fe, SNDRV_PCM_STREAM_PLAYBACK, &list);
>   	if (paths < 0) {
> @@ -2660,13 +2667,18 @@ static int soc_dpcm_fe_runtime_update(struct snd_soc_pcm_runtime *fe, int new)
>   
>   capture:
>   	/* skip if FE doesn't have capture capability */
> -	if (!snd_soc_dai_stream_valid(fe->cpu_dai,   SNDRV_PCM_STREAM_CAPTURE) ||
> -	    !snd_soc_dai_stream_valid(fe->codec_dai, SNDRV_PCM_STREAM_CAPTURE))
> +	if (!snd_soc_dai_stream_valid(fe->cpu_dai,   SNDRV_PCM_STREAM_CAPTURE))
>   		return 0;
> +	for_each_rtd_codec_dai(fe, i, codec_dai)
> +		if (!snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_CAPTURE))
> +			return 0;
>   
>   	/* skip if FE isn't currently capturing */
> -	if (!fe->cpu_dai->capture_active || !fe->codec_dai->capture_active)
> +	if (!fe->cpu_dai->capture_active)
>   		return 0;
> +	for_each_rtd_codec_dai(fe, i, codec_dai)
> +		if (!codec_dai->capture_active)
> +			return 0;
>   
>   	paths = dpcm_path_get(fe, SNDRV_PCM_STREAM_CAPTURE, &list);
>   	if (paths < 0) {
>
Kuninori Morimoto Feb. 14, 2020, 12:07 a.m. UTC | #2
Hi Pierre-Louis

> > From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> > 
> > soc_dpcm_fe_runtime_update() doesn't care Multi Codec now.
> > We need to care it. This patch fixup it.
> 
> Humm, maybe a stupid question but for my education is there an actual
> case where a front-end dailink uses more that one codec_dai? All the
> examples I see for Intel rely on COMP_DUMMY().

Hmm..? indeed...
We might need it in the future somehow, but not so much so far.
OK, let's skip it this time.
Thank you for pointing it.

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 95fe915f26b0..962fe6cb7d3e 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -2614,8 +2614,10 @@  static int dpcm_run_old_update(struct snd_soc_pcm_runtime *fe, int stream)
 
 static int soc_dpcm_fe_runtime_update(struct snd_soc_pcm_runtime *fe, int new)
 {
+	struct snd_soc_dai *codec_dai;
 	struct snd_soc_dapm_widget_list *list;
 	int count, paths;
+	int i;
 
 	if (!fe->dai_link->dynamic)
 		return 0;
@@ -2629,13 +2631,18 @@  static int soc_dpcm_fe_runtime_update(struct snd_soc_pcm_runtime *fe, int new)
 		new ? "new" : "old", fe->dai_link->name);
 
 	/* skip if FE doesn't have playback capability */
-	if (!snd_soc_dai_stream_valid(fe->cpu_dai,   SNDRV_PCM_STREAM_PLAYBACK) ||
-	    !snd_soc_dai_stream_valid(fe->codec_dai, SNDRV_PCM_STREAM_PLAYBACK))
+	if (!snd_soc_dai_stream_valid(fe->cpu_dai,   SNDRV_PCM_STREAM_PLAYBACK))
 		goto capture;
+	for_each_rtd_codec_dai(fe, i, codec_dai)
+		if (!snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_PLAYBACK))
+			goto capture;
 
 	/* skip if FE isn't currently playing */
-	if (!fe->cpu_dai->playback_active || !fe->codec_dai->playback_active)
+	if (!fe->cpu_dai->playback_active)
 		goto capture;
+	for_each_rtd_codec_dai(fe, i, codec_dai)
+		if (!codec_dai->playback_active)
+			goto capture;
 
 	paths = dpcm_path_get(fe, SNDRV_PCM_STREAM_PLAYBACK, &list);
 	if (paths < 0) {
@@ -2660,13 +2667,18 @@  static int soc_dpcm_fe_runtime_update(struct snd_soc_pcm_runtime *fe, int new)
 
 capture:
 	/* skip if FE doesn't have capture capability */
-	if (!snd_soc_dai_stream_valid(fe->cpu_dai,   SNDRV_PCM_STREAM_CAPTURE) ||
-	    !snd_soc_dai_stream_valid(fe->codec_dai, SNDRV_PCM_STREAM_CAPTURE))
+	if (!snd_soc_dai_stream_valid(fe->cpu_dai,   SNDRV_PCM_STREAM_CAPTURE))
 		return 0;
+	for_each_rtd_codec_dai(fe, i, codec_dai)
+		if (!snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_CAPTURE))
+			return 0;
 
 	/* skip if FE isn't currently capturing */
-	if (!fe->cpu_dai->capture_active || !fe->codec_dai->capture_active)
+	if (!fe->cpu_dai->capture_active)
 		return 0;
+	for_each_rtd_codec_dai(fe, i, codec_dai)
+		if (!codec_dai->capture_active)
+			return 0;
 
 	paths = dpcm_path_get(fe, SNDRV_PCM_STREAM_CAPTURE, &list);
 	if (paths < 0) {