]> git.alsa-project.org Git - alsa-ucm-conf.git/commitdiff
sof-soundwire: rework configurations for speaker amplifiers
authorJaroslav Kysela <perex@perex.cz>
Mon, 14 Sep 2026 15:08:46 +0000 (17:08 +0200)
committerJaroslav Kysela <perex@perex.cz>
Mon, 14 Sep 2026 15:44:59 +0000 (17:44 +0200)
Derive SpeakerAmp1 from the "spk:<codec>+<amp>" component and let each
codec config handle the amplifier variant, instead of maintaining
dedicated combined files. Normalize the reverse cs35l56+cs42l43-spk
ordering and drop the now-redundant combined files and symlinks.

Link: https://github.com/alsa-project/alsa-ucm-conf/pull/852
Link: https://github.com/alsa-project/alsa-ucm-conf/pull/855
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
ucm2/codecs/cs35l56+cs42l43-spk [deleted symlink]
ucm2/codecs/cs42l43-spk+cs35l56/init.conf [deleted file]
ucm2/codecs/cs42l43-spk/init.conf
ucm2/sof-soundwire/cs35l56+cs42l43-spk.conf [deleted symlink]
ucm2/sof-soundwire/cs42l43-spk+cs35l56.conf [deleted symlink]
ucm2/sof-soundwire/rt712+rt1320.conf [deleted file]
ucm2/sof-soundwire/rt712.conf
ucm2/sof-soundwire/rt721+rt1320.conf [deleted file]
ucm2/sof-soundwire/rt721.conf
ucm2/sof-soundwire/sof-soundwire.conf

diff --git a/ucm2/codecs/cs35l56+cs42l43-spk b/ucm2/codecs/cs35l56+cs42l43-spk
deleted file mode 120000 (symlink)
index 6f81756..0000000
+++ /dev/null
@@ -1 +0,0 @@
-cs42l43-spk+cs35l56
\ No newline at end of file
diff --git a/ucm2/codecs/cs42l43-spk+cs35l56/init.conf b/ucm2/codecs/cs42l43-spk+cs35l56/init.conf
deleted file mode 100644 (file)
index c3ff43e..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-# cs42l43+cs35l56 specific control settings
-#
-# Arguments:
-#   Amp - amplifier number 1-8
-#
-DefineMacro.cs35l56spkInit.If.0 {
-       Condition {
-               Type ControlExists
-               Control "name='AMP${var:__Amp} Speaker Switch'"
-       }
-       True {
-               LibraryConfig.remap.Config.ctl.default.map {
-                       "name='cs42l43 Speaker Playback Switch'" {
-                               "name='AMP${var:__Amp} Speaker Switch'".vindex.0 0
-                       }
-               }
-               FixedBootSequence [
-                       cset "name='AMP${var:__Amp} Speaker Switch' 0"
-               ]
-               Macro [{ SetLED { LED="speaker" Action="attach" CtlId="AMP${var:__Amp} Speaker Switch" } }]
-       }
-}
-
-LibraryConfig.remap.Config {
-       ctl.default.map {
-               "name='cs42l43 Speaker Playback Switch'" {
-                       "name='cs42l43 Speaker Digital Switch'".vindex.0 [ 0 1 ]
-               }
-       }
-}
-
-Macro [
-       { SetLED { LED="speaker" Action="attach" CtlId="cs42l43 Speaker Digital Switch" } }
-       { cs35l56spkInit { Amp 1 } }
-       { cs35l56spkInit { Amp 2 } }
-       { cs35l56spkInit { Amp 3 } }
-       { cs35l56spkInit { Amp 4 } }
-       { cs35l56spkInit { Amp 5 } }
-       { cs35l56spkInit { Amp 6 } }
-       { cs35l56spkInit { Amp 7 } }
-       { cs35l56spkInit { Amp 8 } }
-]
index 1c0e31c0da306f9e95ff676fa9f942c857e0c8f0..8e4b6c85c87bf43871269e5a9df02259af89bc3a 100644 (file)
@@ -1,14 +1,73 @@
-# cs42l43-spk specific control settings
+# cs42l43-spk settings
 
