Bug 219533

Summary: Builtin microphone doesn't work on Thinkpad p14s Gen 5 (21MES00B00)
Product: Drivers Reporter: Ilya Zverev (ilya)
Component: Sound(ALSA)Assignee: Jaroslav Kysela (perex)
Status: REOPENED ---    
Severity: normal CC: ilya, yaro330
Priority: P3    
Hardware: AMD   
OS: Linux   
Kernel Version: 6.11.8 Subsystem:
Regression: No Bisected commit-id:
Attachments: Patch that possibly fixes the issue

Description Ilya Zverev 2024-11-26 07:49:46 UTC
Created attachment 307282 [details]
Patch that possibly fixes the issue

Basically the same as https://bugzilla.kernel.org/show_bug.cgi?id=216925

External microphones work, internal doesn't. I've made a patch similar to that another issue (attached), but had issues running with the recompiled kernel, so not yet sure it works.

$ lspci|grep Audio
c4:00.1 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] Rembrandt Radeon High Definition Audio Controller
c4:00.5 Multimedia controller: Advanced Micro Devices, Inc. [AMD] ACP/ACP3X/ACP6x Audio Coprocessor (rev 63)
c4:00.6 Audio device: Advanced Micro Devices, Inc. [AMD] Family 17h/19h HD Audio Controller

