Implement headphone autodetection, earpiece routing, and linear volume controls

- Fix msm8916-wcd ALSA UCM2 configs (Earpiece.conf, Speaker.conf,
  Headphones.conf, PrimaryMic.conf, HeadsetMic.conf) so Speaker,
  Earpiece, and Headphones outputs and Mic1/Headset inputs are always
  available and mutually exclusive without invalid mixer controls
- Add event-driven wired headphone/headset jack detection and automatic
  audio routing in sxmo_soundmonitor.sh via evtest on the msm8916
  Headset Jack input device
- Make Earpiece, Speaker, and Headphones first-class routable output
  devices across sxmo_audio.sh, sxmo_modemaudio.sh, xdrawer, dmenu, and
  callscreen
- Make volume controls strictly linear across all channels by keeping
  PipeWire software gain at unity (100%) when unmuted and linearly
  mapping 0-100% to hardware digital volume registers (RX3 for Speaker,
  RX1 for Earpiece, RX1+RX2 for Headphones, TX1+ADC for Microphone)
This commit is contained in:
Luxferre committed 2026-10-29 20:42:26 +02:00
1 parent e42eb573ed
commit 370f8b085c
33 files changed
+1351 -488

No files matched your search

@@ -1,27 +1,27 @@
SectionDevice."Earpiece" {
Comment "Earpiece playback"
Comment "Earpiece playback"
ConflictingDevice [
"Headphones"
]
ConflictingDevice [
"Speaker"
"Headphones"
]
EnableSequence [
cset "name='RX1 MIX1 INP1' RX1"
cset "name='RDAC2 MUX' RX1"
cset "name='EAR_S' 1"
## gain to +6dB
cset "name='RX1 Digital Volume' 90"
]
EnableSequence [
cset "name='RX1 MIX1 INP1' 'RX1'"
cset "name='RDAC2 MUX' 'RX1'"
cset "name='EAR_S' 1"
cset "name='RX1 Digital Volume' 90"
]
DisableSequence [
cset "name='RX1 Digital Volume' 0"
cset "name='EAR_S' 0"
cset "name='RX1 MIX1 INP1' ZERO"
]
DisableSequence [
cset "name='RX1 Digital Volume' 0"
cset "name='EAR_S' 0"
cset "name='RX1 MIX1 INP1' 'ZERO'"
]
Value {
PlaybackPCM "${var:WcdPlaybackPCM}"
PlaybackChannels 2
PlaybackPriority 100
}
Value {
PlaybackPCM "${var:WcdPlaybackPCM}"
PlaybackChannels 2
PlaybackPriority 200
}
}
@@ -0,0 +1,33 @@
SectionDevice."Headphones" {
Comment "Headphones playback"
ConflictingDevice [
"Speaker"
"Earpiece"
]
EnableSequence [
cset "name='RX1 MIX1 INP1' 'RX1'"
cset "name='RX2 MIX1 INP1' 'RX2'"
cset "name='RDAC2 MUX' 'RX2'"
cset "name='HPHL' 1"
cset "name='HPHR' 1"
cset "name='RX1 Digital Volume' 84"
cset "name='RX2 Digital Volume' 84"
]
DisableSequence [
cset "name='RX1 Digital Volume' 0"
cset "name='RX2 Digital Volume' 0"
cset "name='HPHL' 0"
cset "name='HPHR' 0"
cset "name='RX1 MIX1 INP1' 'ZERO'"
cset "name='RX2 MIX1 INP1' 'ZERO'"
]
Value {
PlaybackPCM "${var:WcdPlaybackPCM}"
PlaybackChannels 2
PlaybackPriority 250
}
}
@@ -0,0 +1,27 @@
SectionDevice."Headset" {
Comment "Headset Microphone"
ConflictingDevice [
"Mic1"
]
EnableSequence [
cset "name='DEC1 MUX' 'ADC2'"
cset "name='CIC1 MUX' 'AMIC'"
cset "name='ADC2 Volume' 8"
cset "name='ADC2 MUX' 'INP2'"
cset "name='TX1 Digital Volume' 88"
]
DisableSequence [
cset "name='ADC2 MUX' 'ZERO'"
cset "name='ADC2 Volume' 0"
cset "name='DEC1 MUX' 'ZERO'"
]
Value {
CapturePCM "${var:WcdCapturePCM}"
CaptureChannels 2
CapturePriority 300
}
}
@@ -0,0 +1,25 @@
SectionDevice."Mic1" {
Comment "Primary Microphone"
ConflictingDevice [
"Headset"
]
EnableSequence [
cset "name='DEC1 MUX' 'ADC1'"
cset "name='CIC1 MUX' 'AMIC'"
cset "name='ADC1 Volume' 8"
cset "name='TX1 Digital Volume' 88"
]
DisableSequence [
cset "name='DEC1 MUX' 'ZERO'"
cset "name='ADC1 Volume' 0"
]
Value {
CapturePCM "${var:WcdCapturePCM}"
CaptureChannels 2
CapturePriority 400
}
}
@@ -1,27 +1,26 @@
SectionDevice."Speaker" {
Comment "Speaker playback"
Comment "Speaker playback"
ConflictingDevice [
"Headphones"
"Earpiece"
]
ConflictingDevice [
"Earpiece"
"Headphones"
]
EnableSequence [
cset "name='SPK DAC Switch' 1"
cset "name='RX3 MIX1 INP1' RX1"
## gain to +8dB
cset "name='RX3 Digital Volume' 92"
]
EnableSequence [
cset "name='RX3 MIX1 INP1' 'RX1'"
cset "name='SPK DAC Switch' 1"
cset "name='RX3 Digital Volume' 88"
]
DisableSequence [
cset "name='RX3 Digital Volume' 0"
cset "name='SPK DAC Switch' 0"
cset "name='RX3 MIX1 INP1' ZERO"
]
DisableSequence [
cset "name='RX3 Digital Volume' 0"
cset "name='SPK DAC Switch' 0"
cset "name='RX3 MIX1 INP1' 'ZERO'"
]
Value {
PlaybackPCM "${var:WcdPlaybackPCM}"
PlaybackChannels 2
PlaybackPriority 200
}
Value {
PlaybackPCM "${var:WcdPlaybackPCM}"
PlaybackChannels 2
PlaybackPriority 300
}
}