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

@@ -0,0 +1,111 @@
#!/bin/sh
# configversion: c73f9334f62c4c1addcaf074cbcb91e8
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2022 Sxmo Contributors
# Runs upon system start and starts various background services
# include common definitions
# shellcheck source=scripts/core/sxmo_common.sh
. sxmo_common.sh
# Create xdg user directories, such as ~/Pictures
[ -d "$HOME/Pictures" ] || xdg-user-dirs-update &
# Ensure fontconfig cache is valid without forcing a full rescan on every boot
if command -v fc-cache > /dev/null && [ -z "$(ls -A /var/cache/fontconfig 2>/dev/null)" ]; then
fc-cache >/dev/null 2>&1 &
fi
if ! superctl status > /dev/null 2>&1; then
pkill -9 -x superd > /dev/null 2>&1 || true
rm -f "$XDG_RUNTIME_DIR/superd.lock" "$XDG_RUNTIME_DIR/superd.sock"
sxmo_jobs.sh start daemon_manager superd
while ! superctl status > /dev/null 2>&1; do
sleep 0.05
done
fi
if [ -n "$SXMO_ROTATE_START" ]; then
sxmo_rotate.sh
fi
# Load our sound daemons
if [ -z "$SXMO_NO_AUDIO" ]; then
if ! [ -d /run/systemd/system ]; then
if [ "$(command -v pulseaudio)" ]; then
superctl start pulseaudio
elif [ "$(command -v pipewire)" ]; then
# pipewire-pulse will start pipewire
pidof -s pipewire >/dev/null 2>&1 || superctl start pipewire-pulse
pidof -s wireplumber >/dev/null 2>&1 || superctl start wireplumber
fi
fi
# monitor for headphone for statusbar
superctl start sxmo_soundmonitor
(
sleep 1
sxmo_audio.sh device apply >/dev/null 2>&1 || true
sxmo_hook_statusbar.sh volume >/dev/null 2>&1 || true
) &
fi
# Periodically update some status bar components
sxmo_hook_statusbar.sh all
sxmo_jobs.sh start statusbar_periodics sxmo_run_aligned.sh 60 \
sxmo_hook_statusbar.sh periodics
# dunst is required for warnings.
superctl start dunst
# start adaptive brightness at boot
# superctl start sxmo_adaptivebrightness
# load X11 dwm services
[ "$(command -v sxmo_xob)" ] && superctl start sxmo_xob
[ "$(command -v bonsaid)" ] && superctl start bonsaid
if [ "$(command -v fcitx5)" ]; then
superctl start fcitx5
fi
[ -n "$SXMO_MONITOR" ] && xrandr --output "$SXMO_MONITOR" --primary
# Keep system awake so keypad, lid, and power keys always wake the screen immediately
mkdir -p "$XDG_CACHE_HOME/sxmo"
touch "$XDG_CACHE_HOME/sxmo/sxmo.nosuspend"
if sxmo_wakelock.sh isenabled; then
sxmo_wakelock.sh lock sxmo_not_suspendable infinite
fi
# To setup initial unlock state
sxmo_state.sh set unlock
# Turn on lisgd only on touch devices
if [ -z "$SXMO_NO_VIRTUAL_KEYBOARD" ] && [ ! -e "$XDG_CACHE_HOME"/sxmo/sxmo.nogesture ]; then
superctl start sxmo_hook_lisgd
fi
if [ -z "$SXMO_NO_MODEM" ] && command -v ModemManager > /dev/null; then
# Turn on the dbus-monitors for modem-related tasks
superctl start sxmo_modemmonitor
# place a wakelock for 120s to allow the modem to fully warm up (eg25 +
# elogind/systemd would do this for us, but we don't use those.)
sxmo_wakelock.sh lock sxmo_modem_warming_up 120s
fi
# Start the desktop widget (e.g. clock)
pidof -s conky >/dev/null 2>&1 || DISPLAY=:0 CONKY_DPY=:0 conky -c /home/user/.config/sxmo/conky.conf -d >/dev/null 2>&1 </dev/null || true
# It watch network changes and update the status bar icon by example
superctl start sxmo_networkmonitor
# The daemon that display notifications popup messages
superctl start sxmo_notificationmonitor
# Pre-warm app and script menu caches in background
(
sxmo_hook_apps.sh >/dev/null 2>&1 || true
sxmo_hook_scripts.sh >/dev/null 2>&1 || true
) &