Commit a1aee7f7 authored by Shuming Fan's avatar Shuming Fan Committed by Mark Brown

ASoC: rt711-sdca: add the notification when volume changed

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: default avatarShuming Fan <shumingf@realtek.com>
Link: https://lore.kernel.org/r/20210422103235.22048-1-shumingf@realtek.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent ca5118c0
...@@ -509,12 +509,16 @@ static int rt711_sdca_set_gain_put(struct snd_kcontrol *kcontrol, ...@@ -509,12 +509,16 @@ static int rt711_sdca_set_gain_put(struct snd_kcontrol *kcontrol,
(struct soc_mixer_control *)kcontrol->private_value; (struct soc_mixer_control *)kcontrol->private_value;
struct rt711_sdca_priv *rt711 = snd_soc_component_get_drvdata(component); 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 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") || if (strstr(ucontrol->id.name, "FU1E Capture Volume") ||
strstr(ucontrol->id.name, "FU0F Capture Volume")) strstr(ucontrol->id.name, "FU0F Capture Volume"))
adc_vol_flag = 1; 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 */ /* control value to 2's complement value */
/* L Channel */ /* L Channel */
gain_l_val = ucontrol->value.integer.value[0]; gain_l_val = ucontrol->value.integer.value[0];
...@@ -560,6 +564,11 @@ static int rt711_sdca_set_gain_put(struct snd_kcontrol *kcontrol, ...@@ -560,6 +564,11 @@ static int rt711_sdca_set_gain_put(struct snd_kcontrol *kcontrol,
gain_r_val &= 0xffff; gain_r_val &= 0xffff;
} }
if (lvalue != gain_l_val || rvalue != gain_r_val)
changed = 1;
else
return 0;
for (i = 0; i < 3; i++) { /* retry 3 times at most */ for (i = 0; i < 3; i++) { /* retry 3 times at most */
/* Lch*/ /* Lch*/
regmap_write(rt711->mbq_regmap, mc->reg, gain_l_val); regmap_write(rt711->mbq_regmap, mc->reg, gain_l_val);
...@@ -573,7 +582,7 @@ static int rt711_sdca_set_gain_put(struct snd_kcontrol *kcontrol, ...@@ -573,7 +582,7 @@ static int rt711_sdca_set_gain_put(struct snd_kcontrol *kcontrol,
break; break;
} }
return i == 3 ? -EIO : 0; return i == 3 ? -EIO : changed;
} }
static int rt711_sdca_set_gain_get(struct snd_kcontrol *kcontrol, static int rt711_sdca_set_gain_get(struct snd_kcontrol *kcontrol,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment