[5/7] ASoC: soc-link: add snd_soc_link_compr_startup()
diff mbox series

Message ID 87zha44u0d.wl-kuninori.morimoto.gx@renesas.com
State New
Headers show
Series
  • ASoC: add soc-link
Related show

Commit Message

Kuninori Morimoto May 19, 2020, 1:02 a.m. UTC
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

dai_link related function should be implemented at soc-link.c.
This patch adds snd_soc_link_compr_startup().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc-link.h |  3 +++
 sound/soc/soc-compress.c | 23 ++++++-----------------
 sound/soc/soc-link.c     | 13 +++++++++++++
 3 files changed, 22 insertions(+), 17 deletions(-)

Comments

Ranjani Sridharan May 19, 2020, 1:47 a.m. UTC | #1
On Tue, 2020-05-19 at 10:02 +0900, Kuninori Morimoto wrote:
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> 
> dai_link related function should be implemented at soc-link.c.
> This patch adds snd_soc_link_compr_startup().
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
>  include/sound/soc-link.h |  3 +++
>  sound/soc/soc-compress.c | 23 ++++++-----------------
>  sound/soc/soc-link.c     | 13 +++++++++++++
>  3 files changed, 22 insertions(+), 17 deletions(-)
> 
> diff --git a/include/sound/soc-link.h b/include/sound/soc-link.h
> index aae72f668de6..c152576cbd87 100644
> --- a/include/sound/soc-link.h
> +++ b/include/sound/soc-link.h
> @@ -20,4 +20,7 @@ int snd_soc_link_hw_params(struct snd_pcm_substream
> *substream,
>  void snd_soc_link_hw_free(struct snd_pcm_substream *substream);
>  int snd_soc_link_trigger(struct snd_pcm_substream *substream, int
> cmd);
>  
> +int snd_soc_link_compr_startup(struct snd_soc_pcm_runtime *rtd,
> +			       struct snd_compr_stream *cstream);
> +
>  #endif /* __SOC_LINK_H */
> diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
> index 62ece729e425..35b0af86325a 100644
> --- a/sound/soc/soc-compress.c
> +++ b/sound/soc/soc-compress.c
> @@ -95,15 +95,9 @@ static int soc_compr_open(struct snd_compr_stream
> *cstream)
>  	if (ret < 0)
>  		goto machine_err;
>  
> -	if (rtd->dai_link->compr_ops && rtd->dai_link->compr_ops-
> >startup) {
> -		ret = rtd->dai_link->compr_ops->startup(cstream);
> -		if (ret < 0) {
> -			dev_err(rtd->dev,
> -				"Compress ASoC: %s startup failed:
> %d\n",
> -				rtd->dai_link->name, ret);
> -			goto machine_err;
> -		}
> -	}
> +	ret = snd_soc_link_compr_startup(rtd, cstream);
> +	if (ret < 0)
> +		goto machine_err;
>  
>  	snd_soc_runtime_activate(rtd, cstream->direction);
>  
> @@ -179,14 +173,9 @@ static int soc_compr_open_fe(struct
> snd_compr_stream *cstream)
>  	if (ret < 0)
>  		goto open_err;
>  
> -	if (fe->dai_link->compr_ops && fe->dai_link->compr_ops-
> >startup) {
> -		ret = fe->dai_link->compr_ops->startup(cstream);
> -		if (ret < 0) {
> -			pr_err("Compress ASoC: %s startup failed:
> %d\n",
> -			       fe->dai_link->name, ret);
> -			goto machine_err;
> -		}
> -	}
> +	ret = snd_soc_link_compr_startup(fe, cstream);
> +	if (ret < 0)
> +		goto machine_err;
>  
>  	dpcm_clear_pending_state(fe, stream);
>  	dpcm_path_put(&list);
> diff --git a/sound/soc/soc-link.c b/sound/soc/soc-link.c
> index a735b3ba2385..dddc4a35a0ac 100644
> --- a/sound/soc/soc-link.c
> +++ b/sound/soc/soc-link.c
> @@ -112,3 +112,16 @@ int snd_soc_link_trigger(struct
> snd_pcm_substream *substream, int cmd)
>  
>  	return soc_link_ret(rtd, ret);
>  }
> +
> +int snd_soc_link_compr_startup(struct snd_soc_pcm_runtime *rtd,
> +			       struct snd_compr_stream *cstream)
Can we do the same think as for pcm substream and remove the rtd param?

