stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 1/2] ALSA: hda/realtek: fix a determine_headset_type issue for a Dell AIO
@ 2021-03-20  9:15 Hui Wang
  2021-03-20  9:15 ` [PATCH v3 2/2] ALSA: hda/realtek: call alc_update_headset_mode() in hp_automute_hook Hui Wang
  2021-03-22 11:19 ` [PATCH v3 1/2] ALSA: hda/realtek: fix a determine_headset_type issue for a Dell AIO Takashi Iwai
  0 siblings, 2 replies; 4+ messages in thread
From: Hui Wang @ 2021-03-20  9:15 UTC (permalink / raw)
  To: alsa-devel, tiwai, kailang, stable

We found a recording issue on a Dell AIO, users plug a headset-mic and
select headset-mic from UI, but can't record any sound from
headset-mic. The root cause is the determine_headset_type() returns a
wrong type, e.g. users plug a ctia type headset, but that function
returns omtp type.

On this machine, the internal mic is not connected to the codec, the
"Input Source" is headset mic by default. And when users plug a
headset, the determine_headset_type() will be called immediately, the
codec on this AIO is alc274, the delay time for this codec in the
determine_headset_type() is only 80ms, the delay is too short to
correctly determine the headset type, the fail rate is nearly 99% when
users plug the headset with the normal speed.

Other codecs set several hundred ms delay time, so here I change the
delay time to 850ms for alc2x4 series, after this change, the fail
rate is zero unless users plug the headset slowly on purpose.

Cc: <stable@vger.kernel.org>
Signed-off-by: Hui Wang <hui.wang@canonical.com>
---
 sound/pci/hda/patch_realtek.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 8239e5efc12d..442e555de44c 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -5263,7 +5263,7 @@ static void alc_determine_headset_type(struct hda_codec *codec)
 	case 0x10ec0274:
 	case 0x10ec0294:
 		alc_process_coef_fw(codec, coef0274);
-		msleep(80);
+		msleep(850);
 		val = alc_read_coef_idx(codec, 0x46);
 		is_ctia = (val & 0x00f0) == 0x00f0;
 		break;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v3 2/2] ALSA: hda/realtek: call alc_update_headset_mode() in hp_automute_hook
  2021-03-20  9:15 [PATCH v3 1/2] ALSA: hda/realtek: fix a determine_headset_type issue for a Dell AIO Hui Wang
@ 2021-03-20  9:15 ` Hui Wang
  2021-03-22 11:20   ` Takashi Iwai
  2021-03-22 11:19 ` [PATCH v3 1/2] ALSA: hda/realtek: fix a determine_headset_type issue for a Dell AIO Takashi Iwai
  1 sibling, 1 reply; 4+ messages in thread
From: Hui Wang @ 2021-03-20  9:15 UTC (permalink / raw)
  To: alsa-devel, tiwai, kailang, stable

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.

Cc: <stable@vger.kernel.org>
Signed-off-by: Hui Wang <hui.wang@canonical.com>
---
 sound/pci/hda/patch_realtek.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 442e555de44c..01d9d44aeec1 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)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v3 1/2] ALSA: hda/realtek: fix a determine_headset_type issue for a Dell AIO
  2021-03-20  9:15 [PATCH v3 1/2] ALSA: hda/realtek: fix a determine_headset_type issue for a Dell AIO Hui Wang
  2021-03-20  9:15 ` [PATCH v3 2/2] ALSA: hda/realtek: call alc_update_headset_mode() in hp_automute_hook Hui Wang
@ 2021-03-22 11:19 ` Takashi Iwai
  1 sibling, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2021-03-22 11:19 UTC (permalink / raw)
  To: Hui Wang; +Cc: alsa-devel, kailang, stable

On Sat, 20 Mar 2021 10:15:41 +0100,
Hui Wang wrote:
> 
> We found a recording issue on a Dell AIO, users plug a headset-mic and
> select headset-mic from UI, but can't record any sound from
> headset-mic. The root cause is the determine_headset_type() returns a
> wrong type, e.g. users plug a ctia type headset, but that function
> returns omtp type.
> 
> On this machine, the internal mic is not connected to the codec, the
> "Input Source" is headset mic by default. And when users plug a
> headset, the determine_headset_type() will be called immediately, the
> codec on this AIO is alc274, the delay time for this codec in the
> determine_headset_type() is only 80ms, the delay is too short to
> correctly determine the headset type, the fail rate is nearly 99% when
> users plug the headset with the normal speed.
> 
> Other codecs set several hundred ms delay time, so here I change the
> delay time to 850ms for alc2x4 series, after this change, the fail
> rate is zero unless users plug the headset slowly on purpose.
> 
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Hui Wang <hui.wang@canonical.com>

Applied, thanks.


Takashi

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3 2/2] ALSA: hda/realtek: call alc_update_headset_mode() in hp_automute_hook
  2021-03-20  9:15 ` [PATCH v3 2/2] ALSA: hda/realtek: call alc_update_headset_mode() in hp_automute_hook Hui Wang
@ 2021-03-22 11:20   ` Takashi Iwai
  0 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2021-03-22 11:20 UTC (permalink / raw)
  To: Hui Wang; +Cc: alsa-devel, kailang, stable

On Sat, 20 Mar 2021 10:15:42 +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.
> 
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Hui Wang <hui.wang@canonical.com>

Applied, thanks.


Takashi

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-03-22 11:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-20  9:15 [PATCH v3 1/2] ALSA: hda/realtek: fix a determine_headset_type issue for a Dell AIO Hui Wang
2021-03-20  9:15 ` [PATCH v3 2/2] ALSA: hda/realtek: call alc_update_headset_mode() in hp_automute_hook Hui Wang
2021-03-22 11:20   ` Takashi Iwai
2021-03-22 11:19 ` [PATCH v3 1/2] ALSA: hda/realtek: fix a determine_headset_type issue for a Dell AIO Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).