Skip to content

Instantly share code, notes, and snippets.

@lamperez
Last active November 11, 2024 11:16
Show Gist options
  • Save lamperez/862763881c0e1c812392b5574727f6ff to your computer and use it in GitHub Desktop.
Save lamperez/862763881c0e1c812392b5574727f6ff to your computer and use it in GitHub Desktop.
CS35L41 amplifiers in an ASUS Zenbook on linux

Asus Zenbook UX3402 speakers on Linux

Important

THIS IS NOW OBSOLETE WITH KERNEL VERSIONS ≥ 6.7.0

A recent announcement in the kernel mail list by Cirrus developers will solve the problem described here. Therefore, the proposed solutions will be soon obsolete. See this comment (thanks, @flukejones, for the tip).

I got the speakers working on my Asus Zenbook 14 OLED UX3402, the one with Intel CPU and the two CS35L41 audio amplifiers connected over SPI (not the UM3402YA, with AMD and I²C). The amplifiers are supported by the snd_hda_scodec_cs35l41 module in recent kernel versions, but they require some model-specific configuration paramaters, that should be provided by the BIOS, via ACPI. Of course, they are missing. It seems that the Windows drivers have those parameters somehow hardcoded, instead of using ACPI (bad idea, but who am I to criticise). Since Asus has been nasty and refused/was not able to update the BIOS with the missing data, I have patched the ACPI tables myself.

Warning

As stated by Cirrus developers, if you try this there is a non-zero (low, I hope) possibility of blowing your speakers. Take into account that this procedure is not just configuring your box, it is hardware-level hacking with very scarce information about the hardware (thank you, ASUS, and thank you, Cirrus, for not publishing the CS35L41 datasheet and making it only available by request). Additionally, You should know how to work with DSDT or SSDT files (I have a brief guide here) and how to recover from a non booting system. You are on your own. You have been warned.

Note

I have used the patch for some months, and everything seems OK. As you can see, the most recent versions do not require electrical parameters to be specified, just providing the functions of several GPIO pins, that are already present in the original BIOS, and the behavior associated to them. I am almost sure that the patch is totally safe.

My BIOS is the most recent one (version 310). I have added two _DSD objects in the SSDT file (ssdt_csc3551.dsl, or its already assembled version, ssdt_csc3551.aml):

  • One inside the SPK1 device, providing the missing "cirrus,dev-index" and other properties, just like the I2C models. You can also provide these properties by patching the kernel module (the linux/sound/pci/hda/cs35l41_hda.c file).

  • Another one, after the SPK1 device, with the chip select GPIOs, "cs-gpios", required by the SPI bus (the somehow simpler I²C bus does not use chip select pins, but addresses). Without this _DSD object, only one amplifier can be addressed and activated. In this case, the driver refuses to load even for this single working amplifier.

Obsolete: DSDT patch

Instead of applying a SSDT file, you may patch the full DSDT dissassembled DSDT file (dsdt.dsl). This was my original solution (thanks to @thor2002ro for pointing to the simpler, nicer SSDT solution, see the comment, especially if you use grub). The patch is available for reference, just apply the SSDT file.

Obsolete: internal boost

I keep the old, original patch, that produced AMP short error messages when the volume was high enough, for reference. Please try first the simpler patch with external boost, that seems to work without flaws (thanks to @bdandy, see the comment).

Boot log

Output from journalctl -b -g CSC3551 --output short-monotonic after the old patch:

[5.358062] zenbook kernel: Serial bus multi instantiate pseudo device driver CSC3551:00: Instantiated 2 SPI devices.
[5.643640] zenbook kernel: cs35l41-hda spi1-CSC3551:00-cs35l41-hda.0: Cirrus Logic CS35L41 (35a40), Revision: B2
[5.680302] zenbook kernel: cs35l41-hda spi1-CSC3551:00-cs35l41-hda.1: Cirrus Logic CS35L41 (35a40), Revision: B2
[5.996217] zenbook kernel: cs35l41-hda spi1-CSC3551:00-cs35l41-hda.0: Falling back to default firmware.
[5.996608] zenbook kernel: cs35l41-hda spi1-CSC3551:00-cs35l41-hda.0: DSP1: Firmware version: 3
[5.996611] zenbook kernel: cs35l41-hda spi1-CSC3551:00-cs35l41-hda.0: DSP1: cirrus/cs35l41-dsp1-spk-prot.wmfw: Fri 24 Jun 2022 14:55:56 GMT Daylight Time
[6.069598] zenbook kernel: cs35l41-hda spi1-CSC3551:00-cs35l41-hda.0: DSP1: Firmware: 400a4 vendor: 0x2 v0.58.0, 2 algorithms
[6.070173] zenbook kernel: cs35l41-hda spi1-CSC3551:00-cs35l41-hda.0: DSP1: 0: ID cd v29.78.0 XM@94 YM@e
[6.070185] zenbook kernel: cs35l41-hda spi1-CSC3551:00-cs35l41-hda.0: DSP1: 1: ID f20b v0.1.0 XM@17c YM@0
[6.070192] zenbook kernel: cs35l41-hda spi1-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
[6.083485] zenbook kernel: snd_hda_codec_realtek ehdaudio0D0: bound spi1-CSC3551:00-cs35l41-hda.0 (ops cs35l41_hda_comp_ops [snd_hda_scodec_cs35l41])
[6.083899] zenbook kernel: cs35l41-hda spi1-CSC3551:00-cs35l41-hda.1: Falling back to default firmware.
[6.083962] zenbook kernel: cs35l41-hda spi1-CSC3551:00-cs35l41-hda.1: DSP1: Firmware version: 3
[6.083966] zenbook kernel: cs35l41-hda spi1-CSC3551:00-cs35l41-hda.1: DSP1: cirrus/cs35l41-dsp1-spk-prot.wmfw: Fri 24 Jun 2022 14:55:56 GMT Daylight Time
[6.145224] zenbook kernel: cs35l41-hda spi1-CSC3551:00-cs35l41-hda.1: DSP1: Firmware: 400a4 vendor: 0x2 v0.58.0, 2 algorithms
[6.145817] zenbook kernel: cs35l41-hda spi1-CSC3551:00-cs35l41-hda.1: DSP1: 0: ID cd v29.78.0 XM@94 YM@e
[6.145828] zenbook kernel: cs35l41-hda spi1-CSC3551:00-cs35l41-hda.1: DSP1: 1: ID f20b v0.1.0 XM@17c YM@0
[6.145834] zenbook kernel: cs35l41-hda spi1-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
[6.161484] zenbook kernel: snd_hda_codec_realtek ehdaudio0D0: bound spi1-CSC3551:00-cs35l41-hda.1 (ops cs35l41_hda_comp_ops [snd_hda_scodec_cs35l41])

