Files
bananarchy/overlay/rootfs/usr/bin/sxmo_modemaudio.sh
T
Luxferre 786480a08f Implement 0011 boot ICC, OPP latency, USB PHY, Q6ASM/ALSA, and ZRAM fixes
- Add patches/kernel/0011-msm8909-boot-icc-opp-usb-audio-fixes.patch and update all six standalone device DTS files: mark XPU-restricted MSM8909 PCNOC interconnect nodes ap_owned with NOC_QOS_MODE_INVALID to clear -ENXIO errors, move clock-latency-ns onto each CPU opp child node so cpuinfo_transition_latency reports 100 us instead of CPUFREQ_ETERNAL (6.44 s schedutil rate limit), convert qcom-cpufreq-nvmem OPP deferrals to dev_err_probe, guard fixed 3.075 V pm8909_l13 in phy-qcom-usb-hs, handle async WRITE_V2/READ_V2 and synchronous EOS APR responses in q6asm, and disable unrouted dai-link-multimedia3 while setting q6voice_device=3 for shifted VoiceMMode1 (hw:0,3).
- Restore /bin, /usr/bin, and /usr/sbin BusyBox applet symlinks (excluding pkill) in apply-bananarchy-overlay.sh, size /dev/zram0 from /proc/meminfo in zramstart, guard "/" D-Bus object paths in NetworkManager 50-dns-filter.sh, sync schedutil rate_limit_us in bananarchy-display-power-sync, replace remaining pkill/pgrep -f uses in X11/hook/modem scripts, and clean temporary AT response files via trap in msm-modem-uim-selection.
- Verify live after reboot on nokia-argon, rebuild a1114 (carbonara) images/archives for nokia-argon and nokia-beatles with e2fsck/debugfs and check-rebuild.sh guards, and update pinned hashes in scripts/check-rebuild.sh and CHANGELOG.md.
2026-11-13 21:27:41 +02:00

