linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: "Trevor Wu (吳文良)" <Trevor.Wu@mediatek.com>
To: "lgirdwood@gmail.com" <lgirdwood@gmail.com>,
	"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
	"broonie@kernel.org" <broonie@kernel.org>,
	"xiazhengqiao@huaqin.corp-partner.google.com"
	<xiazhengqiao@huaqin.corp-partner.google.com>,
	"robh+dt@kernel.org" <robh+dt@kernel.org>,
	"perex@perex.cz" <perex@perex.cz>
Cc: "linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>
Subject: Re: [v2 2/2] ASoC: mediatek: mt8188-mt6359: add rt5682s support
Date: Wed, 27 Sep 2023 02:48:38 +0000	[thread overview]
Message-ID: <cb9202ded221ad13eaa2acf917d43b27968ef31a.camel@mediatek.com> (raw)
In-Reply-To: <20230926040901.20338-3-xiazhengqiao@huaqin.corp-partner.google.com>

On Tue, 2023-09-26 at 12:09 +0800, xiazhengqiao wrote:
>  	 
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
>  To use RT5682S as the codec and MAX98390 as the amp, add a new
> sound card named mt8188_rt5682s.
> 
> Signed-off-by: xiazhengqiao <
> xiazhengqiao@huaqin.corp-partner.google.com>
> ---

..snip..

>  
> +static int mt8186_rt5682s_i2s_hw_params(struct snd_pcm_substream 

Should be mt8188.


Thanks,
Trevor

> *substream,
> +					struct snd_pcm_hw_params
> *params)
> +{
> +	struct snd_soc_pcm_runtime *rtd = substream->private_data;
> +	struct snd_soc_card *card = rtd->card;
> +	struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
> +	struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
> +	unsigned int rate = params_rate(params);
> +	int bitwidth;
> +	int ret;
> +
> +	bitwidth = snd_pcm_format_width(params_format(params));
> +	if (bitwidth < 0) {
> +		dev_err(card->dev, "invalid bit width: %d\n",
> bitwidth);
> +		return bitwidth;
> +	}
> +
> +	ret = snd_soc_dai_set_tdm_slot(codec_dai, 0x00, 0x0, 0x2,
> bitwidth);
> +	if (ret) {
> +		dev_err(card->dev, "failed to set tdm slot\n");
> +		return ret;
> +	}
> +
> +	ret = snd_soc_dai_set_pll(codec_dai, RT5682_PLL1,
> RT5682_PLL1_S_BCLK1,
> +				  rate * 32, rate * 512);
> +	if (ret) {
> +		dev_err(card->dev, "failed to set pll\n");
> +		return ret;
> +	}
> +
> +	ret = snd_soc_dai_set_sysclk(codec_dai, RT5682_SCLK_S_PLL1,
> +				     rate * 512, SND_SOC_CLOCK_IN);
> +	if (ret) {
> +		dev_err(card->dev, "failed to set sysclk\n");
> +		return ret;
> +	}
> +
> +	return snd_soc_dai_set_sysclk(cpu_dai, 0, rate * 128,
> +				      SND_SOC_CLOCK_OUT);
> +}
> +
> +static const struct snd_soc_ops mt8188_rt5682s_i2s_ops = {
> +	.hw_params = mt8186_rt5682s_i2s_hw_params,
> +};
> +
>  static int mt8188_sof_be_hw_params(struct snd_pcm_substream
> *substream,
>  				   struct snd_pcm_hw_params *params)
>  {
> @@ -1148,7 +1271,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) {
> +	if (card_data->quirk & (NAU8825_HS_PRESENT |
> RT5682S_HS_PRESENT)) {
>  		struct snd_soc_dapm_widget *w, *next_w;
>  
>  		for_each_card_widgets_safe(card, w, next_w) {
> @@ -1190,6 +1313,7 @@ static int mt8188_mt6359_dev_probe(struct
> platform_device *pdev)
>  	struct snd_soc_dai_link *dai_link;
>  	bool init_mt6359 = false;
>  	bool init_nau8825 = false;
> +	bool init_rt5682s = false;
>  	bool init_max98390 = false;
>  	bool init_dumb = false;
>  	int ret, i;
> @@ -1306,6 +1430,13 @@ static int mt8188_mt6359_dev_probe(struct
> platform_device *pdev)
>  					dai_link->exit =
> mt8188_nau8825_codec_exit;
>  					init_nau8825 = true;
>  				}
> +			} else if (!strcmp(dai_link->codecs->dai_name,
> RT5682S_CODEC_DAI)) {
> +				dai_link->ops =
> &mt8188_rt5682s_i2s_ops;
> +				if (!init_rt5682s) {
> +					dai_link->init =
> mt8188_rt5682s_codec_init;
> +					dai_link->exit =
> mt8188_rt5682s_codec_exit;
> +					init_rt5682s = true;
> +				}
>  			} else {
>  				if (strcmp(dai_link->codecs->dai_name,
> "snd-soc-dummy-dai")) {
>  					if (!init_dumb) {
> @@ -1343,9 +1474,15 @@ static struct mt8188_card_data
> mt8188_nau8825_card = {
>  	.quirk = NAU8825_HS_PRESENT,
>  };
>  
> +static struct mt8188_card_data mt8188_rt5682s_card = {
> +	.name = "mt8188_rt5682s",
> +	.quirk = RT5682S_HS_PRESENT,
> +};
> +
>  static const struct of_device_id mt8188_mt6359_dt_match[] = {
>  	{ .compatible = "mediatek,mt8188-mt6359-evb", .data =
> &mt8188_evb_card, },
>  	{ .compatible = "mediatek,mt8188-nau8825", .data =
> &mt8188_nau8825_card, },
> +	{ .compatible = "mediatek,mt8188-rt5682s", .data =
> &mt8188_rt5682s_card, },
>  	{ /* sentinel */ },
>  };
>  MODULE_DEVICE_TABLE(of, mt8188_mt6359_dt_match);
> -- 
> 2.17.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

      reply	other threads:[~2023-09-27  2:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-26  4:08 [v2 0/2] ASoC: mediatek: mt8188-mt6359: add rt5682s support xiazhengqiao
2023-09-26  4:09 ` [v2 1/2] ASoC: dt-bindings: mediatek,mt8188-mt6359: add RT5682S support xiazhengqiao
2023-09-26  4:09 ` [v2 2/2] ASoC: mediatek: mt8188-mt6359: add rt5682s support xiazhengqiao
2023-09-27  2:48   ` Trevor Wu (吳文良) [this message]

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=cb9202ded221ad13eaa2acf917d43b27968ef31a.camel@mediatek.com \
    --to=trevor.wu@mediatek.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matthias.bgg@gmail.com \
    --cc=perex@perex.cz \
    --cc=robh+dt@kernel.org \
    --cc=xiazhengqiao@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;
as well as URLs for NNTP newsgroup(s).