alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH alsa-ucm-conf v2 0/7] codecs/rt5640: Cleanup + HW volume control support
@ 2021-03-08 22:05 Hans de Goede
  2021-03-08 22:05 ` [PATCH alsa-ucm-conf v2 1/7] codecs/rt5640: Cleanup: unify Stereo / Mono ADC handling Hans de Goede
                   ` (7 more replies)
  0 siblings, 8 replies; 11+ messages in thread
From: Hans de Goede @ 2021-03-08 22:05 UTC (permalink / raw)
  To: Jaroslav Kysela
  Cc: Hans de Goede, alsa-devel, Pierre-Louis Bossart, Bard Liao

Hi All,

Here is v2 of my patch series consisting of some codecs/rt5640 cleanups
and addition of HW volume control support to the rt5640 .conf snippets.

This new version has been updated to deal with the
"[PATCH 3/5] ASoC: rt5640: Add emulated 'DAC1 Playback Switch' control"
kernel-patch being dropped.

Note patch 7 depends on a new "aif:%d" part being added to the
components string, the kernel patches for this are pending upstream
in the "[PATCH resend 0/2] AsoC: rt5640/rt5651: Volume control fixes"
patch-series.

As such patch 7 should probably not be merged until the kernel patches
have landed, because theoretically the new component string part could
change as part of the review of the kernel patches.

Patches 1-6 are ready to be merged now.

Regards,

Hans



Hans de Goede (7):
  codecs/rt5640: Cleanup: unify Stereo / Mono ADC handling
  codecs/rt5640: Cleanup: Initially disable all inputs and outputs
  codecs/rt5640: Cleanup: Move 'SPK MIX' setup to main EnableSequene
  codecs/rt5640: Drop bogus 'DIG MIXL DAC L2 Switch' setting
  codecs/rt5640: Unify capture volume for AIF1 and AIF2 recording paths
  codecs/rt5640: Add hardware volume-control support
  codecs/rt5640: Specify Playback/CaptureMasterElem for HW
    volume-control

 ucm2/bytcr-rt5640/HiFi.conf             | 21 +++++++++++
 ucm2/codecs/rt5640/DigitalMics.conf     | 18 ++++++++-
 ucm2/codecs/rt5640/EnableSeq.conf       | 50 ++++++++++++++++++++-----
 ucm2/codecs/rt5640/HeadPhones.conf      | 15 +++++++-
 ucm2/codecs/rt5640/HeadsetMic.conf      | 24 ++++++++----
 ucm2/codecs/rt5640/IN1-InternalMic.conf | 27 +++++++------
 ucm2/codecs/rt5640/IN3-InternalMic.conf | 27 +++++++------
 ucm2/codecs/rt5640/MonoSpeaker.conf     | 17 +++++++--
 ucm2/codecs/rt5640/Speaker.conf         | 17 +++++++--
 9 files changed, 167 insertions(+), 49 deletions(-)

-- 
2.30.1


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH alsa-ucm-conf v2 1/7] codecs/rt5640: Cleanup: unify Stereo / Mono ADC handling
  2021-03-08 22:05 [PATCH alsa-ucm-conf v2 0/7] codecs/rt5640: Cleanup + HW volume control support Hans de Goede
@ 2021-03-08 22:05 ` Hans de Goede
  2021-03-08 22:05 ` [PATCH alsa-ucm-conf v2 2/7] codecs/rt5640: Cleanup: Initially disable all inputs and outputs Hans de Goede
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Hans de Goede @ 2021-03-08 22:05 UTC (permalink / raw)
  To: Jaroslav Kysela
  Cc: Hans de Goede, alsa-devel, Pierre-Louis Bossart, Bard Liao

Cleanup: no functional changes intended.

The rt5640 codec is sometimes used with AIF1 connected to the SoC
and sometimes with AIF2 connected to the SoC.

The rt5640 UCM configuration deals with this by accepting input from
and sending output to both AIFs, relying on the kernels DAPM framework to
disable parts of the graph which are connected to the unconnected AIF.

On the output side we solve this by enabling both the IF1_DAC and
IF2_DAC data inputs to the digital 'Stereo DAC MIX' mixer.

On the input side handling this is somewhat more complicated, the
"Digital Mixer Path" leading to the IF1_ADC and IF2_ADC outputs
are entirely separate paths. To solve this we enable the active
input (DMIC or ADC) in both the Stereo ADC (connected to IF1_ADC)
and the Mono ADC (IF2_ADC) paths.

So far we've not been entirely consistent in our handling of
the Stereo ADC vs Mono ADC paths, this commit cleans this up:

1. Set the 'Mono ADC Capture Switch' to on once from EnableSeq.conf,
   like we do for the 'ADC Capture Switch' instead of toggling it on/off
   from the individual input Enable/Disable sequences.

2. Group all the 'Mono ADC ...' mixer cset calls together with their
   stereo ADC counterparts.

3. Explicitly select DMIC L/R 1 for the Mono ADC L/R 2 Mux input, instead
   of relying on this being the default.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 ucm2/codecs/rt5640/DigitalMics.conf     |  2 --
 ucm2/codecs/rt5640/EnableSeq.conf       | 10 +++++++---
 ucm2/codecs/rt5640/HeadsetMic.conf      | 10 ++--------
 ucm2/codecs/rt5640/IN1-InternalMic.conf | 11 ++---------
 ucm2/codecs/rt5640/IN3-InternalMic.conf | 11 ++---------
 5 files changed, 13 insertions(+), 31 deletions(-)

