All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Jaroslav Kysela <perex@perex.cz>
Cc: Rasmus Porsager <rasmus@beat.dk>,
	Hans de Goede <hdegoede@redhat.com>,
	alsa-devel@alsa-project.org,
	Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Subject: [PATCH alsa-ucm-conf 1/2] bytcr-rt5640: Add support for devices without speakers and/or an internal mic
Date: Sat,  9 Jan 2021 22:02:51 +0100	[thread overview]
Message-ID: <20210109210252.159162-1-hdegoede@redhat.com> (raw)

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 <rasmus@beat.dk>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 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(-)

diff --git a/ucm2/bytcr-rt5640/HiFi-Components.conf b/ucm2/bytcr-rt5640/HiFi-Components.conf
index 2ce4f59..a76b42d 100644
--- a/ucm2/bytcr-rt5640/HiFi-Components.conf
+++ b/ucm2/bytcr-rt5640/HiFi-Components.conf
@@ -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"
diff --git a/ucm2/bytcr-rt5640/HiFi-LongName.conf b/ucm2/bytcr-rt5640/HiFi-LongName.conf
index c07f153..6cb5556 100644
--- a/ucm2/bytcr-rt5640/HiFi-LongName.conf
+++ b/ucm2/bytcr-rt5640/HiFi-LongName.conf
@@ -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"
diff --git a/ucm2/codecs/rt5640/HeadPhones.conf b/ucm2/codecs/rt5640/HeadPhones.conf
index 42151d6..b7707e5 100644
--- a/ucm2/codecs/rt5640/HeadPhones.conf
+++ b/ucm2/codecs/rt5640/HeadPhones.conf
@@ -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"
diff --git a/ucm2/codecs/rt5640/HeadsetMic.conf b/ucm2/codecs/rt5640/HeadsetMic.conf
index 7a8dfb8..f88b611 100644
--- a/ucm2/codecs/rt5640/HeadsetMic.conf
+++ b/ucm2/codecs/rt5640/HeadsetMic.conf
@@ -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"
-- 
2.28.0


             reply	other threads:[~2021-01-09 21:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-09 21:02 Hans de Goede [this message]
2021-01-09 21:02 ` [PATCH alsa-ucm-conf 2/2] rt5640: Move standard DAC setup to EnableSeq.conf Hans de Goede
2021-01-11 19:00   ` Jaroslav Kysela
2021-01-11 18:59 ` [PATCH alsa-ucm-conf 1/2] bytcr-rt5640: Add support for devices without speakers and/or an internal mic Jaroslav Kysela

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210109210252.159162-1-hdegoede@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=perex@perex.cz \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=rasmus@beat.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.