ASoC: add snd_soc_get_stream_cpu()
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Thu, 1 Jun 2023 00:42:49 +0000 (00:42 +0000)
committerMark Brown <broonie@kernel.org>
Tue, 6 Jun 2023 15:57:31 +0000 (16:57 +0100)
We are using get_stream_cpu() to get CPU stream which cares
Codec2Codec. But it is static function for now, and we want to use it
from other files. This patch makes it global function.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87fs7cj9mf.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
include/sound/soc.h
sound/soc/soc-core.c
sound/soc/soc-dapm.c
sound/soc/soc-pcm.c

index 888b2323784051adbdf5586dfb0676ea958675e2..10e4ea0664af4610622d011c29c6ea57fd5fcafa 100644 (file)
@@ -1291,6 +1291,7 @@ unsigned int snd_soc_daifmt_parse_clock_provider_raw(struct device_node *np,
        snd_soc_daifmt_clock_provider_from_bitmap(                      \
                snd_soc_daifmt_parse_clock_provider_as_bitmap(np, prefix))
 
+int snd_soc_get_stream_cpu(struct snd_soc_dai_link *dai_link, int stream);
 int snd_soc_get_dai_id(struct device_node *ep);
 int snd_soc_get_dai_name(const struct of_phandle_args *args,
                         const char **dai_name);
index b48efc3a08d2614eee452518eca1f72033d4e3a3..e8308926bd981f76a9c749ea9bc7198186568c02 100644 (file)
@@ -3196,6 +3196,40 @@ unsigned int snd_soc_daifmt_parse_clock_provider_raw(struct device_node *np,
 }
 EXPORT_SYMBOL_GPL(snd_soc_daifmt_parse_clock_provider_raw);
 
+int snd_soc_get_stream_cpu(struct snd_soc_dai_link *dai_link, int stream)
+{
+       /*
+        * [Normal]
+        *
+        * Playback
+        *      CPU  : SNDRV_PCM_STREAM_PLAYBACK
+        *      Codec: SNDRV_PCM_STREAM_PLAYBACK
+        *
+        * Capture
+        *      CPU  : SNDRV_PCM_STREAM_CAPTURE
+        *      Codec: SNDRV_PCM_STREAM_CAPTURE
+        */
+       if (!dai_link->c2c_params)
+               return stream;
+
+       /*
+        * [Codec2Codec]
+        *
+        * Playback
+        *      CPU  : SNDRV_PCM_STREAM_CAPTURE
+        *      Codec: SNDRV_PCM_STREAM_PLAYBACK
+        *
+        * Capture
+        *      CPU  : SNDRV_PCM_STREAM_PLAYBACK
+        *      Codec: SNDRV_PCM_STREAM_CAPTURE
+        */
+       if (stream == SNDRV_PCM_STREAM_CAPTURE)
+               return SNDRV_PCM_STREAM_PLAYBACK;
+
+       return SNDRV_PCM_STREAM_CAPTURE;
+}
+EXPORT_SYMBOL_GPL(snd_soc_get_stream_cpu);
+
 int snd_soc_get_dai_id(struct device_node *ep)
 {
        struct snd_soc_component *component;
index c65cc374bb3faef1d34ef54d0fcbd85859af654d..b7b31d4e8ae8017a42c3554a8d72145bd7c0677f 100644 (file)
@@ -4338,39 +4338,6 @@ static void dapm_connect_dai_routes(struct snd_soc_dapm_context *dapm,
        snd_soc_dapm_add_path(dapm, src, sink, NULL, NULL);
 }
 
-static int get_stream_cpu(struct snd_soc_dai_link *dai_link, int stream)
-{
-       /*
-        * [Normal]
-        *
-        * Playback
-        *      CPU  : SNDRV_PCM_STREAM_PLAYBACK
-        *      Codec: SNDRV_PCM_STREAM_PLAYBACK
-        *
-        * Playback
-        *      CPU  : SNDRV_PCM_STREAM_CAPTURE
-        *      Codec: SNDRV_PCM_STREAM_CAPTURE
-        */
-       if (!dai_link->c2c_params)
-               return stream;
-
-       /*
-        * [Codec2Codec]
-        *
-        * Playback
-        *      CPU  : SNDRV_PCM_STREAM_CAPTURE
-        *      Codec: SNDRV_PCM_STREAM_PLAYBACK
-        *
-        * Capture
-        *      CPU  : SNDRV_PCM_STREAM_PLAYBACK
-        *      Codec: SNDRV_PCM_STREAM_CAPTURE
-        */
-       if (stream == SNDRV_PCM_STREAM_CAPTURE)
-               return SNDRV_PCM_STREAM_PLAYBACK;
-
-       return SNDRV_PCM_STREAM_CAPTURE;
-}
-
 static void dapm_connect_dai_pair(struct snd_soc_card *card,
                                  struct snd_soc_pcm_runtime *rtd,
                                  struct snd_soc_dai *codec_dai,
@@ -4388,7 +4355,7 @@ static void dapm_connect_dai_pair(struct snd_soc_card *card,
        for_each_pcm_streams(stream) {
                int stream_cpu, stream_codec;
 
-               stream_cpu      = get_stream_cpu(dai_link, stream);
+               stream_cpu      = snd_soc_get_stream_cpu(dai_link, stream);
                stream_codec    = stream;
 
                /* connect BE DAI playback if widgets are valid */
index fc0817dd0d8335dfb9f6555710cebbf227409c3b..799865a6eb561143a09b670da1de9c7d1372582d 100644 (file)
@@ -2781,10 +2781,8 @@ static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd,
                struct snd_soc_dai *codec_dai;
 
                /* Adapt stream for codec2codec links */
-               int cpu_capture = dai_link->c2c_params ?
-                       SNDRV_PCM_STREAM_PLAYBACK : SNDRV_PCM_STREAM_CAPTURE;
-               int cpu_playback = dai_link->c2c_params ?
-                       SNDRV_PCM_STREAM_CAPTURE : SNDRV_PCM_STREAM_PLAYBACK;
+               int cpu_capture  = snd_soc_get_stream_cpu(dai_link, SNDRV_PCM_STREAM_CAPTURE);
+               int cpu_playback = snd_soc_get_stream_cpu(dai_link, SNDRV_PCM_STREAM_PLAYBACK);
 
                for_each_rtd_codec_dais(rtd, i, codec_dai) {
                        if (dai_link->num_cpus == 1) {