$ arecord -l
card 1: Generic_1 [HD-Audio Generic], device 0: ALC257 Analog [ALC257 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: acp63 [acp63], device 0: DMIC capture dmic-hifi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0

$ sudo dmidecode -t system
Handle 0x0010, DMI type 1, 27 bytes
System Information
        Manufacturer: LENOVO
        Product Name: 21MES00B00
        Version: ThinkPad P14s Gen 5 AMD
        Serial Number: PF51A2KB
        UUID: 3c98c04c-33cd-11b2-a85c-9c1ee103416e
        Wake-up Type: Power Switch
        SKU Number: LENOVO_MT_21ME_BU_Think_FM_ThinkPad P14s Gen 5 AMD
        Family: ThinkPad P14s Gen 5 AMD

$ sudo dmidecode -t baseboard
Handle 0x0011, DMI type 2, 15 bytes
Base Board Information
        Manufacturer: LENOVO
        Product Name: 21MES00B00
        Version: Not Defined
        Serial Number: L1HF46J01ZS

$ sudo dmesg | grep 'acp6x\|DMIC\|snd\|udio'
[    5.685610] snd_hda_intel 0000:c4:00.1: enabling device (0000 -> 0002)
[    5.686586] snd_hda_intel 0000:c4:00.1: Handle vga_switcheroo audio client
[    5.687232] snd_hda_intel 0000:c4:00.6: enabling device (0000 -> 0002)
[    5.713598] snd_hda_intel 0000:c4:00.1: bound 0000:c4:00.0 (ops amdgpu_dm_audio_component_bind_ops [amdgpu])
[    5.718357] input: HD-Audio Generic HDMI/DP,pcm=3 as /devices/pci0000:00/0000:00:08.1/0000:c4:00.1/sound/card0/input16
[    5.718848] input: HD-Audio Generic HDMI/DP,pcm=7 as /devices/pci0000:00/0000:00:08.1/0000:c4:00.1/sound/card0/input17
[    5.720873] input: HD-Audio Generic HDMI/DP,pcm=8 as /devices/pci0000:00/0000:00:08.1/0000:c4:00.1/sound/card0/input18
[    5.754228] snd_pci_ps 0000:c4:00.5: enabling device (0000 -> 0002)
[    5.754911] snd_hda_codec_realtek hdaudioC1D0: autoconfig for ALC257: line_outs=1 (0x14/0x0/0x0/0x0/0x0) type:speaker
[    5.754914] snd_hda_codec_realtek hdaudioC1D0:    speaker_outs=0 (0x0/0x0/0x0/0x0/0x0)
[    5.754916] snd_hda_codec_realtek hdaudioC1D0:    hp_outs=1 (0x21/0x0/0x0/0x0/0x0)
[    5.754918] snd_hda_codec_realtek hdaudioC1D0:    mono: mono_out=0x0
[    5.754919] snd_hda_codec_realtek hdaudioC1D0:    inputs:
[    5.754920] snd_hda_codec_realtek hdaudioC1D0:      Mic=0x19
Comment 1 Ilya Zverev 2024-11-27 12:38:32 UTC
Just tested the patch, and it works fine, I get sound from the mic.

Both the short "21ME" and the long "21MES00B00" work for the product name, although I don't understand why.
Comment 2 Ilya Zverev 2024-11-27 12:39:57 UTC
The problem is, I don't see "acp6x" in the dmesg output. Should I?

$ sudo dmesg | grep 'acp6x\|DMIC\|snd\|udio'
[    6.000040] snd_hda_intel 0000:c4:00.1: enabling device (0000 -> 0002)
[    6.000324] snd_hda_intel 0000:c4:00.1: Handle vga_switcheroo audio client
[    6.003989] snd_hda_intel 0000:c4:00.6: enabling device (0000 -> 0002)
[    6.016977] snd_hda_intel 0000:c4:00.1: bound 0000:c4:00.0 (ops amdgpu_dm_audio_component_bind_ops [amdgpu])
[    6.041615] input: HD-Audio Generic HDMI/DP,pcm=3 as /devices/pci0000:00/0000:00:08.1/0000:c4:00.1/sound/card0/input15
[    6.041725] input: HD-Audio Generic HDMI/DP,pcm=7 as /devices/pci0000:00/0000:00:08.1/0000:c4:00.1/sound/card0/input16
[    6.041828] input: HD-Audio Generic HDMI/DP,pcm=8 as /devices/pci0000:00/0000:00:08.1/0000:c4:00.1/sound/card0/input17
[    6.068296] snd_hda_codec_realtek hdaudioC1D0: autoconfig for ALC257: line_outs=1 (0x14/0x0/0x0/0x0/0x0) type:speaker
[    6.068301] snd_hda_codec_realtek hdaudioC1D0:    speaker_outs=0 (0x0/0x0/0x0/0x0/0x0)
[    6.068303] snd_hda_codec_realtek hdaudioC1D0:    hp_outs=1 (0x21/0x0/0x0/0x0/0x0)
[    6.068304] snd_hda_codec_realtek hdaudioC1D0:    mono: mono_out=0x0
[    6.068306] snd_hda_codec_realtek hdaudioC1D0:    inputs:
[    6.068307] snd_hda_codec_realtek hdaudioC1D0:      Mic=0x19
[    6.068317] snd_pci_ps 0000:c4:00.5: enabling device (0000 -> 0002)
[    6.108190] input: HD-Audio Generic Mic as /devices/pci0000:00/0000:00:08.1/0000:c4:00.6/sound/card1/input18
[    6.108296] input: HD-Audio Generic Headphone as /devices/pci0000:00/0000:00:08.1/0000:c4:00.6/sound/card1/input19
Comment 3 Ilya Zverev 2024-11-27 13:52:31 UTC
Patch submitted: https://lore.kernel.org/all/20241127134420.14471-1-ilya@zverev.info/
Comment 5 Ilya Zverev 2025-03-20 14:40:40 UTC
Frankly, five months later, I don't think this patch has worked. Nether 21ME, not the full 21MES00B00 product ids enable the microphone after a reboot. They do for a short time, but it just does not stick.
Comment 6 Yaro 2025-03-31 20:58:12 UTC
Yeah there's something weird going on with the mic on that platform, I am on the X13 Gen 4, we definitely do not this quirk, as it only really seems to be needed on the AMD 6xxx series with Zen 3+, they might be using the DSP from 7xxx series, but are detected as 5xxx, not sure.

I had to set the sensitivity to 100% for people to hear me, which I do not think is ideal, but it begun cutting out entirely now.

As mentioned here: all that's (supposedly) needed is enabling the driver in the defconfig, but there's something wonky going on here.

https://github.com/torvalds/linux/commit/861b3415e4dee06cc00cd1754808a7827b9105bf
Comment 7 Ilya Zverev 2025-04-11 09:25:48 UTC
Yaro, thanks for the hint! I tried recompiling kernel with those two lines in `kernel-local` file:

CONFIG_SND_SOC_AMD_PS=m
CONFIG_SND_SOC_AMD_PS_MACH=m

And oh my god, a week has passed, with reboots, docked and non-docked mode, sound on sound off, calls and stuff. And the microphone hasn't failed once!

What I don't understand, is that it seems those flags are enabled in Fedora kernels out of the box:

https://src.fedoraproject.org/rpms/kernel/blob/f41/f/kernel-x86_64-fedora.config#_7043

I'm wary of closing this issue, because I don't understand why with the default kernel (6.13.9) the mic does not work.

Now I guess I need to do the same thing Jiawei Wang did, and undo my kernel commit.
Comment 8 Yaro 2025-04-11 09:40:52 UTC
(In reply to Ilya Zverev from comment #7)
> 
> What I don't understand, is that it seems those flags are enabled in Fedora
> kernels out of the box:
> 
> https://src.fedoraproject.org/rpms/kernel/blob/f41/f/kernel-x86_64-fedora.
> config#_7043
> 
> I'm wary of closing this issue, because I don't understand why with the
> default kernel (6.13.9) the mic does not work.
> 
> Now I guess I need to do the same thing Jiawei Wang did, and undo my kernel
> commit.

I was checking out amdgpu driver recently and it looks like every generation of GPUs is compiled every time, there are no config options to disable any of the generations. Maybe the same should be done here as it seems like a ton of distros don't enable new AMD configs, people are left with no mic, they search Google/GitHub and end up doing the same thing as you and many others: creating a quirk in the driver that seems to be compiled universally.