Bug 203831

Summary: Scratching noise on Acer nitro 5 (Maybe other acer laptops) and no option to select headphones or headset after commit c5ba1712661233ce0f4666b8c3dee5bb78d380f2
Product: Drivers Reporter: Haxk20 (haxk612)
Component: Sound(ALSA)Assignee: Jaroslav Kysela (perex)
Status: RESOLVED CODE_FIX    
Severity: high CC: hui.wang, tiwai
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 5.2rc3 Subsystem:
Regression: No Bisected commit-id:
Attachments: dmesg of resuming from sleep and having the issue.
alsa-info not working sound
alsa-info working sound

Description Haxk20 2019-06-05 22:54:11 UTC
After updating from 5.2Rc1 to rc3 i discovered a bug which is kind of annoying.
After suspending or some action (I still dont know exactly what triggers it) just that sound isnt playing and when i play some video the sound is almost non existent and when i hear something its scratchy and weird sounding.
But the first sign of this bug is that now i dont have the option to choose headset or headphones in GNOME which i use on daily basis but this option now doesnt show up and the mode goes straight to headphones.

Its really late and i will provide dmesg tomorrow.
If you need anything else im more then happy to provide it.
Comment 1 Haxk20 2019-06-07 19:28:56 UTC
Created attachment 283147 [details]
dmesg of resuming from sleep and having the issue.
Comment 2 Haxk20 2019-06-12 20:45:59 UTC
After some long spend hours its either 
ALSA: hda/realtek - Improve the headset mic for Acer Aspire laptops
or ALSA: hda/realtek - Check headset type by unplug and resume.
And the name of the bug seems to be incorrect since this seems to only occur on Acer Nitro 5 or maybe other Acer laptops.
The commit on mainline is c5ba1712661233ce0f4666b8c3dee5bb78d380f2.
If somebody could look at this so that we could get a fix in before full 5.2 release ?
Comment 3 Takashi Iwai 2019-06-13 09:22:56 UTC
The most suspected one is the commit aeac1a0dadb4ab699a61136a5729d048abe6ee5f
    ALSA: hda/realtek - Check headset type by unplug and resume