The "Falling back to default firmware" disappears if spk-id-gpios are provided (the block is commented in the patch). As a result, a different firmware is loaded, resulting in very low volume and strong distortion. If the new patch is used, that uses external boost, the sound is correct, and the log is

[0.004000] zenbook kernel: ACPI: Table Upgrade: install [SSDT-CUSTOM- CSC3551]
[0.004000] zenbook kernel: ACPI: SSDT 0x00000000368FD000 0001A0 (v01 CUSTOM CSC3551  00000001 INTL 20200925)
[5.607253] zenbook kernel: Serial bus multi instantiate pseudo device driver CSC3551:00: Instantiated 2 SPI devices.
[5.906936] zenbook kernel: cs35l41-hda spi1-CSC3551:00-cs35l41-hda.0: Cirrus Logic CS35L41 (35a40), Revision: B2
[5.907354] zenbook kernel: cs35l41-hda spi1-CSC3551:00-cs35l41-hda.1: Reset line busy, assuming shared reset
[5.938136] zenbook kernel: cs35l41-hda spi1-CSC3551:00-cs35l41-hda.1: Cirrus Logic CS35L41 (35a40), Revision: B2
[6.239406] zenbook kernel: cs35l41-hda spi1-CSC3551:00-cs35l41-hda.0: DSP1: Firmware version: 3
[6.239415] zenbook kernel: cs35l41-hda spi1-CSC3551:00-cs35l41-hda.0: DSP1: cirrus/cs35l41-dsp1-spk-prot-10431e02.wmfw: Fri 27 Aug 2021 14:58:19 W. Europe Daylight Time
[6.313109] zenbook kernel: cs35l41-hda spi1-CSC3551:00-cs35l41-hda.0: DSP1: Firmware: 400a4 vendor: 0x2 v0.43.1, 2 algorithms
[6.313524] zenbook kernel: cs35l41-hda spi1-CSC3551:00-cs35l41-hda.0: DSP1: 0: ID cd v29.63.1 XM@94 YM@e
[6.313530] zenbook kernel: cs35l41-hda spi1-CSC3551:00-cs35l41-hda.0: DSP1: 1: ID f20b v0.1.0 XM@176 YM@0
[6.313535] zenbook kernel: cs35l41-hda spi1-CSC3551:00-cs35l41-hda.0: DSP1: spk-prot: C:\Users\tyang\Desktop\Product Setting\SmartAMP\ASUS\ASUS_Zenbook\UX3402\Tuning Release\220304\ASUS_UX3402_L_tuning_IDYC_ReDc_PICL_RTL_0304.bin
[6.337211] zenbook kernel: snd_hda_codec_realtek ehdaudio0D0: bound spi1-CSC3551:00-cs35l41-hda.0 (ops cs35l41_hda_comp_ops [snd_hda_scodec_cs35l41])
[6.337534] zenbook kernel: cs35l41-hda spi1-CSC3551:00-cs35l41-hda.1: DSP1: Firmware version: 3
[6.337540] zenbook kernel: cs35l41-hda spi1-CSC3551:00-cs35l41-hda.1: DSP1: cirrus/cs35l41-dsp1-spk-prot-10431e02.wmfw: Fri 27 Aug 2021 14:58:19 W. Europe Daylight Time
[6.399070] zenbook kernel: cs35l41-hda spi1-CSC3551:00-cs35l41-hda.1: DSP1: Firmware: 400a4 vendor: 0x2 v0.43.1, 2 algorithms
[6.399612] zenbook kernel: cs35l41-hda spi1-CSC3551:00-cs35l41-hda.1: DSP1: 0: ID cd v29.63.1 XM@94 YM@e
[6.399623] zenbook kernel: cs35l41-hda spi1-CSC3551:00-cs35l41-hda.1: DSP1: 1: ID f20b v0.1.0 XM@176 YM@0
[6.399629] zenbook kernel: cs35l41-hda spi1-CSC3551:00-cs35l41-hda.1: DSP1: spk-prot: C:\Users\tyang\Desktop\Product Setting\SmartAMP\ASUS\ASUS_Zenbook\UX3402\Tuning Release\220304\ASUS_UX3402_R_tuning_IDYC_ReDc_PICL_RTL_0304.bin
[6.427637] zenbook kernel: snd_hda_codec_realtek ehdaudio0D0: bound spi1-CSC3551:00-cs35l41-hda.1 (ops cs35l41_hda_comp_ops [snd_hda_scodec_cs35l41])
--- dsdt.dsl.old 2023-03-26 01:06:48.845795666 +0100
+++ dsdt.dsl 2023-03-26 12:00:45.643851841 +0200
@@ -18,7 +18,7 @@
* Compiler ID "INTL"
* Compiler Version 0x20200717 (538969879)
*/
-DefinitionBlock ("", "DSDT", 2, "_ASUS_", "Notebook", 0x01072009)
+DefinitionBlock ("", "DSDT", 2, "_ASUS_", "Notebook", 0x0107200A)
{
/*
* iASL Warning: There were 233 external control methods found during
@@ -90642,7 +90642,48 @@
Method (_DIS, 0, NotSerialized) // _DIS: Disable Device
{
}
+
+ Name (_DSD, Package () // _DSD: Device-Specific Data
+ {
+ ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
+ Package ()
+ {
+ Package () { "cirrus,dev-index", Package () { Zero, One }},
+ Package () { "reset-gpios", Package () {
+ SPK1, One, Zero, Zero,
+ SPK1, One, Zero, Zero,
+ } },
+ // Package () { "spk-id-gpios", Package () {
+ // SPK1, 0x02, Zero, Zero,
+ // SPK1, 0x02, Zero, Zero,
+ // } },
+ Package () { "cirrus,speaker-position", Package () { Zero, One } },
+ Package () { "cirrus,gpio1-func", Package () { Zero, Zero } },
+ Package () { "cirrus,gpio2-func", Package () { 0x02, 0x02 } },
+ // boost-type: 0 internal, 1 external
+ Package () { "cirrus,boost-type", Package () { Zero, Zero } },
+ // boost-peak-milliamp: 1600 to 4500, increments of 50 mA
+ Package () { "cirrus,boost-peak-milliamp", Package () { 4500, 4500 } },
+ // boost-ind-nanohenry: 1000 | 1200 | 1500 | 2200 nH
+ Package () { "cirrus,boost-ind-nanohenry", Package () { 1000, 1000 } },
+ // boost-cap-microfarad: rounded to the nearest integer
+ Package () { "cirrus,boost-cap-microfarad", Package () { 24, 24 } },
+ },
+ })
}
+
+ Name (_DSD, Package ()
+ {
+ ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
+ Package ()
+ {
+ Package () { "cs-gpios", Package () {
+ Zero, // Native CS
+ SPK1, Zero, Zero, Zero // GPIO CS
+ } }
+ }
+ })
+
}
Scope (_SB.PC00.LPCB)
--- dsdt.dsl.old 2023-03-26 01:06:48.845795666 +0100
+++ dsdt.dsl 2023-03-26 12:00:45.643851841 +0200
@@ -18,7 +18,7 @@
* Compiler ID "INTL"
* Compiler Version 0x20200717 (538969879)
*/
-DefinitionBlock ("", "DSDT", 2, "_ASUS_", "Notebook", 0x01072009)
+DefinitionBlock ("", "DSDT", 2, "_ASUS_", "Notebook", 0x0107200A)
{
/*
* iASL Warning: There were 233 external control methods found during
@@ -90642,7 +90642,43 @@
Method (_DIS, 0, NotSerialized) // _DIS: Disable Device
{
}
+
+ Name (_DSD, Package () // _DSD: Device-Specific Data
+ {
+ ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
+ Package ()
+ {
+ Package () { "cirrus,dev-index", Package () { Zero, One }},
+ Package () { "reset-gpios", Package () {
+ SPK1, One, Zero, Zero,
+ SPK1, One, Zero, Zero,
+ } },
+ Package () { "spk-id-gpios", Package () {
+ SPK1, 0x02, Zero, Zero,
+ SPK1, 0x02, Zero, Zero,
+ } },
+ Package () { "cirrus,speaker-position", Package () { Zero, One } },
+ // gpioX-func: 0 not used, 1 VPSK_SWITCH, 2: INTERRUPT, 3: SYNC
+ Package () { "cirrus,gpio1-func", Package () { One, One } },
+ Package () { "cirrus,gpio2-func", Package () { 0x02, 0x02 } },
+ // boost-type: 0 internal, 1 external
+ Package () { "cirrus,boost-type", Package () { One, One } },
+ },
+ })
}
+
+ Name (_DSD, Package ()
+ {
+ ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
+ Package ()
+ {
+ Package () { "cs-gpios", Package () {
+ Zero, // Native CS
+ SPK1, Zero, Zero, Zero // GPIO CS
+ } }
+ }
+ })
+
}
Scope (_SB.PC00.LPCB)
DefinitionBlock ("", "SSDT", 1, "CUSTOM", "CSC3551", 0x00000001)
{
External (_SB_.PC00.SPI0, DeviceObj)
External (_SB_.PC00.SPI0.SPK1, DeviceObj)
Scope (_SB.PC00.SPI0.SPK1)
{
Name (_DSD, Package ()
{
ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
Package ()
{
Package () { "cirrus,dev-index", Package () { Zero, One }},
Package () { "reset-gpios", Package () {
SPK1, One, Zero, Zero,
SPK1, One, Zero, Zero
} },
Package () { "spk-id-gpios", Package () {
SPK1, 0x02, Zero, Zero,
SPK1, 0x02, Zero, Zero
} },
Package () { "cirrus,speaker-position", Package () { Zero, One } },
// gpioX-func: 0 not used, 1 VPSK_SWITCH, 2: INTERRUPT, 3: SYNC
Package () { "cirrus,gpio1-func", Package () { One, One } },
Package () { "cirrus,gpio2-func", Package () { 0x02, 0x02 } },
// boost-type: 0 internal, 1 external
Package () { "cirrus,boost-type", Package () { One, One } }
}
})
}
Scope (_SB.PC00.SPI0)
{
Name (_DSD, Package ()
{
ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
Package ()
{
Package () { "cs-gpios", Package () {
Zero, // Native CS
SPK1, Zero, Zero, Zero // GPIO CS
} }
}
})
}
}
@cw-87-tw
Copy link

cw-87-tw commented Jul 5, 2023

@SergioASantosF What guide did you follow, I tried https://github.com/thor2002ro/asus_zenbook_ux3402za/blob/main/Sound/README.md but it doesn't work. I'm also using UX3402ZA. and I followed all the guide
When I tried to update grub, here's my output

Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Searching for custom ACPI tables in /boot
Found custom ACPI table: /boot/ssdt-csc3551.aml
Found linux image: /boot/vmlinuz-5.19.0-46-generic
Found initrd image: /boot/initrd.img-5.19.0-46-generic
Found linux image: /boot/vmlinuz-5.19.0-32-generic
Found initrd image: /boot/initrd.img-5.19.0-32-generic
Memtest86+ needs a 16-bit boot, that is not available on EFI, exiting
Warning: os-prober will be executed to detect other bootable partitions.
Its output will be used to detect bootable binaries on them and create new boot entries.
Found Windows Boot Manager on /dev/nvme0n1p1@/EFI/Microsoft/Boot/bootmgfw.efi
Adding boot menu entry for UEFI Firmware Settings ...
done

Is that normal?

@speedy01
Copy link

speedy01 commented Jul 5, 2023

@cw-87-tw I'm having the same issue. Please post back if you find a solutions.

@SergioASantosF
Copy link

@cw-87-tw, I followed exactly the tutorial that you also tried, using the files provided by @thor2002ro , without making any modifications, and it worked here on Debian 12, Ubuntu, and Fedora 38 (which is currently installed).

I don't know if it's because I don't have dual boot, so I didn't encounter any issues with the grub update.

Since it was my first attempt and it didn't give any errors, I won't be able to help you.

@fermino
Copy link

fermino commented Jul 5, 2023

@cw-87-tw @speedy01 that output looks completely normal (it's detecting the ACPI table and it's detecting a windows installation). What issue are you having?

@speedy01
Copy link

speedy01 commented Jul 5, 2023

@fermino the issue I'm having is "still no sound" from what I can tell, grub is not loading the custom tables. even though the entry is in the grub.cfg
sudo dmesg | grep SSDT
[ 0.015492] ACPI: SSDT 0x00000000407E3000 00740E (v02 DptfTb DptfTabl 00001000 INTL 20200717)
[ 0.015499] ACPI: SSDT 0x000000004076F000 00038C (v02 PmaxDv Pmax_Dev 00000001 INTL 20200717)
[ 0.015501] ACPI: SSDT 0x0000000040769000 005D0B (v02 CpuRef CpuSsdt 00003000 INTL 20200717)
[ 0.015503] ACPI: SSDT 0x0000000040766000 002AA1 (v02 SaSsdt SaSsdt 00003000 INTL 20200717)
[ 0.015505] ACPI: SSDT 0x0000000040762000 0033D3 (v02 INTEL IgfxSsdt 00003000 INTL 20200717)
[ 0.015508] ACPI: SSDT 0x0000000040754000 00D337 (v02 INTEL TcssSsdt 00001000 INTL 20200717)
[ 0.015516] ACPI: SSDT 0x000000004074B000 005D47 (v02 ASUS AdlP_Rvp 00001000 INTL 20200717)
[ 0.015518] ACPI: SSDT 0x0000000040749000 001F1A (v02 ASUS Ther_Rvp 00001000 INTL 20200717)
[ 0.015523] ACPI: SSDT 0x0000000040744000 002A83 (v02 ASUS PtidDevc 00001000 INTL 20200717)
[ 0.015525] ACPI: SSDT 0x0000000040741000 002357 (v02 ASUS TbtTypeC 00000000 INTL 20200717)
[ 0.015532] ACPI: SSDT 0x000000004073D000 001AC9 (v02 ASUS UsbCTabl 00001000 INTL 20200717)
[ 0.015538] ACPI: SSDT 0x0000000040739000 000B35 (v02 INTEL xh_adlLP 00000000 INTL 20200717)
[ 0.015541] ACPI: SSDT 0x0000000040735000 003AEA (v02 SocGpe SocGpe 00003000 INTL 20200717)
[ 0.015543] ACPI: SSDT 0x0000000040732000 002B2A (v02 SocCmn SocCmn 00003000 INTL 20200717)
[ 0.015545] ACPI: SSDT 0x0000000040731000 000144 (v02 Intel ADebTabl 00001000 INTL 20200717)
[ 0.015567] ACPI: Reserving SSDT table memory at [mem 0x407e3000-0x407ea40d]
[ 0.015568] ACPI: Reserving SSDT table memory at [mem 0x4076f000-0x4076f38b]
[ 0.015569] ACPI: Reserving SSDT table memory at [mem 0x40769000-0x4076ed0a]
[ 0.015569] ACPI: Reserving SSDT table memory at [mem 0x40766000-0x40768aa0]
[ 0.015570] ACPI: Reserving SSDT table memory at [mem 0x40762000-0x407653d2]
[ 0.015571] ACPI: Reserving SSDT table memory at [mem 0x40754000-0x40761336]
[ 0.015573] ACPI: Reserving SSDT table memory at [mem 0x4074b000-0x40750d46]
[ 0.015573] ACPI: Reserving SSDT table memory at [mem 0x40749000-0x4074af19]
[ 0.015574] ACPI: Reserving SSDT table memory at [mem 0x40744000-0x40746a82]
[ 0.015575] ACPI: Reserving SSDT table memory at [mem 0x40741000-0x40743356]
[ 0.015577] ACPI: Reserving SSDT table memory at [mem 0x4073d000-0x4073eac8]
[ 0.015578] ACPI: Reserving SSDT table memory at [mem 0x40739000-0x40739b34]
[ 0.015579] ACPI: Reserving SSDT table memory at [mem 0x40735000-0x40738ae9]
[ 0.015579] ACPI: Reserving SSDT table memory at [mem 0x40732000-0x40734b29]
[ 0.015580] ACPI: Reserving SSDT table memory at [mem 0x40731000-0x40731143]
[ 0.230477] ACPI: SSDT 0xFFFF972441FDE400 0001AB (v02 PmRef Cpu0Psd 00003000 INTL 20200717)
[ 0.237350] ACPI: SSDT 0xFFFF97244120A400 000394 (v02 PmRef Cpu0Cst 00003001 INTL 20200717)
[ 0.238595] ACPI: SSDT 0xFFFF97244245C000 000560 (v02 PmRef Cpu0Ist 00003000 INTL 20200717)
[ 0.239782] ACPI: SSDT 0xFFFF97244245C800 0004BA (v02 PmRef Cpu0Hwp 00003000 INTL 20200717)
[ 0.241187] ACPI: SSDT 0xFFFF972441200000 001BAF (v02 PmRef ApIst 00003000 INTL 20200717)
[ 0.242975] ACPI: SSDT 0xFFFF972441204000 001038 (v02 PmRef ApHwp 00003000 INTL 20200717)
[ 0.244470] ACPI: SSDT 0xFFFF972441206000 001349 (v02 PmRef ApPsd 00003000 INTL 20200717)
[ 0.246178] ACPI: SSDT 0xFFFF972441214000 000FBB (v02 PmRef ApCst 00003000 INTL 20200717)

@fermino
Copy link

fermino commented Jul 5, 2023

@speedy01 maybe the grub cfg is being used from another location? Try pressing e in the GRUB screen and see if the ssdt line is there (press ctrl+x in that screen to boot).

@speedy01
Copy link

speedy01 commented Jul 5, 2023

@fermino thanks for the hint. when I manually entered the command, I got an error. Turns out the secure boot is preventing grub from running acpi. A workaround for me was to disable secure boot.

this also pops up...but prob nothing.
sudo journalctl -b | grep "ACPI Error"
Jul 05 13:35:59 lx-asus kernel: ACPI Error: AE_NOT_FOUND, During name lookup/catalog (20221020/psobject-220)
Jul 05 13:35:59 lx-asus kernel: ACPI Error: AE_NOT_FOUND, During name lookup/catalog (20221020/psobject-220)
Jul 05 13:35:59 lx-asus kernel: ACPI Error: AE_NOT_FOUND, During name lookup/catalog (20221020/psobject-220)
Jul 05 13:35:59 lx-asus kernel: ACPI Error: AE_NOT_FOUND, During name lookup/catalog (20221020/psobject-220)
Jul 05 13:36:01 lx-asus kernel: ACPI Error: Aborting method _SB.PC00.LPCB.H_EC.TFN1._FST due to previous error (AE_NOT_FOUND) (20221020/psparse-529

@fermino
Copy link

fermino commented Jul 5, 2023

@speedy01 awesome! Did it work?

@speedy01
Copy link

speedy01 commented Jul 5, 2023

@fermino yes..disabling secure boot allowed grub to load custom table. I have sound! :)

@cw-87-tw
Copy link

cw-87-tw commented Jul 5, 2023

@fermino yes..disabling secure boot allowed grub to load custom table. I have sound! :)

Thank you so much, it finally worked after I turned off secure boot

@amarkezic
Copy link

amarkezic commented Jul 19, 2023

Just got a new laptop, the asus ux5304v and to no surprise (after reading this thread) the audio doesn't work (just the speakers don't). Did anyone here try to apply the patch to this specific device ?

Another question i have is will this get overwritten if there is a BIOS update?
Does asus even push firmware updates for linux devices (like DELL does) or do i need to dualboot windows for the firmware updates (or if i don't want to dual boot, apply them manually myself)?

P.S. I am quite a linux newbie especially when it comes to this level of customization (BIOS level) and am not really keen into giving so much time to just have a working machine

Thank in advance

@thor2002ro
Copy link

Asus just doesn't care at all....
Might need some adjustment on bios update... But doubt asus will release another bios.... They usually release 2-3 bios-es at launch the forget about it

@amarkezic
Copy link

amarkezic commented Jul 19, 2023

Asus just doesn't care at all.... Might need some adjustment on bios update... But doubt asus will release another bios.... They usually release 2-3 bios-es at launch the forget about it

Yea its a real shame, in the end i opted for windows and WSL for this device (becauseit's a work pc). With the XPS 15 i had the best experience on linux it worked event better than on windows.

Thank you anyway

@phptek
Copy link

phptek commented Jul 21, 2023

I've done about as much as I can, but still can't get this to work :-(

  • Problem: Headphone Sound: OK. Speaker Sound: FAIL
  • Model: Asus Zenbook S 13 UX5304VA_UX5304VA
  • O/S: Ubuntu 22.04.2
  • Dual Boot: No (But the machine came with Win11 which I blew away with Ubuntu the first chance I got)
  • Secure Boot: Disabled
  • Fastboot: Disabled
  • BIOS Version: 304 (Machine came with 300, I upgraded after the fact)
  • Kernel version: 5.19.0-46-generic
  • I tried @thor2002ro 's patch, rebooted - still no sound. Noticed what appears to be a typo in DefinitionBlock ("CS3551" vs "CSC3551"), recompiled, reboot, still nothing.
  • Output of journalctl -b -g CSC3551:
Jul 21 13:29:14 marmadukeIII kernel: ACPI: SSDT 0x000000004841AD76 0001A7 (v01 CUSTOM CSC3551  0000300A INTL 20200925)
Jul 21 13:29:15 marmadukeIII kernel: Serial bus multi instantiate pseudo device driver CSC3551:00: Instantiated 2 SPI devices.
Jul 21 13:29:15 marmadukeIII kernel: cs35l41-hda spi1-CSC3551:00-cs35l41-hda.0: error -EINVAL: Platform not supported -22
Jul 21 13:29:15 marmadukeIII kernel: cs35l41-hda: probe of spi1-CSC3551:00-cs35l41-hda.0 failed with error -22
Jul 21 13:29:15 marmadukeIII kernel: cs35l41-hda spi1-CSC3551:00-cs35l41-hda.1: error -EINVAL: Platform not supported -22
Jul 21 13:29:15 marmadukeIII kernel: cs35l41-hda: probe of spi1-CSC3551:00-cs35l41-hda.1 failed with error -22

Questions/Comments:

In the patch from @thor2002ro what does the hex number "0x0000300A" refer to? Is it a BIOS version string? I was naively thinking to tweak it to "0x0000304A" to suit my BIOs version, but haven't done it yet. This machine is brand new and am not quite ready to brick it yet!

Does anyone have any other ideas?

@phamdangtrung
Copy link

I've done about as much as I can, but still can't get this to work :-(

  • Problem: Headphone Sound: OK. Speaker Sound: FAIL
  • Model: Asus Zenbook S 13 UX5304VA_UX5304VA
  • O/S: Ubuntu 22.04.2
  • Dual Boot: No (But the machine came with Win11 which I blew away with Ubuntu the first chance I got)
  • Secure Boot: Disabled
  • Fastboot: Disabled
  • BIOS Version: 304 (Machine came with 300, I upgraded after the fact)
  • Kernel version: 5.19.0-46-generic
  • I tried @thor2002ro 's patch, rebooted - still no sound. Noticed what appears to be a typo in DefinitionBlock ("CS3551" vs "CSC3551"), recompiled, reboot, still nothing.
  • Output of journalctl -b -g CSC3551:
Jul 21 13:29:14 marmadukeIII kernel: ACPI: SSDT 0x000000004841AD76 0001A7 (v01 CUSTOM CSC3551  0000300A INTL 20200925)
Jul 21 13:29:15 marmadukeIII kernel: Serial bus multi instantiate pseudo device driver CSC3551:00: Instantiated 2 SPI devices.
Jul 21 13:29:15 marmadukeIII kernel: cs35l41-hda spi1-CSC3551:00-cs35l41-hda.0: error -EINVAL: Platform not supported -22
Jul 21 13:29:15 marmadukeIII kernel: cs35l41-hda: probe of spi1-CSC3551:00-cs35l41-hda.0 failed with error -22
Jul 21 13:29:15 marmadukeIII kernel: cs35l41-hda spi1-CSC3551:00-cs35l41-hda.1: error -EINVAL: Platform not supported -22
Jul 21 13:29:15 marmadukeIII kernel: cs35l41-hda: probe of spi1-CSC3551:00-cs35l41-hda.1 failed with error -22

Questions/Comments:

In the patch from @thor2002ro what does the hex number "0x0000300A" refer to? Is it a BIOS version string? I was naively thinking to tweak it to "0x0000304A" to suit my BIOs version, but haven't done it yet. This machine is brand new and am not quite ready to brick it yet!

Does anyone have any other ideas?

Compile a newer version of linux kernel (> 6.1). I'm using linux mint 21.2 with kernel 6.3.9.
5.19 is way too old and doesn't include cs35l41 firmware. After booting up linux with the new kernel, follow this https://github.com/thor2002ro/asus_zenbook_ux3402za.
My ux3402za's speaker is working properly for me.
Note that the compilation process may take 1-2 hours

@phptek
Copy link

phptek commented Jul 21, 2023

@phamdangtrung Thanks. I was afraid I'd need to do this. Long time Linux user, first-time compiling a new kernel. What are the dangers of doing this, if any?

Thank you :-)

@phamdangtrung
Copy link

@phamdangtrung Thanks. I was afraid I'd need to do this. Long time Linux user, first-time compiling a new kernel. What are the dangers of doing this, if any?

Thank you :-)

Nothing actually, but I do recommend backing up your important files first. I got some issue with initramfs after booting up with the new kernel so I used the old kernel and ran the following command
sudo make modules_install INSTALL_MOD_STRIP=1

@phptek
Copy link

phptek commented Jul 21, 2023

I got an initramfs issue too while it waited for my encrypted drive. Couldn't get passed that point. Had to revert to old kernel. sudo make modules_install produces a make error. No matter, I'll keep on with it and post back my findings.

@thierry-carron
Copy link

thank you very much, works fine for me :)
I will report solution onto asus forum.

@badger-ua
Copy link

badger-ua commented Jul 24, 2023

@lamperez @Moooebie
Hello, tried the following patch:

DefinitionBlock ("", "SSDT", 1, "CUSTOM", "CSC3551", 0x00001000)
{

    External (_SB_.PC00.SPI0, DeviceObj)
    External (_SB_.PC00.SPI0.SPK1, DeviceObj)

    Scope (_SB.PC00.SPI0.SPK1)
    {
        Method (_DSD, 0, NotSerialized)  // _DSD: Device Specific Data
        {
            Return (Package ()
                {
                    ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
                    Package ()
                    {
                        Package () { "cirrus,dev-index", Package () { Zero, One }},
                        Package () { "reset-gpios", Package () {
                           SPK1, One, Zero, Zero,
                           SPK1, One, Zero, Zero
                        } },
                        Package () { "spk-id-gpios", Package () {
                             SPK1, 0x02, Zero, Zero,
                             SPK1, 0x02, Zero, Zero,
                        } },
                        Package () { "cirrus,speaker-position", Package () { Zero, One } },
                        Package () { "cirrus,gpio1-func", Package () { One, One } },
                        Package () { "cirrus,gpio2-func", Package () { 0x02, 0x02 } },
                        // boost-type: 0 internal, 1 external
                        Package () { "cirrus,boost-type", Package () { One, One } },
                        // boost-peak-milliamp: 1600 to 4500, increments of 50 mA
                        //Package () { "cirrus,boost-peak-milliamp",  Package () { 3000, 3000 } },
                        // boost-ind-nanohenry: 1000 | 1200 | 1500 | 2200 nH
                        //Package () { "cirrus,boost-ind-nanohenry",  Package () { 1000, 1000 } },
                        // boost-cap-microfarad: rounded to the nearest integer
                        //Package () { "cirrus,boost-cap-microfarad", Package () { 15, 15 } },
                    }
                }) /* \_SB_.PC00.SPI0.SPK1._DSD */
        }
    }

    Scope (_SB.PC00.SPI0)
    {
        Method (_DSD, 0, NotSerialized)  // _DSD: Device Specific Data
        {
            Return (Package ()
                {
                    ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
                    Package ()
                    {
                        Package () { "cs-gpios", Package () { 
                            Zero,                    // Native CS
                            SPK1, Zero, Zero, Zero   // GPIO CS
                        } }
                    }
                }) /* \_SB_.PC00.SPI0.SPK1._DSD */
        }
    }
}

