Commit 6181ab31 authored by Jiaxin Yu's avatar Jiaxin Yu Committed by Mark Brown

ASoC: mediatek: mt8192: support rt1015p_rt5682s

Add support for using the rt5682s codec together with rt1015p on
mt8192-mt6359 machines. All configurations are shared with the rt5682
codec variant, so simply select the SND_SOC_RT5682S config to ensure the
codec is present and set the correct card name. The codec will be linked
to by pointing to it in the headset-codec property in the devicetree.

While at it, also create macros for the names of the different codec
variants supported by this driver, as well as rename occurrences of
rt1015p_rt5682 to rt1015p_rt5682x, since they are shared between rt5682
and rt5682s.
Signed-off-by: default avatarJiaxin Yu <jiaxin.yu@mediatek.com>
Reviewed-by: default avatarTzung-Bi Shih <tzungbi@kernel.org>
Reviewed-by: default avatarNícolas F. R. A. Prado <nfraprado@collabora.com>
Tested-by: default avatarNícolas F. R. A. Prado <nfraprado@collabora.com>
Reviewed-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/20220408060552.26607-5-jiaxin.yu@mediatek.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent f8910fb4
...@@ -179,6 +179,7 @@ config SND_SOC_MT8192_MT6359_RT1015_RT5682 ...@@ -179,6 +179,7 @@ config SND_SOC_MT8192_MT6359_RT1015_RT5682
select SND_SOC_RT1015 select SND_SOC_RT1015
select SND_SOC_RT1015P select SND_SOC_RT1015P
select SND_SOC_RT5682_I2C select SND_SOC_RT5682_I2C
select SND_SOC_RT5682S
select SND_SOC_DMIC select SND_SOC_DMIC
help help
This adds ASoC driver for Mediatek MT8192 boards This adds ASoC driver for Mediatek MT8192 boards
......
...@@ -28,6 +28,14 @@ ...@@ -28,6 +28,14 @@
#define RT1015_DEV0_NAME "rt1015.1-0028" #define RT1015_DEV0_NAME "rt1015.1-0028"
#define RT1015_DEV1_NAME "rt1015.1-0029" #define RT1015_DEV1_NAME "rt1015.1-0029"
#define RT1015_RT5682_CARD_NAME "mt8192_mt6359_rt1015_rt5682"
#define RT1015P_RT5682_CARD_NAME "mt8192_mt6359_rt1015p_rt5682"
#define RT1015P_RT5682S_CARD_NAME "mt8192_mt6359_rt1015p_rt5682s"
#define RT1015_RT5682_OF_NAME "mediatek,mt8192_mt6359_rt1015_rt5682"
#define RT1015P_RT5682_OF_NAME "mediatek,mt8192_mt6359_rt1015p_rt5682"
#define RT1015P_RT5682S_OF_NAME "mediatek,mt8192_mt6359_rt1015p_rt5682s"
struct mt8192_mt6359_priv { struct mt8192_mt6359_priv {
struct snd_soc_jack headset_jack; struct snd_soc_jack headset_jack;
struct snd_soc_jack hdmi_jack; struct snd_soc_jack hdmi_jack;
...@@ -68,8 +76,8 @@ static int mt8192_rt1015_i2s_hw_params(struct snd_pcm_substream *substream, ...@@ -68,8 +76,8 @@ static int mt8192_rt1015_i2s_hw_params(struct snd_pcm_substream *substream,
return snd_soc_dai_set_sysclk(cpu_dai, 0, mclk_fs, SND_SOC_CLOCK_OUT); return snd_soc_dai_set_sysclk(cpu_dai, 0, mclk_fs, SND_SOC_CLOCK_OUT);
} }
static int mt8192_rt5682_i2s_hw_params(struct snd_pcm_substream *substream, static int mt8192_rt5682x_i2s_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params) struct snd_pcm_hw_params *params)
{ {
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
struct snd_soc_card *card = rtd->card; struct snd_soc_card *card = rtd->card;
...@@ -118,8 +126,8 @@ static const struct snd_soc_ops mt8192_rt1015_i2s_ops = { ...@@ -118,8 +126,8 @@ static const struct snd_soc_ops mt8192_rt1015_i2s_ops = {
.hw_params = mt8192_rt1015_i2s_hw_params, .hw_params = mt8192_rt1015_i2s_hw_params,
}; };
static const struct snd_soc_ops mt8192_rt5682_i2s_ops = { static const struct snd_soc_ops mt8192_rt5682x_i2s_ops = {
.hw_params = mt8192_rt5682_i2s_hw_params, .hw_params = mt8192_rt5682x_i2s_hw_params,
}; };
static int mt8192_mt6359_mtkaif_calibration(struct snd_soc_pcm_runtime *rtd) static int mt8192_mt6359_mtkaif_calibration(struct snd_soc_pcm_runtime *rtd)
...@@ -950,7 +958,7 @@ static struct snd_soc_dai_link mt8192_mt6359_dai_links[] = { ...@@ -950,7 +958,7 @@ static struct snd_soc_dai_link mt8192_mt6359_dai_links[] = {
.init = mt8192_rt5682_init, .init = mt8192_rt5682_init,
.be_hw_params_fixup = mt8192_i2s_hw_params_fixup, .be_hw_params_fixup = mt8192_i2s_hw_params_fixup,
SND_SOC_DAILINK_REG(i2s8), SND_SOC_DAILINK_REG(i2s8),
.ops = &mt8192_rt5682_i2s_ops, .ops = &mt8192_rt5682x_i2s_ops,
}, },
{ {
.name = "I2S9", .name = "I2S9",
...@@ -959,7 +967,7 @@ static struct snd_soc_dai_link mt8192_mt6359_dai_links[] = { ...@@ -959,7 +967,7 @@ static struct snd_soc_dai_link mt8192_mt6359_dai_links[] = {
.ignore_suspend = 1, .ignore_suspend = 1,
.be_hw_params_fixup = mt8192_i2s_hw_params_fixup, .be_hw_params_fixup = mt8192_i2s_hw_params_fixup,
SND_SOC_DAILINK_REG(i2s9), SND_SOC_DAILINK_REG(i2s9),
.ops = &mt8192_rt5682_i2s_ops, .ops = &mt8192_rt5682x_i2s_ops,
}, },
{ {
.name = "CONNSYS_I2S", .name = "CONNSYS_I2S",
...@@ -1039,7 +1047,7 @@ static struct snd_soc_codec_conf rt1015_amp_conf[] = { ...@@ -1039,7 +1047,7 @@ static struct snd_soc_codec_conf rt1015_amp_conf[] = {
}; };
static struct snd_soc_card mt8192_mt6359_rt1015_rt5682_card = { static struct snd_soc_card mt8192_mt6359_rt1015_rt5682_card = {
.name = "mt8192_mt6359_rt1015_rt5682", .name = RT1015_RT5682_CARD_NAME,
.owner = THIS_MODULE, .owner = THIS_MODULE,
.dai_link = mt8192_mt6359_dai_links, .dai_link = mt8192_mt6359_dai_links,
.num_links = ARRAY_SIZE(mt8192_mt6359_dai_links), .num_links = ARRAY_SIZE(mt8192_mt6359_dai_links),
...@@ -1053,14 +1061,13 @@ static struct snd_soc_card mt8192_mt6359_rt1015_rt5682_card = { ...@@ -1053,14 +1061,13 @@ static struct snd_soc_card mt8192_mt6359_rt1015_rt5682_card = {
.num_configs = ARRAY_SIZE(rt1015_amp_conf), .num_configs = ARRAY_SIZE(rt1015_amp_conf),
}; };
static const struct snd_soc_dapm_widget static const struct snd_soc_dapm_widget mt8192_mt6359_rt1015p_rt5682x_widgets[] = {
mt8192_mt6359_rt1015p_rt5682_widgets[] = {
SND_SOC_DAPM_SPK("Speakers", NULL), SND_SOC_DAPM_SPK("Speakers", NULL),
SND_SOC_DAPM_HP("Headphone Jack", NULL), SND_SOC_DAPM_HP("Headphone Jack", NULL),
SND_SOC_DAPM_MIC("Headset Mic", NULL), SND_SOC_DAPM_MIC("Headset Mic", NULL),
}; };
static const struct snd_soc_dapm_route mt8192_mt6359_rt1015p_rt5682_routes[] = { static const struct snd_soc_dapm_route mt8192_mt6359_rt1015p_rt5682x_routes[] = {
/* speaker */ /* speaker */
{ "Speakers", NULL, "Speaker" }, { "Speakers", NULL, "Speaker" },
/* headset */ /* headset */
...@@ -1069,23 +1076,22 @@ static const struct snd_soc_dapm_route mt8192_mt6359_rt1015p_rt5682_routes[] = { ...@@ -1069,23 +1076,22 @@ static const struct snd_soc_dapm_route mt8192_mt6359_rt1015p_rt5682_routes[] = {
{ "IN1P", NULL, "Headset Mic" }, { "IN1P", NULL, "Headset Mic" },
}; };
static const struct snd_kcontrol_new mt8192_mt6359_rt1015p_rt5682_controls[] = { static const struct snd_kcontrol_new mt8192_mt6359_rt1015p_rt5682x_controls[] = {
SOC_DAPM_PIN_SWITCH("Speakers"), SOC_DAPM_PIN_SWITCH("Speakers"),
SOC_DAPM_PIN_SWITCH("Headphone Jack"), SOC_DAPM_PIN_SWITCH("Headphone Jack"),
SOC_DAPM_PIN_SWITCH("Headset Mic"), SOC_DAPM_PIN_SWITCH("Headset Mic"),
}; };
static struct snd_soc_card mt8192_mt6359_rt1015p_rt5682_card = { static struct snd_soc_card mt8192_mt6359_rt1015p_rt5682x_card = {
.name = "mt8192_mt6359_rt1015p_rt5682",
.owner = THIS_MODULE, .owner = THIS_MODULE,
.dai_link = mt8192_mt6359_dai_links, .dai_link = mt8192_mt6359_dai_links,
.num_links = ARRAY_SIZE(mt8192_mt6359_dai_links), .num_links = ARRAY_SIZE(mt8192_mt6359_dai_links),
.controls = mt8192_mt6359_rt1015p_rt5682_controls, .controls = mt8192_mt6359_rt1015p_rt5682x_controls,
.num_controls = ARRAY_SIZE(mt8192_mt6359_rt1015p_rt5682_controls), .num_controls = ARRAY_SIZE(mt8192_mt6359_rt1015p_rt5682x_controls),
.dapm_widgets = mt8192_mt6359_rt1015p_rt5682_widgets, .dapm_widgets = mt8192_mt6359_rt1015p_rt5682x_widgets,
.num_dapm_widgets = ARRAY_SIZE(mt8192_mt6359_rt1015p_rt5682_widgets), .num_dapm_widgets = ARRAY_SIZE(mt8192_mt6359_rt1015p_rt5682x_widgets),
.dapm_routes = mt8192_mt6359_rt1015p_rt5682_routes, .dapm_routes = mt8192_mt6359_rt1015p_rt5682x_routes,
.num_dapm_routes = ARRAY_SIZE(mt8192_mt6359_rt1015p_rt5682_routes), .num_dapm_routes = ARRAY_SIZE(mt8192_mt6359_rt1015p_rt5682x_routes),
}; };
static int mt8192_mt6359_card_set_be_link(struct snd_soc_card *card, static int mt8192_mt6359_card_set_be_link(struct snd_soc_card *card,
...@@ -1119,6 +1125,13 @@ static int mt8192_mt6359_dev_probe(struct platform_device *pdev) ...@@ -1119,6 +1125,13 @@ static int mt8192_mt6359_dev_probe(struct platform_device *pdev)
return -EINVAL; return -EINVAL;
card->dev = &pdev->dev; card->dev = &pdev->dev;
if (of_device_is_compatible(pdev->dev.of_node, RT1015P_RT5682_OF_NAME))
card->name = RT1015P_RT5682_CARD_NAME;
else if (of_device_is_compatible(pdev->dev.of_node, RT1015P_RT5682S_OF_NAME))
card->name = RT1015P_RT5682S_CARD_NAME;
else
dev_dbg(&pdev->dev, "No need to set card name\n");
hdmi_codec = of_parse_phandle(pdev->dev.of_node, "mediatek,hdmi-codec", 0); hdmi_codec = of_parse_phandle(pdev->dev.of_node, "mediatek,hdmi-codec", 0);
if (!hdmi_codec) if (!hdmi_codec)
dev_dbg(&pdev->dev, "The machine has no hdmi-codec\n"); dev_dbg(&pdev->dev, "The machine has no hdmi-codec\n");
...@@ -1209,12 +1222,16 @@ static int mt8192_mt6359_dev_probe(struct platform_device *pdev) ...@@ -1209,12 +1222,16 @@ static int mt8192_mt6359_dev_probe(struct platform_device *pdev)
#ifdef CONFIG_OF #ifdef CONFIG_OF
static const struct of_device_id mt8192_mt6359_dt_match[] = { static const struct of_device_id mt8192_mt6359_dt_match[] = {
{ {
.compatible = "mediatek,mt8192_mt6359_rt1015_rt5682", .compatible = RT1015_RT5682_OF_NAME,
.data = &mt8192_mt6359_rt1015_rt5682_card, .data = &mt8192_mt6359_rt1015_rt5682_card,
}, },
{ {
.compatible = "mediatek,mt8192_mt6359_rt1015p_rt5682", .compatible = RT1015P_RT5682_OF_NAME,
.data = &mt8192_mt6359_rt1015p_rt5682_card, .data = &mt8192_mt6359_rt1015p_rt5682x_card,
},
{
.compatible = RT1015P_RT5682S_OF_NAME,
.data = &mt8192_mt6359_rt1015p_rt5682x_card,
}, },
{} {}
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment