Re: [PATCH] ASoC: rt711-sdca: add the notification when volume changed

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

 



Dne 22. 04. 21 v 11:08 shumingf@xxxxxxxxxxx napsal(a):
> From: Shuming Fan <shumingf@xxxxxxxxxxx>
> 
> This patch adds the return value when the volume settings were changed.
> The userspace application might monitor the kcontrols to check which control changed.
> 
> Signed-off-by: Shuming Fan <shumingf@xxxxxxxxxxx>
> ---
>  sound/soc/codecs/rt711-sdca.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/sound/soc/codecs/rt711-sdca.c b/sound/soc/codecs/rt711-sdca.c
> index 3ab9048b4ea3..98b26bd69e19 100644
> --- a/sound/soc/codecs/rt711-sdca.c
> +++ b/sound/soc/codecs/rt711-sdca.c
> @@ -509,12 +509,16 @@ static int rt711_sdca_set_gain_put(struct snd_kcontrol *kcontrol,
>  		(struct soc_mixer_control *)kcontrol->private_value;
>  	struct rt711_sdca_priv *rt711 = snd_soc_component_get_drvdata(component);
>  	unsigned int read_l, read_r, gain_l_val, gain_r_val;
> -	unsigned int i, adc_vol_flag = 0;
> +	unsigned int i, adc_vol_flag = 0, changed = 0;
> +	unsigned int lvalue, rvalue;
>  
>  	if (strstr(ucontrol->id.name, "FU1E Capture Volume") ||
>  		strstr(ucontrol->id.name, "FU0F Capture Volume"))
>  		adc_vol_flag = 1;
>  
> +	regmap_read(rt711->mbq_regmap, mc->reg, &lvalue);
> +	regmap_read(rt711->mbq_regmap, mc->rreg, &rvalue);
> +
>  	/* control value to 2's complement value */
>  	/* L Channel */
>  	gain_l_val = ucontrol->value.integer.value[0];
> @@ -560,6 +564,9 @@ static int rt711_sdca_set_gain_put(struct snd_kcontrol *kcontrol,
>  		gain_r_val &= 0xffff;
>  	}
>  
> +	if (lvalue != gain_l_val || rvalue != gain_r_val)
> +		changed = 1;

I think that it's safe to return early with the zero return value here? Why to
rewrite the identical value in the hw registers?

					Jaroslav

-- 
Jaroslav Kysela <perex@xxxxxxxx>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.



[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