]> git.baikalelectronics.ru Git - kernel.git/commitdiff
ASoC: mediatek: mt8186: add mt8186-mt6366 common driver
authorJiaxin Yu <jiaxin.yu@mediatek.com>
Mon, 18 Jul 2022 16:21:59 +0000 (00:21 +0800)
committerMark Brown <broonie@kernel.org>
Wed, 20 Jul 2022 16:42:25 +0000 (17:42 +0100)
Add mt8186-mt6366 common driver for mt8186 series machine.

Signed-off-by: Jiaxin Yu <jiaxin.yu@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/20220718162204.26238-4-jiaxin.yu@mediatek.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/mediatek/mt8186/Makefile
sound/soc/mediatek/mt8186/mt8186-mt6366-common.c [new file with mode: 0644]
sound/soc/mediatek/mt8186/mt8186-mt6366-common.h [new file with mode: 0644]

index 7626bb3499dd1514b84eecd9af782e3f0f95d842..bdca1a3b3ff0a16ef228d4d71b63a6e09ee8c512 100644 (file)
@@ -15,5 +15,6 @@ snd-soc-mt8186-afe-objs := \
        mt8186-dai-hostless.o \
        mt8186-dai-tdm.o \
        mt8186-misc-control.o \
+       mt8186-mt6366-common.o
 
 obj-$(CONFIG_SND_SOC_MT8186) += snd-soc-mt8186-afe.o
diff --git a/sound/soc/mediatek/mt8186/mt8186-mt6366-common.c b/sound/soc/mediatek/mt8186/mt8186-mt6366-common.c
new file mode 100644 (file)
index 0000000..4e66603
--- /dev/null
@@ -0,0 +1,57 @@
+// SPDX-License-Identifier: GPL-2.0
+//
+// mt8186-mt6366-common.c
+//     --  MT8186 MT6366 ALSA common driver
+//
+// Copyright (c) 2022 MediaTek Inc.
+// Author: Jiaxin Yu <jiaxin.yu@mediatek.com>
+//
+#include <sound/soc.h>
+
+#include "../../codecs/mt6358.h"
+#include "../common/mtk-afe-platform-driver.h"
+#include "mt8186-afe-common.h"
+#include "mt8186-mt6366-common.h"
+
+int mt8186_mt6366_init(struct snd_soc_pcm_runtime *rtd)
+{
+       struct snd_soc_component *cmpnt_afe =
+               snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
+       struct snd_soc_component *cmpnt_codec =
+               asoc_rtd_to_codec(rtd, 0)->component;
+       struct mtk_base_afe *afe = snd_soc_component_get_drvdata(cmpnt_afe);
+       struct mt8186_afe_private *afe_priv = afe->platform_priv;
+       struct snd_soc_dapm_context *dapm = &rtd->card->dapm;
+       int ret;
+
+       /* set mtkaif protocol */
+       mt6358_set_mtkaif_protocol(cmpnt_codec,
+                                  MT6358_MTKAIF_PROTOCOL_1);
+       afe_priv->mtkaif_protocol = MT6358_MTKAIF_PROTOCOL_1;
+
+       ret = snd_soc_dapm_sync(dapm);
+       if (ret) {
+               dev_err(rtd->dev, "failed to snd_soc_dapm_sync\n");
+               return ret;
+       }
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(mt8186_mt6366_init);
+
+int mt8186_mt6366_card_set_be_link(struct snd_soc_card *card,
+                                  struct snd_soc_dai_link *link,
+                                  struct device_node *node,
+                                  char *link_name)
+{
+       int ret;
+
+       if (node && strcmp(link->name, link_name) == 0) {
+               ret = snd_soc_of_get_dai_link_codecs(card->dev, node, link);
+               if (ret < 0)
+                       return dev_err_probe(card->dev, ret, "get dai link codecs fail\n");
+       }
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(mt8186_mt6366_card_set_be_link);
diff --git a/sound/soc/mediatek/mt8186/mt8186-mt6366-common.h b/sound/soc/mediatek/mt8186/mt8186-mt6366-common.h
new file mode 100644 (file)
index 0000000..907d8f5
--- /dev/null
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * mt8186-mt6366-common.h
+ *
+ * Copyright (c) 2022 MediaTek Inc.
+ * Author: Jiaxin Yu <jiaxin.yu@mediatek.com>
+ */
+
+#ifndef _MT8186_MT6366_COMMON_H_
+#define _MT8186_MT6366_COMMON_H_
+
+int mt8186_mt6366_init(struct snd_soc_pcm_runtime *rtd);
+int mt8186_mt6366_card_set_be_link(struct snd_soc_card *card,
+                                  struct snd_soc_dai_link *link,
+                                  struct device_node *node,
+                                  char *link_name);
+#endif