Re: [PATCH] ASoC: rt712-sdca: Add RT712 SDCA driver for Jack and Amp topology

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

 



On Tue, Feb 07, 2023 at 05:09:46PM +0800, shumingf@xxxxxxxxxxx wrote:

> +static int rt712_sdca_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 rt712_sdca_priv *rt712 = snd_soc_component_get_drvdata(component);
> +	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
> +	unsigned int *item = ucontrol->value.enumerated.item;
> +	unsigned int mask_sft;

> +
> +	snd_soc_dapm_mux_update_power(dapm, kcontrol,
> +		item[0], e, NULL);
> +
> +	return 1;
> +}

This unconditionally returns 1 if the value written is in bounds which
means that an event will always be signalled.  Please use mixer-test to
check for this and other issues.

> +	/* set sampling frequency */
> +	if (dai->id == RT712_AIF1) {
> +		regmap_write(rt712->regmap,
> +			SDW_SDCA_CTL(FUNC_NUM_JACK_CODEC, RT712_SDCA_ENT_CS01, RT712_SDCA_CTL_SAMPLE_FREQ_INDEX, 0),
> +			sampling_rate);
> +		regmap_write(rt712->regmap,
> +			SDW_SDCA_CTL(FUNC_NUM_JACK_CODEC, RT712_SDCA_ENT_CS11, RT712_SDCA_CTL_SAMPLE_FREQ_INDEX, 0),
> +			sampling_rate);
> +	}
> +
> +	if (dai->id == RT712_AIF2)
> +		regmap_write(rt712->regmap,
> +			SDW_SDCA_CTL(FUNC_NUM_AMP, RT712_SDCA_ENT_CS31, RT712_SDCA_CTL_SAMPLE_FREQ_INDEX, 0),
> +			sampling_rate);

This would be better written as a switch statement, there were some
other checks for variants that looked to have similar issues.  It makes
it clearer that only one option can be selected and allows you to have a
default check that makes sure that any new variant with another AIF gets
handled.

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