From: Jiaxin Yu <jiaxin.yu@mediatek.com>
To: AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>, <broonie@kernel.org>
Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org,
geert+renesas@glider.be, linux-kernel@vger.kernel.org,
zhangqilong3@huawei.com, tiwai@suse.com, lgirdwood@gmail.com,
tzungbi@google.com, robh+dt@kernel.org,
linux-mediatek@lists.infradead.org, trevor.wu@mediatek.com,
p.zabel@pengutronix.de, matthias.bgg@gmail.com,
aaronyu@google.com, linux-arm-kernel@lists.infradead.org
Subject: Re: [v2 09/17] ASoC: mediatek: mt8186: support tdm in platform driver
Date: Fri, 4 Mar 2022 01:39:05 +0800 [thread overview]
Message-ID: <a8edf274beffbdbadec39d7283ebbab5699ef4d4.camel@mediatek.com> (raw)
In-Reply-To: <6bc78592-36c0-8462-f4f8-ad9e04a13da6@collabora.com>
On Thu, 2022-03-03 at 16:08 +0100, AngeloGioacchino Del Regno wrote:
> Il 03/03/22 15:10, Jiaxin Yu ha scritto:
> > On Fri, 2022-02-18 at 15:54 +0100, AngeloGioacchino Del Regno
> > wrote:
> > > Il 17/02/22 14:41, Jiaxin Yu ha scritto:
> > > > This patch adds mt8186 tdm dai driver.
> > > >
> > > > Signed-off-by: Jiaxin Yu <jiaxin.yu@mediatek.com>
> > > > ---
> > > > sound/soc/mediatek/mt8186/mt8186-dai-tdm.c | 713
> > > > +++++++++++++++++++++
> > > > 1 file changed, 713 insertions(+)
> > > > create mode 100644 sound/soc/mediatek/mt8186/mt8186-dai-
> > > > tdm.c
> > > >
> > > > diff --git a/sound/soc/mediatek/mt8186/mt8186-dai-tdm.c
> > > > b/sound/soc/mediatek/mt8186/mt8186-dai-tdm.c
> > > > new file mode 100644
> > > > index 000000000000..28dd3661f0e0
> > > > --- /dev/null
> > > > +++ b/sound/soc/mediatek/mt8186/mt8186-dai-tdm.c
> > > > @@ -0,0 +1,713 @@
> > > > +// SPDX-License-Identifier: GPL-2.0
> > > > +//
> > > > +// MediaTek ALSA SoC Audio DAI TDM Control
> > > > +//
> > > > +// Copyright (c) 2022 MediaTek Inc.
> > > > +// Author: Jiaxin Yu <jiaxin.yu@mediatek.com>
> > > > +
>
> ..snip..
>
> > > > +
> > > > +static int mtk_dai_tdm_hw_params(struct snd_pcm_substream
> > > > *substream,
> > > > + struct snd_pcm_hw_params
> > > > *params,
> > > > + struct snd_soc_dai *dai)
> > > > +{
> > > > + struct mtk_base_afe *afe =
> > > > snd_soc_dai_get_drvdata(dai);
> > > > + struct mt8186_afe_private *afe_priv = afe-
> > > > >platform_priv;
> > > > + int tdm_id = dai->id;
> > > > + struct mtk_afe_tdm_priv *tdm_priv = afe_priv-
> > > > >dai_priv[tdm_id];
> > > > + unsigned int tdm_mode = tdm_priv->tdm_mode;
> > > > + unsigned int data_mode = tdm_priv->data_mode;
> > > > + unsigned int rate = params_rate(params);
> > > > + unsigned int channels = params_channels(params);
> > > > + snd_pcm_format_t format = params_format(params);
> > > > + unsigned int bit_width =
> > > > + snd_pcm_format_physical_width(format);
> > > > + unsigned int tdm_channels = (data_mode ==
> > > > TDM_DATA_ONE_PIN) ?
> > > > + get_tdm_ch_per_sdata(tdm_mode, channels) : 2;
> > > > + unsigned int lrck_width =
> > > > + get_tdm_lrck_width(format, tdm_mode);
> > > > + unsigned int tdm_con = 0;
> > > > + bool slave_mode = tdm_priv->slave_mode;
> > > > + bool lrck_inv = tdm_priv->lck_invert;
> > > > + bool bck_inv = tdm_priv->bck_invert;
> > > > + unsigned int ctrl_reg;
> > > > + unsigned int ctrl_mask;
> > > > + unsigned int tran_rate;
> > > > + unsigned int tran_relatch_rate;
> > > > +
> > > > + if (tdm_priv)
> > > > + tdm_priv->rate = rate;
> > > > + else
> > > > + dev_info(afe->dev, "%s(), tdm_priv == NULL",
> > > > __func__);
> > > > +
> > > > + tran_rate = mt8186_rate_transform(afe->dev, rate, dai-
> > > > >id);
> > > > + tran_relatch_rate =
> > > > mt8186_tdm_relatch_rate_transform(afe->dev,
> > > > rate);
> > > > +
> > > > + /* calculate mclk_rate, if not set explicitly */
> > > > + if (!tdm_priv->mclk_rate) {
> > > > + tdm_priv->mclk_rate = rate * tdm_priv-
> > > > >mclk_multiple;
> > > > + mtk_dai_tdm_cal_mclk(afe,
> > > > + tdm_priv,
> > > > + tdm_priv->mclk_rate);
> > > > + }
> > > > +
> > > > + /* ETDM_IN1_CON0 */
> > > > + tdm_con |= slave_mode <<
> > > > ETDM_IN1_CON0_REG_SLAVE_MODE_SFT;
> > > > + tdm_con |= tdm_mode << ETDM_IN1_CON0_REG_FMT_SFT;
> > > > + tdm_con |= (bit_width - 1) <<
> > > > ETDM_IN1_CON0_REG_BIT_LENGTH_SFT;
> > > > + tdm_con |= (bit_width - 1) <<
> > > > ETDM_IN1_CON0_REG_WORD_LENGTH_SFT;
> > > > + tdm_con |= (tdm_channels - 1) <<
> > > > ETDM_IN1_CON0_REG_CH_NUM_SFT;
> > > > + /* default disable sync mode */
> > > > + tdm_con |= 0 << ETDM_IN1_CON0_REG_SYNC_MODE_SFT;
> > >
> > > 0 << (anything) == 0
> > >
> > > (number |= 0) == number
> > >
> > > Is this a mistake, or are you really doing nothing here?
> > >
> >
> > No, this is just to emphasize the need to set this bit to 0.
> > It really do nothing here, just link a reminder.
> > Can I keep this sentence?
>
> If, in your judgement, it is very important to have a reminder about
> that
> bit having to be unset, then add a comment in the code saying so.
> Don't simply comment out the statement as it is.
>
> A good way would be something like
> /* sync mode bit has to be unset because this that reason, otherwise
> X happens */
I see, thanks for your kind advise.
>
> > >
> > > > + /* relatch fix to h26m */
> > > > + tdm_con |= 0 <<
> > > > ETDM_IN1_CON0_REG_RELATCH_1X_EN_SEL_DOMAIN_SFT;
> > > > +
> > > > + ctrl_reg = ETDM_IN1_CON0;
> > > > + ctrl_mask = ETDM_IN_CON0_CTRL_MASK;
> > > > + regmap_update_bits(afe->regmap, ctrl_reg, ctrl_mask,
> > > > tdm_con);
> > > > +
> > > > + /* ETDM_IN1_CON1 */
> > > > + tdm_con = 0;
> > > > + tdm_con |= 0 << ETDM_IN1_CON1_REG_LRCK_AUTO_MODE_SFT;
> > > > + tdm_con |= 1 << ETDM_IN1_CON1_PINMUX_MCLK_CTRL_OE_SFT;
> > > > + tdm_con |= (lrck_width - 1) <<
> > > > ETDM_IN1_CON1_REG_LRCK_WIDTH_SFT;
> > > > +
> > > > + ctrl_reg = ETDM_IN1_CON1;
> > > > + ctrl_mask = ETDM_IN_CON1_CTRL_MASK;
> > > > + regmap_update_bits(afe->regmap, ctrl_reg, ctrl_mask,
> > > > tdm_con);
> > >
> > > You don't need the ctrl_reg, nor ctrl_mask variables...
> >
> > I was trying to avoid a line of more than 80 words, so I shortened
> > the
> > number of words through variables.
> >
>
> Yes, I know, I did understand what you were trying to do...
> ...but it's fine to go past 80: in this case this would be 88
> columns,
> which is still ok to have!
>
> And note, this is the case with all of similar calls present in this
> function,
> that's why I said that you don't need these two variables! :)
>
> Thank you,
> Angelo
Ok, I got it. This function will be corrected in the next version.
Thank you.
Jiaxin.Yu
>
>
next prev parent reply other threads:[~2022-03-03 17:41 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-17 13:41 [v2 00/17] ASoC: mediatek: Add support for MT8186 SoC Jiaxin Yu
2022-02-17 13:41 ` [v2 01/17] ASoC: mediatek: mt6366: add codec driver Jiaxin Yu
2022-02-18 14:54 ` AngeloGioacchino Del Regno
2022-03-05 4:24 ` Jiaxin Yu
2022-03-07 9:07 ` AngeloGioacchino Del Regno
2022-02-17 13:41 ` [v2 02/17] ASoC: mediatek: mt8186: support audsys clock control Jiaxin Yu
2022-02-17 13:41 ` [v2 03/17] ASoC: mediatek: mt8186: support adda in platform driver Jiaxin Yu
2022-02-18 14:54 ` AngeloGioacchino Del Regno
2022-03-05 10:49 ` Jiaxin Yu
2022-03-07 9:25 ` AngeloGioacchino Del Regno
2022-02-17 13:41 ` [v2 04/17] ASoC: mediatek: mt8186: support hostless " Jiaxin Yu
2022-02-18 14:54 ` AngeloGioacchino Del Regno
2022-02-17 13:41 ` [v2 05/17] ASoC: mediatek: mt8186: support hw gain " Jiaxin Yu
2022-02-18 14:54 ` AngeloGioacchino Del Regno
2022-02-17 13:41 ` [v2 06/17] ASoC: mediatek: mt8186: support i2s " Jiaxin Yu
2022-02-18 14:54 ` AngeloGioacchino Del Regno
2022-03-05 11:07 ` Jiaxin Yu
2022-02-17 13:41 ` [v2 07/17] ASoC: mediatek: mt8186: support pcm " Jiaxin Yu
2022-02-18 14:54 ` AngeloGioacchino Del Regno
2022-03-05 11:12 ` Jiaxin Yu
2022-02-17 13:41 ` [v2 08/17] ASoC: mediatek: mt8186: support src " Jiaxin Yu
2022-02-18 14:54 ` AngeloGioacchino Del Regno
2022-02-17 13:41 ` [v2 09/17] ASoC: mediatek: mt8186: support tdm " Jiaxin Yu
2022-02-18 14:54 ` AngeloGioacchino Del Regno
2022-03-03 14:10 ` Jiaxin Yu
2022-03-03 15:08 ` AngeloGioacchino Del Regno
2022-03-03 17:39 ` Jiaxin Yu [this message]
2022-02-17 13:41 ` [v2 10/17] ASoC: mediatek: mt8186: support audio clock control " Jiaxin Yu
2022-02-18 14:54 ` AngeloGioacchino Del Regno
2022-03-03 15:16 ` Jiaxin Yu
2022-03-03 15:17 ` Jiaxin Yu
2022-02-17 13:41 ` [v2 11/17] ASoC: mediatek: mt8186: support gpio " Jiaxin Yu
2022-02-18 14:54 ` AngeloGioacchino Del Regno
2022-03-03 15:30 ` Jiaxin Yu
2022-02-17 13:42 ` [v2 12/17] ASoC: mediatek: mt8186: add " Jiaxin Yu
2022-02-18 14:54 ` AngeloGioacchino Del Regno
2022-03-05 9:10 ` Jiaxin Yu
2022-02-17 13:42 ` [v2 13/17] dt-bindings: mediatek: mt8186: add audio afe document Jiaxin Yu
2022-02-25 16:43 ` Rob Herring
2022-02-17 13:42 ` [v2 14/17] ASoC: mediatek: mt8186: add machine driver with mt6366, da7219 and max98357 Jiaxin Yu
2022-02-18 14:54 ` AngeloGioacchino Del Regno
2022-03-05 8:58 ` Jiaxin Yu
2022-03-07 9:14 ` AngeloGioacchino Del Regno
2022-02-17 13:42 ` [v2 15/17] dt-bindings: mediatek: mt8186: add mt8186-mt6366-da7219-max98357 document Jiaxin Yu
2022-02-17 13:42 ` [v2 16/17] ASoC: mediatek: mt8186: add machine driver with mt6366, rt1019 and rt5682s Jiaxin Yu
2022-02-17 13:42 ` [v2 17/17] dt-bindings: mediatek: mt8186: add mt8186-mt6366-rt1019-rt5682s document Jiaxin Yu
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=a8edf274beffbdbadec39d7283ebbab5699ef4d4.camel@mediatek.com \
--to=jiaxin.yu@mediatek.com \
--cc=aaronyu@google.com \
--cc=alsa-devel@alsa-project.org \
--cc=angelogioacchino.delregno@collabora.com \
--cc=broonie@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=geert+renesas@glider.be \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=p.zabel@pengutronix.de \
--cc=robh+dt@kernel.org \
--cc=tiwai@suse.com \
--cc=trevor.wu@mediatek.com \
--cc=tzungbi@google.com \
--cc=zhangqilong3@huawei.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