All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Ryan Lee <ryan.lee.analog@gmail.com>
Cc: lgirdwood@gmail.com, robh+dt@kernel.org, krzk+dt@kernel.org,
	perex@perex.cz, tiwai@suse.com, srinivas.kandagatla@linaro.org,
	ckeepax@opensource.cirrus.com, tanureal@opensource.cirrus.com,
	cy_huang@richtek.com, pierre-louis.bossart@linux.intel.com,
	drhodes@opensource.cirrus.com, pbrobinson@gmail.com,
	hdegoede@redhat.com, lukas.bulwahn@gmail.com,
	stephan@gerhold.net, arnd@arndb.de, alsa-devel@alsa-project.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	ryans.lee@analog.com
Subject: Re: [PATCH 2/2] ASoC: max98396: add amplifier driver
Date: Wed, 20 Apr 2022 17:17:50 +0100	[thread overview]
Message-ID: <YmAyLuZIT1zYfNeA@sirena.org.uk> (raw)
In-Reply-To: <20220416004024.210418-2-ryan.lee.analog@gmail.com>

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

On Fri, Apr 15, 2022 at 05:40:24PM -0700, Ryan Lee wrote:

This looks mostly good - some issues below but nothing structural.

> +	switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
> +	case SND_SOC_DAIFMT_NB_NF:
> +	case SND_SOC_DAIFMT_NB_IF:
> +		break;

One of these must be wrong - the device needs to know if it's handling a
normal or inverted frame clock, otherwise the audio will be corrupted.  

> +static int max98396_mux_put(struct snd_kcontrol *kcontrol,
> +			    struct snd_ctl_elem_value *ucontrol)
> +{
> +	struct snd_soc_component *component =
> +		snd_soc_dapm_kcontrol_component(kcontrol);
> +	struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol);
> +	struct max98396_priv *max98396 = snd_soc_component_get_drvdata(component);
> +	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
> +	unsigned int *item = ucontrol->value.enumerated.item;
> +	int reg, val;
> +
> +	if (item[0] >= e->items)
> +		return -EINVAL;
> +
> +	val = snd_soc_enum_item_to_val(e, item[0]) << e->shift_l;
> +
> +	if (max98396->device_id == CODEC_TYPE_MAX98396)
> +		reg = MAX98396_R2055_PCM_RX_SRC1;
> +	else
> +		reg = MAX98397_R2056_PCM_RX_SRC1;
> +
> +	regmap_update_bits(max98396->regmap, reg,
> +			   MAX98396_PCM_RX_MASK, val);
> +
> +	snd_soc_dapm_mux_update_power(dapm, kcontrol, item[0], e, NULL);
> +
> +	return 0;
> +}

This should return 1 if the value changed - you should get an error
reported by mixer-test from selftests if you run them on a sound card
with the driver.

> +	/* L/R mix configuration */
> +	if (max98396->device_id == CODEC_TYPE_MAX98396) {
> +		regmap_write(max98396->regmap,
> +			     MAX98396_R2055_PCM_RX_SRC1, 0x02);
> +		regmap_write(max98396->regmap,
> +			     MAX98396_R2056_PCM_RX_SRC2, 0x10);
> +	} else {
> +		regmap_write(max98396->regmap,
> +			     MAX98397_R2056_PCM_RX_SRC1, 0x02);
> +		regmap_write(max98396->regmap,
> +			     MAX98397_R2057_PCM_RX_SRC2, 0x10);
> +	}

Shouldn't these be user controllable?  Most of the setup being done here
looks system specific, especially the routing stuff.

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

WARNING: multiple messages have this Message-ID (diff)
From: Mark Brown <broonie@kernel.org>
To: Ryan Lee <ryan.lee.analog@gmail.com>
Cc: drhodes@opensource.cirrus.com,
	pierre-louis.bossart@linux.intel.com,
	alsa-devel@alsa-project.org, ckeepax@opensource.cirrus.com,
	stephan@gerhold.net, tanureal@opensource.cirrus.com,
	hdegoede@redhat.com, linux-kernel@vger.kernel.org,
	tiwai@suse.com, ryans.lee@analog.com, lgirdwood@gmail.com,
	cy_huang@richtek.com, devicetree@vger.kernel.org,
	robh+dt@kernel.org, srinivas.kandagatla@linaro.org,
	pbrobinson@gmail.com, lukas.bulwahn@gmail.com,
	krzk+dt@kernel.org, arnd@arndb.de
