]> git.alsa-project.org Git - alsa-ucm-conf.git/commitdiff
sof-soundwire: Use one file for speaker codec initialization
authorJaroslav Kysela <perex@perex.cz>
Wed, 6 Dec 2023 14:53:38 +0000 (15:53 +0100)
committerJaroslav Kysela <perex@perex.cz>
Tue, 9 Jan 2024 14:42:44 +0000 (15:42 +0100)
Use macros to minimize configuration blocks.

Closes: https://github.com/alsa-project/alsa-ucm-conf/pull/370
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
ucm2/sof-soundwire/HiFi.conf
ucm2/sof-soundwire/rt1308-1.conf [deleted file]
ucm2/sof-soundwire/rt1308-2.conf [deleted file]
ucm2/sof-soundwire/rt1308.conf [new file with mode: 0644]
ucm2/sof-soundwire/rt1316-1.conf [deleted file]
ucm2/sof-soundwire/rt1316-2.conf [deleted file]
ucm2/sof-soundwire/rt1316.conf [new file with mode: 0644]
ucm2/sof-soundwire/rt1318-1.conf [deleted file]
ucm2/sof-soundwire/rt1318-2.conf [deleted file]
ucm2/sof-soundwire/rt1318.conf [new file with mode: 0644]

index a8c1e3317a9fac49e75fd49c3fca4bce702af0d1..ffea077c40ec48bc8f01c97233c27386065445a7 100644 (file)
@@ -13,7 +13,7 @@ If.spkdev {
                Type String
                Empty "${var:SpeakerCodec1}"
        }
