Re: The regression caused by snd_soc_dapm_enable_pin

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 05 Nov 2021 03:58:46 +0100,
Yu-Hsuan Hsu wrote:
> 
> Hi Takashi,
> 
> The patch 5af82c81b2c49cfb1cad84d9eb6eab0e3d1c4842(ASoC: DAPM: Fix
> missing kctl change notifications) caused the regression on some
> ChromeBook.
> 
> The reason is that some drivers check the return value of
> snd_soc_dapm_enable_pin, like kabylake_ssp0_trigger(Which caused a
> regression). In addition, some SOF drivers may be also affected by
> this change(e.g. sof_sdw_max98373.c). Could you help to fix it?

Does the patch below fix the problem?


Takashi


--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -3589,10 +3589,10 @@ int snd_soc_dapm_put_pin_switch(struct snd_kcontrol *kcontrol,
 	const char *pin = (const char *)kcontrol->private_value;
 	int ret;
 
-	if (ucontrol->value.integer.value[0])
-		ret = snd_soc_dapm_enable_pin(&card->dapm, pin);
-	else
-		ret = snd_soc_dapm_disable_pin(&card->dapm, pin);
+	mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
+
+	ret = snd_soc_dapm_set_pin(dapm, pin, !!ucontrol->value.integer.value[0]);
+	mutex_unlock(&dapm->card->dapm_mutex);
 
 	snd_soc_dapm_sync(&card->dapm);
 	return ret;
@@ -4506,7 +4506,9 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_stream_stop);
 int snd_soc_dapm_enable_pin_unlocked(struct snd_soc_dapm_context *dapm,
 				   const char *pin)
 {
-	return snd_soc_dapm_set_pin(dapm, pin, 1);
+	int err = snd_soc_dapm_set_pin(dapm, pin, 1);
+
+	return err < 0 ? err : 0;
 }
 EXPORT_SYMBOL_GPL(snd_soc_dapm_enable_pin_unlocked);
 
@@ -4527,7 +4529,7 @@ int snd_soc_dapm_enable_pin(struct snd_soc_dapm_context *dapm, const char *pin)
 
 	mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
 
-	ret = snd_soc_dapm_set_pin(dapm, pin, 1);
+	ret = snd_soc_dapm_enable_pin_unlocked(dapm, pin);
 
 	mutex_unlock(&dapm->card->dapm_mutex);
 
@@ -4618,7 +4620,9 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_force_enable_pin);
 int snd_soc_dapm_disable_pin_unlocked(struct snd_soc_dapm_context *dapm,
 				    const char *pin)
 {
-	return snd_soc_dapm_set_pin(dapm, pin, 0);
+	int err = snd_soc_dapm_set_pin(dapm, pin, 0);
+
+	return err < 0 ? err : 0;
 }
 EXPORT_SYMBOL_GPL(snd_soc_dapm_disable_pin_unlocked);
 
@@ -4639,7 +4643,7 @@ int snd_soc_dapm_disable_pin(struct snd_soc_dapm_context *dapm,
 
 	mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
 
-	ret = snd_soc_dapm_set_pin(dapm, pin, 0);
+	ret = snd_soc_dapm_disable_pin_unlocked(dapm, pin);
 
 	mutex_unlock(&dapm->card->dapm_mutex);
 



[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux