This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TAS2781: tas2781s linux drivers for Lenovo laptops

Part Number: TAS2781

Dear community,

Hope all is well on your end

I have recently bought a laptop from Lenovo ( Legion gen8 16IRX8H ) ,  that does not have sound support among Linux users.

Thanks to the I2C, I believe I have located a piece of equipment that is manufactured by Texas Instrument:

/sys/bus/i2c/devices/i2c-TIAS2781\:00/

This smart amplifier is a TAS2781 which already have support for the Alsa SoC https://git.ti.com/cgit/tas2781-linux-drivers/tas2781-linux-driver/ , but and ca't be useful on a Linux x86/x86_64.

The tas2781s is connected with a Realtek (ALC287) codec in this laptop. The Lenovo BIOS, unfortunately, doesn't contain the proper information to make the Realtek codec to communicate with the AMP chip (it misses of init verbs table), so a substantial rework of the Realtek driver is needed.

As I understood, there is a file called patch_realtek.c in the current Linux kernel source, specifically in sound/pci/hda/patch_realtek.c . This file has a fixup with snd_pci_quirk for the motherboard to fix the speakers of many laptops/desktops. For instance, a line that includes a patch for a specific laptop that use the CIRRUS AMP looks like this: 
SND_PCI_QUIRK(0x17aa, 0x3874, "Legion 7 16IAX7", ALC287_FIXUP_CS35L41_I2C_2),

For the Legion laptop
SND_PCI_QUIRK(0x17aa,  0x3884  , "Legion 7 Pro 16IRX8H", ALC287_FIXUP_TAS2781S_I2C_2),
Where the ALC287 is the specific codec recognised by the kernel.
I took the (0x17aa, 0x3884) that matches my alsa-info http://alsa-project.org/db/?f=ed0116e9d7235fd5cbece5dccaa589ecad71f534 and the DSDT table (that can be found here https://bugzilla.kernel.org/attachment.cgi?id=303959) and its extract is the following:
  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")
                         }
                     }
