Skip to contentSkip to conversation

bytcr-rt5640: Add support for devices without speakers and/or an internal mic

PATCH Applied Hans de Goede 2 participants 4 messages Jan 9, 2021 – Jan 11, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 bytcr-rt5640: Add support for devices without speakers and/or an internal mic

There are kernel patches pending upstream for the bytcr-rt5640 machine-driver to support devices without speakers and/or an internal mic.

Since the UCM profile already conditionally loads the speaker and internal-mic codec include files, these will simply get skipped in this case, so this almost works with the current UCM profile without changes.

The only troublesome part is the ConflictingDevice sections in the codec HeadPhones.conf and HeadsetMic.conf files, which refer to resp. a "Speaker" and a "Mic" device. Without any of the speaker or mic codec conf files being included there will not by any "Speaker" / "Mic" devices leading to an error while parsing the HeadPhones.conf / HeadsetMic.conf files.

This commit makes the ConflictingDevice section conditional, fixing this.

Cc Rasmus Porsager <[email protected]>
---
 ucm2/bytcr-rt5640/HiFi-Components.conf | 28 +++++++++++++++++++++-----
 ucm2/bytcr-rt5640/HiFi-LongName.conf   | 28 +++++++++++++++++++++-----
 ucm2/codecs/rt5640/HeadPhones.conf     | 14 ++++++++++---
 ucm2/codecs/rt5640/HeadsetMic.conf     | 14 ++++++++++---
 4 files changed, 68 insertions(+), 16 deletions(-)
ucm2/bytcr-rt5640/HiFi-Components.conf +23 -5
index 2ce4f59..a76b42d 100644
@@ -1,10 +1,16 @@
+Define.HaveSpeaker ""
+Define.HaveInternalMic ""
+
 If.spk {
 	Condition {
 		Type String
 		Haystack "${CardComponents}"
 		Needle "cfg-spk:2"
 	}
-	True.Include.spk.File "/codecs/rt5640/Speaker.conf"
+	True {
+		Include.spk.File "/codecs/rt5640/Speaker.conf"
+		Define.HaveSpeaker "yes"
+	}
 }
 
 If.mono {
@@ -13,7 +19,10 @@ If.mono {
 		Haystack "${CardComponents}"
 		Needle "cfg-spk:1"
 	}
-	True.Include.mspk.File "/codecs/rt5640/MonoSpeaker.conf"
+	True {
+		Include.mspk.File "/codecs/rt5640/MonoSpeaker.conf"
+		Define.HaveSpeaker "yes"
+	}
 }
 
 Include.hs.File "/codecs/rt5640/HeadPhones.conf"
@@ -24,7 +33,10 @@ If.dmic1 {
 		Haystack "${CardComponents}"
 		Needle "cfg-mic:dmic1"
 	}
-	True.Include.dmic.File "/codecs/rt5640/DigitalMics.conf"
+	True {
+		Include.dmic.File "/codecs/rt5640/DigitalMics.conf"
+		Define.HaveInternalMic "yes"
+	}
 }
 
 If.in1 {
@@ -33,7 +45,10 @@ If.in1 {
 		Haystack "${CardComponents}"
 		Needle "cfg-mic:in1"
 	}
-	True.Include.mic1.File "/codecs/rt5640/IN1-InternalMic.conf"
+	True {
+		Include.mic1.File "/codecs/rt5640/IN1-InternalMic.conf"
+		Define.HaveInternalMic "yes"
+	}
 }
 
 If.in3 {
@@ -42,7 +57,10 @@ If.in3 {
 		Haystack "${CardComponents}"
 		Needle "cfg-mic:in3"
 	}
-	True.Include.mic3.File "/codecs/rt5640/IN3-InternalMic.conf"
+	True {
+		Include.mic3.File "/codecs/rt5640/IN3-InternalMic.conf"
+		Define.HaveInternalMic "yes"
+	}
 }
 
 Include.hsmic.File "/codecs/rt5640/HeadsetMic.conf"
