Bug 211853

Summary: Realtek ALC295 external headset microphone not working on Acer Spin 5 - SP513-54N
Product: Drivers Reporter: crysman (crysman)
Component: Sound(ALSA)Assignee: Jaroslav Kysela (perex)
Status: REOPENED ---    
Severity: normal CC: amaramardhruva+kernel, msalle, pmenzel+bugzilla.kernel.org, tiwai, victor1984
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 5.8.0-43-generic Subsystem:
Regression: No Bisected commit-id:
Attachments: alsa-info-0.4.65_output

Description crysman 2021-02-19 18:10:45 UTC
Created attachment 295367 [details]
alsa-info-0.4.65_output

Simply put, external microphone (classic cable jack input) does not work.

I've already described thoroughly the whole issue on various places, choose your favorite:

- https://bugs.launchpad.net/ubuntu/+source/pulseaudio/+bug/1912052
- https://askubuntu.com/questions/1305942/external-headset-microphone-not-working-in-ubuntu-20-10-not-even-wired-cable-h

Might be related?:
- https://bugzilla.kernel.org/show_bug.cgi?id=195457#c29

I'm attaching the output of this ( https://git.alsa-project.org/?p=alsa-utils.git;a=blob_plain;f=alsa-info/alsa-info.sh;hb=HEAD )
Comment 1 Takashi Iwai 2021-02-22 10:11:54 UTC
First off, please try the latest kernel, at best 5.11.  It makes further debugging easier.

After confirming the latest kernel still doesn't work, let's try to switch to the legacy HD-audio snd-hda-intel driver; we're checking only about the external mic, and it makes easier to debug, too.  Boot with snd_intel_dspcfg.dsp_driver=1 boot option, and it'll forcibly use the legacy driver.  Note that, with this, the built-in mic won't work with this.

Once after that, you can try to pass a different model option to snd-hda-intel module.
Comment 2 crysman 2021-02-23 19:38:51 UTC
OK, I wait until Ubuntu ships 5.11 natively and then let you know.
5.10 will be not enough in 21.04?

Sad is that it used to work before - until some upgrade along the way...

Meanwhile, just tested "snd_intel_dspcfg.dsp_driver=1" boot option and... nope, has not fixed the problem. There is a change it the name of the device - something like "...Analog input..." instead of something like "...SmartSound Technology..." but external cable mic is not working nevertheless.

Regarding "passing different option to snd-..." I am not sure what you exacly mean? You mean try this "sudo hda-verb /dev/snd/hwC0D0 ...." kinda' hacking?

Thank you!
Comment 3 Takashi Iwai 2021-02-24 09:01:15 UTC
The debug will be based on 5.11.x, so it's better to move it at first.

About the different option to snd-hda-intel: no, you can pass "model" option to snd-hda-intel module to apply some device-specific quirk.  For example,
  snd_hda_intel.model=alc255-acer
boot option will apply some Acer-specific workaround.  Or try
  snd_hda_intel.model=headset-mic

There are quite many model options for the Realtek codecs.  A part of available values are found in Documentation/sound/hd-audio/models.rst, the section for ALC269.
Comment 4 Paul Menzel 2021-03-01 17:48:05 UTC
crysman, with Ubuntu you can easily test Linux kernel releases using their builds [1]. Download the package and install with `sudo dpkg -i …`.

[1]: https://kernel.ubuntu.com/~kernel-ppa/mainline/
Comment 5 Amardhruva 2021-10-30 15:37:25 UTC
I am not sure if this will help but I have a Acer Predator helios 300 with ALC295 and had to do the workaround snd_hda_intel model=alc255-acer for the Headphone microphone to work. Would love it if the kernel could automatically detect the card and apply the quirk.
Comment 6 crysman 2021-10-31 09:19:54 UTC
I've made a new test, currently on POPOS 21.04, kernel 5.13:

❱ uname -rv
5.13.0-7614-generic #14~1631647151~21.04~930e87c-Ubuntu SMP Fri Sep 17 00:24:58 UTC

1) default boot options:
========================
- internal mic works, external not


2) changed to  intel_dspcfg.dsp_driver + headset-mic:
========================
❱ cat /proc/cmdline
initrd=\EFI\Pop_OS-a99686bf-c48a-464b-af3a-25f67847049a\initrd.img root=UUID=a99686bf-c48a-464b-af3a-25f67847049a ro snd_intel_dspcfg.dsp_driver=1 snd_hda_intel.model=headset-mic