Subject: Re: [PATCH 2/2] ASoC: max98396: add amplifier driver
Date: Wed, 20 Apr 2022 17:17:50 +0100	[thread overview]
Message-ID: <YmAyLuZIT1zYfNeA@sirena.org.uk> (raw)
In-Reply-To: <20220416004024.210418-2-ryan.lee.analog@gmail.com>

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

On Fri, Apr 15, 2022 at 05:40:24PM -0700, Ryan Lee wrote:

This looks mostly good - some issues below but nothing structural.

> +	switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
> +	case SND_SOC_DAIFMT_NB_NF:
> +	case SND_SOC_DAIFMT_NB_IF:
> +		break;

One of these must be wrong - the device needs to know if it's handling a
normal or inverted frame clock, otherwise the audio will be corrupted.  

> +static int max98396_mux_put(struct snd_kcontrol *kcontrol,
> +			    struct snd_ctl_elem_value *ucontrol)
> +{
> +	struct snd_soc_component *component =
> +		snd_soc_dapm_kcontrol_component(kcontrol);
> +	struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol);
> +	struct max98396_priv *max98396 = snd_soc_component_get_drvdata(component);
> +	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
> +	unsigned int *item = ucontrol->value.enumerated.item;
> +	int reg, val;
> +
> +	if (item[0] >= e->items)
> +		return -EINVAL;
> +
> +	val = snd_soc_enum_item_to_val(e, item[0]) << e->shift_l;
> +
> +	if (max98396->device_id == CODEC_TYPE_MAX98396)
> +		reg = MAX98396_R2055_PCM_RX_SRC1;
> +	else
> +		reg = MAX98397_R2056_PCM_RX_SRC1;
> +
> +	regmap_update_bits(max98396->regmap, reg,
> +			   MAX98396_PCM_RX_MASK, val);
> +
> +	snd_soc_dapm_mux_update_power(dapm, kcontrol, item[0], e, NULL);
> +
> +	return 0;
> +}

This should return 1 if the value changed - you should get an error
reported by mixer-test from selftests if you run them on a sound card
with the driver.

> +	/* L/R mix configuration */
> +	if (max98396->device_id == CODEC_TYPE_MAX98396) {
> +		regmap_write(max98396->regmap,
> +			     MAX98396_R2055_PCM_RX_SRC1, 0x02);
> +		regmap_write(max98396->regmap,
> +			     MAX98396_R2056_PCM_RX_SRC2, 0x10);
> +	} else {
> +		regmap_write(max98396->regmap,
> +			     MAX98397_R2056_PCM_RX_SRC1, 0x02);
> +		regmap_write(max98396->regmap,
> +			     MAX98397_R2057_PCM_RX_SRC2, 0x10);
> +	}

Shouldn't these be user controllable?  Most of the setup being done here
looks system specific, especially the routing stuff.

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

  reply	other threads:[~2022-04-20 16:18 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-16  0:40 [PATCH 1/2] ASoC: dt-bindings: max98396: add amplifier driver Ryan Lee
2022-04-16  0:40 ` [PATCH 2/2] ASoC: " Ryan Lee
2022-04-20 16:17   ` Mark Brown [this message]
2022-04-20 16:17     ` Mark Brown
2022-04-21 22:38     ` Lee, RyanS
2022-04-21 22:38       ` Lee, RyanS
2022-04-16 22:17 ` [PATCH 1/2] ASoC: dt-bindings: " Rob Herring
2022-04-16 22:17   ` Rob Herring
2022-04-18 22:32   ` Lee, RyanS
2022-04-18 22:32     ` Lee, RyanS

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=YmAyLuZIT1zYfNeA@sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=arnd@arndb.de \
    --cc=ckeepax@opensource.cirrus.com \
    --cc=cy_huang@richtek.com \
    --cc=devicetree@vger.kernel.org \
    --cc=drhodes@opensource.cirrus.com \
    --cc=hdegoede@redhat.com \
    --cc=krzk+dt@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lukas.bulwahn@gmail.com \
    --cc=pbrobinson@gmail.com \
    --cc=perex@perex.cz \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=robh+dt@kernel.org \
    --cc=ryan.lee.analog@gmail.com \
    --cc=ryans.lee@analog.com \
    --cc=srinivas.kandagatla@linaro.org \
    --cc=stephan@gerhold.net \
    --cc=tanureal@opensource.cirrus.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.