linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] Sound support for Huawei line of AMD laptops using ACP and ES8336 codec
@ 2023-01-06 18:47 Marian Postevca
  2023-01-07  1:15 ` Pierre-Louis Bossart
       [not found] ` <598ca0a8-8aef-a030-7060-f76ba4700bbf@amd.com>
  0 siblings, 2 replies; 6+ messages in thread
From: Marian Postevca @ 2023-01-06 18:47 UTC (permalink / raw)
  To: alsa-devel, linux-kernel
  Cc: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Vijendar Mukunda, Mario Limonciello, V sujith kumar Reddy,
	syed sabakareem


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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFC] Sound support for Huawei line of AMD laptops using ACP and ES8336 codec
  2023-01-06 18:47 [RFC] Sound support for Huawei line of AMD laptops using ACP and ES8336 codec Marian Postevca
@ 2023-01-07  1:15 ` Pierre-Louis Bossart
       [not found] ` <598ca0a8-8aef-a030-7060-f76ba4700bbf@amd.com>
  1 sibling, 0 replies; 6+ messages in thread
From: Pierre-Louis Bossart @ 2023-01-07  1:15 UTC (permalink / raw)
  To: Marian Postevca, alsa-devel, linux-kernel
  Cc: Takashi Iwai, Liam Girdwood, Mark Brown, Mario Limonciello,
	Vijendar Mukunda, V sujith kumar Reddy, syed sabakareem, Chehab,
	Mauro, David Yang



> 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

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).

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFC] Sound support for Huawei line of AMD laptops using ACP and ES8336 codec
       [not found] ` <598ca0a8-8aef-a030-7060-f76ba4700bbf@amd.com>
@ 2023-01-09 18:21   ` Limonciello, Mario
  2023-01-10 12:27     ` Marian Postevca
  0 siblings, 1 reply; 6+ messages in thread
From: Limonciello, Mario @ 2023-01-09 18:21 UTC (permalink / raw)
  To: Reddy, V sujith kumar, Marian Postevca, alsa-devel, linux-kernel
  Cc: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Vijendar Mukunda, syed sabakareem

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:
>>
>> 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.
> 
> 
> Not recommended
> 
>> 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.
> 
> 
> 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/soc/amd/acp-config.c#n50
> 
> As you said add the   structure static struct acp_card_drvdata and also 
> add the required dai_link of codec.
> 
> 
> 
>> 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.
> 
> 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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFC] Sound support for Huawei line of AMD laptops using ACP and ES8336 codec
  2023-01-09 18:21   ` Limonciello, Mario
@ 2023-01-10 12:27     ` Marian Postevca
  2023-01-11  9:33       ` Reddy, V sujith kumar
  0 siblings, 1 reply; 6+ messages in thread
From: Marian Postevca @ 2023-01-10 12:27 UTC (permalink / raw)
  To: Limonciello, Mario, Reddy, V sujith kumar, alsa-devel, linux-kernel
  Cc: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Vijendar Mukunda, syed sabakareem

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.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFC] Sound support for Huawei line of AMD laptops using ACP and ES8336 codec
  2023-01-10 12:27     ` Marian Postevca
@ 2023-01-11  9:33       ` Reddy, V sujith kumar
  0 siblings, 0 replies; 6+ messages in thread
From: Reddy, V sujith kumar @ 2023-01-11  9:33 UTC (permalink / raw)
  To: Marian Postevca, Limonciello, Mario, alsa-devel, linux-kernel
  Cc: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Vijendar Mukunda, syed sabakareem


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/sound/soc/sof/ipc3-loader.c?h=v6.2-rc3#n204,

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.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [RFC] Sound support for Huawei line of AMD laptops using ACP and ES8336 codec
@ 2023-01-06 18:39 Marian Postevca
  0 siblings, 0 replies; 6+ messages in thread
From: Marian Postevca @ 2023-01-06 18:39 UTC (permalink / raw)
  To: alsa-devel, linux-kernel
  Cc: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Vijendar Mukunda, Ajit Kumar Pandey, Mario Limonciello,
	V sujith kumar Reddy, syed sabakareem, Dan Carpenter


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.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-01-11  9:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-06 18:47 [RFC] Sound support for Huawei line of AMD laptops using ACP and ES8336 codec Marian Postevca
2023-01-07  1:15 ` Pierre-Louis Bossart
     [not found] ` <598ca0a8-8aef-a030-7060-f76ba4700bbf@amd.com>
2023-01-09 18:21   ` Limonciello, Mario
2023-01-10 12:27     ` Marian Postevca
2023-01-11  9:33       ` Reddy, V sujith kumar
  -- strict thread matches above, loose matches on Subject: below --
2023-01-06 18:39 Marian Postevca

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).