]> git.alsa-project.org Git - alsa-ucm-conf.git/commitdiff
common: introduce DirectUseCase macro
authorJaroslav Kysela <perex@perex.cz>
Tue, 6 Jan 2026 13:37:04 +0000 (14:37 +0100)
committerJaroslav Kysela <perex@perex.cz>
Tue, 6 Jan 2026 19:36:06 +0000 (20:36 +0100)
The goal is to replace the common/direct.conf with this more
universal macro.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
ucm2/common/directm.conf [new file with mode: 0644]

diff --git a/ucm2/common/directm.conf b/ucm2/common/directm.conf
new file mode 100644 (file)
index 0000000..4939f03
--- /dev/null
@@ -0,0 +1,77 @@
+#
+# Define direct use case (no channel split or routing changes) macros
+#
+
+#
+# Macro DirectUseCase
+#
+# Arguments:
+#   Id - Use Case identifier (e.g. "Direct" or "Direct1")
+#   [CardName] - optional, default is global CardName
+#   [Comment] - optional, default is compibed from identifier and CardName
+#   [PlaybackChannels] - optional, playback channels or/and
+#   [CaptureChannels] - optional, capture channels
+#   [PlaybackRate] - optional, in Hz
+#   [CaptureRate] - optional, in Hz
+#
+
+DefineMacro.DirectUseCase {
+       If.cardname {
+               Condition {
+                       Type String
+                       Empty "${var:-__CardName}"
+               }
+               True.Define.__CardName "${CardName}"
+       }
+       If.comment {
+               Condition {
+                       Type String
+                       Empty "${var:-__Comment}"
+               }
+               True.Define.__Comment "${var:__Id} ${var:__CardName}"
+       }
+       SectionUseCase."${var:__Id}" {
+               Comment "Direct ${var:__CardName}"
+               Config.SectionDevice."Direct" {
+                       Comment "Direct ${CardName}"
+                       Value {
+                               If.p {
+                                       Condition {
+                                               Type String
+                                               Empty "${var:-__PlaybackChannels}"
+                                       }
+                                       False {
+                                               PlaybackPriority 1000
+                                               PlaybackChannels "${var:__PlaybackChannels}"
+                                               PlaybackPCM "hw:${CardId}"
+                                       }
+                               }
+                               If.c {
+                                       Condition {
+                                               Type String
+                                               Empty "${var:-__CaptureChannels}"
+                                       }
+                                       False {
+                                               CapturePriority 1000
+                                               CaptureChannels "${var:__CaptureChannels}"
+                                               CapturePCM "hw:${CardId}"
+                                       }
+                               }
+                       }
+                       If.prate {
+                               Condition {
+                                       Type String
+                                       Empty "${var:-__PlaybackRate}"
+                               }
+                               False.Value.PlaybackRate "${var:-__PlaybackRate}"
+                       }
+                       If.crate {
+                               Condition {
+                                       Type String
+                                       Empty "${var:-__CaptureRate}"
+                               }
+                               False.Value.CaptureRate "${var:-__CaptureRate}"
+                       }
+               }
+       }
+}