[v8 3/4] ASoC: mediatek: mt8188-mt6359: add es8326 support
AngeloGioacchino Del Regno
angelogioacchino.delregno at collabora.com
Mon Dec 11 06:40:02 PST 2023
Il 08/12/23 08:09, Rui Zhou ha scritto:
> To use ES8326 as the codec, add a new sound card
> named mt8186_es8326.
>
> Reviewed-by: Trevor Wu <trevor.wu at mediatek.com>
> Signed-off-by: Rui Zhou <zhourui at huaqin.corp-partner.google.com>
> ---
> sound/soc/mediatek/Kconfig | 1 +
> sound/soc/mediatek/mt8188/mt8188-mt6359.c | 51 ++++++++++++++++++++++-
> 2 files changed, 50 insertions(+), 2 deletions(-)
>
> diff --git a/sound/soc/mediatek/Kconfig b/sound/soc/mediatek/Kconfig
> index b93d455744ab..296b434caf81 100644
> --- a/sound/soc/mediatek/Kconfig
> +++ b/sound/soc/mediatek/Kconfig
> @@ -252,6 +252,7 @@ config SND_SOC_MT8188_MT6359
> select SND_SOC_NAU8315
> select SND_SOC_NAU8825
> select SND_SOC_RT5682S
> + select SND_SOC_ES8326
> help
> This adds support for ASoC machine driver for MediaTek MT8188
> boards with the MT6359 and other I2S audio codecs.
> diff --git a/sound/soc/mediatek/mt8188/mt8188-mt6359.c b/sound/soc/mediatek/mt8188/mt8188-mt6359.c
> index b4606a28794c..ddbdf9265640 100644
> --- a/sound/soc/mediatek/mt8188/mt8188-mt6359.c
> +++ b/sound/soc/mediatek/mt8188/mt8188-mt6359.c
> @@ -34,6 +34,8 @@
>
> #define NAU8825_HS_PRESENT BIT(0)
> #define RT5682S_HS_PRESENT BIT(1)
> +#define ES8326_HS_PRESENT BIT(2)
> +#define MAX98390_TWO_AMP BIT(3)
> /*
> * Maxim MAX98390
> */
> @@ -48,6 +50,11 @@
> */
> #define NAU8825_CODEC_DAI "nau8825-hifi"
>
> +/*
> + * ES8326
> + */
> +#define ES8326_CODEC_DAI "ES8326 HiFi"
> +
> #define SOF_DMA_DL2 "SOF_DMA_DL2"
> #define SOF_DMA_DL3 "SOF_DMA_DL3"
> #define SOF_DMA_UL4 "SOF_DMA_UL4"
> @@ -888,6 +895,30 @@ static const struct snd_soc_ops mt8188_sof_be_ops = {
> .hw_params = mt8188_sof_be_hw_params,
> };
>
> +static int mt8188_es8326_hw_params(struct snd_pcm_substream *substream,
> + struct snd_pcm_hw_params *params)
> +{
> + struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
> + struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0);
> + struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, 0);
> + unsigned int rate = params_rate(params);
> + int ret;
> +
> + /* Configure MCLK for codec */
> + ret = snd_soc_dai_set_sysclk(codec_dai, 0, rate * 256, SND_SOC_CLOCK_IN);
> + if (ret < 0) {
> + dev_err(codec_dai->dev, "can't set MCLK %d\n", ret);
> + return ret;
> + }
> +
> + /* Configure MCLK for cpu */
> + return snd_soc_dai_set_sysclk(cpu_dai, 0, rate * 256, SND_SOC_CLOCK_OUT);
> +}
> +
> +static const struct snd_soc_ops mt8188_es8326_ops = {
> + .hw_params = mt8188_es8326_hw_params,
> +};
> +
> static struct snd_soc_dai_link mt8188_mt6359_dai_links[] = {
> /* FE */
> [DAI_LINK_DL2_FE] = {
> @@ -1197,7 +1228,7 @@ static void mt8188_fixup_controls(struct snd_soc_card *card)
> struct mt8188_card_data *card_data = (struct mt8188_card_data *)priv->private_data;
> struct snd_kcontrol *kctl;
>
> - if (card_data->quirk & (NAU8825_HS_PRESENT | RT5682S_HS_PRESENT)) {
> + if (card_data->quirk & (NAU8825_HS_PRESENT | RT5682S_HS_PRESENT | ES8326_HS_PRESENT)) {
> struct snd_soc_dapm_widget *w, *next_w;
>
> for_each_card_widgets_safe(card, w, next_w) {
> @@ -1238,6 +1269,7 @@ static int mt8188_mt6359_dev_probe(struct platform_device *pdev)
> struct mt8188_card_data *card_data;
> struct snd_soc_dai_link *dai_link;
> bool init_mt6359 = false;
> + bool init_es8326 = false;
> bool init_nau8825 = false;
> bool init_rt5682s = false;
> bool init_max98390 = false;
> @@ -1344,7 +1376,9 @@ static int mt8188_mt6359_dev_probe(struct platform_device *pdev)
> strcmp(dai_link->name, "ETDM1_IN_BE") == 0 ||
> strcmp(dai_link->name, "ETDM2_IN_BE") == 0) {
> if (!strcmp(dai_link->codecs->dai_name, MAX98390_CODEC_DAI)) {
> - dai_link->ops = &mt8188_max98390_ops;
> + if (!(card_data->quirk & MAX98390_TWO_AMP)) {
> + dai_link->ops = &mt8188_max98390_ops;
> + }
Can you please explain why is it *not* necessary to setup the TDM with
mt8188_max98390_ops in the TWO_AMP case?
Please also add that as a comment in the code, as this looks strange.
Thanks,
Angelo
More information about the Linux-mediatek
mailing list