From c17dfb63aeff72efb37996049c5dda525c33cd31 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Wed, 1 Jul 2026 16:41:23 +0200 Subject: [PATCH] ALSA: hda: mic: add initial support for driver source auto-switching Use boost volume controls to detect this case. Link: https://github.com/alsa-project/alsa-ucm-conf/pull/792 Signed-off-by: Jaroslav Kysela --- ucm2/HDA/HiFi-mic.conf | 83 +++++++++++++++++++++++++++++------------- 1 file changed, 58 insertions(+), 25 deletions(-) diff --git a/ucm2/HDA/HiFi-mic.conf b/ucm2/HDA/HiFi-mic.conf index 37ffce5..e084700 100644 --- a/ucm2/HDA/HiFi-mic.conf +++ b/ucm2/HDA/HiFi-mic.conf @@ -6,14 +6,16 @@ # Microphone related variables as used internally # HDA codecs can offer input source selection (mux) via "Input Source" or -# "Capture Source" with varying options: -# 'Internal Mic' -# 'Headset Mic' -# 'Headphone Mic' -# 'Mic' +# "Capture Source" with varying options '[PREFIX ]Mic' where PREFIX is +# ,Internal,Headset,Headphone. # # or there can be 'Mic' and optional 'Front Mic' available # +# There is also third variant - driver supports auto-switching. In +# this case, the '[Prefix ]Mic Boost Volume' controls exists. There are also +# phantom jacks exported by the driver in this case, but it's not +# necessary to use them. Prefixes: ,Internal,Front +# # This leads to up to maximum of four possible input devices. Define.SourceControl "" @@ -162,7 +164,7 @@ DefineMacro.HDAMicSwitch.SectionDevice."${var:__DevName}" { CaptureVolume "${var:__Name} Volume" CaptureSwitch "${var:__Name} Switch" CaptureMasterElem "${var:__Name} Boost" - JackControl "${var:__Jack}" + JackControl "${var:-__Jack}" } } @@ -202,27 +204,58 @@ If.micsetup { Jack "${var:MicHSJackControl}" } } - True { - # the input selection is via switches, the possible types are - # Mic and Front Mic - Macro.mic.HDAMicSwitch { - DevName "Mic:hda" - Comment "Stereo Microphone" - Name "Mic" - Priority 100 - Jack "${var:MicJackControl}" + True.If.autoswitch { + Condition { + Type ControlExists + Control "name='Internal Mic Boost Volume'" } - If.fmic { - Condition { - Type ControlExists - Control "name='Front Mic Playback Switch'" + False { + # the input selection is via switches, the possible types are + # Mic and Front Mic + Macro.mic.HDAMicSwitch { + DevName "Mic:hda" + Comment "Stereo Microphone" + Name "Mic" + Priority 100 + Jack "${var:MicJackControl}" } - True.Macro.fmic.HDAMicSwitch { - DevName "Mic:hda-front" - Comment "Front Stereo Microphone" - Name "Front Mic" - Priority 200 - Jack "Front Mic Jack" + If.fmic { + Condition { + Type ControlExists + Control "name='Front Mic Playback Switch'" + } + True.Macro.fmic.HDAMicSwitch { + DevName "Mic:hda-front" + Comment "Front Stereo Microphone" + Name "Front Mic" + Priority 200 + Jack "Front Mic Jack" + } + } + } + True { + # third variant - the driver does auto-switching + # note that we should assign right Jack controls to + # allow expose the boost volume + Macro.mic.HDAMicSwitch { + DevName "Mic:hda-int" + Comment "Internal Stereo Microphone" + Name "Internal Mic" + Priority 100 + } + If.mic { + # external microphone + Condition { + Type ControlExists + Control "name='Mic Boost Volume'" + } + True.Macro.mic.HDAMicSwitch { + DevName "Mic:hda" + Comment "Stereo Microphone" + Name "Mic" + Priority 200 + Jack "${var:MicJackControl}" + } } } }