diff --git a/ucm2/codecs/rt5640/DigitalMics.conf b/ucm2/codecs/rt5640/DigitalMics.conf
index fdd412f..157c544 100644
--- a/ucm2/codecs/rt5640/DigitalMics.conf
+++ b/ucm2/codecs/rt5640/DigitalMics.conf
@@ -8,7 +8,6 @@ SectionDevice."Mic" {
 	EnableSequence [
 		cset "name='Mono ADC MIXL ADC2 Switch' on"
 		cset "name='Mono ADC MIXR ADC2 Switch' on"
-		cset "name='Mono ADC Capture Switch' on"
 		cset "name='Stereo ADC MIXL ADC2 Switch' on"
 		cset "name='Stereo ADC MIXR ADC2 Switch' on"
 		cset "name='Internal Mic Switch' on"
@@ -18,7 +17,6 @@ SectionDevice."Mic" {
 	DisableSequence [
 		cset "name='Mono ADC MIXL ADC2 Switch' off"
 		cset "name='Mono ADC MIXR ADC2 Switch' off"
-		cset "name='Mono ADC Capture Switch' off"
 		cset "name='Stereo ADC MIXL ADC2 Switch' off"
 		cset "name='Stereo ADC MIXR ADC2 Switch' off"
 		cset "name='Internal Mic Switch' off"
diff --git a/ucm2/codecs/rt5640/EnableSeq.conf b/ucm2/codecs/rt5640/EnableSeq.conf
index 145a23b..4754df7 100644
--- a/ucm2/codecs/rt5640/EnableSeq.conf
+++ b/ucm2/codecs/rt5640/EnableSeq.conf
@@ -30,8 +30,13 @@ EnableSequence [
 	# Input Configuration
 	cset "name='Stereo ADC1 Mux' ADC"
 	cset "name='Stereo ADC2 Mux' DMIC1"
-	cset "name='Mono ADC L1 Mux' 1"
-	cset "name='Mono ADC R1 Mux' 1"
+	cset "name='ADC Capture Switch' on"
+
+	cset "name='Mono ADC L1 Mux' ADCL"
+	cset "name='Mono ADC R1 Mux' ADCR"
+	cset "name='Mono ADC L2 Mux' DMIC L1"
+	cset "name='Mono ADC R2 Mux' DMIC R1"
+	cset "name='Mono ADC Capture Switch' on"
 
 	# 47=0dB, 0.375 dB/step, set it to 6 dB to help with soft mics
 	cset "name='ADC Capture Volume' 63"
@@ -45,5 +50,4 @@ EnableSequence [
 
 	cset "name='Internal Mic Switch' off"
 	cset "name='Headset Mic Switch' off"
-	cset "name='ADC Capture Switch' on"
 ]
diff --git a/ucm2/codecs/rt5640/HeadsetMic.conf b/ucm2/codecs/rt5640/HeadsetMic.conf
index f88b611..829e4e6 100644
--- a/ucm2/codecs/rt5640/HeadsetMic.conf
+++ b/ucm2/codecs/rt5640/HeadsetMic.conf
@@ -21,26 +21,20 @@ SectionDevice."Headset" {
 
 		cset "name='Stereo ADC MIXL ADC1 Switch' on"
 		cset "name='Stereo ADC MIXR ADC1 Switch' on"
-
 		cset "name='Mono ADC MIXL ADC1 Switch' on"
 		cset "name='Mono ADC MIXR ADC1 Switch' on"
-
-		cset "name='Mono ADC Capture Switch' on"
 	]
 
 	DisableSequence [
 		cset "name='Stereo ADC MIXL ADC1 Switch' off"
 		cset "name='Stereo ADC MIXR ADC1 Switch' off"
+		cset "name='Mono ADC MIXL ADC1 Switch' off"
+		cset "name='Mono ADC MIXR ADC1 Switch' off"
 
 		cset "name='RECMIXL BST2 Switch' off"
 		cset "name='RECMIXR BST2 Switch' off"
 
 		cset "name='Headset Mic Switch' off"
-
-		cset "name='Mono ADC MIXL ADC1 Switch' off"
-		cset "name='Mono ADC MIXR ADC1 Switch' off"
-
-		cset "name='Mono ADC Capture Switch' off"
 	]
 
 	Value {
diff --git a/ucm2/codecs/rt5640/IN1-InternalMic.conf b/ucm2/codecs/rt5640/IN1-InternalMic.conf
index ebb5b6d..260df90 100644
--- a/ucm2/codecs/rt5640/IN1-InternalMic.conf
+++ b/ucm2/codecs/rt5640/IN1-InternalMic.conf
@@ -15,27 +15,20 @@ SectionDevice."Mic" {
 
 		cset "name='Stereo ADC MIXL ADC1 Switch' on"
 		cset "name='Stereo ADC MIXR ADC1 Switch' on"
-
 		cset "name='Mono ADC MIXL ADC1 Switch' on"
 		cset "name='Mono ADC MIXR ADC1 Switch' on"
-
-		cset "name='Mono ADC Capture Switch' on"
 	]
 
 	DisableSequence [
 		cset "name='Stereo ADC MIXL ADC1 Switch' off"
 		cset "name='Stereo ADC MIXR ADC1 Switch' off"
+		cset "name='Mono ADC MIXL ADC1 Switch' off"
+		cset "name='Mono ADC MIXR ADC1 Switch' off"
 
 		cset "name='RECMIXL BST1 Switch' off"
 		cset "name='RECMIXR BST1 Switch' off"
 
 		cset "name='Internal Mic Switch' off"
-
-		cset "name='Mono ADC MIXL ADC1 Switch' off"
-		cset "name='Mono ADC MIXR ADC1 Switch' off"
-
-		cset "name='Mono ADC Capture Switch' off"
-
 	]
 
 	Value {
diff --git a/ucm2/codecs/rt5640/IN3-InternalMic.conf b/ucm2/codecs/rt5640/IN3-InternalMic.conf
index 172d909..ebd2b9c 100644
--- a/ucm2/codecs/rt5640/IN3-InternalMic.conf
+++ b/ucm2/codecs/rt5640/IN3-InternalMic.conf
@@ -15,27 +15,20 @@ SectionDevice."Mic" {
 
 		cset "name='Stereo ADC MIXL ADC1 Switch' on"
 		cset "name='Stereo ADC MIXR ADC1 Switch' on"
-
 		cset "name='Mono ADC MIXL ADC1 Switch' on"
 		cset "name='Mono ADC MIXR ADC1 Switch' on"
-
-		cset "name='Mono ADC Capture Switch' on"
-
 	]
 
 	DisableSequence [
 		cset "name='Stereo ADC MIXL ADC1 Switch' off"
 		cset "name='Stereo ADC MIXR ADC1 Switch' off"
+		cset "name='Mono ADC MIXL ADC1 Switch' off"
+		cset "name='Mono ADC MIXR ADC1 Switch' off"
 
 		cset "name='RECMIXL BST3 Switch' off"
 		cset "name='RECMIXR BST3 Switch' off"
 
 		cset "name='Internal Mic Switch' off"
-
-		cset "name='Mono ADC MIXL ADC1 Switch' off"
-		cset "name='Mono ADC MIXR ADC1 Switch' off"
-
-		cset "name='Mono ADC Capture Switch' off"
 	]
 
 	Value {
-- 
2.30.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH alsa-ucm-conf v2 2/7] codecs/rt5640: Cleanup: Initially disable all inputs and outputs
  2021-03-08 22:05 [PATCH alsa-ucm-conf v2 0/7] codecs/rt5640: Cleanup + HW volume control support Hans de Goede
  2021-03-08 22:05 ` [PATCH alsa-ucm-conf v2 1/7] codecs/rt5640: Cleanup: unify Stereo / Mono ADC handling Hans de Goede
@ 2021-03-08 22:05 ` Hans de Goede
  2021-03-08 22:05 ` [PATCH alsa-ucm-conf v2 3/7] codecs/rt5640: Cleanup: Move 'SPK MIX' setup to main EnableSequene Hans de Goede
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Hans de Goede @ 2021-03-08 22:05 UTC (permalink / raw)
  To: Jaroslav Kysela
  Cc: Hans de Goede, alsa-devel, Pierre-Louis Bossart, Bard Liao

Cleanup: no functional changes intended.

Disable all inputs and outputs from the main EnableSequence.

This allows removing some weirdness from the individual input/output
EnableSequences where they were turning controls for other inputs/outputs
then themselves off.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 ucm2/codecs/rt5640/EnableSeq.conf       | 21 +++++++++++++++++++++
 ucm2/codecs/rt5640/HeadPhones.conf      |  1 -
 ucm2/codecs/rt5640/IN1-InternalMic.conf |  2 --
 ucm2/codecs/rt5640/IN3-InternalMic.conf |  2 --
 ucm2/codecs/rt5640/MonoSpeaker.conf     |  1 -
 ucm2/codecs/rt5640/Speaker.conf         |  1 -
 6 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/ucm2/codecs/rt5640/EnableSeq.conf b/ucm2/codecs/rt5640/EnableSeq.conf
index 4754df7..5dc7092 100644
--- a/ucm2/codecs/rt5640/EnableSeq.conf
+++ b/ucm2/codecs/rt5640/EnableSeq.conf
@@ -48,6 +48,27 @@ EnableSequence [
 	cset "name='IN2 Boost' 1"
 	cset "name='IN3 Boost' 8"
 
+	# Start with all controls which are used by the individual
+	# input/output Enable/DisableSequences off
+
+	cset "name='RECMIXL BST1 Switch' off"
+	cset "name='RECMIXR BST1 Switch' off"
+	cset "name='RECMIXL BST2 Switch' off"
+	cset "name='RECMIXR BST2 Switch' off"
+	cset "name='RECMIXL BST3 Switch' off"
+	cset "name='RECMIXR BST3 Switch' off"
+
+	cset "name='Stereo ADC MIXL ADC1 Switch' off"
+	cset "name='Stereo ADC MIXR ADC1 Switch' off"
+	cset "name='Stereo ADC MIXL ADC2 Switch' off"
+	cset "name='Stereo ADC MIXR ADC2 Switch' off"
+	cset "name='Mono ADC MIXL ADC1 Switch' off"
+	cset "name='Mono ADC MIXR ADC1 Switch' off"
+	cset "name='Mono ADC MIXL ADC2 Switch' off"
+	cset "name='Mono ADC MIXR ADC2 Switch' off"
+
+	cset "name='Speaker Switch' off"
+	cset "name='Headphone Switch' off"
 	cset "name='Internal Mic Switch' off"
 	cset "name='Headset Mic Switch' off"
 ]
diff --git a/ucm2/codecs/rt5640/HeadPhones.conf b/ucm2/codecs/rt5640/HeadPhones.conf
index a9e4d20..1f4316d 100644
--- a/ucm2/codecs/rt5640/HeadPhones.conf
+++ b/ucm2/codecs/rt5640/HeadPhones.conf
@@ -17,7 +17,6 @@ SectionDevice."Headphones" {
  		cset "name='HPO MIX HPVOL Switch'  on"
  		cset "name='Headphone Switch'  on"
 		cset "name='HP Channel Switch' on"
- 		cset "name='Speaker Switch' off"
 		cset "name='HP L Playback Switch' on"
 		cset "name='HP R Playback Switch' on"
 		cset "name='HP Playback Volume' 29"
diff --git a/ucm2/codecs/rt5640/IN1-InternalMic.conf b/ucm2/codecs/rt5640/IN1-InternalMic.conf
index 260df90..d7c419e 100644
--- a/ucm2/codecs/rt5640/IN1-InternalMic.conf
+++ b/ucm2/codecs/rt5640/IN1-InternalMic.conf
@@ -10,8 +10,6 @@ SectionDevice."Mic" {
 
 		cset "name='RECMIXL BST1 Switch' on"
 		cset "name='RECMIXR BST1 Switch' on"
-		cset "name='RECMIXL BST3 Switch' off"
-		cset "name='RECMIXR BST3 Switch' off"
 
 		cset "name='Stereo ADC MIXL ADC1 Switch' on"
 		cset "name='Stereo ADC MIXR ADC1 Switch' on"
diff --git a/ucm2/codecs/rt5640/IN3-InternalMic.conf b/ucm2/codecs/rt5640/IN3-InternalMic.conf
index ebd2b9c..3e330e6 100644
--- a/ucm2/codecs/rt5640/IN3-InternalMic.conf
+++ b/ucm2/codecs/rt5640/IN3-InternalMic.conf
@@ -8,8 +8,6 @@ SectionDevice."Mic" {
 	EnableSequence [
 		cset "name='Internal Mic Switch' on"
 
-		cset "name='RECMIXL BST1 Switch' off"
-		cset "name='RECMIXR BST1 Switch' off"
 		cset "name='RECMIXL BST3 Switch' on"
 		cset "name='RECMIXR BST3 Switch' on"
 
diff --git a/ucm2/codecs/rt5640/MonoSpeaker.conf b/ucm2/codecs/rt5640/MonoSpeaker.conf
index 23cf34c..5035c8d 100644
--- a/ucm2/codecs/rt5640/MonoSpeaker.conf
+++ b/ucm2/codecs/rt5640/MonoSpeaker.conf
@@ -14,7 +14,6 @@ SectionDevice."Speaker" {
 		cset "name='SPOL MIX SPKVOL R Switch' on"
 		cset "name='Speaker Switch' on"
 		cset "name='Speaker Channel Switch' on"
-		cset "name='Headphone Switch' off"
 		cset "name='Speaker L Playback Switch' on"
 		cset "name='Speaker R Playback Switch' on"
 		cset "name='Speaker Playback Volume' 35"
diff --git a/ucm2/codecs/rt5640/Speaker.conf b/ucm2/codecs/rt5640/Speaker.conf
index 422cfdf..fd74994 100644
--- a/ucm2/codecs/rt5640/Speaker.conf
+++ b/ucm2/codecs/rt5640/Speaker.conf
@@ -14,7 +14,6 @@ SectionDevice."Speaker" {
 		cset "name='SPOL MIX SPKVOL R Switch' off"
 		cset "name='Speaker Switch' on"
 		cset "name='Speaker Channel Switch' on"
-		cset "name='Headphone Switch' off"
 		cset "name='Speaker L Playback Switch' on"
 		cset "name='Speaker R Playback Switch' on"
 		cset "name='Speaker Playback Volume' 35"
-- 
2.30.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH alsa-ucm-conf v2 3/7] codecs/rt5640: Cleanup: Move 'SPK MIX' setup to main EnableSequene
  2021-03-08 22:05 [PATCH alsa-ucm-conf v2 0/7] codecs/rt5640: Cleanup + HW volume control support Hans de Goede
  2021-03-08 22:05 ` [PATCH alsa-ucm-conf v2 1/7] codecs/rt5640: Cleanup: unify Stereo / Mono ADC handling Hans de Goede
  2021-03-08 22:05 ` [PATCH alsa-ucm-conf v2 2/7] codecs/rt5640: Cleanup: Initially disable all inputs and outputs Hans de Goede
@ 2021-03-08 22:05 ` Hans de Goede
  2021-03-08 22:05 ` [PATCH alsa-ucm-conf v2 4/7] codecs/rt5640: Drop bogus 'DIG MIXL DAC L2 Switch' setting Hans de Goede
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Hans de Goede @ 2021-03-08 22:05 UTC (permalink / raw)
  To: Jaroslav Kysela
  Cc: Hans de Goede, alsa-devel, Pierre-Louis Bossart, Bard Liao

Cleanup: no functional changes intended.

Do the 'SPK MIXL' / 'SPK MIXR' setup only once from the main
EnableSequene, like we do for the 'OUT MIXL' / 'OUT MIXR' setup
used by the headphones already.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 ucm2/codecs/rt5640/EnableSeq.conf   | 6 ++++--
 ucm2/codecs/rt5640/MonoSpeaker.conf | 2 --
 ucm2/codecs/rt5640/Speaker.conf     | 2 --
 3 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/ucm2/codecs/rt5640/EnableSeq.conf b/ucm2/codecs/rt5640/EnableSeq.conf
index 5dc7092..4a355a5 100644
--- a/ucm2/codecs/rt5640/EnableSeq.conf
+++ b/ucm2/codecs/rt5640/EnableSeq.conf
@@ -6,8 +6,10 @@ EnableSequence [
 	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"
+	cset "name='OUT MIXL DAC L1 Switch' on"
+	cset "name='OUT MIXR DAC R1 Switch' on"
+	cset "name='SPK MIXL DAC L1 Switch' on"
+	cset "name='SPK MIXR DAC R1 Switch' on"
 
 	# uncomment for loopback mic->speakers
 	# cset "name='SPOL MIX BST1 Switch' on"
diff --git a/ucm2/codecs/rt5640/MonoSpeaker.conf b/ucm2/codecs/rt5640/MonoSpeaker.conf
index 5035c8d..654edc3 100644
--- a/ucm2/codecs/rt5640/MonoSpeaker.conf
+++ b/ucm2/codecs/rt5640/MonoSpeaker.conf
@@ -6,8 +6,6 @@ SectionDevice."Speaker" {
 	]
 
 	EnableSequence [
-		cset "name='SPK MIXL DAC L1 Switch' on"
-		cset "name='SPK MIXR DAC R1 Switch' on"
 		cset "name='SPOL MIX SPKVOL L Switch' on"
 # for mono speaker we apply left on right
 #		cset "name='SPOR MIX SPKVOL R Switch' on"
diff --git a/ucm2/codecs/rt5640/Speaker.conf b/ucm2/codecs/rt5640/Speaker.conf
index fd74994..3264cc3 100644
--- a/ucm2/codecs/rt5640/Speaker.conf
+++ b/ucm2/codecs/rt5640/Speaker.conf
@@ -6,8 +6,6 @@ SectionDevice."Speaker" {
 	]
 
 	EnableSequence [
-		cset "name='SPK MIXL DAC L1 Switch' on"
-		cset "name='SPK MIXR DAC R1 Switch' on"
 		cset "name='SPOL MIX SPKVOL L Switch' on"
 		cset "name='SPOR MIX SPKVOL R Switch' on"
 		# undo MonoSpeaker mixing of right channel to left speaker
-- 
2.30.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH alsa-ucm-conf v2 4/7] codecs/rt5640: Drop bogus 'DIG MIXL DAC L2 Switch' setting
  2021-03-08 22:05 [PATCH alsa-ucm-conf v2 0/7] codecs/rt5640: Cleanup + HW volume control support Hans de Goede
                   ` (2 preceding siblings ...)
  2021-03-08 22:05 ` [PATCH alsa-ucm-conf v2 3/7] codecs/rt5640: Cleanup: Move 'SPK MIX' setup to main EnableSequene Hans de Goede
@ 2021-03-08 22:05 ` Hans de Goede
  2021-03-08 22:05 ` [PATCH alsa-ucm-conf v2 5/7] codecs/rt5640: Unify capture volume for AIF1 and AIF2 recording paths Hans de Goede
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Hans de Goede @ 2021-03-08 22:05 UTC (permalink / raw)
  To: Jaroslav Kysela
  Cc: Hans de Goede, alsa-devel, Pierre-Louis Bossart, Bard Liao

The 'DIG MIXL DAC L2 Switch' path is only used for Digital Mixer Path
loopback, which we don't use. Drop it.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 ucm2/codecs/rt5640/EnableSeq.conf | 1 -
 1 file changed, 1 deletion(-)

diff --git a/ucm2/codecs/rt5640/EnableSeq.conf b/ucm2/codecs/rt5640/EnableSeq.conf
index 4a355a5..223cceb 100644
--- a/ucm2/codecs/rt5640/EnableSeq.conf
+++ b/ucm2/codecs/rt5640/EnableSeq.conf
@@ -27,7 +27,6 @@ EnableSequence [
 	#cset "name='DAI select' 1"
 
 	cset "name='DAC2 Playback Switch' on"
-	cset "name='DIG MIXL DAC L2 Switch' on"
 
 	# Input Configuration
 	cset "name='Stereo ADC1 Mux' ADC"
-- 
2.30.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH alsa-ucm-conf v2 5/7] codecs/rt5640: Unify capture volume for AIF1 and AIF2 recording paths
  2021-03-08 22:05 [PATCH alsa-ucm-conf v2 0/7] codecs/rt5640: Cleanup + HW volume control support Hans de Goede
                   ` (3 preceding siblings ...)
  2021-03-08 22:05 ` [PATCH alsa-ucm-conf v2 4/7] codecs/rt5640: Drop bogus 'DIG MIXL DAC L2 Switch' setting Hans de Goede
@ 2021-03-08 22:05 ` Hans de Goede
  2021-03-08 22:05 ` [PATCH alsa-ucm-conf v2 6/7] codecs/rt5640: Add hardware volume-control support Hans de Goede
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Hans de Goede @ 2021-03-08 22:05 UTC (permalink / raw)
  To: Jaroslav Kysela
  Cc: Hans de Goede, alsa-devel, Pierre-Louis Bossart, Bard Liao

The rt5640 codec is sometimes used with AIF1 connected to the
SoC and sometimes with AIF2 connected to the SoC.

The rt5640 UCM configuration deals with this by accepting input from
and sending output to both AIFs, relying on the kernels DAPM framework to
disable parts of the graph which are connected to the unconnected AIF.

Before this commit codecs/rt5640/EnableSeq.conf was adding a +9dB
(digital) boost to recording going through the 'ADC' path to AIF1,
while not touching the 'Mono ADC' path to AIF2.

This was causing recordings on devices using AIF2 to be somewhat soft.

This commit unifies the record volume control settings for both paths by
only using the '[Mono ]ADC Capture Volume' control, which is present
in both paths and setting it to +9dB on both paths.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 ucm2/codecs/rt5640/EnableSeq.conf | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/ucm2/codecs/rt5640/EnableSeq.conf b/ucm2/codecs/rt5640/EnableSeq.conf
index 223cceb..49703ae 100644
--- a/ucm2/codecs/rt5640/EnableSeq.conf
+++ b/ucm2/codecs/rt5640/EnableSeq.conf
@@ -39,10 +39,14 @@ EnableSequence [
 	cset "name='Mono ADC R2 Mux' DMIC R1"
 	cset "name='Mono ADC Capture Switch' on"
 
-	# 47=0dB, 0.375 dB/step, set it to 6 dB to help with soft mics
-	cset "name='ADC Capture Volume' 63"
-	# Set ADC Boost Gain to 3dB higher vals result in too much noise
-	cset "name='ADC Boost Gain' 1"
+	# 47=0dB, 0.375 dB/step, set it to 9 dB to help with soft mics
+	cset "name='ADC Capture Volume' 71"
+	cset "name='Mono ADC Capture Volume' 71"
+
+	# The second 'Mono ADC' path does not have a 'Boost Gain',
+	# set this to 0dB so that the volume of the AIF1 and AIF2 paths is equal.
+	cset "name='ADC Boost Gain' 0"
+
 	# Set IN1/IN3 internal mic boost to 8 (max)
 	# Set IN2 headset-mic boost to 1, headset mics are quite loud
 	cset "name='IN1 Boost' 8"
-- 
2.30.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH alsa-ucm-conf v2 6/7] codecs/rt5640: Add hardware volume-control support
  2021-03-08 22:05 [PATCH alsa-ucm-conf v2 0/7] codecs/rt5640: Cleanup + HW volume control support Hans de Goede
                   ` (4 preceding siblings ...)
  2021-03-08 22:05 ` [PATCH alsa-ucm-conf v2 5/7] codecs/rt5640: Unify capture volume for AIF1 and AIF2 recording paths Hans de Goede
@ 2021-03-08 22:05 ` Hans de Goede
  2021-03-08 22:05 ` [PATCH alsa-ucm-conf v2 7/7] codecs/rt5640: Specify Playback/CaptureMasterElem for HW volume-control Hans de Goede
  2021-03-10 10:24 ` [PATCH alsa-ucm-conf v2 0/7] codecs/rt5640: Cleanup + HW volume control support Jaroslav Kysela
  7 siblings, 0 replies; 11+ messages in thread
From: Hans de Goede @ 2021-03-08 22:05 UTC (permalink / raw)
  To: Jaroslav Kysela
  Cc: Hans de Goede, alsa-devel, Pierre-Louis Bossart, Bard Liao

Add hardware volume-control support for the rt5640 codec.

Note this commit does not add support for the (digital) master
ADC/DAC Volume / Mute controls. There are 2 of each, and which
one should be used depends on which AIF is being used.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 ucm2/codecs/rt5640/HeadPhones.conf      | 2 ++
 ucm2/codecs/rt5640/HeadsetMic.conf      | 2 ++
 ucm2/codecs/rt5640/IN1-InternalMic.conf | 2 ++
 ucm2/codecs/rt5640/IN3-InternalMic.conf | 2 ++
 ucm2/codecs/rt5640/MonoSpeaker.conf     | 2 ++
 ucm2/codecs/rt5640/Speaker.conf         | 2 ++
 6 files changed, 12 insertions(+)

diff --git a/ucm2/codecs/rt5640/HeadPhones.conf b/ucm2/codecs/rt5640/HeadPhones.conf
index 1f4316d..5535111 100644
--- a/ucm2/codecs/rt5640/HeadPhones.conf
+++ b/ucm2/codecs/rt5640/HeadPhones.conf
@@ -35,5 +35,7 @@ SectionDevice."Headphones" {
 		PlaybackPriority 300
 		PlaybackPCM "hw:${CardId}"
 		JackControl "Headphone Jack"
+		PlaybackMixerElem "HP"
+		PlaybackVolume "HP Playback Volume"
 	}
 }
diff --git a/ucm2/codecs/rt5640/HeadsetMic.conf b/ucm2/codecs/rt5640/HeadsetMic.conf
index 829e4e6..8479672 100644
--- a/ucm2/codecs/rt5640/HeadsetMic.conf
+++ b/ucm2/codecs/rt5640/HeadsetMic.conf
@@ -41,5 +41,7 @@ SectionDevice."Headset" {
 		CapturePriority 200
 		CapturePCM "hw:${CardId}"
 		JackControl "Headset Mic Jack"
+		CaptureMixerElem "IN2 Boost"
+		CaptureVolume "IN2 Boost"
 	}
 }
diff --git a/ucm2/codecs/rt5640/IN1-InternalMic.conf b/ucm2/codecs/rt5640/IN1-InternalMic.conf
index d7c419e..a317388 100644
--- a/ucm2/codecs/rt5640/IN1-InternalMic.conf
+++ b/ucm2/codecs/rt5640/IN1-InternalMic.conf
@@ -32,5 +32,7 @@ SectionDevice."Mic" {
 	Value {
 		CapturePriority 100
 		CapturePCM "hw:${CardId}"
+		CaptureMixerElem "IN1 Boost"
+		CaptureVolume "IN1 Boost"
 	}
 }
diff --git a/ucm2/codecs/rt5640/IN3-InternalMic.conf b/ucm2/codecs/rt5640/IN3-InternalMic.conf
index 3e330e6..ef4eaba 100644
--- a/ucm2/codecs/rt5640/IN3-InternalMic.conf
+++ b/ucm2/codecs/rt5640/IN3-InternalMic.conf
@@ -32,5 +32,7 @@ SectionDevice."Mic" {
 	Value {
 		CapturePriority 100
 		CapturePCM "hw:${CardId}"
+		CaptureMixerElem "IN3 Boost"
+		CaptureVolume "IN3 Boost"
 	}
 }
diff --git a/ucm2/codecs/rt5640/MonoSpeaker.conf b/ucm2/codecs/rt5640/MonoSpeaker.conf
index 654edc3..3cbeafd 100644
--- a/ucm2/codecs/rt5640/MonoSpeaker.conf
+++ b/ucm2/codecs/rt5640/MonoSpeaker.conf
@@ -29,5 +29,7 @@ SectionDevice."Speaker" {
 	Value {
 		PlaybackPriority 100
 		PlaybackPCM "hw:${CardId}"
+		PlaybackMixerElem "Speaker"
+		PlaybackVolume "Speaker Playback Volume"
 	}
 }
diff --git a/ucm2/codecs/rt5640/Speaker.conf b/ucm2/codecs/rt5640/Speaker.conf
index 3264cc3..0924f9c 100644
--- a/ucm2/codecs/rt5640/Speaker.conf
+++ b/ucm2/codecs/rt5640/Speaker.conf
@@ -29,5 +29,7 @@ SectionDevice."Speaker" {
 	Value {
 		PlaybackPriority 100
 		PlaybackPCM "hw:${CardId}"
+		PlaybackMixerElem "Speaker"
+		PlaybackVolume "Speaker Playback Volume"
 	}
 }
-- 
2.30.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH alsa-ucm-conf v2 7/7] codecs/rt5640: Specify Playback/CaptureMasterElem for HW volume-control
  2021-03-08 22:05 [PATCH alsa-ucm-conf v2 0/7] codecs/rt5640: Cleanup + HW volume control support Hans de Goede
                   ` (5 preceding siblings ...)
  2021-03-08 22:05 ` [PATCH alsa-ucm-conf v2 6/7] codecs/rt5640: Add hardware volume-control support Hans de Goede
@ 2021-03-08 22:05 ` Hans de Goede
  2021-03-13 12:10   ` Hans de Goede
  2021-03-10 10:24 ` [PATCH alsa-ucm-conf v2 0/7] codecs/rt5640: Cleanup + HW volume control support Jaroslav Kysela
  7 siblings, 1 reply; 11+ messages in thread
From: Hans de Goede @ 2021-03-08 22:05 UTC (permalink / raw)
  To: Jaroslav Kysela
  Cc: Hans de Goede, alsa-devel, Pierre-Louis Bossart, Bard Liao

Newer kernels add "aif:1" or "aif:2" to the components string to let
us know which AIF is being used.

Use this to specify the correct Playback/CaptureMasterElem for HW
volume-control, based on which AIF is being used.

On older kernels, where there is no "aif:%d" string in the components
string, no Playback/CaptureMasterElem is specified.

In DigitalMics.conf the master mixer is used as regular CaptureMixerElem
instead of as CaptureMasterElem since the DMICs don't have any analog
volume control.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 ucm2/bytcr-rt5640/HiFi.conf             | 21 +++++++++++++++++++++
 ucm2/codecs/rt5640/DigitalMics.conf     | 16 ++++++++++++++++
 ucm2/codecs/rt5640/HeadPhones.conf      | 12 ++++++++++++
 ucm2/codecs/rt5640/HeadsetMic.conf      | 12 ++++++++++++
 ucm2/codecs/rt5640/IN1-InternalMic.conf | 12 ++++++++++++
 ucm2/codecs/rt5640/IN3-InternalMic.conf | 12 ++++++++++++
 ucm2/codecs/rt5640/MonoSpeaker.conf     | 12 ++++++++++++
 ucm2/codecs/rt5640/Speaker.conf         | 12 ++++++++++++
 8 files changed, 109 insertions(+)

diff --git a/ucm2/bytcr-rt5640/HiFi.conf b/ucm2/bytcr-rt5640/HiFi.conf
index a5c05ba..7d504d1 100644
--- a/ucm2/bytcr-rt5640/HiFi.conf
+++ b/ucm2/bytcr-rt5640/HiFi.conf
@@ -1,5 +1,26 @@
 # Use case Configuration for bytcr-rt5640
 
+Define.HaveAif1 ""
+Define.HaveAif2 ""
+
+If.DefineAif1 {
+	Condition {
+		Type String
+		Haystack "${CardComponents}"
+		Needle "aif:1"
+	}
+	True.Define.HaveAif1 "yes"
+}
+
+If.DefineAif2 {
+	Condition {
+		Type String
+		Haystack "${CardComponents}"
+		Needle "aif:2"
+	}
+	True.Define.HaveAif2 "yes"
+}
+
 SectionVerb {
 	Include.e.File "/codecs/rt5640/EnableSeq.conf"
 
diff --git a/ucm2/codecs/rt5640/DigitalMics.conf b/ucm2/codecs/rt5640/DigitalMics.conf
index 157c544..032d954 100644
--- a/ucm2/codecs/rt5640/DigitalMics.conf
+++ b/ucm2/codecs/rt5640/DigitalMics.conf
@@ -26,5 +26,21 @@ SectionDevice."Mic" {
 	Value {
 		CapturePriority 100
 		CapturePCM "hw:${CardId}"
+		If.DmicAif1 {
+			Condition { Type String Empty "${var:HaveAif1}" }
+			False {
+				CaptureMixerElem "ADC"
+				CaptureVolume "ADC Capture Volume"
+				CaptureSwitch "ADC Capture Switch"
+			}
+		}
+		If.DmicAif2 {
+			Condition { Type String Empty "${var:HaveAif2}" }
+			False {
+				CaptureMixerElem "Mono ADC"
+				CaptureVolume "Mono ADC Capture Volume"
+				CaptureSwitch "Mono ADC Capture Switch"
+			}
+		}
 	}
 }
diff --git a/ucm2/codecs/rt5640/HeadPhones.conf b/ucm2/codecs/rt5640/HeadPhones.conf
index 5535111..4fbe95d 100644
--- a/ucm2/codecs/rt5640/HeadPhones.conf
+++ b/ucm2/codecs/rt5640/HeadPhones.conf
@@ -37,5 +37,17 @@ SectionDevice."Headphones" {
 		JackControl "Headphone Jack"
 		PlaybackMixerElem "HP"
 		PlaybackVolume "HP Playback Volume"
+		If.HpAif1 {
+			Condition { Type String Empty "${var:HaveAif1}" }
+			False {
+				PlaybackMasterElem "DAC1"
+			}
+		}
+		If.HpAif2 {
+			Condition { Type String Empty "${var:HaveAif2}" }
+			False {
+				PlaybackMasterElem "DAC2"
+			}
+		}
 	}
 }
diff --git a/ucm2/codecs/rt5640/HeadsetMic.conf b/ucm2/codecs/rt5640/HeadsetMic.conf
index 8479672..b49dad4 100644
--- a/ucm2/codecs/rt5640/HeadsetMic.conf
+++ b/ucm2/codecs/rt5640/HeadsetMic.conf
@@ -43,5 +43,17 @@ SectionDevice."Headset" {
 		JackControl "Headset Mic Jack"
 		CaptureMixerElem "IN2 Boost"
 		CaptureVolume "IN2 Boost"
+		If.HSmicAif1 {
+			Condition { Type String Empty "${var:HaveAif1}" }
+			False {
+				CaptureMasterElem "ADC"
+			}
+		}
+		If.HSmicAif2 {
+			Condition { Type String Empty "${var:HaveAif2}" }
+			False {
+				CaptureMasterElem "Mono ADC"
+			}
+		}
 	}
 }
diff --git a/ucm2/codecs/rt5640/IN1-InternalMic.conf b/ucm2/codecs/rt5640/IN1-InternalMic.conf
index a317388..d670484 100644
--- a/ucm2/codecs/rt5640/IN1-InternalMic.conf
+++ b/ucm2/codecs/rt5640/IN1-InternalMic.conf
@@ -34,5 +34,17 @@ SectionDevice."Mic" {
 		CapturePCM "hw:${CardId}"
 		CaptureMixerElem "IN1 Boost"
 		CaptureVolume "IN1 Boost"
+		If.In1Aif1 {
+			Condition { Type String Empty "${var:HaveAif1}" }
+			False {
+				CaptureMasterElem "ADC"
+			}
+		}
+		If.In1Aif2 {
+			Condition { Type String Empty "${var:HaveAif2}" }
+			False {
+				CaptureMasterElem "Mono ADC"
+			}
+		}
 	}
 }
diff --git a/ucm2/codecs/rt5640/IN3-InternalMic.conf b/ucm2/codecs/rt5640/IN3-InternalMic.conf
index ef4eaba..345db1e 100644
--- a/ucm2/codecs/rt5640/IN3-InternalMic.conf
+++ b/ucm2/codecs/rt5640/IN3-InternalMic.conf
@@ -34,5 +34,17 @@ SectionDevice."Mic" {
 		CapturePCM "hw:${CardId}"
 		CaptureMixerElem "IN3 Boost"
 		CaptureVolume "IN3 Boost"
+		If.In3Aif1 {
+			Condition { Type String Empty "${var:HaveAif1}" }
+			False {
+				CaptureMasterElem "ADC"
+			}
+		}
+		If.In3Aif2 {
+			Condition { Type String Empty "${var:HaveAif2}" }
+			False {
+				CaptureMasterElem "Mono ADC"
+			}
+		}
 	}
 }
diff --git a/ucm2/codecs/rt5640/MonoSpeaker.conf b/ucm2/codecs/rt5640/MonoSpeaker.conf
index 3cbeafd..addaddd 100644
--- a/ucm2/codecs/rt5640/MonoSpeaker.conf
+++ b/ucm2/codecs/rt5640/MonoSpeaker.conf
@@ -31,5 +31,17 @@ SectionDevice."Speaker" {
 		PlaybackPCM "hw:${CardId}"
 		PlaybackMixerElem "Speaker"
 		PlaybackVolume "Speaker Playback Volume"
+		If.MonoSpkAif1 {
+			Condition { Type String Empty "${var:HaveAif1}" }
+			False {
+				PlaybackMasterElem "DAC1"
+			}
+		}
+		If.MonoSpkAif2 {
+			Condition { Type String Empty "${var:HaveAif2}" }
+			False {
+				PlaybackMasterElem "DAC2"
+			}
+		}
 	}
 }
diff --git a/ucm2/codecs/rt5640/Speaker.conf b/ucm2/codecs/rt5640/Speaker.conf
index 0924f9c..e7ff673 100644
--- a/ucm2/codecs/rt5640/Speaker.conf
+++ b/ucm2/codecs/rt5640/Speaker.conf
@@ -31,5 +31,17 @@ SectionDevice."Speaker" {
 		PlaybackPCM "hw:${CardId}"
 		PlaybackMixerElem "Speaker"
 		PlaybackVolume "Speaker Playback Volume"
+		If.SpkAif1 {
+			Condition { Type String Empty "${var:HaveAif1}" }
+			False {
+				PlaybackMasterElem "DAC1"
+			}
+		}
+		If.SpkAif2 {
+			Condition { Type String Empty "${var:HaveAif2}" }
+			False {
+				PlaybackMasterElem "DAC2"
+			}
+		}
 	}
 }
-- 
2.30.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH alsa-ucm-conf v2 0/7] codecs/rt5640: Cleanup + HW volume control support
  2021-03-08 22:05 [PATCH alsa-ucm-conf v2 0/7] codecs/rt5640: Cleanup + HW volume control support Hans de Goede
                   ` (6 preceding siblings ...)
  2021-03-08 22:05 ` [PATCH alsa-ucm-conf v2 7/7] codecs/rt5640: Specify Playback/CaptureMasterElem for HW volume-control Hans de Goede
@ 2021-03-10 10:24 ` Jaroslav Kysela
  7 siblings, 0 replies; 11+ messages in thread
From: Jaroslav Kysela @ 2021-03-10 10:24 UTC (permalink / raw)
  To: Hans de Goede; +Cc: alsa-devel, Pierre-Louis Bossart, Bard Liao

Dne 08. 03. 21 v 23:05 Hans de Goede napsal(a):
> Hi All,
> 
> Here is v2 of my patch series consisting of some codecs/rt5640 cleanups
> and addition of HW volume control support to the rt5640 .conf snippets.
> 
> This new version has been updated to deal with the
> "[PATCH 3/5] ASoC: rt5640: Add emulated 'DAC1 Playback Switch' control"
> kernel-patch being dropped.
> 
> Note patch 7 depends on a new "aif:%d" part being added to the
> components string, the kernel patches for this are pending upstream
> in the "[PATCH resend 0/2] AsoC: rt5640/rt5651: Volume control fixes"
> patch-series.

Applied all except the 7th patch.

Thank you.

				Jaroslav

-- 
Jaroslav Kysela <perex@perex.cz>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH alsa-ucm-conf v2 7/7] codecs/rt5640: Specify Playback/CaptureMasterElem for HW volume-control
  2021-03-08 22:05 ` [PATCH alsa-ucm-conf v2 7/7] codecs/rt5640: Specify Playback/CaptureMasterElem for HW volume-control Hans de Goede
@ 2021-03-13 12:10   ` Hans de Goede
  2021-03-13 16:05     ` Jaroslav Kysela
  0 siblings, 1 reply; 11+ messages in thread
From: Hans de Goede @ 2021-03-13 12:10 UTC (permalink / raw)
  To: Jaroslav Kysela; +Cc: alsa-devel, Pierre-Louis Bossart, Bard Liao

Hi,

On 3/8/21 11:05 PM, Hans de Goede wrote:
> Newer kernels add "aif:1" or "aif:2" to the components string to let
> us know which AIF is being used.
> 
> Use this to specify the correct Playback/CaptureMasterElem for HW
> volume-control, based on which AIF is being used.
> 
> On older kernels, where there is no "aif:%d" string in the components
> string, no Playback/CaptureMasterElem is specified.
> 
> In DigitalMics.conf the master mixer is used as regular CaptureMixerElem
> instead of as CaptureMasterElem since the DMICs don't have any analog
> volume control.
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>

The kernel side of this patch has landed now, so this patch can
be merged now.

Thanks & Regards,

Hans


> ---
>  ucm2/bytcr-rt5640/HiFi.conf             | 21 +++++++++++++++++++++
>  ucm2/codecs/rt5640/DigitalMics.conf     | 16 ++++++++++++++++
>  ucm2/codecs/rt5640/HeadPhones.conf      | 12 ++++++++++++
>  ucm2/codecs/rt5640/HeadsetMic.conf      | 12 ++++++++++++
>  ucm2/codecs/rt5640/IN1-InternalMic.conf | 12 ++++++++++++
>  ucm2/codecs/rt5640/IN3-InternalMic.conf | 12 ++++++++++++
>  ucm2/codecs/rt5640/MonoSpeaker.conf     | 12 ++++++++++++
>  ucm2/codecs/rt5640/Speaker.conf         | 12 ++++++++++++
>  8 files changed, 109 insertions(+)
> 
> diff --git a/ucm2/bytcr-rt5640/HiFi.conf b/ucm2/bytcr-rt5640/HiFi.conf
> index a5c05ba..7d504d1 100644
> --- a/ucm2/bytcr-rt5640/HiFi.conf
> +++ b/ucm2/bytcr-rt5640/HiFi.conf
> @@ -1,5 +1,26 @@
>  # Use case Configuration for bytcr-rt5640
>  
> +Define.HaveAif1 ""
> +Define.HaveAif2 ""
> +
> +If.DefineAif1 {
> +	Condition {
> +		Type String
> +		Haystack "${CardComponents}"
> +		Needle "aif:1"
> +	}
> +	True.Define.HaveAif1 "yes"
> +}
> +
> +If.DefineAif2 {
> +	Condition {
> +		Type String
> +		Haystack "${CardComponents}"
> +		Needle "aif:2"
> +	}
> +	True.Define.HaveAif2 "yes"
> +}
> +
>  SectionVerb {
>  	Include.e.File "/codecs/rt5640/EnableSeq.conf"
>  
> diff --git a/ucm2/codecs/rt5640/DigitalMics.conf b/ucm2/codecs/rt5640/DigitalMics.conf
> index 157c544..032d954 100644
> --- a/ucm2/codecs/rt5640/DigitalMics.conf
> +++ b/ucm2/codecs/rt5640/DigitalMics.conf
> @@ -26,5 +26,21 @@ SectionDevice."Mic" {
>  	Value {
>  		CapturePriority 100
>  		CapturePCM "hw:${CardId}"
> +		If.DmicAif1 {
> +			Condition { Type String Empty "${var:HaveAif1}" }
> +			False {
> +				CaptureMixerElem "ADC"
> +				CaptureVolume "ADC Capture Volume"
> +				CaptureSwitch "ADC Capture Switch"
> +			}
> +		}
> +		If.DmicAif2 {
> +			Condition { Type String Empty "${var:HaveAif2}" }
> +			False {
> +				CaptureMixerElem "Mono ADC"
> +				CaptureVolume "Mono ADC Capture Volume"
> +				CaptureSwitch "Mono ADC Capture Switch"
> +			}
> +		}
>  	}
>  }
> diff --git a/ucm2/codecs/rt5640/HeadPhones.conf b/ucm2/codecs/rt5640/HeadPhones.conf
> index 5535111..4fbe95d 100644
> --- a/ucm2/codecs/rt5640/HeadPhones.conf
> +++ b/ucm2/codecs/rt5640/HeadPhones.conf
> @@ -37,5 +37,17 @@ SectionDevice."Headphones" {
>  		JackControl "Headphone Jack"
>  		PlaybackMixerElem "HP"
>  		PlaybackVolume "HP Playback Volume"
> +		If.HpAif1 {
> +			Condition { Type String Empty "${var:HaveAif1}" }
> +			False {
> +				PlaybackMasterElem "DAC1"
> +			}
> +		}
> +		If.HpAif2 {
> +			Condition { Type String Empty "${var:HaveAif2}" }
> +			False {
> +				PlaybackMasterElem "DAC2"
> +			}
> +		}
>  	}
>  }
> diff --git a/ucm2/codecs/rt5640/HeadsetMic.conf b/ucm2/codecs/rt5640/HeadsetMic.conf
> index 8479672..b49dad4 100644
> --- a/ucm2/codecs/rt5640/HeadsetMic.conf
> +++ b/ucm2/codecs/rt5640/HeadsetMic.conf
> @@ -43,5 +43,17 @@ SectionDevice."Headset" {
>  		JackControl "Headset Mic Jack"
>  		CaptureMixerElem "IN2 Boost"
>  		CaptureVolume "IN2 Boost"
> +		If.HSmicAif1 {
> +			Condition { Type String Empty "${var:HaveAif1}" }
> +			False {
> +				CaptureMasterElem "ADC"
> +			}
> +		}
> +		If.HSmicAif2 {
> +			Condition { Type String Empty "${var:HaveAif2}" }
> +			False {
> +				CaptureMasterElem "Mono ADC"
> +			}
> +		}
>  	}
>  }
> diff --git a/ucm2/codecs/rt5640/IN1-InternalMic.conf b/ucm2/codecs/rt5640/IN1-InternalMic.conf
> index a317388..d670484 100644
> --- a/ucm2/codecs/rt5640/IN1-InternalMic.conf
> +++ b/ucm2/codecs/rt5640/IN1-InternalMic.conf
> @@ -34,5 +34,17 @@ SectionDevice."Mic" {
>  		CapturePCM "hw:${CardId}"
>  		CaptureMixerElem "IN1 Boost"
>  		CaptureVolume "IN1 Boost"
> +		If.In1Aif1 {
> +			Condition { Type String Empty "${var:HaveAif1}" }
> +			False {
> +				CaptureMasterElem "ADC"
> +			}
> +		}
> +		If.In1Aif2 {
> +			Condition { Type String Empty "${var:HaveAif2}" }
> +			False {
> +				CaptureMasterElem "Mono ADC"
> +			}
> +		}
>  	}
>  }
> diff --git a/ucm2/codecs/rt5640/IN3-InternalMic.conf b/ucm2/codecs/rt5640/IN3-InternalMic.conf
> index ef4eaba..345db1e 100644
> --- a/ucm2/codecs/rt5640/IN3-InternalMic.conf
> +++ b/ucm2/codecs/rt5640/IN3-InternalMic.conf
> @@ -34,5 +34,17 @@ SectionDevice."Mic" {
>  		CapturePCM "hw:${CardId}"
>  		CaptureMixerElem "IN3 Boost"
>  		CaptureVolume "IN3 Boost"
> +		If.In3Aif1 {
> +			Condition { Type String Empty "${var:HaveAif1}" }
> +			False {
> +				CaptureMasterElem "ADC"
> +			}
> +		}
> +		If.In3Aif2 {
> +			Condition { Type String Empty "${var:HaveAif2}" }
> +			False {
> +				CaptureMasterElem "Mono ADC"
> +			}
> +		}
>  	}
>  }
> diff --git a/ucm2/codecs/rt5640/MonoSpeaker.conf b/ucm2/codecs/rt5640/MonoSpeaker.conf
> index 3cbeafd..addaddd 100644
> --- a/ucm2/codecs/rt5640/MonoSpeaker.conf
> +++ b/ucm2/codecs/rt5640/MonoSpeaker.conf
> @@ -31,5 +31,17 @@ SectionDevice."Speaker" {
>  		PlaybackPCM "hw:${CardId}"
>  		PlaybackMixerElem "Speaker"
>  		PlaybackVolume "Speaker Playback Volume"
> +		If.MonoSpkAif1 {
> +			Condition { Type String Empty "${var:HaveAif1}" }
> +			False {
> +				PlaybackMasterElem "DAC1"
> +			}
> +		}
> +		If.MonoSpkAif2 {
> +			Condition { Type String Empty "${var:HaveAif2}" }
> +			False {
> +				PlaybackMasterElem "DAC2"
> +			}
> +		}
>  	}
>  }
> diff --git a/ucm2/codecs/rt5640/Speaker.conf b/ucm2/codecs/rt5640/Speaker.conf
> index 0924f9c..e7ff673 100644
> --- a/ucm2/codecs/rt5640/Speaker.conf
> +++ b/ucm2/codecs/rt5640/Speaker.conf
> @@ -31,5 +31,17 @@ SectionDevice."Speaker" {
>  		PlaybackPCM "hw:${CardId}"
>  		PlaybackMixerElem "Speaker"
>  		PlaybackVolume "Speaker Playback Volume"
> +		If.SpkAif1 {
> +			Condition { Type String Empty "${var:HaveAif1}" }
> +			False {
> +				PlaybackMasterElem "DAC1"
> +			}
> +		}
> +		If.SpkAif2 {
> +			Condition { Type String Empty "${var:HaveAif2}" }
> +			False {
> +				PlaybackMasterElem "DAC2"
> +			}
> +		}
>  	}
>  }
> 


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH alsa-ucm-conf v2 7/7] codecs/rt5640: Specify Playback/CaptureMasterElem for HW volume-control
  2021-03-13 12:10   ` Hans de Goede
@ 2021-03-13 16:05     ` Jaroslav Kysela
  0 siblings, 0 replies; 11+ messages in thread
From: Jaroslav Kysela @ 2021-03-13 16:05 UTC (permalink / raw)
  To: Hans de Goede; +Cc: alsa-devel, Pierre-Louis Bossart, Bard Liao

Dne 13. 03. 21 v 13:10 Hans de Goede napsal(a):
> Hi,
> 
> On 3/8/21 11:05 PM, Hans de Goede wrote:
>> Newer kernels add "aif:1" or "aif:2" to the components string to let
>> us know which AIF is being used.
>>
>> Use this to specify the correct Playback/CaptureMasterElem for HW
>> volume-control, based on which AIF is being used.
>>
>> On older kernels, where there is no "aif:%d" string in the components
>> string, no Playback/CaptureMasterElem is specified.
>>
>> In DigitalMics.conf the master mixer is used as regular CaptureMixerElem
>> instead of as CaptureMasterElem since the DMICs don't have any analog
>> volume control.
>>
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> 
> The kernel side of this patch has landed now, so this patch can
> be merged now.

Merged. Thank you.

				Jaroslav

-- 
Jaroslav Kysela <perex@perex.cz>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-03-13 16:06 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-08 22:05 [PATCH alsa-ucm-conf v2 0/7] codecs/rt5640: Cleanup + HW volume control support Hans de Goede
2021-03-08 22:05 ` [PATCH alsa-ucm-conf v2 1/7] codecs/rt5640: Cleanup: unify Stereo / Mono ADC handling Hans de Goede
2021-03-08 22:05 ` [PATCH alsa-ucm-conf v2 2/7] codecs/rt5640: Cleanup: Initially disable all inputs and outputs Hans de Goede
2021-03-08 22:05 ` [PATCH alsa-ucm-conf v2 3/7] codecs/rt5640: Cleanup: Move 'SPK MIX' setup to main EnableSequene Hans de Goede
2021-03-08 22:05 ` [PATCH alsa-ucm-conf v2 4/7] codecs/rt5640: Drop bogus 'DIG MIXL DAC L2 Switch' setting Hans de Goede
2021-03-08 22:05 ` [PATCH alsa-ucm-conf v2 5/7] codecs/rt5640: Unify capture volume for AIF1 and AIF2 recording paths Hans de Goede
2021-03-08 22:05 ` [PATCH alsa-ucm-conf v2 6/7] codecs/rt5640: Add hardware volume-control support Hans de Goede
2021-03-08 22:05 ` [PATCH alsa-ucm-conf v2 7/7] codecs/rt5640: Specify Playback/CaptureMasterElem for HW volume-control Hans de Goede
2021-03-13 12:10   ` Hans de Goede
2021-03-13 16:05     ` Jaroslav Kysela
2021-03-10 10:24 ` [PATCH alsa-ucm-conf v2 0/7] codecs/rt5640: Cleanup + HW volume control support Jaroslav Kysela

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).