Bug 218119

Summary: ALC294: Asus Zenbook UM5302LA (AMD R7840u): CS3551 AMP is not supported in patch_realtek
Product: Drivers Reporter: VitaliiT (vitaly.torshyn)
Component: Sound(ALSA)Assignee: Jaroslav Kysela (perex)
Status: NEW ---    
Severity: normal CC: vitaly.torshyn
Priority: P3 Keywords: trivial
Hardware: AMD   
OS: Linux   
Kernel Version: 6.6.0 Subsystem:
Regression: No Bisected commit-id:
Attachments: alsa-info output
UM5302LA: cs35L41 quirks

Description VitaliiT 2023-11-08 22:47:04 UTC
Created attachment 305378 [details]
alsa-info output

Actually the title is self descriptive. 
System: UM5302LA with BIOS 301.
ACPI DSDT table contains correct _DSD configuration for SPKR (\_SB_.I2CA.SPKR._DSD). 
To prove it the dump of ACPI tables in windows with realtek drivers installed was compared against ACPI dump in Linux. To my surprise ASUS seems listen to customers and relatively new laptop with young BIOS have cs35L41 configuration out-of-the-box.

UM5302LA comes with ALC294 with subsystem-id 1043:1a83, which is not covered in patch_realtek.c.

Creating a bug to track changes required to get speakers working.
Comment 1 VitaliiT 2023-11-08 23:03:33 UTC
Actually, patching DSDT table is not required to fix that problem (I'm not expert, just can see _DSD section in DSDT disassembly output SPKR with pins configs).

But open questions are: 
1) Obtain correct firmware, which can not be found on cirrus git (at least now)
2) Apply the patch to enable quirks for subsystem-id 10431A83

On Windows I can't find firmware blobs for 10431A83: 

```
find ./ | grep -i 10431A83
./System32/DriverStore/FileRepository/dax3_ext_rtk.inf_amd64_1ef1d30092819137/DEV_0294_SUBSYS_10431A83_PCI_SUBSYS_1A831043.xml
```
So only DAX (Dolby extensions) are present. Suspected that in Windows realtek does use FW for another i2c based sub-id. 

After experimenting, I found that firmware for 104317f3 works with 10431A83 but it is required to create symlinks: 
```
$ cd /lib/firmware/cirrus/ && \
for fw in $(find ./ -name '*104317f3*'); do newfw=$(echo $fw | sed 's/104317f3/10431a83/g'); echo echo "$fw -> $newfw"; cp $f $newfw; done
```

In addition, the patch should applied to patch_realtek.c (see attachment).
Comment 2 VitaliiT 2023-11-08 23:44:36 UTC
Created attachment 305379 [details]
UM5302LA: cs35L41 quirks

Proposed patch fixes initialization of CSC3551 on the UM5302LA laptop.
Patching DSDT table is not required since ASUS did added _DSD entry.
Nothing new introduced but reused work started by Stefan B.
With the patch applied to 6.6.0 and obviously symlinks to 104317F3 FW, speakers works and to my surprise they sound is quite good and loud without distortion.

Probably confirmation from cirrus team is needed on firmware.
Comment 3 VitaliiT 2023-11-09 00:30:38 UTC
dmesg output:

