From: Trevor Wu <trevor.wu@mediatek.com>
To: <broonie@kernel.org>, <tiwai@suse.com>, <robh+dt@kernel.org>,
<matthias.bgg@gmail.com>
Cc: <trevor.wu@mediatek.com>, <alsa-devel@alsa-project.org>,
<linux-mediatek@lists.infradead.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>, <devicetree@vger.kernel.org>,
<aaronyu@google.com>, <angelogioacchino.delregno@collabora.com>,
<tzungbi@google.com>, <yc.hung@mediatek.com>
Subject: [PATCH v3 5/6] ASoC: mediatek: mt8195: add machine support for max98390 and rt5682
Date: Mon, 21 Mar 2022 15:23:11 +0800 [thread overview]
Message-ID: <20220321072312.14972-6-trevor.wu@mediatek.com> (raw)
In-Reply-To: <20220321072312.14972-1-trevor.wu@mediatek.com>
This patch adds support for mt8195 board with mt6359, max98390 and
rt5682.
Signed-off-by: Trevor Wu <trevor.wu@mediatek.com>
---
sound/soc/mediatek/Kconfig | 1 +
sound/soc/mediatek/mt8195/mt8195-mt6359.c | 72 +++++++++++++++++++++++
2 files changed, 73 insertions(+)
diff --git a/sound/soc/mediatek/Kconfig b/sound/soc/mediatek/Kconfig
index d3f4b8b9c0af..ce055cd28dc7 100644
--- a/sound/soc/mediatek/Kconfig
+++ b/sound/soc/mediatek/Kconfig
@@ -207,6 +207,7 @@ config SND_SOC_MT8195_MT6359
select SND_SOC_RT1015P
select SND_SOC_RT5682_I2C
select SND_SOC_RT5682S
+ select SND_SOC_MAX98390
select SND_SOC_DMIC
select SND_SOC_HDMI_CODEC
help
diff --git a/sound/soc/mediatek/mt8195/mt8195-mt6359.c b/sound/soc/mediatek/mt8195/mt8195-mt6359.c
index 60279eee22c8..8f8c3b999747 100644
--- a/sound/soc/mediatek/mt8195/mt8195-mt6359.c
+++ b/sound/soc/mediatek/mt8195/mt8195-mt6359.c
@@ -25,6 +25,11 @@
#define RT1011_SPEAKER_AMP_PRESENT BIT(0)
#define RT1019_SPEAKER_AMP_PRESENT BIT(1)
+#define MAX98390_SPEAKER_AMP_PRESENT BIT(2)
+
+#define MAX98390_CODEC_DAI "max98390-aif1"
+#define MAX98390_DEV0_NAME "max98390.2-0038" /* right */
+#define MAX98390_DEV1_NAME "max98390.2-0039" /* left */
#define RT1011_CODEC_DAI "rt1011-aif"
#define RT1011_DEV0_NAME "rt1011.2-0038"
@@ -121,6 +126,11 @@ static const struct snd_soc_dapm_route mt8195_rt1019_routes[] = {
{ "Ext Spk", NULL, "Speaker" },
};
+static const struct snd_soc_dapm_route mt8195_max98390_routes[] = {
+ { "Left Spk", NULL, "Left BE_OUT" },
+ { "Right Spk", NULL, "Right BE_OUT" },
+};
+
#define CKSYS_AUD_TOP_CFG 0x032c
#define CKSYS_AUD_TOP_MON 0x0330
@@ -670,6 +680,35 @@ static int mt8195_rt1019_init(struct snd_soc_pcm_runtime *rtd)
return ret;
}
+static int mt8195_max98390_init(struct snd_soc_pcm_runtime *rtd)
+{
+ struct snd_soc_card *card = rtd->card;
+ int ret;
+
+ ret = snd_soc_dapm_new_controls(&card->dapm, mt8195_dual_speaker_widgets,
+ ARRAY_SIZE(mt8195_dual_speaker_widgets));
+ if (ret) {
+ dev_err(rtd->dev, "unable to add dapm controls, ret %d\n", ret);
+ /* Don't need to add routes if widget addition failed */
+ return ret;
+ }
+
+ ret = snd_soc_add_card_controls(card, mt8195_dual_speaker_controls,
+ ARRAY_SIZE(mt8195_dual_speaker_controls));
+ if (ret) {
+ dev_err(rtd->dev, "unable to add card controls, ret %d\n", ret);
+ return ret;
+ }
+
+ ret = snd_soc_dapm_add_routes(&card->dapm, mt8195_max98390_routes,
+ ARRAY_SIZE(mt8195_max98390_routes));
+
+ if (ret)
+ dev_err(rtd->dev, "unable to add dapm routes, ret %d\n", ret);
+
+ return ret;
+}
+
static int mt8195_etdm_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
struct snd_pcm_hw_params *params)
{
@@ -928,6 +967,12 @@ SND_SOC_DAILINK_DEF(rt1011_comps,
COMP_CODEC(RT1011_DEV1_NAME,
RT1011_CODEC_DAI)));
+SND_SOC_DAILINK_DEF(max98390_comps,
+ DAILINK_COMP_ARRAY(COMP_CODEC(MAX98390_DEV0_NAME,
+ MAX98390_CODEC_DAI),
+ COMP_CODEC(MAX98390_DEV1_NAME,
+ MAX98390_CODEC_DAI)));
+
static const struct sof_conn_stream g_sof_conn_streams[] = {
{ "ETDM2_OUT_BE", "AFE_SOF_DL2", SOF_DMA_DL2, SNDRV_PCM_STREAM_PLAYBACK},
{ "ETDM1_OUT_BE", "AFE_SOF_DL3", SOF_DMA_DL3, SNDRV_PCM_STREAM_PLAYBACK},
@@ -1251,6 +1296,17 @@ static struct snd_soc_codec_conf rt1011_codec_conf[] = {
},
};
+static struct snd_soc_codec_conf max98390_codec_conf[] = {
+ {
+ .dlc = COMP_CODEC_CONF(MAX98390_DEV0_NAME),
+ .name_prefix = "Right",
+ },
+ {
+ .dlc = COMP_CODEC_CONF(MAX98390_DEV1_NAME),
+ .name_prefix = "Left",
+ },
+};
+
static struct snd_soc_card mt8195_mt6359_soc_card = {
.owner = THIS_MODULE,
.dai_link = mt8195_mt6359_dai_links,
@@ -1546,6 +1602,13 @@ static int mt8195_mt6359_dev_probe(struct platform_device *pdev)
dai_link->num_codecs = ARRAY_SIZE(rt1019_comps);
dai_link->init = mt8195_rt1019_init;
break;
+ case MAX98390_SPEAKER_AMP_PRESENT:
+ dai_link->codecs = max98390_comps;
+ dai_link->num_codecs = ARRAY_SIZE(max98390_comps);
+ dai_link->init = mt8195_max98390_init;
+ card->codec_conf = max98390_codec_conf;
+ card->num_configs = ARRAY_SIZE(max98390_codec_conf);
+ break;
default:
break;
}
@@ -1576,6 +1639,11 @@ static struct mt8195_card_data mt8195_mt6359_rt1011_rt5682_card = {
.quirk = RT1011_SPEAKER_AMP_PRESENT,
};
+static struct mt8195_card_data mt8195_mt6359_max98390_rt5682_card = {
+ .name = "mt8195_m98390_r5682",
+ .quirk = MAX98390_SPEAKER_AMP_PRESENT,
+};
+
#ifdef CONFIG_OF
static const struct of_device_id mt8195_mt6359_dt_match[] = {
{
@@ -1586,6 +1654,10 @@ static const struct of_device_id mt8195_mt6359_dt_match[] = {
.compatible = "mediatek,mt8195_mt6359_rt1011_rt5682",
.data = &mt8195_mt6359_rt1011_rt5682_card,
},
+ {
+ .compatible = "mediatek,mt8195_mt6359_max98390_rt5682",
+ .data = &mt8195_mt6359_max98390_rt5682_card,
+ },
};
#endif
--
2.18.0
next prev parent reply other threads:[~2022-03-21 7:23 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-21 7:23 [PATCH v3 0/6] ASoC: mediatek: Add support for MT8195 sound card with " Trevor Wu
2022-03-21 7:23 ` [PATCH v3 1/6] ASoC: mediatek: mt8195: revise mt8195-mt6359-rt1019-rt5682.c Trevor Wu
2022-03-21 15:10 ` Tzung-Bi Shih
2022-03-21 7:23 ` [PATCH v3 2/6] ASoC: mediatek: mt8195: merge machine driver Trevor Wu
2022-03-21 15:12 ` Tzung-Bi Shih
2022-03-23 8:15 ` Trevor Wu
2022-03-21 7:23 ` [PATCH v3 3/6] ASoC: dt-bindings: mediatek: mt8195: merge mt8195 machine yaml Trevor Wu
2022-03-21 23:30 ` Miles Chen
2022-03-23 7:27 ` Trevor Wu
2022-03-21 7:23 ` [PATCH v3 4/6] ASoC: mediatek: mt8195: rename card controls Trevor Wu
2022-03-21 15:12 ` Tzung-Bi Shih
2022-03-21 7:23 ` Trevor Wu [this message]
2022-03-21 15:12 ` [PATCH v3 5/6] ASoC: mediatek: mt8195: add machine support for max98390 and rt5682 Tzung-Bi Shih
2022-03-23 7:29 ` Trevor Wu
2022-03-21 7:23 ` [PATCH v3 6/6] ASoC: dt-bindings: mediatek: mt8195: support mt8195-mt6359-max98390-rt5682 Trevor Wu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220321072312.14972-6-trevor.wu@mediatek.com \
--to=trevor.wu@mediatek.com \
--cc=aaronyu@google.com \
--cc=alsa-devel@alsa-project.org \
--cc=angelogioacchino.delregno@collabora.com \
--cc=broonie@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=robh+dt@kernel.org \
--cc=tiwai@suse.com \
--cc=tzungbi@google.com \
--cc=yc.hung@mediatek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®