From: "Trevor Wu (吳文良)" <Trevor.Wu@mediatek.com>
To: "robh+dt@kernel.org" <robh+dt@kernel.org>,
"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
"p.zabel@pengutronix.de" <p.zabel@pengutronix.de>,
"angelogioacchino.delregno@collabora.com"
<angelogioacchino.delregno@collabora.com>,
"broonie@kernel.org" <broonie@kernel.org>,
"tiwai@suse.com" <tiwai@suse.com>
Cc: "linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-mediatek@lists.infradead.org"
<linux-mediatek@lists.infradead.org>,
"alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>
Subject: Re: [PATCH 04/12] ASoC: mediatek: mt8188: support adda in platform driver
Date: Wed, 5 Oct 2022 07:14:42 +0000 [thread overview]
Message-ID: <0c9b3c1f64438c17bfe520ae11ff52d71c1df600.camel@mediatek.com> (raw)
In-Reply-To: <0d017f04-cad3-fa76-5d2d-daaa052f2e62@collabora.com>
On Tue, 2022-10-04 at 11:37 +0200, AngeloGioacchino Del Regno wrote:
> Il 30/09/22 16:56, Trevor Wu ha scritto:
> >
..snip..
>
> > +
> > +static int mt8188_adda_mtkaif_init(struct mtk_base_afe *afe)
> > +{
> > + struct mt8188_afe_private *afe_priv = afe->platform_priv;
> > + struct mtkaif_param *param = &afe_priv->mtkaif_params;
> > + int delay_data;
> > + int delay_cycle;
> > + unsigned int mask = 0;
> > + unsigned int val = 0;
> > +
> > + /* set rx protocol 2 & mtkaif_rxif_clkinv_adc inverse */
> > + mask = (MTKAIF_RXIF_CLKINV_ADC | MTKAIF_RXIF_PROTOCOL2);
> > + val = (MTKAIF_RXIF_CLKINV_ADC | MTKAIF_RXIF_PROTOCOL2);
> > +
> > + regmap_update_bits(afe->regmap, AFE_ADDA_MTKAIF_CFG0, mask,
> > val);
>
> This should be
> regmap_set_bits(afe->regmap, AFE_ADDA_MTKAIF_CFG0,
> MTKAIF_RXIF_CLKINV_ADC |
> MTKAIF_RXIF_PROTOCOL2);
OK. I will replace all similar usages in V2.
> > +
> > + mask = RG_RX_PROTOCOL2;
> > + val = RG_RX_PROTOCOL2;
> > + regmap_update_bits(afe->regmap, AFE_AUD_PAD_TOP, mask, val);
>
> regmap_set_bits() again
>
> > +
> > + if (!param->mtkaif_calibration_ok) {
> > + dev_info(afe->dev, "%s(), calibration
> > fail\n", __func__);
> > + return 0;
> > + }
> > +
> > + /* set delay for ch1, ch2 */
> > + if (param->mtkaif_phase_cycle[MT8188_MTKAIF_MISO_0] >=
> > + param->mtkaif_phase_cycle[MT8188_MTKAIF_MISO_1]) {
> > + delay_data = DELAY_DATA_MISO1;
> > + delay_cycle =
> > + param->mtkaif_phase_cycle[MT8188_MTKAIF_MISO_0]
> > -
> > + param-
> > >mtkaif_phase_cycle[MT8188_MTKAIF_MISO_1];
> > + } else {
> > + delay_data = DELAY_DATA_MISO0;
> > + delay_cycle =
> > + param->mtkaif_phase_cycle[MT8188_MTKAIF_MISO_1]
> > -
> > + param-
> > >mtkaif_phase_cycle[MT8188_MTKAIF_MISO_0];
> > + }
> > +
> > + val = 0;
> > + mask = (MTKAIF_RXIF_DELAY_DATA | MTKAIF_RXIF_DELAY_CYCLE_MASK);
> > + val |= MTKAIF_RXIF_DELAY_CYCLE(delay_cycle) &
> > + MTKAIF_RXIF_DELAY_CYCLE_MASK;
>
> val = FIELD_PREP(MTKAIF_RXIF_DELAY_CYCLE_MASK, delay_cycle);
>
> > + val |= delay_data << MTKAIF_RXIF_DELAY_DATA_SHIFT;
>
> val |= FIELD_PREP(MTKAIF_RXIF_DELAY_DATA, delay_data);
>
> Can you please use bitfield access macros across the entire file (and
> the others)?
> This will both increase human readability and add compile-time checks
> on register
> fields.
>
Thanks for your suggestion.
compile-time checks are helpful to find some unexpected errors.
I will update it in V2.
> > + regmap_update_bits(afe->regmap, AFE_ADDA_MTKAIF_RX_CFG2, mask,
> > val);
> > +
> > + return 0;
> > +}
> > +
> > +static int mtk_adda_mtkaif_cfg_event(struct snd_soc_dapm_widget
> > *w,
> > + struct snd_kcontrol *kcontrol,
> > + int event)
> > +{
> > + struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w-
> > >dapm);
> > + struct mtk_base_afe *afe =
> > snd_soc_component_get_drvdata(cmpnt);
> > +
> > + dev_dbg(afe->dev, "%s(), name %s, event 0x%x\n",
> > + __func__, w->name, event);
> > +
> > + switch (event) {
> > + case SND_SOC_DAPM_PRE_PMU:
> > + mt8188_adda_mtkaif_init(afe);
> > + break;
> > + default:
> > + break;
> > + }
> > +
> > + return 0;
> > +}
> > +
> > +static int mtk_adda_dl_event(struct snd_soc_dapm_widget *w,
> > + struct snd_kcontrol *kcontrol,
> > + int event)
> > +{
> > + struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w-
> > >dapm);
> > + struct mtk_base_afe *afe =
> > snd_soc_component_get_drvdata(cmpnt);
> > +
> > + dev_dbg(afe->dev, "%s(), name %s, event 0x%x\n",
> > + __func__, w->name, event);
> > +
> > + switch (event) {
> > + case SND_SOC_DAPM_POST_PMD:
> > + /* should delayed 1/fs(smallest is 8k) = 125us before
> > afe off */
> > + usleep_range(125, 135);
> > + break;
> > + default:
> > + break;
> > + }
> > +
> > + return 0;
> > +}
> > +
> > +static void mtk_adda_ul_mictype(struct mtk_base_afe *afe, bool
> > dmic)
> > +{
> > + unsigned int reg = AFE_ADDA_UL_SRC_CON0;
> > + unsigned int val = 0;
> > + unsigned int mask;
> > +
> > + mask = (UL_SDM3_LEVEL_CTL | UL_MODE_3P25M_CH1_CTL |
> > + UL_MODE_3P25M_CH2_CTL);
>
> val = (UL_SDM3_LEVEL_CTL | UL_MODE_3P25M_CH1_CTL |
> UL_MODE_3P25M_CH2_CTL);
>
> > +
> > + /* turn on dmic, ch1, ch2 */
> > + if (dmic)
>
> regmap_set_bits(afe->regmap, reg, val);
> else
> regmap_clear_bits(afe->regmap, reg, val);
>
>
OK. I will update this part in V2.
> > + val = mask;
> > +
> > + regmap_update_bits(afe->regmap, reg, mask, val);
> > +}
> > +
>
> ..snip..
>
> > +
> > +static int mtk_afe_adc_hires_connect(struct snd_soc_dapm_widget
> > *source,
> > + struct snd_soc_dapm_widget *sink)
> > +{
> > + struct snd_soc_dapm_widget *w = source;
> > + struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w-
> > >dapm);
> > + struct mtk_base_afe *afe =
> > snd_soc_component_get_drvdata(cmpnt);
> > + struct mt8188_afe_private *afe_priv = afe->platform_priv;
> > + struct mtk_dai_adda_priv *adda_priv;
> > +
> > + adda_priv = afe_priv->dai_priv[MT8188_AFE_IO_ADDA];
> > +
> > + if (!adda_priv) {
> > + dev_err(afe->dev, "%s adda_priv == NULL", __func__);
> > + return 0;
>
> return -EINVAL?
>
dapm_supply_check_power doesn't handled error return value, so it seems
to be better to keep return 0 here.
> > + }
> > +
> > + return (adda_priv->ul_rate > ADDA_HIRES_THRES) ? 1 : 0;
>
> return !!(adda_priv->ul_rate > ADDA_HIRES_THRES);
>
OK. I will update it in V2.
> > +}
> > +
> > +static int mtk_afe_dac_hires_connect(struct snd_soc_dapm_widget
> > *source,
> > + struct snd_soc_dapm_widget *sink)
> > +{
> > + struct snd_soc_dapm_widget *w = source;
> > + struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w-
> > >dapm);
> > + struct mtk_base_afe *afe =
> > snd_soc_component_get_drvdata(cmpnt);
> > + struct mt8188_afe_private *afe_priv = afe->platform_priv;
> > + struct mtk_dai_adda_priv *adda_priv;
> > +
> > + adda_priv = afe_priv->dai_priv[MT8188_AFE_IO_ADDA];
> > +
> > + if (!adda_priv) {
> > + dev_err(afe->dev, "%s adda_priv == NULL", __func__);
> > + return 0;
>
> same here
>
> > + }
> > +
> > + return (adda_priv->dl_rate > ADDA_HIRES_THRES) ? 1 : 0;
> > +}
> > +
>
> ..snip..
>
> Regards,
> Angelo
>
>
next prev parent reply other threads:[~2022-10-05 7:14 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-30 14:56 [PATCH 00/12] ASoC: mediatek: Add support for MT8188 SoC Trevor Wu
2022-09-30 14:56 ` [PATCH 01/12] ASoC: mediatek: common: add SMC ops ID Trevor Wu
2022-09-30 14:56 ` [PATCH 02/12] ASoC: mediatek: mt8188: add common header Trevor Wu
2022-09-30 14:56 ` [PATCH 03/12] ASoC: mediatek: mt8188: support audsys clock Trevor Wu
2022-09-30 14:56 ` [PATCH 04/12] ASoC: mediatek: mt8188: support adda in platform driver Trevor Wu
2022-10-04 9:37 ` AngeloGioacchino Del Regno
2022-10-05 7:14 ` Trevor Wu (吳文良) [this message]
2022-09-30 14:56 ` [PATCH 05/12] ASoC: mediatek: mt8188: support etdm " Trevor Wu
2022-09-30 14:56 ` [PATCH 06/12] ASoC: mediatek: mt8188: support pcmif " Trevor Wu
2022-09-30 14:56 ` [PATCH 07/12] ASoC: mediatek: mt8188: support audio clock control Trevor Wu
2022-09-30 14:56 ` [PATCH 08/12] ASoC: mediatek: mt8188: add platform driver Trevor Wu
2022-10-01 9:17 ` kernel test robot
2022-10-05 6:50 ` Trevor Wu (吳文良)
2022-10-05 10:59 ` Mark Brown
2022-10-06 3:13 ` Trevor Wu (吳文良)
2022-10-04 9:36 ` AngeloGioacchino Del Regno
2022-10-06 2:48 ` Trevor Wu (吳文良)
2022-10-15 2:27 ` Trevor Wu (吳文良)
2022-09-30 14:56 ` [PATCH 09/12] ASoC: mediatek: mt8188: add control for timing select Trevor Wu
2022-09-30 14:56 ` [PATCH 10/12] dt-bindings: mediatek: mt8188: add audio afe document Trevor Wu
2022-09-30 22:05 ` Rob Herring
2022-10-05 3:57 ` Trevor Wu (吳文良)
2022-10-28 23:46 ` Krzysztof Kozlowski
2022-10-03 16:30 ` Rob Herring
2022-10-05 10:12 ` Trevor Wu (吳文良)
2022-09-30 14:57 ` [PATCH 11/12] ASoC: mediatek: mt8188: add machine driver with mt6359 Trevor Wu
2022-09-30 14:57 ` [PATCH 12/12] dt-bindings: mediatek: mt8188: add mt8188-mt6359 document Trevor Wu
2022-10-03 16:38 ` Rob Herring
2022-10-06 2:38 ` Trevor Wu (吳文良)
2022-10-21 8:54 ` Trevor Wu (吳文良)
2022-10-21 8:58 ` Trevor Wu (吳文良)
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=0c9b3c1f64438c17bfe520ae11ff52d71c1df600.camel@mediatek.com \
--to=trevor.wu@mediatek.com \
--cc=alsa-devel@alsa-project.org \
--cc=angelogioacchino.delregno@collabora.com \
--cc=broonie@kernel.org \
--cc=devicetree@vger.kernel.org \
--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 \
/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
all inboxes | Powered by JetHome®