diff mbox series

[v2,2/2] ALSA: hda/realtek: call alc_update_headset_mode() in hp_automute_hook

Message ID 20210319075903.6480-2-hui.wang@canonical.com (mailing list archive)
State Superseded
Headers show
Series [v2,1/2] ALSA: hda/realtek: fix a determine_headset_type issue for a Dell AIO | expand

Commit Message

Hui Wang March 19, 2021, 7:59 a.m. UTC
We found the alc_update_headset_mode() is not called on some machines
when unplugging the headset, as a result, the mode of the
ALC_HEADSET_MODE_UNPLUGGED can't be set, then the current_headset_type
is not cleared, if users plug a differnt type of headset next time,
the determine_headset_type() will not be called and the audio jack is
set to the headset type of previous time.

On the Dell machines which connect the dmic to the PCH, if we open
the gnome-sound-setting and unplug the headset, this issue will
happen. Those machines disable the auto-mute by ucm and has no
internal mic in the input source, so the update_headset_mode() will
not be called by cap_sync_hook or automute_hook when unplugging, and
because the gnome-sound-setting is opened, the codec will not enter
the runtime_suspend state, so the update_headset_mode() will not be
called by alc_resume when unplugging. In this case the
hp_automute_hook is called when unplugging, so add
update_headset_mode() calling to this function.

Signed-off-by: Hui Wang <hui.wang@canonical.com>
---
 sound/pci/hda/patch_realtek.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Takashi Iwai March 19, 2021, 10:17 a.m. UTC | #1
On Fri, 19 Mar 2021 08:59:03 +0100,
Hui Wang wrote:
> 
> We found the alc_update_headset_mode() is not called on some machines
> when unplugging the headset, as a result, the mode of the
> ALC_HEADSET_MODE_UNPLUGGED can't be set, then the current_headset_type
> is not cleared, if users plug a differnt type of headset next time,
> the determine_headset_type() will not be called and the audio jack is
> set to the headset type of previous time.
> 
> On the Dell machines which connect the dmic to the PCH, if we open
> the gnome-sound-setting and unplug the headset, this issue will
> happen. Those machines disable the auto-mute by ucm and has no
> internal mic in the input source, so the update_headset_mode() will
> not be called by cap_sync_hook or automute_hook when unplugging, and
> because the gnome-sound-setting is opened, the codec will not enter
> the runtime_suspend state, so the update_headset_mode() will not be
> called by alc_resume when unplugging. In this case the
> hp_automute_hook is called when unplugging, so add
> update_headset_mode() calling to this function.
> 
> Signed-off-by: Hui Wang <hui.wang@canonical.com>
> ---
>  sound/pci/hda/patch_realtek.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
> index 442e555de44c..c928704da20b 100644
> --- a/sound/pci/hda/patch_realtek.c
> +++ b/sound/pci/hda/patch_realtek.c
> @@ -5447,6 +5447,7 @@ static void alc_update_headset_jack_cb(struct hda_codec *codec,
>  				       struct hda_jack_callback *jack)
>  {
>  	snd_hda_gen_hp_automute(codec, jack);
> +	alc_update_headset_mode(codec);
>  }

This change was described in the above, but ...

>  
>  static void alc_probe_headset_mode(struct hda_codec *codec)
> @@ -5559,7 +5560,7 @@ static void alc288_update_headset_jack_cb(struct hda_codec *codec,
>  {
>  	struct alc_spec *spec = codec->spec;
>  
> -	alc_update_headset_jack_cb(codec, jack);
> +	snd_hda_gen_hp_automute(codec, jack);
>  	/* Headset Mic enable or disable, only for Dell Dino */
>  	alc_update_gpio_data(codec, 0x40, spec->gen.hp_jack_present);

This change isn't clear why it's needed from the description.
Does it man that only ALC288 shouldn't call alc_update_headset_mode()
by some reason?


thanks,

Takashi
Hui Wang March 20, 2021, 9:02 a.m. UTC | #2
On 3/19/21 6:17 PM, Takashi Iwai wrote:
> On Fri, 19 Mar 2021 08:59:03 +0100,
> Hui Wang wrote:
>> We found the alc_update_headset_mode() is not called on some machines
>> when unplugging the headset, as a result, the mode of the
>> ALC_HEADSET_MODE_UNPLUGGED can't be set, then the current_headset_type
>> is not cleared, if users plug a differnt type of headset next time,
>> the determine_headset_type() will not be called and the audio jack is
>> set to the headset type of previous time.
>>
>> On the Dell machines which connect the dmic to the PCH, if we open
>> the gnome-sound-setting and unplug the headset, this issue will
>> happen. Those machines disable the auto-mute by ucm and has no
>> internal mic in the input source, so the update_headset_mode() will
>> not be called by cap_sync_hook or automute_hook when unplugging, and
>> because the gnome-sound-setting is opened, the codec will not enter
>> the runtime_suspend state, so the update_headset_mode() will not be
>> called by alc_resume when unplugging. In this case the
>> hp_automute_hook is called when unplugging, so add
>> update_headset_mode() calling to this function.
>>
>> Signed-off-by: Hui Wang <hui.wang@canonical.com>
>> ---
>>   sound/pci/hda/patch_realtek.c | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
>> index 442e555de44c..c928704da20b 100644
>> --- a/sound/pci/hda/patch_realtek.c
>> +++ b/sound/pci/hda/patch_realtek.c
>> @@ -5447,6 +5447,7 @@ static void alc_update_headset_jack_cb(struct hda_codec *codec,
>>   				       struct hda_jack_callback *jack)
>>   {
>>   	snd_hda_gen_hp_automute(codec, jack);
>> +	alc_update_headset_mode(codec);
>>   }
> This change was described in the above, but ...
>
>>   
>>   static void alc_probe_headset_mode(struct hda_codec *codec)
>> @@ -5559,7 +5560,7 @@ static void alc288_update_headset_jack_cb(struct hda_codec *codec,
>>   {
>>   	struct alc_spec *spec = codec->spec;
>>   
>> -	alc_update_headset_jack_cb(codec, jack);
>> +	snd_hda_gen_hp_automute(codec, jack);
>>   	/* Headset Mic enable or disable, only for Dell Dino */
>>   	alc_update_gpio_data(codec, 0x40, spec->gen.hp_jack_present);
> This change isn't clear why it's needed from the description.
> Does it man that only ALC288 shouldn't call alc_update_headset_mode()
> by some reason?
Oh, I thought this is a normal audio jack, doesn't support 
headphone/headset and microphone. Will fix it in the v3.
>
> thanks,
>
> Takashi
diff mbox series

Patch

diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 442e555de44c..c928704da20b 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -5447,6 +5447,7 @@  static void alc_update_headset_jack_cb(struct hda_codec *codec,
 				       struct hda_jack_callback *jack)
 {
 	snd_hda_gen_hp_automute(codec, jack);
+	alc_update_headset_mode(codec);
 }
 
 static void alc_probe_headset_mode(struct hda_codec *codec)
@@ -5559,7 +5560,7 @@  static void alc288_update_headset_jack_cb(struct hda_codec *codec,
 {
 	struct alc_spec *spec = codec->spec;
 
-	alc_update_headset_jack_cb(codec, jack);
+	snd_hda_gen_hp_automute(codec, jack);
 	/* Headset Mic enable or disable, only for Dell Dino */
 	alc_update_gpio_data(codec, 0x40, spec->gen.hp_jack_present);
 }