sudo dmesg | grep SSDT output is seems to be correct I have the line with patch:
[ 0.015531] ACPI: SSDT 0x0000000047E01D76 0001A7 (v01 CUSTOM CSC3551 00001000 INTL 20200925)
but the outpu of: sudo journalctl -b -g CSC3551 still is:

Jul 24 12:43:53 zenbook-pop-os kernel: ACPI: SSDT 0x0000000047E01D76 0001A7 (v01 CUSTOM CSC3551  00001000 INTL 20200925)
Jul 24 12:43:53 zenbook-pop-os kernel: Serial bus multi instantiate pseudo device driver CSC3551:00: Instantiated 2 SPI devices.
Jul 24 12:43:54 zenbook-pop-os kernel: cs35l41-hda spi1-CSC3551:00-cs35l41-hda.0: Error: ACPI _DSD Properties are missing for HID CSC3551.
Jul 24 12:43:54 zenbook-pop-os kernel: cs35l41-hda spi1-CSC3551:00-cs35l41-hda.0: error -EINVAL: Platform not supported
Jul 24 12:43:54 zenbook-pop-os kernel: cs35l41-hda: probe of spi1-CSC3551:00-cs35l41-hda.0 failed with error -22
Jul 24 12:43:54 zenbook-pop-os kernel: cs35l41-hda spi1-CSC3551:00-cs35l41-hda.1: Error: ACPI _DSD Properties are missing for HID CSC3551.
Jul 24 12:43:54 zenbook-pop-os kernel: cs35l41-hda spi1-CSC3551:00-cs35l41-hda.1: error -EINVAL: Platform not supported
Jul 24 12:43:54 zenbook-pop-os kernel: cs35l41-hda: probe of spi1-CSC3551:00-cs35l41-hda.1 failed with error -22

