--- /dev/null
+#
+# 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}"
+ }
+ }
+ }
+}
--- /dev/null
+#
+# 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}"
+ }
+ }
+ }
+}