diff mbox series

[4/8] ASoC: soc-pcm: add soc_pcm_care_symmetry()

Message ID 87o8g2qqaw.wl-kuninori.morimoto.gx@renesas.com (mailing list archive)
State Superseded
Headers show
Series ASoC: soc-pcm: cleanup each functions | expand

Commit Message

Kuninori Morimoto March 2, 2021, 1:48 a.m. UTC
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Current soc-pcm has soc_pcm_has_symmetry() and using it as

	if (soc_pcm_has_symmetry(substream))
		substream->runtime->hw.info |= SNDRV_PCM_INFO_JOINT_DUPLEX;

We want to share same operation as same function.
This patch adds soc_pcm_care_symmetry() and share the code.

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

Comments

Mark Brown March 2, 2021, 1:10 p.m. UTC | #1
On Tue, Mar 02, 2021 at 10:48:07AM +0900, Kuninori Morimoto wrote:

> -static bool soc_pcm_has_symmetry(struct snd_pcm_substream *substream)
> +static void soc_pcm_care_symmetry(struct snd_pcm_substream *substream)
>  {
>  	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
>  	struct snd_soc_dai_link *link = rtd->dai_link;
> @@ -423,7 +423,8 @@ static bool soc_pcm_has_symmetry(struct snd_pcm_substream *substream)
>  			dai->driver->symmetric_channels ||
>  			dai->driver->symmetric_sample_bits;
>  
> -	return symmetry;
> +	if (symmetry)
> +		substream->runtime->hw.info |= SNDRV_PCM_INFO_JOINT_DUPLEX;

The idea makes sense but I'm not sure about the name here - perhaps
soc_pcm_update_symmetry() might work better?  It's not super clear but
does look more natural.

>  }
>  
>  static void soc_pcm_set_msb(struct snd_pcm_substream *substream, int bits)
> @@ -735,8 +736,7 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
>  	/* Check that the codec and cpu DAIs are compatible */
>  	soc_pcm_init_runtime_hw(substream);
>  
> -	if (soc_pcm_has_symmetry(substream))
> -		runtime->hw.info |= SNDRV_PCM_INFO_JOINT_DUPLEX;
> +	soc_pcm_care_symmetry(substream);
>  
>  	ret = -EINVAL;
>  	if (!runtime->hw.rates) {
> @@ -1681,8 +1681,7 @@ static int dpcm_apply_symmetry(struct snd_pcm_substream *fe_substream,
>  	int i;
>  
>  	/* apply symmetry for FE */
> -	if (soc_pcm_has_symmetry(fe_substream))
> -		fe_substream->runtime->hw.info |= SNDRV_PCM_INFO_JOINT_DUPLEX;
> +	soc_pcm_care_symmetry(fe_substream);
>  
>  	for_each_rtd_cpu_dais (fe, i, fe_cpu_dai) {
>  		/* Symmetry only applies if we've got an active stream. */
> @@ -1707,8 +1706,7 @@ static int dpcm_apply_symmetry(struct snd_pcm_substream *fe_substream,
>  		if (rtd->dai_link->be_hw_params_fixup)
>  			continue;
>  
> -		if (soc_pcm_has_symmetry(be_substream))
> -			be_substream->runtime->hw.info |= SNDRV_PCM_INFO_JOINT_DUPLEX;
> +		soc_pcm_care_symmetry(be_substream);
>  
>  		/* Symmetry only applies if we've got an active stream. */
>  		for_each_rtd_dais(rtd, i, dai) {
> -- 
> 2.25.1
>
Kuninori Morimoto March 4, 2021, 10:06 p.m. UTC | #2
Hi Mark

> > -static bool soc_pcm_has_symmetry(struct snd_pcm_substream *substream)
> > +static void soc_pcm_care_symmetry(struct snd_pcm_substream *substream)
> >  {
> >  	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
> >  	struct snd_soc_dai_link *link = rtd->dai_link;
> > @@ -423,7 +423,8 @@ static bool soc_pcm_has_symmetry(struct snd_pcm_substream *substream)
> >  			dai->driver->symmetric_channels ||
> >  			dai->driver->symmetric_sample_bits;
> >  
> > -	return symmetry;
> > +	if (symmetry)
> > +		substream->runtime->hw.info |= SNDRV_PCM_INFO_JOINT_DUPLEX;
> 
> The idea makes sense but I'm not sure about the name here - perhaps
> soc_pcm_update_symmetry() might work better?  It's not super clear but
> does look more natural.

Thank for your feedback.
Make sense, will update today

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 de31eb7fbec9..76c7f04cfd1a 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -406,7 +406,7 @@  static int soc_pcm_params_symmetry(struct snd_pcm_substream *substream,
 	return 0;
 }
 
-static bool soc_pcm_has_symmetry(struct snd_pcm_substream *substream)
+static void soc_pcm_care_symmetry(struct snd_pcm_substream *substream)
 {
 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
 	struct snd_soc_dai_link *link = rtd->dai_link;
@@ -423,7 +423,8 @@  static bool soc_pcm_has_symmetry(struct snd_pcm_substream *substream)
 			dai->driver->symmetric_channels ||
 			dai->driver->symmetric_sample_bits;
 
-	return symmetry;
+	if (symmetry)
+		substream->runtime->hw.info |= SNDRV_PCM_INFO_JOINT_DUPLEX;
 }
 
 static void soc_pcm_set_msb(struct snd_pcm_substream *substream, int bits)
@@ -735,8 +736,7 @@  static int soc_pcm_open(struct snd_pcm_substream *substream)
 	/* Check that the codec and cpu DAIs are compatible */
 	soc_pcm_init_runtime_hw(substream);
 
-	if (soc_pcm_has_symmetry(substream))
-		runtime->hw.info |= SNDRV_PCM_INFO_JOINT_DUPLEX;
+	soc_pcm_care_symmetry(substream);
 
 	ret = -EINVAL;
 	if (!runtime->hw.rates) {
@@ -1681,8 +1681,7 @@  static int dpcm_apply_symmetry(struct snd_pcm_substream *fe_substream,
 	int i;
 
 	/* apply symmetry for FE */
-	if (soc_pcm_has_symmetry(fe_substream))
-		fe_substream->runtime->hw.info |= SNDRV_PCM_INFO_JOINT_DUPLEX;
+	soc_pcm_care_symmetry(fe_substream);
 
 	for_each_rtd_cpu_dais (fe, i, fe_cpu_dai) {
 		/* Symmetry only applies if we've got an active stream. */
@@ -1707,8 +1706,7 @@  static int dpcm_apply_symmetry(struct snd_pcm_substream *fe_substream,
 		if (rtd->dai_link->be_hw_params_fixup)
 			continue;
 
-		if (soc_pcm_has_symmetry(be_substream))
-			be_substream->runtime->hw.info |= SNDRV_PCM_INFO_JOINT_DUPLEX;
+		soc_pcm_care_symmetry(be_substream);
 
 		/* Symmetry only applies if we've got an active stream. */
 		for_each_rtd_dais(rtd, i, dai) {