]> git.alsa-project.org Git - alsa-ucm-conf.git/commitdiff
Add common/ctl/remap.conf and common/pcm/split.conf
authorJaroslav Kysela <perex@perex.cz>
Tue, 17 May 2022 17:30:56 +0000 (19:30 +0200)
committerJaroslav Kysela <perex@perex.cz>
Fri, 27 May 2022 08:16:28 +0000 (10:16 +0200)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
ucm2/common/ctl/remap.conf [new file with mode: 0644]
ucm2/common/pcm/split.conf [new file with mode: 0644]

diff --git a/ucm2/common/ctl/remap.conf b/ucm2/common/ctl/remap.conf
new file mode 100644 (file)
index 0000000..9ee7cdf
--- /dev/null
@@ -0,0 +1,50 @@
+#
+# Remap controls
+#
+
+#
+# Macro CtlRemapMonoVolSw
+#
+# Arguments:
+#   Dst - Destination control name
+#   Src - Source control name
+#   Index - hardware index for value 0 (mono)
+#
+
+DefineMacro.CtlRemapMonoVolSw {
+       LibraryConfig.pcm.SubstiConfig {
+               ctl.default.map {
+                       "name='${var:__Src} Volume'"."name='${var:__Dst} Volume'" {
+                               vindex.0 "${evali:$__Index}"
+                       }
+                       "name='${var:__Src} Switch'"."name='${var:__Dst} Switch'" {
+                               vindex.0 "${evali:$__Index}"
+                       }
+               }
+       }
+}
+
+#
+# Macro CtlRemapStereoVolSw
+#
+# Arguments:
+#   Dst - Destination control name
+#   Src - Source control name
+#   Index0 - hardware index for the application index 0
+#   Index1 - hardware index for the application index 1
+#
+
+DefineMacro.CtlRemapStereoVolSw {
+       LibraryConfig.pcm.SubstiConfig {
+               ctl.default.map {
+                       "name='${var:__Src} Volume'"."name='${var:__Dst} Volume'" {
+                               vindex.0 "${evali:$__Index0}"
+                               vindex.1 "${evali:$__Index1}"
+                       }
+                       "name='${var:__Src} Switch'"."name='${var:__Dst} Switch'" {
+                               vindex.0 "${evali:$__Index0}"
+                               vindex.1 "${evali:$__Index1}"
+                       }
+               }
+       }
+}
diff --git a/ucm2/common/pcm/split.conf b/ucm2/common/pcm/split.conf
new file mode 100644 (file)
index 0000000..b0596c1
--- /dev/null
@@ -0,0 +1,164 @@
+#
+# Split multichannel PCM stream to channel groups
+#
+
+#
+# Macro SplitPCM
+#
+# Application variable:
+#   @SplitPCM - defined, return channel description using UCM values
+#
+# Arguments:
+#   Name - PCM name (alsa-lib)
+#   Direction - "Playback" or "Capture"
+#   Channels - application channels
+#   HWChannels - hardware channels
+#   HWChannelPos0 - channel position (MONO FR FL etc. - see alsa-lib's strings)
+#   [HWChannelPos1] - channel position (MONO FR FL etc. - see alsa-lib's strings)
+#
+
+DefineMacro.SplitPCM.If.0 {
+       Condition {
+               Type String
+               Empty "${var:@SplitPCM}"
+       }
+       True {
+               LibraryConfig.pcm.SubstiConfig.pcm."${var:__Name}" {
+                       @args [ CARD DEV CHN0 ]
+                       @args {
+                               CARD.type string
+                               DEV.type integer
+                               CHN0.type integer
+                       }
+                       ipc_key 6678293
+                       type dshare
+                       slave {
+                               pcm {
+                                       type hw
+                                       card $CARD
+                                       device $DEV
+                                       chmap [ "${var:__HWChannelPos0}" ]
+                               }
+                               channels "${evali:$__HWChannels}"
+                       }
+                       bindings.0 $CHN0
+               }
+
+               If.pos1 {
+                       Condition {
+                               Type String
+                               Empty "${var:__HWChannelPos1}"
+                       }
+                       False.LibraryConfig.pos1.SubstiConfig.pcm."${var:__Name}" {
+                               slave.pcm.chmap [ "${var:__HWChannelPos1}" ]
+                       }
+               }
+               If.pos2 {
+                       Condition {
+                               Type String
+                               Empty "${var:-__HWChannelPos2}"
+                       }
+                       False.LibraryConfig.pos2.SubstiConfig.pcm."${var:__Name}" {
+                               slave.pcm.chmap [ "${var:-__HWChannelPos2}" ]
+                       }
+               }
+               If.pos3 {
+                       Condition {
+                               Type String
+                               Empty "${var:-__HWChannelPos3}"
+                       }
+                       False.LibraryConfig.pos3.SubstiConfig.pcm."${var:__Name}" {
+                               slave.pcm.chmap [ "${var:-__HWChannelPos3}" ]
+                       }
+               }
+
+               If.ch1 {
+                       Condition {
+                               Type RegexMatch
+                               Regex "^([2-9]|[1-9][0-9])$"
+                               String "${var:__Channels}"
+                       }
+                       True.LibraryConfig.ch1.SubstiConfig.pcm."${var:__Name}" {
+                               @args.3 CHN1
+                               @args { CHN1.type integer }
+                               bindings.1 $CHN1
+                       }
+               }
+
+               If.dir {
+                       Condition {
+                               Type String
+                               String1 "${var:__Direction}"
+                               String2 "Capture"
+                       }
+                       True.LibraryConfig.dir.Config.pcm."${var:__Name}".type dsnoop
+               }
+       }
+}
+
+#
+# Macro SplitPCMDevice
+#
+# Application variable:
+#   @SplitPCM - defined, return channel description using UCM values
+#
+# Arguments:
+#   Name - PCM name (alsa-lib)
+#   Direction - "Playback" or "Capture"
+#   Device - hardware PCM device number (optional - default 0)
+#   Channels - count of application channels
+#   HWChannels - total channels (in hardware)
+#   Channel0 - channel index in stream for the destination channel 0
+#   [Channel1] - channel index in stream for the destination channel 1 (optional)
+#   ChannelPos0 - channel position (MONO FR FL etc. - see alsa-lib's strings
+#   [ChannelPos1] - channel position (MONO FR FL etc. - see alsa-lib's strings)
+#
+
+DefineMacro.SplitPCMDevice {
+       Define.__dev ""
+       If.0 {
+               Condition {
+                       Type String
+                       Empty "${var:__dev}"
+               }
+               True.Define.__dev "0"
+       }
+       If.1 {
+               Condition {
+                       Type String
+                       Empty "${var:@SplitPCM}"
+               }
+               False {
+                       Value {
+                               "${var:__Direction}Channels" "${var:__HWChannels}"
+                               "${var:__Direction}PCM" "hw:${CardId},${var:__dev}"
+                               "${var:__Direction}Channel0" "${var:__Channel0}"
+                               "${var:__Direction}ChannelPos0" "${var:__ChannelPos0}"
+                       }
+                       If.ch1 {
+                               Condition {
+                                       Type String
+                                       Empty "${var:-__Channel1}"
+                               }
+                               False.Value {
+                                       "${var:__Direction}Channel1" "${var:__Channel1}"
+                                       "${var:__Direction}ChannelPos1" "${var:__ChannelPos1}"
+                               }
+                       }
+               }
+               True {
+                       Define.__pcmdev "${var:__Name}:${CardId},${var:__dev},${var:__Channel0}"
+                       If.ch1 {
+                               Condition {
+                                       Type String
+                                       Empty "${var:-__Channel1}"
+                               }
+                               False.Define.__pcmdev "${var:__pcmdev},${var:__Channel1}"
+                       }
+                       Value {
+                               "${var:__Direction}Channels" "${var:__Channels}"
+                               "${var:__Direction}PCM" "${var:__pcmdev}"
+                       }
+               }
+       }
+}