I also tried to extract dsdt.dat by your guide: https://gist.github.com/lamperez/d5b385bc0c0c04928211e297a69f32d7 and dsdt.dsl has nothing CSC3551 related in that file

Device: asus_zenbook_s13_ux5304va
My kernel is: 6.2.6-76060206-generic
Dual Boot: No
Secure Boot: Disabled
Fastboot: Disabled
BIOS Version: 304

I'm assuming I need to modify the patch itself somehow?

P.S: Begging for help 😸

@thor2002ro
Copy link

It won't work on a different models kernel it needs to be adapted and also you have to look it the kernel is patched for you model the quirk is applied based on sound card id

@badger-ua
Copy link

badger-ua commented Jul 24, 2023

It won't work on a different models kernel it needs to be adapted and also you have to look it the kernel is patched for you model the quirk is applied based on sound card id

got it, I'll try to build kernel from sources then with my model included as @Moooebie wrote in his guide, s13 and 14 zenbooks are pretty much the same I had a hope that it will work without kernel patches, I created a working dsl patch (by modifiing depackaged dsdt.dat) via: https://gist.github.com/lamperez/d5b385bc0c0c04928211e297a69f32d7

DefinitionBlock ("", "SSDT", 1, "CUSTOM", "CSC3551", 0x00000002)
{
    External (_SB_.GPI0, DeviceObj)
    External (_SB_.PC00.SPI1, DeviceObj)

    Scope (\_SB.PC00.SPI1)
    {
        Device (SPK1)
        {
            Name (_HID, "CSC3551")  // _HID: Hardware ID
            Name (_SUB, "104316D3")  // _SUB: Subsystem ID
            Name (_UID, One)  // _UID: Unique ID
            Method (_CRS, 0, NotSerialized)  // _CRS: Current Resource Settings
            {
                Name (SBUF, ResourceTemplate ()
                {
                    SpiSerialBusV2 (0x0000, PolarityLow, FourWireMode, 0x08,
                        ControllerInitiated, 0x003D0900, ClockPolarityLow,
                        ClockPhaseFirst, "\\_SB.PC00.SPI1",
                        0x00, ResourceConsumer, , Exclusive,
                        )
                    SpiSerialBusV2 (0x0001, PolarityLow, FourWireMode, 0x08,
                        ControllerInitiated, 0x003D0900, ClockPolarityLow,
                        ClockPhaseFirst, "\\_SB.PC00.SPI1",
                        0x00, ResourceConsumer, , Exclusive,
                        )
                    GpioIo (Exclusive, PullUp, 0x0000, 0x0000, IoRestrictionOutputOnly,
                        "\\_SB.GPI0", 0x00, ResourceConsumer, ,
                        )
                        {   // Pin list
                            0x0017
                        }
                    GpioIo (Exclusive, PullDown, 0x0000, 0x0000, IoRestrictionOutputOnly,
                        "\\_SB.GPI0", 0x00, ResourceConsumer, ,
                        )
                        {   // Pin list
                            0x0131
                        }
                    GpioIo (Exclusive, PullUp, 0x0000, 0x0000, IoRestrictionInputOnly,
                        "\\_SB.GPI0", 0x00, ResourceConsumer, ,
                        )
                        {   // Pin list
                            0x012E
                        }
                    GpioIo (Shared, PullUp, 0x0064, 0x0000, IoRestrictionInputOnly,
                        "\\_SB.GPI0", 0x00, ResourceConsumer, ,
                        )
                        {   // Pin list
                            0x012F
                        }
                    GpioInt (Edge, ActiveBoth, Shared, PullUp, 0x0064,
                        "\\_SB.GPI0", 0x00, ResourceConsumer, ,
                        )
                        {   // Pin list
                            0x012F
                        }
                })
                Return (SBUF) /* \_SB_.PC00.SPI1.SPK1._CRS.SBUF */
            }

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

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

            Method (_DSD, 0, NotSerialized)  // _DSD: Device Specific Data
            {
                Return (Package ()
                    {
                        ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
                        Package ()
                        {
                            Package () { "cirrus,dev-index", Package () { Zero, One }},
                            Package () { "reset-gpios", Package () {
                            SPK1, One, Zero, Zero,
                            SPK1, One, Zero, Zero
                            } },
                            Package () { "spk-id-gpios", Package () {
                                SPK1, 0x02, Zero, Zero,
                                SPK1, 0x02, Zero, Zero,
                            } },
                            Package () { "cirrus,speaker-position", Package () { Zero, One } },
                            Package () { "cirrus,gpio1-func", Package () { One, One } },
                            Package () { "cirrus,gpio2-func", Package () { 0x02, 0x02 } },
                            // boost-type: 0 internal, 1 external
                            Package () { "cirrus,boost-type", Package () { One, One } },
                            // boost-peak-milliamp: 1600 to 4500, increments of 50 mA
                            //Package () { "cirrus,boost-peak-milliamp",  Package () { 3000, 3000 } },
                            // boost-ind-nanohenry: 1000 | 1200 | 1500 | 2200 nH
                            //Package () { "cirrus,boost-ind-nanohenry",  Package () { 1000, 1000 } },
                            // boost-cap-microfarad: rounded to the nearest integer
                            //Package () { "cirrus,boost-cap-microfarad", Package () { 15, 15 } },
                        }
                    }) /* \_SB_.PC00.SPI0.SPK1._DSD */
            }
        }

        Method (_DSD, 0, NotSerialized)  // _DSD: Device Specific Data
        {
            Return (Package ()
                {
                    ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
                    Package ()
                    {
                        Package () { "cs-gpios", Package () { 
                            Zero,                    // Native CS
                            SPK1, Zero, Zero, Zero   // GPIO CS
                        } }
                    }
                }) /* \_SB_.PC00.SPI0.SPK1._DSD */
        }
    }
}

