Bug 217063

Summary: Commit 2232b2d breaks microphone on Lenovo "82SJ" Ideapad 14ARH7
Product: Drivers Reporter: Joseph R (prosenfeld)
Component: Sound(ALSA)Assignee: Jaroslav Kysela (perex)
Status: REOPENED ---    
Severity: normal CC: git, kerneldev, mario.limonciello, prosenfeld, regressions, tiwai, wildjim
Priority: P1    
Hardware: AMD   
OS: Linux   
Kernel Version: 6.4.11 Subsystem:
Regression: Yes Bisected commit-id:
Attachments: lspci -vv
Alsa Info stock kernel
Alsa Info with the commit removed
Alsa Info, stock kernel, no other sound devices attached
Alsa Info, modified kernel, no other sound devices attached
patch for 82TL
attachment-17299-0.html
attachment-22653-0.html
microphone patch for Yoga Slim 7 Pro 82UU

Description Joseph R 2023-02-21 00:35:34 UTC
Created attachment 303765 [details]
lspci -vv

Commit 2232b2dd8cd4f1e6d554b2c3f6899ce36f791b67, intended to fix sound on Lenovo Yoga Slim 7 Pro X, makes the microphone on Lenovo Ideapad 14 14ARH7 with product code Lenovo "82SJ" unusable. 

Simply removing the lines added by the commit make the microphone work again without issues. 

Attached is lspci on a kernel with the lines removed. 

First kernel bug report, so please let me know how I can help get this fixed!
Comment 1 Mario Limonciello (AMD) 2023-02-21 13:16:54 UTC
Can you please share alsa-info.sh output both with and without the commit in place?
Comment 2 Takashi Iwai 2023-03-04 05:55:40 UTC
Sorry for the late response, as I've been off for weeks.

It's an unfortunate conflict.  Could you give alsa-info.sh output?  Run the script with --no-upload option, and attach the output to Bugzilla.
Comment 3 The Linux kernel's regression tracker (Thorsten Leemhuis) 2023-03-15 12:45:33 UTC
Joseph, could you please provide the alsa-info.sh output that was asked for? Or did the problem vanish on its own maybe in between?
Comment 4 Joseph R 2023-03-15 14:17:58 UTC
Created attachment 303953 [details]
attachment-25690-0.html

So sorry, I got very busy with work shortly after submitting the bug report.

The good news is I am no longer able to replicate the issue on the newest
kernel; both microphone and speakers are working without any issues.

My apologies for the delayed response,

Joseph

On Wed, Mar 15, 2023 at 8:45 AM <bugzilla-daemon@kernel.org> wrote:

> https://bugzilla.kernel.org/show_bug.cgi?id=217063
>
> The Linux kernel's regression tracker (Thorsten Leemhuis) (
> regressions@leemhuis.info) changed:
>
>            What    |Removed                     |Added
>
> ----------------------------------------------------------------------------
>                  CC|                            |regressions@leemhuis.info
>
> --- Comment #3 from The Linux kernel's regression tracker (Thorsten
> Leemhuis) (regressions@leemhuis.info) ---
> Joseph, could you please provide the alsa-info.sh output that was asked
> for? Or
> did the problem vanish on its own maybe in between?
>
> --
> You may reply to this email to add a comment.
>
> You are receiving this mail because:
> You reported the bug.
Comment 5 Joseph R 2023-08-20 22:25:57 UTC
Created attachment 304917 [details]
Alsa Info stock kernel
Comment 6 Joseph R 2023-08-20 22:26:27 UTC
Created attachment 304918 [details]
Alsa Info with the commit removed
Comment 7 Joseph R 2023-08-20 22:28:25 UTC
Hello Kernel team,

I took this laptop out again after not using it for most of the summer and updated to the latest kernel, and unfortunetly I am once again the microphone is not functional. Removing the previously mentioned commit fixes microphone input.

I've attached Alsa-info both with and without those lines, please let me know what else I can do to assist with getting this fixed on my laptop.

Thank you,

Joseph
Comment 8 Mario Limonciello (AMD) 2023-08-21 13:09:53 UTC
I notice in your alsa info with the patched kernel that there is also a USB headset and USB audio from a monitor connected.

Is that possibly factoring into this issue as well?  Perhaps in your "working" kernel the software was using one of those inputs/outputs instead?
Comment 9 Joseph R 2023-08-21 13:17:43 UTC
Good point, thank you for checking. 

Just rechecked with no USB sound devices connected - and I can confirm behavior is still the same as before. Stock kernel does not have functional microphone output, my modified kernel does have functional microphone output.

I'm attaching new alsa-info outputs with no other sound devices attached in case that helps.

I will also note that on the stock kernel alsa info prints out "cat: '/sys/module/snd_soc_acp6x_mach/parameters/*': No such file or directory", which it does not do on my modified kernel.
Comment 10 Joseph R 2023-08-21 13:18:25 UTC
Created attachment 304921 [details]
Alsa Info, stock kernel, no other sound devices attached
Comment 11 Joseph R 2023-08-21 13:19:01 UTC
Created attachment 304922 [details]
Alsa Info, modified kernel, no other sound devices attached
Comment 12 Mario Limonciello (AMD) 2023-08-21 13:23:21 UTC
> Stock kernel does not have functional microphone output, my modified kernel
> does have functional microphone output.

You mean microphone "input" not "output" right?

