- 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)
78 lines
2.3 KiB
Bash
Executable File
78 lines
2.3 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
export PATH="${XDG_CONFIG_HOME:-$HOME/.config}/sxmo/hooks:/usr/share/sxmo/default_hooks:$PATH"
|
|
|
|
# shellcheck source=scripts/core/sxmo_common.sh
|
|
. sxmo_common.sh
|
|
|
|
CFG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/sxmo"
|
|
|
|
enable_call_audio_mode() {
|
|
printf "1\n" > /tmp/sxmo_in_call 2>/dev/null || true
|
|
|
|
# If wired headphones are plugged in or currently routed, keep call audio on Headphones;
|
|
# otherwise route voice call audio to Earpiece by default.
|
|
cur_out="$(sxmo_audio.sh device get 2>/dev/null || printf "Speaker")"
|
|
jack_plugged=0
|
|
if [ -r /tmp/sxmo_jack_plugged ]; then
|
|
read -r jack_plugged < /tmp/sxmo_jack_plugged 2>/dev/null || jack_plugged=0
|
|
fi
|
|
|
|
if [ "$jack_plugged" = "1" ] || [ "$cur_out" = "Headphones" ]; then
|
|
target_out="Headphones"
|
|
else
|
|
target_out="Earpiece"
|
|
fi
|
|
|
|
sxmo_audio.sh device set "$target_out" >/dev/null 2>&1 || true
|
|
|
|
if command -v amixer >/dev/null 2>&1; then
|
|
amixer -c 0 cset "name='PRI_MI2S_RX Voice Mixer VoiceMMode1'" 1 >/dev/null 2>&1 || true
|
|
amixer -c 0 cset "name='VoiceMMode1 Capture Mixer TERT_MI2S_TX'" 1 >/dev/null 2>&1 || true
|
|
amixer -c 0 cset "name='MultiMedia2 Mixer TERT_MI2S_TX'" 0 >/dev/null 2>&1 || true
|
|
amixer -c 0 cset "name='RX1 Mute Switch'" 0 >/dev/null 2>&1 || true
|
|
fi
|
|
|
|
sxmo_log "Enabled ALSA voice call audio mode ($target_out)."
|
|
sxmo_hook_statusbar.sh volume >/dev/null 2>&1 || true
|
|
return 0
|
|
}
|
|
|
|
disable_call_audio_mode() {
|
|
rm -f /tmp/sxmo_in_call /tmp/sxmo_call_vol 2>/dev/null || true
|
|
|
|
jack_plugged=0
|
|
if [ -r /tmp/sxmo_jack_plugged ]; then
|
|
read -r jack_plugged < /tmp/sxmo_jack_plugged 2>/dev/null || jack_plugged=0
|
|
fi
|
|
|
|
if [ "$jack_plugged" = "1" ]; then
|
|
target_out="Headphones"
|
|
else
|
|
target_out="Speaker"
|
|
fi
|
|
|
|
if command -v amixer >/dev/null 2>&1; then
|
|
amixer -c 0 cset "name='PRI_MI2S_RX Voice Mixer VoiceMMode1'" 0 >/dev/null 2>&1 || true
|
|
amixer -c 0 cset "name='VoiceMMode1 Capture Mixer TERT_MI2S_TX'" 0 >/dev/null 2>&1 || true
|
|
amixer -c 0 cset "name='MultiMedia2 Mixer TERT_MI2S_TX'" 1 >/dev/null 2>&1 || true
|
|
fi
|
|
|
|
sxmo_audio.sh device set "$target_out" >/dev/null 2>&1 || true
|
|
sxmo_log "Disabled ALSA voice call audio mode ($target_out)."
|
|
sxmo_hook_statusbar.sh volume >/dev/null 2>&1 || true
|
|
return 0
|
|
}
|
|
|
|
setup_audio() {
|
|
enable_call_audio_mode
|
|
return 0
|
|
}
|
|
|
|
reset_audio() {
|
|
disable_call_audio_mode
|
|
return 0
|
|
}
|
|
|
|
"$@"
|