at least the sudo journalctl -b -g CSC3551 outputs no errors but still no sound, going after kernel then, if that will be successful I'll upload a source code for my model to git, but the question that comes in mind, that to make users life easier just by appling patch without kernel modification as you mentioned my device SND_PCI_QUIRK(0x1043, 0x16d3, "ASUS UX5304VA", ALC245_FIXUP_CS35L41_SPI_2), should be included in kernel, I've never done the kernel modification before, if I'm modifying ubuntus kernel I have to find the kernel sources on ubuntu git and submit a pr?

@badger-ua
Copy link

I have a good news and bad news, good one is that patching kernel done the job, I've got the sound thatnks a lot for guides @lamperez @Moooebie @thor2002ro but with custom kernel wifi module is missing now 😸

@badger-ua
Copy link

wifi is working, just installation of kernel went wrong.
2 new issues I'm trying to solve will keep everyone here updated:

  1. When laptop goes to sleep, speakers doesn't work after wake up
  2. Since speakers are harman kardon branded sound on linux is complete crap comparing to windows, trying to bring some quality back with Easy Effects package but so far no luck.

@fermino
Copy link

fermino commented Jul 24, 2023

@badger-lviv-ua the first problem could be related to your sound server, does the 3.5mm output work after suspending and waking it up?