-LibraryConfig.remap.Config {
-       ctl.default.map {
-               "name='cs42l43 Speaker Playback Switch'" {
-                       "name='cs42l43 Speaker Digital Switch'".vindex.0 0
-                       "name='cs42l43 Speaker Digital Switch'".vindex.1 1
+If.no_amp {
+       # cs42l43-spk specific control settings without amplifier
+       Condition {
+               Type String
+               Empty "${var:SpeakerAmp1}"
+       }
+       True {
+               LibraryConfig.remap.Config {
+                       ctl.default.map {
+                               "name='cs42l43 Speaker Playback Switch'" {
+                                       "name='cs42l43 Speaker Digital Switch'".vindex.0 0
+                                       "name='cs42l43 Speaker Digital Switch'".vindex.1 1
+                               }
+                       }
                }
+               Macro [{ SetLED { LED="speaker" Action="attach" CtlId="cs42l43 Speaker Digital Switch" } }]
        }
 }
 
-Macro [
-       { SetLED { LED="speaker" Action="attach" CtlId="cs42l43 Speaker Digital Switch" } }
-]
\ No newline at end of file
+If.cs35l56_amp {
+       # cs42l43+cs35l56 specific control settings
+       Condition {
+               Type String
+               String1 "${var:SpeakerAmp1}"
+               String2 "cs35l56"
+       }
+
+       True {
+               #
+               # Arguments:
+               #   Amp - amplifier number 1-8
+               #
+               DefineMacro.cs35l56spkInit.If.0 {
+                       Condition {
+                               Type ControlExists
+                               Control "name='AMP${var:__Amp} Speaker Switch'"
+                       }
+                       True {
+                               LibraryConfig.remap.Config.ctl.default.map {
+                                       "name='cs42l43 Speaker Playback Switch'" {
+                                               "name='AMP${var:__Amp} Speaker Switch'".vindex.0 0
+                                       }
+                               }
+                               FixedBootSequence [
+                                       cset "name='AMP${var:__Amp} Speaker Switch' 0"
+                               ]
+                               Macro [{ SetLED { LED="speaker" Action="attach" CtlId="AMP${var:__Amp} Speaker Switch" } }]
+                       }
+               }
+
+               LibraryConfig.remap.Config {
+                       ctl.default.map {
+                               "name='cs42l43 Speaker Playback Switch'" {
+                                       "name='cs42l43 Speaker Digital Switch'".vindex.0 [ 0 1 ]
+                               }
+                       }
+               }
+
+               Macro [
+                       { SetLED { LED="speaker" Action="attach" CtlId="cs42l43 Speaker Digital Switch" } }
+                       { cs35l56spkInit { Amp 1 } }
+                       { cs35l56spkInit { Amp 2 } }
+                       { cs35l56spkInit { Amp 3 } }
+                       { cs35l56spkInit { Amp 4 } }
+                       { cs35l56spkInit { Amp 5 } }
+                       { cs35l56spkInit { Amp 6 } }
+                       { cs35l56spkInit { Amp 7 } }
+                       { cs35l56spkInit { Amp 8 } }
+               ]
+       }
+}
diff --git a/ucm2/sof-soundwire/cs35l56+cs42l43-spk.conf b/ucm2/sof-soundwire/cs35l56+cs42l43-spk.conf
deleted file mode 120000 (symlink)
index 93e49c3..0000000
+++ /dev/null
@@ -1 +0,0 @@
-cs42l43-spk.conf
\ No newline at end of file
diff --git a/ucm2/sof-soundwire/cs42l43-spk+cs35l56.conf b/ucm2/sof-soundwire/cs42l43-spk+cs35l56.conf
deleted file mode 120000 (symlink)
index 93e49c3..0000000
+++ /dev/null
@@ -1 +0,0 @@
-cs42l43-spk.conf
\ No newline at end of file
diff --git a/ucm2/sof-soundwire/rt712+rt1320.conf b/ucm2/sof-soundwire/rt712+rt1320.conf
deleted file mode 100644 (file)
index 4fcad9c..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-# Use case Configuration for sof-soundwire card
-
-#
-# Arguments:
-#   Amp - amplifier number (1,2 etc.)
-#   Sel - channel selection (L,R R,L L,L R,R L,L+R R,L+R L+R,L L+R,R L+R,L+R)
-#
-DefineMacro.rt1320spk {
-       EnableSequence [
-               cset "name='rt1320-${var:__Amp} RX Channel Select' ${var:__Sel}"
-               cset "name='rt1320-${var:__Amp} OT23 L Switch' 1"
-               cset "name='rt1320-${var:__Amp} OT23 R Switch' 1"
-       ]
-       DisableSequence [
-               cset "name='rt1320-${var:__Amp} OT23 L Switch' 0"
-               cset "name='rt1320-${var:__Amp} OT23 R Switch' 0"
-       ]
-}
-
-DefineMacro.rt1320AmpNum.If.0 {
-       Condition {
-               Type ControlExists
-               Control "name='rt1320-2 OT23 L Switch'"
-       }
-       True {
-               Macro.num1.rt1320spk { Amp 1 Sel "L,L" }
-               Macro.num2.rt1320spk { Amp 2 Sel "R,R" }
-       }
-       False {
-               Macro.num1.rt1320spk { Amp 1 Sel "L,R" }
-       }
-}
-
-SectionDevice."Speaker" {
-       Comment "Speaker"
-
-       Macro.num1.rt1320AmpNum { }
-
-       EnableSequence [
-               cset "name='Speaker Switch' on"
-       ]
-
-       DisableSequence [
-               cset "name='Speaker Switch' off"
-       ]
-
-       Value {
-             PlaybackPriority 100
-             PlaybackPCM "hw:${CardId},2"
-       }
-}
index 2165023ae56a5bf7e65c0ccf84549e17105d9c4c..5bc053625ff3790806cd901a969ed23bb85e57cf 100644 (file)
@@ -1,5 +1,36 @@
 # Use case Configuration for sof-soundwire card
 
+#
+# Arguments:
+#   Amp - amplifier number (1,2 etc.)
+#   Sel - channel selection (L,R R,L L,L R,R L,L+R R,L+R L+R,L L+R,R L+R,L+R)
+#
+DefineMacro.rt1320spk {
+       EnableSequence [
+               cset "name='rt1320-${var:__Amp} RX Channel Select' ${var:__Sel}"
+               cset "name='rt1320-${var:__Amp} OT23 L Switch' 1"
+               cset "name='rt1320-${var:__Amp} OT23 R Switch' 1"
+       ]
+       DisableSequence [
+               cset "name='rt1320-${var:__Amp} OT23 L Switch' 0"
+               cset "name='rt1320-${var:__Amp} OT23 R Switch' 0"
+       ]
+}
+
+DefineMacro.rt1320AmpNum.If.0 {
+       Condition {
+               Type ControlExists
+               Control "name='rt1320-2 OT23 L Switch'"
+       }
+       True {
+               Macro.num1.rt1320spk { Amp 1 Sel "L,L" }
+               Macro.num2.rt1320spk { Amp 2 Sel "R,R" }
+       }
+       False {
+               Macro.num1.rt1320spk { Amp 1 Sel "L,R" }
+       }
+}
+
 If.codec_spk {
        Condition {
                Type RegexMatch
@@ -7,6 +38,15 @@ If.codec_spk {
                String "${var:SpeakerCodec1}"
        }
        True {
+               If.amp {
+                       Condition {
+                               Type String
+                               String1 "${var:SpeakerAmp1}"
+                               String2 "rt1320"
+                       }
+                       True.Macro.num1.rt1320AmpNum { }
+               }
+
                SectionDevice."Speaker" {
                        Comment "Speaker"
 
diff --git a/ucm2/sof-soundwire/rt721+rt1320.conf b/ucm2/sof-soundwire/rt721+rt1320.conf
deleted file mode 100644 (file)
index 4fcad9c..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-# Use case Configuration for sof-soundwire card
-
-#
-# Arguments:
-#   Amp - amplifier number (1,2 etc.)
-#   Sel - channel selection (L,R R,L L,L R,R L,L+R R,L+R L+R,L L+R,R L+R,L+R)
-#
-DefineMacro.rt1320spk {
-       EnableSequence [
-               cset "name='rt1320-${var:__Amp} RX Channel Select' ${var:__Sel}"
-               cset "name='rt1320-${var:__Amp} OT23 L Switch' 1"
-               cset "name='rt1320-${var:__Amp} OT23 R Switch' 1"
-       ]
-       DisableSequence [
-               cset "name='rt1320-${var:__Amp} OT23 L Switch' 0"
-               cset "name='rt1320-${var:__Amp} OT23 R Switch' 0"
-       ]
-}
-
-DefineMacro.rt1320AmpNum.If.0 {
-       Condition {
-               Type ControlExists
-               Control "name='rt1320-2 OT23 L Switch'"
-       }
-       True {
-               Macro.num1.rt1320spk { Amp 1 Sel "L,L" }
-               Macro.num2.rt1320spk { Amp 2 Sel "R,R" }
-       }
-       False {
-               Macro.num1.rt1320spk { Amp 1 Sel "L,R" }
-       }
-}
-
-SectionDevice."Speaker" {
-       Comment "Speaker"
-
-       Macro.num1.rt1320AmpNum { }
-
-       EnableSequence [
-               cset "name='Speaker Switch' on"
-       ]
-
-       DisableSequence [
-               cset "name='Speaker Switch' off"
-       ]
-
-       Value {
-             PlaybackPriority 100
-             PlaybackPCM "hw:${CardId},2"
-       }
-}
index 09428fd085f97ebb9ed45dc11c1f87faace0e5c5..65b4f01cb1e31b24682b4470fbd3296385437931 100644 (file)
@@ -1,5 +1,36 @@
 # Use case Configuration for sof-soundwire card
 
+#
+# Arguments:
+#   Amp - amplifier number (1,2 etc.)
+#   Sel - channel selection (L,R R,L L,L R,R L,L+R R,L+R L+R,L L+R,R L+R,L+R)
+#
+DefineMacro.rt1320spk {
+       EnableSequence [
+               cset "name='rt1320-${var:__Amp} RX Channel Select' ${var:__Sel}"
+               cset "name='rt1320-${var:__Amp} OT23 L Switch' 1"
+               cset "name='rt1320-${var:__Amp} OT23 R Switch' 1"
+       ]
+       DisableSequence [
+               cset "name='rt1320-${var:__Amp} OT23 L Switch' 0"
+               cset "name='rt1320-${var:__Amp} OT23 R Switch' 0"
+       ]
+}
+
+DefineMacro.rt1320AmpNum.If.0 {
+       Condition {
+               Type ControlExists
+               Control "name='rt1320-2 OT23 L Switch'"
+       }
+       True {
+               Macro.num1.rt1320spk { Amp 1 Sel "L,L" }
+               Macro.num2.rt1320spk { Amp 2 Sel "R,R" }
+       }
+       False {
+               Macro.num1.rt1320spk { Amp 1 Sel "L,R" }
+       }
+}
+
 If.codecmic {
        Condition {
                Type RegexMatch
@@ -36,6 +67,15 @@ If.codecspk {
                String "${var:SpeakerCodec1}"
        }
        True {
+               If.amp {
+                       Condition {
+                               Type String
+                               String1 "${var:SpeakerAmp1}"
+                               String2 "rt1320"
+                       }
+                       True.Macro.num1.rt1320AmpNum { }
+               }
+
                SectionDevice."Speaker" {
                        Comment "Speaker"
 
index d9155e29c62869e816f34fb04a4858a2e8a67eaa..95bd28b8d737687a93a385c107cc455ed7d67e82 100644 (file)
@@ -11,6 +11,7 @@ Include.ctl-remap.File "/lib/ctl-remap.conf"
 
 Define {
        SpeakerCodec1 ""
+       SpeakerAmp1 ""
        SpeakerChannels1 "2"
        SpeakerAmps1 "0"
        HeadsetCodec1 ""
@@ -60,12 +61,25 @@ DefineRegex {
 If.old_multi_spk {
        Condition {
                Type RegexMatch
-               Regex "(spk:cs42l43-spk .*spk:cs35l56( |$))|(spk:cs35l56 .*spk:cs42l43-spk( |$))"
+               Regex "(spk:cs42l43-spk .*spk:cs35l56( |$))|(spk:cs35l56 .*spk:cs42l43-spk( |$))|(spk:cs35l56\\+cs42l43-spk( |$))"
                String "${CardComponents}"
        }
        True.Define.SpeakerCodec1 "cs42l43-spk+cs35l56"
 }
 
+# for speaker, do codec+amplifier split
+If.spk_amp_split1.Append.DefineRegex.SpeakerSplit {
+       Regex "([a-z0-9-]+)\\+([a-z0-9-]+)"
+       String "${var:SpeakerCodec1}"
+}
+If.spk_amp_split2 {
+       Condition { Type String Empty "${var:-SpeakerSplit1}" }
+       False.Define {
+               SpeakerCodec1 "${var:SpeakerSplit1}"
+               SpeakerAmp1 "${var:SpeakerSplit2}"
+       }
+}
+
 # set default file variables after regex evaluation
 If.codec_default.Append.Define {
        SpeakerCodecFile "${var:SpeakerCodec1}"
@@ -134,7 +148,7 @@ If.spk {
        False.If.filter {
                Condition {
                        Type RegexMatch
-                       Regex "(${var:MultiCodecRegex}|tas2783|rt1318|cs42l43-spk(\\+cs35l56)?|cs35l56((-bridge)|(\\+cs42l43-spk))?)"
+                       Regex "(${var:MultiCodecRegex}|tas2783|rt1318|cs42l43-spk|cs35l56(-bridge)?)"
                        String "${var:SpeakerCodecFile}"
                }
                True.Include.a.File "/codecs/${var:SpeakerCodecFile}/init.conf"