Re: [PATCH 2/2] ASoC: nau8325: new driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jan 22, 2024 at 05:56:50PM +0800, Seven Lee wrote:

> +++ b/sound/soc/codecs/nau8325.c
> @@ -0,0 +1,896 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * nau8325.c -- Nuvoton NAU8325 audio codec driver
> + *

Please use a C++ comment for the whole block to make things look more
consistent.

> +static int nau8325_clkdet_put(struct snd_kcontrol *kcontrol,
> +			      struct snd_ctl_elem_value *ucontrol)
> +{
> +	struct soc_mixer_control *mc =
> +		(struct soc_mixer_control *)kcontrol->private_value;
> +	struct snd_soc_component *component =
> +		snd_soc_kcontrol_component(kcontrol);
> +	struct nau8325 *nau8325 = snd_soc_component_get_drvdata(component);
> +	unsigned int max = mc->max, min = mc->min, val;
> +	unsigned int mask = (1 << fls(max)) - 1;

AFAICT this will only work well if max is 1, just hard code that.

> +
> +	val = (ucontrol->value.integer.value[0] + min) & mask;
> +	nau8325->clock_detection = val;
> +
> +	if (nau8325->clock_detection)
> +		regmap_update_bits(nau8325->regmap, NAU8325_R40_CLK_DET_CTRL,
> +				   NAU8325_CLKPWRUP_DIS, 0);
> +	else
> +		regmap_update_bits(nau8325->regmap, NAU8325_R40_CLK_DET_CTRL,
> +				   NAU8325_CLKPWRUP_DIS, NAU8325_CLKPWRUP_DIS);
> +
> +	return nau8325->clock_detection;
> +}

Please use mixer-test to verify that your controls conform to the
expected API, the return value here is not what's expected - it should
be a negative value for an error, 0 for no change and 1 for change.

> +	SOC_SINGLE_EXT("Clock Detection", SND_SOC_NOPM, 0, 1, 0,
> +		       nau8325_clkdet_get, nau8325_clkdet_put),

Shouldn't this be a Switch?

> +	SOC_SINGLE("ALC Enable", NAU8325_R2E_ALC_CTRL3,
> +		   NAU8325_ALC_EN_SFT, 1, 0),

ALC Switch.

> +static int nau8325_powerup_event(struct snd_soc_dapm_widget *w,
> +				 struct snd_kcontrol *kcontrol, int event)
> +{
> +	struct snd_soc_component *component =
> +		snd_soc_dapm_to_component(w->dapm);
> +	struct nau8325 *nau8325 = snd_soc_component_get_drvdata(component);
> +
> +	if (nau8325->clock_detection)
> +		return 0;
> +

What happens if someone enables clock detection while things are powered
up?

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux