From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
To: Rui Zhou <zhourui@huaqin.corp-partner.google.com>,
lgirdwood@gmail.com, broonie@kernel.org, robh+dt@kernel.org,
krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org,
perex@perex.cz, allen-kh.cheng@mediatek.com,
kuninori.morimoto.gx@renesas.com
Cc: linux-sound@vger.kernel.org, devicetree@vger.kernel.org,
linux-mediatek@lists.infradead.org
Subject: Re: [PATCH v5 2/3] ASoC: mediatek: mt8188-mt6359: add es8326 support
Date: Wed, 15 Nov 2023 10:15:33 +0100 [thread overview]
Message-ID: <1b7a6572-25cc-40c8-b8bd-a0605fd8d317@collabora.com> (raw)
In-Reply-To: <20231115090903.578438-3-zhourui@huaqin.corp-partner.google.com>
Il 15/11/23 10:09, Rui Zhou ha scritto:
> To use ES8326 as the codec, add a new sound card
> named mt8186_es8326.
>
> Signed-off-by: Rui Zhou <zhourui@huaqin.corp-partner.google.com>
> ---
> sound/soc/mediatek/Kconfig | 1 +
> sound/soc/mediatek/mt8188/mt8188-mt6359.c | 100 +++++++++++++++++++++-
> 2 files changed, 100 insertions(+), 1 deletion(-)
>
> 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 33d477cc2e54..0421debe3ce4 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"
> @@ -261,6 +268,17 @@ static struct snd_soc_jack_pin nau8825_jack_pins[] = {
> },
> };
>
> +static struct snd_soc_jack_pin es8326_jack_pins[] = {
This is practically the same as nau8825_jack_pins, can we please avoid duplication?
> + {
> + .pin = "Headphone",
> + .mask = SND_JACK_HEADPHONE,
> + },
> + {
> + .pin = "Headset Mic",
> + .mask = SND_JACK_MICROPHONE,
> + },
> +};
> +
> struct mt8188_card_data {
> const char *name;
> unsigned long quirk;
> @@ -943,6 +961,71 @@ static const struct snd_soc_ops mt8188_sof_be_ops = {
> .hw_params = mt8188_sof_be_hw_params,
> };
>
> +static int mt8188_es8326_codec_init(struct snd_soc_pcm_runtime *rtd)
> +{
> + struct mtk_soc_card_data *soc_card_data = snd_soc_card_get_drvdata(rtd->card);
> + struct mt8188_mt6359_priv *priv = soc_card_data->mach_priv;
> + struct snd_soc_component *component = snd_soc_rtd_to_codec(rtd, 0)->component;
> + struct snd_soc_jack *jack = &priv->headset_jack;
> + int ret;
> +
> + ret = snd_soc_card_jack_new_pins(rtd->card, "Headset Jack",
> + SND_JACK_HEADSET | SND_JACK_BTN_0 |
> + SND_JACK_BTN_1 | SND_JACK_BTN_2 |
> + SND_JACK_BTN_3,
> + jack,
> + es8326_jack_pins,
> + ARRAY_SIZE(es8326_jack_pins));
> + if (ret) {
> + dev_err(rtd->dev, "Headset Jack creation failed: %d\n", ret);
> + return ret;
> + }
> +
> + snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_PLAYPAUSE);
> + snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOICECOMMAND);
> + snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEUP);
> + snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN);
> + ret = snd_soc_component_set_jack(component, jack, NULL);
> +
> + if (ret) {
> + dev_err(rtd->dev, "Headset Jack call-back failed: %d\n", ret);
> + return ret;
> + }
> +
This exact code pattern is repeated already twice: once for RT5682s and once for
NAU8825. Can we please commonize it?
> + return ret;
> +};
> +
> +static void mt8188_es8326_codec_exit(struct snd_soc_pcm_runtime *rtd)
> +{
Same for this one.
> + struct snd_soc_component *component = snd_soc_rtd_to_codec(rtd, 0)->component;
> +
> + snd_soc_component_set_jack(component, NULL, NULL);
> +}
> +
Regards,
Angelo
next prev parent reply other threads:[~2023-11-15 9:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-15 9:09 [PATCH v5 0/3] add es8326 dt-bindings, es8326 support and Enable dual amp for rt5682s Rui Zhou
2023-11-15 9:09 ` [PATCH v5 1/3] ASoC: dt-bindings: mt8188-mt6359: add es8326 support Rui Zhou
2023-11-15 14:42 ` Conor Dooley
2023-11-15 9:09 ` [PATCH v5 2/3] ASoC: mediatek: " Rui Zhou
2023-11-15 9:15 ` AngeloGioacchino Del Regno [this message]
2023-11-15 9:09 ` [PATCH v5 3/3] ASoC: mediatek: mt8188-mt6359: Enable dual amp for mt8188-rt5682s Rui Zhou
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=1b7a6572-25cc-40c8-b8bd-a0605fd8d317@collabora.com \
--to=angelogioacchino.delregno@collabora.com \
--cc=allen-kh.cheng@mediatek.com \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=kuninori.morimoto.gx@renesas.com \
--cc=lgirdwood@gmail.com \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=robh+dt@kernel.org \
--cc=zhourui@huaqin.corp-partner.google.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