ucm2/bytcr-rt5640/HiFi-LongName.conf +23 -5
index c07f153..6cb5556 100644
@@ -1,10 +1,16 @@
+Define.HaveSpeaker ""
+Define.HaveInternalMic ""
+
 If.spk {
 	Condition {
 		Type String
 		Haystack "${CardLongName}"
 		Needle "-stereo-spk"
 	}
-	True.Include.spk.File "/codecs/rt5640/Speaker.conf"
+	True {
+		Include.spk.File "/codecs/rt5640/Speaker.conf"
+		Define.HaveSpeaker "yes"
+	}
 }
 
 If.mono {
@@ -13,7 +19,10 @@ If.mono {
 		Haystack "${CardLongName}"
 		Needle "-mono-spk"
 	}
-	True.Include.mspk.File "/codecs/rt5640/MonoSpeaker.conf"
+	True {
+		Include.mspk.File "/codecs/rt5640/MonoSpeaker.conf"
+		Define.HaveSpeaker "yes"
+	}
 }
 
 Include.hs.File "/codecs/rt5640/HeadPhones.conf"
@@ -24,7 +33,10 @@ If.dmic1 {
 		Haystack "${CardLongName}"
 		Needle "-dmic1-mic"
 	}
-	True.Include.dmic.File "/codecs/rt5640/DigitalMics.conf"
+	True {
+		Include.dmic.File "/codecs/rt5640/DigitalMics.conf"
+		Define.HaveInternalMic "yes"
+	}
 }
 
 If.in1 {
@@ -33,7 +45,10 @@ If.in1 {
 		Haystack "${CardLongName}"
 		Needle "-in1-mic"
 	}
-	True.Include.mic1.File "/codecs/rt5640/IN1-InternalMic.conf"
+	True {
+		Include.mic1.File "/codecs/rt5640/IN1-InternalMic.conf"
+		Define.HaveInternalMic "yes"
+	}
 }
 
 If.in3 {
@@ -42,7 +57,10 @@ If.in3 {
 		Haystack "${CardLongName}"
 		Needle "-in3-mic"
 	}
-	True.Include.mic3.File "/codecs/rt5640/IN3-InternalMic.conf"
+	True {
+		Include.mic3.File "/codecs/rt5640/IN3-InternalMic.conf"
+		Define.HaveInternalMic "yes"
+	}
 }
 
 Include.hsmic.File "/codecs/rt5640/HeadsetMic.conf"
