From: Jaroslav Kysela Date: Mon, 14 Sep 2026 15:08:46 +0000 (+0200) Subject: sof-soundwire: rework configurations for speaker amplifiers X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=ba372ade3434dfc802f6332cad874b6957456adb;p=alsa-ucm-conf.git sof-soundwire: rework configurations for speaker amplifiers Derive SpeakerAmp1 from the "spk:+" 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 --- diff --git a/ucm2/codecs/cs35l56+cs42l43-spk b/ucm2/codecs/cs35l56+cs42l43-spk deleted file mode 120000 index 6f81756..0000000 --- a/ucm2/codecs/cs35l56+cs42l43-spk +++ /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 index c3ff43e..0000000 --- a/ucm2/codecs/cs42l43-spk+cs35l56/init.conf +++ /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 } } -] diff --git a/ucm2/codecs/cs42l43-spk/init.conf b/ucm2/codecs/cs42l43-spk/init.conf index 1c0e31c..8e4b6c8 100644 --- a/ucm2/codecs/cs42l43-spk/init.conf +++ b/ucm2/codecs/cs42l43-spk/init.conf @@ -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 index 93e49c3..0000000 --- a/ucm2/sof-soundwire/cs35l56+cs42l43-spk.conf +++ /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 index 93e49c3..0000000 --- a/ucm2/sof-soundwire/cs42l43-spk+cs35l56.conf +++ /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 index 4fcad9c..0000000 --- a/ucm2/sof-soundwire/rt712+rt1320.conf +++ /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" - } -} diff --git a/ucm2/sof-soundwire/rt712.conf b/ucm2/sof-soundwire/rt712.conf index 2165023..5bc0536 100644 --- a/ucm2/sof-soundwire/rt712.conf +++ b/ucm2/sof-soundwire/rt712.conf @@ -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 index 4fcad9c..0000000 --- a/ucm2/sof-soundwire/rt721+rt1320.conf +++ /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" - } -} diff --git a/ucm2/sof-soundwire/rt721.conf b/ucm2/sof-soundwire/rt721.conf index 09428fd..65b4f01 100644 --- a/ucm2/sof-soundwire/rt721.conf +++ b/ucm2/sof-soundwire/rt721.conf @@ -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" diff --git a/ucm2/sof-soundwire/sof-soundwire.conf b/ucm2/sof-soundwire/sof-soundwire.conf index d9155e2..95bd28b 100644 --- a/ucm2/sof-soundwire/sof-soundwire.conf +++ b/ucm2/sof-soundwire/sof-soundwire.conf @@ -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"