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

+17 -4
View File
@@ -2549,11 +2549,24 @@ open_builtin_menu(const char *menu_name, int keep_idx)
snprintf(label, sizeof(label), "%s Do Not Disturb %s", ICON_ZZZ, (access(pbuf, F_OK) == 0) ? ICON_TON : ICON_TOF);
add_menu_item(label, "@toggle:dnd", 1);
snprintf(label, sizeof(label), "%s Route to Speaker", ICON_MUS);
add_menu_item(label, "amixer -c 0 cset name='SPK DAC Switch' on >/dev/null 2>&1; sxmo_hook_statusbar.sh audio", 1);
char out_dev[64] = "Speaker";
if (!read_first_line("/tmp/sxmo_audio_out_device", out_dev, sizeof(out_dev))) {
snprintf(pbuf, sizeof(pbuf), "%s/.config/sxmo/audio_out_device", home);
read_first_line(pbuf, out_dev, sizeof(out_dev));
}
int is_ear = (strstr(out_dev, "Earpiece") != NULL || strstr(out_dev, "earpiece") != NULL);
int is_hp = (strstr(out_dev, "Headphone") != NULL || strstr(out_dev, "headphone") != NULL ||
strstr(out_dev, "Headset") != NULL || strstr(out_dev, "headset") != NULL);
int is_spk = (!is_ear && !is_hp);
snprintf(label, sizeof(label), "%s Route to Earpiece", ICON_PHN);
add_menu_item(label, "amixer -c 0 cset name='SPK DAC Switch' off >/dev/null 2>&1; sxmo_hook_statusbar.sh audio", 1);
snprintf(label, sizeof(label), "%s Route to Speaker %s", ICON_MUS, is_spk ? ICON_TON : ICON_TOF);
add_menu_item(label, "printf 'Speaker\\n' > /tmp/sxmo_audio_out_device; sxmo_audio.sh device set Speaker >/dev/null 2>&1", 1);
snprintf(label, sizeof(label), "%s Route to Earpiece %s", ICON_PHN, is_ear ? ICON_TON : ICON_TOF);
add_menu_item(label, "printf 'Earpiece\\n' > /tmp/sxmo_audio_out_device; sxmo_audio.sh device set Earpiece >/dev/null 2>&1", 1);
snprintf(label, sizeof(label), "%s Route to Headphones %s", ICON_MUS, is_hp ? ICON_TON : ICON_TOF);
add_menu_item(label, "printf 'Headphones\\n' > /tmp/sxmo_audio_out_device; sxmo_audio.sh device set Headphones >/dev/null 2>&1", 1);
snprintf(label, sizeof(label), "%s System Menu", ICON_MNU);
add_menu_item(label, "@menu:sys", 1);