]> git.alsa-project.org Git - alsa-ucm-conf.git/commitdiff
sof-soundwire: rt1320: add playback control switch
authorderek fang <derek.fang@realtek.com>
Fri, 13 Mar 2026 03:11:34 +0000 (11:11 +0800)
committerJaroslav Kysela <perex@perex.cz>
Thu, 16 Apr 2026 12:00:59 +0000 (14:00 +0200)
This patch defines 'rt1320 OT23' as PlaybackMixerElem and
a remapped one 'rt1320 OT23 Playback Switch' when using one
or two amps.

And also attach rt1320 OT23 controls to speaker LED.

Closes: https://github.com/alsa-project/alsa-ucm-conf/pull/743
Signed-off-by: derek fang <derek.fang@realtek.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
ucm2/codecs/rt1320/init.conf [new file with mode: 0644]
ucm2/sof-soundwire/rt1320.conf
ucm2/sof-soundwire/sof-soundwire.conf

diff --git a/ucm2/codecs/rt1320/init.conf b/ucm2/codecs/rt1320/init.conf
new file mode 100644 (file)
index 0000000..f8f80c5
--- /dev/null
@@ -0,0 +1,67 @@
+# RT1320 amp specific switch control settings
+
+DefineMacro.rt1320spkled.If.0 {
+       Condition {
+               Type RegexMatch
+               Regex "${var:__ForAmps}"
+               String "${var:SpeakerAmps}"
+       }
+       True.Macro [
+               { SetLED { LED="speaker" Action="attach" CtlId="rt1320-${var:__Amp} OT23 L Switch" } }
+               { SetLED { LED="speaker" Action="attach" CtlId="rt1320-${var:__Amp} OT23 R Switch" } }
+       ]
+}
+
+If.spk_init_rt1320 {
+       Condition {
+               Type String
+               Needle "rt1320"
+               Haystack "${var:MultiSpeakerShadow}"
+       }
+       True {
+               Macro.num1.rt1320spkled { ForAmps "[12]" Amp 1 }
+               Macro.num2.rt1320spkled { ForAmps "2" Amp 2 }
+       }
+}
+
+Define.SpeakerMixerElem "rt1320-1 OT23"
+
+If.oneAmp {
+       Condition {
+               Type RegexMatch
+               Regex "1"
+               String "${var:SpeakerAmps}"
+       }
+       True {
+               Define.SpeakerMixerElem "rt1320 OT23"
+               LibraryConfig.remap.Config {
+                       ctl.default.map {
+                               "name='rt1320 OT23 Playback Switch'" {
+                                       "name='rt1320-1 OT23 L Switch'".vindex.0 0
+                                       "name='rt1320-1 OT23 R Switch'".vindex.1 0
+                               }
+                       }
+               }
+       }
+}
+
+If.twoAmps {
+       Condition {
+               Type RegexMatch
+               Regex "2"
+               String "${var:SpeakerAmps}"
+       }
+       True {
+               Define.SpeakerMixerElem "rt1320 OT23"
+               LibraryConfig.remap.Config {
+                       ctl.default.map {
+                               "name='rt1320 OT23 Playback Switch'" {
+                                       "name='rt1320-1 OT23 L Switch'".vindex.0 0
+                                       "name='rt1320-1 OT23 R Switch'".vindex.0 0
+                                       "name='rt1320-2 OT23 L Switch'".vindex.1 0
+                                       "name='rt1320-2 OT23 R Switch'".vindex.1 0
+                               }
+                       }
+               }
+       }
+}
index 6d3ddc8ff28b0b9beeb34f56a70ba17c1794bd99..2d5d1e84f82ed51bb006089b13444075376b5f33 100644 (file)
@@ -41,7 +41,10 @@ SectionDevice."Speaker" {
        ]
 
        Value {
-             PlaybackPriority 100
-             PlaybackPCM "hw:${CardId},2"
+               PlaybackPriority 100
+               PlaybackPCM "hw:${CardId},2"
+               PlaybackMixer "default:${CardId}"
+               PlaybackMixerElem "${var:SpeakerMixerElem}"
+               PlaybackSwitch "${var:SpeakerMixerElem} Playback Switch"
        }
 }
index 2f358135422591ec1a4ca08a97190070700d8c58..e48f4749784b73a9e417520bbdae2a3418040404 100644 (file)
@@ -50,7 +50,7 @@ DefineRegex {
                String "${CardComponents}"
        }
        MultiCodec {
-               Regex "(rt712|rt713|rt721|rt722)"
+               Regex "(rt712|rt713|rt721|rt722|rt1320)"
                String "${var:SpeakerCodec1} ${var:HeadsetCodec1} ${var:MicCodec1}"
        }
 }