linux icon indicating copy to clipboard operation
linux copied to clipboard

Improve quirks detection for es8336

Open mchehab opened this issue 6 months ago • 7 comments

Use _DSM table to detect GPIO level and AMIC. This change has @plbossart patches that apply, with some changes as discussed on #4112.

Tested on Huawei Matebook D15 ( BOHB-WAX9):

[    4.825981] es8316 i2c-ESSX8336:00: =========== EM83XX ACPI _DSM TABLE DUMP ===========
[    4.826009] es8316 i2c-ESSX8336:00: PLATFORM_MAINMIC_TYPE_ARG=0xbb
[    4.826023] es8316 i2c-ESSX8336:00: PLATFORM_HPMIC_TYPE_ARG=0xbb
[    4.826038] es8316 i2c-ESSX8336:00: PLATFORM_SPK_TYPE_ARG=0x2
[    4.826054] es8316 i2c-ESSX8336:00: PLATFORM_HPDET_INV_ARG=0x1
[    4.826267] es8316 i2c-ESSX8336:00: PLATFORM_MIC_DE_POP_ARG=0x0
[    4.826499] es8316 i2c-ESSX8336:00: PLATFORM_BUS_SLOT_ARG=0x0
[    4.826521] es8316 i2c-ESSX8336:00: HP_CODEC_LINEIN_PGA_GAIN_ARG=0x6
[    4.826547] es8316 i2c-ESSX8336:00: MAIN_CODEC_LINEIN_PGA_GAIN_ARG=0x8
[    4.826576] es8316 i2c-ESSX8336:00: HP_CODEC_D2SEPGA_GAIN_ARG=0x1
[    4.826606] es8316 i2c-ESSX8336:00: MAIN_CODEC_D2SEPGA_GAIN_ARG=0x1
[    4.826639] es8316 i2c-ESSX8336:00: HP_CODEC_ADC_VOLUME_ARG=0x0
[    4.826675] es8316 i2c-ESSX8336:00: MAIN_CODEC_ADC_VOLUME_ARG=0x0
[    4.826713] es8316 i2c-ESSX8336:00: HP_CODEC_ADC_ALC_ENABLE_ARG=0x1
[    4.826750] es8316 i2c-ESSX8336:00: MAIN_CODEC_ADC_ALC_ENABLE_ARG=0x1
[    4.826790] es8316 i2c-ESSX8336:00: HP_CODEC_ADC_ALC_TARGET_LEVEL_ARG=0xa
[    4.826820] es8316 i2c-ESSX8336:00: MAIN_CODEC_ADC_ALC_TARGET_LEVEL_ARG=0xa
[    4.826845] es8316 i2c-ESSX8336:00: HP_CODEC_ADC_ALC_MAXGAIN_ARG=0x12
[    4.826880] es8316 i2c-ESSX8336:00: MAIN_CODEC_ADC_ALC_MAXGAIN_ARG=0x12
[    4.826915] es8316 i2c-ESSX8336:00: HP_CODEC_ADC_ALC_MINGAIN_ARG=0x8
[    4.826943] es8316 i2c-ESSX8336:00: MAIN_CODEC_ADC_ALC_MINGAIN_ARG=0x8
[    4.826977] es8316 i2c-ESSX8336:00: HP_CODEC_ADC_ALC_HLDTIME_ARG=0x0
[    4.827017] es8316 i2c-ESSX8336:00: MAIN_CODEC_ADC_ALC_HLDTIME_ARG=0x0
[    4.827059] es8316 i2c-ESSX8336:00: HP_CODEC_ADC_ALC_DCYTIME_ARG=0x0
[    4.827117] es8316 i2c-ESSX8336:00: MAIN_CODEC_ADC_ALC_DCYTIME_ARG=0x0
[    4.827156] es8316 i2c-ESSX8336:00: HP_CODEC_ADC_ALC_ATKTIME_ARG=0x2
[    4.827216] es8316 i2c-ESSX8336:00: MAIN_CODEC_ADC_ALC_ATKTIME_ARG=0x2
[    4.827278] es8316 i2c-ESSX8336:00: HP_CODEC_ADC_ALC_NGTYPE_ARG=0x3
[    4.827324] es8316 i2c-ESSX8336:00: MAIN_CODEC_ADC_ALC_NGTYPE_ARG=0x3
[    4.827369] es8316 i2c-ESSX8336:00: HP_CODEC_ADC_ALC_NGTHLD_ARG=0x1
[    4.827407] es8316 i2c-ESSX8336:00: MAIN_CODEC_ADC_ALC_NGTHLD_ARG=0x1
[    4.827421] es8316 i2c-ESSX8336:00: MAIN_CODEC_ADC_GUI_STEP_ARG=0x3
[    4.827437] es8316 i2c-ESSX8336:00: MAIN_CODEC_ADC_GUI_GAIN_RANGE_ARG=0x3
[    4.827764] es8316 i2c-ESSX8336:00: HP_CODEC_DAC_HPMIX_HIGAIN_ARG=0x0
[    4.827835] es8316 i2c-ESSX8336:00: SPK_CODEC_DAC_HPMIX_HIGAIN_ARG=0x0
[    4.827965] es8316 i2c-ESSX8336:00: HP_CODEC_DAC_HPMIX_VOLUME_ARG=0xbb
[    4.828018] es8316 i2c-ESSX8336:00: SPK_CODEC_DAC_HPMIX_VOLUME_ARG=0xbb
[    4.828079] es8316 i2c-ESSX8336:00: HP_CODEC_DAC_HPOUT_VOLUME_ARG=0x0
[    4.828147] es8316 i2c-ESSX8336:00: SPK_CODEC_DAC_HPOUT_VOLUME_ARG=0x0
[    4.828194] es8316 i2c-ESSX8336:00: HP_CODEC_LDAC_VOLUME_ARG=0x0
[    4.828265] es8316 i2c-ESSX8336:00: HP_CODEC_RDAC_VOLUME_ARG=0x0
[    4.828345] es8316 i2c-ESSX8336:00: SPK_CODEC_LDAC_VOLUME_ARG=0x0
[    4.828435] es8316 i2c-ESSX8336:00: SPK_CODEC_RDAC_VOLUME_ARG=0x0
[    4.828535] es8316 i2c-ESSX8336:00: HP_CODEC_DAC_AUTOMUTE_ARG=0x0
[    4.828630] es8316 i2c-ESSX8336:00: SPK_CODEC_DAC_AUTOMUTE_ARG=0x1
[    4.828723] es8316 i2c-ESSX8336:00: HP_CODEC_DAC_MONO_ARG=0x0
[    4.828803] es8316 i2c-ESSX8336:00: SPK_CODEC_DAC_MONO_ARG=0x0
[    4.829141] es8316 i2c-ESSX8336:00: SPK_CTL_IO_LEVEL_ARG=0x1
[    4.830289] es8316 i2c-ESSX8336:00: PLATFORM_MCLK_LRCK_FREQ_ARG=0x20
[    4.830292] es8316 i2c-ESSX8336:00: ===================================================
[    4.830312] es8316 i2c-ESSX8336:00: HP jack detect inverted 1
[    4.989925] sof-audio-pci-intel-cnl 0000:00:1f.3:  Topology file:     intel/sof-tplg/sof-cml-es8336-dmic2ch-ssp0.tplg
[    5.120526] es8316 i2c-ESSX8336:00: speaker gpio 1 active high, headphone gpio 0 active low
[    5.147442] es8316 i2c-ESSX8336:00: assuming static mclk

