ASoC: soc.h: use array instead of playback/capture_widget
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tue, 20 Sep 2022 06:32:36 +0000 (06:32 +0000)
committerMark Brown <broonie@kernel.org>
Tue, 20 Sep 2022 11:19:32 +0000 (12:19 +0100)
snd_soc_pcm_runtime has playback/capture_widget for Codec2Coddec.
The naming is unclear.
This patch names it as c2c_widget and uses array.

struct snd_soc_pcm_runtime {
...
=> struct snd_soc_dapm_widget *playback_widget;
=> struct snd_soc_dapm_widget *capture_widget;
...
}

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

index 4adb6236860c6a6dcbc0e428ce0c4ea9da43df5b..37bbfc8b45cb28b9033c823a1db64565e320d4c1 100644 (file)
@@ -1063,6 +1063,7 @@ struct snd_soc_pcm_runtime {
 
        /* Dynamic PCM BE runtime data */
        struct snd_soc_dpcm_runtime dpcm[SNDRV_PCM_STREAM_LAST + 1];
+       struct snd_soc_dapm_widget *c2c_widget[SNDRV_PCM_STREAM_LAST + 1];
 
        long pmdown_time;
 
@@ -1079,9 +1080,6 @@ struct snd_soc_pcm_runtime {
         */
        struct snd_soc_dai **dais;
 
-       struct snd_soc_dapm_widget *playback_widget;
-       struct snd_soc_dapm_widget *capture_widget;
-
        struct delayed_work delayed_work;
        void (*close_delayed_work_func)(struct snd_soc_pcm_runtime *rtd);
 #ifdef CONFIG_DEBUG_FS
index f10133f35c5d5499fd5c64c581ddee1630162f9b..d515e7a78ea86892b543a4dc3c46ffe0dea1bef2 100644 (file)
@@ -4361,6 +4361,7 @@ static void dapm_connect_dai_pair(struct snd_soc_card *card,
        struct snd_soc_dapm_widget *dai, *codec, *playback_cpu, *capture_cpu;
        struct snd_pcm_substream *substream;
        struct snd_pcm_str *streams = rtd->pcm->streams;
+       int stream;
 
        if (dai_link->params) {
                playback_cpu = cpu_dai->capture_widget;
@@ -4371,37 +4372,39 @@ static void dapm_connect_dai_pair(struct snd_soc_card *card,
        }
 
        /* connect BE DAI playback if widgets are valid */
+       stream = SNDRV_PCM_STREAM_PLAYBACK;
        codec = codec_dai->playback_widget;
 
        if (playback_cpu && codec) {
-               if (dai_link->params && !rtd->playback_widget) {
-                       substream = streams[SNDRV_PCM_STREAM_PLAYBACK].substream;
+               if (dai_link->params && !rtd->c2c_widget[stream]) {
+                       substream = streams[stream].substream;
                        dai = snd_soc_dapm_new_dai(card, substream, "playback");
                        if (IS_ERR(dai))
                                goto capture;
-                       rtd->playback_widget = dai;
+                       rtd->c2c_widget[stream] = dai;
                }
 
                dapm_connect_dai_routes(&card->dapm, cpu_dai, playback_cpu,
-                                       rtd->playback_widget,
+                                       rtd->c2c_widget[stream],
                                        codec_dai, codec);
        }
 
 capture:
        /* connect BE DAI capture if widgets are valid */
+       stream = SNDRV_PCM_STREAM_CAPTURE;
        codec = codec_dai->capture_widget;
 
        if (codec && capture_cpu) {
-               if (dai_link->params && !rtd->capture_widget) {
-                       substream = streams[SNDRV_PCM_STREAM_CAPTURE].substream;
+               if (dai_link->params && !rtd->c2c_widget[stream]) {
+                       substream = streams[stream].substream;
                        dai = snd_soc_dapm_new_dai(card, substream, "capture");
                        if (IS_ERR(dai))
                                return;
-                       rtd->capture_widget = dai;
+                       rtd->c2c_widget[stream] = dai;
                }
 
                dapm_connect_dai_routes(&card->dapm, codec_dai, codec,
-                                       rtd->capture_widget,
+                                       rtd->c2c_widget[stream],
                                        cpu_dai, capture_cpu);
        }
 }