]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ASoC: fsl_micfil: Fix event generation in hwvad_put_init_mode()
authorShengjiu Wang <shengjiu.wang@nxp.com>
Wed, 1 Apr 2026 09:42:18 +0000 (17:42 +0800)
committerMark Brown <broonie@kernel.org>
Wed, 1 Apr 2026 17:24:22 +0000 (18:24 +0100)
ALSA controls should return 1 if the value in the control changed but the
control put operation hwvad_put_init_mode() only returns 0 or a negative
error code, causing ALSA to not generate any change events.

Add a suitable check in the function before updating the vad_init_mode
variable.

Fixes: 29dbfeecab85 ("ASoC: fsl_micfil: Add Hardware Voice Activity Detector support")
Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Link: https://patch.msgid.link/20260401094226.2900532-4-shengjiu.wang@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/fsl/fsl_micfil.c

index 97f24c9bdd68b899f2b575e677639460dcb7d2bf..1c826e0cb1d5e8ee82d74bb6ad3cb18ec3738328 100644 (file)
@@ -407,13 +407,18 @@ static int hwvad_put_init_mode(struct snd_kcontrol *kcontrol,
        unsigned int *item = ucontrol->value.enumerated.item;
        struct fsl_micfil *micfil = snd_soc_component_get_drvdata(comp);
        int val = snd_soc_enum_item_to_val(e, item[0]);
+       bool change = false;
+
+       if (val < MICFIL_HWVAD_ENVELOPE_MODE || val > MICFIL_HWVAD_ENERGY_MODE)
+               return -EINVAL;
 
        /* 0 - Envelope-based Mode
         * 1 - Energy-based Mode
         */
+       change = (micfil->vad_init_mode != val);
        micfil->vad_init_mode = val;
 
-       return 0;
+       return change;
 }
 
 static int hwvad_get_init_mode(struct snd_kcontrol *kcontrol,