From 3989ade2d1e7ffc900e3842dc542b9e4bb3618fe Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Tue, 20 Sep 2022 06:32:16 +0000 Subject: ASoC: soc.h: remove num_cpus/codecs Current rtd has both dai_link pointer (A) and num_cpus/codecs (B). (A) rtd->dai_link = dai_link; (B) rtd->num_cpus = dai_link->num_cpus; (B) rtd->num_codecs = dai_link->num_codecs; But, we can get num_cpus/codecs (B) via dai_link (A). This means we don't need to keep num_cpus/codecs on rtd. This patch removes these. Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/87sfkmv9n3.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- include/sound/soc.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'include/sound') diff --git a/include/sound/soc.h b/include/sound/soc.h index 4351d86eedf6..f5e0c402acb7 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -1078,8 +1078,6 @@ struct snd_soc_pcm_runtime { * asoc_rtd_to_codec() */ struct snd_soc_dai **dais; - unsigned int num_codecs; - unsigned int num_cpus; struct snd_soc_dapm_widget *playback_widget; struct snd_soc_dapm_widget *capture_widget; @@ -1108,7 +1106,7 @@ struct snd_soc_pcm_runtime { }; /* see soc_new_pcm_runtime() */ #define asoc_rtd_to_cpu(rtd, n) (rtd)->dais[n] -#define asoc_rtd_to_codec(rtd, n) (rtd)->dais[n + (rtd)->num_cpus] +#define asoc_rtd_to_codec(rtd, n) (rtd)->dais[n + (rtd)->dai_link->num_cpus] #define asoc_substream_to_rtd(substream) \ (struct snd_soc_pcm_runtime *)snd_pcm_substream_chip(substream) @@ -1118,15 +1116,15 @@ struct snd_soc_pcm_runtime { (i)++) #define for_each_rtd_cpu_dais(rtd, i, dai) \ for ((i) = 0; \ - ((i) < rtd->num_cpus) && ((dai) = asoc_rtd_to_cpu(rtd, i)); \ + ((i) < rtd->dai_link->num_cpus) && ((dai) = asoc_rtd_to_cpu(rtd, i)); \ (i)++) #define for_each_rtd_codec_dais(rtd, i, dai) \ for ((i) = 0; \ - ((i) < rtd->num_codecs) && ((dai) = asoc_rtd_to_codec(rtd, i)); \ + ((i) < rtd->dai_link->num_codecs) && ((dai) = asoc_rtd_to_codec(rtd, i)); \ (i)++) #define for_each_rtd_dais(rtd, i, dai) \ for ((i) = 0; \ - ((i) < (rtd)->num_cpus + (rtd)->num_codecs) && \ + ((i) < (rtd)->dai_link->num_cpus + (rtd)->dai_link->num_codecs) && \ ((dai) = (rtd)->dais[i]); \ (i)++) -- cgit v1.2.3 From a26ec2acb2043a52c41d2b651b30d2df475f4263 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Tue, 20 Sep 2022 06:32:25 +0000 Subject: ASoC: soc.h: use defined number instead of direct number snd_soc_pcm_runtime has dpcm for Playback/Capture, but it is defined directly "2". It should use defined number. struct snd_soc_pcm_runtime { ... => struct snd_soc_dpcm_runtime dpcm[2]; ... } This patch fixup it. Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/87r106v9mv.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- include/sound/soc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/sound') diff --git a/include/sound/soc.h b/include/sound/soc.h index f5e0c402acb7..4adb6236860c 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -1062,7 +1062,7 @@ struct snd_soc_pcm_runtime { unsigned int params_select; /* currently selected param for dai link */ /* Dynamic PCM BE runtime data */ - struct snd_soc_dpcm_runtime dpcm[2]; + struct snd_soc_dpcm_runtime dpcm[SNDRV_PCM_STREAM_LAST + 1]; long pmdown_time; -- cgit v1.2.3 From 3289dc026a8cf5d6469eb49d838bc971f4370f9d Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Tue, 20 Sep 2022 06:32:36 +0000 Subject: ASoC: soc.h: use array instead of playback/capture_widget 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 Link: https://lore.kernel.org/r/87pmfqv9mk.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- include/sound/soc.h | 4 +--- sound/soc/soc-dapm.c | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 11 deletions(-) (limited to 'include/sound') diff --git a/include/sound/soc.h b/include/sound/soc.h index 4adb6236860c..37bbfc8b45cb 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -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 diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index f10133f35c5d..d515e7a78ea8 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -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); } } -- cgit v1.2.3