ASoC: soc-pcm: add snd_soc_dai_get_widget()
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Wed, 19 Feb 2020 06:56:41 +0000 (15:56 +0900)
committerMark Brown <broonie@kernel.org>
Mon, 24 Feb 2020 21:18:30 +0000 (21:18 +0000)
soc-pcm.c has dai_get_widget(), but it can be more generic.
This patch renames it to snd_soc_dai_get_widget(), and use it.

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

index c1089194ddf167a8f61c2db6c6862a351915a7e0..92c382690930e460089d9937d88a90032e9783c2 100644 (file)
@@ -359,6 +359,14 @@ snd_soc_dai_get_pcm_stream(const struct snd_soc_dai *dai, int stream)
                &dai->driver->playback : &dai->driver->capture;
 }
 
+static inline
+struct snd_soc_dapm_widget *snd_soc_dai_get_widget(
+       struct snd_soc_dai *dai, int stream)
+{
+       return (stream == SNDRV_PCM_STREAM_PLAYBACK) ?
+               dai->playback_widget : dai->capture_widget;
+}
+
 static inline void *snd_soc_dai_get_dma_data(const struct snd_soc_dai *dai,
                                             const struct snd_pcm_substream *ss)
 {
index b99509675d29a270437833cd552cb5b850c15900..05a9677c5a53f2181d46e04bab67888921bb2635 100644 (file)
@@ -112,10 +112,7 @@ static void skl_set_suspend_active(struct snd_pcm_substream *substream,
        struct snd_soc_dapm_widget *w;
        struct skl_dev *skl = bus_to_skl(bus);
 
-       if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-               w = dai->playback_widget;
-       else
-               w = dai->capture_widget;
+       w = snd_soc_dai_get_widget(dai, substream->stream);
 
        if (w->ignore_suspend && enable)
                skl->supend_active++;
@@ -475,10 +472,7 @@ static int skl_pcm_trigger(struct snd_pcm_substream *substream, int cmd,
        if (!mconfig)
                return -EIO;
 
-       if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-               w = dai->playback_widget;
-       else
-               w = dai->capture_widget;
+       w = snd_soc_dai_get_widget(dai, substream->stream);
 
        switch (cmd) {
        case SNDRV_PCM_TRIGGER_RESUME:
index 69eff234b26fd208efa50b3ba84198f9fe3c8fe5..f2e6788654803b02d83119c732c11d6fc94efbd7 100644 (file)
@@ -2620,10 +2620,7 @@ static int dapm_update_dai_unlocked(struct snd_pcm_substream *substream,
        struct snd_soc_dapm_widget *w;
        int ret;
 
-       if (dir == SNDRV_PCM_STREAM_PLAYBACK)
-               w = dai->playback_widget;
-       else
-               w = dai->capture_widget;
+       w = snd_soc_dai_get_widget(dai, dir);
 
        if (!w)
                return 0;
@@ -4389,10 +4386,7 @@ static void soc_dapm_dai_stream_event(struct snd_soc_dai *dai, int stream,
        struct snd_soc_dapm_widget *w;
        unsigned int ep;
 
-       if (stream == SNDRV_PCM_STREAM_PLAYBACK)
-               w = dai->playback_widget;
-       else
-               w = dai->capture_widget;
+       w = snd_soc_dai_get_widget(dai, stream);
 
        if (w) {
                dapm_mark_dirty(w, "stream event");
index 6f56526bbb26226a082be8d2f7e8fd8a303dd282..e183fabc5b6f2e31133946d882b14a9bb9e8aee2 100644 (file)
@@ -82,15 +82,6 @@ static int soc_rtd_trigger(struct snd_soc_pcm_runtime *rtd,
        return 0;
 }
 
-static inline
-struct snd_soc_dapm_widget *dai_get_widget(struct snd_soc_dai *dai, int stream)
-{
-       if (stream == SNDRV_PCM_STREAM_PLAYBACK)
-               return dai->playback_widget;
-       else
-               return dai->capture_widget;
-}
-
 static void snd_soc_runtime_action(struct snd_soc_pcm_runtime *rtd,
                                   int stream, int action)
 {
@@ -1242,7 +1233,7 @@ static struct snd_soc_pcm_runtime *dpcm_get_be(struct snd_soc_card *card,
                if (!be->dai_link->no_pcm)
                        continue;
 
-               w = dai_get_widget(be->cpu_dai, stream);
+               w = snd_soc_dai_get_widget(be->cpu_dai, stream);
 
                dev_dbg(card->dev, "ASoC: try BE : %s\n",
                        w ? w->name : "(not set)");
@@ -1251,7 +1242,7 @@ static struct snd_soc_pcm_runtime *dpcm_get_be(struct snd_soc_card *card,
                        return be;
 
                for_each_rtd_codec_dai(be, i, dai) {
-                       w = dai_get_widget(dai, stream);
+                       w = snd_soc_dai_get_widget(dai, stream);
 
                        if (w == widget)
                                return be;
@@ -1326,7 +1317,7 @@ static int dpcm_prune_paths(struct snd_soc_pcm_runtime *fe, int stream,
                unsigned int i;
 
                /* is there a valid CPU DAI widget for this BE */
-               widget = dai_get_widget(dpcm->be->cpu_dai, stream);
+               widget = snd_soc_dai_get_widget(dpcm->be->cpu_dai, stream);
 
                /* prune the BE if it's no longer in our active list */
                if (widget && widget_in_list(list, widget))
@@ -1335,7 +1326,7 @@ static int dpcm_prune_paths(struct snd_soc_pcm_runtime *fe, int stream,
                /* is there a valid CODEC DAI widget for this BE */
                do_prune = 1;
                for_each_rtd_codec_dai(dpcm->be, i, dai) {
-                       widget = dai_get_widget(dai, stream);
+                       widget = snd_soc_dai_get_widget(dai, stream);
 
                        /* prune the BE if it's no longer in our active list */
                        if (widget && widget_in_list(list, widget))