ucm2/codecs/rt5640/HeadPhones.conf +11 -3
index 42151d6..b7707e5 100644
@@ -1,9 +1,17 @@
 SectionDevice."Headphones" {
 	Comment "Headphones"
 
-	ConflictingDevice [
-		"Speaker"
-	]
+	If.have-spk {
+		Condition {
+			Type String
+			Empty "${var:HaveSpeaker}"
+		}
+		False {
+			ConflictingDevice [
+				"Speaker"
+			]
+		}
+	}
 
 	EnableSequence [
  		cset "name='DAC MIXL INF1 Switch'  on"
ucm2/codecs/rt5640/HeadsetMic.conf +11 -3
index 7a8dfb8..f88b611 100644
@@ -1,9 +1,17 @@
 SectionDevice."Headset" {
 	Comment "Headset Microphone"
 
-	ConflictingDevice [
-		"Mic"
-	]
+	If.have-mic {
+		Condition {
+			Type String
+			Empty "${var:HaveInternalMic}"
+		}
+		False {
+			ConflictingDevice [
+				"Mic"
+			]
+		}
+	}
 
 	EnableSequence [
 		cset "name='Headset Mic Switch' on"
Signature · 1 line
2.28.0
#1 lore raw

PATCH 2/2 rt5640: Move standard DAC setup to EnableSeq.conf

No matter which output is used, we always need to setup the standard DAC config. Move this to the shared EnableSeq.conf to avoid having to duplicate it in various places.

---
 ucm2/codecs/rt5640/EnableSeq.conf   | 6 ++++++
 ucm2/codecs/rt5640/HeadPhones.conf  | 6 ------
 ucm2/codecs/rt5640/MonoSpeaker.conf | 6 ------
 ucm2/codecs/rt5640/Speaker.conf     | 6 ------
 4 files changed, 6 insertions(+), 18 deletions(-)
ucm2/codecs/rt5640/EnableSeq.conf +6 -0
index cbf4038..145a23b 100644
@@ -1,5 +1,11 @@
 EnableSequence [
 	# RT5640 default output routing
+	cset "name='DAC MIXL INF1 Switch' on"
+	cset "name='DAC MIXR INF1 Switch' on"
+	cset "name='Stereo DAC MIXL DAC L1 Switch' on"
+	cset "name='Stereo DAC MIXR DAC R1 Switch' on"
+	cset "name='Stereo DAC MIXL DAC L2 Switch' on"
+	cset "name='Stereo DAC MIXR DAC R2 Switch' on"
 	cset "name='OUT MIXL DAC L1 Switch'  on"
 	cset "name='OUT MIXR DAC R1 Switch'  on"
 
ucm2/codecs/rt5640/HeadPhones.conf +0 -6
index b7707e5..a9e4d20 100644
@@ -14,12 +14,6 @@ SectionDevice."Headphones" {
 	}
 
 	EnableSequence [
- 		cset "name='DAC MIXL INF1 Switch'  on"
- 		cset "name='DAC MIXR INF1 Switch'  on"
- 		cset "name='Stereo DAC MIXL DAC L1 Switch'  on"
- 		cset "name='Stereo DAC MIXR DAC R1 Switch'  on"
-		cset "name='Stereo DAC MIXL DAC L2 Switch'  on"
- 		cset "name='Stereo DAC MIXR DAC R2 Switch'  on"
  		cset "name='HPO MIX HPVOL Switch'  on"
  		cset "name='Headphone Switch'  on"
 		cset "name='HP Channel Switch' on"
ucm2/codecs/rt5640/MonoSpeaker.conf +0 -6
index ddc7ba8..23cf34c 100644
@@ -6,12 +6,6 @@ SectionDevice."Speaker" {
 	]
 
 	EnableSequence [
-		cset "name='DAC MIXL INF1 Switch' on"
-		cset "name='DAC MIXR INF1 Switch' on"
-		cset "name='Stereo DAC MIXL DAC L1 Switch' on"
-		cset "name='Stereo DAC MIXR DAC R1 Switch' on"
-		cset "name='Stereo DAC MIXL DAC L2 Switch'  on"
-		cset "name='Stereo DAC MIXR DAC R2 Switch'  on"
 		cset "name='SPK MIXL DAC L1 Switch' on"
 		cset "name='SPK MIXR DAC R1 Switch' on"
 		cset "name='SPOL MIX SPKVOL L Switch' on"
ucm2/codecs/rt5640/Speaker.conf +0 -6
index 411cd13..422cfdf 100644
@@ -6,12 +6,6 @@ SectionDevice."Speaker" {
 	]
 
 	EnableSequence [
-		cset "name='DAC MIXL INF1 Switch' on"
-		cset "name='DAC MIXR INF1 Switch' on"
-		cset "name='Stereo DAC MIXL DAC L1 Switch' on"
-		cset "name='Stereo DAC MIXR DAC R1 Switch' on"
-		cset "name='Stereo DAC MIXL DAC L2 Switch'  on"
- 		cset "name='Stereo DAC MIXR DAC R2 Switch'  on"
 		cset "name='SPK MIXL DAC L1 Switch' on"
 		cset "name='SPK MIXR DAC R1 Switch' on"
 		cset "name='SPOL MIX SPKVOL L Switch' on"
Signature · 1 line
2.28.0
#2 lore raw

Re: [PATCH alsa-ucm-conf 2/2] rt5640: Move standard DAC setup to EnableSeq.conf

Dne 09. 01. 21 v 22:02 Hans de Goede napsal(a):

Quoted 3 lines

No matter which output is used, we always need to setup the standard DAC config. Move this to the shared EnableSeq.conf to avoid having to duplicate it in various places.

Applied to the ucm repo. Thank you.

Jaroslav

Signature · 2 lines
Jaroslav Kysela <[email protected]>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.
#3 lore raw
In reply to Hans de Goede

Dne 09. 01. 21 v 22:02 Hans de Goede napsal(a):

Quoted 7 lines

There are kernel patches pending upstream for the bytcr-rt5640 machine-driver to support devices without speakers and/or an internal mic.

Since the UCM profile already conditionally loads the speaker and internal-mic codec include files, these will simply get skipped in this case, so this almost works with the current UCM profile without changes.

Quoted 7 lines

The only troublesome part is the ConflictingDevice sections in the codec HeadPhones.conf and HeadsetMic.conf files, which refer to resp. a "Speaker" and a "Mic" device. Without any of the speaker or mic codec conf files being included there will not by any "Speaker" / "Mic" devices leading to an error while parsing the HeadPhones.conf / HeadsetMic.conf files.

This commit makes the ConflictingDevice section conditional, fixing this.

Applied to the ucm repo. Thank you.

Jaroslav

Signature · 2 lines
Jaroslav Kysela <[email protected]>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.