codecs/rt5640: Cleanup + HW volume control support
v2 cover codecs/rt5640: Cleanup + HW volume control support
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(-)
Signature · 1 line
2.30.1
PATCH v2 1/7 codecs/rt5640: Cleanup: unify Stereo / Mono ADC handling
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.
--- 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(-)
ucm2/codecs/rt5640/DigitalMics.conf +0 -2
@@ -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"
ucm2/codecs/rt5640/EnableSeq.conf +7 -3
@@ -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" ]
ucm2/codecs/rt5640/HeadsetMic.conf +2 -8
@@ -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 {
ucm2/codecs/rt5640/IN1-InternalMic.conf +2 -9
@@ -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 {
ucm2/codecs/rt5640/IN3-InternalMic.conf +2 -9
@@ -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 {
Signature · 1 line
2.30.1
PATCH v2 2/7 codecs/rt5640: Cleanup: Initially disable all inputs and outputs
In reply to Hans de GoedeCleanup: 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.
--- 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(-)
ucm2/codecs/rt5640/EnableSeq.conf +21 -0
@@ -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" ]
ucm2/codecs/rt5640/HeadPhones.conf +0 -1
@@ -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"
ucm2/codecs/rt5640/IN1-InternalMic.conf +0 -2
@@ -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"
ucm2/codecs/rt5640/IN3-InternalMic.conf +0 -2
@@ -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"
ucm2/codecs/rt5640/MonoSpeaker.conf +0 -1
@@ -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"
ucm2/codecs/rt5640/Speaker.conf +0 -1
@@ -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"
Signature · 1 line
2.30.1
PATCH v2 3/7 codecs/rt5640: Cleanup: Move 'SPK MIX' setup to main EnableSequene
In reply to Hans de GoedeCleanup: 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.
--- 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(-)
ucm2/codecs/rt5640/EnableSeq.conf +4 -2
@@ -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"
ucm2/codecs/rt5640/MonoSpeaker.conf +0 -2
@@ -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"
ucm2/codecs/rt5640/Speaker.conf +0 -2
@@ -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
Signature · 1 line
2.30.1
PATCH v2 4/7 codecs/rt5640: Drop bogus 'DIG MIXL DAC L2 Switch' setting
In reply to Hans de GoedeThe 'DIG MIXL DAC L2 Switch' path is only used for Digital Mixer Path loopback, which we don't use. Drop it.
--- ucm2/codecs/rt5640/EnableSeq.conf | 1 - 1 file changed, 1 deletion(-)
ucm2/codecs/rt5640/EnableSeq.conf +0 -1
@@ -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"
Signature · 1 line
2.30.1
PATCH v2 5/7 codecs/rt5640: Unify capture volume for AIF1 and AIF2 recording paths
In reply to Hans de GoedeThe 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.
--- ucm2/codecs/rt5640/EnableSeq.conf | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
ucm2/codecs/rt5640/EnableSeq.conf +8 -4
@@ -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"
Signature · 1 line
2.30.1
PATCH v2 6/7 codecs/rt5640: Add hardware volume-control support
In reply to Hans de GoedeAdd 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.
--- 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(+)
ucm2/codecs/rt5640/HeadPhones.conf +2 -0
@@ -35,5 +35,7 @@ SectionDevice."Headphones" { PlaybackPriority 300 PlaybackPCM "hw:${CardId}" JackControl "Headphone Jack" + PlaybackMixerElem "HP" + PlaybackVolume "HP Playback Volume" } }
ucm2/codecs/rt5640/HeadsetMic.conf +2 -0
@@ -41,5 +41,7 @@ SectionDevice."Headset" { CapturePriority 200 CapturePCM "hw:${CardId}" JackControl "Headset Mic Jack" + CaptureMixerElem "IN2 Boost" + CaptureVolume "IN2 Boost" } }
ucm2/codecs/rt5640/IN1-InternalMic.conf +2 -0
@@ -32,5 +32,7 @@ SectionDevice."Mic" { Value { CapturePriority 100 CapturePCM "hw:${CardId}" + CaptureMixerElem "IN1 Boost" + CaptureVolume "IN1 Boost" } }
ucm2/codecs/rt5640/IN3-InternalMic.conf +2 -0
@@ -32,5 +32,7 @@ SectionDevice."Mic" { Value { CapturePriority 100 CapturePCM "hw:${CardId}" + CaptureMixerElem "IN3 Boost" + CaptureVolume "IN3 Boost" } }
ucm2/codecs/rt5640/MonoSpeaker.conf +2 -0
@@ -29,5 +29,7 @@ SectionDevice."Speaker" { Value { PlaybackPriority 100 PlaybackPCM "hw:${CardId}" + PlaybackMixerElem "Speaker" + PlaybackVolume "Speaker Playback Volume" } }
ucm2/codecs/rt5640/Speaker.conf +2 -0
@@ -29,5 +29,7 @@ SectionDevice."Speaker" { Value { PlaybackPriority 100 PlaybackPCM "hw:${CardId}" + PlaybackMixerElem "Speaker" + PlaybackVolume "Speaker Playback Volume" } }
Signature · 1 line
2.30.1
PATCH v2 7/7 codecs/rt5640: Specify Playback/CaptureMasterElem for HW volume-control
In reply to Hans de GoedeNewer 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.
--- 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(+)
ucm2/bytcr-rt5640/HiFi.conf +21 -0
@@ -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"
ucm2/codecs/rt5640/DigitalMics.conf +16 -0
@@ -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" + } + } } }
ucm2/codecs/rt5640/HeadPhones.conf +12 -0
@@ -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" + } + } } }
ucm2/codecs/rt5640/HeadsetMic.conf +12 -0
@@ -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" + } + } } }
ucm2/codecs/rt5640/IN1-InternalMic.conf +12 -0
@@ -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" + } + } } }
ucm2/codecs/rt5640/IN3-InternalMic.conf +12 -0
@@ -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" + } + } } }
ucm2/codecs/rt5640/MonoSpeaker.conf +12 -0
@@ -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" + } + } } }
ucm2/codecs/rt5640/Speaker.conf +12 -0
@@ -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" + } + } } }
Signature · 1 line
2.30.1
Re: [PATCH alsa-ucm-conf v2 7/7] codecs/rt5640: Specify Playback/CaptureMasterElem for HW volume-control
Hi,
Quoted 6 lines · Hans de Goede
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.
Quoted 8 lines
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 <[email protected]>
The kernel side of this patch has landed now, so this patch can be merged now.
Thanks & Regards,
Hans
Quoted 201 lines
--- 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(+)ucm2/bytcr-rt5640/HiFi.conf +21
-0@@ -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"ucm2/codecs/rt5640/DigitalMics.conf +16
-0@@ -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" + } + } } }ucm2/codecs/rt5640/HeadPhones.conf +12
-0@@ -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" + } + } } }ucm2/codecs/rt5640/HeadsetMic.conf +12
-0@@ -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" + } + } } }ucm2/codecs/rt5640/IN1-InternalMic.conf +12
-0@@ -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" + } + } } }ucm2/codecs/rt5640/IN3-InternalMic.conf +12
-0@@ -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" + } + } } }ucm2/codecs/rt5640/MonoSpeaker.conf +12
-0@@ -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" + } + } } }ucm2/codecs/rt5640/Speaker.conf +12
-0@@ -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" + } + } } }
Re: [PATCH alsa-ucm-conf v2 7/7] codecs/rt5640: Specify Playback/CaptureMasterElem for HW volume-control
Dne 13. 03. 21 v 13:10 Hans de Goede napsal(a):
Quoted 12 lines
Hi,
Quoted 9 lines · Hans de Goede
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.
Quoted 8 lines
Quoted 5 lines
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 <[email protected]>The kernel side of this patch has landed now, so this patch can be merged now.
Merged. Thank you.
Jaroslav
Signature · 2 lines
Jaroslav Kysela <[email protected]> Linux Sound Maintainer; ALSA Project; Red Hat, Inc.
Dne 08. 03. 21 v 23:05 Hans de Goede napsal(a):
Quoted 5 lines
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.
Quoted 8 lines
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
Signature · 2 lines
Jaroslav Kysela <[email protected]> Linux Sound Maintainer; ALSA Project; Red Hat, Inc.