OSDN Git Service

ASoC: soc-dai: add snd_soc_pcm_dai_prepare()
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Thu, 23 Apr 2020 23:14:53 +0000 (08:14 +0900)
committerMark Brown <broonie@kernel.org>
Wed, 29 Apr 2020 12:27:37 +0000 (13:27 +0100)
We have 2 type of component functions
snd_soc_dai_xxx()     is focusing to dai itself,
snd_soc_pcm_dai_xxx() is focusing to rtd related dai.

Now we can update snd_soc_dai_prepare() to
snd_soc_pcm_dai_prepare(). This patch do it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-By: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/87wo65ssk2.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
include/sound/soc-dai.h
sound/soc/soc-dai.c
sound/soc/soc-pcm.c

index fd7e203..1b25318 100644 (file)
@@ -154,8 +154,6 @@ int snd_soc_dai_startup(struct snd_soc_dai *dai,
                        struct snd_pcm_substream *substream);
 void snd_soc_dai_shutdown(struct snd_soc_dai *dai,
                          struct snd_pcm_substream *substream);
-int snd_soc_dai_prepare(struct snd_soc_dai *dai,
-                       struct snd_pcm_substream *substream);
 int snd_soc_dai_trigger(struct snd_soc_dai *dai,
                        struct snd_pcm_substream *substream, int cmd);
 int snd_soc_dai_bespoke_trigger(struct snd_soc_dai *dai,
@@ -171,6 +169,7 @@ int snd_soc_dai_compress_new(struct snd_soc_dai *dai,
 bool snd_soc_dai_stream_valid(struct snd_soc_dai *dai, int stream);
 
 int snd_soc_pcm_dai_new(struct snd_soc_pcm_runtime *rtd);
+int snd_soc_pcm_dai_prepare(struct snd_pcm_substream *substream);
 
 struct snd_soc_dai_ops {
        /*
index 1b45e6e..1a9cfdc 100644 (file)
@@ -354,18 +354,6 @@ void snd_soc_dai_shutdown(struct snd_soc_dai *dai,
                dai->driver->ops->shutdown(substream, dai);
 }
 
-int snd_soc_dai_prepare(struct snd_soc_dai *dai,
-                       struct snd_pcm_substream *substream)
-{
-       int ret = 0;
-
-       if (dai->driver->ops &&
-           dai->driver->ops->prepare)
-               ret = dai->driver->ops->prepare(substream, dai);
-
-       return soc_dai_ret(dai, ret);
-}
-
 int snd_soc_dai_trigger(struct snd_soc_dai *dai,
                        struct snd_pcm_substream *substream,
                        int cmd)
@@ -461,3 +449,21 @@ int snd_soc_pcm_dai_new(struct snd_soc_pcm_runtime *rtd)
 
        return 0;
 }
+
+int snd_soc_pcm_dai_prepare(struct snd_pcm_substream *substream)
+{
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_dai *dai;
+       int i, ret;
+
+       for_each_rtd_dais(rtd, i, dai) {
+               if (dai->driver->ops &&
+                   dai->driver->ops->prepare) {
+                       ret = dai->driver->ops->prepare(substream, dai);
+                       if (ret < 0)
+                               return soc_dai_ret(dai, ret);
+               }
+       }
+
+       return 0;
+}
index 77a680d..f7b3dca 100644 (file)
@@ -950,13 +950,10 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream)
                }
        }
 
-       for_each_rtd_dais(rtd, i, dai) {
-               ret = snd_soc_dai_prepare(dai, substream);
-               if (ret < 0) {
-                       dev_err(dai->dev,
-                               "ASoC: DAI prepare error: %d\n", ret);
-                       goto out;
-               }
+       ret = snd_soc_pcm_dai_prepare(substream);
+       if (ret < 0) {
+               dev_err(rtd->dev, "ASoC: DAI prepare error: %d\n", ret);
+               goto out;
        }
 
        /* cancel any delayed stream shutdown that is pending */