diff mbox series

[alsa-ucm-conf] ucm2: bytcr-rt5640: Add support for swapped speakers

Message ID 20231217215055.50296-1-hdegoede@redhat.com
State New
Headers show
Series [alsa-ucm-conf] ucm2: bytcr-rt5640: Add support for swapped speakers | expand

Commit Message

Hans de Goede Dec. 17, 2023, 9:50 p.m. UTC
Some BYTCR x86 tablets with a rt5640 codec have their speakers
swapped. This is indicated by the kernel by setting cfg-spk:swapped
in the components string. Add support for this.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 ucm2/Intel/bytcr-rt5640/HiFi.conf | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
diff mbox series

Patch

diff --git a/ucm2/Intel/bytcr-rt5640/HiFi.conf b/ucm2/Intel/bytcr-rt5640/HiFi.conf
index fd1906c..7e10db5 100644
--- a/ucm2/Intel/bytcr-rt5640/HiFi.conf
+++ b/ucm2/Intel/bytcr-rt5640/HiFi.conf
@@ -70,6 +70,7 @@  If.spk {
 
 		SectionDevice."Speaker" {
 			EnableSequence [
+				cset "name='DAC IF1 Data Switch' Normal"
 				cset "name='Speaker Switch' on"
 			]
 
@@ -91,6 +92,31 @@  If.mono {
 
 		SectionDevice."Speaker" {
 			EnableSequence [
+				cset "name='DAC IF1 Data Switch' Normal"
+				cset "name='Speaker Switch' on"
+			]
+
+			DisableSequence [
+				cset "name='Speaker Switch' off"
+			]
+		}
+	}
+}
+
+# Note this direcly looks at CardComponents since this is never set
+# by HiFi-LongName.conf
+If.swapped {
+	Condition {
+		Type String
+		Haystack "${CardComponents}"
+		Needle "cfg-spk:swapped"
+	}
+	True {
+		Include.spk.File "/codecs/rt5640/Speaker.conf"
+
+		SectionDevice."Speaker" {
+			EnableSequence [
+				cset "name='DAC IF1 Data Switch' Swap"
 				cset "name='Speaker Switch' on"
 			]
 
@@ -108,6 +134,7 @@  If.hp {
 
 		SectionDevice."Headphones" {
 			EnableSequence [
+				cset "name='DAC IF1 Data Switch' Normal"
 				cset "name='Headphone Switch' on"
 			]
 
@@ -125,6 +152,7 @@  If.hp2 {
 
 		SectionDevice."Headphones2" {
 			EnableSequence [
+				cset "name='DAC IF1 Data Switch' Normal"
 				cset "name='Line Out Switch' on"
 			]