@badger-ua
Copy link

@badger-lviv-ua the first problem could be related to your sound server, does the 3.5mm output work after suspending and waking it up?

@fermino actually yes 3.5mm works, actually very strange behavior scenarious:

  • if laptop suspend with no sound playing, after laptop awake - speakers sound works
  • if laptop suspend with music playing, after laptop awake - speakers sound doesn't work, but if I inject 3.5mm headphones and unplug them sound is back from speakers

@badger-ua
Copy link

badger-ua commented Jul 24, 2023

Uploaded a patch for asus_zenbook_ux5304va

Special thanks

Author Description
lamperez For ACPI DSDT/SSDT patching guides and tools
Moooebie For ACPI DSDT/SSDT patching guide
thor2002ro For GRUB patch for similar laptop

Warning: patch doesnt work without kernel modification (described in repo readme)

@thor2002ro
Copy link

thor2002ro commented Jul 24, 2023

Try to disable the sound card realtek power saving on my model it tries to save power very aggressively and after a while all audio sounds werid like all highes and not mids and lows this seams to fix it not sure if it's placebo yet.... It's probably related to the fact that the speakers are separate from the card and are on the spi bus

@badger-ua
Copy link

Thanks for the hint @thor2002ro will try that 🤝

@psxpaul
Copy link

psxpaul commented Jul 28, 2023

I have a Dell XPS 15 9530 that seems to have the same CS35L41 amplifier and resulting ACPI _DSD Properties are missing for HID CSC3551 dmesg error. I've tried everything suggested here and this wiki, but it looks like the kernel module is attempting to load more firmware files than the Dell drivers provide. I figured out that if I omit spk-id-gpios from the ssdt patch, it attempts to load the correct firmware files, but it takes several minutes and the sounds doesn't seem improved.

Can someone tell me what some of these properties in the ssdt patch do, or how I can determine the correct values for my hardware?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment