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:
1 parent
e42eb573ed
commit
370f8b085c
33 files changed
+1351
-488
No files matched your search
@@ -152,8 +152,7 @@ finish() {
|
||||
fi
|
||||
pkill -TERM -x sxmo_vibrate 2>/dev/null || true
|
||||
if ! is_call_picked_up; then
|
||||
amixer -c 0 cset "name='RX3 Digital Volume'" "$SAVED_RX3" >/dev/null 2>&1 || true
|
||||
wpctl set-volume @DEFAULT_AUDIO_SINK@ "${SAVED_SPK_VOL}%" >/dev/null 2>&1 || true
|
||||
sxmo_audio.sh device apply >/dev/null 2>&1 || true
|
||||
fi
|
||||
exit 0
|
||||
}
|
||||
@@ -170,8 +169,7 @@ ring() {
|
||||
if [ "${SXMO_RINGVOL:-100}" -le 0 ] || [ -z "${SXMO_RINGTONE:-}" ] || [ ! -f "$SXMO_RINGTONE" ]; then
|
||||
return 0
|
||||
fi
|
||||
ring_rx3=$(( 60 + SXMO_RINGVOL * 24 / 100 ))
|
||||
pw_vol="$(awk -v v="$SXMO_RINGVOL" 'BEGIN { printf "%.2f", v / 100.0 }')"
|
||||
ring_rx3=$(( 56 + (SXMO_RINGVOL * 32 + 50) / 100 ))
|
||||
|
||||
(
|
||||
rchild=""
|
||||
@@ -187,7 +185,7 @@ cset "name='RX3 MIX1 INP1'" 3
|
||||
cset "name='RX3 Digital Volume'" $ring_rx3
|
||||
EOF
|
||||
wpctl set-mute @DEFAULT_AUDIO_SINK@ 0 >/dev/null 2>&1 || true
|
||||
wpctl set-volume @DEFAULT_AUDIO_SINK@ "${SXMO_RINGVOL}%" >/dev/null 2>&1 || true
|
||||
wpctl set-volume @DEFAULT_AUDIO_SINK@ 100% >/dev/null 2>&1 || true
|
||||
|
||||
(
|
||||
for d in 0.15 0.40; do
|
||||
@@ -198,7 +196,7 @@ cset "name='SPK DAC Switch'" 1
|
||||
cset "name='RX3 MIX1 INP1'" 3
|
||||
cset "name='RX3 Digital Volume'" $ring_rx3
|
||||
EOF
|
||||
wpctl set-volume @DEFAULT_AUDIO_SINK@ "${SXMO_RINGVOL}%" >/dev/null 2>&1 || true
|
||||
wpctl set-volume @DEFAULT_AUDIO_SINK@ 100% >/dev/null 2>&1 || true
|
||||
done
|
||||
) &
|
||||
vhelper="$!"
|
||||
@@ -217,8 +215,8 @@ EOF
|
||||
while [ "$i" -lt "$loops" ]; do
|
||||
should_stop_ringing && break
|
||||
amixer -c 0 cset "name='RX3 Digital Volume'" "$ring_rx3" >/dev/null 2>&1 || true
|
||||
wpctl set-volume @DEFAULT_AUDIO_SINK@ "${SXMO_RINGVOL}%" >/dev/null 2>&1 || true
|
||||
pw-play --volume="$pw_vol" "$SXMO_RINGTONE" >/dev/null 2>&1 &
|
||||
wpctl set-volume @DEFAULT_AUDIO_SINK@ 100% >/dev/null 2>&1 || true
|
||||
pw-play --volume=1.0 "$SXMO_RINGTONE" >/dev/null 2>&1 &
|
||||
rchild="$!"
|
||||
wait "$rchild" 2>/dev/null
|
||||
rc="$?"
|
||||
@@ -239,7 +237,7 @@ EOF
|
||||
if [ "$use_pw" -eq 0 ] && ! should_stop_ringing; then
|
||||
mpv --no-config --no-terminal --no-resume-playback --quiet --vo=null --no-video \
|
||||
--ao=pipewire,pulse,alsa --audio-channels=stereo --audio-samplerate=48000 \
|
||||
--volume-max=150 --volume="$SXMO_RINGVOL" \
|
||||
--volume-max=100 --volume=100 \
|
||||
--loop="$loops" "$SXMO_RINGTONE" </dev/null >/dev/null 2>&1 &
|
||||
rchild="$!"
|
||||
wait "$rchild" 2>/dev/null || true
|
||||
|
||||
@@ -47,20 +47,7 @@ if [ -z "$SXMO_NO_AUDIO" ]; then
|
||||
superctl start sxmo_soundmonitor
|
||||
(
|
||||
sleep 1
|
||||
spk_vol=100
|
||||
if [ -r "$XDG_CONFIG_HOME/sxmo/speaker_vol" ]; then
|
||||
read -r spk_vol < "$XDG_CONFIG_HOME/sxmo/speaker_vol" 2>/dev/null || spk_vol=100
|
||||
fi
|
||||
case "$spk_vol" in ''|*[!0-9]*) spk_vol=100 ;; esac
|
||||
if [ "$spk_vol" -le 0 ]; then
|
||||
amixer -c 0 cset "name='RX3 Digital Volume'" 0 >/dev/null 2>&1 || true
|
||||
wpctl set-volume @DEFAULT_AUDIO_SINK@ 0% >/dev/null 2>&1 || true
|
||||
else
|
||||
rx3_hw=$(( 60 + spk_vol * 32 / 100 ))
|
||||
amixer -c 0 cset "name='SPK DAC Switch'" 1 >/dev/null 2>&1 || true
|
||||
amixer -c 0 cset "name='RX3 Digital Volume'" "$rx3_hw" >/dev/null 2>&1 || true
|
||||
wpctl set-volume @DEFAULT_AUDIO_SINK@ "${spk_vol}%" >/dev/null 2>&1 || true
|
||||
fi
|
||||
sxmo_audio.sh device apply >/dev/null 2>&1 || true
|
||||
sxmo_hook_statusbar.sh volume >/dev/null 2>&1 || true
|
||||
) &
|
||||
fi
|
||||
|
||||
Reference in new issue
Block a user