I can link you to the following patch https://bugzilla.kernel.org/attachment.cgi?id=303828 that has been posted in the following discussion https://bugzilla.kernel.org/show_bug.cgi?id=216194#c66 for someone that patched the Realtek driver for his laptop (a Legion 7 16IAX7 that has on board a SMART AMP CSC3551)
It would be lovely if someone from the TI community could help, or a driver can be made to be included in the main kernel release.
Thanks a lot for your time
Warm regards.
  • Hi Carlo

    Thanks for your trust. I have checked from Lenovo that there're two pcs of tas2781 in Legion gen8 16IRX8H.

    In order that I can we can work at the same page, may I collect following infomation:

    1. What kind of Linux, Ubuntu or others?
    2. kernel version, 6.2 or others?

    A simliar Laptop is being borrowed from Lenovo, I think it will be ready next week.

    This week, I will prepare the tas2781 Linux driver to support ACPI arch Linux.

    If I have some questions, I will let you know via e2e forrum, mail or conf-call which can share the screen and code, etc.

    BR

    Shenghao Ding

  • Dear Shenghao, 

    That's a fantastic news!

    I currently use Ubuntu 22.10 with kernel 6.2.7 that I retrieved from here kernel.ubuntu.com/.../

    Thanks a lot then, to the TI and the Lenovo team too!

  • Hi Carlo,

    Just double checking, was your question resolved or are you waiting on a response from Shenghao?

    Thank you,

    Jeff McPherson

  • Hello Jeff, thanks for your message.

    Actually the thread should be still open. I'm waiting for Shenghao to give me more instructions . He is managing to build the driver for the amp chip on linux

  • Quoting a friend that dealt with another lenovo legion:
    "The cs35l41 driver was originally strictly for ASoC, and to support

    cs35l41 smart amps on laptops, Cirrus Logic took the approach of making
    portions of their driver into a "shared library" such that they could
    have a callback/hook called from sound/pci/hda/patch_realtek.c, allowing
    speaker output to work on such systems.

    The TI devs could follow some of the discussions around that and/or look
    at the cs35l41 code to at least get them started in the right direction."

  • Hi Carlo,

    Thanks for the clarification. In that case please wait to reply until Shenghao gets a chance to prepare the driver for you unless another question comes up.

    Thank you,

    Jeff McPherson

  • Hi Carlo

    Just this Monday. I got the Lenovo engninering laptop. Yesterdya, I have delpyed Ubuntu 22.10 on it and share the schematics with AMD guys for review and confirm how to modify the asl file and realtek codec drive code for Linux. This task involves AMD, TI, realtek, and Lenovo, it just kick off.

    Would you be so kind and run following Linux commands in your laptop and upload the log and files with me?

    following 4 commands will output several files, upload them.

    # acpidump -s > acpi-table,lst

     #acpidump -o ACPI_table.out

    # acpixtract -a ACPI_table.out

    # amixer > kcontrol.lst

    following 3 commands will out some log in the comand terminal, capture it and upload.

    # ls /dev/snd -al

    # cat /proc/asound/pcm

    # cat /proc/asound/cards

    BR

    Shenghao Ding

  • Hello Shenghao.

    Many thanks for the support.

    I asked someone on the Lenovo forum with my same hardware and bios firmware to do so because I'm currently unable to access my laptop.

    Original post: forums.lenovo.com/.../5944669

    Here you can find the ACPI_AMIXER for our model: https://forums.lenovo.com/download/oJ0EhFr8QFk

    And here is the extract of our ls:

    1) # ls /dev/snd -al

    total 0
    drwxr-xr-x   3 root root      380 Apr  5 12:22 .
    drwxr-xr-x  20 root root     5420 Apr  5 12:24 ..
    drwxr-xr-x   2 root root       80 Apr  5 12:22 by-path
    crw-rw----+  1 root audio 116, 15 Apr  5 12:22 controlC0
    crw-rw----+  1 root audio 116,  6 Apr  5 12:22 controlC1
    crw-rw----+  1 root audio 116, 13 Apr  5 12:22 hwC0D0
    crw-rw----+  1 root audio 116, 14 Apr  5 12:22 hwC0D2
    crw-rw----+  1 root audio 116,  5 Apr  5 12:22 hwC1D0
    crw-rw----+  1 root audio 116,  8 Apr  5 12:26 pcmC0D0c
    crw-rw----+  1 root audio 116,  7 Apr  5 12:32 pcmC0D0p
    crw-rw----+  1 root audio 116,  9 Apr  5 12:26 pcmC0D3p
    crw-rw----+  1 root audio 116, 10 Apr  5 12:26 pcmC0D7p
    crw-rw----+  1 root audio 116, 11 Apr  5 12:26 pcmC0D8p
    crw-rw----+  1 root audio 116, 12 Apr  5 12:26 pcmC0D9p
    crw-rw----+  1 root audio 116,  2 Apr  5 12:26 pcmC1D3p
    crw-rw----+  1 root audio 116,  3 Apr  5 12:26 pcmC1D7p
    crw-rw----+  1 root audio 116,  4 Apr  5 12:26 pcmC1D8p
    crw-rw----+  1 root audio 116,  1 Apr  5 12:22 seq
    crw-rw----+  1 root audio 116, 33 Apr  5 12:22 timer

    2) # cat /proc/asound/pcm

    00-00: ALC287 Analog : ALC287 Analog : playback 1 : capture 1
    00-03: HDMI 0 : HDMI 0 : playback 1
    00-07: HDMI 1 : HDMI 1 : playback 1
    00-08: HDMI 2 : HDMI 2 : playback 1
    00-09: HDMI 3 : HDMI 3 : playback 1
    01-03: HDMI 0 : HDMI 0 : playback 1
    01-07: HDMI 1 : HDMI 1 : playback 1
    01-08: HDMI 2 : HDMI 2 : playback 1

     

    3) # cat /proc/asound/cards

    0 [PCH               ]: HDA-Intel - HDA Intel PCH
                                    HDA Intel PCH at 0x6405130000 irq 239
     1 [NVidia         ]: HDA-Intel - HDA NVidia
                                   HDA NVidia at 0x86000000 irq 17

  • I post mine as well, since they are a bit different

    The dump is: forums.lenovo.com/.../w_VqKdO9zjA

    ls /dev/snd -al  
    /dev/snd:
    total 0
    drwxr-xr-x   3 root root      280 Apr  5 18:29 .
    drwxr-xr-x  21 root root     4880 Apr  5 18:29 ..
    drwxr-xr-x   2 root root       80 Apr  5 18:29 by-path
    crw-rw----+  1 root audio 116, 10 Apr  5 18:29 controlC0
    crw-rw----+  1 root audio 116,  6 Apr  5 18:29 controlC1
    crw-rw----+  1 root audio 116,  9 Apr  5 18:29 hwC0D0
    crw-rw----+  1 root audio 116,  5 Apr  5 18:29 hwC1D0
    crw-rw----+  1 root audio 116,  8 Apr  5 18:29 pcmC0D0c
    crw-rw----+  1 root audio 116,  7 Apr  5 18:29 pcmC0D0p
    crw-rw----+  1 root audio 116,  2 Apr  5 18:29 pcmC1D3p
    crw-rw----+  1 root audio 116,  3 Apr  5 18:29 pcmC1D7p
    crw-rw----+  1 root audio 116,  4 Apr  5 18:29 pcmC1D8p
    crw-rw----+  1 root audio 116,  1 Apr  5 18:29 seq
    crw-rw----+  1 root audio 116, 33 Apr  5 18:29 timer


     cat /proc/asound/pcm
    00-00: ALC287 Analog : ALC287 Analog : playback 1 : capture 1
    01-03: HDMI 0 : HDMI 0 : playback 1
    01-07: HDMI 1 : HDMI 1 : playback 1
    01-08: HDMI 2 : HDMI 2 : playback 1

     cat /proc/asound/cards
     0 [PCH            ]: HDA-Intel - HDA Intel PCH
                          HDA Intel PCH at 0x4404130000 irq 220
     1 [NVidia         ]: HDA-Intel - HDA NVidia
                          HDA NVidia at 0x86000000 irq 17

  • Do not ignore running "amixer > kcontrol.lst"

  • Hello Shenghao Slight smile
    It's included in the dump i posted forums.lenovo.com/.../w_VqKdO9zjA

  • Hi Carlo

    Thanks, would you be so kind get vendor id and device id for me in win11?

    Like following snapshot. Looking forward to your feedback.

  • Hello Shenghao :)

    I appreciate your message. On a separate hard disk, I have just finished installing Windows 11. (I bought the no os version for my laptop).

    After putting in the sound card drivers, this is what I got:

  • Thanks, I have collected all the laptops which had deplyed tas2781.

    Before I plan to add following into patch_realtek.c, I will discuss wtih mantianer for patch_realtek.c (realtek guy)

    the and Laptop vendor(Lenovo guy) first. Then, I can have my coding

    SND_PCI_QUIRK(0x17aa, 0x387d, "Yoga S780-16 pro Quad AAC", ALC287_FIXUP_TAS2781_I2C),
    SND_PCI_QUIRK(0x17aa, 0x387e, "Yoga S780-16 pro Quad YC", ALC287_FIXUP_TAS2781_I2C),
    SND_PCI_QUIRK(0x17aa, 0x3881, "YB9 dual powe mode2 YC", ALC287_FIXUP_TAS2781_I2C),
    SND_PCI_QUIRK(0x17aa, 0x3884, "Y780 YG DUAL", ALC287_FIXUP_TAS2781_I2C),
    SND_PCI_QUIRK(0x17aa, 0x3886, "Y780 VECO DUAL", ALC287_FIXUP_TAS2781_I2C),
    SND_PCI_QUIRK(0x17aa, 0x38a7, "Y780P AMD YG dual", ALC287_FIXUP_TAS2781_I2C),
    SND_PCI_QUIRK(0x17aa, 0x38a8, "Y780P AMD VECO dual", ALC287_FIXUP_TAS2781_I2C),
    SND_PCI_QUIRK(0x17aa, 0x38ba, "Yoga S780-14.5 Air AMD quad YC", ALC287_FIXUP_TAS2781_I2C),
    SND_PCI_QUIRK(0x17aa, 0x38bb, "Yoga S780-14.5 Air AMD quad AAC", ALC287_FIXUP_TAS2781_I2C),
    SND_PCI_QUIRK(0x17aa, 0x38be, "Yoga S980-14.5 proX YC Dual", ALC287_FIXUP_TAS2781_I2C),
    SND_PCI_QUIRK(0x17aa, 0x38bf, "Yoga S980-14.5 proX LX Dual", ALC287_FIXUP_TAS2781_I2C),
    SND_PCI_QUIRK(0x17aa, 0x38c3, "Y980 DUAL", ALC287_FIXUP_TAS2781_I2C),

  • Hi Carlo

    The HDA driver seemed so different from the codec driver. I am still speding some time studying it.

    I struggle to start coding as soon as possible. Following is the driver arch. Looking forward to your 

    comment.

    Have a good weekend.

    Shenghao Ding

  • Hi Carlo

    The code for bypass is ready.

    2500.current.7z

    Folder name

    Remark

    Purpose

    config_dir

    Config files for kernel image compiling

    Merge not copy or overwrite them into compiling folder

    Documentation

    Store Tas2781 dts illustration file

    include

    Three Header files for tas2781 driver

    sound

    Store the source files for tas2781 driver

    ubuntu2304-make.sh

    Compiling script

    lib

    Store the firmware for different laptop deployed with tas2781

    Copy the whole folder into Laptop /

    • This patch has been tested on Ubuntu 23.04/kernel6.4.0-rc5+
    • After code merge, use ubuntu2304-make.sh to compile and image deployment
    • Don’t forget copy whole folder lib into the laptop lib
    • Then reboot the laptop

    BR

    Shenghao Ding

  • Thanks a lot Shenghao