Pluging/unpluging jack events also work as expected, getting "jack unplugged" messages when removing the headset jack:

[    5.194858] es8316 i2c-ESSX8336:00: gpio flags 0x24
[   67.652212] es8316 i2c-ESSX8336:00: gpio flags 0x20
[   67.675464] es8316 i2c-ESSX8336:00: gpio flags 0x22
[   70.690092] es8316 i2c-ESSX8336:00: gpio flags 0x20
[   70.691194] es8316 i2c-ESSX8336:00: gpio flags 0x24
[   70.691550] es8316 i2c-ESSX8336:00: jack unplugged
[  147.101628] es8316 i2c-ESSX8336:00: gpio flags 0x20
[  147.123512] es8316 i2c-ESSX8336:00: gpio flags 0x22
[  186.022655] es8316 i2c-ESSX8336:00: gpio flags 0x20
[  186.024774] es8316 i2c-ESSX8336:00: gpio flags 0x24
[  186.027025] es8316 i2c-ESSX8336:00: jack unplugged
[  251.718579] es8316 i2c-ESSX8336:00: gpio flags 0x20
[  251.740952] es8316 i2c-ESSX8336:00: gpio flags 0x22
[  255.747784] es8316 i2c-ESSX8336:00: gpio flags 0x24
[  255.750680] es8316 i2c-ESSX8336:00: jack unplugged

