Skip to contentSkip to conversation

bytcr-wm5102: Add new UCM profile for BYT boards with a WM5102 codec

PATCH In review Hans de Goede 2 participants 4 messages Feb 9, 2021 – Feb 11, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bytcr-wm5102: Add new UCM profile for BYT boards with a WM5102 codec

Add new UCM profile for BYT boards with a WM5102 codec. This has been tested with both the SST and the SOF driver on a
Lenovo Yoga Tablet 2 1051L.

---
 ucm2/SOF/HiFi.conf                      |  9 +++++++++
 ucm2/bytcr-wm5102/HiFi.conf             | 27 +++++++++++++++++++++++++
 ucm2/bytcr-wm5102/bytcr-wm5102.conf     |  6 ++++++
 ucm2/codecs/wm5102/EnableSeq.conf       | 16 +++++++++++++++
 ucm2/codecs/wm5102/HeadPhones.conf      | 23 +++++++++++++++++++++
 ucm2/codecs/wm5102/IN1-HeadsetMic.conf  | 24 ++++++++++++++++++++++
 ucm2/codecs/wm5102/IN3-InternalMic.conf | 23 +++++++++++++++++++++
 ucm2/codecs/wm5102/Speaker.conf         | 22 ++++++++++++++++++++
 8 files changed, 150 insertions(+)
 create mode 100644 ucm2/bytcr-wm5102/HiFi.conf
 create mode 100644 ucm2/bytcr-wm5102/bytcr-wm5102.conf
 create mode 100644 ucm2/codecs/wm5102/EnableSeq.conf
 create mode 100644 ucm2/codecs/wm5102/HeadPhones.conf
 create mode 100644 ucm2/codecs/wm5102/IN1-HeadsetMic.conf
 create mode 100644 ucm2/codecs/wm5102/IN3-InternalMic.conf
 create mode 100644 ucm2/codecs/wm5102/Speaker.conf
ucm2/SOF/HiFi.conf +9 -0
index af0d8c9..adf8cc5 100644
@@ -79,6 +79,15 @@ If.bytcht_max98090 {
 	True.Include.main.File "/chtmax98090/HiFi.conf"
 }
 