What userspace are you using to capture from the microphone?  In the non-working kernel can you swap microphones and it works with the "other ones"?
Comment 13 Joseph R 2023-08-21 22:09:46 UTC
Yes, microphone input. Sorry for the typo.

I've tried many applications including just monitoring the microphone in gnome settings, webapps in Firefox, and Audacity. Results were the same across all applications.

If I have another microphone device plugged in on the non-working kernel (e.g USB Headset), it still works fine.
Comment 14 Mario Limonciello (AMD) 2023-08-22 03:44:03 UTC
On the non-working kernel can you also modprobe.blacklist=snd_pci_acp6x on the kernel command line and get it working?  I'd expect yes.

The other thing that doesn't make sense to me is can't you just pick the analog microphone in the non-working kernel?  

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

Takashi - thoughts on this issue?

I guess we probably just want to change the quirk from '82' to '82V2'.
@joseph can you test that?
Comment 15 Takashi Iwai 2023-08-22 12:08:33 UTC
If the revert works, it means that the built-in mic isn't on AMD ACP but rather directly hooked to HD-audio codec pin 0x12, I suppose.
So limiting the condition to apply the acp6x-mach should work around it.

(In reply to Mario Limonciello (AMD) from comment #14)
> I guess we probably just want to change the quirk from '82' to '82V2'.
> @joseph can you test that?

FWIW, it'll be a change like below:

--- a/sound/soc/amd/yc/acp6x-mach.c
+++ b/sound/soc/amd/yc/acp6x-mach.c
@@ -217,7 +217,7 @@ static const struct dmi_system_id yc_acp_quirk_table[] = {
                .driver_data = &acp6x_card,
                .matches = {
                        DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"),
-                       DMI_MATCH(DMI_PRODUCT_NAME, "82"),
+                       DMI_MATCH(DMI_PRODUCT_NAME, "82V2"),
                }
        },
        {
Comment 16 Joseph R 2023-08-22 19:36:46 UTC
Adding "modprobe.blacklist=snd_pci_acp6x" to the kernel command line fixes microphone input with a kernel that did not previously.

Regarding selecting the analog microphone - a microphone device does show up as an option, however it does not give any useful output.

Tested the rebuilt kernel with the quirk to be "82V2" - that does fix the issue as well.
Comment 17 Mario Limonciello (AMD) 2023-08-24 01:45:57 UTC
Thanks, I've sent out 
https://lore.kernel.org/alsa-devel/20230824011149.1395-1-mario.limonciello@amd.com/T/#u
Comment 18 wildjim@kiwinet.org 2023-09-04 05:42:47 UTC
I think this patch has caused the microphone to be no-longer detected on my laptop, which is also a Lenovo 14ARH7, but is the European-branding of basically the same device.

The microphone was working great until 6.4.12, and then stopped being detected in 6.4.13 onwards, incl. 6.5 and 6.5.1.
I suspect this patch is the cause; I think a quirk for "82TL" might also be needed?

Thanks.
-----

System Information
        Manufacturer: LENOVO
        Product Name: 82TL
        Version: Yoga Slim 7 ProX 14ARH7
        SKU Number: LENOVO_MT_82TL_BU_idea_FM_Yoga Slim 7 ProX 14ARH7
        Family: Yoga Slim 7 ProX 14ARH7
Comment 19 Takashi Iwai 2023-09-04 11:11:13 UTC
(In reply to wildjim@kiwinet.org from comment #18)
> I suspect this patch is the cause; I think a quirk for "82TL" might also be
> needed?

Yes, looks so.  Could you test it with your machine?
(And if possible, submit / attach the patch for upstreaming :)
Comment 20 Mario Limonciello (AMD) 2023-09-05 20:07:15 UTC
Created attachment 305046 [details]
patch for 82TL

Yeah this is the reason that the original quirk was 82 :/  I knew there were a variety of variants.

Here's a patch to try.
Comment 21 wildjim@kiwinet.org 2023-09-05 22:24:49 UTC
Created attachment 305051 [details]
attachment-17299-0.html

Oh thanks!
I was literally going to have a go myself, rn!
Comment 22 wildjim@kiwinet.org 2023-09-06 05:48:47 UTC
Created attachment 305053 [details]
attachment-22653-0.html

Hi there,
I tested the patch on both 6.4.14 and 6.5.1, and the mic re-appeared on
both, and appears to be working fine, now.

Cheers!
Comment 23 kerneldev@epic-bytes.net 2023-09-30 21:23:06 UTC
Created attachment 305167 [details]
microphone patch for Yoga Slim 7 Pro 82UU

Please add this patch to the mainline kernel and to the stable kernel releases to make the microphone on Yoga Slim 7 Pro 82UU work again, thank you!
Comment 24 kerneldev@epic-bytes.net 2023-09-30 21:28:31 UTC
I did forgot to provide more information about the patch above.
Lenovo sells a variant of the Lenovo Yoga Slim 7 Pro 14ARH7 which is not containted in the quirk table. Its product name is 82UU.

I've added the notebook to the quirk table and the mic is finally showing up.
Tested on my Yoga Slim 7 Pro.

System Information
        Manufacturer: LENOVO
        Product Name: 82UU
        Version: Yoga Slim 7 Pro 14ARH7
        SKU Number: LENOVO_MT_82UU_BU_idea_FM_Yoga Slim 7 Pro 14ARH7
        Family: Yoga Slim 7 Pro 14ARH7
Comment 25 Mario Limonciello (AMD) 2023-10-02 14:11:19 UTC
Can you please send your new patch to the alsa-devel mailing list?