[RFC] Sound support for Huawei line of AMD laptops using ACP and ES8336 codec
I have a Huawei Matebook 14 AMD 2021 laptop for which the sound isn't supported on Linux. On further investigation in Windows and ACPI tables I could determine that this particular SKU has an ES8336 codec connected to the CPU ACP module. The CPU of my laptop is an AMD Ryzen 5 5500U which seems to be codenamed Lucienne and is a derivation of the Renoir family. Acording to lspci the ACP is revision 1:
03:00.5 Multimedia controller [0480]: Advanced Micro Devices, Inc. [AMD] Raven/Raven2/FireFlight/Renoir Audio Processor [1022:15e2] (rev 01) Subsystem: Device [1e83:3e4d] Kernel driver in use: snd_rn_pci_acp3x Kernel modules: snd_pci_acp3x, snd_rn_pci_acp3x, snd_pci_acp5x, snd_pci_acp6x, snd_acp_pci, snd_rpl_pci_acp6x, snd_sof_amd_renoir
I have written a machine driver for this platform and managed to make the sound and internal microphone work. I am looking to integrate this support but there are some issues with the current implementation of ACP support.
As far as I can tell there are 4 directions I could take to add support:
1. A standalone machine driver in sound/soc/amd that uses the platform drivers from sound/soc/amd/raven/
2. An embedded driver in sound/soc/amd/acp/acp-legacy-mach.c
3. A standalone machine driver in sound/soc/amd that uses the platform drivers from sound/soc/amd/renoir
4. Use the SOF infrastructure
Now as far as I can tell, all of these directions have issues:
1. The pci driver from sound/soc/amd/raven/pci-acp3x.c doesn't support Lucienne since it blocks rev 1 devices in :
/* Raven device detection */ if (pci->revision != 0x00) return -ENODEV;
This is the approach I took and just changed the check to add support for rev 1. The sound and internal microphone worked ok and I didn't encounter any issues with it. Of course I don't know the internals of ACP and don't know what are the differences between rev 0 and rev 1.
2. This approach could work but I would need to change the structure acp_card_drvdata and struct snd_soc_dapm_widget acp_widgets, to add proper support for jack handling (and maybe some other modifications). This driver seems to support rev 1 (in sound/soc/amd/acp/acp-pci.c):
switch (pci->revision) { case 0x01: chip->name = "acp_asoc_renoir"; chip->acp_rev = ACP3X_DEV; break;
Also from the module description it seems that these drivers are meant only for chromebook support.
3. This seems like it would the best approach in theory, but the problem is that the drivers inside only seem to add support for DMIC.
4. I tried to use SOF early when I started tinkering, but I always got a timeout during init phase when loading the renoir firmware.
So the reason for this email is to get some idea, on how to best add support for these laptops.
I have a Huawei Matebook 14 AMD 2021 laptop for which the sound isn't supported on Linux. On further investigation in Windows and ACPI tables I could determine that this particular SKU has an ES8336 codec connected to the CPU ACP module. The CPU of my laptop is an AMD Ryzen 5 5500U which seems to be codenamed Lucienne and is a derivation of the Renoir family. Acording to lspci the ACP is revision 1:
03:00.5 Multimedia controller [0480]: Advanced Micro Devices, Inc. [AMD] Raven/Raven2/FireFlight/Renoir Audio Processor [1022:15e2] (rev 01) Subsystem: Device [1e83:3e4d] Kernel driver in use: snd_rn_pci_acp3x Kernel modules: snd_pci_acp3x, snd_rn_pci_acp3x, snd_pci_acp5x, snd_pci_acp6x, snd_acp_pci, snd_rpl_pci_acp6x, snd_sof_amd_renoir
I have written a machine driver for this platform and managed to make the sound and internal microphone work. I am looking to integrate this support but there are some issues with the current implementation of ACP support.
As far as I can tell there are 4 directions I could take to add support:
- A standalone machine driver in sound/soc/amd that uses the platform
drivers from sound/soc/amd/raven/
An embedded driver in sound/soc/amd/acp/acp-legacy-mach.c
A standalone machine driver in sound/soc/amd that uses the platform
drivers from sound/soc/amd/renoir
- Use the SOF infrastructure
The main issue with this codec is the mind-blowing proliferation of configurations and quirks. I can't comment on AMD-specific stuff, but would recommend you take a look at the GitHub PR we've been reviewing to extract as much information as possible from ACPI _DSM tables (as done by the Windows driver). see https://github.com/thesofproject/linux/pull/4112 (credits to Mauro Chehab for fixing and testing on real hardware and David Yang for providing the DSM information and comments).
Hi Marian,
Thanks for the query.
On 1/7/2023 12:17 AM, Marian Postevca wrote:
I have a Huawei Matebook 14 AMD 2021 laptop for which the sound isn't supported on Linux. On further investigation in Windows and ACPI tables I could determine that this particular SKU has an ES8336 codec connected to the CPU ACP module. The CPU of my laptop is an AMD Ryzen 5 5500U which seems to be codenamed Lucienne and is a derivation of the Renoir family. Acording to lspci the ACP is revision 1:
03:00.5 Multimedia controller [0480]: Advanced Micro Devices, Inc. [AMD] Raven/Raven2/FireFlight/Renoir Audio Processor [1022:15e2] (rev 01) Subsystem: Device [1e83:3e4d] Kernel driver in use: snd_rn_pci_acp3x Kernel modules: snd_pci_acp3x, snd_rn_pci_acp3x, snd_pci_acp5x, snd_pci_acp6x, snd_acp_pci, snd_rpl_pci_acp6x, snd_sof_amd_renoir
I have written a machine driver for this platform and managed to make the sound and internal microphone work. I am looking to integrate this support but there are some issues with the current implementation of ACP support.
As far as I can tell there are 4 directions I could take to add support:
A standalone machine driver in sound/soc/amd that uses the platform drivers from sound/soc/amd/raven/
An embedded driver in sound/soc/amd/acp/acp-legacy-mach.c
A standalone machine driver in sound/soc/amd that uses the platform drivers from sound/soc/amd/renoir
Use the SOF infrastructure
Now as far as I can tell, all of these directions have issues:
The pci driver from sound/soc/amd/raven/pci-acp3x.c doesn't support Lucienne since it blocks rev 1 devices in :
/* Raven device detection */ if (pci->revision != 0x00) return -ENODEV;
This is the approach I took and just changed the check to add support for rev 1. The sound and internal microphone worked ok and I didn't encounter any issues with it. Of course I don't know the internals of ACP and don't know what are the differences between rev 0 and rev 1.
Not recommended
This approach could work but I would need to change the structure acp_card_drvdata and struct snd_soc_dapm_widget acp_widgets, to add proper support for jack handling (and maybe some other modifications). This driver seems to support rev 1 (in sound/soc/amd/acp/acp-pci.c):
switch (pci->revision) { case 0x01: chip->name = "acp_asoc_renoir"; chip->acp_rev = ACP3X_DEV; break;
Also from the module description it seems that these drivers are meant only for chromebook support.
Recommended. Please add below code
{ .flags = FLAG_AMD_LEGACY, .device = ACP_PCI_DEV_ID, .dmi_table = (const struct dmi_system_id []) { { .matches = { DMI_MATCH(DMI_SYS_VENDOR, ""),///change accordingly DMI_MATCH(DMI_PRODUCT_NAME, ""),///change accordingly }, },
at https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git/tree/sound...
As you said add the structure static struct acp_card_drvdata and also add the required dai_link of codec.
This seems like it would the best approach in theory, but the problem is that the drivers inside only seem to add support for DMIC.
I tried to use SOF early when I started tinkering, but I always got a timeout during init phase when loading the renoir firmware.
Could you please send the error, we will check and let you know what is missing.
So the reason for this email is to get some idea, on how to best add support for these laptops.
On 1/7/2023 00:58, Reddy, V sujith kumar wrote:
Hi Marian,
Thanks for the query.
On 1/7/2023 12:17 AM, Marian Postevca wrote:
I have a Huawei Matebook 14 AMD 2021 laptop for which the sound isn't supported on Linux. On further investigation in Windows and ACPI tables I could determine that this particular SKU has an ES8336 codec connected to the CPU ACP module. The CPU of my laptop is an AMD Ryzen 5 5500U which seems to be codenamed Lucienne and is a derivation of the Renoir family. Acording to lspci the ACP is revision 1:
03:00.5 Multimedia controller [0480]: Advanced Micro Devices, Inc. [AMD] Raven/Raven2/FireFlight/Renoir Audio Processor [1022:15e2] (rev 01) Subsystem: Device [1e83:3e4d] Kernel driver in use: snd_rn_pci_acp3x Kernel modules: snd_pci_acp3x, snd_rn_pci_acp3x, snd_pci_acp5x, snd_pci_acp6x, snd_acp_pci, snd_rpl_pci_acp6x, snd_sof_amd_renoir
I have written a machine driver for this platform and managed to make the sound and internal microphone work. I am looking to integrate this support but there are some issues with the current implementation of ACP support.
As far as I can tell there are 4 directions I could take to add support:
A standalone machine driver in sound/soc/amd that uses the platform drivers from sound/soc/amd/raven/
An embedded driver in sound/soc/amd/acp/acp-legacy-mach.c
A standalone machine driver in sound/soc/amd that uses the platform drivers from sound/soc/amd/renoir
Use the SOF infrastructure
Now as far as I can tell, all of these directions have issues:
The pci driver from sound/soc/amd/raven/pci-acp3x.c doesn't support Lucienne since it blocks rev 1 devices in :
/* Raven device detection */ if (pci->revision != 0x00) return -ENODEV;
This is the approach I took and just changed the check to add support for rev 1. The sound and internal microphone worked ok and I didn't encounter any issues with it. Of course I don't know the internals of ACP and don't know what are the differences between rev 0 and rev 1.
Not recommended
This approach could work but I would need to change the structure acp_card_drvdata and struct snd_soc_dapm_widget acp_widgets, to add proper support for jack handling (and maybe some other modifications). This driver seems to support rev 1 (in sound/soc/amd/acp/acp-pci.c):
switch (pci->revision) { case 0x01: chip->name = "acp_asoc_renoir"; chip->acp_rev = ACP3X_DEV; break;
Also from the module description it seems that these drivers are meant only for chromebook support.
Recommended. Please add below code
{ .flags = FLAG_AMD_LEGACY, .device = ACP_PCI_DEV_ID, .dmi_table = (const struct dmi_system_id []) { { .matches = { DMI_MATCH(DMI_SYS_VENDOR, ""),///change accordingly DMI_MATCH(DMI_PRODUCT_NAME, ""),///change accordingly }, },
at https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git/tree/sound...
As you said add the structure static struct acp_card_drvdata and also add the required dai_link of codec.
This seems like it would the best approach in theory, but the problem is that the drivers inside only seem to add support for DMIC.
I tried to use SOF early when I started tinkering, but I always got a timeout during init phase when loading the renoir firmware.
Could you please send the error, we will check and let you know what is missing.
Just a guess here without seeing the error. Is this perhaps because the SOF F/W binary that was loaded was not signed with signature trusted by the platform and the platform required validation?
SOF on AMD was first introduced for Chromebooks which don't use the same authority for firmware binary verification that general purpose UEFI notebooks would use.
Hello V sujith kumar, Mario,
Thanks for the replies to my email.
"Limonciello, Mario" mario.limonciello@amd.com writes:
On 1/7/2023 00:58, Reddy, V sujith kumar wrote:
Could you please send the error, we will check and let you know what is missing.
Just a guess here without seeing the error. Is this perhaps because the SOF F/W binary that was loaded was not signed with signature trusted by the platform and the platform required validation?
SOF on AMD was first introduced for Chromebooks which don't use the same authority for firmware binary verification that general purpose UEFI notebooks would use.
So I compiled the latest sof firmware from main branch commit 90c14e56cb, and now it seems I get additional errors that I didn't get a few months ago when I last tried: [ 38.251393] snd_sof_amd_renoir 0000:03:00.5: enabling device (0000 -> 0002) [ 38.252944] snd_sof_amd_renoir 0000:03:00.5: unknown sof_ext_man header type 3 size 0x30 [ 38.252955] snd_sof_amd_renoir 0000:03:00.5: Firmware info: version 2:0:0-90c14 [ 38.252957] snd_sof_amd_renoir 0000:03:00.5: Firmware: ABI 3:26:0 Kernel ABI 3:23:0 [ 41.345068] snd_sof_amd_renoir 0000:03:00.5: ------------[ DSP dump start ]------------ [ 41.345080] snd_sof_amd_renoir 0000:03:00.5: Firmware boot failure due to timeout [ 41.345085] snd_sof_amd_renoir 0000:03:00.5: fw_state: SOF_FW_BOOT_IN_PROGRESS (2) [ 41.345137] snd_sof_amd_renoir 0000:03:00.5: invalid header size 0x7f841000. FW oops is bogus [ 41.345142] snd_sof_amd_renoir 0000:03:00.5: unexpected fault 0x7f840000 trace 0x7f840000 [ 41.345146] snd_sof_amd_renoir 0000:03:00.5: ------------[ DSP dump end ]------------ [ 41.345150] snd_sof_amd_renoir 0000:03:00.5: error: failed to boot DSP firmware -5 [ 41.345266] snd_sof_amd_renoir 0000:03:00.5: error: sof_probe_work failed err: -5
The kernel I'm running on is based on the asoc tree from Mark Brown: git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
commit f8778e910cab179f5835386a0a70847921a8fbec (sound/for-next) Merge: cdfa92eb90f5 b11845893678 Author: Mark Brown broonie@kernel.org Date: Fri Jan 6 17:04:36 2023 +0000
Merge remote-tracking branch 'asoc/for-6.3' into asoc-next
Let me know what other information you need in order to debug this.
On 1/10/2023 5:57 PM, Marian Postevca wrote:
Hello V sujith kumar, Mario,
Thanks for the replies to my email.
"Limonciello, Mario" mario.limonciello@amd.com writes:
On 1/7/2023 00:58, Reddy, V sujith kumar wrote:
Could you please send the error, we will check and let you know what is missing.
Just a guess here without seeing the error. Is this perhaps because the SOF F/W binary that was loaded was not signed with signature trusted by the platform and the platform required validation?
SOF on AMD was first introduced for Chromebooks which don't use the same authority for firmware binary verification that general purpose UEFI notebooks would use.
So I compiled the latest sof firmware from main branch commit 90c14e56cb, and now it seems I get additional errors that I didn't get a few months ago when I last tried: [ 38.251393] snd_sof_amd_renoir 0000:03:00.5: enabling device (0000 -> 0002) [ 38.252944] snd_sof_amd_renoir 0000:03:00.5: unknown sof_ext_man header type 3 size 0x30 [ 38.252955] snd_sof_amd_renoir 0000:03:00.5: Firmware info: version 2:0:0-90c14 [ 38.252957] snd_sof_amd_renoir 0000:03:00.5: Firmware: ABI 3:26:0 Kernel ABI 3:23:0 [ 41.345068] snd_sof_amd_renoir 0000:03:00.5: ------------[ DSP dump start ]------------ [ 41.345080] snd_sof_amd_renoir 0000:03:00.5: Firmware boot failure due to timeout [ 41.345085] snd_sof_amd_renoir 0000:03:00.5: fw_state: SOF_FW_BOOT_IN_PROGRESS (2) [ 41.345137] snd_sof_amd_renoir 0000:03:00.5: invalid header size 0x7f841000. FW oops is bogus [ 41.345142] snd_sof_amd_renoir 0000:03:00.5: unexpected fault 0x7f840000 trace 0x7f840000 [ 41.345146] snd_sof_amd_renoir 0000:03:00.5: ------------[ DSP dump end ]------------ [ 41.345150] snd_sof_amd_renoir 0000:03:00.5: error: failed to boot DSP firmware -5 [ 41.345266] snd_sof_amd_renoir 0000:03:00.5: error: sof_probe_work failed err: -5
The kernel I'm running on is based on the asoc tree from Mark Brown: git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
commit f8778e910cab179f5835386a0a70847921a8fbec (sound/for-next) Merge: cdfa92eb90f5 b11845893678 Author: Mark Brown broonie@kernel.org Date: Fri Jan 6 17:04:36 2023 +0000
Merge remote-tracking branch 'asoc/for-6.3' into asoc-next
Let me know what other information you need in order to debug this.
As per the error in https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/soun...,
the firmware header was not proper.
Even the header parsing is done correctly, you will run into other issues related to signed firmware validation error as mentioned by mario.limonciello@amd.com .
So please Use x86 based implementation without DSP that is recommended 2.
participants (4)
-
Limonciello, Mario
-
Marian Postevca
-
Pierre-Louis Bossart
-
Reddy, V sujith kumar