Thanks,
Ranjani
Kuninori Morimoto May 19, 2020, 4:18 a.m. UTC | #2
Hi Ranjani

> > From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> > 
> > dai_link related function should be implemented at soc-link.c.
> > This patch adds snd_soc_link_compr_startup().
> > 
> > Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> > ---
(snip)
> > +int snd_soc_link_compr_startup(struct snd_soc_pcm_runtime *rtd,
> > +			       struct snd_compr_stream *cstream)
> Can we do the same think as for pcm substream and remove the rtd param?

Yes, Indeed !
Will update it in v2

Thank you for your help !!

Best regards
---
Kuninori Morimoto

Patch
diff mbox series

diff --git a/include/sound/soc-link.h b/include/sound/soc-link.h
index aae72f668de6..c152576cbd87 100644
--- a/include/sound/soc-link.h
+++ b/include/sound/soc-link.h
@@ -20,4 +20,7 @@  int snd_soc_link_hw_params(struct snd_pcm_substream *substream,
 void snd_soc_link_hw_free(struct snd_pcm_substream *substream);
 int snd_soc_link_trigger(struct snd_pcm_substream *substream, int cmd);
 
+int snd_soc_link_compr_startup(struct snd_soc_pcm_runtime *rtd,
+			       struct snd_compr_stream *cstream);
+
 #endif /* __SOC_LINK_H */
diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
index 62ece729e425..35b0af86325a 100644
--- a/sound/soc/soc-compress.c
+++ b/sound/soc/soc-compress.c
@@ -95,15 +95,9 @@  static int soc_compr_open(struct snd_compr_stream *cstream)
 	if (ret < 0)
 		goto machine_err;
 
-	if (rtd->dai_link->compr_ops && rtd->dai_link->compr_ops->startup) {
-		ret = rtd->dai_link->compr_ops->startup(cstream);
-		if (ret < 0) {
-			dev_err(rtd->dev,
-				"Compress ASoC: %s startup failed: %d\n",
-				rtd->dai_link->name, ret);
-			goto machine_err;
-		}
-	}
+	ret = snd_soc_link_compr_startup(rtd, cstream);
+	if (ret < 0)
+		goto machine_err;
 
 	snd_soc_runtime_activate(rtd, cstream->direction);
 
@@ -179,14 +173,9 @@  static int soc_compr_open_fe(struct snd_compr_stream *cstream)
 	if (ret < 0)
 		goto open_err;
 
-	if (fe->dai_link->compr_ops && fe->dai_link->compr_ops->startup) {
-		ret = fe->dai_link->compr_ops->startup(cstream);
-		if (ret < 0) {
-			pr_err("Compress ASoC: %s startup failed: %d\n",
-			       fe->dai_link->name, ret);
-			goto machine_err;
-		}
-	}
+	ret = snd_soc_link_compr_startup(fe, cstream);
+	if (ret < 0)
+		goto machine_err;
 
 	dpcm_clear_pending_state(fe, stream);
 	dpcm_path_put(&list);
diff --git a/sound/soc/soc-link.c b/sound/soc/soc-link.c
index a735b3ba2385..dddc4a35a0ac 100644
--- a/sound/soc/soc-link.c
+++ b/sound/soc/soc-link.c
@@ -112,3 +112,16 @@  int snd_soc_link_trigger(struct snd_pcm_substream *substream, int cmd)
 
 	return soc_link_ret(rtd, ret);
 }
+
+int snd_soc_link_compr_startup(struct snd_soc_pcm_runtime *rtd,
+			       struct snd_compr_stream *cstream)
+{
+	int ret = 0;
+
+	if (rtd->dai_link->compr_ops &&
+	    rtd->dai_link->compr_ops->startup)
+		ret = rtd->dai_link->compr_ops->startup(cstream);
+
+	return soc_link_ret(rtd, ret);
+}
+EXPORT_SYMBOL_GPL(snd_soc_link_compr_startup);