devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Jiaxin Yu <jiaxin.yu@mediatek.com>
Cc: lgirdwood@gmail.com, tiwai@suse.com, robh+dt@kernel.org,
	matthias.bgg@gmail.com, perex@perex.cz, p.zabel@pengutronix.de,
	geert+renesas@glider.be, trevor.wu@mediatek.com,
	tzungbi@google.com, zhangqilong3@huawei.com,
	alsa-devel@alsa-project.org, devicetree@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 03/15] ASoC: mediatek: mt8186: support adda in platform driver
Date: Fri, 11 Feb 2022 15:10:54 +0000	[thread overview]
Message-ID: <YgZ8fnvd4/Mxm3wp@sirena.org.uk> (raw)
In-Reply-To: <20220211103818.8266-4-jiaxin.yu@mediatek.com>

[-- Attachment #1: Type: text/plain, Size: 3230 bytes --]

On Fri, Feb 11, 2022 at 06:38:06PM +0800, Jiaxin Yu wrote:

This looks pretty good, there's some issues below but they're all very
minor, mostly stylistic things rather than anything substantial.

> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + *  MediaTek ALSA SoC Audio DAI ADDA Control
> + *
> + *  Copyright (c) 2022 MediaTek Inc.
> + *  Author: Jiaxin Yu <jiaxin.yu@mediatek.com>
> + */

Please make the entire comment a C++ one so things look more
intentional.

> +static int mtk_adda_ul_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);
> +	struct mt8186_afe_private *afe_priv = afe->platform_priv;
> +	int mtkaif_dmic = afe_priv->mtkaif_dmic;
> +
> +	dev_info(afe->dev, "%s(), name %s, event 0x%x, mtkaif_dmic %d\n",
> +		 __func__, w->name, event, mtkaif_dmic);

This should be dev_dbg() at most, otherwise the logs will get very noisy
(but note that there are trace points in the core which cover this).
There's a bunch of other dev_info() calls like this on DAPM events.

> +		if (afe_priv->mtkaif_protocol == MTKAIF_PROTOCOL_2_CLK_P2)
> +			regmap_write(afe->regmap, AFE_AUD_PAD_TOP, 0x38);
> +		else if (afe_priv->mtkaif_protocol == MTKAIF_PROTOCOL_2)
> +			regmap_write(afe->regmap, AFE_AUD_PAD_TOP, 0x30);
> +		else
> +			regmap_write(afe->regmap, AFE_AUD_PAD_TOP, 0x30);

This could be more clearly written as a switch statement.