- neither mic works


3) changed to intel_dspcfg.dsp_driver + alc255-acer
=========================
❱ cat /proc/cmdline
initrd=\EFI\Pop_OS-a99686bf-c48a-464b-af3a-25f67847049a\initrd.img root=UUID=a99686bf-c48a-464b-af3a-25f67847049a ro quiet splash snd_intel_dspcfg.dsp_driver=1 snd_hda_intel.model=alc255-acer

- external mic is now working (!), when jack is plugged-in, it corerctly asks what device have I connected (headset or headphones?)
- internal mic is not working, though :(


4) it (does not) works with pci=nocrs, too:
================================
❱ cat /proc/cmdline
initrd=\EFI\Pop_OS-a99686bf-c48a-464b-af3a-25f67847049a\initrd.img root=UUID=a99686bf-c48a-464b-af3a-25f67847049a ro quiet splash pci=nocrs snd_intel_dspcfg.dsp_driver=1 snd_hda_intel.model=alc255-acer


So, this solution is not very practical, because when I do not have headset available at the moment, I cannot use internal microphone :(
Comment 7 Jaroslav Kysela 2021-10-31 11:23:27 UTC
Try 'snd_sof_intel_hda_common.hda_model=alc255-acer' kernel parameter and don't modify snd_intel_dspcfg configuration.
Comment 8 crysman 2021-10-31 14:34:44 UTC
@Jaroslav: OK, I've just tested that.

5) only alc255-acer:
====================
❱ cat /proc/cmdline 
initrd=\EFI\Pop_OS-a99686bf-c48a-464b-af3a-25f67847049a\initrd.img root=UUID=a99686bf-c48a-464b-af3a-25f67847049a ro quiet splash pci=nocrs snd_hda_intel.model=alc255-acer

- internal mic works
- external does not :(


I've noticed some RED messages in dmesg, though - the latest seem to be relevant:

[    0.089089] x86/cpu: SGX disabled by BIOS.
[    0.670858] pci 0000:00:07.0: DPC: RP PIO log size 0 is invalid
[    0.672459] pci 0000:00:07.1: DPC: RP PIO log size 0 is invalid
[    0.674048] pci 0000:00:07.2: DPC: RP PIO log size 0 is invalid
[    0.675635] pci 0000:00:07.3: DPC: RP PIO log size 0 is invalid
[   30.127898] snd_hda_codec_realtek ehdaudio0D0: didn't find PCM for DAI Digital Codec DAI
[   30.127909] snd_hda_codec_realtek ehdaudio0D0: ASoC: error at snd_soc_dai_startup on Digital Codec DAI: -22
[   30.127915]  Digital Playback and Capture: soc_pcm_open() failed (-22)
[   30.127919]  HDA Digital: ASoC: dpcm_be_dai_startup() failed at Digital Playback and Capture (-22)
[   30.127922]  HDA Digital: dpcm_fe_dai_startup() failed (-22)
[   30.128026] snd_hda_codec_realtek ehdaudio0D0: didn't find PCM for DAI Digital Codec DAI
[   30.128030] snd_hda_codec_realtek ehdaudio0D0: ASoC: error at snd_soc_dai_startup on Digital Codec DAI: -22
[   30.128034]  Digital Playback and Capture: soc_pcm_open() failed (-22)
[   30.128036]  HDA Digital: ASoC: dpcm_be_dai_startup() failed at Digital Playback and Capture (-22)
[   30.128039]  HDA Digital: dpcm_fe_dai_startup() failed (-22)
Comment 9 Jaroslav Kysela 2021-10-31 14:58:36 UTC
Please, attach new alsa-info.sh output.
Comment 10 Jaroslav Kysela 2021-10-31 14:59:33 UTC
And you didn't follow my instructions - read them carefully. There is another module and parameters for the SOF driver to set the HDA model.
Comment 11 crysman 2021-10-31 17:28:17 UTC
@jaroslav fresh report here:
http://alsa-project.org/db/?f=4fa645dcfb6f79261c362d5510af0ad4e6183548

(while booted with `❱ cat /proc/cmdline 
initrd=\EFI\Pop_OS-a99686bf-c48a-464b-af3a-25f67847049a\initrd.img root=UUID=a99686bf-c48a-464b-af3a-25f67847049a ro quiet splash pci=nocrs snd_hda_intel.model=alc255-acer
`

please, could you navigate me to "the instructions", I've been looking around and have not found what you mean, I will try my best to follow them once I know exactly what to follow, thanks a lot!
Comment 12 Jaroslav Kysela 2021-10-31 17:58:44 UTC
snd_sof_intel_hda_common.hda_model=alc255-acer  not snd_hda_intel.model=alc255-acer
Comment 13 crysman 2021-10-31 19:03:34 UTC
@jaroslav you RULEZZ! This has, indeed, solved reported problem, now both microphones work! Thanks a lot!

SOLUTION SUMMARY:
1) use kernel 5.11+
2) use `snd_sof_intel_hda_common.hda_model=alc255-acer` kernel boot parameter
Comment 14 Jaroslav Kysela 2021-10-31 20:31:15 UTC
The model should be detected automatically. The parameter is just for override useful for tests.

