Bug 216194 - cs35l41: Platform not supported -EINVAL
Summary: cs35l41: Platform not supported -EINVAL
Status: RESOLVED DOCUMENTED
Alias: None
Product: Drivers
Classification: Unclassified
Component: Sound(ALSA) (show other bugs)
Hardware: AMD Linux
: P1 normal
Assignee: Jaroslav Kysela
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-07-01 06:43 UTC by XiaoYan Li
Modified: 2024-02-27 14:40 UTC (History)
29 users (show)

See Also:
Kernel Version: 5.19-rc7
Subsystem:
Regression: No
Bisected commit-id:


Attachments
snippet from DSDT on another platform that works properly (2.08 KB, text/plain)
2022-07-21 12:20 UTC, Mario Limonciello (AMD)
Details
INF file for Windows drivers for codec 9333.1 (96.91 KB, text/plain)
2022-08-06 09:19 UTC, Vincent Bernat
Details
INF file for Windows drivers for driver 9333.1 (24.29 KB, text/plain)
2022-08-06 09:20 UTC, Vincent Bernat
Details
csaudio.inf from UM5302TA (6.08 KB, application/octet-stream)
2022-08-16 08:03 UTC, XiaoYan Li
Details
csaudioext.inf from UM5302TA (54.84 KB, application/octet-stream)
2022-08-16 08:04 UTC, XiaoYan Li
Details
dmesg from Lenovo Legion 7i Gen7 (261.52 KB, text/plain)
2022-08-20 18:58 UTC, Cameron Berkenpas
Details
ACPI dump from Lenovo Legion 7i Gen7 (905.84 KB, application/x-bzip)
2022-08-20 18:59 UTC, Cameron Berkenpas
Details
Initial but dangerous support for Lenovo Legion 7i Gen7. Use at your own risk. (3.26 KB, patch)
2022-08-25 18:58 UTC, Cameron Berkenpas
Details | Diff
lenovo-7i-gen7-0.0.1.patch (3.56 KB, patch)
2022-08-26 04:20 UTC, Cameron Berkenpas
Details | Diff
lenovo-7i-gen7-0.0.2.patch (3.01 KB, patch)
2022-08-31 01:15 UTC, Cameron Berkenpas
Details | Diff
lenovo-7i-gen7-sound-6.1.0-rc4-0.0.2.patch (4.05 KB, patch)
2022-11-09 01:13 UTC, Cameron Berkenpas
Details | Diff
lenovo-7i-gen7-sound-6.2.0-rc1-0.0.3.patch (4.51 KB, patch)
2022-12-30 22:13 UTC, Cameron Berkenpas
Details | Diff
lenovo-7i-gen7-sound-6.2.0-rc3-0.0.3.patch (4.44 KB, patch)
2023-01-10 19:37 UTC, Cameron Berkenpas
Details | Diff
lenovo-7i-gen7-sound-6.2.0-rc3-0.0.4.patch (4.24 KB, patch)
2023-01-11 00:21 UTC, Cameron Berkenpas
Details | Diff
dmesg output on my Legion Slim 7i with patch applied (122.84 KB, text/plain)
2023-01-11 22:14 UTC, jmaximusix
Details
lenovo-7i-gen7-sound-6.2.0-rc3-0.0.5b.patch (4.32 KB, patch)
2023-02-28 20:09 UTC, Cameron Berkenpas
Details | Diff
dmesg on patched Legion 7 16IAX7 (86.09 KB, text/plain)
2023-03-01 16:54 UTC, Jacopo G. Chen
Details
attachment-26853-0.html (6.71 KB, text/html)
2023-03-01 18:47 UTC, Cameron Berkenpas
Details
Output of alsa-info script (63.08 KB, text/plain)
2023-03-01 21:53 UTC, Jacopo G. Chen
Details
lenovo-7i-gen7-sound-6.2.0-rc3-0.0.5b-001.patch (4.41 KB, patch)
2023-03-01 22:47 UTC, Cameron Berkenpas
Details | Diff
lenovo-7i-gen7-sound-6.2.0-rc3-0.0.5b-002.patch (4.50 KB, patch)
2023-03-02 01:14 UTC, Cameron Berkenpas
Details | Diff
dmesg + alsa-info (135.02 KB, text/plain)
2023-03-02 15:34 UTC, Jacopo G. Chen
Details
attachment-26271-0.html (2.72 KB, text/html)
2023-03-05 21:14 UTC, Cameron Berkenpas
Details
legion pro 7 16IRX8H dsdt FILE (362.36 KB, application/gzip)
2023-03-15 21:25 UTC, Carlo Francesco
Details
alsa info from legion pro 7 16IRX8H (45.24 KB, text/plain)
2023-03-15 21:45 UTC, Carlo Francesco
Details
Alsa info without any patch to the kernel (44.63 KB, text/plain)
2023-03-15 21:51 UTC, Carlo Francesco
Details
attachment-14046-0.html (8.93 KB, text/html)
2023-03-15 21:53 UTC, Cameron Berkenpas
Details
Volume comparison: patched linux/win11 (259.65 KB, image/png)
2023-05-26 10:04 UTC, Jacopo G. Chen
Details
Debug outputs of 14IRP8 (7.25 KB, text/plain)
2023-06-28 11:55 UTC, Thomas Gfeller
Details
Debug outputs of 14IRP8 Part 2 (8.21 KB, text/plain)
2023-06-28 14:25 UTC, Thomas Gfeller
Details
Amps are working for certain devices (2.00 KB, application/x-shellscript)
2023-08-03 05:34 UTC, Thomas Gfeller
Details
dmesg from Legion Y9000X 16IAH7, 6.5.3+ (90.31 KB, text/plain)
2023-10-13 16:50 UTC, Xavier Hsinyuan
Details
Legion Y9000X IAH7(82TF) ACPI DSDT (3.53 MB, text/x-csrc)
2023-10-13 16:51 UTC, Xavier Hsinyuan
Details
alsa and dmesg (29.51 KB, application/zip)
2023-12-28 21:52 UTC, Farrel
Details
legion_7i-gen7_16IAX7-sound-6.7.3.patch (2.15 KB, patch)
2024-02-07 16:11 UTC, ramzes005
Details | Diff

Description XiaoYan Li 2022-07-01 06:43:10 UTC
Device: ASUS Zenbook S 13 OLED 2022 (UM5302TA)

Related DSDT definition block:

---
Device (SPKR)
{
    Name (_HID, "CSC3551")  // _HID: Hardware ID
    Name (_SUB, "10431F12")  // _SUB: Subsystem ID
    Name (_UID, One)  // _UID: Unique ID
    Method (_CRS, 0, NotSerialized)  // _CRS: Current Resource Settings
    {
        Name (RBUF, ResourceTemplate ()
        {
            I2cSerialBusV2 (0x0040, ControllerInitiated, 0x000F4240,
                AddressingMode7Bit, "\\_SB.I2CA",
                0x00, ResourceConsumer, , Exclusive,
                )
            I2cSerialBusV2 (0x0041, ControllerInitiated, 0x000F4240,
                AddressingMode7Bit, "\\_SB.I2CA",
                0x00, ResourceConsumer, , Exclusive,
                )
            GpioIo (Exclusive, PullDown, 0x0000, 0x0000, IoRestrictionOutputOnly,
                "\\_SB.GPIO", 0x00, ResourceConsumer, ,
                )
                {   // Pin list
                    0x0004
                }
            GpioIo (Exclusive, PullUp, 0x0000, 0x0000, IoRestrictionInputOnly,
                "\\_SB.GPIO", 0x00, ResourceConsumer, ,
                )
                {   // Pin list
                    0x009B
                }
            GpioIo (Shared, PullUp, 0x0064, 0x0000, IoRestrictionInputOnly,
                "\\_SB.GPIO", 0x00, ResourceConsumer, ,
                )
                {   // Pin list
                    0x0009
                }
            GpioInt (Edge, ActiveBoth, Shared, PullUp, 0x0064,
                "\\_SB.GPIO", 0x00, ResourceConsumer, ,
                )
                {   // Pin list
                    0x0009
                }
        })
        Return (RBUF) /* \_SB_.I2CA.SPKR._CRS.RBUF */
    }

    Method (_STA, 0, NotSerialized)  // _STA: Status
    {
        If ((AMPD == Zero))
        {
            Return (Zero)
        }
        Else
        {
            Return (0x0F)
        }
    }

    Method (_DIS, 0, NotSerialized)  // _DIS: Disable Device
    {
    }
}
---
Comment 1 Mario Limonciello (AMD) 2022-07-20 19:14:59 UTC
To me it looks that this DSDT doesn't have the needed properties, so ASUS would need to add those in a BIOS update.  Please contact them to get the firmware fixed.

https://github.com/torvalds/linux/blob/d7227785e384d4422b3ca189aa5bf19f462337cc/sound/pci/hda/cs35l41_hda.c#L319
Comment 2 XiaoYan Li 2022-07-21 06:10:51 UTC
On Windows, it functions perfectly. I believe we should wait to hear from Cirrus devs.
Comment 3 Mario Limonciello (AMD) 2022-07-21 12:19:37 UTC
Other platforms with this amplifier must have this information added to BIOS specifically for Linux as it's otherwise not discoverable information.

Let me attach a dsdt from a platform that did it right to demonstrate.  These values aren't necessarily correct for your system, ASUS needs to put the right ones in for your system.
Comment 4 Mario Limonciello (AMD) 2022-07-21 12:20:55 UTC
Created attachment 301471 [details]
snippet from DSDT on another platform that works properly
Comment 5 XiaoYan Li 2022-07-21 12:35:04 UTC
I understood it. Why this is not necessary for the Windows driver baffles me.
Comment 6 Mario Limonciello (AMD) 2022-07-21 12:47:30 UTC
I don't know the details either but if I was going to guess you could specify this type of info in the INF for Windows.  Maybe poke around the Windows driver for similar info for your system.  If it is indeed in the INF maybe a quirk for this system to set device properties is doable from that information.

The "proper" solution is to have it in the BIOS though.
Comment 7 XiaoYan Li 2022-07-25 02:49:37 UTC
Unfortunately, ASUS said they don't provide tech support for Linux.
Comment 8 Vincent Bernat 2022-08-06 09:19:29 UTC
Created attachment 301529 [details]
INF file for Windows drivers for codec 9333.1
Comment 9 Vincent Bernat 2022-08-06 09:20:03 UTC
Created attachment 301530 [details]
INF file for Windows drivers for driver 9333.1
Comment 10 Vincent Bernat 2022-08-06 09:22:06 UTC
I have attached a two of the INF files shipped with Windows. The codec one has many stuff in it that seems to relate to something that could be in DSDT. Does it look familiar?

The driver ships all these INF files:

Codec_9333.1/HDXACPASUS.inf
ExtRtk_9333.1/HDX_AsusExt_DOLBY_DSP_Wrap_RTKGen4.inf
ExtRtk_AmdDMIC_146/AmdDMicExt_Asus.inf
ExtRtk_AmdDMIC_146/AmdDMicExtT_Asus_104315DF.inf
ExtRtk_APO_Tuning_9333/HDX_AsusExt_APOT_2-63_off_basic.inf
ExtRtk_APO_Tuning_9333/HDX_AsusExt_APOT_AD72_C.inf
ExtRtk_APO_Tuning_9333/HDX_AsusExt_SpDllT_2-63.inf
OVWrap2_25/OVWrap2.inf
RealtekAPO2_1040/RealtekAPO2.inf
RealtekASIO_8/RealtekASIO.inf
RealtekHSA_270/RealtekHSA.inf
RealtekINTAPO2_1040/RealtekINTAPO2.inf
RealtekService_511/RealtekService.inf

I suppose the AmdDMIC ones could help with the mic not working as well.
Comment 11 Mario Limonciello (AMD) 2022-08-10 04:42:13 UTC
> Does it look familiar?

It doesn't directly match anything like the DSDT information I referenced above (no mention of word GPIO or index).

Maybe you should start with the snippet I shared and try to set up a quirk for your system using that information as a reference from a working system.  It all depends on whether the design is different for this OEM or not from the one I shared the snippet from.
 
> I suppose the AmdDMIC ones could help with the mic not working as well.

If the DMIC isn't working, I would start out with adding the platform to https://github.com/torvalds/linux/blob/master/sound/soc/amd/yc/acp6x-mach.c#L47

and make sure that you have the right driver matching it selected in your kernel config.
Comment 12 XiaoYan Li 2022-08-16 08:03:49 UTC
Created attachment 301584 [details]
csaudio.inf from UM5302TA
Comment 13 XiaoYan Li 2022-08-16 08:04:24 UTC
Created attachment 301585 [details]
csaudioext.inf from UM5302TA
Comment 14 XiaoYan Li 2022-08-16 08:08:18 UTC
Those INFs appear to have no meaningful information. Is there anything I missed?
Comment 15 Mario Limonciello (AMD) 2022-08-16 13:05:59 UTC
I think it's worth raising this discussion on the mailing list for your case.
Comment 16 XiaoYan Li 2022-08-16 14:13:57 UTC
I'm not familiar with the LKML. Which mailing list should I use? linux-audio or alsa-devel?

BTW it appears that another laptop model has a similar issue.
https://lore.kernel.org/all/20220811053950.11810-1-faenkhauser@gmail.com/T/
Comment 17 Mario Limonciello (AMD) 2022-08-16 14:19:57 UTC
From my perspective this is still a BIOS bug.  The OEM /should/ be populating the relevant _DSD.

But for this discussion on a quirk and what it should be, I suggest alsa-devel ML.  I'm pretty sure you'll at least be able to get Cirrus guys attention.
Comment 18 Cameron Berkenpas 2022-08-20 18:58:33 UTC
Created attachment 301611 [details]
dmesg from Lenovo Legion 7i Gen7
Comment 19 Cameron Berkenpas 2022-08-20 18:59:17 UTC
Created attachment 301612 [details]
ACPI dump from Lenovo Legion 7i Gen7
Comment 20 Cameron Berkenpas 2022-08-20 19:11:04 UTC
The Lenovo Legion 7i Gen 7 also has non-working sound with the CSC3551.

I don't have a Lenovo Legion 7i Gen 7 myself, but I've been working with someone who does. I just attached the ACPI dump and dmesg they shared from their system.

The Intel HDA early patching method was used to apply the CSC3551 i2c quirk.

Here is their alsa-info as well:
http://alsa-project.org/db/?f=0be0a7575b5bcc9534f5e301194db6f31f614eba

Here's the relevant section from the dump:
    Scope (_SB.PC00.I2C2)
    {
        Name (I2CN, Zero)
        Name (I2CX, Zero)
        Name (I2CI, 0x02)
        Method (_INI, 0, NotSerialized)  // _INI: Initialize
        {
            I2CN = SDS2 /* \SDS2 */
            I2CX = 0x02
        }

        Device (SPK1)
        {
            Name (_HID, "CSC3551")  // _HID: Hardware ID
            Name (_UID, One)  // _UID: Unique ID
            Name (_SUB, "17AA3874")  // _SUB: Subsystem ID
            Method (_INI, 0, NotSerialized)  // _INI: Initialize
            {
                If ((SPID == Zero))
                {
                    _SUB = "17AA3874"
                    Return (Zero)
                }

                If ((SPID == One))
                {
                    _SUB = "17AA386F"
                    Return (Zero)
                }
            }

            Name (GPIB, ResourceTemplate ()
            {
                GpioIo (Exclusive, PullDown, 0x0000, 0x0000, IoRestrictionOutputOnly,
                    "\\_SB.GPI0", 0x00, ResourceConsumer, ,
                    )
                    {   // Pin list
                        0x0027
                    }
                GpioIo (Shared, PullUp, 0x0064, 0x0000, IoRestrictionInputOnly,
                    "\\_SB.GPI0", 0x00, ResourceConsumer, ,
                    )
                    {   // Pin list
                        0x0026
                    }
                GpioInt (Edge, ActiveBoth, Shared, PullUp, 0x0064,
                    "\\_SB.GPI0", 0x00, ResourceConsumer, ,
                    )
                    {   // Pin list
                        0x0026
                    }
            })
            Method (_CRS, 0, NotSerialized)  // _CRS: Current Resource Settings
            {
                Name (IBUF, ResourceTemplate ()
                {
                    I2cSerialBusV2 (0x0040, ControllerInitiated, 0x000F4240,
                        AddressingMode7Bit, "\\_SB.PC00.I2C2",
                        0x00, ResourceConsumer, , Exclusive,
                        )
                    I2cSerialBusV2 (0x0041, ControllerInitiated, 0x000F4240,
                        AddressingMode7Bit, "\\_SB.PC00.I2C2",
                        0x00, ResourceConsumer, , Exclusive,
                        )
                })
                Return (ConcatenateResTemplate (IBUF, GPIB))
            }

            Method (_STA, 0, NotSerialized)  // _STA: Status
            {
                Return (0x0F)
            }

            Method (_DIS, 0, NotSerialized)  // _DIS: Disable Device
            {
            }
        }
    }

I wonder if updating the DSDT to include the missing properties would the way to go for the initial testing:
https://wiki.archlinux.org/title/DSDT#Find_a_fixed_DSDT

All assuming that the example of working properties would even be valid.
Comment 21 Cameron Berkenpas 2022-08-22 16:58:25 UTC
Perhaps the values needed are hardcoded into the drivers (or the tunings)...

Another possibility, is that the drivers assume default values if the relevant values are not in the DSDT.
Comment 22 Mario Limonciello (AMD) 2022-08-22 19:32:49 UTC
FYI - this patch just went up.

https://patchwork.kernel.org/project/alsa-devel/patch/20220815162906.463108-1-sbinding@opensource.cirrus.com/
Comment 23 Cameron Berkenpas 2022-08-25 18:58:37 UTC
Created attachment 301660 [details]
Initial but dangerous support for Lenovo Legion 7i Gen7. Use at your own risk.

I went ahead and tried hard coding some values. This is against kernel 5.19.4 and sound does partially work.

It's all rather hacky, but you can make changes under the 'csc3551:' label in 'sound/pci/hda/cs35l41_hda.c'

But I do get left channel audio out of the right speaker. However, as a warning, I suspect this is fine, but I can't guarantee it. I get this potentially ominous message in dmesg:
[  412.976460] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.0: Amp short error