> +			if (strcmp(w->name, "ADDA_MTKAIF_CFG") == 0) {
> +				if (afe_priv->mtkaif_chosen_phase[0] < 0 &&
> +				    afe_priv->mtkaif_chosen_phase[1] < 0) {
> +					dev_info(afe->dev,
> +						 "%s(), calib fail mtkaif_chosen_phase[0/1]:%d/%d\n",
> +						 __func__,

Should this be a dev_err() given that the calibration failed?

> +/* mtkaif dmic */
> +static const char * const mt8186_adda_off_on_str[] = {
> +	"Off", "On"
> +};
> +
> +static const struct soc_enum mt8186_adda_enum[] = {
> +	SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(mt8186_adda_off_on_str),
> +			    mt8186_adda_off_on_str),
> +};

This is a simple on/off control so should be a standard numeric control
with a name ending in Switch to help UIs handle it properly.

> +static int mt8186_adda_dmic_set(struct snd_kcontrol *kcontrol,
> +				struct snd_ctl_elem_value *ucontrol)
> +{
> +	struct snd_soc_component *cmpnt = snd_soc_kcontrol_component(kcontrol);
> +	struct mtk_base_afe *afe = snd_soc_component_get_drvdata(cmpnt);
> +	struct mt8186_afe_private *afe_priv = afe->platform_priv;
> +	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
> +	int dmic_on;
> +
> +	if (ucontrol->value.enumerated.item[0] >= e->items)
> +		return -EINVAL;
> +
> +	dmic_on = ucontrol->value.integer.value[0];
> +
> +	dev_info(afe->dev, "%s(), kcontrol name %s, dmic_on %d\n",
> +		 __func__, kcontrol->id.name, dmic_on);
> +
> +	afe_priv->mtkaif_dmic = dmic_on;
> +	return 0;

This should return 1 if the value changed so an event is generated for
userspace.  You might want to run the mixer-test kselftest (ideally the
version that's in -next as there were a few bits added very recently),
it should detect issues like this.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2022-02-11 15:11 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-11 10:38 [PATCH 00/15] ASoC: mediatek: Add support for MT8186 SoC Jiaxin Yu
2022-02-11 10:38 ` [PATCH 01/15] ASoC: mediatek: mt6366: add codec driver Jiaxin Yu
2022-02-11 14:54   ` Mark Brown
2022-02-11 10:38 ` [PATCH 02/15] ASoC: mediatek: mt8186: support audsys clock control Jiaxin Yu
2022-02-11 10:38 ` [PATCH 03/15] ASoC: mediatek: mt8186: support adda in platform driver Jiaxin Yu
2022-02-11 15:10   ` Mark Brown [this message]
2022-02-11 10:38 ` [PATCH 04/15] ASoC: mediatek: mt8186: support hostless " Jiaxin Yu
2022-02-11 10:38 ` [PATCH 05/15] ASoC: mediatek: mt8186: support hw gain " Jiaxin Yu
2022-02-11 15:15   ` Mark Brown
2022-02-17 14:05     ` Jiaxin Yu
2022-02-11 10:38 ` [PATCH 06/15] ASoC: mediatek: mt8186: support i2s " Jiaxin Yu
2022-02-11 10:38 ` [PATCH 07/15] ASoC: mediatek: mt8186: support pcm " Jiaxin Yu
2022-02-11 10:38 ` [PATCH 08/15] ASoC: mediatek: mt8186: support src " Jiaxin Yu
2022-02-11 10:38 ` [PATCH 09/15] ASoC: mediatek: mt8186: support tdm " Jiaxin Yu
2022-02-11 15:24   ` Mark Brown
2022-02-17 13:59     ` Jiaxin Yu
2022-02-11 10:38 ` [PATCH 10/15] ASoC: mediatek: mt8186: add " Jiaxin Yu
2022-02-11 16:12   ` Mark Brown
2022-02-17 13:51     ` Jiaxin Yu
2022-02-11 10:38 ` [PATCH 11/15] dt-bindings: mediatek: mt8186: add audio afe document Jiaxin Yu
2022-02-11 12:12   ` Rob Herring
2022-02-11 10:38 ` [PATCH 12/15] ASoC: mediatek: mt8186: add machine driver with mt6366, da7219 and max98357 Jiaxin Yu
2022-02-11 10:38 ` [PATCH 13/15] dt-bindings: mediatek: mt8186: add mt8186-mt6366-da7219-max98357 document Jiaxin Yu
2022-02-11 10:38 ` [PATCH 14/15] ASoC: mediatek: mt8186: add machine driver with mt6366, rt1019 and rt5682 Jiaxin Yu
2022-02-11 10:38 ` [PATCH 15/15] dt-bindings: mediatek: mt8186: add mt8186-mt6366-rt1019-rt5682 document Jiaxin Yu
2022-02-11 16:14 ` [PATCH 00/15] ASoC: mediatek: Add support for MT8186 SoC Mark Brown
2022-02-12  7:18   ` 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=YgZ8fnvd4/Mxm3wp@sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=devicetree@vger.kernel.org \
    --cc=geert+renesas@glider.be \
    --cc=jiaxin.yu@mediatek.com \
    --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=perex@perex.cz \
    --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;
as well as URLs for NNTP newsgroup(s).