# Generic handling of analog microphones on HDA devices
# Microphone related variables on entry
-# If DMIC is present:
-# (DeviceDmic == "Mic1")
-# DeviceMic == "Mic2"
-#
-# If DMIC is not present:
-# DeviceMic == "Mic"
+# MicType == "hda" # HDA microphone
+# MicType != "hda" # other microphone type (AMD 'acp', Intel 'sof-dsp')
# Microphone related variables as used internally
# HDA codecs can offer input source selection (mux) via "Input Source" or
# This leads to up to maximum of four possible input devices.
Define.SourceControl ""
+Define.MicExtraPriority 0
Define.MicJackControl ""
Define.MicHPJackControl ""
Define.MicHSJackControl ""
-# DeviceMic is pre-configured
-Define.DeviceMicName ""
-Define.DeviceMicComment ""
-Define.DeviceMicPriority ""
-Define.DeviceMicJack ""
-Define.DeviceMic2 ""
-Define.DeviceMic2Name ""
-Define.DeviceMic2Comment ""
-Define.DeviceMic2Priority ""
-Define.DeviceMic2Jack ""
-Define.DeviceMic3 ""
-Define.DeviceMic3Name ""
-Define.DeviceMic3Comment ""
-Define.DeviceMic3Priority ""
-Define.DeviceMic3Jack ""
-Define.DeviceMic4 ""
-Define.DeviceMic4Name ""
-Define.DeviceMic4Comment ""
-Define.DeviceMic4Priority ""
-Define.DeviceMic4Jack ""
-
# evaluate the microphone jack name
If.micjack {
Condition {
}
}
-# Set initial names and priorities for the SectionDevices based on the presence
-# of DMIC (DMIC is named as 'Mic1')
+# Extra priority for systems with DMIC presence (MicType != 'hda')
If.micdevs {
- # DeviceMic == "Mic2" indicates DMIC presence
- Condition {
- Type String
- String1 "${var:DeviceMic}"
- String2 "Mic2"
- }
- True.Define {
- # DeviceMic "Mic2" - already set (Mic1 is DMIC)
- DeviceMicPriority 200
- DeviceMic2 "Mic3"
- DeviceMic2Priority 300
- DeviceMic3 "Mic4"
- DeviceMic3Priority 400
- DeviceMic4 "Mic5"
- DeviceMic4Priority 500
- }
- False.Define {
- DeviceMic "Mic1"
- DeviceMicPriority 100
- DeviceMic2 "Mic2"
- DeviceMic2Priority 200
- DeviceMic3 "Mic3"
- DeviceMic3Priority 300
- DeviceMic4 "Mic4"
- DeviceMic4Priority 400
- }
-}
-
-# Scan the Microphone configuration in the system and set the definitions for
-# the SectionDevice creations for them.
-If.micsetup {
Condition {
Type String
- Empty "${var:SourceControl}"
- }
- False {
- # the input selection is via ENUM, the possible types are
- # Internal, Headset, Headphone and just 'Mic'
-
- # Internal Mic
- If.internalmic {
- Condition {
- Type ControlExists
- Control "name='${var:SourceControl}'"
- ControlEnum "Internal Mic"
- }
- True.Define {
- DeviceMicName "Internal Mic"
- DeviceMicComment "Internal Stereo Microphone"
- }
- }
-
- # Headphone Mic (Stereo Microphone in Headphone Jack)
- If.hpmic {
- Condition {
- Type ControlExists
- Control "name='${var:SourceControl}'"
- ControlEnum "Headphone Mic"
- }
- True.If.whichdev {
- Condition {
- Type String
- Empty "${var:DeviceMicName}"
- }
- True.Define {
- DeviceMicName "Headphone Mic"
- DeviceMicComment "Headphones Stereo Microphone"
- DeviceMicJack "${var:MicHPJackControl}"
- }
- False.Define {
- DeviceMic2Name "Headphone Mic"
- DeviceMic2Comment "Headphones Stereo Microphone"
- DeviceMic2Jack "${var:MicHPJackControl}"
- }
- }
- }
-
- # Just 'Mic'
- If.justmic {
- Condition {
- Type ControlExists
- Control "name='${var:SourceControl}'"
- ControlEnum "Mic"
- }
- True.If.whichdev {
- Condition {
- Type String
- Empty "${var:DeviceMicName}"
- }
- True.Define {
- DeviceMicName "Mic"
- DeviceMicComment "Stereo Microphone"
- DeviceMicJack "${var:MicJackControl}"
- }
- False.If.whichdev2 {
- Condition {
- Type String
- Empty "${var:DeviceMic2Name}"
- }
- True.Define {
- DeviceMic2Name "Mic"
- DeviceMic2Comment "Stereo Microphone"
- DeviceMic2Jack "${var:MicJackControl}"
- }
- False.Define {
- DeviceMic3Name "Mic"
- DeviceMic3Comment "Stereo Microphone"
- DeviceMic3Jack "${var:MicJackControl}"
- }
- }
- }
- }
-
- # Headset Mono Mic
- If.hsmic {
- Condition {
- Type ControlExists
- Control "name='${var:SourceControl}'"
- ControlEnum "Headset Mic"
- }
- True.If.whichdev {
- # Override the DeviceMicX (which is used as
- # SectionDevice name) for headset mic as per
- # UCM naming convention, reference:
- # https://github.com/alsa-project/alsa-lib/blob/master/include/use-case.h
- Condition {
- Type String
- Empty "${var:DeviceMicName}"
- }
- True.Define {
- DeviceMic "Headset"
- DeviceMicName "Headset Mic"
- DeviceMicComment "Headset Mono Microphone"
- DeviceMicJack "${var:MicHSJackControl}"
- }
- False.If.whichdev2 {
- Condition {
- Type String
- Empty "${var:DeviceMic2Name}"
- }
- True.Define {
- DeviceMic2 "Headset"
- DeviceMic2Name "Headset Mic"
- DeviceMic2Comment "Headset Mono Microphone"
- DeviceMic2Jack "${var:MicHSJackControl}"
- }
- False.If.whichdev3 {
- Condition {
- Type String
- Empty "${var:DeviceMic2Name}"
- }
- True.Define {
- DeviceMic3 "Headset"
- DeviceMic3Name "Headset Mic"
- DeviceMic3Comment "Headset Mono Microphone"
- DeviceMic3Jack "${var:MicHSJackControl}"
- }
- False.Define {
- DeviceMic4 "Headset"
- DeviceMic4Name "Headset Mic"
- DeviceMic4Comment "Headset Mono Microphone"
- DeviceMic4Jack "${var:MicHSJackControl}"
- }
- }
-
- }
- }
- }
- }
- True {
- # the input selection is via switches, the possible types are
- # Mic and Front Mic
- Define {
- DeviceMicName "Mic"
- DeviceMicComment "Stereo Microphone"
- DeviceMicJack "${var:MicJackControl}"
- DeviceMicPriority 200
- }
-
- If.fmic {
- Condition {
- Type ControlExists
- Control "name='Front Mic Playback Switch'"
- }
- True.Define {
- DeviceMic2Name "Front Mic"
- DeviceMic2Comment "Front Stereo Microphone"
- DeviceMic2Jack "Front Mic Jack"
- DeviceMic2Priority 300
- }
- }
+ String1 "${var:MicType}"
+ String2 "hda"
}
+ False.Define.MicExtraPriority 100
}
-# Macro HDACaptureDevice - Create the SectionDevice for HDA inputs
+# Macro HDAMicEnum - Create the SectionDevice for HDA inputs
#
# Arguments:
# DevName - Name of the device (used as SectionDevice."${var:__DevName}"
-# MicName - Name of the Microphone
-# DevComment - Long name of the SectionDevice
-# JackName - Jack control if available
+# Enum - Name of the source/input enum
+# Comment - Long name of the SectionDevice
+# Jack - Jack control if available
# Priority - CapturePriority
-# ConflictCondition1 - (string) if not empty, set ConflictingDevice 1
-# ConflictDev1 - Name of the ConflictingDevice 1
-# ConflictCondition2 - (string) if not empty, set ConflictingDevice 2
-# ConflictDev2 - Name of the ConflictingDevice 2
-# ConflictCondition3 - (string) if not empty, set ConflictingDevice 3
-# ConflictDev3 - Name of the ConflictingDevice 3
-DefineMacro.HDACaptureDevice.SectionDevice."${var:__DevName}" {
- Comment "${var:__DevComment}"
+DefineMacro.HDAMicEnum.SectionDevice."${var:__DevName}" {
+ Comment "${var:__Comment}"
- If.micsetup {
- Condition {
- Type String
- Empty "${var:SourceControl}"
- }
- False.EnableSequence [
- cset "name='${var:SourceControl}' '${var:__MicName}'"
- ]
- }
+ EnableSequence [
+ cset "name='${var:SourceControl}' '${var:__Enum}'"
+ ]
Value {
- CapturePriority "${var:__Priority}"
+ CapturePriority "${eval:($__Priority+$MicExtraPriority)}"
CapturePCM "hw:${CardId}"
CaptureMixerElem "Capture"
CaptureVolume "Capture Volume"
CaptureSwitch "Capture Switch"
- CaptureMasterElem "${var:__MicName} Boost"
+ CaptureMasterElem "${var:__Enum} Boost"
}
If.jack {
Condition {
Type String
- Empty "${var:__JackName}"
+ Empty "${var:-__Jack}"
}
- False.Value.JackControl "${var:__JackName}"
+ False.Value.JackControl "${var:__Jack}"
}
- If.conflict1 {
- Condition {
- Type String
- Empty "${var:-__ConflictCondition1}"
- }
- False.ConflictingDevice [
- "${var:-__ConflictDev1}"
- ]
- }
- If.conflict2 {
- Condition {
- Type String
- Empty "${var:-__ConflictCondition2}"
- }
- False.ConflictingDevice [
- "${var:-__ConflictDev2}"
- ]
- }
- If.conflict3 {
- Condition {
- Type String
- Empty "${var:-__ConflictCondition3}"
- }
- False.ConflictingDevice [
- "${var:-__ConflictDev3}"
- ]
- }
+ ConflictingDevice [
+ "Mic:hda-int"
+ "Mic:hda-hp"
+ "Mic:hda"
+ "Headset:hda-mic"
+ ]
}
-If.mic1 {
- Condition {
- Type String
- Empty "${var:DeviceMicName}"
- }
- False.Macro.0.HDACaptureDevice {
- DevName "${var:DeviceMic}"
- MicName "${var:DeviceMicName}"
- DevComment "${var:DeviceMicComment}"
- JackName "${var:DeviceMicJack}"
- Priority "${var:DeviceMicPriority}"
- ConflictCondition1 "${var:DeviceMic2Name}" ConflictDev1 "${var:DeviceMic2}"
- ConflictCondition2 "${var:DeviceMic3Name}" ConflictDev2 "${var:DeviceMic3}"
- ConflictCondition3 "${var:DeviceMic4Name}" ConflictDev3 "${var:DeviceMic4}"
- }
-}
+# Macro HDAMicSwitch - Create the SectionDevice for HDA inputs (switches)
+#
+# Arguments:
+# DevName - Name of the device (used as SectionDevice."${var:__DevName}"
+# Name - Name of the controls
+# Comment - Long name of the SectionDevice
+# Jack - Jack control if available
+# Priority - CapturePriority
+DefineMacro.HDAMicSwitch.SectionDevice."${var:__DevName}" {
+ Comment "${var:__Comment}"
-If.mic2 {
- Condition {
- Type String
- Empty "${var:DeviceMic2Name}"
- }
- False.Macro.1.HDACaptureDevice {
- DevName "${var:DeviceMic2}"
- MicName "${var:DeviceMic2Name}"
- DevComment "${var:DeviceMic2Comment}"
- JackName "${var:DeviceMic2Jack}"
- Priority "${var:DeviceMic2Priority}"
- ConflictCondition1 "${var:DeviceMic3Name}" ConflictDev1 "${var:DeviceMic3}"
- ConflictCondition2 "${var:DeviceMic4Name}" ConflictDev2 "${var:DeviceMic4}"
+ Value {
+ CapturePriority "${eval:($__Priority+$MicExtraPriority)}"
+ CapturePCM "hw:${CardId}"
+ CaptureMixerElem "${var:__Name}"
+ CaptureVolume "${var:__Name} Volume"
+ CaptureSwitch "${var:__Name} Switch"
+ CaptureMasterElem "${var:__Name} Boost"
+ JackControl "${var:__Jack}"
}
}
-If.mic3 {
+If.micsetup {
Condition {
Type String
- Empty "${var:DeviceMic3Name}"
- }
- False.Macro.1.HDACaptureDevice {
- DevName "${var:DeviceMic3}"
- MicName "${var:DeviceMic3Name}"
- DevComment "${var:DeviceMic3Comment}"
- JackName "${var:DeviceMic3Jack}"
- Priority "${var:DeviceMic3Priority}"
- ConflictCondition1 "${var:DeviceMic4Name}" ConflictDev1 "${var:DeviceMic4}"
+ Empty "${var:SourceControl}"
}
-}
-
-If.mic4 {
- Condition {
- Type String
- Empty "${var:DeviceMic4Name}"
+ False {
+ # the input selection is via ENUM, the possible types are
+ # Internal, Headset, Headphone and just 'Mic'
+ Macro.in.HDAMicEnum {
+ DevName "Mic:hda-int"
+ Comment "Internal Stereo Microphone"
+ Enum "Internal Mic"
+ Priority 100
+ }
+ Macro.hp.HDAMicEnum {
+ DevName "Mic:hda-hp"
+ Comment "Headphones Stereo Microphone"
+ Enum "Headphone Mic"
+ Priority 200
+ Jack "${var:MicHPJackControl}"
+ }
+ Macro.mi.HDAMicEnum {
+ DevName "Mic:hda"
+ Comment "Stereo Microphone"
+ Enum "Mic"
+ Priority 300
+ Jack "${var:MicJackControl}"
+ }
+ Macro.hs.HDAMicEnum {
+ DevName "Headset:hda-mic"
+ Comment "Headset Mono Microphone"
+ Enum "Headset Mic"
+ Priority 400
+ Jack "${var:MicHSJackControl}"
+ }
}
- False.Macro.1.HDACaptureDevice {
- DevName "${var:DeviceMic4}"
- MicName "${var:DeviceMic4Name}"
- DevComment "${var:DeviceMic4Comment}"
- JackName "${var:DeviceMic4Jack}"
- Priority "${var:DeviceMic4Priority}"
+ 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}"
+ }
+ 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"
+ }
+ }
}
}