[PATCH alsa-ucm-conf 1/1] cht-bsw-rt5672: Add support for the components string

Hans de Goede hdegoede at redhat.com
Sun Apr 4 09:45:21 CEST 2021


Upcoming kernel versions will report which speaker and dmic config is used
by the device in a components strings so that we don't need to duplicate
the DMI quirks in both the kernel and the UCM profile.

Add support for getting the speaker and dmic config from the components string.

Note the old DMI matching is kept for support of older kernels, this means
that on devices where the old DMI matching was used things like:

Define.MonoSpeaker ""

Will now be done twice, this is harmless as long as the kernel and UCM profile
DMI quirks are in sync, which they are.

Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
 ucm2/cht-bsw-rt5672/HiFi.conf | 37 +++++++++++++++++++++++++++++++++--
 1 file changed, 35 insertions(+), 2 deletions(-)

diff --git a/ucm2/cht-bsw-rt5672/HiFi.conf b/ucm2/cht-bsw-rt5672/HiFi.conf
index 5e5f78f..41828ef 100644
--- a/ucm2/cht-bsw-rt5672/HiFi.conf
+++ b/ucm2/cht-bsw-rt5672/HiFi.conf
@@ -7,7 +7,40 @@ Define.DigitalMic1 "yes"
 Define.DigitalMic2 "yes"
 Define.HeadsetMic "yes"
 
-If.cfg-dmic1 {
+# Figure out which components are in use on the device, we check both the
+# components string (present on newer kernels) as well as checking for DMI
+# strings for compatibility with older kernels. Note DMI matches for new
+# models should only be added to the kernel, this UCM profile will then
+# automatically pick up the info from the components string.
+
+If.components-stereo-spk {
+	Condition {
+		Type String
+		Haystack "${CardComponents}"
+		Needle "cfg-spk:2"
+	}
+	True.Define.MonoSpeaker ""
+}
+
+If.components-dmic1 {
+	Condition {
+		Type String
+		Haystack "${CardComponents}"
+		Needle "cfg-mic:dmic1"
+	}
+	True.Define.DigitalMic2 ""
+}
+
+If.components-dmic2 {
+	Condition {
+		Type String
+		Haystack "${CardComponents}"
+		Needle "cfg-mic:dmic2"
+	}
+	True.Define.DigitalMic1 ""
+}
+
+If.dmi-dmic1 {
 	Condition {
 		Type RegexMatch
 		String "${CardLongName}"
@@ -19,7 +52,7 @@ If.cfg-dmic1 {
 	}
 }
 
-If.cfg-dmic2 {
+If.dmi-dmic2 {
 	Condition {
 		Type RegexMatch
 		String "${CardLongName}"
-- 
2.30.2



More information about the Alsa-devel mailing list