]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ASoC: tas2562: Fix event generation for volume control
authorMark Brown <broonie@kernel.org>
Wed, 15 Jul 2026 20:18:10 +0000 (21:18 +0100)
committerMark Brown <broonie@kernel.org>
Sun, 19 Jul 2026 21:03:23 +0000 (22:03 +0100)
ALSA put() operations should return 0 for noop updates and 1 if the
value of the control changed, this is used by the ALSA core to generate
events to userspace.  tas2562_volume_control_put() does not implement
this, it just writes whatever value userspace wrote to the device and
returns 0 regardless of what the previous value was.  Fix this by
suppressing writes if the value is unchanged and returning 1 if the
writes succeed.

Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://patch.msgid.link/20260715-asoc-tas2562-put-retval-v1-2-97bf467c924e@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/tas2562.c

index 40b7803c68bebb20b7b85d381590888c95829c35..d3d0aaa0f60788d134700b14a76887c6f57230c4 100644 (file)
@@ -474,6 +474,9 @@ static int tas2562_volume_control_put(struct snd_kcontrol *kcontrol,
        int ret, index;
        u32 reg_val;
 
+       if (tas2562->volume_lvl == ucontrol->value.integer.value[0])
+               return 0;
+
        index = ucontrol->value.integer.value[0] / 2;
        if (index < 0 || index >= ARRAY_SIZE(float_vol_db_lookup))
                return -EINVAL;
@@ -498,7 +501,7 @@ static int tas2562_volume_control_put(struct snd_kcontrol *kcontrol,
 
        tas2562->volume_lvl = ucontrol->value.integer.value[0];
 
-       return 0;
+       return 1;
 }
 
 /* Digital Volume Control. From 0 dB to -110 dB in 1 dB steps */