]> git.alsa-project.org Git - alsa-ucm-conf.git/commitdiff
ALSA: hda: mic: add initial support for driver source auto-switching HEAD master
authorJaroslav Kysela <perex@perex.cz>
Wed, 1 Jul 2026 14:41:23 +0000 (16:41 +0200)
committerJaroslav Kysela <perex@perex.cz>
Wed, 1 Jul 2026 14:45:36 +0000 (16:45 +0200)
Use boost volume controls to detect this case.

Link: https://github.com/alsa-project/alsa-ucm-conf/pull/792
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
ucm2/HDA/HiFi-mic.conf

index 37ffce547e72372f54f5d9a619cdf6cfea9245e1..e084700a5e0f9787c672683c19972aca36832ef6 100644 (file)
@@ -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
+# <Empty>,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: <Empty>,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'"
+               }
+               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}"
+                       }
+                       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"
+                               }
+                       }
                }
-               If.fmic {
-                       Condition {
-                               Type ControlExists
-                               Control "name='Front Mic Playback Switch'"
+               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
                        }
-                       True.Macro.fmic.HDAMicSwitch {
-                               DevName "Mic:hda-front"
-                               Comment "Front Stereo Microphone"
-                               Name "Front Mic"
-                               Priority 200
-                               Jack "Front Mic Jack"
+                       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}"
+                               }
                        }
                }
        }