160 lines
5.0 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"
find_bt_card() {
pactl list short cards 2>/dev/null | awk '$2 ~ /^bluez_card\./ { print $2; exit }'
}
switch_bt_card_hfp() {
bt_card="$1"
[ -z "$bt_card" ] && return 1
pactl set-card-profile "$bt_card" headset-head-unit-cvsd >/dev/null 2>&1 || \
pactl set-card-profile "$bt_card" headset-head-unit >/dev/null 2>&1 || \
pactl set-card-profile "$bt_card" headset-head-unit-msbc >/dev/null 2>&1 || return 1
return 0
}
switch_bt_card_a2dp() {
bt_card="$1"
[ -z "$bt_card" ] && return 1
if pactl set-card-profile "$bt_card" a2dp-sink >/dev/null 2>&1; then
return 0
fi
a2dp_prof="$(pactl list cards 2>/dev/null | awk -v c="$bt_card" '
$1 == "Name:" { in_card = ($2 == c); in_prof = 0 }
in_card && $1 == "Profiles:" { in_prof = 1; next }
in_card && in_prof && /^[[:space:]]*Active Profile:/ { in_prof = 0 }
in_card && in_prof && $1 ~ /^a2dp-sink/ && $0 !~ /available: no/ {
sub(/:$/, "", $1); print $1; exit
}
')"
if [ -n "$a2dp_prof" ]; then
pactl set-card-profile "$bt_card" "$a2dp_prof" >/dev/null 2>&1 && return 0
fi
return 1
}
enable_call_audio_mode() {
exec 9>/tmp/sxmo_modemaudio.lock
flock -x 9
printf "1\n" > /tmp/sxmo_in_call 2>/dev/null || true
cur_out="$(sxmo_audio.sh device get 2>/dev/null || printf "Speaker")"
bt_card="$(find_bt_card)"
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 [ -n "$bt_card" ]; then
target_out="Bluetooth"
switch_bt_card_hfp "$bt_card" || true
sxmo_audio.sh device set Bluetooth >/dev/null 2>&1 || true
sxmo_audio.sh device setinput Bluetooth >/dev/null 2>&1 || true
if command -v amixer >/dev/null 2>&1; then
amixer -c 0 -s >/dev/null 2>&1 <<'EOF' || true
cset name='INT_BT_SCO_RX Audio Mixer MultiMedia1' 0
cset name='MultiMedia2 Mixer INT_BT_SCO_TX' 0
cset name='MultiMedia2 Mixer TERT_MI2S_TX' 0
cset name='PRI_MI2S_RX Voice Mixer VoiceMMode1' 0
cset name='VoiceMMode1 Capture Mixer TERT_MI2S_TX' 0
cset name='INT_BT_SCO_RX Voice Mixer VoiceMMode1' 1
cset name='VoiceMMode1 Capture Mixer INT_BT_SCO_TX' 1
EOF
fi
else
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 -s >/dev/null 2>&1 <<'EOF' || true
cset name='INT_BT_SCO_RX Voice Mixer VoiceMMode1' 0
cset name='VoiceMMode1 Capture Mixer INT_BT_SCO_TX' 0
cset name='PRI_MI2S_RX Voice Mixer VoiceMMode1' 1
cset name='VoiceMMode1 Capture Mixer TERT_MI2S_TX' 1
cset name='MultiMedia2 Mixer TERT_MI2S_TX' 0
cset name='RX1 Mute Switch' 0
EOF
fi
fi
sxmo_log "Enabled ALSA voice call audio mode ($target_out)."
return 0
}
disable_call_audio_mode() {
exec 9>/tmp/sxmo_modemaudio.lock
flock -x 9
if [ ! -e /tmp/sxmo_in_call ]; then
rm -f /tmp/sxmo_call_vol 2>/dev/null || true
return 0
fi
rm -f /tmp/sxmo_in_call /tmp/sxmo_call_vol 2>/dev/null || true
bt_card="$(find_bt_card)"
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 command -v amixer >/dev/null 2>&1; then
amixer -c 0 -s >/dev/null 2>&1 <<'EOF' || true
cset name='INT_BT_SCO_RX Voice Mixer VoiceMMode1' 0
cset name='VoiceMMode1 Capture Mixer INT_BT_SCO_TX' 0
cset name='PRI_MI2S_RX Voice Mixer VoiceMMode1' 0
cset name='VoiceMMode1 Capture Mixer TERT_MI2S_TX' 0
cset name='INT_BT_SCO_RX Audio Mixer MultiMedia1' 0
cset name='MultiMedia2 Mixer INT_BT_SCO_TX' 0
cset name='PRI_MI2S_RX Audio Mixer MultiMedia1' 1
cset name='MultiMedia2 Mixer TERT_MI2S_TX' 1
EOF
fi
if [ -n "$bt_card" ]; then
target_out="Bluetooth"
if [ -r /tmp/sxmo_bt_sco_keepalive.pid ]; then
read -r kpid < /tmp/sxmo_bt_sco_keepalive.pid 2>/dev/null || kpid=""
rm -f /tmp/sxmo_bt_sco_keepalive.pid 2>/dev/null || true
[ -n "$kpid" ] && kill -TERM "$kpid" 2>/dev/null || true
fi
for _bpid in $(ps | awk '/pacat --playback --device=bluez_output/ && !/awk/ {print $1}' 2>/dev/null || true); do
kill -TERM "$_bpid" 2>/dev/null || true
done
switch_bt_card_a2dp "$bt_card" || true
sxmo_audio.sh device setinput Mic1 >/dev/null 2>&1 || true
sxmo_audio.sh device set Bluetooth >/dev/null 2>&1 || true
else
if [ "$jack_plugged" = "1" ]; then
target_out="Headphones"
else
target_out="Speaker"
fi
sxmo_audio.sh device setinput Mic1 >/dev/null 2>&1 || true
sxmo_audio.sh device set "$target_out" >/dev/null 2>&1 || true
fi
sxmo_log "Disabled ALSA voice call audio mode ($target_out)."
return 0
}
setup_audio() {
enable_call_audio_mode
return 0
}
reset_audio() {
disable_call_audio_mode
return 0
}
"$@"