New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sof-hda-dsp/sof-soundwire: Create "hdmi:" mapping PCMs to allow passthrough if supported #411
Conversation
e3caae1
to
1275fd9
Compare
Changes since v1:
|
Thanks. Some notes:
The config in
|
OK, I have this working without the iec958 inclusion, I must have added it back by mistake.
Right, I'm not sure how that is done in practice. I could not find a way to save a generated section, not to mention how to generate that section which can then be saved. I guess one of the generated alsaconf section in the split.conf is
I see, I would guess that this needs alignment with Pulseaudio and Pipewire at least?
OK, let me see how far I will get with this ;) Thank you for the suggestions! |
One file should be enough. Just save the appropriate generated subtree:
(assuming PCM configs like The command
Not really. Use only SplitPCM macro for an example. SplitPCMDevice is a helper which uses different UCM config for applications implementing channel splitting. |
@perexg, it almost works, but not the way I expected..
The /lib/sof-hdmi2.conf files is:
It creates one file with a single pcm.hdmi.X where X is the value from the last macro call. If I drop the Device 4 and 5, I have the mapping for Device 3, if I only drop the Device 5 then it is the Device 4 only. But still, only the section generated by the last call to the macro is present. In /tmp/alsa-ucm.txt I only have prints from the last call of the macro + Save |
Replace:
with shorter notation (less tabs) and correct use
|
Also, the RegEx is too much specific for your use. I would like to move regex to the caller (call macros from this condition) - outside /lib file. |
@perexg, I think I got it working! 🎉 This is what I have now:
[2] the /lib/sof-hdmi2.conf :
The
|
1275fd9
to
93a1675
Compare
Changes since v2:
|
ucm2/common/pcm/hdmi.conf
Outdated
|
||
BootSequence [ | ||
shell "echo 'Record: ${var:__Device}:${var:__Index}' >> /tmp/alsa-ucm.txt" | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
debugprints :(
93a1675
to
667dad3
Compare
Changes since v3:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Good work. Please, check my latest comments.
667dad3
to
b180709
Compare
Changes since v4:
|
Link: alsa-project/alsa-ucm-conf#411 Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Link: alsa-project/alsa-ucm-conf#411 Signed-off-by: Jaroslav Kysela <perex@perex.cz>
- for new macro argument substitution - for new Path condition fields substitutions Link: alsa-project/alsa-ucm-conf#411 Link: #395 Signed-off-by: Jaroslav Kysela <perex@perex.cz>
} | ||
|
||
If.HdmiIec61937 { | ||
Condition { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably last thing I forgot to note in the first review - can we use RegexMatch here using the ${var:Iec61937Pcms1}
string instead a temporary variable?
Like Regex "((^|,)[345](,|$))"
?
It saves some lines.
b180709
to
52529b3
Compare
Changes since v5:
|
52529b3
to
ec40b8a
Compare
Right, sof-soundwire stopped working correctly with the last update |
No, this PR is right, the reason why it is broken is: c56d0a4 ("sof-soundwire: Add basic support for cs42l43's speaker")
|
Sorry. The various changes were merged together by mistake. Use new 035d920 HEAD. |
…evices User space expect to see hdmi: PCM devices to be able to use bytestream passthrough. The common/pcm/hdmi.conf provides two macros: HdmiPCM: to generate an ALSA conf section for an hdmi: PCM device HdmiPCMSave: to save the generated config Example of use (sof-hda-dsp card with hardware HDMI PCMs: 3-5): Macro.0.HdmiPCM { Device 3 Index 0 } Macro.1.HdmiPCM { Device 4 Index 1 } Macro.2.HdmiPCM { Device 5 Index 2 } Macro.3.HdmiPCMSave { } Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
If the HDMI PCM index (3-5) is found in iec61937-pcm list of the card's components list then use the HdmiPCM/HdmiPCMSave macros to create the configuration file. The PCMs that will be created are: aplay -L | grep hdmi hdmi:CARD=sofhdadsp,DEV=0 hdmi:CARD=sofhdadsp,DEV=1 hdmi:CARD=sofhdadsp,DEV=2 Audio servers (Pulseaudio, Pipewrire) or applications then can use these for bytestream passthrough, for example: mplayer -ao alsa:device=hdmi=sofhdadsp,DEV=0 -ac hwdts <video with dts> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
If the HDMI PCM index (3-5) is found in iec61937-pcm list of the card's components list then use the HdmiPCM/HdmiPCMSave macros to create the configuration file. The PCMs that will be created are: aplay -L | grep hdmi hdmi:CARD=sofsoundwire,DEV=0 hdmi:CARD=sofsoundwire,DEV=1 hdmi:CARD=sofsoundwire,DEV=2 Audio servers (Pulseaudio, Pipewrire) or applications then can use these for bytestream passthrough, for example: mplayer -ao alsa:device=hdmi=sofsoundwire,DEV=0 -ac hwdts <video with dts> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
ec40b8a
to
0397a38
Compare
Changes since v6:
|
@perexg, can I do the update to 'Syntax 7' when the support is released with alsa-lib? |
If the HDMI PCM index (3-5) is found in iec61937-pcm list of the card's components list then use the HdmiPCM/HdmiPCMSave macros to create the configuration file. The PCMs that will be created are: aplay -L | grep hdmi hdmi:CARD=sofhdadsp,DEV=0 hdmi:CARD=sofhdadsp,DEV=1 hdmi:CARD=sofhdadsp,DEV=2 Audio servers (Pulseaudio, Pipewrire) or applications then can use these for bytestream passthrough, for example: mplayer -ao alsa:device=hdmi=sofhdadsp,DEV=0 -ac hwdts <video with dts> Closes: #411 Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
If the HDMI PCM index (3-5) is found in iec61937-pcm list of the card's components list then use the HdmiPCM/HdmiPCMSave macros to create the configuration file. The PCMs that will be created are: aplay -L | grep hdmi hdmi:CARD=sofsoundwire,DEV=0 hdmi:CARD=sofsoundwire,DEV=1 hdmi:CARD=sofsoundwire,DEV=2 Audio servers (Pulseaudio, Pipewrire) or applications then can use these for bytestream passthrough, for example: mplayer -ao alsa:device=hdmi=sofsoundwire,DEV=0 -ac hwdts <video with dts> Closes: #411 Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
I applied the current work. It looks fine for me. For |
@perexg, does this makes sense for the diff --git a/ucm2/Intel/sof-hda-dsp/sof-hda-dsp.conf b/ucm2/Intel/sof-hda-dsp/sof-hda-dsp.conf
index 00e40d690aee..0604b09c049e 100644
--- a/ucm2/Intel/sof-hda-dsp/sof-hda-dsp.conf
+++ b/ucm2/Intel/sof-hda-dsp/sof-hda-dsp.conf
@@ -1,4 +1,4 @@
-Syntax 6
+Syntax 7
Include.card-init.File "/lib/card-init.conf"
@@ -128,32 +128,9 @@ If.Capture {
Include.hdmi-pcm.File "/common/pcm/hdmi.conf"
-If.Hdmi3-iec61937 {
- Condition {
- Type RegexMatch
- Regex "((^|,)[3](,|$))"
- String "${var:Iec61937Pcms1}"
- }
- True.Macro.hdmi3.HdmiPCM { Device 3 Index 0 }
-}
-
-If.Hdmi4-iec61937 {
- Condition {
- Type RegexMatch
- Regex "((^|,)[4](,|$))"
- String "${var:Iec61937Pcms1}"
- }
- True.Macro.hdmi4.HdmiPCM { Device 4 Index 1 }
-}
-
-If.Hdmi5-iec61937 {
- Condition {
- Type RegexMatch
- Regex "((^|,)[5](,|$))"
- String "${var:Iec61937Pcms1}"
- }
- True.Macro.hdmi5.HdmiPCM { Device 5 Index 2 }
-}
+Macro.0.SofHdmiDevice { SofIec61937Pcms "${var:Iec61937Pcms1}" Dev 3 Idx 0 }
+Macro.1.SofHdmiDevice { SofIec61937Pcms "${var:Iec61937Pcms1}" Dev 4 Idx 1 }
+Macro.2.SofHdmiDevice { SofIec61937Pcms "${var:Iec61937Pcms1}" Dev 5 Idx 2 }
If.HdmiIec61937 {
Condition {
diff --git a/ucm2/common/pcm/hdmi.conf b/ucm2/common/pcm/hdmi.conf
index 0a870edba54f..1a52986b7a0d 100644
--- a/ucm2/common/pcm/hdmi.conf
+++ b/ucm2/common/pcm/hdmi.conf
@@ -1,3 +1,5 @@
+Syntax 7
+
# Macro HdmiPCM - Generate ALSA control section for hdmi: PCM device
#
# Arguments:
@@ -72,3 +74,22 @@ DefineMacro.HdmiPCMSave {
cfg-save "${var:LibDir}/${var:__Name}.conf:hdmi-pcm"
]
}
+
+# Macro SofHdmiDevice - Create hdmi PCM device for a SOF sound card if
+# passthrough is supported
+#
+# Arguments:
+# SofIec61937Pcms - Comma separated list of PCM device indexes (from
+# iec61937-pcm: components tag)
+# Dev - hardware PCM device to match in SofIec61937Pcms
+# Idx - hdmi: device index and control index
+#
+
+DefineMacro.SofHdmiDevice.If.iec61937 {
+ Condition {
+ Type RegexMatch
+ Regex "((^|,)[${var:__Dev}](,|$))"
+ String "${var:__SofIec61937Pcms}"
+ }
+ True.Macro.hdmi.HdmiPCM { Device "${var:__Dev}" Index "${var:__Idx}" }
+}
diff --git a/ucm2/sof-soundwire/sof-soundwire.conf b/ucm2/sof-soundwire/sof-soundwire.conf
index 34ceb64c98cf..d110a869ac69 100644
--- a/ucm2/sof-soundwire/sof-soundwire.conf
+++ b/ucm2/sof-soundwire/sof-soundwire.conf
@@ -1,4 +1,4 @@
-Syntax 6
+Syntax 7
SectionUseCase."HiFi" {
File "/sof-soundwire/HiFi.conf"
@@ -111,32 +111,9 @@ If.mics-array {
Include.hdmi-pcm.File "/common/pcm/hdmi.conf"
-If.Hdmi5-iec61937 {
- Condition {
- Type RegexMatch
- Regex "((^|,)[5](,|$))"
- String "${var:Iec61937Pcms1}"
- }
- True.Macro.hdmi5.HdmiPCM { Device 5 Index 0 }
-}
-
-If.Hdmi6-iec61937 {
- Condition {
- Type RegexMatch
- Regex "((^|,)[6](,|$))"
- String "${var:Iec61937Pcms1}"
- }
- True.Macro.hdmi6.HdmiPCM { Device 6 Index 1 }
-}
-
-If.Hdmi7-iec61937 {
- Condition {
- Type RegexMatch
- Regex "((^|,)[7](,|$))"
- String "${var:Iec61937Pcms1}"
- }
- True.Macro.hdmi7.HdmiPCM { Device 7 Index 2 }
-}
+Macro.0.SofHdmiDevice { SofIec61937Pcms "${var:Iec61937Pcms1}" Dev 5 Idx 0 }
+Macro.1.SofHdmiDevice { SofIec61937Pcms "${var:Iec61937Pcms1}" Dev 6 Idx 1 }
+Macro.2.SofHdmiDevice { SofIec61937Pcms "${var:Iec61937Pcms1}" Dev 7 Idx 2 }
If.HdmiIec61937 {
Condition { I think this can even be simplified a bit further by extending the Then we can have DefineRegex in the pcm/hdmi.conf to extract the IDs to SofHdmi ( |
It looks nice. I would just rename |
Yes, the current proposal seems more readable (one line to create one device). |
Right, I have kept the 'Sof' namespacing as the SOF provides the Let me think how to document it if it is converted to a generic macro. |
Hi,
SOF with IPC4 can use 'ChainDMA' on selected PCMs (HDMI/DP currently) which allows them to be used for bytestream passthrough since the data is passed through unmodified.
The kernel will list the PCMs with ChainDMA to the card's components list:
thesofproject/linux#4921
For example for sof-dsp-hda cards
iec61937-pcm:5,4,3
will be added.For user space to use HDMI passthrough, the
hdmi:
PCM device should be present correctly mapping to the machine, for example for sof-dsp-hda:This PR does this by
iec61937-pcm
indexes against the expected HDMI devices (sof-dsp-hda: 3-5, sof-soundwire: 5-7)The generated files are:
[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, mapping
[3] Card specific definitions of the three HDMI port
Note for [1]: I needed to use
shell "echo '...
since thecfg-save
would expand the includes into the saved config file and that just does not result a working alsa configuration.@perexg, I'm sure all this can be done in a cleaner way... We cannot do this unconditionally as if the HDMI is not using ChainDMA (and SOF is not IPC4) then the passthrough is not possible since the firmware might touch the data.