]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ASoC: fsl_micfil: Fix event generation in micfil_quality_set()
authorShengjiu Wang <shengjiu.wang@nxp.com>
Wed, 1 Apr 2026 09:42:21 +0000 (17:42 +0800)
committerMark Brown <broonie@kernel.org>
Wed, 1 Apr 2026 17:24:25 +0000 (18:24 +0100)
ALSA controls should return 1 if the value in the control changed but the
control put operation micfil_quality_set() 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 quality variable.

Also enable pm runtime before calling the function micfil_set_quality()
to make the regmap cache data align with the value in hardware.

Fixes: bea1d61d5892 ("ASoC: fsl_micfil: rework quality setting")
Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Link: https://patch.msgid.link/20260401094226.2900532-7-shengjiu.wang@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/fsl/fsl_micfil.c

index 983805bbaae272f4ff8de866059c40afeabf5d23..2e887f1f1f361ed9192111b69c8aaf873cfda92c 100644 (file)
@@ -289,10 +289,34 @@ static int micfil_quality_set(struct snd_kcontrol *kcontrol,
 {
        struct snd_soc_component *cmpnt = snd_kcontrol_chip(kcontrol);
        struct fsl_micfil *micfil = snd_soc_component_get_drvdata(cmpnt);
+       int val = ucontrol->value.integer.value[0];
+       bool change = false;
+       int old_val;
+       int ret;
+
+       if (val < QUALITY_HIGH || val > QUALITY_VLOW2)
+               return -EINVAL;
+
+       if (micfil->quality != val) {
+               ret = pm_runtime_resume_and_get(cmpnt->dev);
+               if (ret)
+                       return ret;
+
+               old_val = micfil->quality;
+               micfil->quality = val;
+               ret = micfil_set_quality(micfil);
 
-       micfil->quality = ucontrol->value.integer.value[0];
+               pm_runtime_put_autosuspend(cmpnt->dev);
 
-       return micfil_set_quality(micfil);
+               if (ret) {
+                       micfil->quality = old_val;
+                       return ret;
+               }
+
+               change = true;
+       }
+
+       return change;
 }
 
 static const char * const micfil_hwvad_enable[] = {