+If.bytcht_wm5102 {
+	Condition {
+		Type String
+		Haystack "${CardName}"
+		Needle "bytcht wm5102"
+	}
+	True.Include.main.File "/bytcr-wm5102/HiFi.conf"
+}
+
 If.bdw_rt286 {
 	Condition {
 		Type String
ucm2/bytcr-wm5102/HiFi.conf new file +27 -0
new file mode 100644
index 0000000..1269868
@@ -0,0 +1,27 @@
+SectionVerb {
+
+	Value {
+		TQ "HiFi"
+	}
+
+	Include.e.File "/codecs/wm5102/EnableSeq.conf"
+
+	If.Controls {
+		Condition {
+			Type ControlExists
+			Control "name='media0_in Gain 0 Switch'"
+		}
+		True {
+			Include.pe {
+				File "/platforms/bytcr/PlatformEnableSeq.conf"
+				Before.EnableSequence "0"
+			}
+			Include.pd.File "/platforms/bytcr/PlatformDisableSeq.conf"
+		}
+	}
+}
+
+Include.spk.File "/codecs/wm5102/Speaker.conf"
+Include.hp.File "/codecs/wm5102/HeadPhones.conf"
+Include.mic.File "/codecs/wm5102/IN3-InternalMic.conf"
+Include.headset.File "/codecs/wm5102/IN1-HeadsetMic.conf"
ucm2/bytcr-wm5102/bytcr-wm5102.conf new file +6 -0
new file mode 100644
index 0000000..af966ef
@@ -0,0 +1,6 @@
+Syntax 3
+
+SectionUseCase."HiFi" {
+	File "HiFi.conf"
+	Comment "Play HiFi quality Music"
+}
ucm2/codecs/wm5102/EnableSeq.conf new file +16 -0
new file mode 100644
index 0000000..6a857a2
@@ -0,0 +1,16 @@
+EnableSequence [
+	# Route AIF1 to the speakers and headphones
+	cset "name='SPKOUTL Input 1' AIF1RX1"
+	cset "name='SPKOUTR Input 1' AIF1RX2"
+	cset "name='HPOUT1L Input 1' AIF1RX1"
+	cset "name='HPOUT1R Input 1' AIF1RX2"
+
+	# Both mics are quite soft by default, boost then
+	cset "name='IN1L Volume' 28"
+	cset "name='IN3L Volume' 28"
+
+	cset "name='Headphone Switch' off"
+	cset "name='Headset Mic Switch' off"
+	cset "name='Internal Mic Switch' off"
+	cset "name='Speaker Switch' off"
+]
ucm2/codecs/wm5102/HeadPhones.conf new file +23 -0
new file mode 100644
index 0000000..cb29347
@@ -0,0 +1,23 @@
+SectionDevice."Headphones" {
+	Comment "Headphones"
+
+	Value {
+		PlaybackPriority 200
+		PlaybackPCM "hw:${CardId}"
+		JackControl "Headphone Jack"
+	}
+
+	ConflictingDevice [
+		"Speaker"
+	]
+
+	EnableSequence [
+		cset "name='HPOUT1 Digital Switch' on"
+		cset "name='Headphone Switch' on"
+	]
+
+	DisableSequence [
+		cset "name='HPOUT1 Digital Switch' off"
+		cset "name='Headphone Switch' off"
+	]
+}
ucm2/codecs/wm5102/IN1-HeadsetMic.conf new file +24 -0
new file mode 100644
index 0000000..a607487
@@ -0,0 +1,24 @@
+SectionDevice."Headset" {
+	Comment "Headset Microphone"
+
+	ConflictingDevice [
+		"Mic"
+	]
+
+	EnableSequence [
+		cset "name='AIF1TX1 Input 1' IN1L"
+		cset "name='AIF1TX2 Input 1' IN1L"
+
+		cset "name='Headset Mic Switch' on"
+	]
+
+	DisableSequence [
+		cset "name='Headset Mic Switch' off"
+	]
+
+	Value {
+		CapturePriority 200
+		CapturePCM "hw:${CardId}"
+		JackControl "Headset Mic Jack"
+	}
+}
ucm2/codecs/wm5102/IN3-InternalMic.conf new file +23 -0
new file mode 100644
index 0000000..3a03ac3
@@ -0,0 +1,23 @@
+SectionDevice."Mic" {
+	Comment "Internal Microphone"
+
+	ConflictingDevice [
+		"Headset"
+	]
+
+	EnableSequence [
+		cset "name='AIF1TX1 Input 1' IN3L"
+		cset "name='AIF1TX2 Input 1' IN3L"
+
+		cset "name='Internal Mic Switch' on"
+	]
+
+	DisableSequence [
+		cset "name='Internal Mic Switch' off"
+	]
+
+	Value {
+		CapturePriority 100
+		CapturePCM "hw:${CardId}"
+	}
+}
ucm2/codecs/wm5102/Speaker.conf new file +22 -0
new file mode 100644
index 0000000..9f631f5
@@ -0,0 +1,22 @@
+SectionDevice."Speaker" {
+	Comment "Speakers"
+
+	Value {
+		PlaybackPriority 100
+		PlaybackPCM "hw:${CardId}"
+	}
+
+	ConflictingDevice [
+		"Headphones"
+	]
+
+	EnableSequence [
+		cset "name='Speaker Digital Switch' on"
+		cset "name='Speaker Switch' on"
+	]
+
+	DisableSequence [
+		cset "name='Speaker Digital Switch' off"
+		cset "name='Speaker Switch' off"
+	]
+}
Signature · 1 line
2.30.0
#1 lore raw

Dne 09. 02. 21 v 20:08 Hans de Goede napsal(a):

Quoted 3 lines

Add new UCM profile for BYT boards with a WM5102 codec. This has been tested with both the SST and the SOF driver on a
Lenovo Yoga Tablet 2 1051L.

Hans,

could you also add the configuration for the hardware volume mixer controls?

Thank you,
Jaroslav

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

Hi Jaroslav,

Quoted 8 lines · Jaroslav Kysela

Dne 09. 02. 21 v 20:08 Hans de Goede napsal(a):

Quoted 3 lines

Add new UCM profile for BYT boards with a WM5102 codec. This has been tested with both the SST and the SOF driver on a
Lenovo Yoga Tablet 2 1051L.

Hans,

could you also add the configuration for the hardware volume mixer controls?

I definitely plan to look into those, but that is going to be a codec by codec thing.

I want to start with the codecs which are used in devices with mute LEDs, to see if I can get the LEDs to work in combination with testing the kernel generic alsa led-trigger kernel-patch you send.

So I would prefer for you to merge this as is for now. Together with the wm5102 kernel bits which just landed in -next for 5.12, this will result in working audio at the same level as all the other Intel ASoC using devices.

There are only so much hours in a day... I do want to add HW volume control support to all the codecs used on Intel BYT/CHT boards but this will be something which I need to do on a case by case bases and in my spare time, so this will take a while.

My priority ordering for upcoming UCM work roughly is:

1. Finish testing all codecs with SOF and fix any SOF only UCM (or kernel) issues
2. Add hw volume control for codecs used on devices with mute LEDs
3. Add hw volume control for the most popular codecs (all the rt56?? codecs, which also overlaps with 2.)
4. Deal with the remaining codecs

The wm5102 firmly falls under 4. it is only used in 1 Lenovo design and I only ended up working on it at all because I happen to have such a Lenovo tablet and Pierre-Louis pointed out to me that there already was a machine-driver available in some Android kernels.

Regards,

Hans

#3 lore raw
In reply to Hans de Goede

Dne 09. 02. 21 v 20:08 Hans de Goede napsal(a):

Quoted 5 lines

Add new UCM profile for BYT boards with a WM5102 codec. This has been tested with both the SST and the SOF driver on a
Lenovo Yoga Tablet 2 1051L.

The patch was applied to the alsa-ucm-conf repository.

Jaroslav

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