[ 2088.782511] snd_hda_intel 0000:c3:00.1: Handle vga_switcheroo audio client
[ 2088.785539] snd_hda_intel 0000:c3:00.1: bound 0000:c3:00.0 (ops __SCT__tp_func_dcn_optc_lock_unlock_state [amdgpu])
[ 2088.786085] input: HD-Audio Generic HDMI/DP,pcm=3 as /devices/pci0000:00/0000:00:08.1/0000:c3:00.1/sound/card0/input16
[ 2088.786164] input: HD-Audio Generic HDMI/DP,pcm=7 as /devices/pci0000:00/0000:00:08.1/0000:c3:00.1/sound/card0/input17
[ 2088.786387] input: HD-Audio Generic HDMI/DP,pcm=8 as /devices/pci0000:00/0000:00:08.1/0000:c3:00.1/sound/card0/input18
[ 2088.797952] snd_hda_codec_realtek hdaudioC1D0: autoconfig for ALC294: line_outs=1 (0x17/0x0/0x0/0x0/0x0) type:speaker
[ 2088.797972] snd_hda_codec_realtek hdaudioC1D0:    speaker_outs=0 (0x0/0x0/0x0/0x0/0x0)
[ 2088.797977] snd_hda_codec_realtek hdaudioC1D0:    hp_outs=1 (0x21/0x0/0x0/0x0/0x0)
[ 2088.797981] snd_hda_codec_realtek hdaudioC1D0:    mono: mono_out=0x0
[ 2088.797983] snd_hda_codec_realtek hdaudioC1D0:    inputs:
[ 2089.250105] input: HD-Audio Generic Headphone as /devices/pci0000:00/0000:00:08.1/0000:c3:00.6/sound/card1/input19
[ 2113.447185] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.0: Detecting cs35l41 with subsystem-id=10431A83, hid=CSC3551
[ 2113.447194] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.0: ... result -2
[ 2113.481471] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.0: Cirrus Logic CS35L41 (35a40), Revision: B2
[ 2113.481615] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.1: Detecting cs35l41 with subsystem-id=10431A83, hid=CSC3551
[ 2113.481619] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.1: ... result -2
[ 2113.481726] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.1: Reset line busy, assuming shared reset
[ 2113.515533] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.0: DSP1: Firmware version: 3
[ 2113.515539] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.0: DSP1: cirrus/cs35l41-dsp1-spk-prot-10431a83.wmfw: Fri 27 Aug 2021 14:58:19 W. Europe Daylight Time
[ 2113.979373] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.0: DSP1: Firmware: 400a4 vendor: 0x2 v0.43.1, 2 algorithms
[ 2113.980516] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.0: DSP1: cirrus/cs35l41-dsp1-spk-prot-10431a83-spkid0-l0.bin: v0.43.1
[ 2113.980531] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.0: DSP1: spk-prot: C:\Users\dchunyi\Documents\Asus_ROG\Project\NR2301\Tuning\20221125\104317F3_221125_V0_A0.bin
[ 2114.064594] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.0: CS35L41 Bound - SSID: 10431A83, BST: 0, VSPK: 0, CH: L, FW EN: 1, SPKID: 0
[ 2114.064614] snd_hda_codec_realtek hdaudioC1D0: bound i2c-CSC3551:00-cs35l41-hda.0 (ops cs35l41_add_dsd_properties [snd_hda_scodec_cs35l41])
[ 2114.065585] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.1: DSP1: Firmware version: 3
[ 2114.065594] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.1: DSP1: cirrus/cs35l41-dsp1-spk-prot-10431a83.wmfw: Fri 27 Aug 2021 14:58:19 W. Europe Daylight Time
[ 2114.530107] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.1: DSP1: Firmware: 400a4 vendor: 0x2 v0.43.1, 2 algorithms
[ 2114.531521] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.1: DSP1: cirrus/cs35l41-dsp1-spk-prot-10431a83-spkid0-r0.bin: v0.43.1
[ 2114.531544] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.1: DSP1: spk-prot: C:\Users\dchunyi\Documents\Asus_ROG\Project\NR2301\Tuning\20221125\104317F3_221125_V0_A1.bin
[ 2114.614936] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.1: CS35L41 Bound - SSID: 10431A83, BST: 0, VSPK: 0, CH: R, FW EN: 1, SPKID: 0
[ 2114.614952] snd_hda_codec_realtek hdaudioC1D0: bound i2c-CSC3551:00-cs35l41-hda.1 (ops cs35l41_add_dsd_properties [snd_hda_scodec_cs35l41])
[ 2114.614977] cs35l41-hda i2c-CSC3551:00-cs35l41-hda.1: Cirrus Logic CS35L41 (35a40), Revision: B2