[PATCH 7/7] ASoC: soc-link: add snd_soc_link_compr_set_params()

Kuninori Morimoto kuninori.morimoto.gx at renesas.com
Tue May 19 03:02:24 CEST 2020


From: Kuninori Morimoto <kuninori.morimoto.gx at renesas.com>

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

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx at renesas.com>
---
 include/sound/soc-link.h |  2 ++
 sound/soc/soc-compress.c | 16 ++++++----------
 sound/soc/soc-link.c     | 13 +++++++++++++
 3 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/include/sound/soc-link.h b/include/sound/soc-link.h
index 83ca7301c91b..f1fb9036335e 100644
--- a/include/sound/soc-link.h
+++ b/include/sound/soc-link.h
@@ -24,5 +24,7 @@ int snd_soc_link_compr_startup(struct snd_soc_pcm_runtime *rtd,
 			       struct snd_compr_stream *cstream);
 void snd_soc_link_compr_shutdown(struct snd_soc_pcm_runtime *rtd,
 				 struct snd_compr_stream *cstream);
+int snd_soc_link_compr_set_params(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 9db7810bbe04..7806bb5b46bd 100644
--- a/sound/soc/soc-compress.c
+++ b/sound/soc/soc-compress.c
@@ -438,11 +438,9 @@ static int soc_compr_set_params(struct snd_compr_stream *cstream,
 	if (ret < 0)
 		goto err;
 
-	if (rtd->dai_link->compr_ops && rtd->dai_link->compr_ops->set_params) {
-		ret = rtd->dai_link->compr_ops->set_params(cstream);
-		if (ret < 0)
-			goto err;
-	}
+	ret = snd_soc_link_compr_set_params(rtd, cstream);
+	if (ret < 0)
+		goto err;
 
 	if (cstream->direction == SND_COMPRESS_PLAYBACK)
 		snd_soc_dapm_stream_event(rtd, SNDRV_PCM_STREAM_PLAYBACK,
@@ -506,11 +504,9 @@ static int soc_compr_set_params_fe(struct snd_compr_stream *cstream,
 	if (ret < 0)
 		goto out;
 
-	if (fe->dai_link->compr_ops && fe->dai_link->compr_ops->set_params) {
-		ret = fe->dai_link->compr_ops->set_params(cstream);
-		if (ret < 0)
-			goto out;
-	}
+	ret = snd_soc_link_compr_set_params(fe, cstream);
+	if (ret < 0)
+		goto out;
 
 	dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_START);
 	fe->dpcm[stream].state = SND_SOC_DPCM_STATE_PREPARE;
diff --git a/sound/soc/soc-link.c b/sound/soc/soc-link.c
index bad719176379..e9b20a9c05e8 100644
--- a/sound/soc/soc-link.c
+++ b/sound/soc/soc-link.c
@@ -134,3 +134,16 @@ void snd_soc_link_compr_shutdown(struct snd_soc_pcm_runtime *rtd,
 		rtd->dai_link->compr_ops->shutdown(cstream);
 }
 EXPORT_SYMBOL_GPL(snd_soc_link_compr_shutdown);
+
+int snd_soc_link_compr_set_params(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->set_params)
+		ret = rtd->dai_link->compr_ops->set_params(cstream);
+
+	return soc_link_ret(rtd, ret);
+}
+EXPORT_SYMBOL_GPL(snd_soc_link_compr_set_params);
-- 
2.17.1



More information about the Alsa-devel mailing list