I think this is probably really easy to fix (just need to adjust some of the more obvious values I'd guess), but I don't have a lot of time today so I'm sharing it in case someone else wants to play with it.

If you don't have the same model of laptop as me, don't forget to add a quirk for your laptop under 'sound/pci/hda/patch_realtek.c'
Comment 24 Cameron Berkenpas 2022-08-26 04:20:37 UTC
Created attachment 301669 [details]
lenovo-7i-gen7-0.0.1.patch

This patch gives me full working sound on the Lenovo Legion 7i Gen 7 (16IAX7). It's for 5.19.4. I suspect it's fairly safe, but use at your own risk.

As it is, it won't be accepted into the kernel (and nor should it be). But it shows you can get sound working without the values in the DSDT.

I wonder if Cirrus Logic has plans to support quirks for different laptops, etc in their driver?

One big caveat, is that when resuming from sleep/hibernate, you will no longer have sound. Does anyone know if this is true in general for CSC3551 based systems? I know it's true for the CLSA0101 (which is supported by the same driver) and that a patch to fix that is coming eventually according to Cirrus Logic.

XiaoYan Li, this might work for you. You'll just need to add a quirk line for your specific model of laptop.
Comment 25 Mario Limonciello (AMD) 2022-08-26 12:44:24 UTC
> This patch gives me full working sound on the Lenovo Legion 7i Gen 7
> (16IAX7). It's for 5.19.4. I suspect it's fairly safe, but use at your own
> risk.

Good job!

> As it is, it won't be accepted into the kernel (and nor should it be). But it
> shows you can get sound working without the values in the DSDT.

Yeah not the way it's built up right now it wouldn't be.

> I wonder if Cirrus Logic has plans to support quirks for different laptops,
> etc in their driver?

You can certainly do a cleaner quirk from your existing patch that can potentially be mainlined and discuss it.  You'll want to add a DMI match table and just run that new code when your system is detected.
Comment 26 Cameron Berkenpas 2022-08-27 17:14:56 UTC
I reached out to the submitter of this patch to see if there is already some work to enable device specific works or at least plans for it:
https://www.spinics.net/lists/alsa-devel/msg146157.html

(In reply to Mario Limonciello (AMD) from comment #25)

> You can certainly do a cleaner quirk from your existing patch that can
> potentially be mainlined and discuss it.  You'll want to add a DMI match
> table and just run that new code when your system is detected.

Looking at the DMI match stuff, it seems fairly straight forward.

If there are not even plans to enable quirks for machines that lack the otherwise necessary _DSD properties, it's something I'd be willing work on.
Comment 27 Cameron Berkenpas 2022-08-31 01:15:09 UTC
Created attachment 301704 [details]
lenovo-7i-gen7-0.0.2.patch

No change in functionality, but cleaned up the original patch a bit.

I'm also setting the GPIO reset pin correctly (or at least less incorrectly) for each amp chip resulting in no longer seeing this message: "Reset line busy, assuming shared reset"
Comment 28 Mario Limonciello (AMD) 2022-09-07 21:07:20 UTC
At least another model was reported to have the same missing nodes (bug 216446).  So if your quirk methodology ends up working it would be good to get data for both models in place.
Comment 29 Cameron Berkenpas 2022-09-08 18:18:47 UTC
Unfortunately, Cirrus Logic got back to me and stated that what I'm doing isn't a great idea as utilizing the wrong settings could potentially physically damage your speakers.

I hadn't updated on this sooner to see if they'd follow up with me, but so far they have not.

If you have an unsupported model, your best bet is to ask the laptop vendor to update their BIOS with this information. Perhaps if a vendor gets enough requests, they may actually even do it.

I'm still holding off before I ask Lenovo, but if I don't hear back from Cirrus logic within the next 1-2 weeks, I'm going to give it a shot. In my experience, Lenovo has been pretty uncooperative with this sort of thing when it comes to models that aren't explicitly Linux supported so I won't be holding my breath.
Comment 30 Mario Limonciello (AMD) 2022-09-08 18:26:52 UTC
Thanks.

I think that's enough of a reason that we should close this issue.  Anyone affected by this should report the issue to the OEM to get fixed in BIOS.
Comment 31 Lina Anderson 2022-09-12 16:04:23 UTC
I opened a ticket with Asus for the UM3402Y and they've replied with "Our team has advised that we will forward this information to our senior team for review for future design consideration once we start supporting Linux OS."

Time to sit back and wait, but at least it's hopeful.
Comment 32 Cameron Berkenpas 2022-11-09 01:13:47 UTC
Created attachment 303151 [details]
lenovo-7i-gen7-sound-6.1.0-rc4-0.0.2.patch

Updated patch that works with 6.1-rc4. 6.1 has support for suspend/resume so in conjunction with this patch, you get full proper sound support. Still no issues with the speakers so probably in good shape.
Comment 33 Cameron Berkenpas 2022-12-30 22:13:02 UTC
Created attachment 303506 [details]
lenovo-7i-gen7-sound-6.2.0-rc1-0.0.3.patch

Currently, Nvidia drivers don't work with 6.2*, but 6.2* does allow you to increase your refresh rate to 165 Hz instead of being stuck at merely 60.

So this patch could be useful if you have no gaming or CUDA work worked planned in the near future. Plus, I'm getting ahead of 6.2* support.
Comment 34 Cameron Berkenpas 2022-12-30 22:14:02 UTC
NOTE: This is still use at your own risk. However, I have it on good word that after several months of Linux usage nearly absolutely everyday, there are no issues.

(In reply to Cameron Berkenpas from comment #33)
> Created attachment 303506 [details]
> lenovo-7i-gen7-sound-6.2.0-rc1-0.0.3.patch
> 
> Currently, Nvidia drivers don't work with 6.2*, but 6.2* does allow you to
> increase your refresh rate to 165 Hz instead of being stuck at merely 60.
> 
> So this patch could be useful if you have no gaming or CUDA work worked
> planned in the near future. Plus, I'm getting ahead of 6.2* support.
Comment 35 Mario Limonciello (AMD) 2023-01-03 23:06:02 UTC
As a "cleaner" patch perhaps you can do it as an DSDT/SSDT patch that is loaded by your bootloader (IE GRUB) or contained within the initrd.

It would also illustrate exactly what the OEM needs to put into their BIOS for them to fix it properly.
Comment 36 Cameron Berkenpas 2023-01-04 00:04:45 UTC
Unfortunately, I don't have exactly what's needed for this model of laptop. The values are guessed and there are several optional values that can be set (but of course, aren't). MIGHT be useful as an example?

I've already tried the approach with doing the DSDT approach and even had some success this way with the guessed values... But one speaker would keep going out with an "Amp Short" error in dmesg.

My patch behaves somewhat differently than what we get with the DSDT entries since it's based on an older version of the cs35l41 driver and so doesn't have that particular issue for whatever reason.

I suppose I could narrow it down to which part is results in this issue, but haven't had the time.

My current patch is the best that can be done for the Lenovo Legion 7i Gen 7, at least for now.

(In reply to Mario Limonciello (AMD) from comment #35)
> As a "cleaner" patch perhaps you can do it as an DSDT/SSDT patch that is
> loaded by your bootloader (IE GRUB) or contained within the initrd.
> 
> It would also illustrate exactly what the OEM needs to put into their BIOS
> for them to fix it properly.
Comment 37 jmaximusix 2023-01-06 21:22:19 UTC
Does this patch also work for the Legion Slim 7i Gen 7 (16IAH7)?
Comment 38 Cameron Berkenpas 2023-01-06 21:36:58 UTC
It could be adapted to work for it by adding a quirk.

That being said, the slim version likely needs different settings. Using 
wrong settings could damage the laptop.

How do I know this patch is fairly safe on the non-Slim Gen 7 Legion 79? 
Because it's been used  daily for months without issue.

On 1/6/2023 1:22 PM, bugzilla-daemon@kernel.org wrote:
> https://bugzilla.kernel.org/show_bug.cgi?id=216194
>
> jmaximusix@gmail.com changed:
>
>             What    |Removed                     |Added
> ----------------------------------------------------------------------------
>                   CC|                            |jmaximusix@gmail.com
>
> --- Comment #37 from jmaximusix@gmail.com ---
> Does this patch also work for the Legion Slim 7i Gen 7 (16IAH7)?
>
Comment 39 jmaximusix 2023-01-10 16:12:46 UTC
Thanks for your answer, however I have no clue on how to do that. Also, I don’t quite understand the meaning of these so calles “_DSD properties”, what exactly are they and in what way can wrong settings damage my hardware?
It would be super cool if you could tell me what information you need me to provide to make this work for my laptop model or if not, could you maybe point me in a direction on where to look to be able to adapt this to work for my laptop myself, but I’m not an expert, so I don‘t know if I’m able to.
Thanks in advance!


(In reply to Cameron Berkenpas from comment #38)
> It could be adapted to work for it by adding a quirk.
> 
> That being said, the slim version likely needs different settings. Using 
> wrong settings could damage the laptop.
> 
> How do I know this patch is fairly safe on the non-Slim Gen 7 Legion 79? 
> Because it's been used  daily for months without issue.
> 
> On 1/6/2023 1:22 PM, bugzilla-daemon@kernel.org wrote:
> > https://bugzilla.kernel.org/show_bug.cgi?id=216194
> >
> > jmaximusix@gmail.com changed:
> >
> >             What    |Removed                     |Added
> >
> ----------------------------------------------------------------------------
> >                   CC|                            |jmaximusix@gmail.com
> >
> > --- Comment #37 from jmaximusix@gmail.com ---
> > Does this patch also work for the Legion Slim 7i Gen 7 (16IAH7)?
> >
Comment 40 Mario Limonciello (AMD) 2023-01-10 16:15:31 UTC
_DSD properties are "Device Specific Data" for an ACPI device.  They are used to express how and what hardware is connected.  If you use the wrong values you might (for example) blow your speakers.
Comment 41 Cameron Berkenpas 2023-01-10 19:37:30 UTC
Created attachment 303570 [details]
lenovo-7i-gen7-sound-6.2.0-rc3-0.0.3.patch

The previous patch included a fix that is now already in rc3, preventing the old 6.2.0-rc1 patch from not applying cleaning to rc3. This fixes that.
Comment 42 jmaximusix 2023-01-10 19:47:07 UTC
So it'll work with the Legion Slim 7i Gen 7? Sorry if I'm asking dumb questions, just want to be sure, if so, thats absolutely amazing, thank you!

(In reply to Cameron Berkenpas from comment #41)
> Created attachment 303570 [details]
> lenovo-7i-gen7-sound-6.2.0-rc3-0.0.3.patch
> 
> The previous patch included a fix that is now already in rc3, preventing the
> old 6.2.0-rc1 patch from not applying cleaning to rc3. This fixes that.
Comment 43 jmaximusix 2023-01-10 20:59:57 UTC
Sorry, my bad, must have misunderstood, you just updated the fix for your laptop to the latest kernel, right?
Comment 44 Cameron Berkenpas 2023-01-10 21:20:15 UTC
(In reply to jmaximusix from comment #43)
> Sorry, my bad, must have misunderstood, you just updated the fix for your
> laptop to the latest kernel, right?

Correct. If you want me to add a quirk for your laptop, I need your alsa-info.
Comment 45 jmaximusix 2023-01-10 21:29:32 UTC
Here it is, if you need anything else let me know, thank you so much!
http://alsa-project.org/db/?f=b6e28d60ea6010ece2066e33c1bf1aa72f9f8d25
Comment 46 Cameron Berkenpas 2023-01-11 00:21:02 UTC
Created attachment 303571 [details]
lenovo-7i-gen7-sound-6.2.0-rc3-0.0.4.patch

Adds experimental Legion S7 16IAH7 (Gen 7 slim) support.

Other minor improvements.

At the very minimum, your kernel should have the following configured:
CONFIG_SND_HDA_SCODEC_CS35L41=m
CONFIG_SND_HDA_SCODEC_CS35L41_I2C=m
CONFIG_SND_HDA_SCODEC_CS35L41_SPI=m
CONFIG_SND_SOC_CS35L41_LIB=m
CONFIG_SND_SOC_CS35L41=m
CONFIG_SND_SOC_CS35L41_SPI=m
CONFIG_SND_SOC_CS35L41_I2C=m
Comment 47 jmaximusix 2023-01-11 18:50:50 UTC
Hi! Thank you so much for trying to help me out. Unfortunately, however, I wasn't able to make it work. Because I'm not an expert by any means tho, I'm not sure whether this could just be my fault.
Here's what I tried so far:

- downloaded kernel version 6.2.0-rc3 from kernel.org
- used the endeavourOS default .config and made sure the config options you mentioned are set (they already were)
- applied your patch and compiled the kernel
=> unfortunately still no working audio

I tried the same thing with a small modification to your patch, changing the "Legion 7 16IAH7" in line 128 to "Legion S7 16IAH7" since I wasn't quite sure if this was a typo (?), but still no success after recompiling the kernel

Am I missing something?
I'm also not sure if I just got some configs (alsa/whatever) wrong, I tried a bunch of things with no success yet. 

I also noticed that the output of `dmesg | grep error`
still lists:
[    0.009609] [Firmware Bug]: TSC ADJUST differs within socket(s), fixing all errors
[    5.349307] Serial bus multi instantiate pseudo device driver CSC3551:00: error -ENOENT: Error requesting irq at index 0
[    5.351682] Serial bus multi instantiate pseudo device driver: probe of CSC3551:00 failed with error -2
[    5.964098] platform regulatory.0: Direct firmware load for regulatory.db failed with error -2

and I'm not sure if the second and third line here imply that the fix in fact didn't work?

I'd really appreciate any help. If I can provide any other debugging information, just ask for it, I just don't know what to include here because I don't really know what's helpful
Thanks in advance!

(In reply to Cameron Berkenpas from comment #46)
> Created attachment 303571 [details]
> lenovo-7i-gen7-sound-6.2.0-rc3-0.0.4.patch
> 
> Adds experimental Legion S7 16IAH7 (Gen 7 slim) support.
> 
> Other minor improvements.
> 
> At the very minimum, your kernel should have the following configured:
> CONFIG_SND_HDA_SCODEC_CS35L41=m
> CONFIG_SND_HDA_SCODEC_CS35L41_I2C=m
> CONFIG_SND_HDA_SCODEC_CS35L41_SPI=m
> CONFIG_SND_SOC_CS35L41_LIB=m
> CONFIG_SND_SOC_CS35L41=m
> CONFIG_SND_SOC_CS35L41_SPI=m
> CONFIG_SND_SOC_CS35L41_I2C=m
Comment 48 Cameron Berkenpas 2023-01-11 21:52:08 UTC
My last follow up was blocked by SpamAssassin. So now I'm posting again through the site:

Are you sure you're running the right kernel? Try:
uname -a

Attach the entire contents of your dmesg to this bug.
Comment 49 jmaximusix 2023-01-11 22:14:54 UTC
Created attachment 303584 [details]
dmesg output on my Legion Slim 7i with patch applied

uname -r
-> 6.2.0-rc3-mylegionfix

So I definitely am running my custom kernel, however I don't really know how to 100% verify the patch has beed applied correctly (99.9% certain tho, at least I checked the files if they had been correctly changed before compiling it)

I attached the entire dmesg output, hope hat helps, and thanks so much for your time and patience.
Comment 50 Cameron Berkenpas 2023-01-11 22:36:20 UTC
(In reply to jmaximusix from comment #49)
> Created attachment 303584 [details]
> dmesg output on my Legion Slim 7i with patch applied
> 
> uname -r
> -> 6.2.0-rc3-mylegionfix
> 
> So I definitely am running my custom kernel, however I don't really know how
> to 100% verify the patch has beed applied correctly (99.9% certain tho, at
> least I checked the files if they had been correctly changed before
> compiling it)
> 
> I attached the entire dmesg output, hope hat helps, and thanks so much for
> your time and patience.

It seems it there's a problem getting the hardware going. This is a separate issue that occurs before any of the coded added by my hacky patch can even be run. Unfortunately, I don't know what it's happening.

Do you get the same kind of error with the stock kernel (assuming the stock kernel is recent enough for CSC3551 support)?

What version is your stock vendor kernel BTW?
Comment 51 Cameron Berkenpas 2023-01-11 22:38:48 UTC
I see from your alsa-info, that the stock vendor kernel is 6.1.4-arch1-1

That's definitely recent enough. What messages relating to CSC3551 do you get in dmesg there? If it's able to pick up the hardware... maybe there's a bug in 6.2 that affects you hardware.
Comment 52 jmaximusix 2023-01-12 00:04:16 UTC
The dmesg on the stock kernel contains the same 2 errors regarding "CSC3551".
I came across this bug where people seem to relate it back to cs35l41, I've got no clue about this stuff, but maybe you can make sense of it...

https://bugzilla.kernel.org/show_bug.cgi?id=215993

One comment also links to this:

https://github.com/CirrusLogic/linux-firmware/tree/main/cirrus/cs35l41

although I'm not quite certain if that means it's already in the linux kernel by now or not.

I might be completely on the wrong track here as I don't understand much of any of this, I'll try and look further into it tomorrow as much as I can but I doubt I'll find solutions completely on my own.

I don't take your further help for granted and really appreciate what you've already done for me, however I'd be very grateful if you could maybe take a look at it.
Thank you in advance!
Comment 53 Cameron Berkenpas 2023-01-12 03:34:50 UTC
(In reply to jmaximusix from comment #52)
> The dmesg on the stock kernel contains the same 2 errors regarding "CSC3551".
> I came across this bug where people seem to relate it back to cs35l41, I've
> got no clue about this stuff, but maybe you can make sense of it...
> 
> https://bugzilla.kernel.org/show_bug.cgi?id=215993
I saw that earlier too... May or may not be related.


> 
> One comment also links to this:
> 
> https://github.com/CirrusLogic/linux-firmware/tree/main/cirrus/cs35l41
> 
> although I'm not quite certain if that means it's already in the linux
> kernel by now or not.
Sadly, this is probably just for Lenovo's Linux supported laptops. Though it means that they do have some know-how on how to add the relevant DSD intros into the BIOS.

I'm not really sure what's going on here either... Maybe there's a way you can report this issue to Cirrus Logic? Most likely, your laptop is missing the DSD entries, so once this is fixed, you'd still need a workaround like my patch.

Cirrus Logic might be interested in fixing another corner case.

On a tangential note... The latest BIOS version for my laptop is from July. I think I've had it since September? Weird that Lenovo hasn't had any updates for it, but maybe we'll get lucky?

Make sure you have the latest BIOS. Even if updating doesn't add DSD entries (probably not), there is a _slight_ chance it could fix your current issue.
Comment 54 Josh Gao 2023-02-07 05:20:13 UTC
(In reply to Cameron Berkenpas from comment #46)
> Created attachment 303571 [details]
> lenovo-7i-gen7-sound-6.2.0-rc3-0.0.4.patch
> 
> Adds experimental Legion S7 16IAH7 (Gen 7 slim) support.
> 
> Other minor improvements.
> 
> At the very minimum, your kernel should have the following configured:
> CONFIG_SND_HDA_SCODEC_CS35L41=m
> CONFIG_SND_HDA_SCODEC_CS35L41_I2C=m
> CONFIG_SND_HDA_SCODEC_CS35L41_SPI=m
> CONFIG_SND_SOC_CS35L41_LIB=m
> CONFIG_SND_SOC_CS35L41=m
> CONFIG_SND_SOC_CS35L41_SPI=m
> CONFIG_SND_SOC_CS35L41_I2C=m

I'm happy to report that this patch works for the Lenovo ThinkBook Plus Gen 3 as well (17aa:3891)
Comment 55 Cameron Berkenpas 2023-02-07 06:37:55 UTC
That's great news. Thank you for reporting this!
Comment 56 Cameron Berkenpas 2023-02-28 20:09:11 UTC
Created attachment 303814 [details]
lenovo-7i-gen7-sound-6.2.0-rc3-0.0.5b.patch

Added experimental 16ARHA7 support.

This is a very much use at your own risk scenario. These are guessed values that have worked for the Legion 7i Gen 7 for an extended period of time without issue. 

Sounds like the Intel based 7i has been working (can anyone followup?) so this could be okay too. If you encounter issues which may include but is not limited to distorted sound, loudness, and perhaps "amp short" errors in dmesg, stop using this patch for your slim.
Comment 57 Jacopo G. Chen 2023-03-01 15:47:49 UTC
(In reply to Cameron Berkenpas from comment #46)
> Created attachment 303571 [details]
> lenovo-7i-gen7-sound-6.2.0-rc3-0.0.4.patch
> 
> Adds experimental Legion S7 16IAH7 (Gen 7 slim) support.

Hi Cameron, I have a Legion 7 16IAX7, so I tried to apply your patch, but I still have no sound. I am running kernel 6.2.1, so I applied the patch manually since the line numbers didn't match. The kernel works just fine, with the following dmesg outputs:

(stock kernel)
$ uname -sr
Linux 6.2.1-arch1-1
$ sudo dmesg | grep CSC3551
[    3.453341] Serial bus multi instantiate pseudo device driver CSC3551:00: Instantiated 2 I2C devices.
[    3.550639] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.0: Error: ACPI _DSD Properties are missing for HID CSC3551.
[    3.551697] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.0: error -EINVAL: Platform not supported
[    3.552809] cs35l41-hda: probe of i2c-CSC3551:00-cs35l41-hda.0 failed with error -22
[    3.553217] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.1: Error: ACPI _DSD Properties are missing for HID CSC3551.
[    3.554134] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.1: error -EINVAL: Platform not supported
[    3.555026] cs35l41-hda: probe of i2c-CSC3551:00-cs35l41-hda.1 failed with error -22

(with patch)
$ uname -sr
Linux 6.2.1-arch1-1-legion7
$ sudo dmesg | grep CSC3551
[    3.224156] Serial bus multi instantiate pseudo device driver CSC3551:00: Instantiated 2 I2C devices.
[    3.382932] CSC3551: probing CSC3551
[    3.382976] CSC3551: no_acpi_dsd: CSC3551
[    3.382978] CSC3551: id == 0x40
[    3.383156] CSC3551: Done.
[    3.437900] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.0: Cirrus Logic CS35L41 (35a40), Revision: B2
[    3.437945] CSC3551: probing CSC3551
[    3.437963] CSC3551: no_acpi_dsd: CSC3551
[    3.437963] CSC3551: id == 0x41
[    3.438058] CSC3551: Done.
[    3.475528] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.1: Cirrus Logic CS35L41 (35a40), Revision: B2

However as I said there is still no sound (even on the fallback initramfs, fwiw). What do you think could be the reason? Thank you for all your work on this issue.
Comment 58 Cameron Berkenpas 2023-03-01 15:59:35 UTC
Are you sure none of your sound is muted? This is something I've seen 
many times over the years.

Try alsa-mixer maybe?

Try the sound settings for your laptop. Maybe something (like the output 
device) is misconfigured?

The output from the patched kernel strongly suggests it's working 
(though there's likely more related dmesg output than what you've shared 
which could be helpful).

In case it wasn't clear, I have the exact same model of laptop as you so 
it should definitely work.

On 3/1/23 07:47, bugzilla-daemon@kernel.org wrote:
> https://bugzilla.kernel.org/show_bug.cgi?id=216194
>
> Jacopo G. Chen (jacopo.chen256@gmail.com) changed:
>
>             What    |Removed                     |Added
> ----------------------------------------------------------------------------
>                   CC|                            |jacopo.chen256@gmail.com
>
> --- Comment #57 from Jacopo G. Chen (jacopo.chen256@gmail.com) ---
> (In reply to Cameron Berkenpas from comment #46)
>> Created attachment 303571 [details]
>> lenovo-7i-gen7-sound-6.2.0-rc3-0.0.4.patch
>>
>> Adds experimental Legion S7 16IAH7 (Gen 7 slim) support.
> Hi Cameron, I have a Legion 7 16IAX7, so I tried to apply your patch, but I
> still have no sound. I am running kernel 6.2.1, so I applied the patch
> manually
> since the line numbers didn't match. The kernel works just fine, with the
> following dmesg outputs:
>
> (stock kernel)
> $ uname -sr
> Linux 6.2.1-arch1-1
> $ sudo dmesg | grep CSC3551
> [    3.453341] Serial bus multi instantiate pseudo device driver CSC3551:00:
> Instantiated 2 I2C devices.
> [    3.550639] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.0: Error: ACPI _DSD
> Properties are missing for HID CSC3551.
> [    3.551697] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.0: error -EINVAL:
> Platform not supported
> [    3.552809] cs35l41-hda: probe of i2c-CSC3551:00-cs35l41-hda.0 failed with
> error -22
> [    3.553217] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.1: Error: ACPI _DSD
> Properties are missing for HID CSC3551.
> [    3.554134] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.1: error -EINVAL:
> Platform not supported
> [    3.555026] cs35l41-hda: probe of i2c-CSC3551:00-cs35l41-hda.1 failed with
> error -22
>
> (with patch)
> $ uname -sr
> Linux 6.2.1-arch1-1-legion7
> $ sudo dmesg | grep CSC3551
> [    3.224156] Serial bus multi instantiate pseudo device driver CSC3551:00:
> Instantiated 2 I2C devices.
> [    3.382932] CSC3551: probing CSC3551
> [    3.382976] CSC3551: no_acpi_dsd: CSC3551
> [    3.382978] CSC3551: id == 0x40
> [    3.383156] CSC3551: Done.
> [    3.437900] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.0: Cirrus Logic CS35L41
> (35a40), Revision: B2
> [    3.437945] CSC3551: probing CSC3551
> [    3.437963] CSC3551: no_acpi_dsd: CSC3551
> [    3.437963] CSC3551: id == 0x41
> [    3.438058] CSC3551: Done.
> [    3.475528] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.1: Cirrus Logic CS35L41
> (35a40), Revision: B2
>
> However as I said there is still no sound (even on the fallback initramfs,
> fwiw). What do you think could be the reason? Thank you for all your work on
> this issue.
>
Comment 59 Jacopo G. Chen 2023-03-01 16:54:18 UTC
Created attachment 303823 [details]
dmesg on patched Legion 7 16IAX7

Thank you for your quick reply. Here is the output from dmesg on the patched kernel (uname -sr --> Linux 6.2.1-arch1-1-legion7). I tried speaker-test and the tests from KDE's audio settings, with both intel and nvidia cards, to no avail. Alsamixer shows nothing muted except for S/PDIF (unmuting it changes nothing). When I try to play some sound, the system tray GUI volume indicator moves (showing changes in output volume),
I use wireplumber, but this should be immaterial: in my understanding speaker-test is more low-level as it interfaces directly with ALSA.
Comment 60 Cameron Berkenpas 2023-03-01 18:47:02 UTC
Created attachment 303824 [details]
attachment-26853-0.html

What BIOS version are you running? I'm running the latest from here:
https://pcsupport.lenovo.com/us/en/products/laptops-and-netbooks/legion-series/legion-7-16iax7/downloads/driver-list/component?name=BIOS%2FUEFI

Which is version K1CN40WW

I doubt that's the reason, but worth a shot if you haven't tried it.

Can you provide a link to your alsa-info? I don't think you've provided 
that yet.

Here's what my output looks like:
[   15.163991] Serial bus multi instantiate pseudo device driver 
CSC3551:00: Instantiated 2 I2C devices.
[   15.177667] CSC3551: probing CSC3551
[   15.177687] CSC3551: no_acpi_dsd: CSC3551
[   15.177688] CSC3551: id == 0x40
[   15.177689] Serial bus multi instantiate pseudo device driver 
CSC3551:00: using ACPI '\_SB.PC00.I2C2.SPK1' for '(null)' GPIO lookup
[   15.177694] acpi CSC3551:00: GPIO: looking up gpios
[   15.177696] acpi CSC3551:00: GPIO: looking up gpio
[   15.177697] acpi CSC3551:00: GPIO: looking up 0 in _CRS
[   15.177835] CS3551: reset_gpio == 0xc5058618
[   15.177837] CSC3551: Done.
[   15.207653] snd_hda_codec_realtek hdaudioC0D0: autoconfig for ALC287: 
line_outs=1 (0x17/0x0/0x0/0x0/0x0) type:speaker
[   15.207655] snd_hda_codec_realtek hdaudioC0D0: speaker_outs=0 
(0x0/0x0/0x0/0x0/0x0)
[   15.214974] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.0: Cirrus Logic 
CS35L41 (35a40), Revision: B2
[   15.215017] CSC3551: probing CSC3551
[   15.215431] CSC3551: no_acpi_dsd: CSC3551
[   15.215432] CSC3551: id == 0x41
[   15.215434] Serial bus multi instantiate pseudo device driver 
CSC3551:00: using ACPI '\_SB.PC00.I2C2.SPK1' for '(null)' GPIO lookup
[   15.215438] acpi CSC3551:00: GPIO: looking up gpios
[   15.215440] acpi CSC3551:00: GPIO: looking up gpio
[   15.215441] acpi CSC3551:00: GPIO: looking up 1 in _CRS
[   15.215998] acpi CSC3551:00: Override GPIO initialization flags
[   15.216136] CS3551: reset_gpio == 0xc50585f0
[   15.216139] CSC3551: Done.
[   15.253685] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.0: DSP1: Firmware 
version: 3
[   15.253687] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.0: DSP1: 
cirrus/cs35l41-dsp1-spk-prot.wmfw: Fri 24 Jun 2022 14:55:56 GMT Daylight 
Time
[   15.716983] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.0: DSP1: Firmware: 
400a4 vendor: 0x2 v0.58.0, 2 algorithms
[   15.718190] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.0: DSP1: 0: ID cd 
v29.78.0 XM@94 YM@e
[   15.718208] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.0: DSP1: 1: ID 
f20b v0.1.0 XM@17c YM@0
[   15.718219] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.0: DSP1: spk-prot: 
e:\workspace\workspace\tibranch_release_playback_6.76_2\ormis\staging\default_tunings\internal\CS35L53\Fixed_Attenuation_Mono_48000_29.78.0\full\Fixed_Attenuation_Mono_48000_29.78.0_full.bin
[   15.734385] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.0: Cannot Write 
Control: CAL_AMBIENT - 1
[   15.734390] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.0: Cannot 
Initialize Firmware. Error: 1
[   15.735295] snd_hda_codec_realtek hdaudioC0D0: bound 
i2c-CSC3551:00-cs35l41-hda.0 (ops cs35l41_hda_playback_hook.cold 
[snd_hda_scodec_cs35l41])
[   15.735327] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.1: DSP1: Firmware 
version: 3
[   15.735328] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.1: DSP1: 
cirrus/cs35l41-dsp1-spk-prot.wmfw: Fri 24 Jun 2022 14:55:56 GMT Daylight 
Time
[   16.198676] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.1: DSP1: Firmware: 
400a4 vendor: 0x2 v0.58.0, 2 algorithms
[   16.199910] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.1: DSP1: 0: ID cd 
v29.78.0 XM@94 YM@e
[   16.199928] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.1: DSP1: 1: ID 
f20b v0.1.0 XM@17c YM@0
[   16.199935] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.1: DSP1: spk-prot: 
e:\workspace\workspace\tibranch_release_playback_6.76_2\ormis\staging\default_tunings\internal\CS35L53\Fixed_Attenuation_Mono_48000_29.78.0\full\Fixed_Attenuation_Mono_48000_29.78.0_full.bin
[   16.216078] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.1: Cannot Write 
Control: CAL_AMBIENT - 1
[   16.216083] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.1: Cannot 
Initialize Firmware. Error: 1


The only thing that stands out is the reset_gp io address... but I think 
that's probably not the cause. Both our addresses are in the upper 3GB 
for kernel space and nothing indicates an error so it's probably nothing.

On 3/1/23 08:54, bugzilla-daemon@kernel.org wrote:
> https://bugzilla.kernel.org/show_bug.cgi?id=216194
>
> --- Comment #59 from Jacopo G. Chen (jacopo.chen256@gmail.com) ---
> Created attachment 303823 [details]
>    -->https://bugzilla.kernel.org/attachment.cgi?id=303823&action=edit
> dmesg on patched Legion 7 16IAX7
>
> Thank you for your quick reply. Here is the output from dmesg on the patched
> kernel (uname -sr --> Linux 6.2.1-arch1-1-legion7). I tried speaker-test and
> the tests from KDE's audio settings, with both intel and nvidia cards, to no
> avail. Alsamixer shows nothing muted except for S/PDIF (unmuting it changes
> nothing). When I try to play some sound, the system tray GUI volume indicator
> moves (showing changes in output volume),
> I use wireplumber, but this should be immaterial: in my understanding
> speaker-test is more low-level as it interfaces directly with ALSA.
>
Comment 61 Cameron Berkenpas 2023-03-01 18:50:29 UTC
Maybe you're missing some CS35l41 related options? 

Here's what I have:
CONFIG_SND_HDA_SCODEC_CS35L41=m
CONFIG_SND_HDA_SCODEC_CS35L41_I2C=m
CONFIG_SND_HDA_SCODEC_CS35L41_SPI=m
CONFIG_SND_SOC_CS35L41_LIB=m
CONFIG_SND_SOC_CS35L41=m
CONFIG_SND_SOC_CS35L41_SPI=m
CONFIG_SND_SOC_CS35L41_I2C=m
Comment 62 Jacopo G. Chen 2023-03-01 21:53:46 UTC
Created attachment 303825 [details]
Output of alsa-info script

I attached the output from alsa-info. I used to run the K1CN38WW BIOS and have just updated it to version K1CN40WW (no change). All the config flags are as you said:

$ zcat /proc/config.gz > file.config
$ cat file.config | grep CS35L41
CONFIG_SND_HDA_SCODEC_CS35L41=m
CONFIG_SND_HDA_SCODEC_CS35L41_I2C=m
CONFIG_SND_HDA_SCODEC_CS35L41_SPI=m
CONFIG_SND_SOC_CS35L41_LIB=m
CONFIG_SND_SOC_CS35L41=m
CONFIG_SND_SOC_CS35L41_SPI=m
CONFIG_SND_SOC_CS35L41_I2C=m
Comment 63 Cameron Berkenpas 2023-03-01 22:47:53 UTC
Created attachment 303826 [details]
lenovo-7i-gen7-sound-6.2.0-rc3-0.0.5b-001.patch

Found the problem. Jacopo and I have slightly different revisions of the same laptop and therefore have different subsystem ID's.

Here's an updated patch that adds this revision's subsystem ID to use the quirk.
Comment 64 Jacopo G. Chen 2023-03-02 00:17:39 UTC
(In reply to Cameron Berkenpas from comment #63)
> Created attachment 303826 [details]
> lenovo-7i-gen7-sound-6.2.0-rc3-0.0.5b-001.patch
> 
> Found the problem. Jacopo and I have slightly different revisions of the
> same laptop and therefore have different subsystem ID's.
> 
> Here's an updated patch that adds this revision's subsystem ID to use the
> quirk.

Now it works, this is the best! There's a little "click" sometimes when a sound starts playing, but I guess that's just a software glitch, as it goes away when trying to reproduce it.

Thank you Cameron, you really helped me!
Comment 65 Cameron Berkenpas 2023-03-02 00:41:55 UTC
See if the click occurs with all software. When it happens, try "dmesg 
-T" (to get a timestamp) and see if any messages line up.

I don't recall that happening to me, but I could just be tuning it out.

What I think might be happening... is that when there hasn't been any 
audio output for a while, the speakers/amp chips go to sleep and have to 
be woken back up. In such situations, I notice there's a small delay in 
audio output starting up again (probably a bit less than a second, but 
I've never tried to time it) so that could it. If that's the case, 
you'll likely see some output in dmesg corresponding to the CSC3551's 
being woken back up.

If you notice one speaker going out (or both), keep an eye out for "amp 
short" errors in dmesg. When those happen, you'll temporarily lose sound 
in the affected speakers... Eventually it will recover. When this is an 
issue, it's more likely to occur at high volumes (so worth looking for!).

There's no documentation in the code as to what these errors mean... but 
I think what's happening is that the amp chip has determined that 
whatever it's sending to the speaker is perhaps out of bounds so that's 
not good and probably you would want to avoid using the patch until we 
can figure something out. So definitely test this out. If you're able to 
play some music at a high volume for a couple of minutes without issue, 
I think you're safe from this particular "amp short" issue.

But this is very encouraging news! I'm glad we got this working for you! 
I think it's ridiculous that in 2023 we can't just have working sound in 
Linux on x86. I remember buying an ISA Soundblaster 16 in 1999 to ensure 
sound would work under Linux then having to pass parameters to the 
module such as the ioport, etc. We've come so far since then, but some 
vendors are still so obtuse about these things.

On 3/1/23 16:17, bugzilla-daemon@kernel.org wrote:
> https://bugzilla.kernel.org/show_bug.cgi?id=216194
>
> --- Comment #64 from Jacopo G. Chen (jacopo.chen256@gmail.com) ---
> (In reply to Cameron Berkenpas from comment #63)
>> Created attachment 303826 [details]
>> lenovo-7i-gen7-sound-6.2.0-rc3-0.0.5b-001.patch
>>
>> Found the problem. Jacopo and I have slightly different revisions of the
>> same laptop and therefore have different subsystem ID's.
>>
>> Here's an updated patch that adds this revision's subsystem ID to use the
>> quirk.
> Now it works, this is the best! There's a little "click" sometimes when a
> sound
> starts playing, but I guess that's just a software glitch, as it goes away
> when
> trying to reproduce it.
>
> Thank you Cameron, you really helped me!
>
Comment 66 Cameron Berkenpas 2023-03-02 01:14:52 UTC
Created attachment 303828 [details]
lenovo-7i-gen7-sound-6.2.0-rc3-0.0.5b-002.patch

This patch theoretically supports the following models:
+       SND_PCI_QUIRK(0x17aa, 0x3874, "Legion 7 16IAX7", ALC287_FIXUP_CS35L41_I2C_2),
+       SND_PCI_QUIRK(0x17aa, 0x386f, "Legion 7 16IAX7", ALC287_FIXUP_CS35L41_I2C_2),
+       SND_PCI_QUIRK(0x17aa, 0x3803, "Legion 7i slim 16IAH7", ALC287_FIXUP_CS35L41_I2C_2),
+       SND_PCI_QUIRK(0x17aa, 0x3856, "Yoga Slim 7 Carbon 14ACN6", ALC287_FIXUP_CS35L41_I2C_2),
+       SND_PCI_QUIRK(0x17aa, 0x3877, "Legion 7 slim 16ARHA7", ALC287_FIXUP_CS35L41_I2C_2),

The Lenovo Legion 7i Gen 7 16IAX7 seems pretty safe (and has had by far the most testing). 

That being said, all support provided by this patch is USE AT YOUR OWN RISK. Different models of laptop theoretically have different values (that should be provided via the DSD table in the BIOS). These are guessed values that work for the 16IAX7 and possibly others. I can't make any guarantees.

If you have problems with your sound, overly loud volume, distorted sound, "AMP short" errors (see below), back out the patch and update this bug with your feedback (giving your alsa-info)

If you get "AMP short" messages in dmesg, it's probably wise to back out the patch as I suspect prolonged usage could result. To test for this, just play some music out a very high volume for a few minutes. You may notice one or both of your speakers going out (and you'll see "AMP short" messages in dmesg). If this happens, back the patch out. 

With "AMP short" errors, once audio output has been stopped for probablly 5+ minutes, the affected speakers will "recover", but eventually they'll fail again. Just because they might start working again doesn't mean there isn't a serious problem. Just back out the patch and provide feedback.

If you don't get any sound at all... Provide your alsa-info and your full dmesg output. If you see a message such as "Serial bus multi instantiate pseudo device driver CSC3551:00: error -ENOENT: Error requesting irq at index 0", this is an issue that occurs before my patch. There's an issue with the cs35l41 driver where it's not able to detect the CSC3551's on your model of laptop. Reporting this to Cirrus Logic may help and AFTER that issue is fixed... You may still need my patch.

If the patch works, please provide feedback with your alsa-info. With all the info, my hope is that we'll have an eventual "safe list" of laptop models for this patch.
Comment 67 Jacopo G. Chen 2023-03-02 15:34:38 UTC
Created attachment 303831 [details]
dmesg + alsa-info

Update: sound in general still works great (the nVidia sound card does not work but I think that's an alsa config issue). Clicks happen upon opening sound related apps like spotify but leave no trace on dmesg.
However, it appears that some errors are triggered in cs35l41_hda.c (functions: static int cs35l41_apply_calibration, static int cs35l41_smart_amp):

[    6.940102] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.0: Cannot Write Control: CAL_AMBIENT - 1
[    6.940971] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.0: Cannot Initialize Firmware. Error: 1

Not really an issue, I played loud music without speakers going out/short amp errors.
Comment 68 Mario Limonciello (AMD) 2023-03-02 15:37:52 UTC
As a suggestion since this patch isn't likely to be accepted by the Cirrus driver maintainers in it's current form it might be best to open up a central place for you to work with people on it and iterate rather than this kernel bug tracker.

Maybe like a personal Github repo?
Comment 69 Cameron Berkenpas 2023-03-02 16:41:49 UTC
Yeah, those errors are expected. I get the same. It's due to the hackish 
nature of the patch.

I think the Nvidia sound is something that needs an external monitor to 
work (ie, via HDMI or displayport).

I'm a bit concerned by the clicks though... But unsure if that problem 
is serious.

On 3/2/23 07:34, bugzilla-daemon@kernel.org wrote:
> https://bugzilla.kernel.org/show_bug.cgi?id=216194
>
> --- Comment #67 from Jacopo G. Chen (jacopo.chen256@gmail.com) ---
> Created attachment 303831 [details]
>    --> https://bugzilla.kernel.org/attachment.cgi?id=303831&action=edit
> dmesg + alsa-info
>
> Update: sound in general still works great (the nVidia sound card does not
> work
> but I think that's an alsa config issue). Clicks happen upon opening sound
> related apps like spotify but leave no trace on dmesg.
> However, it appears that some errors are triggered in cs35l41_hda.c
> (functions:
> static int cs35l41_apply_calibration, static int cs35l41_smart_amp):
>
> [    6.940102] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.0: Cannot Write
> Control:
> CAL_AMBIENT - 1
> [    6.940971] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.0: Cannot Initialize
> Firmware. Error: 1
>
> Not really an issue, I played loud music without speakers going out/short amp
> errors.
>
Comment 70 Olivier 2023-03-05 08:57:25 UTC
Hello,

I've the issue with Lenovo Legion 7i but I don't know how to install these patches,
I'm a novice with linux please help me with steps

Thank you
Comment 71 Cameron Berkenpas 2023-03-05 18:32:38 UTC
You'll have to read up on how to compile a custom kernel for your 
distribution.

On 3/5/23 00:57, bugzilla-daemon@kernel.org wrote:
> https://bugzilla.kernel.org/show_bug.cgi?id=216194
>
> Olivier (onlinetwisto@gmail.com) changed:
>
>             What    |Removed                     |Added
> ----------------------------------------------------------------------------
>                   CC|                            |onlinetwisto@gmail.com
>
> --- Comment #70 from Olivier (onlinetwisto@gmail.com) ---
> Hello,
>
> I've the issue with Lenovo Legion 7i but I don't know how to install these
> patches,
> I'm a novice with linux please help me with steps
>
> Thank you
>
Comment 72 antidense 2023-03-05 20:38:46 UTC
I wanted to confirm that I got this working for 16ARHA7 (Lenovo Legion 7 AMD)

I used the instructions here for archlinux (which is what I run):

https://wiki.archlinux.org/title/Kernel/Traditional_compilation

I just used this command to patch it after unzipping the kernel:

    make mrproper
    zcat /proc/config.gz  > .config
    patch -p1 < ./lenovo-7i-gen7-sound-6.2.0-rc3-0.0.5b-002.patch 
    make -j$(nproc)
    make modules
    sudo make modules_install
    make bzImage


Then had to copy the kernel, make the initramfs and update the bootloader.

No problems with amp shorts so far, but I will watch it.
Comment 73 Cameron Berkenpas 2023-03-05 21:14:53 UTC
Created attachment 303877 [details]
attachment-26271-0.html

That's great news! If there are no problems over the next few months, 
please update us.

That being said... And this is for everyone: As Mario Limonciello 
suggested... At some point, this discussion and these patches should be 
moved out of this kernel bug.  Once I'm able to do that, I'll ask that 
people look for updated patches there as well as for providing status 
updates.

That's still a little ways off yet, as I'm a pretty busy guy (I was only 
able to do some more work on this because I was out sick recently). When 
the time comes, I'll update this bug with the new location.

On 3/5/2023 12:38 PM, bugzilla-daemon@kernel.org wrote:
> https://bugzilla.kernel.org/show_bug.cgi?id=216194
>
> antidense@gmail.com  changed:
>
>             What    |Removed                     |Added
> ----------------------------------------------------------------------------
>                   CC|                            |antidense@gmail.com
>
> --- Comment #72 fromantidense@gmail.com  ---
> I wanted to confirm that I got this working for 16ARHA7 (Lenovo Legion 7 AMD)
>
> I used the instructions here for archlinux (which is what I run):
>
> https://wiki.archlinux.org/title/Kernel/Traditional_compilation
>
> I just used this command to patch it after unzipping the kernel:
>
>      make mrproper
>      zcat /proc/config.gz  > .config
>      patch -p1 < ./lenovo-7i-gen7-sound-6.2.0-rc3-0.0.5b-002.patch
>      make -j$(nproc)
>      make modules
>      sudo make modules_install
>      make bzImage
>
>
> Then had to copy the kernel, make the initramfs and update the bootloader.
>
> No problems with amp shorts so far, but I will watch it.
>
Comment 74 Blake Lee 2023-03-07 19:04:40 UTC
(In reply to Cameron Berkenpas from comment #73)
> Created attachment 303877 [details]
> attachment-26271-0.html
> 
> That's great news! If there are no problems over the next few months, 
> please update us.
> 
> That being said... And this is for everyone: As Mario Limonciello 
> suggested... At some point, this discussion and these patches should be 
> moved out of this kernel bug.  Once I'm able to do that, I'll ask that 
> people look for updated patches there as well as for providing status 
> updates.
> 
> That's still a little ways off yet, as I'm a pretty busy guy (I was only 
> able to do some more work on this because I was out sick recently). When 
> the time comes, I'll update this bug with the new location.
> 
> On 3/5/2023 12:38 PM, bugzilla-daemon@kernel.org wrote:
> > https://bugzilla.kernel.org/show_bug.cgi?id=216194
> >
> > antidense@gmail.com  changed:
> >
> >             What    |Removed                     |Added
> >
> ----------------------------------------------------------------------------
> >                   CC|                            |antidense@gmail.com
> >
> > --- Comment #72 fromantidense@gmail.com  ---
> > I wanted to confirm that I got this working for 16ARHA7 (Lenovo Legion 7
> AMD)
> >
> > I used the instructions here for archlinux (which is what I run):
> >
> > https://wiki.archlinux.org/title/Kernel/Traditional_compilation
> >
> > I just used this command to patch it after unzipping the kernel:
> >
> >      make mrproper
> >      zcat /proc/config.gz  > .config
> >      patch -p1 < ./lenovo-7i-gen7-sound-6.2.0-rc3-0.0.5b-002.patch
> >      make -j$(nproc)
> >      make modules
> >      sudo make modules_install
> >      make bzImage
> >
> >
> > Then had to copy the kernel, make the initramfs and update the bootloader.
> >
> > No problems with amp shorts so far, but I will watch it.
> >

Hey Cameron, 

If you are still working on or looking into your alternate DSD patch, I noticed on my laptop below the Ctrl key it says "Audio By Harman". I looked them up and they produce speaker systems of all kinds, from laptop systems to bluetooth speakers, and so I wonder if they would be more forthcoming on the appropriate DSD info or verbs to send?

Just a thought, thank you for all you do,
Blake Lee
Comment 75 Cameron Berkenpas 2023-03-07 19:31:08 UTC
No, they can't help here.

The values are needed by the Cirrus Logic amplifier chips, and the 
values are specific to the model of laptop. These values depend on the 
type and setup of the speakers, and these details are largely unique to 
the model of laptop. Values that are way out of range relative to your 
model of laptop can potentially cause physical damage.

This is why Lenovo needs to do this. Only they have this information 
about their own laptop designs.

For the Lenovo 7i Gen 7, these values seem completely safe. No issues 
have developed since August or September (I forget which) since the 
initial version of the patch was released. I'm hoping these values that 
I've guessed are largely conservative to avoid as much risk as possible, 
but I really have no idea and this is why I'm clear this is a 
use-at-your-own-risk situation.

On 3/7/23 11:04, bugzilla-daemon@kernel.org wrote:
> https://bugzilla.kernel.org/show_bug.cgi?id=216194
>
> Blake Lee (blake99lee@gmail.com) changed:
>
>             What    |Removed                     |Added
> ----------------------------------------------------------------------------
>                   CC|                            |blake99lee@gmail.com
>
> --- Comment #74 from Blake Lee (blake99lee@gmail.com) ---
> (In reply to Cameron Berkenpas from comment #73)
>> Created attachment 303877 [details]
>> attachment-26271-0.html
>>
>> That's great news! If there are no problems over the next few months,
>> please update us.
>>
>> That being said... And this is for everyone: As Mario Limonciello
>> suggested... At some point, this discussion and these patches should be
>> moved out of this kernel bug.  Once I'm able to do that, I'll ask that
>> people look for updated patches there as well as for providing status
>> updates.
>>
>> That's still a little ways off yet, as I'm a pretty busy guy (I was only
>> able to do some more work on this because I was out sick recently). When
>> the time comes, I'll update this bug with the new location.
>>
>> On 3/5/2023 12:38 PM, bugzilla-daemon@kernel.org wrote:
>>> https://bugzilla.kernel.org/show_bug.cgi?id=216194
>>>
>>> antidense@gmail.com  changed:
>>>
>>>              What    |Removed                     |Added
>>>
>> ----------------------------------------------------------------------------
>>>                    CC|                            |antidense@gmail.com
>>>
>>> --- Comment #72 fromantidense@gmail.com  ---
>>> I wanted to confirm that I got this working for 16ARHA7 (Lenovo Legion 7
>> AMD)
>>> I used the instructions here for archlinux (which is what I run):
>>>
>>> https://wiki.archlinux.org/title/Kernel/Traditional_compilation
>>>
>>> I just used this command to patch it after unzipping the kernel:
>>>
>>>       make mrproper
>>>       zcat /proc/config.gz  > .config
>>>       patch -p1 < ./lenovo-7i-gen7-sound-6.2.0-rc3-0.0.5b-002.patch
>>>       make -j$(nproc)
>>>       make modules
>>>       sudo make modules_install
>>>       make bzImage
>>>
>>>
>>> Then had to copy the kernel, make the initramfs and update the bootloader.
>>>
>>> No problems with amp shorts so far, but I will watch it.
>>>
> Hey Cameron,
>
> If you are still working on or looking into your alternate DSD patch, I
> noticed
> on my laptop below the Ctrl key it says "Audio By Harman". I looked them up
> and
> they produce speaker systems of all kinds, from laptop systems to bluetooth
> speakers, and so I wonder if they would be more forthcoming on the
> appropriate
> DSD info or verbs to send?
>
> Just a thought, thank you for all you do,
> Blake Lee
>
Comment 76 Carlo Francesco 2023-03-15 20:21:14 UTC
Hello All :)
I jump in the conversation, which I was lurking for a while hoping for a patch to my Legion pro 7 16IRX8H . I guess it's too recent to receive any feedback on this model :O

Long story short, I tried n+1 combinations of possible solutions, with n->∞

I even opened a 3ed at Lenovo, https://forums.lenovo.com/t5/Ubuntu/Ubuntu-and-legion-pro-7-16IRX8H-audio-issues/m-p/5210709?page=1#5924344 , that they glossed over with much nonchalance by moving my post to the Linux pile of non working things.
My last resource was the wizardry made by Cameron by applying a patch to the lenovo-7i-gen7-sound-6.2.0-rc3-0.0.5b-002.patch, namely adding the pci sound quirk for my sound card
	SND_PCI_QUIRK(0x17aa, 0x3846, "Legion 7 Pro 16IRX8H", ALC287_FIXUP_CS35L41_I2C_2),
hwinfo --sound reports:
Model: "Intel Audio device"
  Vendor: pci 0x8086 "Intel Corporation"
  Device: pci 0x7a50 
  SubVendor: pci 0x17aa "Lenovo"
  SubDevice: pci 0x3846 
...
Model: "nVidia Audio device"
  Vendor: pci 0x10de "nVidia Corporation"
  Device: pci 0x22bc 
  SubVendor: pci 0xffff "Illegal Vendor ID"
  SubDevice: pci 0xffff 

Unfortunately, it doesn't work. If you have any idea or guide to rip these DSD info or verbs, I will try to contribute as much as I can.
PS, funny thing: I bought the laptop with no OS, so I can't say that my speakers are actually working -.-

Thanks a lot to everyone!
Comment 77 Cameron Berkenpas 2023-03-15 21:05:49 UTC
You're going to need some tools to grab the DSDT table. On Ubuntu you can do this with:
sudo apt install acpica-tools

# From there you can do:
mkdir /tmp/dsdt
cd /tmp/dsdt
sudo cat /sys/firmware/acpi/tables/DSDT > dsdt.dat
iasl -d dsdt.dat

# You should then have:
/tmp/dsdt/dsdt.dsl

Attach dsdt.dsl to this ticket and call it something like dsdt.dsl-16IRX8H so I can take a look at it.

If what you need is in there... you need a _very_ simple patch that will be accepted upstream. If not, probably need add support for your laptop to my hacked up patch.. and it will mean I'm definitely going for another brand of laptop next purchase.
Comment 78 Cameron Berkenpas 2023-03-15 21:07:04 UTC
Scratch that, I see you added your own quirk and it didn't work. You should attach your dmesg and provide the link to your alsa-info.
Comment 79 Carlo Francesco 2023-03-15 21:25:00 UTC
Created attachment 303959 [details]
legion pro 7 16IRX8H dsdt FILE
Comment 80 Carlo Francesco 2023-03-15 21:34:10 UTC
Hello Cameron, 
thanks a lot! What I've tested is actually using your patch and added in "patch_realtek.c"  section the 
	+SND_PCI_QUIRK(0x17aa, 0x3846, "Legion 7 Pro 16IRX8H", ALC287_FIXUP_CS35L41_I2C_2),
gathering the PCI address from  hwinfo --sound: 
Model: "Intel Audio device"
  Vendor: pci 0x8086 "Intel Corporation"
  Device: pci 0x7a50 
  SubVendor: pci 0x17aa "Lenovo"   <---- this 
  SubDevice: pci 0x3846 <----- This

 
I never used the /sys/firmware/acpi/tables/DSDT . So I have added it here. not sure how to use it though.

My alsa-info is here http://alsa-project.org/db/?f=ed0116e9d7235fd5cbece5dccaa589ecad71f534
And my dmesg is https://pastebin.mozilla.org/gjXQOg32

I really admire how much  effort you put into helping this community. 

Thanks again
Comment 81 Cameron Berkenpas 2023-03-15 21:40:45 UTC
Definitely need your alsa-info link.

It's possible this doesn't use Cirrus Logic.

On 3/15/23 2:25 PM, bugzilla-daemon@kernel.org wrote:
> https://bugzilla.kernel.org/show_bug.cgi?id=216194
>
> --- Comment #79 from Carlo Francesco (gentuser@gmail.com) ---
> Created attachment 303959 [details]
>    --> https://bugzilla.kernel.org/attachment.cgi?id=303959&action=edit
> legion pro 7 16IRX8H dsdt FILE
>
Comment 82 Carlo Francesco 2023-03-15 21:45:06 UTC
Created attachment 303960 [details]
alsa info from legion pro 7 16IRX8H
Comment 83 Carlo Francesco 2023-03-15 21:51:37 UTC
Created attachment 303961 [details]
Alsa info without any patch to the kernel

Sorry Cameron, this is the correct alsa-info
Comment 84 Cameron Berkenpas 2023-03-15 21:53:02 UTC
Created attachment 303962 [details]
attachment-14046-0.html

I think this is the relevant section, but I'm also not 100% sure and I'm 
pretty busy so I can't really check too thoroughly. We do see the 
"TIAS2781" show in your alsa-info though (but that's just showing your 
ACPI devices which we already know this is).

So far it's not looking like this laptop has Cirrus Logic AMP chips of 
any kind. From both the DSDT table and your alsa-info.

I strongly suspect there's no support for this hardware generally... 
Googling is turning up nothing.


             Scope (PC00.I2C2)
             {
                 Device (SPKR)
                 {
                     Name (_HID, "TIAS2781")  // _HID: Hardware ID
                     Name (_UID, Zero)  // _UID: Unique ID
                     Method (_SUB, 0, NotSerialized)  // _SUB: Subsystem ID
                     {
                         If ((SPID == Zero))
                         {
                             Return ("17AA3886")
                         }

                         If ((SPID == One))
                         {
                             Return ("17AA3884")
                         }
                     }

                     Method (_CRS, 0, NotSerialized)  // _CRS: Current 
Resource Settings
                     {
                         Name (RBUF, ResourceTemplate ()
                         {
                             I2cSerialBusV2 (0x003F, 
ControllerInitiated, 0x00061A80,
                                 AddressingMode7Bit, "\\_SB.PC00.I2C2",
                                 0x00, ResourceConsumer, , Exclusive,
                                 )
                             I2cSerialBusV2 (0x0038, 
ControllerInitiated, 0x00061A80,
                                 AddressingMode7Bit, "\\_SB.PC00.I2C2",
                                 0x00, ResourceConsumer, , Exclusive,
                                 )
                             I2cSerialBusV2 (0x0040, 
ControllerInitiated, 0x00061A80,
                                 AddressingMode7Bit, "\\_SB.PC00.I2C2",
                                 0x00, ResourceConsumer, , Exclusive,
                                 )
                             GpioIo (Exclusive, PullUp, 0x0000, 0x0000, 
IoRestrictionInputOnly,
                                 "\\_SB.GPI0", 0x00, ResourceConsumer, ,
                                 )
                                 {   // Pin list
                                     0x0000
                                 }
                             GpioInt (Edge, ActiveLow, SharedAndWake, 
PullNone, 0x0000,
                                 "\\_SB.GPI0", 0x00, ResourceConsumer, ,
                                 )
                                 {   // Pin list
                                     0x0000
                                 }
                         })
                         CreateWordField (RBUF, 0x9D, IN1N)
                         CreateWordField (RBUF, 0x7A, SIDN)
                         SIDN = GNUM (0x080A000D)
                         IN1N = GNUM (0x0805000B)
                         Return (RBUF) /* \_SB_.PC00.I2C2.SPKR._CRS.RBUF */
                     }

                     Method (_STA, 0, NotSerialized)  // _STA: Status
                     {
                         If ((MCSK == 0x02))
                         {
                             Return (0x0F)
                         }

                         Return (Zero)
                     }

                     Method (_DIS, 0, NotSerialized)  // _DIS: Disable 
Device
                     {
                     }
                 }

             }


One part stands up to me a bit:

                         If ((SPID == Zero))
                         {
                             Return ("17AA3886")
                         }

                         If ((SPID == One))
                         {
                             Return ("17AA3884")
                         }

17AA3884 matches the subsystem ID in your alsa-info:

Subsystem Id: 0x17aa3884


So probably we're in the right area... There's no 3886 in your 
alsa-info... But might be worth making sure you're selecting the correct 
audio output device?

Maybe "TIA" is the name of the company? I'm not finding anything relevant.

If Linux is important to you, I would take advantage of the 30 day 
return for your money back if all else fails.


Sadly, it looks like I will be very much skipping Lenovo on my next 
laptop (which isn't anytime soon anyway).


On 3/15/23 2:34 PM, bugzilla-daemon@kernel.org wrote:
> https://bugzilla.kernel.org/show_bug.cgi?id=216194
>
> --- Comment #80 from Carlo Francesco (gentuser@gmail.com) ---
> Hello Cameron,
> thanks a lot! What I've tested is actually using your patch and added in
> "patch_realtek.c"  section the
>          +SND_PCI_QUIRK(0x17aa, 0x3846, "Legion 7 Pro 16IRX8H",
> ALC287_FIXUP_CS35L41_I2C_2),
> gathering the PCI address from  hwinfo --sound:
> Model: "Intel Audio device"
>    Vendor: pci 0x8086 "Intel Corporation"
>    Device: pci 0x7a50
>    SubVendor: pci 0x17aa "Lenovo"   <---- this
>    SubDevice: pci 0x3846 <----- This
>
>
> I never used the /sys/firmware/acpi/tables/DSDT . So I have added it here.
> not
> sure how to use it though.
>
> My alsa-info is here
> http://alsa-project.org/db/?f=ed0116e9d7235fd5cbece5dccaa589ecad71f534
> And my dmesg ishttps://pastebin.mozilla.org/gjXQOg32
>
> I really admire how much  effort you put into helping this community.
>
> Thanks again
>
Comment 85 Cameron Berkenpas 2023-03-15 21:56:59 UTC
Seems to be no different.

On 3/15/23 14:51, bugzilla-daemon@kernel.org wrote:
> https://bugzilla.kernel.org/show_bug.cgi?id=216194
>
> --- Comment #83 from Carlo Francesco (gentuser@gmail.com) ---
> Created attachment 303961 [details]
>    --> https://bugzilla.kernel.org/attachment.cgi?id=303961&action=edit
> Alsa info without any patch to the kernel
>
> Sorry Cameron, this is the correct alsa-info
>
Comment 86 Carlo Francesco 2023-03-15 22:06:33 UTC
Indeed, I'm thinking to return the laptop. Totally not worth the high cost.

For the output device I can see I have:
Analog stereo duplex
Analog stereo output
Pro Audio

None of them works (headset are working)
i will google this tia thing
Thx :)
Comment 87 Carlo Francesco 2023-03-15 22:17:44 UTC
from : https://psref.lenovo.com/syspool/Sys/PDF/Legion/Legion_Pro_7_16IRX8H/Legion_Pro_7_16IRX8H_Spec.pdf

The laptop specs, in multimedia section it says:
Multi-Media
Audio Chip
High Definition (HD) Audio, Realtek® ALC3306 codec
Speakers
Stereo speakers (super linear speaker), 2W x2, audio by HARMAN certification, optimized with Nahimic Audio, Smart
Amplifier (AMP)

(identical to  the Legion 7 16IAX7 specs https://psref.lenovo.com/Product/Legion/Legion_7_16IAX7)
Comment 88 Cameron Berkenpas 2023-03-15 22:21:48 UTC
Yeah, but what is "Nahimic"? We don't get specific model numbers, seems 
relatively generic.

If and when you return it, make it extremely clear it's due to lack of 
Linux support of course. :)

If you find a good gaming laptop that works correctly with Linux that 
you're happy with, feel free to email me directly. Eventually I'll be on 
the market for one. :D

On 3/15/23 15:17, bugzilla-daemon@kernel.org wrote:
> https://bugzilla.kernel.org/show_bug.cgi?id=216194
>
> --- Comment #87 from Carlo Francesco (gentuser@gmail.com) ---
> from :
>
> https://psref.lenovo.com/syspool/Sys/PDF/Legion/Legion_Pro_7_16IRX8H/Legion_Pro_7_16IRX8H_Spec.pdf
>
> The laptop specs, in multimedia section it says:
> Multi-Media
> Audio Chip
> High Definition (HD) Audio, Realtek® ALC3306 codec
> Speakers
> Stereo speakers (super linear speaker), 2W x2, audio by HARMAN certification,
> optimized with Nahimic Audio, Smart
> Amplifier (AMP)
>
> (identical to  the Legion 7 16IAX7 specs
> https://psref.lenovo.com/Product/Legion/Legion_7_16IAX7)
>
Comment 89 antidense 2023-03-19 15:10:25 UTC
I wrote this bash script to patch the current kernel with the patch (for archlinux).

This is my first time writing in bash, so hope there's nothing too egregious in it.
Feel free to suggest modifications.

https://github.com/antidense/archlinux-lenovo-legion-sound-patch/blob/main/kernel_compile.sh
Comment 90 Cameron Berkenpas 2023-03-19 15:49:47 UTC
I see one problem. The first line should be:
#!/bin/bash

You have:
!#/bin/bash

On 3/19/23 08:10, bugzilla-daemon@kernel.org wrote:
> https://bugzilla.kernel.org/show_bug.cgi?id=216194
>
> --- Comment #89 from antidense@gmail.com ---
> I wrote this bash script to patch the current kernel with the patch (for
> archlinux).
>
> This is my first time writing in bash, so hope there's nothing too egregious
> in
> it.
> Feel free to suggest modifications.
>
>
> https://github.com/antidense/archlinux-lenovo-legion-sound-patch/blob/main/kernel_compile.sh
>
Comment 91 Carlo Francesco 2023-03-19 17:20:42 UTC
Thanks to all (especially to Cameron)
Apparently my smart amp is not A cirrus logic. Very luckily is a Texas Instrument https://www.ti.com/product/TAS2781

For my TAS2781 smart amp there are even pin schemas on their website and drivers for linux: https://git.ti.com/cgit/tas2781-linux-drivers

Anyone could guide me on how to make the patch for this chip (before I get to destroy my amp and speakers ahah)

My laptop version is Lenovo Legion 16IRX8H
 
Thanks to all!
Comment 92 Cameron Berkenpas 2023-03-19 17:50:57 UTC
Fsck yeah! This is a great find!

You may have saved Lenovo at least one sale... If only the built-in nic 
had 2.5 Gbps like the Gen 7 model, but I never got that setup with my 
Gen 7 anyway (since my 10g switch doesn't support 2.5 Gps, and this is 
apparently the common case).

Anyway, I'm going to dig into this and if I start figuring some stuff 
out, I'll respond to you directly to keep from polluting this bug.

On 3/19/23 10:20, bugzilla-daemon@kernel.org wrote:
> https://bugzilla.kernel.org/show_bug.cgi?id=216194
>
> --- Comment #91 from Carlo Francesco (gentuser@gmail.com) ---
> Thanks to all (especially to Cameron)
> Apparently my smart amp is not A cirrus logic. Very luckily is a Texas
> Instrument https://www.ti.com/product/TAS2781
>
> For my TAS2781 smart amp there are even pin schemas on their website and
> drivers for linux: https://git.ti.com/cgit/tas2781-linux-drivers
>
> Anyone could guide me on how to make the patch for this chip (before I get to
> destroy my amp and speakers ahah)
>
> My laptop version is Lenovo Legion 16IRX8H
>
> Thanks to all!
>
Comment 93 Cameron Berkenpas 2023-03-19 18:13:06 UTC
Carlo,

I jumped for joy a little too soon. These are drivers in progress, and here's the latest version (I think):
https://mailman.alsa-project.org/hyperkitty/list/alsa-devel@alsa-project.org/message/ESCCDHAIMYA5LQ44L64ZC4OVTSBRHLKZ/

The problem is that these are ASoC drivers:
https://www.alsa-project.org/wiki/ASoC

This driver isn't enough to do anything on its own on your laptop I'm afraid.

This was exactly the case the cs35l41 drivers (which includes CSC3551 support). A callback was implemented for systems with cs35l41 smart amps so that they audio output would work.

Fortunately, one of the Cirrus Logic devs ended up purchasing the Lenovo Legion 7 Gen 6 (AMD version) and wanted his audio to work which helped to grease the wheels I think.

I would email the developers and see if they're working on anything or if there are at least plans to implement support.

Hopefully we don't end up with a situation where the smart amps are technically supported, but the BIOS doesn't have enough information for them to work, is the case with the Legion 7 Gen 7.

So definitely be mindful of your 30 day return period.

(In reply to Cameron Berkenpas from comment #92)
> Fsck yeah! This is a great find!
> 
> You may have saved Lenovo at least one sale... If only the built-in nic 
> had 2.5 Gbps like the Gen 7 model, but I never got that setup with my 
> Gen 7 anyway (since my 10g switch doesn't support 2.5 Gps, and this is 
> apparently the common case).
> 
> Anyway, I'm going to dig into this and if I start figuring some stuff 
> out, I'll respond to you directly to keep from polluting this bug.
Comment 94 Cameron Berkenpas 2023-03-20 22:38:23 UTC
Here's a thread where people are expressing their dissatisfaction with Lenovo's support of Linux on their Legion series laptops. Maybe if enough people chime in, they'll take us seriously and we'll get somewhere. I personally don't need/want formalized Linux support... I just want the hardware to work:
https://forums.lenovo.com/t5/Ubuntu/Ubuntu-and-legion-pro-7-16IRX8H-audio-issues/m-p/5210709
Comment 95 Sergey Strigin 2023-03-21 13:55:54 UTC
Thank you all, especially Cameron. His latest patch lenovo-7i-gen7-sound-6.2.0-rc3-0.0.5b-001.patch works just like a charm. But one small note for one who will apply the patch to the latest (currently 6.2.7-arch1) kernel. You need manually copy paste the changes from the patch to the appropriate places of the files modified, cuz with the patch command it places changes in the wrong places.
Comment 96 Mark Pearson 2023-04-12 15:03:53 UTC
Hi,

I've been working with the Legion team on this. I do want to highlight that Linux is not plan-of-record for this platform; but they have been working with the Lenovo Linux team to try and figure this out. This is our busiest time of year with our regular Linux certified platforms so patience and understanding is really appreciated :)

The Legion team just forwarded me the patch that is mentioned above as being required. I take it from the post that this is not all of the story and other pieces are missing? Can someone fill me in with as many details/specifics as possible - I want to make sure my asks of the team are as concise and detailed as possible.

No promises on a solution at this point - but the Legion team are engaged.

Thanks
Mark
Comment 97 Mario Limonciello (AMD) 2023-04-12 15:05:38 UTC
The BIOS needs to include the proper programming for the amplifier for the Linux kernel driver to parse.

The patches that have been developed are workarounds with guessed values.  This isn't generically safe without knowing the proper values to utilize.
Comment 98 Cameron Berkenpas 2023-04-12 16:04:04 UTC
What are needed are the settings in the DSD table in the DSDT snippet shared on this ticket (and in my Lenovo forum) post. As Mario mentioned, the values are guessed. I suspect they're mostly safe values, however, I think they're still not quite right (max volume is lower than it should be). 

So perhaps a few of the guessed values are a bit off and/or some of the values that are optionally needed for the Legion 7i Gen 7i.

I believe these are all the properties that the driver can utilize from the DSDT:
https://github.com/gregkh/linux/blob/v6.2.9/sound/pci/hda/cs35l41_hda.c#L1322-L1366

Probably the Lenovo Smart AMP CSC3551 drivers are hard coding the values somewhere.

You can likely get some a bit of direction/help from Cirrus Logic. I just forwarded you the last email I received from them (you may need to check your spam filter).

Even if support doesnt work out for the Lenovo 7i Gen 7, your help is still greatly appreciated!

(In reply to Mark Pearson from comment #96)
> Hi,
> 
> I've been working with the Legion team on this. I do want to highlight that
> Linux is not plan-of-record for this platform; but they have been working
> with the Lenovo Linux team to try and figure this out. This is our busiest
> time of year with our regular Linux certified platforms so patience and
> understanding is really appreciated :)
> 
> The Legion team just forwarded me the patch that is mentioned above as being
> required. I take it from the post that this is not all of the story and
> other pieces are missing? Can someone fill me in with as many
> details/specifics as possible - I want to make sure my asks of the team are
> as concise and detailed as possible.
> 
> No promises on a solution at this point - but the Legion team are engaged.
> 
> Thanks
> Mark
Comment 99 Blake Lee 2023-04-12 17:32:53 UTC
(In reply to Mario Limonciello (AMD) from comment #97)
> The BIOS needs to include the proper programming for the amplifier for the
> Linux kernel driver to parse.
> 
> The patches that have been developed are workarounds with guessed values. 
> This isn't generically safe without knowing the proper values to utilize.

Additionally to what Cameron said, if you could pass along that the Lenovo Slim series (both Slim 7i Gen 7 and mine, the Slim 7 Gen 7 (AMD) ) have the same issue and likely the same fix with slightly different table entries, that would be great! This issue is across the whole current-gen Legion lineup.
Comment 100 Blake Lee 2023-04-12 17:34:06 UTC
(In reply to Mario Limonciello (AMD) from comment #97)
> The BIOS needs to include the proper programming for the amplifier for the
> Linux kernel driver to parse.
> 
> The patches that have been developed are workarounds with guessed values. 
> This isn't generically safe without knowing the proper values to utilize.

Additionally to what Cameron said, if you could pass along that the Lenovo Slim series (both Slim 7i Gen 7 and mine, the Slim 7 Gen 7 (AMD) ) have the same issue and likely the same fix with slightly different table entries, that would be great! This issue is across the whole current-gen Legion lineup.
Comment 101 Blake Lee 2023-04-13 05:07:43 UTC
(In reply to Mark Pearson from comment #96)
> Hi,
> 
> I've been working with the Legion team on this. I do want to highlight that
> Linux is not plan-of-record for this platform; but they have been working
> with the Lenovo Linux team to try and figure this out. This is our busiest
> time of year with our regular Linux certified platforms so patience and
> understanding is really appreciated :)
> 
> The Legion team just forwarded me the patch that is mentioned above as being
> required. I take it from the post that this is not all of the story and
> other pieces are missing? Can someone fill me in with as many
> details/specifics as possible - I want to make sure my asks of the team are
> as concise and detailed as possible.
> 
> No promises on a solution at this point - but the Legion team are engaged.
> 
> Thanks
> Mark

Additionally to what Cameron said, if you could pass along that the Lenovo Slim series (both Slim 7i Gen 7 and mine, the Slim 7 Gen 7 (AMD) ) have the same issue and likely the same fix with slightly different table entries, that would be great! This issue is across the whole current-gen Legion lineup.
Comment 102 Aedan 2023-04-28 20:32:22 UTC
(In reply to Blake Lee from comment #101)
> (In reply to Mark Pearson from comment #96)
> > Hi,
> > 
> > I've been working with the Legion team on this. I do want to highlight that
> > Linux is not plan-of-record for this platform; but they have been working
> > with the Lenovo Linux team to try and figure this out. This is our busiest
> > time of year with our regular Linux certified platforms so patience and
> > understanding is really appreciated :)
> > 
> > The Legion team just forwarded me the patch that is mentioned above as
> being
> > required. I take it from the post that this is not all of the story and
> > other pieces are missing? Can someone fill me in with as many
> > details/specifics as possible - I want to make sure my asks of the team are
> > as concise and detailed as possible.
> > 
> > No promises on a solution at this point - but the Legion team are engaged.
> > 
> > Thanks
> > Mark
> 
> Additionally to what Cameron said, if you could pass along that the Lenovo
> Slim series (both Slim 7i Gen 7 and mine, the Slim 7 Gen 7 (AMD) ) have the
> same issue and likely the same fix with slightly different table entries,
> that would be great! This issue is across the whole current-gen Legion
> lineup.

Seconding this, I have the Slim 7 Gen 7 AMD (16ARHA7) also and encountering this issue.
Comment 103 shuohuili 2023-05-11 06:36:48 UTC
(In reply to Mark Pearson from comment #96)
> Hi,
> 
> I've been working with the Legion team on this. I do want to highlight that
> Linux is not plan-of-record for this platform; but they have been working
> with the Lenovo Linux team to try and figure this out. This is our busiest
> time of year with our regular Linux certified platforms so patience and
> understanding is really appreciated :)
> 
> The Legion team just forwarded me the patch that is mentioned above as being
> required. I take it from the post that this is not all of the story and
> other pieces are missing? Can someone fill me in with as many
> details/specifics as possible - I want to make sure my asks of the team are
> as concise and detailed as possible.
> 
> No promises on a solution at this point - but the Legion team are engaged.
> 
> Thanks
> Mark

Hi, I have a thinkbook 16p gen4 with the same ACL3306 and AMP (it's basically a re-skin of Legion slim 16). I wonder if Lenovo also has plan to provide BIOS support for this laptop model?
Comment 104 Vincent S. 2023-05-13 03:10:59 UTC
I recently purchased the lenovo legion 7i 16IAX7. I was happy to see linux almost work near entirely perfect on it - except for the speakers. 

I see there has been a kernel patch made by the amazing people here but I want to inquire before I try it how risky of an endeavor it is? I've read through the entire thread and it seems like some people have used it with this model ofaltop for almost a year now? How worried should I be about the prospect of it damaging my speakers. 

Second, what is the newest kernel version that the patch supports? 

I appreciate the time and help of everyone here.
Comment 105 Cameron Berkenpas 2023-05-13 16:04:58 UTC
(In reply to Vincent S. from comment #104)
> I recently purchased the lenovo legion 7i 16IAX7. I was happy to see linux
> almost work near entirely perfect on it - except for the speakers. 
> 
> I see there has been a kernel patch made by the amazing people here but I
> want to inquire before I try it how risky of an endeavor it is? I've read
> through the entire thread and it seems like some people have used it with
> this model ofaltop for almost a year now? How worried should I be about the
> prospect of it damaging my speakers. 
> 
> Second, what is the newest kernel version that the patch supports? 
> 
> I appreciate the time and help of everyone here.

I'm currently using it with kernel 6.3.2. As there hasn't been any problems with this patch and the 16IAX7 since I started using it back around August or September... I think the patch is fairly safe at this point. But it's still use-at-your-own risk of course.
Comment 106 shuohuili 2023-05-20 15:01:34 UTC
(In reply to Cameron Berkenpas from comment #105)
> (In reply to Vincent S. from comment #104)
> > I recently purchased the lenovo legion 7i 16IAX7. I was happy to see linux
> > almost work near entirely perfect on it - except for the speakers. 
> > 
> > I see there has been a kernel patch made by the amazing people here but I
> > want to inquire before I try it how risky of an endeavor it is? I've read
> > through the entire thread and it seems like some people have used it with
> > this model ofaltop for almost a year now? How worried should I be about the
> > prospect of it damaging my speakers. 
> > 
> > Second, what is the newest kernel version that the patch supports? 
> > 
> > I appreciate the time and help of everyone here.
> 
> I'm currently using it with kernel 6.3.2. As there hasn't been any problems
> with this patch and the 16IAX7 since I started using it back around August
> or September... I think the patch is fairly safe at this point. But it's
> still use-at-your-own risk of course.

Hi, big thanks for your efforts! Lenovo really owes you a big one. I can confirm the patch also works on ThinkBook 16p gen4 IRH. The kernel version is 6.3.2. No amp short error in dmesg. I only added this line to your patch of sound/pci/hda/patch_realtek.c: "SND_PCI_QUIRK(0x17aa, 0x38ab, "Lenovo ThinkBook 16p Gen4 IRH", ALC287_FIXUP_CS35L41_I2C_2)"
Comment 107 Cameron Berkenpas 2023-05-20 16:13:47 UTC
Great to hear! Just keep an ear out for issues with your sound possibly 
developing over time.

Seeing as people with different models who have had success with this 
patch haven't reported issues... I wonder if maybe these are just really 
conservative settings? Under Linux, my sound tends to be more quiet than 
I'd like it to be, but not bad by any means, and certainly much better 
than no sound.

On 5/20/23 08:01, bugzilla-daemon@kernel.org wrote:
> https://bugzilla.kernel.org/show_bug.cgi?id=216194
>
> --- Comment #106 from shuohuili (li012589li@outlook.com) ---
> (In reply to Cameron Berkenpas from comment #105)
>> (In reply to Vincent S. from comment #104)
>>> I recently purchased the lenovo legion 7i 16IAX7. I was happy to see linux
>>> almost work near entirely perfect on it - except for the speakers.
>>>
>>> I see there has been a kernel patch made by the amazing people here but I
>>> want to inquire before I try it how risky of an endeavor it is? I've read
>>> through the entire thread and it seems like some people have used it with
>>> this model ofaltop for almost a year now? How worried should I be about the
>>> prospect of it damaging my speakers.
>>>
>>> Second, what is the newest kernel version that the patch supports?
>>>
>>> I appreciate the time and help of everyone here.
>> I'm currently using it with kernel 6.3.2. As there hasn't been any problems
>> with this patch and the 16IAX7 since I started using it back around August
>> or September... I think the patch is fairly safe at this point. But it's
>> still use-at-your-own risk of course.
> Hi, big thanks for your efforts! Lenovo really owes you a big one. I can
> confirm the patch also works on ThinkBook 16p gen4 IRH. The kernel version is
> 6.3.2. No amp short error in dmesg. I only added this line to your patch of
> sound/pci/hda/patch_realtek.c: "SND_PCI_QUIRK(0x17aa, 0x38ab, "Lenovo
> ThinkBook
> 16p Gen4 IRH", ALC287_FIXUP_CS35L41_I2C_2)"
>
Comment 108 Huayu Zhang 2023-05-26 05:28:28 UTC
Thanks for all you guys!

I can confirm the sound could output at a acceptable level now at `Lenovo ThinkBook 16p Gen4 IRH` which is same as shuohuili.

Behavior change:
1. after install package named `sof-firmware` in Archlinux, the internal speaker can output sound on up facing speakers (but sound level is very low), but the down facing ones not work. (headphone jack and bluetooth works)

2. after applying the modified patch into kernel v6.3.4, the down facing speaker can output at a right level. (When I tried to adjust volume in Gnome settings, the low and middle volume seems `activate` down facing speakers and high volume `activate ` up facing speakers) (this means the sound level is not adjustable for now, but very funny though, ^_^)


Info:
1. Distro: Archlinux
2. Kernel version: 6.3.4
3. different from the path: (the second parameter has slight different from shuohuili's, this should pick up from alsa-info for specific machine even they may have same devive name, I guess)
    sound/pci/hda/patch_realtek.c: "SND_PCI_QUIRK(0x17aa, 0x38a9, "Lenovo ThinkBook 16p Gen4 IRH", ALC287_FIXUP_CS35L41_I2C_2)"

And hope this could be officially fixed up by Cirrus and Lenovo soon <https://lore.kernel.org/lkml/b4c202b2-ab29-e2aa-b141-0c967b2c1645@opensource.cirrus.com/>

Thanks again for all you guys!!! You are amazing!!!
Comment 109 Jacopo G. Chen 2023-05-26 10:04:06 UTC
Created attachment 304326 [details]
Volume comparison: patched linux/win11

Hi everyone, it occurred to me that since my Legion 7 16IAX7 also has Windows 11 in dual boot, I could test the speaker volume on both systems. This could help with calibration. I played a frequency sweep video on Youtube at 100% volume and used a spectrogram app on my phone, keeping it in the exact same position very close to the speakers.

I superimposed the two screenshots (attached), where red = Linux, green = Windows. The line records the max intensity ever reached at that frequency. Frequencies below 100 HZ should be disregarded as the video wasn't very loud there and it picked up some ambient noise.

I'm running Arch Linux with 6.3.2 patched kernel.
Comment 110 Thomas Gfeller 2023-06-28 07:02:00 UTC
(In reply to shuohuili from comment #106)
> (In reply to Cameron Berkenpas from comment #105)
> > (In reply to Vincent S. from comment #104)
> > > I recently purchased the lenovo legion 7i 16IAX7. I was happy to see
> linux
> > > almost work near entirely perfect on it - except for the speakers. 
> > > 
> > > I see there has been a kernel patch made by the amazing people here but I
> > > want to inquire before I try it how risky of an endeavor it is? I've read
> > > through the entire thread and it seems like some people have used it with
> > > this model ofaltop for almost a year now? How worried should I be about
> the
> > > prospect of it damaging my speakers. 
> > > 
> > > Second, what is the newest kernel version that the patch supports? 
> > > 
> > > I appreciate the time and help of everyone here.
> > 
> > I'm currently using it with kernel 6.3.2. As there hasn't been any problems
> > with this patch and the 16IAX7 since I started using it back around August
> > or September... I think the patch is fairly safe at this point. But it's
> > still use-at-your-own risk of course.
> 
> Hi, big thanks for your efforts! Lenovo really owes you a big one. I can
> confirm the patch also works on ThinkBook 16p gen4 IRH. The kernel version
> is 6.3.2. No amp short error in dmesg. I only added this line to your patch
> of sound/pci/hda/patch_realtek.c: "SND_PCI_QUIRK(0x17aa, 0x38ab, "Lenovo
> ThinkBook 16p Gen4 IRH", ALC287_FIXUP_CS35L41_I2C_2)"

Wow this thread looks truly interesting to me:

I have the same issue: My smart amps are not working on a Lenovo Yoga Pro 9 14IRP8. I posted available diagnostics data here: https://bugzilla.kernel.org/show_bug.cgi?id=217449

Can someone guide me on how I could try to fix my speakers? I'm fine patching and building kernels but the learning curve for these fixes is quite steep for me. Any help is highly appreciated.
Comment 111 Carlo Francesco 2023-06-28 07:37:19 UTC
(In reply to Thomas Gfeller from comment #110)
> (In reply to shuohuili from comment #106)
> > (In reply to Cameron Berkenpas from comment #105)
> > > (In reply to Vincent S. from comment #104)
> > > > I recently purchased the lenovo legion 7i 16IAX7. I was happy to see
> > linux
> > > > almost work near entirely perfect on it - except for the speakers. 
> > > > 
> > > > I see there has been a kernel patch made by the amazing people here but
> I
> > > > want to inquire before I try it how risky of an endeavor it is? I've
> read
> > > > through the entire thread and it seems like some people have used it
> with
> > > > this model ofaltop for almost a year now? How worried should I be about
> > the
> > > > prospect of it damaging my speakers. 
> > > > 
> > > > Second, what is the newest kernel version that the patch supports? 
> > > > 
> > > > I appreciate the time and help of everyone here.
> > > 
> > > I'm currently using it with kernel 6.3.2. As there hasn't been any
> problems
> > > with this patch and the 16IAX7 since I started using it back around
> August
> > > or September... I think the patch is fairly safe at this point. But it's
> > > still use-at-your-own risk of course.
> > 
> > Hi, big thanks for your efforts! Lenovo really owes you a big one. I can
> > confirm the patch also works on ThinkBook 16p gen4 IRH. The kernel version
> > is 6.3.2. No amp short error in dmesg. I only added this line to your patch
> > of sound/pci/hda/patch_realtek.c: "SND_PCI_QUIRK(0x17aa, 0x38ab, "Lenovo
> > ThinkBook 16p Gen4 IRH", ALC287_FIXUP_CS35L41_I2C_2)"
> 
> Wow this thread looks truly interesting to me:
> 
> I have the same issue: My smart amps are not working on a Lenovo Yoga Pro 9
> 14IRP8. I posted available diagnostics data here:
> https://bugzilla.kernel.org/show_bug.cgi?id=217449
> 
> Can someone guide me on how I could try to fix my speakers? I'm fine
> patching and building kernels but the learning curve for these fixes is
> quite steep for me. Any help is highly appreciated.

Hello Thomas,
I replied to you in the other thread as well.
I had a look at your alsa file and it seems you have a Texas Instrument smart amp. 
Here https://forums.lenovo.com/t5/Ubuntu/Ubuntu-and-legion-pro-7-16IRX8H-audio-issues/m-p/5210709?page=7#6004369 you can find the solution for this specific amplifier. 
You can download the driver source https://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-files/6/2500.current.7z and the patched firmware, https://forums.lenovo.com/download/cHTBiFZo-k4 ( do not use the one included in the driver zip), then:
1. cp -RT [source_of_downloaded_driver]/     [linux_source_tree]/
2. extract the old .config, make menuconfig, select as module TAS2781 
3. install the kernel and modules, make initramfs, and config boot loader to load the new kernel
4. copy the firmware  to /lib/firmware/
5. reboot into the new kernel, then you should have sound from the bass speakers

Let me know the outcome. Thanks and good luck!
Comment 112 Thomas Gfeller 2023-06-28 11:23:42 UTC
(In reply to Carlo Francesco from comment #111)
> 
> Hello Thomas,
> I replied to you in the other thread as well.
> I had a look at your alsa file and it seems you have a Texas Instrument
> smart amp. 
> Here
> https://forums.lenovo.com/t5/Ubuntu/Ubuntu-and-legion-pro-7-16IRX8H-audio-
> issues/m-p/5210709?page=7#6004369 you can find the solution for this
> specific amplifier. 
> You can download the driver source
> https://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-
> files/6/2500.current.7z and the patched firmware,
> https://forums.lenovo.com/download/cHTBiFZo-k4 ( do not use the one included
> in the driver zip), then:
> 1. cp -RT [source_of_downloaded_driver]/     [linux_source_tree]/
> 2. extract the old .config, make menuconfig, select as module TAS2781 
> 3. install the kernel and modules, make initramfs, and config boot loader to
> load the new kernel
> 4. copy the firmware  to /lib/firmware/
> 5. reboot into the new kernel, then you should have sound from the bass
> speakers
> 
> Let me know the outcome. Thanks and good luck!

Hi. I tried this; for you to check if I made any mistakes:

1. I cloned the kernel sources and checked out tag v6.4-rc5
2. I copied the source of the drivers to the kernel source tree.
3. I executed "cp /boot/config-`uname -r`* .config".
4, I executed "make olddefconfig"
4. I executed "make menuconfig" and selected "M" for "Symbol: SND_HDA_SCODEC_TAS2781_I2C [=m]" and "Symbol: SND_SOC_TAS2781 [=m]".
5. I copied over the firmware files to /lib/firmware.
6. I built and installed both the modules and the kernel and rebooted.

Status of the system now:

$ uname -r
6.4.0-rc5-dirty <- the kernel I just built.

$ find /lib/modules/6.4.0-rc5-dirty/ -name *tas*
...
/lib/modules/6.4.0-rc5-dirty/kernel/sound/pci/hda/snd-hda-scodec-tas2781-i2c.ko
...
/lib/modules/6.4.0-rc5-dirty/kernel/sound/soc/codecs/snd-soc-tas2562.ko
/lib/modules/6.4.0-rc5-dirty/kernel/sound/soc/codecs/snd-soc-tas2764.ko
/lib/modules/6.4.0-rc5-dirty/kernel/sound/soc/codecs/snd-soc-tas2780.ko
/lib/modules/6.4.0-rc5-dirty/kernel/sound/soc/codecs/snd-soc-tas2781-comlib.ko
/lib/modules/6.4.0-rc5-dirty/kernel/sound/soc/codecs/snd-soc-tas2781-fmwlib.ko
/lib/modules/6.4.0-rc5-dirty/kernel/sound/soc/codecs/snd-soc-tas2781.ko
/lib/modules/6.4.0-rc5-dirty/kernel/sound/soc/codecs/snd-soc-tas5805m.ko
/lib/modules/6.4.0-rc5-dirty/kernel/sound/soc/codecs/snd-soc-tas6424.ko
/lib/modules/6.4.0-rc5-dirty/kernel/sound/soc/codecs/snd-soc-tas2770.ko

$ lsmod | grep tas2781
snd_hda_scodec_tas2781_i2c    32768  0
snd_soc_tas2781_fmwlib    53248  1 snd_hda_scodec_tas2781_i2c
snd_soc_tas2781_comlib    20480  2 snd_soc_tas2781_fmwlib,snd_hda_scodec_tas2781_i2c
crc8                   12288  2 snd_soc_tas2781_fmwlib,snd_soc_tas2781_comlib
snd_soc_core          438272  9 soundwire_intel,snd_sof,snd_sof_intel_hda_common,snd_soc_hdac_hdmi,snd_soc_hdac_hda,snd_sof_probes,snd_soc_dmic,snd_soc_skl_hda_dsp,snd_hda_scodec_tas2781_i2c
snd                   143360  45 snd_ctl_led,snd_hda_codec_generic,snd_seq,snd_seq_device,snd_hda_codec_hdmi,snd_hwdep,snd_hda_intel,snd_usb_audio,snd_usbmidi_lib,snd_hda_codec,snd_hda_codec_realtek,snd_sof,snd_timer,snd_soc_hdac_hdmi,snd_compress,snd_soc_core,snd_pcm,snd_hda_scodec_tas2781_i2c,snd_rawmidi

$ ls -l /lib/firmware/TAS*
-rw-r--r--. 1 root root 64504 Jun 28 13:03 /lib/firmware/TAS2XXX387D.bin
-rw-r--r--. 1 root root 64732 Jun 28 13:03 /lib/firmware/TAS2XXX387E.bin
-rw-r--r--. 1 root root 36628 Jun 28 13:03 /lib/firmware/TAS2XXX3881.bin
-rw-r--r--. 1 root root 36628 Jun 28 13:03 /lib/firmware/TAS2XXX3884.bin
-rw-r--r--. 1 root root 36628 Jun 28 13:03 /lib/firmware/TAS2XXX3886.bin
-rw-r--r--. 1 root root 36628 Jun 28 13:03 /lib/firmware/TAS2XXX38A7.bin
-rw-r--r--. 1 root root 36628 Jun 28 13:03 /lib/firmware/TAS2XXX38A8.bin
-rw-r--r--. 1 root root 36628 Jun 28 13:03 /lib/firmware/TAS2XXX38B8.bin
-rw-r--r--. 1 root root 36628 Jun 28 13:03 /lib/firmware/TAS2XXX38B9.bin
-rw-r--r--. 1 root root 64732 Jun 28 13:03 /lib/firmware/TAS2XXX38BA.bin
-rw-r--r--. 1 root root 64504 Jun 28 13:03 /lib/firmware/TAS2XXX38BB.bin
-rw-r--r--. 1 root root 36248 Jun 28 13:03 /lib/firmware/TAS2XXX38BE.bin
-rw-r--r--. 1 root root 36248 Jun 28 13:03 /lib/firmware/TAS2XXX38BF.bin
-rw-r--r--. 1 root root 36628 Jun 28 13:03 /lib/firmware/TAS2XXX38C3.bin
-rw-r--r--. 1 root root 36628 Jun 28 13:03 /lib/firmware/TAS2XXX38CB.bin
-rw-r--r--. 1 root root 36628 Jun 28 13:03 /lib/firmware/TAS2XXX38CD.bin

Unfortunately the bass speakers are still not working. Did I miss something?
Comment 113 Carlo Francesco 2023-06-28 11:31:51 UTC
Could you please attach the output of these three commands as well:

# cd /sys/bus/i2c/devices; ls -al 

# amixer -c 0 contents 
# amixer -c 1 contents
Comment 114 Carlo Francesco 2023-06-28 11:33:18 UTC
and dmesg ¦ grep  tas2781
Comment 115 Thomas Gfeller 2023-06-28 11:55:07 UTC
Created attachment 304495 [details]
Debug outputs of 14IRP8

(In reply to Carlo Francesco from comment #113)
> Could you please attach the output of these three commands as well:
> 
> # cd /sys/bus/i2c/devices; ls -al 
> 
> # amixer -c 0 contents 
> # amixer -c 1 contents

To keep the thread here readable I attached the outputs to this file: debug-outputs-14IRP8.log.

Note that dmesg does not contain "tas2781" in my case. I'm using Fedora 38. Maybe I have to increase the verbosity of the logging?
Comment 116 Carlo Francesco 2023-06-28 13:14:29 UTC
I guess there is a problem in the quirk
your PCI is clearly stated to be included in the Realtek patch.

your audio Subsystem Id: 0x17aa38bf
The Realtek patch includes it with this line: SND_PCI_QUIRK(0x17aa, 0x38bf, "Yoga S980-14.5 proX LX Dual", ALC287_FIXUP_TAS2781_I2C)

Furthermore the I2C points correctly to the pci device:
 i2c-TIAS2781:00 -> ../../../devices/pci0000:00/0000:00:10.0/i2c_designware.0/i2c-0/i2c-TIAS2781:00

I'm not sure why the TAS firmware isn't loaded at the startup.
Anyway, I have just realised that you have 4 audio cards,
snd_usb_audio (card 0)
snd_hda_intel (card 1)
snd_usb_audio (card 2)
snd_soc_skl_hda_dsp (card 3)

can you please add the outputs of: 
> # amixer -c 2 contents 
> # amixer -c 3 contents
> lspci -knn | grep -i -A3 audio
> sudo dmesg  | grep 'hda\|snd\|firmware\|audio'
> pacmd list-sinks

the snd_soc_skl_hda_dsp soundcard actually makes me think.

Since multiple drivers can register the same PCI ID, the snd-intel-dspcfg module exposes an API used by all drivers, and the user can override default choices by setting the dsp_driver parameter. For example:

options snd-intel-dspcfg dsp_driver=1

will allow for the HDaudio legacy driver to be used. This will typically work for speakers and headphones/headsets, but will not allow DMIC capture.

In case, can you try adding this option on fedora's module autoload with something similar to:
sudo tee /etc/modprobe.d/snd-soc-skl-fix.conf <<<'options snd-intel-dspcfg dsp_driver=1'

If it fails, just remove it:
sudo rm /etc/modprobe.d/snd-soc-skl-fix.conf

finger crossed!
Comment 117 Thomas Gfeller 2023-06-28 14:25:55 UTC
Created attachment 304499 [details]
Debug outputs of 14IRP8 Part 2

Alright.

Yeah, I have multiple soundcards connected (due to a headset. NVIDIA graphics card and docking station). I figured out (via alsamixer) that soundcard 1 is sof-hda-dsp. Check the attached file for the output of 'amixer -c 1 contents'.

Also, the other commands were piped to the attached file. I don't know what I missed last time but tas2781 is present in dmesg now.

I tried sudo tee /etc/modprobe.d/snd-soc-skl-fix.conf <<<'options snd-intel-dspcfg dsp_driver=1' even with including 'options snd_hda_intel model=alc287-yoga9-bass-spk-pin'. Both options did not make the subwoofers working. But the soundcards were named differently and the mic was not detected any longer.

Just to clarify: I appreciate this help very much :-).
Comment 118 Carlo Francesco 2023-06-28 14:53:38 UTC
(In reply to Thomas Gfeller from comment #117)
> Created attachment 304499 [details]
> Debug outputs of 14IRP8 Part 2
> 
> Alright.
> 
> Yeah, I have multiple soundcards connected (due to a headset. NVIDIA
> graphics card and docking station). I figured out (via alsamixer) that
> soundcard 1 is sof-hda-dsp. Check the attached file for the output of
> 'amixer -c 1 contents'.
> 
> Also, the other commands were piped to the attached file. I don't know what
> I missed last time but tas2781 is present in dmesg now.
> 
> I tried sudo tee /etc/modprobe.d/snd-soc-skl-fix.conf <<<'options
> snd-intel-dspcfg dsp_driver=1' even with including 'options snd_hda_intel
> model=alc287-yoga9-bass-spk-pin'. Both options did not make the subwoofers
> working. But the soundcards were named differently and the mic was not
> detected any longer.
> 
> Just to clarify: I appreciate this help very much :-).

Ok then "options snd-intel-dspcfg dsp_driver=1" did something. At least the correct snd-hda intel driver is loaded. 
Please keep that options enabled and remove the "options snd_hda_intel model=alc287-yoga9-bass-spk-pin"
It won't work for you , because it will quirk 
SND_PCI_QUIRK(0x17aa, 0x3869, "Lenovo Yoga7 14IAL7", ALC287_FIXUP_YOGA9_14IAP7_BASS_SPK_PIN),
SND_PCI_QUIRK(0x17aa, 0x3801, "Lenovo Yoga9 14IAP7", ALC287_FIXUP_YOGA9_14IAP7_BASS_SPK_PIN),
which aren't your Subsystem Id: 0x17aa38bf

what stands out to me is :
[ 2685.600191] tas2781-hda i2c-TIAS2781:00: tasdevice_prmg_load: Firmware is NULL
[ 2685.600196] tas2781-hda i2c-TIAS2781:00: conf_no should be not more than 0
[ 2901.366625] tas2781-hda i2c-TIAS2781:00: tasdevice_prmg_load: Firmware is NULL


From a quick search it seems that additional firmwares should be compressed with xz in Fedora. So try to go the firmware lib you downloaded and extracted. and run those commands:

xz *.fw
sudo cp *.xz /usr/lib/firmware
sudo restorecon -R /usr/lib/firmware

Let me know!
Comment 119 Carlo Francesco 2023-06-28 15:00:58 UTC
sorry the firmware are .bin files not .fw Maybe it's just a matter of copying those bin in  /usr/lib/firmware instead of /lib/firmware?
maybe it's worth rebuilding the initram after?
Comment 120 Thomas Gfeller 2023-06-28 15:36:33 UTC
ok, I tried to put the files in this directory: Both as xz and as bin files:

$ ls -l /usr/lib/firmware/TAS* && ls -l /usr/lib/firmware/TIA*
-rw-r--r--. 1 root root 64504 Jun 28 17:16 /usr/lib/firmware/TAS2XXX387D.bin
-rw-r--r--. 1 root root  4476 Jun 28 17:11 /usr/lib/firmware/TAS2XXX387D.bin.xz
-rw-r--r--. 1 root root 64732 Jun 28 17:16 /usr/lib/firmware/TAS2XXX387E.bin
-rw-r--r--. 1 root root  4764 Jun 28 17:11 /usr/lib/firmware/TAS2XXX387E.bin.xz
-rw-r--r--. 1 root root 36628 Jun 28 17:16 /usr/lib/firmware/TAS2XXX3881.bin
-rw-r--r--. 1 root root  4356 Jun 28 17:11 /usr/lib/firmware/TAS2XXX3881.bin.xz
-rw-r--r--. 1 root root 36628 Jun 28 17:16 /usr/lib/firmware/TAS2XXX3884.bin
-rw-r--r--. 1 root root  4508 Jun 28 17:11 /usr/lib/firmware/TAS2XXX3884.bin.xz
-rw-r--r--. 1 root root 36628 Jun 28 17:16 /usr/lib/firmware/TAS2XXX3886.bin
-rw-r--r--. 1 root root  4508 Jun 28 17:11 /usr/lib/firmware/TAS2XXX3886.bin.xz
-rw-r--r--. 1 root root 36628 Jun 28 17:16 /usr/lib/firmware/TAS2XXX38A7.bin
-rw-r--r--. 1 root root  4500 Jun 28 17:11 /usr/lib/firmware/TAS2XXX38A7.bin.xz
-rw-r--r--. 1 root root 36628 Jun 28 17:16 /usr/lib/firmware/TAS2XXX38A8.bin
-rw-r--r--. 1 root root  4516 Jun 28 17:11 /usr/lib/firmware/TAS2XXX38A8.bin.xz
-rw-r--r--. 1 root root 36628 Jun 28 17:16 /usr/lib/firmware/TAS2XXX38B8.bin
-rw-r--r--. 1 root root  4284 Jun 28 17:11 /usr/lib/firmware/TAS2XXX38B8.bin.xz
-rw-r--r--. 1 root root 36628 Jun 28 17:16 /usr/lib/firmware/TAS2XXX38B9.bin
-rw-r--r--. 1 root root  4292 Jun 28 17:11 /usr/lib/firmware/TAS2XXX38B9.bin.xz
-rw-r--r--. 1 root root 64732 Jun 28 17:16 /usr/lib/firmware/TAS2XXX38BA.bin
-rw-r--r--. 1 root root  4712 Jun 28 17:11 /usr/lib/firmware/TAS2XXX38BA.bin.xz
-rw-r--r--. 1 root root 64504 Jun 28 17:16 /usr/lib/firmware/TAS2XXX38BB.bin
-rw-r--r--. 1 root root  4660 Jun 28 17:11 /usr/lib/firmware/TAS2XXX38BB.bin.xz
-rw-r--r--. 1 root root 36248 Jun 28 17:16 /usr/lib/firmware/TAS2XXX38BE.bin
-rw-r--r--. 1 root root  4216 Jun 28 17:11 /usr/lib/firmware/TAS2XXX38BE.bin.xz
-rw-r--r--. 1 root root 36248 Jun 28 17:16 /usr/lib/firmware/TAS2XXX38BF.bin
-rw-r--r--. 1 root root  4200 Jun 28 17:11 /usr/lib/firmware/TAS2XXX38BF.bin.xz
-rw-r--r--. 1 root root 36628 Jun 28 17:16 /usr/lib/firmware/TAS2XXX38C3.bin
-rw-r--r--. 1 root root  4512 Jun 28 17:11 /usr/lib/firmware/TAS2XXX38C3.bin.xz
-rw-r--r--. 1 root root 36628 Jun 28 17:16 /usr/lib/firmware/TAS2XXX38CB.bin
-rw-r--r--. 1 root root  4508 Jun 28 17:11 /usr/lib/firmware/TAS2XXX38CB.bin.xz
-rw-r--r--. 1 root root 36628 Jun 28 17:16 /usr/lib/firmware/TAS2XXX38CD.bin
-rw-r--r--. 1 root root  4508 Jun 28 17:11 /usr/lib/firmware/TAS2XXX38CD.bin.xz
-rw-r--r--. 1 root root  1220 Jun 28 17:16 /usr/lib/firmware/TIAS2781RCA2.bin
-rw-r--r--. 1 root root   316 Jun 28 17:11 /usr/lib/firmware/TIAS2781RCA2.bin.xz
-rw-r--r--. 1 root root 31925 Jun 28 17:16 /usr/lib/firmware/TIAS2781RCA2.json
-rw-r--r--. 1 root root  1324 Jun 28 17:16 /usr/lib/firmware/TIAS2781RCA4.bin
-rw-r--r--. 1 root root   288 Jun 28 17:11 /usr/lib/firmware/TIAS2781RCA4.bin.xz
-rw-r--r--. 1 root root 46158 Jun 28 17:16 /usr/lib/firmware/TIAS2781RCA4.json

I also removed 'options snd_hda_intel model=alc287-yoga9-bass-spk-pin'

I also rebuilt the initframfs.

Unfortunately no lock. What's very strange: I don't have any dmesg entries for tas2781 any longer. Despite booting the same kernel with the same settings. I also didn't manage to reproduce the dmesg entries again.

But the modules are loaded:

$ lsmod | grep tas
snd_hda_scodec_tas2781_i2c    32768  0
snd_soc_tas2781_fmwlib    53248  1 snd_hda_scodec_tas2781_i2c
snd_soc_tas2781_comlib    20480  2 snd_soc_tas2781_fmwlib,snd_hda_scodec_tas2781_i2c
crc8                   12288  2 snd_soc_tas2781_fmwlib,snd_soc_tas2781_comlib
snd_soc_core          438272  5 soundwire_intel,snd_sof,snd_sof_intel_hda_common,snd_soc_hdac_hda,snd_hda_scodec_tas2781_i2c
snd                   143360  38 snd_ctl_led,snd_hda_codec_generic,snd_seq,snd_seq_device,snd_hda_codec_hdmi,snd_hwdep,snd_hda_intel,snd_usb_audio,snd_usbmidi_lib,snd_hda_codec,snd_hda_codec_realtek,snd_sof,snd_timer,snd_compress,snd_soc_core,snd_pcm,snd_hda_scodec_tas2781_i2c,snd_rawmidi

How shall I proceed?
Comment 121 Carlo Francesco 2023-06-28 16:08:06 UTC
Ok maybe it's woth adding options snd_hda_intel model=alc287-yoga9-bass-spk-pin, maybe it forces the driver to be laoded. I'm not sure :P
Comment 122 Thomas Gfeller 2023-06-28 18:54:16 UTC
No matter what I did, I didn't manage to get the dmesg output for tas2781 any more. I was not able to reproduce this.

I have a few further insights however:

When setting 'options snd-intel-dspcfg dsp_driver=1', I have three options to choose from in the audio settings:

- Analog Surround 2.1
- Analog Surround 4.0
- Analog Stereo Output

Setting 'options snd_hda_intel model=alc287-yoga9-bass-spk-pin' leads to a slightly different behaviour in front / rear speakers. Though none of these work. I think the amp is still not activated.

The modules are properly available and loaded:
$ lsmod | grep tas
snd_hda_scodec_tas2781_i2c    32768  0
snd_soc_tas2781_fmwlib    53248  1 snd_hda_scodec_tas2781_i2c
snd_soc_tas2781_comlib    20480  2 snd_soc_tas2781_fmwlib,snd_hda_scodec_tas2781_i2c
crc8                   12288  2 snd_soc_tas2781_fmwlib,snd_soc_tas2781_comlib
snd_soc_core          438272  5 soundwire_intel,snd_sof,snd_sof_intel_hda_common,snd_soc_hdac_hda,snd_hda_scodec_tas2781_i2c
snd                   143360  36 snd_hda_codec_generic,snd_seq,snd_seq_device,snd_hda_codec_hdmi,snd_hwdep,snd_hda_intel,snd_usb_audio,snd_usbmidi_lib,snd_hda_codec,snd_hda_codec_realtek,snd_sof,snd_timer,snd_compress,snd_soc_core,snd_pcm,snd_hda_scodec_tas2781_i2c,snd_rawmidi

The firmware files are xz-compressed and available in /lib/firmware (which is linked with /usr/lib/firmware/):
$ ls -l /lib/firmware/TAS* && ls -l /lib/firmware/TIA*
-rw-r--r--. 1 root root 4476 Jun 28 20:16 /lib/firmware/TAS2XXX387D.bin.xz
-rw-r--r--. 1 root root 4764 Jun 28 20:16 /lib/firmware/TAS2XXX387E.bin.xz
-rw-r--r--. 1 root root 4356 Jun 28 20:16 /lib/firmware/TAS2XXX3881.bin.xz
-rw-r--r--. 1 root root 4508 Jun 28 20:16 /lib/firmware/TAS2XXX3884.bin.xz
-rw-r--r--. 1 root root 4508 Jun 28 20:16 /lib/firmware/TAS2XXX3886.bin.xz
-rw-r--r--. 1 root root 4500 Jun 28 20:16 /lib/firmware/TAS2XXX38A7.bin.xz
-rw-r--r--. 1 root root 4516 Jun 28 20:16 /lib/firmware/TAS2XXX38A8.bin.xz
-rw-r--r--. 1 root root 4284 Jun 28 20:16 /lib/firmware/TAS2XXX38B8.bin.xz
-rw-r--r--. 1 root root 4292 Jun 28 20:16 /lib/firmware/TAS2XXX38B9.bin.xz
-rw-r--r--. 1 root root 4712 Jun 28 20:16 /lib/firmware/TAS2XXX38BA.bin.xz
-rw-r--r--. 1 root root 4660 Jun 28 20:16 /lib/firmware/TAS2XXX38BB.bin.xz
-rw-r--r--. 1 root root 4216 Jun 28 20:16 /lib/firmware/TAS2XXX38BE.bin.xz
-rw-r--r--. 1 root root 4200 Jun 28 20:16 /lib/firmware/TAS2XXX38BF.bin.xz
-rw-r--r--. 1 root root 4512 Jun 28 20:16 /lib/firmware/TAS2XXX38C3.bin.xz
-rw-r--r--. 1 root root 4508 Jun 28 20:16 /lib/firmware/TAS2XXX38CB.bin.xz
-rw-r--r--. 1 root root 4508 Jun 28 20:16 /lib/firmware/TAS2XXX38CD.bin.xz
-rw-r--r--. 1 root root  316 Jun 28 20:16 /lib/firmware/TIAS2781RCA2.bin.xz
-rw-r--r--. 1 root root 1412 Jun 28 20:16 /lib/firmware/TIAS2781RCA2.json.xz
-rw-r--r--. 1 root root  288 Jun 28 20:16 /lib/firmware/TIAS2781RCA4.bin.xz
-rw-r--r--. 1 root root 1496 Jun 28 20:16 /lib/firmware/TIAS2781RCA4.json.xz

Do you have any suggestions on how to proceed from here?
Comment 123 Cameron Berkenpas 2023-06-28 19:28:23 UTC
We don't even know if you have the tas hardware. Can you at least provide a link to your alsa-info? Most of Lenovo's laptop models use Cirrus Logic.

(In reply to Thomas Gfeller from comment #122)
> Do you have any suggestions on how to proceed from here?
Comment 124 Thomas Gfeller 2023-06-28 19:45:49 UTC
(In reply to Cameron Berkenpas from comment #123)
> We don't even know if you have the tas hardware. Can you at least provide a
> link to your alsa-info? Most of Lenovo's laptop models use Cirrus Logic.
> 
> (In reply to Thomas Gfeller from comment #122)
> > Do you have any suggestions on how to proceed from here?

Sure, I thought this had been confirmed:

- https://bugzilla.kernel.org/show_bug.cgi?id=217449
- http://alsa-project.org/db/?f=45447739750ff897cdc20fd0e98d4f2055beebdf

-> /sys/bus/acpi/devices/TIAS2781:00/status 	 15
Comment 125 Carlo Francesco 2023-06-28 20:23:27 UTC
I have the feeling that the /etc/modprobe.d/snd-soc-skl-fix.conf should containt only one line:
options snd-intel-dspcfg dsp_driver=1 

No other options defined, neither in other files (ie alsa.conf snd.conf or whatever links to an option in snd-hda)
It's the only way to force the SOF Linux driver to not be used. This way the snd-hda-intel will run the pci quirk containied in the realtek-patch.c that will try to load the lenovo Firmware (which was not found in your last trial).
Comment 126 Cameron Berkenpas 2023-06-28 21:07:43 UTC
Thanks! Since this is unrelated to Cirrus Logic amps, probably better to continue this in the Lenovo forums: https://forums.lenovo.com/t5/Other-Linux-Discussions/Power-ACPI-Issues-of-Legion-Pro-7-16IRX8H/m-p/5232492?page=3

The quirk for your model is already in the driver provided by TI? Am I understanding that correctly? If that's the case, the TI devs will likely help you with this.



(In reply to Thomas Gfeller from comment #124)
> (In reply to Cameron Berkenpas from comment #123)
> > We don't even know if you have the tas hardware. Can you at least provide a
> > link to your alsa-info? Most of Lenovo's laptop models use Cirrus Logic.
> > 
> > (In reply to Thomas Gfeller from comment #122)
> > > Do you have any suggestions on how to proceed from here?
> 
> Sure, I thought this had been confirmed:
> 
> - https://bugzilla.kernel.org/show_bug.cgi?id=217449
> - http://alsa-project.org/db/?f=45447739750ff897cdc20fd0e98d4f2055beebdf
> 
> -> /sys/bus/acpi/devices/TIAS2781:00/status    15
Comment 127 Thomas Gfeller 2023-08-03 05:34:42 UTC
Created attachment 304762 [details]
Amps are working for certain devices

I got my amps working. If your device has a TIAS2781 component inside (http://alsa-project.org/db/?f=45447739750ff897cdc20fd0e98d4f2055beebdf <- note line 71), you can try the following:

Install i2ctools first and then run ./2pa-byps.sh with the i2c-bus number where your TIAS2781 is connected. E.g:

sudo ./2pa-byps.sh 0

In my case this enabled my subwoofers and the sound was working properly.

This change will be included in the kernel in the next couple of weeks / months so no workaround will be necessary anymore.
Comment 128 kuchenrolle 2023-08-06 14:45:17 UTC
I have the same issue with a new Lenovo Legion Slim 7i Gen 8 - sound works fine through the headphone jack, but the speakers remain silent. I got a bit lost in this thread and the other forum posts I found on this and tried some of the patches that seemed fitting, but to no avail. What can I do? My alsa info is here: http://alsa-project.org/db/?f=b4c4bd602b8bd2851639280076667fd64c08189f
Comment 129 Cameron Berkenpas 2023-08-06 18:40:02 UTC
This bug has nothing to do with Gen 8. I don't know if the slim is 
supported, but the non-slim is as well as a few other models. More info 
here:
https://forums.lenovo.com/t5/Ubuntu/Ubuntu-and-legion-pro-7-16IRX8H-audio-issues/m-p/5210709?page=15

On 8/6/23 07:45, bugzilla-daemon@kernel.org wrote:
> https://bugzilla.kernel.org/show_bug.cgi?id=216194
>
> kuchenrolle@googlemail.com changed:
>
>             What    |Removed                     |Added
> ----------------------------------------------------------------------------
>                   CC|                            |kuchenrolle@googlemail.com
>
> --- Comment #128 from kuchenrolle@googlemail.com ---
> I have the same issue with a new Lenovo Legion Slim 7i Gen 8 - sound works
> fine
> through the headphone jack, but the speakers remain silent. I got a bit lost
> in
> this thread and the other forum posts I found on this and tried some of the
> patches that seemed fitting, but to no avail. What can I do? My alsa info is
> here: http://alsa-project.org/db/?f=b4c4bd602b8bd2851639280076667fd64c08189f
>
Comment 130 riag 2023-09-18 18:05:50 UTC
(In reply to Cameron Berkenpas from comment #129)
> This bug has nothing to do with Gen 8. I don't know if the slim is 
> supported, but the non-slim is as well as a few other models. More info 
> here:
> https://forums.lenovo.com/t5/Ubuntu/Ubuntu-and-legion-pro-7-16IRX8H-audio-
> issues/m-p/5210709?page=15
> 
> On 8/6/23 07:45, bugzilla-daemon@kernel.org wrote:
> > https://bugzilla.kernel.org/show_bug.cgi?id=216194
> >
> > kuchenrolle@googlemail.com changed:
> >
> >             What    |Removed                     |Added
> >
> ----------------------------------------------------------------------------
> >                   CC|                           
> |kuchenrolle@googlemail.com
> >
> > --- Comment #128 from kuchenrolle@googlemail.com ---
> > I have the same issue with a new Lenovo Legion Slim 7i Gen 8 - sound works
> > fine
> > through the headphone jack, but the speakers remain silent. I got a bit
> lost
> > in
> > this thread and the other forum posts I found on this and tried some of the
> > patches that seemed fitting, but to no avail. What can I do? My alsa info
> is
> > here:
> http://alsa-project.org/db/?f=b4c4bd602b8bd2851639280076667fd64c08189f
> >

I can confirm that this bug is also present with the Slim Gen 8 (at least with my Legion Slim 7 16APH8).
I can also confirm that Cameron's patch works (with a little adjustment).

Following this and other threads on the issue I was able to compile a kernel with working sound. It only took like 10 kernel builds :)

For everyone out there without sound here are the steps i took:

1.also-info
http://alsa-project.org/db/?f=28c8e557a7baeeeebc911e08f416c051ec702d09

Find out whether you have the TIAS* or Realtek device

Find your device (mine looks like this):
Codec: Realtek ALC287
Address: 0
AFG Function Id: 0x1 (unsol 1)
Vendor Id: 0x10ec0287
Subsystem Id: 0x17aa38b6
Revision Id: 0x100002

As far as I understand, this only works for the Realtek device.

What you are looking for is the "Subsystem Id: 0x17aa38b6" or the second part of it "38b6".

2. DSDT table

Confirm the I2C address (?) with the above mentioned lookup.
My results: 
          Method (_SUB, 0, NotSerialized)  // _SUB: Subsystem ID
            {
                If ((RTSV == One))
                {
                    Return ("17AA38B7")
                }

                Return ("17AA38B6")
            }

One matches the one from alsa info. To be sure I compiled two kernels. Spoiler alert, the one from alsa-info worked.

3. Edit Cameron's patch to the values you just found out. Since I'm running a newer kernel, the patch command did not work and I did it manually.

Find the places in your kernels source /sound/pci/hda/cs35l41_hda.c file and copy the code from the patch.

In your kernels /sound/pci/hda/patch_realtek.c file add one line in the code block where the  patch added the code:

"SND_PCI_QUIRK(0x17aa, 0x38b6, "Legion Slim 7 16APH8", ALC287_FIXUP_CS35L41_I2C_2),"

Exchange "0x38b6" with your id from alsa info. I've also experienced, that it doesn't work if your device description ("Legion Slim 7 16APH8") is different from the one in your alsa info

4.Compile your own kernel. I followed 
https://wiki.archlinux.org/title/Kernel/Traditional_compilation

That were the basic steps I took to make my speakers work. Please correct me if wrote something wrong, built my first kernel a few days ago...

Thank you Cameron for putting in the time, I'd like to buy you some beer/coffee or send you flowers. I'm not kidding, write if you are interested...
Comment 131 Xavier Hsinyuan 2023-10-13 16:50:22 UTC
Created attachment 305210 [details]
dmesg from Legion Y9000X 16IAH7, 6.5.3+
Comment 132 Xavier Hsinyuan 2023-10-13 16:51:33 UTC
Created attachment 305211 [details]
Legion Y9000X IAH7(82TF) ACPI DSDT
Comment 133 Xavier Hsinyuan 2023-10-13 16:54:58 UTC
(In reply to Cameron Berkenpas from comment #46)
> Created attachment 303571 [details]
> lenovo-7i-gen7-sound-6.2.0-rc3-0.0.4.patch
> 
> Adds experimental Legion S7 16IAH7 (Gen 7 slim) support.
> 
> Other minor improvements.

Hi Cameron,
Thanks for your patch for Legion S7 16IAH7. I try to applied this patch (and edit with subsystem id in alsa-info) for Legion Y9000X 16IAH7, but the speakers and jacks remain silent and I got some bad messages in dmesg(https://bugzilla.kernel.org/attachment.cgi?id=305210):

[    9.881918] genirq: Flags mismatch irq 58. 00002088 (cs35l41 IRQ1 Controller) vs. 00002088 (cs35l41 IRQ1 Controller)
[    9.881930] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.1: Failed to request IRQ 58 for cs35l41 IRQ1 Controller: -16

alsa-info: http://alsa-project.org/db/?f=05d424dfcb9b901cfa001109e9edd97aa3904393
Comment 134 Cameron Berkenpas 2023-10-13 17:11:22 UTC
Probably won't work...

IIRC, the smart amps aren't necessarily always on an i2c bus. It could 
be on the other bus (the name escapes me at the moment).

On 10/13/23 9:54 AM, bugzilla-daemon@kernel.org wrote:
> https://bugzilla.kernel.org/show_bug.cgi?id=216194
>
> --- Comment #133 from Xavier Hsinyuan (thelastlin@outlook.jp) ---
> (In reply to Cameron Berkenpas from comment #46)
>> Created attachment 303571 [details]
>> lenovo-7i-gen7-sound-6.2.0-rc3-0.0.4.patch
>>
>> Adds experimental Legion S7 16IAH7 (Gen 7 slim) support.
>>
>> Other minor improvements.
> Hi Cameron,
> Thanks for your patch for Legion S7 16IAH7. I try to applied this patch (and
> edit with subsystem id in alsa-info) for Legion Y9000X 16IAH7, but the
> speakers
> and jacks remain silent and I got some bad messages in
> dmesg(https://bugzilla.kernel.org/attachment.cgi?id=305210):
>
> [    9.881918] genirq: Flags mismatch irq 58. 00002088 (cs35l41 IRQ1
> Controller) vs. 00002088 (cs35l41 IRQ1 Controller)
> [    9.881930] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.1: Failed to request
> IRQ
> 58 for cs35l41 IRQ1 Controller: -16
>
> alsa-info:
> http://alsa-project.org/db/?f=05d424dfcb9b901cfa001109e9edd97aa3904393
>
Comment 135 exstrim401 2023-12-09 08:34:09 UTC
(In reply to riag from comment #130)
> (In reply to Cameron Berkenpas from comment #129)
> > This bug has nothing to do with Gen 8. I don't know if the slim is 
> > supported, but the non-slim is as well as a few other models. More info 
> > here:
> > https://forums.lenovo.com/t5/Ubuntu/Ubuntu-and-legion-pro-7-16IRX8H-audio-
> > issues/m-p/5210709?page=15
> > 
> > On 8/6/23 07:45, bugzilla-daemon@kernel.org wrote:
> > > https://bugzilla.kernel.org/show_bug.cgi?id=216194
> > >
> > > kuchenrolle@googlemail.com changed:
> > >
> > >             What    |Removed                     |Added
> > >
> >
> ----------------------------------------------------------------------------
> > >                   CC|                           
> > |kuchenrolle@googlemail.com
> > >
> > > --- Comment #128 from kuchenrolle@googlemail.com ---
> > > I have the same issue with a new Lenovo Legion Slim 7i Gen 8 - sound
> works
> > > fine
> > > through the headphone jack, but the speakers remain silent. I got a bit
> > lost
> > > in
> > > this thread and the other forum posts I found on this and tried some of
> the
> > > patches that seemed fitting, but to no avail. What can I do? My alsa info
> > is
> > > here:
> > http://alsa-project.org/db/?f=b4c4bd602b8bd2851639280076667fd64c08189f
> > >
> 
> I can confirm that this bug is also present with the Slim Gen 8 (at least
> with my Legion Slim 7 16APH8).
> I can also confirm that Cameron's patch works (with a little adjustment).
> 
> Following this and other threads on the issue I was able to compile a kernel
> with working sound. It only took like 10 kernel builds :)
> 
> For everyone out there without sound here are the steps i took:
> 
> 1.also-info
> http://alsa-project.org/db/?f=28c8e557a7baeeeebc911e08f416c051ec702d09
> 
> Find out whether you have the TIAS* or Realtek device
> 
> Find your device (mine looks like this):
> Codec: Realtek ALC287
> Address: 0
> AFG Function Id: 0x1 (unsol 1)
> Vendor Id: 0x10ec0287
> Subsystem Id: 0x17aa38b6
> Revision Id: 0x100002
> 
> As far as I understand, this only works for the Realtek device.
> 
> What you are looking for is the "Subsystem Id: 0x17aa38b6" or the second
> part of it "38b6".
> 
> 2. DSDT table
> 
> Confirm the I2C address (?) with the above mentioned lookup.
> My results: 
>           Method (_SUB, 0, NotSerialized)  // _SUB: Subsystem ID
>             {
>                 If ((RTSV == One))
>                 {
>                     Return ("17AA38B7")
>                 }
> 
>                 Return ("17AA38B6")
>             }
> 
> One matches the one from alsa info. To be sure I compiled two kernels.
> Spoiler alert, the one from alsa-info worked.
> 
> 3. Edit Cameron's patch to the values you just found out. Since I'm running
> a newer kernel, the patch command did not work and I did it manually.
> 
> Find the places in your kernels source /sound/pci/hda/cs35l41_hda.c file and
> copy the code from the patch.
> 
> In your kernels /sound/pci/hda/patch_realtek.c file add one line in the code
> block where the  patch added the code:
> 
> "SND_PCI_QUIRK(0x17aa, 0x38b6, "Legion Slim 7 16APH8",
> ALC287_FIXUP_CS35L41_I2C_2),"
> 
> Exchange "0x38b6" with your id from alsa info. I've also experienced, that
> it doesn't work if your device description ("Legion Slim 7 16APH8") is
> different from the one in your alsa info
> 
> 4.Compile your own kernel. I followed 
> https://wiki.archlinux.org/title/Kernel/Traditional_compilation
> 
> That were the basic steps I took to make my speakers work. Please correct me
> if wrote something wrong, built my first kernel a few days ago...
> 
> Thank you Cameron for putting in the time, I'd like to buy you some
> beer/coffee or send you flowers. I'm not kidding, write if you are
> interested...

Thanks!
'SND_PCI_QUIRK(0x17aa, 0x38b5, "Legion Y9000X IRH8", ALC287_FIXUP_CS35L41_I2C_2)'
fixed sound for my device
Comment 136 Sergey Strigin 2023-12-24 10:33:30 UTC
Hello there, I have a Lenovo legion 7 16IAX7, this is my Alsa info output: http://alsa-project.org/db/?f=0cfb976e04cafc95304e47f58270cc993d985e8d.

I applied a patch from this thread. It works, the speakers start play sound, but amps (subwoofers) are not working. Can you help me?
Comment 137 Cameron Berkenpas 2023-12-25 00:36:52 UTC
(In reply to Sergey Strigin from comment #136)
> Hello there, I have a Lenovo legion 7 16IAX7, this is my Alsa info output:
> http://alsa-project.org/db/?f=0cfb976e04cafc95304e47f58270cc993d985e8d.
> 
> I applied a patch from this thread. It works, the speakers start play sound,
> but amps (subwoofers) are not working. Can you help me?

That looks to just be the regular Legion 7i Gen 7. It just has the standard 2 speakers. It doesn't have subwoofers.
Comment 138 Sergey Strigin 2023-12-25 02:53:50 UTC
(In reply to Cameron Berkenpas from comment #137)
> (In reply to Sergey Strigin from comment #136)
> > Hello there, I have a Lenovo legion 7 16IAX7, this is my Alsa info output:
> > http://alsa-project.org/db/?f=0cfb976e04cafc95304e47f58270cc993d985e8d.
> > 
> > I applied a patch from this thread. It works, the speakers start play
> sound,
> > but amps (subwoofers) are not working. Can you help me?
> 
> That looks to just be the regular Legion 7i Gen 7. It just has the standard
> 2 speakers. It doesn't have subwoofers.

Perhaps you're right, and my laptop doesn't have subwoofers. However, when I listen to music on Windows 11, there's a significant difference in sound quality. On Windows, the sound is loud, expansive, deep, and rich in lower frequencies, among other qualities. In contrast, on Arch with a patch applied, the sound quality is roughly 50% of what it is on Windows. This difference is quite noticeable to me. If the laptop indeed lacks subwoofers, as I initially thought, what could be the reason for this discrepancy?
Comment 139 Cameron Berkenpas 2023-12-25 04:07:22 UTC
(In reply to Sergey Strigin from comment #138)
> (In reply to Cameron Berkenpas from comment #137)
> > (In reply to Sergey Strigin from comment #136)
> > > Hello there, I have a Lenovo legion 7 16IAX7, this is my Alsa info
> output:
> > > http://alsa-project.org/db/?f=0cfb976e04cafc95304e47f58270cc993d985e8d.
> > > 
> > > I applied a patch from this thread. It works, the speakers start play
> > sound,
> > > but amps (subwoofers) are not working. Can you help me?
> > 
> > That looks to just be the regular Legion 7i Gen 7. It just has the standard
> > 2 speakers. It doesn't have subwoofers.
> 
> Perhaps you're right, and my laptop doesn't have subwoofers. However, when I
> listen to music on Windows 11, there's a significant difference in sound
> quality. On Windows, the sound is loud, expansive, deep, and rich in lower
> frequencies, among other qualities. In contrast, on Arch with a patch
> applied, the sound quality is roughly 50% of what it is on Windows. This
> difference is quite noticeable to me. If the laptop indeed lacks subwoofers,
> as I initially thought, what could be the reason for this discrepancy?

The difference is due to guessed values in the patch. 

I personally mainly noticed a difference in sound volume.
Comment 140 Farrel 2023-12-28 21:52:29 UTC
Created attachment 305669 [details]
alsa and dmesg

(In reply to Cameron Berkenpas from comment #66)
> Created attachment 303828 [details]
> lenovo-7i-gen7-sound-6.2.0-rc3-0.0.5b-002.patch
> 
> This patch theoretically supports the following models:
> +       SND_PCI_QUIRK(0x17aa, 0x3874, "Legion 7 16IAX7",
> ALC287_FIXUP_CS35L41_I2C_2),
> +       SND_PCI_QUIRK(0x17aa, 0x386f, "Legion 7 16IAX7",
> ALC287_FIXUP_CS35L41_I2C_2),
> +       SND_PCI_QUIRK(0x17aa, 0x3803, "Legion 7i slim 16IAH7",
> ALC287_FIXUP_CS35L41_I2C_2),
> +       SND_PCI_QUIRK(0x17aa, 0x3856, "Yoga Slim 7 Carbon 14ACN6",
> ALC287_FIXUP_CS35L41_I2C_2),
> +       SND_PCI_QUIRK(0x17aa, 0x3877, "Legion 7 slim 16ARHA7",
> ALC287_FIXUP_CS35L41_I2C_2),
> 
> The Lenovo Legion 7i Gen 7 16IAX7 seems pretty safe (and has had by far the
> most testing). 
> 
> That being said, all support provided by this patch is USE AT YOUR OWN RISK.
> Different models of laptop theoretically have different values (that should
> be provided via the DSD table in the BIOS). These are guessed values that
> work for the 16IAX7 and possibly others. I can't make any guarantees.
> 
> If you have problems with your sound, overly loud volume, distorted sound,
> "AMP short" errors (see below), back out the patch and update this bug with
> your feedback (giving your alsa-info)
> 
> If you get "AMP short" messages in dmesg, it's probably wise to back out the
> patch as I suspect prolonged usage could result. To test for this, just play
> some music out a very high volume for a few minutes. You may notice one or
> both of your speakers going out (and you'll see "AMP short" messages in
> dmesg). If this happens, back the patch out. 
> 
> With "AMP short" errors, once audio output has been stopped for probablly 5+
> minutes, the affected speakers will "recover", but eventually they'll fail
> again. Just because they might start working again doesn't mean there isn't
> a serious problem. Just back out the patch and provide feedback.
> 
> If you don't get any sound at all... Provide your alsa-info and your full
> dmesg output. If you see a message such as "Serial bus multi instantiate
> pseudo device driver CSC3551:00: error -ENOENT: Error requesting irq at
> index 0", this is an issue that occurs before my patch. There's an issue
> with the cs35l41 driver where it's not able to detect the CSC3551's on your
> model of laptop. Reporting this to Cirrus Logic may help and AFTER that
> issue is fixed... You may still need my patch.
> 
> If the patch works, please provide feedback with your alsa-info. With all
> the info, my hope is that we'll have an eventual "safe list" of laptop
> models for this patch.

Hi Cameron,

Thank you for your work with the patch. I'm on a Lenovo S7 16IAH7 running on Debian 6.1.67. I installed the patch you had provided but my speakers still doesn't seem to work. I also tried following the suggestion made in comment 130, but to no avail. Could it be related to the kernel that I'm on? You can find my alsa-info and my dmesg. Hope the information provided was helpful!
Comment 141 Cameron Berkenpas 2023-12-28 22:09:12 UTC
(In reply to Farrel from comment #140)
> Created attachment 305669 [details]
> alsa and dmesg
> 
> 
> Hi Cameron,
> 
> Thank you for your work with the patch. I'm on a Lenovo S7 16IAH7 running on
> Debian 6.1.67. I installed the patch you had provided but my speakers still
> doesn't seem to work. I also tried following the suggestion made in comment
> 130, but to no avail. Could it be related to the kernel that I'm on? You can
> find my alsa-info and my dmesg. Hope the information provided was helpful!

Reading through all the comments on this issue, it seems the 16IAH7 just doesn't work.

Maybe it's not even using i2c?
Comment 142 ramzes005 2024-02-07 16:11:15 UTC
Created attachment 305841 [details]
legion_7i-gen7_16IAX7-sound-6.7.3.patch
Comment 143 ramzes005 2024-02-07 16:14:24 UTC
Comment on attachment 305841 [details]
legion_7i-gen7_16IAX7-sound-6.7.3.patch

From newest kernel version it is possible to add legion quirk in easy way. I've tested it on kernel 6.7.3 and it works for my Legion 7i 16IAX7
Comment 144 xotewan489 2024-02-18 10:25:20 UTC
I can't get sound from my Legion S7 16IAH7. I bought my device 2 years ago and I could never get the sound to work. I finally found this place, please help me.


asla-info: https://privatebin.net/?71c5dc1d4e857a3a#42XU3YaPfT7zAm2Y2Q8mYU6H7uH5YGUJN8xRjX9Vy7zU
Comment 145 nutmeg_progress873 2024-02-23 08:36:20 UTC
(In reply to ramzes005 from comment #143)
> Comment on attachment 305841 [details]
> legion_7i-gen7_16IAX7-sound-6.7.3.patch
> 
> From newest kernel version it is possible to add legion quirk in easy way.
> I've tested it on kernel 6.7.3 and it works for my Legion 7i 16IAX7


I added a quirk for the Legion S7 16IAH7 following this format; it doesn't work, and have no idea why; if anyone is up for debugging this I'm happy to work with them.

As a point of reference, I added the quirk to 6.8-rc5 on Opensuse Tumbleweed.
Comment 146 Tom Benham 2024-02-27 14:40:52 UTC
(In reply to ramzes005 from comment #143)
> Comment on attachment 305841 [details]
> legion_7i-gen7_16IAX7-sound-6.7.3.patch
> 
> From newest kernel version it is possible to add legion quirk in easy way.
> I've tested it on kernel 6.7.3 and it works for my Legion 7i 16IAX7

I have patched my kernel v6.7.6 in the same way for my Legion S7 16ARHA7. I just replaced the value 17AA386F with 17AA3878 and 0x386f with 0x3878 to match what I got from alsa-info.sh.

Now sound seems to work well.

Can this be merged into the kernel ? What are the risks ?

Note You need to log in before you can comment on or make changes to this bug.