Commit cabc3ace authored by Ajit Kumar Pandey's avatar Ajit Kumar Pandey Committed by Mark Brown

ASoC: amd: acp: Add support for Maxim amplifier codec

In newer chrome boards we have max98360a as an amplifier codec.
Add support for max98360a in generic machine driver and configure
driver data to enable SOF sound card support on newer boards .
Signed-off-by: default avatarAjit Kumar Pandey <AjitKumar.Pandey@amd.com>
Link: https://lore.kernel.org/r/20211019070938.5076-8-AjitKumar.Pandey@amd.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 9f84940f
...@@ -32,6 +32,7 @@ config SND_SOC_AMD_MACH_COMMON ...@@ -32,6 +32,7 @@ config SND_SOC_AMD_MACH_COMMON
select SND_SOC_RT5682_I2C select SND_SOC_RT5682_I2C
select SND_SOC_DMIC select SND_SOC_DMIC
select SND_SOC_RT1019 select SND_SOC_RT1019
select SND_SOC_MAX98357A
depends on X86 && PCI && I2C depends on X86 && PCI && I2C
help help
This option enables common Machine driver module for ACP. This option enables common Machine driver module for ACP.
......
...@@ -274,6 +274,31 @@ static const struct snd_soc_ops acp_card_rt1019_ops = { ...@@ -274,6 +274,31 @@ static const struct snd_soc_ops acp_card_rt1019_ops = {
.hw_params = acp_card_rt1019_hw_params, .hw_params = acp_card_rt1019_hw_params,
}; };
/* Declare Maxim codec components */
SND_SOC_DAILINK_DEF(max98360a,
DAILINK_COMP_ARRAY(COMP_CODEC("MX98360A:00", "HiFi")));
static const struct snd_soc_dapm_route max98360a_map[] = {
{"Spk", NULL, "Speaker"},
};
static int acp_card_maxim_init(struct snd_soc_pcm_runtime *rtd)
{
struct snd_soc_card *card = rtd->card;
struct acp_card_drvdata *drvdata = card->drvdata;
if (drvdata->amp_codec_id != MAX98360A)
return -EINVAL;
return snd_soc_dapm_add_routes(&rtd->card->dapm, max98360a_map,
ARRAY_SIZE(max98360a_map));
}
static const struct snd_soc_ops acp_card_maxim_ops = {
.startup = acp_card_amp_startup,
.shutdown = acp_card_shutdown,
};
/* Declare DMIC codec components */ /* Declare DMIC codec components */
SND_SOC_DAILINK_DEF(dmic_codec, SND_SOC_DAILINK_DEF(dmic_codec,
DAILINK_COMP_ARRAY(COMP_CODEC("dmic-codec", "dmic-hifi"))); DAILINK_COMP_ARRAY(COMP_CODEC("dmic-codec", "dmic-hifi")));
...@@ -371,6 +396,12 @@ int acp_sofdsp_dai_links_create(struct snd_soc_card *card) ...@@ -371,6 +396,12 @@ int acp_sofdsp_dai_links_create(struct snd_soc_card *card)
card->codec_conf = rt1019_conf; card->codec_conf = rt1019_conf;
card->num_configs = ARRAY_SIZE(rt1019_conf); card->num_configs = ARRAY_SIZE(rt1019_conf);
} }
if (drv_data->amp_codec_id == MAX98360A) {
links[i].codecs = max98360a;
links[i].num_codecs = ARRAY_SIZE(max98360a);
links[i].ops = &acp_card_maxim_ops;
links[i].init = acp_card_maxim_init;
}
i++; i++;
} }
...@@ -455,6 +486,12 @@ int acp_legacy_dai_links_create(struct snd_soc_card *card) ...@@ -455,6 +486,12 @@ int acp_legacy_dai_links_create(struct snd_soc_card *card)
card->codec_conf = rt1019_conf; card->codec_conf = rt1019_conf;
card->num_configs = ARRAY_SIZE(rt1019_conf); card->num_configs = ARRAY_SIZE(rt1019_conf);
} }
if (drv_data->amp_codec_id == MAX98360A) {
links[i].codecs = max98360a;
links[i].num_codecs = ARRAY_SIZE(max98360a);
links[i].ops = &acp_card_maxim_ops;
links[i].init = acp_card_maxim_init;
}
} }
card->dai_link = links; card->dai_link = links;
......
...@@ -35,6 +35,7 @@ enum codec_endpoints { ...@@ -35,6 +35,7 @@ enum codec_endpoints {
DUMMY = 0, DUMMY = 0,
RT5682, RT5682,
RT1019, RT1019,
MAX98360A,
}; };
struct acp_card_drvdata { struct acp_card_drvdata {
......
...@@ -29,6 +29,15 @@ static struct acp_card_drvdata sof_rt5682_rt1019_data = { ...@@ -29,6 +29,15 @@ static struct acp_card_drvdata sof_rt5682_rt1019_data = {
.dmic_codec_id = DMIC, .dmic_codec_id = DMIC,
}; };
static struct acp_card_drvdata sof_rt5682_max_data = {
.hs_cpu_id = I2S_SP,
.amp_cpu_id = I2S_SP,
.dmic_cpu_id = DMIC,
.hs_codec_id = RT5682,
.amp_codec_id = MAX98360A,
.dmic_codec_id = DMIC,
};
static const struct snd_kcontrol_new acp_controls[] = { static const struct snd_kcontrol_new acp_controls[] = {
SOC_DAPM_PIN_SWITCH("Headphone Jack"), SOC_DAPM_PIN_SWITCH("Headphone Jack"),
SOC_DAPM_PIN_SWITCH("Headset Mic"), SOC_DAPM_PIN_SWITCH("Headset Mic"),
...@@ -85,6 +94,10 @@ static const struct platform_device_id board_ids[] = { ...@@ -85,6 +94,10 @@ static const struct platform_device_id board_ids[] = {
.name = "rt5682-rt1019", .name = "rt5682-rt1019",
.driver_data = (kernel_ulong_t)&sof_rt5682_rt1019_data .driver_data = (kernel_ulong_t)&sof_rt5682_rt1019_data
}, },
{
.name = "rt5682-max",
.driver_data = (kernel_ulong_t)&sof_rt5682_max_data
},
{ } { }
}; };
static struct platform_driver acp_asoc_audio = { static struct platform_driver acp_asoc_audio = {
...@@ -100,4 +113,5 @@ module_platform_driver(acp_asoc_audio); ...@@ -100,4 +113,5 @@ module_platform_driver(acp_asoc_audio);
MODULE_IMPORT_NS(SND_SOC_AMD_MACH); MODULE_IMPORT_NS(SND_SOC_AMD_MACH);
MODULE_DESCRIPTION("ACP chrome SOF audio support"); MODULE_DESCRIPTION("ACP chrome SOF audio support");
MODULE_ALIAS("platform:rt5682-rt1019"); MODULE_ALIAS("platform:rt5682-rt1019");
MODULE_ALIAS("platform:rt5682-max");
MODULE_LICENSE("GPL v2"); MODULE_LICENSE("GPL v2");
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