From ee39f9ec0c90f64213d50f346b7d15627c8b1be3 Mon Sep 17 00:00:00 2001 From: derek fang Date: Fri, 13 Mar 2026 11:11:34 +0800 Subject: [PATCH] sof-soundwire: rt1320: add playback control switch 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 Signed-off-by: Jaroslav Kysela --- ucm2/codecs/rt1320/init.conf | 67 +++++++++++++++++++++++++++ ucm2/sof-soundwire/rt1320.conf | 7 ++- ucm2/sof-soundwire/sof-soundwire.conf | 2 +- 3 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 ucm2/codecs/rt1320/init.conf diff --git a/ucm2/codecs/rt1320/init.conf b/ucm2/codecs/rt1320/init.conf new file mode 100644 index 0000000..f8f80c5 --- /dev/null +++ b/ucm2/codecs/rt1320/init.conf @@ -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 + } + } + } + } +} diff --git a/ucm2/sof-soundwire/rt1320.conf b/ucm2/sof-soundwire/rt1320.conf index 6d3ddc8..2d5d1e8 100644 --- a/ucm2/sof-soundwire/rt1320.conf +++ b/ucm2/sof-soundwire/rt1320.conf @@ -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" } } diff --git a/ucm2/sof-soundwire/sof-soundwire.conf b/ucm2/sof-soundwire/sof-soundwire.conf index 2f35813..e48f474 100644 --- a/ucm2/sof-soundwire/sof-soundwire.conf +++ b/ucm2/sof-soundwire/sof-soundwire.conf @@ -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}" } } -- 2.52.0