ASoC: rt711-sdca: add the notification when volume changed
Subsystems (3)
PATCH 1/1 ASoC: rt711-sdca: add the notification when volume changed
From: Shuming Fan <[email protected]>
This patch adds the return value when the volume settings were changed. The userspace application might monitor the kcontrols to check which control changed.
--- sound/soc/codecs/rt711-sdca.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
sound/soc/codecs/rt711-sdca.c +9 -2
@@ -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 ; +for (i =0 ; i <3 ; i++) {/* retry 3 times at most */ /* Lch*/ regmap_write (rt711->mbq_regmap, mc->reg, gain_l_val);
@@ -573,7 +580,7 @@ static int rt711_sdca_set_gain_put(struct snd_kcontrol *kcontrol,break ; } -return i ==3 ? -EIO :0 ; +return i ==3 ? -EIO : changed; } static int rt711_sdca_set_gain_get(struct snd_kcontrol *kcontrol,
Signature · 1 line
2.29.0
Jaroslav Kysela
maintainerDne 22. 04. 21 v 11:08 [email protected] napsal(a):
Quoted 33 lines
From: Shuming Fan <[email protected]>
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 <[email protected]>--- sound/soc/codecs/rt711-sdca.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)sound/soc/codecs/rt711-sdca.c +5
-1@@ -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 ];
sound/soc/codecs/rt711-sdca.c static int rt711_sdca_set_gain_put(struct snd_kcontrol *kcontrol, · line 568
Quoted 5 lines
sound/soc/codecs/rt711-sdca.c +2
-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
Signature · 2 lines
Jaroslav Kysela <[email protected]> Linux Sound Maintainer; ALSA Project; Red Hat, Inc.
Hi Jaroslav,
Quoted 24 lines
Review static int rt711_sdca_set_gain_put(struct
Quoted 1 line
(quoted diff) +0
-0@@ -509,12 +509,16 @@ static int rt711_sdca_set_gain_put(struct
snd_kcontrol*kcontrol,Review static int rt711_sdca_set_gain_put(struct · line 510
Quoted 2 lines
(quoted diff) +0
-0(struct soc_mixer_control *)kcontrol->private_value; struct rt711_sdca_priv *rt711 =
snd_soc_component_get_drvdata(component);Quoted 19 lines
sound/soc/codecs/rt711-sdca.c +5
-1unsigned 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,sound/soc/codecs/rt711-sdca.c +0
-0gain_r_val &=0xffff ; }
Quoted 5 lines
sound/soc/codecs/rt711-sdca.c static int rt711_sdca_set_gain_put(struct snd_kcontrol *kcontrol, · line 568
Quoted 2 lines
sound/soc/codecs/rt711-sdca.c +2
-0+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?
OK, will fix. Thanks.
Quoted 7 lines
Jaroslav
--
Jaroslav Kysela <[email protected]>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc. ------Please consider the environment before printing this e-mail.