linux-realtek-alc287 icon indicating copy to clipboard operation
linux-realtek-alc287 copied to clipboard

Does not work with my Lenovo Legion Slim 7 15IMH5 82BC006URK

Open Nikolay-Kha opened this issue 3 years ago • 13 comments

Hi,

thank you for this patch. I tried to apply it to my machine, it doesn't work at all, though according to dmesg patched is used:

$ dmesg | grep -B 10 -A 10 alc287 
[   32.260507] input: CUST0001:00 06CB:CD3E Mouse as /devices/pci0000:00/0000:00:15.1/i2c_designware.1/i2c-3/i2c-CUST0001:00/0018:06CB:CD3E.0001/input/input13
[   32.260563] input: CUST0001:00 06CB:CD3E Touchpad as /devices/pci0000:00/0000:00:15.1/i2c_designware.1/i2c-3/i2c-CUST0001:00/0018:06CB:CD3E.0001/input/input14
[   32.260608] hid-multitouch 0018:06CB:CD3E.0001: input,hidraw0: I2C HID v1.00 Mouse [CUST0001:00 06CB:CD3E] on i2c-CUST0001:00
[   32.261322] intel_rapl_common: Found RAPL domain package
[   32.261323] intel_rapl_common: Found RAPL domain core
[   32.261324] intel_rapl_common: Found RAPL domain uncore
[   32.261325] intel_rapl_common: Found RAPL domain dram
[   32.261325] intel_rapl_common: Found RAPL domain psys
[   32.263209] snd_hda_intel 0000:00:1f.3: DSP detected with PCI class/subclass/prog-if info 0x040380
[   32.263235] snd_hda_intel 0000:00:1f.3: enabling device (0000 -> 0002)
[   32.263819] snd_hda_intel 0000:00:1f.3: Applying patch firmware 'legion-alc287.patch'
[   32.264063] snd_hda_intel 0000:01:00.1: enabling device (0000 -> 0002)
[   32.264170] snd_hda_intel 0000:01:00.1: Disabling MSI
[   32.264178] snd_hda_intel 0000:01:00.1: Handle vga_switcheroo audio client
[   32.264263] snd_hda_intel 0000:00:1f.3: bound 0000:00:02.0 (ops i915_audio_component_bind_ops [i915])
[   32.265058] mei_hdcp 0000:00:16.0-b638ab7e-94e2-4ea2-a552-d1c54b627f04: bound 0000:00:02.0 (ops i915_hdcp_component_ops [i915])
[   32.291814] snd_hda_codec_realtek hdaudioC0D0: autoconfig for ALC287: line_outs=1 (0x17/0x0/0x0/0x0/0x0) type:speaker
[   32.291819] snd_hda_codec_realtek hdaudioC0D0:    speaker_outs=0 (0x0/0x0/0x0/0x0/0x0)
[   32.291820] snd_hda_codec_realtek hdaudioC0D0:    hp_outs=1 (0x21/0x0/0x0/0x0/0x0)
[   32.291822] snd_hda_codec_realtek hdaudioC0D0:    mono: mono_out=0x0
[   32.291823] snd_hda_codec_realtek hdaudioC0D0:    inputs:

python based patch(sudo python3 realtek-verb-tools/applyverbs.py verbs-legion.txt) fixes my sound but after reboot/suspend/just some amount of time sound disappear again. Any ideas why patched firmware doesn't work?

$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC287 Analog [ALC287 Analog]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 8: HDMI 2 [HDMI 2]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 9: HDMI 3 [HDMI 3]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 10: HDMI 4 [HDMI 4]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 8: HDMI 2 [HDMI 2]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 9: HDMI 3 [HDMI 3]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 10: HDMI 4 [HDMI 4]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
$ lspci -v
...
00:1f.3 Audio device: Intel Corporation Comet Lake PCH cAVS (prog-if 80)
	Subsystem: Lenovo Device 3811
	Flags: bus master, fast devsel, latency 64, IRQ 189
	Memory at 6023218000 (64-bit, non-prefetchable) [size=16K]
	Memory at 6023100000 (64-bit, non-prefetchable) [size=1M]
	Capabilities: <access denied>
	Kernel driver in use: snd_hda_intel
	Kernel modules: snd_hda_intel, snd_sof_pci
...

Nikolay-Kha avatar Oct 27 '21 23:10 Nikolay-Kha

I remember people complaining about the solution not being permanent. Check the forum here to see what they did to fix it. I am not sure this patch has been tested for Legion Slim 7 though. @cberkenpas any tests on Legion Slim 7?

thiagotei avatar Oct 27 '21 23:10 thiagotei

@Nikolay-Kha The patch has been mainlined for a little while. Chances are you already have it if you keep your OS up to date.

Can you share your alsa-info?