Also tested basic audio on Matebook 14, although UCM logic for this device very likely needs to be patched to be more generic.

mchehab avatar Dec 29 '23 18:12 mchehab

Can one of the admins verify this patch?

reply test this please to run this test once

sofci avatar Dec 29 '23 18:12 sofci

Btw, did a quick test today on a different notebook: Huawei 14 2021: BIOS DSM is also not reliable there: quirks are needed. I'll try to add a patch on the top of this series adding support for it, depending on weather I'll be able to keep such notebook long enough to write the patches and test it.

mchehab avatar Dec 30 '23 21:12 mchehab

Btw, did a quick test today on a different notebook: Huawei 14 2021: BIOS DSM is also not reliable there: quirks are needed. I'll try to add a patch on the top of this series adding support for it, depending on weather I'll be able to keep such notebook long enough to write the patches and test it.

Matebook 14 (2021) support for internal MIC is not trivial: it uses AMIC on TGL. Currently, it seems that this is not properly supported, as device probe is called with mach_params.dmic_num > 0. Maybe something needs to be changed at firmware topology level?

mchehab avatar Dec 31 '23 11:12 mchehab

Btw, did a quick test today on a different notebook: Huawei 14 2021: BIOS DSM is also not reliable there: quirks are needed. I'll try to add a patch on the top of this series adding support for it, depending on weather I'll be able to keep such notebook long enough to write the patches and test it.

Matebook 14 (2021) support is not trivial: it uses AMIC on TGL. Currently, it seems that this is not properly supported. Maybe something needs to be changed at firmware topology level?

Trying to not enable DMIC on Huawei Matebook 14 (after some patches to address it) doesn't work, as sof-audio-pci-intel-tgl complains with:

[ 4.303999] sof-audio-pci-intel-tgl 0000:00:1f.3: Topology: ABI 3:22:1 Kernel ABI 3:23:0 [ 4.304028] sof-audio-pci-intel-tgl 0000:00:1f.3: error: can't connect DAI DMIC0.IN stream dmic01 [ 4.304029] sof-audio-pci-intel-tgl 0000:00:1f.3: error: failed to add widget id 0 type 28 name : DMIC0.IN stream dmic01 [ 4.304032] sof-essx8336 sof-essx8336: ASoC: failed to load widget DMIC0.IN [ 4.304033] sof-essx8336 sof-essx8336: ASoC: topology: could not load header: -22 [ 4.304037] sof-audio-pci-intel-tgl 0000:00:1f.3: error: tplg component load failed -22 [ 4.304039] sof-audio-pci-intel-tgl 0000:00:1f.3: error: failed to load DSP topology -22 [ 4.304040] sof-audio-pci-intel-tgl 0000:00:1f.3: ASoC: error at snd_soc_component_probe on 0000:00:1f.3: -22 [ 4.304046] sof-essx8336 sof-essx8336: ASoC: failed to instantiate card -22 [ 4.304072] sof-essx8336 sof-essx8336: snd_soc_register_card failed: -22 [ 4.304078] sof-essx8336: probe of sof-essx8336 failed with error -22

I opened a separate issue describing the problem at: https://github.com/thesofproject/linux/issues/4757

mchehab avatar Dec 31 '23 12:12 mchehab

Matebook 14 (2021) support is not trivial: it uses AMIC on TGL. Currently, it seems that this is not properly supported. Maybe something needs to be changed at firmware topology level?

Trying to not enable DMIC on Huawei Matebook 14 (after some patches to address it) doesn't work, as sof-audio-pci-intel-tgl.

Fixed a AMIC probing logic to better cope with AMIC. Still, TGL seems to be relying on having DMIC (perhaps due to UCM settings).

mchehab avatar Dec 31 '23 13:12 mchehab

@mchehab can you attach the log where the DMIC is used instead of AMIC? The SOF driver relies on the ACPI NHLT table to figure out when to enable the DMICs, if that information is incorrect then yet another quirk is needed.

plbossart avatar Jan 03 '24 11:01 plbossart

test this please

plbossart avatar Jan 03 '24 13:01 plbossart