Skip to contentSkip to conversation

ASoC: mediatek: mt8195: extract SOF common code

PATCH In review Chunxu Li 2 participants 2 messages Jul 15, 2022 – Jul 18, 2022

Subsystems (3)
lore
Share & tools
lore

Chunxu Li

author
#0 lore raw

PATCH v2 1/1 ASoC: mediatek: mt8195: extract SOF common code

The functions related to SOF can be reused in different machine drivers, such as mt8195 or mt8186, so extract the common code to avoid duplication.

Set mtk_soc_card_data which include machine private data and SOF private data as card drvdata, then the difference between machine private can be ignored such as mt8195_mt6359_priv or mt8186_mt6366_priv, at the same time the SOF related code can be reused in different machine drivers.

---
 sound/soc/mediatek/common/Makefile            |   2 +-
 .../soc/mediatek/common/mtk-dsp-sof-common.c  | 196 +++++++++++++++
 .../soc/mediatek/common/mtk-dsp-sof-common.h  |  36 +++
 sound/soc/mediatek/common/mtk-soc-card.h      |  17 ++
 sound/soc/mediatek/mt8195/mt8195-mt6359.c     | 233 ++++--------------
 5 files changed, 301 insertions(+), 183 deletions(-)
 create mode 100644 sound/soc/mediatek/common/mtk-dsp-sof-common.c
 create mode 100644 sound/soc/mediatek/common/mtk-dsp-sof-common.h
 create mode 100644 sound/soc/mediatek/common/mtk-soc-card.h
sound/soc/mediatek/common/Makefile +1 -1
index acbe01e9e928..576deb7f8cce 100644
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 # platform driver
-snd-soc-mtk-common-objs := mtk-afe-platform-driver.o mtk-afe-fe-dai.o
+snd-soc-mtk-common-objs := mtk-afe-platform-driver.o mtk-afe-fe-dai.o mtk-dsp-sof-common.o
 obj-$(CONFIG_SND_SOC_MEDIATEK) += snd-soc-mtk-common.o
 
 obj-$(CONFIG_SND_SOC_MTK_BTCVSD) += mtk-btcvsd.o
sound/soc/mediatek/common/mtk-dsp-sof-common.c new file +196 -0

196 lines not on this page · raw message

sound/soc/mediatek/common/mtk-dsp-sof-common.h new file +36 -0
new file mode 100644
index 000000000000..dd38c4a93574
@@ -0,0 +1,36 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * mtk-dsp-sof-common.h  --  MediaTek dsp sof common definition
+ *
+ * Copyright (c) 2022 MediaTek Inc.
+ * Author: Chunxu Li <[email protected]>
+ */
+
+#ifndef _MTK_DSP_SOF_COMMON_H_
+#define _MTK_DSP_SOF_COMMON_H_
+
+#include <sound/soc.h>
+
+struct sof_conn_stream {
+	const char *normal_link;
+	const char *sof_link;
+	const char *sof_dma;
+	int stream_dir;
+};
+
+struct mtk_sof_priv {
+	const struct sof_conn_stream *conn_streams;
+	int num_streams;
+	int (*sof_dai_link_fixup)(struct snd_soc_pcm_runtime *rtd,
+				  struct snd_pcm_hw_params *params);
+};
+
+int mtk_sof_dai_link_fixup(struct snd_soc_pcm_runtime *rtd,
+			   struct snd_pcm_hw_params *params);
+int mtk_sof_card_probe(struct snd_soc_card *card);
+int mtk_sof_card_late_probe(struct snd_soc_card *card);
+int mtk_sof_dailink_parse_of(struct snd_soc_card *card, struct device_node *np,
+			     const char *propname, struct snd_soc_dai_link *pre_dai_links,
+			     int pre_num_links);
+
+#endif
sound/soc/mediatek/common/mtk-soc-card.h new file +17 -0
new file mode 100644
index 000000000000..eeda79370049
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * mtk-soc-card.h  --  MediaTek soc card data definition
+ *
+ * Copyright (c) 2022 MediaTek Inc.
+ * Author: Chunxu Li <[email protected]>
+ */
+
+#ifndef _MTK_SOC_CARD_H_
+#define _MTK_SOC_CARD_H_
+
+struct mtk_soc_card_data {
+	void *mach_priv;
+	void *sof_priv;
+};
+
+#endif
sound/soc/mediatek/mt8195/mt8195-mt6359.c +51 -182

320 lines not on this page · raw message

Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 9 lines · Chunxu Li

The functions related to SOF can be reused in different machine drivers, such as mt8195 or mt8186, so extract the common code to avoid duplication.

Set mtk_soc_card_data which include machine private data and SOF private data as card drvdata, then the difference between machine private can be ignored such as mt8195_mt6359_priv or mt8186_mt6366_priv, at the same time the SOF related code can be reused in different machine drivers.

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: mediatek: mt8195: extract SOF common code

      commit: 0caf1120c58395108344d5df4e09359b67e95094

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark