[PATCH v3 4/7] ASoC: soc-link: add snd_soc_link_be_hw_params_fixup()

Kuninori Morimoto kuninori.morimoto.gx at renesas.com
Fri May 22 02:14:04 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_be_hw_params_fixup().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx at renesas.com>
---
 include/sound/soc-link.h |  3 +++
 sound/soc/soc-core.c     |  6 +++++-
 sound/soc/soc-dai.c      |  9 ++++-----
 sound/soc/soc-link.c     | 11 +++++++++++
 sound/soc/soc-pcm.c      | 13 +++----------
 5 files changed, 26 insertions(+), 16 deletions(-)

diff --git a/include/sound/soc-link.h b/include/sound/soc-link.h
index 2a81dca945cd..aae72f668de6 100644
--- a/include/sound/soc-link.h
+++ b/include/sound/soc-link.h
@@ -9,6 +9,9 @@
 #define __SOC_LINK_H
 
 int snd_soc_link_init(struct snd_soc_pcm_runtime *rtd);
+int snd_soc_link_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
+				    struct snd_pcm_hw_params *params);
+
 int snd_soc_link_startup(struct snd_pcm_substream *substream);
 void snd_soc_link_shutdown(struct snd_pcm_substream *substream);
 int snd_soc_link_prepare(struct snd_pcm_substream *substream);
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 955e175643d7..e1b65059c0c4 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1656,7 +1656,11 @@ static void soc_check_tplg_fes(struct snd_soc_card *card)
 			dai_link->dpcm_playback = 1;
 			dai_link->dpcm_capture = 1;
 
-			/* override any BE fixups */
+			/*
+			 * override any BE fixups
+			 * see
+			 *	snd_soc_link_be_hw_params_fixup()
+			 */
 			dai_link->be_hw_params_fixup =
 				component->driver->be_hw_params_fixup;
 
diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c
index ce4e1fd1ab79..2c6ac3b0afa5 100644
--- a/sound/soc/soc-dai.c
+++ b/sound/soc/soc-dai.c
@@ -8,6 +8,7 @@
 
 #include <sound/soc.h>
 #include <sound/soc-dai.h>
+#include <sound/soc-link.h>
 
 #define soc_dai_ret(dai, ret) _soc_dai_ret(dai, __func__, ret)
 static inline int _soc_dai_ret(struct snd_soc_dai *dai,
@@ -313,11 +314,9 @@ int snd_soc_dai_hw_params(struct snd_soc_dai *dai,
 	int ret = 0;
 
 	/* perform any topology hw_params fixups before DAI  */
-	if (rtd->dai_link->be_hw_params_fixup) {
-		ret = rtd->dai_link->be_hw_params_fixup(rtd, params);
-		if (ret < 0)
-			goto end;
-	}
+	ret = snd_soc_link_be_hw_params_fixup(rtd, params);
+	if (ret < 0)
+		goto end;
 
 	if (dai->driver->ops &&
 	    dai->driver->ops->hw_params)
diff --git a/sound/soc/soc-link.c b/sound/soc/soc-link.c
index 5ce3e209b1a8..113a4d1b2262 100644
--- a/sound/soc/soc-link.c
+++ b/sound/soc/soc-link.c
@@ -36,6 +36,17 @@ int snd_soc_link_init(struct snd_soc_pcm_runtime *rtd)
 	return soc_link_ret(rtd, ret);
 }
 
+int snd_soc_link_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
+				    struct snd_pcm_hw_params *params)
+{
+	int ret = 0;
+
+	if (rtd->dai_link->be_hw_params_fixup)
+		ret = rtd->dai_link->be_hw_params_fixup(rtd, params);
+
+	return soc_link_ret(rtd, ret);
+}
+
 int snd_soc_link_startup(struct snd_pcm_substream *substream)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 0204a3ecfc8b..80dd3cf6200c 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -2079,16 +2079,9 @@ int dpcm_be_dai_hw_params(struct snd_soc_pcm_runtime *fe, int stream)
 				sizeof(struct snd_pcm_hw_params));
 
 		/* perform any hw_params fixups */
-		if (be->dai_link->be_hw_params_fixup) {
-			ret = be->dai_link->be_hw_params_fixup(be,
-					&dpcm->hw_params);
-			if (ret < 0) {
-				dev_err(be->dev,
-					"ASoC: hw_params BE fixup failed %d\n",
-					ret);
-				goto unwind;
-			}
-		}
+		ret = snd_soc_link_be_hw_params_fixup(be, &dpcm->hw_params);
+		if (ret < 0)
+			goto unwind;
 
 		/* copy the fixed-up hw params for BE dai */
 		memcpy(&be->dpcm[stream].hw_params, &dpcm->hw_params,
-- 
2.17.1



More information about the Alsa-devel mailing list