diff mbox series

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

Message ID 20210422103235.22048-1-shumingf@realtek.com
State Superseded
Headers show
Series [v2] ASoC: rt711-sdca: add the notification when volume changed | expand

Commit Message

Shuming [θŒƒζ›ΈιŠ˜] April 22, 2021, 10:32 a.m. UTC
From: Shuming Fan <shumingf@realtek.com>

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@realtek.com>
---
 sound/soc/codecs/rt711-sdca.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

Comments

Mark Brown April 23, 2021, 6:06 p.m. UTC | #1
On Thu, 22 Apr 2021 18:32:35 +0800, shumingf@realtek.com wrote:
> This patch adds the return value when the volume settings were changed.
> The userspace application might monitor the kcontrols to check which control changed.

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: rt711-sdca: add the notification when volume changed
      commit: a1aee7f7b71155595a06f21f2d021b6a58d04017

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark
diff mbox series

Patch

diff --git a/sound/soc/codecs/rt711-sdca.c b/sound/soc/codecs/rt711-sdca.c
index 39848d2641c3..cc36739f7fcf 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,11 @@  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;
+	else
+		return 0;
+
 	for (i = 0; i < 3; i++) { /* retry 3 times at most */
 		/* Lch*/
 		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,
 			break;
 	}
 
-	return i == 3 ? -EIO : 0;
+	return i == 3 ? -EIO : changed;
 }
 
 static int rt711_sdca_set_gain_get(struct snd_kcontrol *kcontrol,