The 2021 AMD versions Legion 7 and Legion 7 slim seem to share the same subsystem id so maybe the 2020 Legion 7 and Legion 7 do too (which would mean the same intel HDA quirks/fixes would be automatically applied to your model of laptop as well and this should would most likely work if that's the case).

cberkenpas avatar Oct 27 '21 23:10 cberkenpas

I have intel version of legion 7. System is up to date according ubuntu repos, though Ubuntu 20.04.3 LTS might not included it yet...

$ uname -a Linux legion 5.11.0-38-generic #42~20.04.1-Ubuntu SMP Tue Sep 28 20:41:07 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

alsa info is attached alsa-info.txt

Nikolay-Kha avatar Oct 27 '21 23:10 Nikolay-Kha

Yeah, it has a different subsystem id than the regular 2020 Legion which is why it's not getting picked up.

Do you know how to patch and build your own kernel? If yes, I can provide a patch for you to test. It's just a one line addition.

cberkenpas avatar Oct 28 '21 00:10 cberkenpas

yes, I can. Please give me a patch.

Nikolay-Kha avatar Oct 28 '21 00:10 Nikolay-Kha

Here you go:

diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index b30e1843273b..c7f7d2047880 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -8800,6 +8800,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
        SND_PCI_QUIRK(0x17aa, 0x3827, "Ideapad S740", ALC285_FIXUP_IDEAPAD_S740_COEF),
        SND_PCI_QUIRK(0x17aa, 0x3843, "Yoga 9i", ALC287_FIXUP_IDEAPAD_BASS_SPK_AMP),
        SND_PCI_QUIRK(0x17aa, 0x3813, "Legion 7i 15IMHG05", ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS),
+       SND_PCI_QUIRK(0x17aa, 0x3822, "Legion 7i Slim", ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS),
        SND_PCI_QUIRK(0x17aa, 0x3852, "Lenovo Yoga 7 14ITL5", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS),
        SND_PCI_QUIRK(0x17aa, 0x3853, "Lenovo Yoga 7 15ITL5", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS),
        SND_PCI_QUIRK(0x17aa, 0x3819, "Lenovo 13s Gen2 ITL", ALC287_FIXUP_13S_GEN2_SPEAKERS),

cberkenpas avatar Oct 28 '21 00:10 cberkenpas

@Nikolay-Kha,

Were you able to test this yet?

cberkenpas avatar Oct 28 '21 19:10 cberkenpas

sorry for delay, it's been a while since I built the kernel for the last time.... though after some straggling I managed to build 5.15-rc7 with your patch.

The result is: it doesn't work :( no sound in speakers. Python based script fixes sound with 5.15 though.

alsa info from 5.15: alsa-info-5.15.txt

it feels like thiagotei is right, verbs are applied, but after few seconds of inactivity sound just disappears(while sound device is in use it works stable). Seems to me both solutions - kernel and modprobe conf file from this repo actually apply verbs, but for some reason sound card just forgets about them in several seconds of inactivity, i.e. while booting. Just a suggestion, not an expert in sound subsystem.

I read topic which thiagotei topic above and did not found the issue when sound dissappear after applying that patch.

Nikolay-Kha avatar Oct 28 '21 21:10 Nikolay-Kha

These results mean that the streamlined verbs for the full sized 2020 Legion don't work for your model. The verbs in the kernel aren't exactly the same as in verbs-legion.txt anyway. The fact that verbs-legion.txt works for you potentially makes things MUCH easier. Can you verify how well they work for you by running some tests? At the very least, make sure audio for the left channel actually comes out of the left speaker and the same for the right side.

If so, we're in great shape and the hardest work is already done.... But from there you'll need to test the verbs to narrow them down (good news that at only 19 lines we're likely not far off at all).

You can narrow them down by running "applyverbs.py -d". This will print out the verbs with a small delay while playing sound to see where audio starts working properly for both channels.

The delay set for debug in applyverbs.py is only 0.1 seconds, so if that's not enough time, you could change this line from: time.sleep(0.1) To: time.sleep(1)

And you'll get a full second.

Once you've verified the verbs work properly for your laptop and you've narrow them down to what's needed, share the verbs here and I'll make a new patch.

cberkenpas avatar Oct 29 '21 00:10 cberkenpas

@cberkenpas thank you for the patch and these instructions. I will play with verbs on the weekend. I can tell you for sure that left channel is left, right is right. But I can hear clamps. Even with low volume. Hope it will be fixed when I tune verbs.

Nikolay-Kha avatar Oct 29 '21 08:10 Nikolay-Kha

I have one legion slim too amd/amd, image it doesn't work for me ;-;

kernel 6.0.8-arch1-1 Endeavouros

chrisemke avatar Nov 13 '22 20:11 chrisemke

I copied the file as method 1 says, but got this

[    3.547280] snd_hda_intel 0000:03:00.1: Force to non-snoop mode
[    3.547286] snd_hda_intel 0000:03:00.1: Applying patch firmware 'legion-alc287.patch'
[    3.547326] snd_hda_intel 0000:03:00.1: Direct firmware load for legion-alc287.patch failed with error -2
[    3.547328] snd_hda_intel 0000:03:00.1: Cannot load firmware, continue without patching

Does this imply that the firmware has not been loaded? I don't know who is to blame, but I suffer a lot.

Dlinuigh avatar Jul 09 '23 12:07 Dlinuigh

Looks like it failed, and I don't know why. You haven't given any context. What machine you have, etc.

cberkenpas avatar Jul 09 '23 18:07 cberkenpas