Skip to contentSkip to conversation

UCM vs SOF vs HDMI passthrough

DISCUSSION Péter Ujfalusi 2 participants 3 messages Apr 11, 2024 – Apr 12, 2024

lore
Share & tools
lore
#0 lore raw

Hi,

afaik for HDMI passthrough there should be a usable PCM mapping present for user space:
aplay -L | grep hdmi
hdmi:CARD=PCH,DEV=0
hdmi:CARD=PCH,DEV=1
hdmi:CARD=PCH,DEV=2

or similar.

SOF with IPC4 (Meteor Lake and newer or some TGL/ADL setups with 2024.03 release) it is possible to use passthrough via HDMI technically but we are lacking the "hdmi:..." PCMs, so in reality it is not usable for applications. Afaik.

So far I managed to cook up two ways of doing this, but neither one is good enough as they will create the "hdmi:..." for both IPC3 and IPC4 setups and IPC3 firmware cannot support passthrough.

Setups:
sof-hda-dsp cards have HDMI PCMs: pcm3-5
sof-soundwire cards have HDMI PCMs: pcm5-7

[A] use card profile
Add these to /usr/share/alsa/cards/aliases.conf:
sof-hda-dsp cards.sof-hda-dsp
sof-soundwire cards.sof-soundwire

Create the minimal sof-hda-ds.conf and sof-soundwire.conf to handle the two types of HDMI PCM numbering.

[B] Using UCM
https://github.com/ujfalusi/alsa-ucm-conf/tree/topic/sof-hdmi

It is using the BootSequence[] to create three files:
[1] /var/lib/alsa/conf.d/42-sof-hdmi.conf
[2] /var/lib/alsa/card[card_number].conf.d/30-sof-hdmi-common.conf
[3] /var/lib/alsa/card[card_number].conf.d/31-sof-hdmi.conf

[1] includes the pcm/iec958.conf and pcm/hdmi.conf to global space of alsaconf to be used by the card macros
[2] Card specific macros for hdmi PCM definition, ampping
[3] Card specific definitions of the three HDMI port

In both case I have the needed PCMs:
aplay -L | grep hdmi

hdmi:CARD=sofhdadsp,DEV=0
hdmi:CARD=sofhdadsp,DEV=1
hdmi:CARD=sofhdadsp,DEV=2
or
hdmi:CARD=sofsoundwire,DEV=0
hdmi:CARD=sofsoundwire,DEV=1
hdmi:CARD=sofsoundwire,DEV=2

But it is unconditional and they will be created for all sof-hda-dsp and sof-soundwire cards.

I would really appreciate some guidance on how we can achieve this correctly (the code for the UCM way leaves much to be desired, I know).

How can this be done conditionally?
We can set the HDMI PCMs to advertise IEC958_SUBFRAME_LE for IPC4 only, but how can we use that?
Should we add some parameter to 'amixer -c0 info', like ipc_version:4/3, so if the ipc_version is 3 or missing we assume that passthrough is not supported?

Thanks for the help,
Péter

#1 lore raw
Quoted 2 lines · Péter Ujfalusi

[B] Using UCM
https://github.com/ujfalusi/alsa-ucm-conf/tree/topic/sof-hdmi

This is only way to go. The configuration for "legacy" PCM device names should be handled through UCM (when UCM config exists for this hw).

Quoted 3 lines

Should we add some parameter to 'amixer -c0 info', like ipc_version:4/3, so if the ipc_version is 3 or missing we assume that passthrough is not supported?

UCM must be able to detect sound card capabilities. For passthrough, there should be some controls for AES bits which may be used for the conditional matching. If it's not sufficient, a hint to the components string (mixer info structure) may be added by the driver. Also PCM name or subname may be matched for a substring, if you like (seems more related than the components string).

Jaroslav

Signature · 2 lines
Jaroslav Kysela <[email protected]>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.
#2 lore raw
Quoted 7 lines · Jaroslav Kysela
Quoted 2 lines · Péter Ujfalusi

[B] Using UCM
https://github.com/ujfalusi/alsa-ucm-conf/tree/topic/sof-hdmi

This is only way to go. The configuration for "legacy" PCM device names should be handled through UCM (when UCM config exists for this hw).

OK, I will drop the other option.

Quoted 10 lines
Quoted 3 lines

Should we add some parameter to 'amixer -c0 info', like ipc_version:4/3, so if the ipc_version is 3 or missing we assume that passthrough is not supported?

UCM must be able to detect sound card capabilities. For passthrough, there should be some controls for AES bits which may be used for the conditional matching. If it's not sufficient, a hint to the components string (mixer info structure) may be added by the driver. Also PCM name or subname may be matched for a substring, if you like (seems more related than the components string).

Thanks for the advice!

I have now something really working in a way it should be. The kernel will add "hdmi-pt:1" to the card's components when HDMI passthrough is possible (IPC4, ChainDMA enabled for HDMI PCM). [1]

UCM will use the existence of "hdmi-pt:1" to decide to create the needed mapping PCMs [2]

[1] https://github.com/thesofproject/linux/pull/4921
[2] https://github.com/ujfalusi/alsa-ucm-conf/tree/topic/sof-hdmi

I'm not sure about the "hdmi-pt:1", can we just have plain "hdmi-pt" or we need a param:value pair always?

There are still funky things done in the UCM patch due to lack of experience with it. I guess I should create a formal PR to get it reviewed and correct, right?

Thank you,
Péter