ASoC: soc-link: add snd_soc_link_be_hw_params_fixup()
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Mon, 25 May 2020 00:57:36 +0000 (09:57 +0900)
committerMark Brown <broonie@kernel.org>
Mon, 25 May 2020 13:22:11 +0000 (14:22 +0100)
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@renesas.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/87wo503k73.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
include/sound/soc-link.h
sound/soc/soc-core.c
sound/soc/soc-dai.c
sound/soc/soc-link.c
sound/soc/soc-pcm.c

index 2a81dca945cdb860320f092562bc306c80acfefe..aae72f668de647581dd8ce8184861e99a50f1db8 100644 (file)
@@ -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);
index 955e175643d73d25e407e251175155dede627c37..e1b65059c0c42a69a2d51ba07a6a6235dd712b6d 100644 (file)
@@ -1656,7 +1656,11 @@ match:
                        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;
 
index ce4e1fd1ab79a789a1b7b04e48c6212e6c472644..2c6ac3b0afa53ed6097c1739ec47696b9f6308a5 100644 (file)
@@ -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)
index 5ce3e209b1a84dec754d865ad73ccc5f0091fda5..113a4d1b2262235b6c462734fa3c7a7739f5719b 100644 (file)
@@ -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;
index 0204a3ecfc8b2fc005b5084a320d2cccc7a2457b..80dd3cf6200c1ee29e54a52b475812595c19cf5f 100644 (file)
@@ -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,