If you can, could you test this code change?

  diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
  index 6322fac9e694..4f46cfc5393b 100644
  --- a/sound/pci/hda/patch_realtek.c
  +++ b/sound/pci/hda/patch_realtek.c
  @@ -8485,6 +8485,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
          SND_PCI_QUIRK(0x1025, 0x1308, "Acer Aspire Z24-890",,
  ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
          SND_PCI_QUIRK(0x1025, 0x132a, "Acer TravelMate B114-21",
  ALC233_FIXUP_ACER_HEADSET_MIC),
          SND_PCI_QUIRK(0x1025, 0x1330, "Acer TravelMate X514-51T",
  ALC255_FIXUP_ACER_HEADSET_MIC),
  +       SND_PCI_QUIRK(0x1025, 0x141f, "Acer Acer Spin SP513-54N",
  ALC255_FIXUP_ACER_MIC_NO_PRESENCE),
          SND_PCI_QUIRK(0x1025, 0x142b, "Acer Swift SF314-42",
  ALC255_FIXUP_ACER_MIC_NO_PRESENCE),
          SND_PCI_QUIRK(0x1025, 0x1430, "Acer TravelMate B311R-31",
  ALC256_FIXUP_ACER_MIC_NO_PRESENCE),
          SND_PCI_QUIRK(0x1025, 0x1466, "Acer Aspire A515-56", 
  ALC255_FIXUP_ACER_HEADPHONE_AND_MIC),
Comment 15 Jaroslav Kysela 2021-11-08 08:15:58 UTC
The above change is in upstream:

  https://lore.kernel.org/alsa-devel/20211104155726.2090997-1-perex@perex.cz/
Comment 16 crysman 2022-04-14 14:37:22 UTC
Thanks a lot for everything so far. One more thing regarding to this audio issue, though - maybe you @Jaroslav would know what the problem is - could you please have look at this?
https://bugs.launchpad.net/linux/+bug/1912052/comments/29
Comment 17 Victor Shyba 2023-01-23 22:33:50 UTC
I just had the same issue but on Acer Predator PH315-54

alsa-info.sh output: http://alsa-project.org/db/?f=66787dea0436de3059aac928371c61646ebad51b

Jaroslav, I sent a patch for you and alsa-devel, but I think it did not arrive as I am not a member of the list. I just applied the same quirk and recompiled, resulting in a working headset microphone.
Thank you a lot for all the information/guidance in this issue.

diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 6fab7c8fc19a..5b628fd3351d 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -9202,6 +9202,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
 	SND_PCI_QUIRK(0x1025, 0x142b, "Acer Swift SF314-42", ALC255_FIXUP_ACER_MIC_NO_PRESENCE),
 	SND_PCI_QUIRK(0x1025, 0x1430, "Acer TravelMate B311R-31", ALC256_FIXUP_ACER_MIC_NO_PRESENCE),
 	SND_PCI_QUIRK(0x1025, 0x1466, "Acer Aspire A515-56", ALC255_FIXUP_ACER_HEADPHONE_AND_MIC),
+	SND_PCI_QUIRK(0x1025, 0x1534, "Acer Predator PH315-54", ALC255_FIXUP_ACER_MIC_NO_PRESENCE),
 	SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
 	SND_PCI_QUIRK(0x1028, 0x053c, "Dell Latitude E5430", ALC292_FIXUP_DELL_E7X),
 	SND_PCI_QUIRK(0x1028, 0x054b, "Dell XPS one 2710", ALC275_FIXUP_DELL_XPS),
Comment 18 Amardhruva 2023-02-28 21:05:00 UTC
@Victor @Jaroslav Can we have one made for PH315-53 too?