]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ASoC: sophgo: return 1 on volume change in cv1800b_adc_volume_set()
authorSurendra Singh Chouhan <kr494167@gmail.com>
Mon, 27 Jul 2026 05:38:04 +0000 (11:08 +0530)
committerMark Brown <broonie@kernel.org>
Mon, 27 Jul 2026 22:56:58 +0000 (23:56 +0100)
cv1800b_adc_volume_set() serves as the .put callback for the "Internal
I2S Capture Volume" control.

ALSA mixer control callbacks must return 1 when the register value is
modified, 0 if unchanged, or a negative error code on failure. Returning
0 unconditionally causes ALSA core to assume the value was unchanged,
suppressing SNDRV_CTL_EVENT_MASK_VALUE change notifications to userspace
sound servers (e.g. PipeWire/PulseAudio).

Fix this by comparing the new register value with the existing register
value. If unchanged, return 0; otherwise, write the updated value and
return 1.

Fixes: 4cf8752a03e6 ("ASoC: sophgo: add CV1800B internal ADC codec driver")
Signed-off-by: Surendra Singh Chouhan <kr494167@gmail.com>
Link: https://patch.msgid.link/20260727053804.25599-1-kr494167@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sophgo/cv1800b-sound-adc.c

index b66761156b9934f491021a0761a868a783559971..bd93e261bdd1d29162f3a7bb0ebe829a4efb6db8 100644 (file)
@@ -251,16 +251,22 @@ static int cv1800b_adc_volume_set(struct snd_kcontrol *kcontrol,
 
        u32 v_left = clamp_t(u32, ucontrol->value.integer.value[0], 0, 24);
        u32 v_right = clamp_t(u32, ucontrol->value.integer.value[1], 0, 24);
-       u32 val;
+       u32 val, old_val;
 
        val = readl(priv->regs + CV1800B_RXADC_ANA0);
+       old_val = val;
+
        val = u32_replace_bits(val, cv1800b_gains[v_left],
                               REG_COMB_LEFT_VOLUME);
        val = u32_replace_bits(val, cv1800b_gains[v_right],
                               REG_COMB_RIGHT_VOLUME);
+
+       if (val == old_val)
+               return 0;
+
        writel(val, priv->regs + CV1800B_RXADC_ANA0);
 
-       return 0;
+       return 1;
 }
 
 static DECLARE_TLV_DB_SCALE(cv1800b_volume_tlv, 0, 200, 0);