-       False.Include.spkdev.File "/sof-soundwire/${var:SpeakerCodec1}-${var:SpeakerAmps1}.conf"
+       False.Include.spkdev.File "/sof-soundwire/${var:SpeakerCodec1}.conf"
 }
 
 If.micdev {
diff --git a/ucm2/sof-soundwire/rt1308-1.conf b/ucm2/sof-soundwire/rt1308-1.conf
deleted file mode 100644 (file)
index 6da5b7e..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-# Use case Configuration for sof-soundwire card
-
-SectionDevice."Speaker" {
-       Comment "Speaker"
-
-       EnableSequence [
-               cset "name='rt1308-1 DAC L Switch' 1"
-               cset "name='rt1308-1 DAC R Switch' 1"
-               cset "name='Speaker Switch' on"
-       ]
-
-       DisableSequence [
-               cset "name='rt1308-1 DAC L Switch' 0"
-               cset "name='rt1308-1 DAC R Switch' 0"
-               cset "name='Speaker Switch' off"
-       ]
-
-       Value {
-             PlaybackPriority 100
-             PlaybackPCM "hw:${CardId},2"
-       }
-}
diff --git a/ucm2/sof-soundwire/rt1308-2.conf b/ucm2/sof-soundwire/rt1308-2.conf
deleted file mode 100644 (file)
index f88cb81..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-# Use case Configuration for sof-soundwire card
-
-SectionDevice."Speaker" {
-       Comment "Speaker"
-
-       EnableSequence [
-               cset "name='rt1308-1 RX Channel Select' LL"
-               cset "name='rt1308-2 RX Channel Select' RR"
-
-               cset "name='rt1308-1 DAC L Switch' 1"
-               cset "name='rt1308-1 DAC R Switch' 1"
-               cset "name='rt1308-2 DAC L Switch' 1"
-               cset "name='rt1308-2 DAC R Switch' 1"
-               cset "name='Speaker Switch' on"
-       ]
-
-       DisableSequence [
-               cset "name='rt1308-1 DAC L Switch' 0"
-               cset "name='rt1308-1 DAC R Switch' 0"
-               cset "name='rt1308-2 DAC L Switch' 0"
-               cset "name='rt1308-2 DAC R Switch' 0"
-               cset "name='Speaker Switch' off"
-       ]
-
-       Value {
-             PlaybackPriority 100
-             PlaybackPCM "hw:${CardId},2"
-       }
-}
diff --git a/ucm2/sof-soundwire/rt1308.conf b/ucm2/sof-soundwire/rt1308.conf
new file mode 100644 (file)
index 0000000..cce3d13
--- /dev/null
@@ -0,0 +1,46 @@
+# Use case Configuration for sof-soundwire card
+
+#
+# Arguments:
+#   ForAmps - regex filter for var:SpeakerAmps
+#   Amp - amplifier number (1,2 etc.)
+#   Sel - channel selection (LR LL RL RR)
+#
+DefineMacro.rt1308spk.If.0 {
+       Condition {
+               Type RegexMatch
+               Regex "${var:__ForAmps}"
+               String "${var:SpeakerAmps}"
+       }
+       True {
+               EnableSequence [
+                       cset "name='rt1308-${var:__Amp} RX Channel Select' ${var:__Sel}"
+                       cset "name='rt1308-${var:__Amp} DAC L Switch' 1"
+                       cset "name='rt1308-${var:__Amp} DAC R Switch' 1"
+               ]
+               DisableSequence [
+                       cset "name='rt1308-${var:__Amp} DAC L Switch' 0"
+                       cset "name='rt1308-${var:__Amp} DAC R Switch' 0"
+               ]
+       }
+}
+
+SectionDevice."Speaker" {
+       Comment "Speaker"
+
+       Macro.num1.rt1308spk { ForAmps "[12]" Amp 1 Sel LL }
+       Macro.num2.rt1308spk { ForAmps "2" Amp 2 Sel RR }
+
+       EnableSequence [
+               cset "name='Speaker Switch' on"
+       ]
+
+       DisableSequence [
+               cset "name='Speaker Switch' off"
+       ]
+
+       Value {
+             PlaybackPriority 100
+             PlaybackPCM "hw:${CardId},2"
+       }
+}
diff --git a/ucm2/sof-soundwire/rt1316-1.conf b/ucm2/sof-soundwire/rt1316-1.conf
deleted file mode 100644 (file)
index aa277dd..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-# Use case Configuration for sof-soundwire card
-
-SectionDevice."Speaker" {
-       Comment "Speaker"
-
-       If.lrswitch {
-               Condition {
-                       Type ControlExists
-                       Control "name='rt1316-1 DAC L Switch'"
-               }
-               True {
-                       EnableSequence [
-                               cset "name='rt1316-1 DAC L Switch' 1"
-                               cset "name='rt1316-1 DAC R Switch' 1"
-                               cset "name='Speaker Switch' on"
-                       ]
-
-                       DisableSequence [
-                               cset "name='rt1316-1 DAC L Switch' 0"
-                               cset "name='rt1316-1 DAC R Switch' 0"
-                               cset "name='Speaker Switch' off"
-                       ]
-               }
-               False {
-                       EnableSequence [
-                               cset "name='rt1316-1 DAC Switch' 1"
-                               cset "name='Speaker Switch' on"
-                       ]
-
-                       DisableSequence [
-                               cset "name='rt1316-1 DAC Switch' 0"
-                               cset "name='Speaker Switch' off"
-                       ]
-               }
-       }
-
-       Value {
-             PlaybackPriority 100
-             PlaybackPCM "hw:${CardId},2"
-       }
-}
diff --git a/ucm2/sof-soundwire/rt1316-2.conf b/ucm2/sof-soundwire/rt1316-2.conf
deleted file mode 100644 (file)
index 94223e1..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-# Use case Configuration for sof-soundwire card
-
-SectionDevice."Speaker" {
-       Comment "Speaker"
-
-       If.lrswitch {
-               Condition {
-                       Type ControlExists
-                       Control "name='rt1316-1 DAC L Switch'"
-               }
-               True {
-                       EnableSequence [
-                               cset "name='rt1316-1 RX Channel Select' L,L"
-                               cset "name='rt1316-2 RX Channel Select' R,R"
-                               cset "name='rt1316-1 DAC L Switch' 1"
-                               cset "name='rt1316-1 DAC R Switch' 1"
-                               cset "name='rt1316-2 DAC L Switch' 1"
-                               cset "name='rt1316-2 DAC R Switch' 1"
-                               cset "name='Speaker Switch' on"
-                       ]
-
-                       DisableSequence [
-                               cset "name='rt1316-1 DAC L Switch' 0"
-                               cset "name='rt1316-1 DAC R Switch' 0"
-                               cset "name='rt1316-2 DAC L Switch' 0"
-                               cset "name='rt1316-2 DAC R Switch' 0"
-                               cset "name='Speaker Switch' off"
-                       ]
-               }
-               False {
-                       EnableSequence [
-                               cset "name='rt1316-1 RX Channel Select' L,L"
-                               cset "name='rt1316-2 RX Channel Select' R,R"
-                               cset "name='rt1316-1 DAC Switch' 1"
-                               cset "name='rt1316-2 DAC Switch' 1"
-                               cset "name='Speaker Switch' on"
-                       ]
-
-                       DisableSequence [
-                               cset "name='rt1316-1 DAC Switch' 0"
-                               cset "name='rt1316-2 DAC Switch' 0"
-                               cset "name='Speaker Switch' off"
-                       ]
-               }
-       }
-
-       Value {
-             PlaybackPriority 100
-             PlaybackPCM "hw:${CardId},2"
-       }
-}
diff --git a/ucm2/sof-soundwire/rt1316.conf b/ucm2/sof-soundwire/rt1316.conf
new file mode 100644 (file)
index 0000000..a8038b6
--- /dev/null
@@ -0,0 +1,65 @@
+# Use case Configuration for sof-soundwire card
+
+#
+# Arguments:
+#   ForAmps - regex filter for var:SpeakerAmps
+#   Amp - amplifier number (1,2 etc.)
+#   Sel - channel selection (L,R L,L L,R L,L+R R,L R,R R,L+R L+R,L L+R,R L+R,L+R)
+#
+DefineMacro.rt1316spk.If.0 {
+       Condition {
+               Type RegexMatch
+               Regex "${var:__ForAmps}"
+               String "${var:SpeakerAmps}"
+       }
+       True {
+               EnableSequence [
+                       cset "name='rt1316-${var:__Amp} RX Channel Select' ${var:__Sel}"
+               ]
+               If.lrswitch {
+                       Condition {
+                               Type ControlExists
+                               Control "name='rt1316-${var:__Amp} DAC L Switch'"
+                       }
+                       True {
+                               EnableSequence [
+                                       cset "name='rt1316-${var:__Amp} DAC L Switch' 1"
+                                       cset "name='rt1316-${var:__Amp} DAC R Switch' 1"
+                               ]
+                               DisableSequence [
+                                       cset "name='rt1316-${var:__Amp} DAC L Switch' 0"
+                                       cset "name='rt1316-${var:__Amp} DAC R Switch' 0"
+                               ]
+                       }
+                       False {
+                               EnableSequence [
+                                       cset "name='rt1316-${var:__Amp} DAC Switch' 1"
+                               ]
+
+                               DisableSequence [
+                                       cset "name='rt1316-${var:__Amp} DAC Switch' 0"
+                               ]
+                       }
+               }
+       }
+}
+
+SectionDevice."Speaker" {
+       Comment "Speaker"
+
+       Macro.num1.rt1316spk { ForAmps "[12]" Amp 1 Sel "L,L" }
+       Macro.num2.rt1316spk { ForAmps "2" Amp 2 Sel "R,R" }
+
+       EnableSequence [
+               cset "name='Speaker Switch' on"
+       ]
+
+       DisableSequence [
+               cset "name='Speaker Switch' off"
+       ]
+
+       Value {
+             PlaybackPriority 100
+             PlaybackPCM "hw:${CardId},2"
+       }
+}
diff --git a/ucm2/sof-soundwire/rt1318-1.conf b/ucm2/sof-soundwire/rt1318-1.conf
deleted file mode 100644 (file)
index 13d77e1..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-# Use case Configuration for sof-soundwire card
-
-SectionDevice."Speaker" {
-       Comment "Speaker"
-
-       EnableSequence [
-               cset "name='rt1318-1 DAC Switch' 1"
-               cset "name='Speaker Switch' on"
-       ]
-
-       DisableSequence [
-               cset "name='rt1318-1 DAC Switch' 0"
-               cset "name='Speaker Switch' off"
-       ]
-
-       Value {
-             PlaybackPriority 100
-             PlaybackPCM "hw:${CardId},2"
-       }
-}
diff --git a/ucm2/sof-soundwire/rt1318-2.conf b/ucm2/sof-soundwire/rt1318-2.conf
deleted file mode 100644 (file)
index 5602470..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-# Use case Configuration for sof-soundwire card
-
-SectionDevice."Speaker" {
-       Comment "Speaker"
-
-       EnableSequence [
-               cset "name='rt1318-1 RX Channel Select' L,L"
-               cset "name='rt1318-2 RX Channel Select' R,R"
-
-               cset "name='rt1318-1 DAC Switch' 1"
-               cset "name='rt1318-2 DAC Switch' 1"
-               cset "name='Speaker Switch' on"
-       ]
-
-       DisableSequence [
-               cset "name='rt1318-1 DAC Switch' 0"
-               cset "name='rt1318-2 DAC Switch' 0"
-               cset "name='Speaker Switch' off"
-       ]
-
-       Value {
-             PlaybackPriority 100
-             PlaybackPCM "hw:${CardId},2"
-       }
-}
diff --git a/ucm2/sof-soundwire/rt1318.conf b/ucm2/sof-soundwire/rt1318.conf
new file mode 100644 (file)
index 0000000..e40c3be
--- /dev/null
@@ -0,0 +1,44 @@
+# Use case Configuration for sof-soundwire card
+
+#
+# Arguments:
+#   ForAmps - regex filter for var:SpeakerAmps
+#   Amp - amplifier number (1,2 etc.)
+#   Sel - channel selection (L,R L,L L,R L,L+R R,L R,R R,L+R L+R,L L+R,R L+R,L+R)
+#
+DefineMacro.rt1318spk.If.0 {
+       Condition {
+               Type RegexMatch
+               Regex "${var:__RegEx}"
+               String "${var:SpeakerAmps}"
+       }
+       True {
+               EnableSequence [
+                       cset "name='rt1308-${var:__Amp} RX Channel Select' ${var:__Sel}"
+                       cset "name='rt1308-${var:__Amp} DAC Switch' 1"
+               ]
+               DisableSequence [
+                       cset "name='rt1308-${var:__Amp} DAC Switch' 0"
+               ]
+       }
+}
+
+SectionDevice."Speaker" {
+       Comment "Speaker"
+
+       Macro.num1.rt1318spk { ForAmps "[12]" Amp 1 Sel "L,L" }
+       Macro.num2.rt1318spk { ForAmps "2" Amp 2 Sel "R,R" }
+
+       EnableSequence [
+               cset "name='Speaker Switch' on"
+       ]
+
+       DisableSequence [
+               cset "name='Speaker Switch' off"
+       ]
+
+       Value {
+             PlaybackPriority 100
+             PlaybackPCM "hw:${CardId},2"
+       }
+}