Could you just revert it and see whether the problem is gone?
Comment 4 Haxk20 2019-06-13 09:49:29 UTC
(In reply to Takashi Iwai from comment #3)
> The most suspected one is the commit aeac1a0dadb4ab699a61136a5729d048abe6ee5f
>     ALSA: hda/realtek - Check headset type by unplug and resume
> 
> Could you just revert it and see whether the problem is gone?

Will report once the build is done.
Comment 5 Haxk20 2019-06-13 11:25:07 UTC
(In reply to Takashi Iwai from comment #3)
> The most suspected one is the commit aeac1a0dadb4ab699a61136a5729d048abe6ee5f
>     ALSA: hda/realtek - Check headset type by unplug and resume
> 
> Could you just revert it and see whether the problem is gone?

Reverting that commit doesnt fix the issue.
Comment 6 Haxk20 2019-06-13 11:39:30 UTC
Reverting commit ALSA: hda/realtek - Improve the headset mic for Acer Aspire laptops fixes the issue.
Comment 7 Takashi Iwai 2019-06-13 13:01:26 UTC
OK, then could you give alsa-info.sh output?  Run it with --no-upload option and attach the output to Bugzilla.
Comment 8 Haxk20 2019-06-13 13:59:38 UTC
(In reply to Takashi Iwai from comment #7)
> OK, then could you give alsa-info.sh output?  Run it with --no-upload option
> and attach the output to Bugzilla.

Of the broken kernel or the fixed one ?
I guess broken one so i will have to build it
Comment 9 Haxk20 2019-06-13 14:11:06 UTC
Created attachment 283257 [details]
alsa-info not working sound
Comment 10 Haxk20 2019-06-13 14:11:31 UTC
Created attachment 283259 [details]
alsa-info working sound
Comment 11 Haxk20 2019-06-13 14:12:31 UTC
Here are both for not working sound (quiet and when high scratching) and replugged the headphones and rerun it with working sound.
Comment 12 Takashi Iwai 2019-06-13 14:22:35 UTC
Thanks.

Hui, your patch seems causing a regression on another Acer model.
Could you check it?  In the worst case, we need to revert it before the 5.2 final release.
Comment 13 Hui Wang 2019-06-13 15:23:04 UTC
Hello Haxk20,

The patch (ALSA: hda/realtek - Improve the headset mic for Acer Aspire laptops) just changes the headset-mic from phantom audio jack to normal audio jack. Without this patch, the external mic is a phantom jack, it is always true, then it always shows up in the gnome UI, users can select it anytime.

After applying this patch, the external mic is a normal jack, if users plug a headset (headphone+mic) into the jack, the mic will shows up in the gnome UI; if users plug a headphone into the jack, the mic will not show up in the gnome UI.

So after applying this patch and plugging a headset into the jack, does the mic Jack change to true like below (in the alsa-info.txt):

	control.17 {
		iface CARD
		name 'Mic Jack'
		value true
		comment {
			access read
			type BOOLEAN
			count 1
		}
	}

If it doesn't change to true, we should revert this patch.
Comment 14 Haxk20 2019-06-13 15:41:41 UTC
After plugging in earphones without microphone the control.17 remains false. I do not have earphones with microphone to test if that will change in any way.
Comment 15 Haxk20 2019-06-13 15:44:16 UTC
I found some old earphones with microphone and it changed to true. So this behaviur is intended ?
Comment 16 Haxk20 2019-06-13 15:47:08 UTC
OK but weird is that when i have the microphone earphones plugged in i can only see internal microphone in GNOME but it gets the audio from the earphones microphone. Shoudlnt there be option to select between external and internal microphone in gnome when user plugs them in ?
Comment 17 Haxk20 2019-06-13 15:48:37 UTC
But still the bug remains that when this patch is applied and i restart or suspend PC with earphones plugged in i can hear audio very slightly but its scratching a little. This doesnt happen without this patch.
Comment 18 Hui Wang 2019-06-14 01:15:48 UTC
Reply the comment 16:
If the UI is (gnome-sound-setting + pulseaudio), when there is no external mic, the internal microphone will show up in the gnome-sound-setting, after plugging a earphone with mic, the internal microphone will disappear and the microphone will show up, then users only can record sound via earphone mic. This is the design by pulseaudio. So for your case, the Mic Jack changes to true, but there is still only internal microphone in the UI, I really don't have idea for it. Probably your UI is not (gnome-sound-setting + pulseaudio)?

Reply the comment 17:
For the noise issue, in theory I didn't touch spec->shutup/init_hook, it will not introduce noise for reboot or suspend/resume. I just wrote an email to kailang@realtek, let us see if he have some idea on it.

If we can't resolve the noise issue, let us revert this patch then.
Comment 19 Hui Wang 2019-06-14 03:45:22 UTC
Hello Haxk20,

Kailang and I had a short discussion about the noise, we all don't have any idea for this issue.

So please double confirm that after reverting the patch, there is no noise when rebooting and suspending, while after applying the patch, there is significant noise that most users can't ignore it. Then let us revert this patch.

Thanks
Comment 20 Haxk20 2019-06-14 08:01:01 UTC
(In reply to Hui Wang from comment #19)
> Hello Haxk20,
> 
> Kailang and I had a short discussion about the noise, we all don't have any
> idea for this issue.
> 
> So please double confirm that after reverting the patch, there is no noise
> when rebooting and suspending, while after applying the patch, there is
> significant noise that most users can't ignore it. Then let us revert this
> patch.
> 
> Thanks

Hello,
Yes i can confirm for 100% that after reverting this patch there is no issue with sound.
After applying it tho the issue is that when you reboot or suspend with headphones plugged in and you play music after that or just any sound its not heard. Its only heard if the sound is of high volume but its scratching like crazy. This is impossible to ignore.
Thank you.
Comment 21 Haxk20 2019-06-14 08:02:32 UTC
(In reply to Hui Wang from comment #18)
> Reply the comment 16:
> If the UI is (gnome-sound-setting + pulseaudio), when there is no external
> mic, the internal microphone will show up in the gnome-sound-setting, after
> plugging a earphone with mic, the internal microphone will disappear and the
> microphone will show up, then users only can record sound via earphone mic.
> This is the design by pulseaudio. So for your case, the Mic Jack changes to
> true, but there is still only internal microphone in the UI, I really don't
> have idea for it. Probably your UI is not (gnome-sound-setting + pulseaudio)?
> 
> Reply the comment 17:
> For the noise issue, in theory I didn't touch spec->shutup/init_hook, it
> will not introduce noise for reboot or suspend/resume. I just wrote an email
> to kailang@realtek, let us see if he have some idea on it.
> 
> If we can't resolve the noise issue, let us revert this patch then.

My UI is pulseaudio and gnome-sound-settings.
Comment 22 Haxk20 2019-06-14 08:05:23 UTC
(In reply to Hui Wang from comment #18)
> Reply the comment 16:
> If the UI is (gnome-sound-setting + pulseaudio), when there is no external
> mic, the internal microphone will show up in the gnome-sound-setting, after
> plugging a earphone with mic, the internal microphone will disappear and the
> microphone will show up, then users only can record sound via earphone mic.
> This is the design by pulseaudio. So for your case, the Mic Jack changes to
> true, but there is still only internal microphone in the UI, I really don't
> have idea for it. Probably your UI is not (gnome-sound-setting + pulseaudio)?
> 
> Reply the comment 17:
> For the noise issue, in theory I didn't touch spec->shutup/init_hook, it
> will not introduce noise for reboot or suspend/resume. I just wrote an email
> to kailang@realtek, let us see if he have some idea on it.
> 
> If we can't resolve the noise issue, let us revert this patch then.

Im so sorry. Indeed the mic changes to external in the UI but this still doesnt fix the scratching sound.
Comment 23 Hui Wang 2019-06-14 08:44:47 UTC
The reverting patch is just sent out to review.

thx.
Comment 24 Haxk20 2019-06-14 11:03:34 UTC
(In reply to Hui Wang from comment #23)
> The reverting patch is just sent out to review.
> 
> thx.

Thank you very much.
Since the patch is sent to review i will close this bug.