[PATCH 00/25] ASoC: use helper function and cleanup
Hi Mark
I'm posting about DT schema fixup, but it seems take longer time. This patch-set is 100% independent from it, so I will post it.
struct snd_soc_dai need to have info for playback/capture, but it is using "playback/capture_xxx" or "tx/tx_xxx" or array. This kind of random definition is very difficult to read.
This patch-set add helper functions and each driver use it. And cleanup the definition.
Kuninori Morimoto (25): ASoC: soc-dai.h: add missing snd_soc_dai_set_widget() ASoC: soc-dai.h: add snd_soc_dai_dma_data_set/get() for low level ASoC: soc-dai.h: add snd_soc_dai_tdm_mask_set/get() helper ASoC: soc-dai.h: add snd_soc_dai_get/set_widget_playback/capture() helper ASoC: soc.h: add snd_soc_card_is_instantiated() helper ASoC: hdmi-codec: use helper function ASoC: hda: use helper function ASoC: max: use helper function ASoC: rt: use helper function ASoC: cirrus: use helper function ASoC: spear: use helper function ASoC: sdw-mockup: use helper function ASoC: intel: use helper function ASoC: mediatek: use helper function ASoC: meson: use helper function ASoC: rockchip: use helper function ASoC: sof: use helper function ASoC: tegra: use helper function ASoC: ti: use helper function ASoC: soc-core.c: use helper function ASoC: soc-dapm.c: use helper function ASoC: soc-dai.c: use helper function ASoC: soc-pcm.c: use helper function ASoC: soc-topology.c: use helper function ASoC: soc-dai.h: cleanup Playback/Capture data for snd_soc_dai
include/sound/soc-dai.h | 90 ++++++++------- include/sound/soc.h | 6 + sound/soc/cirrus/ep93xx-ac97.c | 4 +- sound/soc/cirrus/ep93xx-i2s.c | 4 +- sound/soc/codecs/hda.c | 7 +- sound/soc/codecs/hdmi-codec.c | 11 +- sound/soc/codecs/max98373-sdw.c | 5 +- sound/soc/codecs/rt1308-sdw.c | 5 +- sound/soc/codecs/rt1316-sdw.c | 5 +- sound/soc/codecs/rt1318-sdw.c | 5 +- sound/soc/codecs/rt5645.c | 2 +- sound/soc/codecs/rt5665.c | 4 +- sound/soc/codecs/rt5668.c | 4 +- sound/soc/codecs/rt5682-sdw.c | 5 +- sound/soc/codecs/rt5682.c | 4 +- sound/soc/codecs/rt5682s.c | 4 +- sound/soc/codecs/rt700.c | 7 +- sound/soc/codecs/rt711-sdca.c | 7 +- sound/soc/codecs/rt711.c | 7 +- sound/soc/codecs/rt715-sdca.c | 5 +- sound/soc/codecs/rt715.c | 5 +- sound/soc/codecs/sdw-mockup.c | 5 +- sound/soc/intel/atom/sst-atom-controls.c | 9 +- sound/soc/intel/avs/boards/nau8825.c | 5 +- sound/soc/intel/avs/pcm.c | 15 +-- sound/soc/intel/skylake/skl-topology.c | 19 +--- .../soc/mediatek/common/mtk-dsp-sof-common.c | 18 ++- sound/soc/mediatek/mt6797/mt6797-dai-pcm.c | 8 +- sound/soc/mediatek/mt8183/mt8183-dai-pcm.c | 7 +- sound/soc/mediatek/mt8186/mt8186-dai-pcm.c | 7 +- sound/soc/mediatek/mt8192/mt8192-dai-pcm.c | 8 +- sound/soc/mediatek/mt8195/mt8195-dai-pcm.c | 7 +- sound/soc/meson/aiu-fifo-i2s.c | 4 +- sound/soc/meson/aiu-fifo-spdif.c | 2 +- sound/soc/meson/aiu-fifo.c | 21 ++-- sound/soc/meson/axg-tdm-interface.c | 34 +++--- sound/soc/meson/axg-tdmin.c | 2 +- sound/soc/meson/axg-tdmout.c | 2 +- sound/soc/meson/meson-codec-glue.c | 8 +- sound/soc/rockchip/rockchip_i2s_tdm.c | 4 +- sound/soc/rockchip/rockchip_pdm.c | 2 +- sound/soc/rockchip/rockchip_spdif.c | 2 +- sound/soc/soc-core.c | 8 +- sound/soc/soc-dai.c | 13 ++- sound/soc/soc-dapm.c | 26 ++--- sound/soc/soc-pcm.c | 12 +- sound/soc/soc-topology.c | 4 +- sound/soc/sof/topology.c | 104 +++++++----------- sound/soc/spear/spdif_out.c | 3 +- sound/soc/tegra/tegra20_ac97.c | 4 +- sound/soc/tegra/tegra20_i2s.c | 4 +- sound/soc/tegra/tegra20_spdif.c | 3 +- sound/soc/tegra/tegra210_admaif.c | 4 +- sound/soc/tegra/tegra30_i2s.c | 4 +- sound/soc/ti/davinci-i2s.c | 5 +- sound/soc/ti/davinci-mcasp.c | 5 +- sound/soc/ti/davinci-vcif.c | 5 +- 57 files changed, 274 insertions(+), 315 deletions(-)
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Current ASoC has snd_soc_dai_set/get_dma_data() which is assuming struct snd_pcm_substream to get Playback/Capture direction.
But, many drivers want to use it not through snd_pcm_substream. This patch adds more low level snd_soc_dai_dma_data_set/get() for it, and previous functions will be macro for it.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/soc-dai.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h index ea704d92deaa..f27b33dd97bd 100644 --- a/include/sound/soc-dai.h +++ b/include/sound/soc-dai.h @@ -493,18 +493,21 @@ void snd_soc_dai_set_widget(struct snd_soc_dai *dai, int stream, struct snd_soc_ dai->capture_widget = widget; }
-static inline void *snd_soc_dai_get_dma_data(const struct snd_soc_dai *dai, - const struct snd_pcm_substream *ss) +#define snd_soc_dai_dma_data_get_playback(dai) snd_soc_dai_dma_data_get(dai, SNDRV_PCM_STREAM_PLAYBACK) +#define snd_soc_dai_dma_data_get_capture(dai) snd_soc_dai_dma_data_get(dai, SNDRV_PCM_STREAM_CAPTURE) +#define snd_soc_dai_get_dma_data(dai, ss) snd_soc_dai_dma_data_get(dai, ss->stream) +static inline void *snd_soc_dai_dma_data_get(const struct snd_soc_dai *dai, int stream) { - return (ss->stream == SNDRV_PCM_STREAM_PLAYBACK) ? + return (stream == SNDRV_PCM_STREAM_PLAYBACK) ? dai->playback_dma_data : dai->capture_dma_data; }
-static inline void snd_soc_dai_set_dma_data(struct snd_soc_dai *dai, - const struct snd_pcm_substream *ss, - void *data) +#define snd_soc_dai_dma_data_set_playback(dai, data) snd_soc_dai_dma_data_set(dai, SNDRV_PCM_STREAM_PLAYBACK, data) +#define snd_soc_dai_dma_data_set_capture(dai, data) snd_soc_dai_dma_data_set(dai, SNDRV_PCM_STREAM_CAPTURE, data) +#define snd_soc_dai_set_dma_data(dai, ss, data) snd_soc_dai_dma_data_set(dai, ss->stream, data) +static inline void snd_soc_dai_dma_data_set(struct snd_soc_dai *dai, int stream, void *data) { - if (ss->stream == SNDRV_PCM_STREAM_PLAYBACK) + if (stream == SNDRV_PCM_STREAM_PLAYBACK) dai->playback_dma_data = data; else dai->capture_dma_data = data;
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Current ASoC has tx/rx_mask, and is directly accessing to them, but accessing to it via function is nice idea. This patch adds snd_soc_dai_tdm_mask_set/get() for it.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/soc-dai.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h index f27b33dd97bd..9b18e230e5b3 100644 --- a/include/sound/soc-dai.h +++ b/include/sound/soc-dai.h @@ -520,6 +520,23 @@ static inline void snd_soc_dai_init_dma_data(struct snd_soc_dai *dai, dai->capture_dma_data = capture; }
+static inline unsigned int snd_soc_dai_tdm_mask_get(struct snd_soc_dai *dai, int stream) +{ + if (stream == SNDRV_PCM_STREAM_PLAYBACK) + return dai->tx_mask; + else + return dai->rx_mask; +} + +static inline void snd_soc_dai_tdm_mask_set(struct snd_soc_dai *dai, int stream, + unsigned int tdm_mask) +{ + if (stream == SNDRV_PCM_STREAM_PLAYBACK) + dai->tx_mask = tdm_mask; + else + dai->rx_mask = tdm_mask; +} + static inline void snd_soc_dai_set_drvdata(struct snd_soc_dai *dai, void *data) {
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
snd_soc_dai_get_widget() requests SNDRV_PCM_STREAM_PLAYBACK/CAPTURE. This patch adds helper for it.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/soc-dai.h | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h index 9b18e230e5b3..197dc1629708 100644 --- a/include/sound/soc-dai.h +++ b/include/sound/soc-dai.h @@ -477,6 +477,8 @@ snd_soc_dai_get_pcm_stream(const struct snd_soc_dai *dai, int stream) &dai->driver->playback : &dai->driver->capture; }
+#define snd_soc_dai_get_widget_playback(dai) snd_soc_dai_get_widget(dai, SNDRV_PCM_STREAM_PLAYBACK) +#define snd_soc_dai_get_widget_capture(dai) snd_soc_dai_get_widget(dai, SNDRV_PCM_STREAM_CAPTURE) static inline struct snd_soc_dapm_widget *snd_soc_dai_get_widget(struct snd_soc_dai *dai, int stream) { @@ -484,6 +486,8 @@ struct snd_soc_dapm_widget *snd_soc_dai_get_widget(struct snd_soc_dai *dai, int dai->playback_widget : dai->capture_widget; }
+#define snd_soc_dai_set_widget_playback(dai, widget) snd_soc_dai_set_widget(dai, SNDRV_PCM_STREAM_PLAYBACK, widget) +#define snd_soc_dai_set_widget_capture(dai, widget) snd_soc_dai_set_widget(dai, SNDRV_PCM_STREAM_CAPTURE, widget) static inline void snd_soc_dai_set_widget(struct snd_soc_dai *dai, int stream, struct snd_soc_dapm_widget *widget) {
Hi Mark
I'm posting about DT schema fixup, but it seems take longer time. This patch-set is 100% independent from it, so I will post it.
struct snd_soc_dai need to have info for playback/capture, but it is using "playback/capture_xxx" or "tx/tx_xxx" or array. This kind of random definition is very difficult to read.
This patch-set add helper functions and each driver use it. And cleanup the definition.
Posted messages are rejected. It seems too many Cc members are added. I will repost it, again with reduced member.
Thank you for your help !!
Best regards --- Kuninori Morimoto
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Current ASoC has snd_soc_dai_get_widget() (= _get_) but doesn't have _set_ function. This patch adds it.
This patch also cleanup unnecessary line break for _get_ function.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/soc-dai.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h index ea7509672086..ea704d92deaa 100644 --- a/include/sound/soc-dai.h +++ b/include/sound/soc-dai.h @@ -478,13 +478,21 @@ snd_soc_dai_get_pcm_stream(const struct snd_soc_dai *dai, int stream) }
static inline -struct snd_soc_dapm_widget *snd_soc_dai_get_widget( - struct snd_soc_dai *dai, int stream) +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_set_widget(struct snd_soc_dai *dai, int stream, struct snd_soc_dapm_widget *widget) +{ + if (stream == SNDRV_PCM_STREAM_PLAYBACK) + dai->playback_widget = widget; + else + dai->capture_widget = widget; +} + static inline void *snd_soc_dai_get_dma_data(const struct snd_soc_dai *dai, const struct snd_pcm_substream *ss) {
On Fri, Jan 20, 2023 at 06:59:34AM +0000, Kuninori Morimoto wrote:
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Current ASoC has snd_soc_dai_get_widget() (= _get_) but doesn't have _set_ function. This patch adds it.
This patch also cleanup unnecessary line break for _get_ function.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Reviewed-by: Charles Keepax ckeepax@opensource.cirrus.com
Thanks, Charles
participants (2)
-
Charles Keepax
-
Kuninori Morimoto