Add Bluetooth audio/HID/discoverability/alias support, fix SD card hotplug & caller ID matching, and expand ReMEdy J2ME JSRs + 64MB GC
This commit is contained in:
1 parent
456d3fbc42
commit
471916424e
51 files changed
+2961
-305
No files matched your search
@@ -26,6 +26,7 @@ clamp_pct() {
|
||||
|
||||
normalize_out_dev() {
|
||||
case "$1" in
|
||||
*[Bb]luetooth*|*[Bb]luez*) printf "Bluetooth" ;;
|
||||
*[Ee]arpiece*) printf "Earpiece" ;;
|
||||
*[Hh]eadphone*|*[Hh]eadset*) printf "Headphones" ;;
|
||||
*) printf "Speaker" ;;
|
||||
@@ -34,14 +35,24 @@ normalize_out_dev() {
|
||||
|
||||
normalize_in_dev() {
|
||||
case "$1" in
|
||||
*[Bb]luetooth*|*[Bb]luez*) printf "Bluetooth" ;;
|
||||
*[Hh]eadset*) printf "Headset" ;;
|
||||
*) printf "Mic1" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
find_bt_sink() {
|
||||
pactl list short sinks 2>/dev/null | awk '$2 ~ /^bluez_output\./ { print $2; exit }'
|
||||
}
|
||||
|
||||
find_bt_source() {
|
||||
pactl list short sources 2>/dev/null | awk '$2 ~ /^bluez_input\./ { print $2; exit }'
|
||||
}
|
||||
|
||||
vol_file_for_dev() {
|
||||
dev="$(normalize_out_dev "$1")"
|
||||
case "$dev" in
|
||||
Bluetooth) printf "%s/bluetooth_vol" "$CFG_DIR" ;;
|
||||
Earpiece) printf "%s/earpiece_vol" "$CFG_DIR" ;;
|
||||
Headphones) printf "%s/headphones_vol" "$CFG_DIR" ;;
|
||||
*) printf "%s/speaker_vol" "$CFG_DIR" ;;
|
||||
@@ -51,7 +62,7 @@ vol_file_for_dev() {
|
||||
default_vol_for_dev() {
|
||||
dev="$(normalize_out_dev "$1")"
|
||||
case "$dev" in
|
||||
Headphones) printf "80" ;;
|
||||
Bluetooth|Headphones) printf "80" ;;
|
||||
*) printf "85" ;;
|
||||
esac
|
||||
}
|
||||
@@ -104,11 +115,23 @@ pct_to_hw_adc() {
|
||||
}
|
||||
|
||||
deviceget() {
|
||||
sink="$(pactl get-default-sink 2>/dev/null || true)"
|
||||
case "$sink" in
|
||||
bluez_output.*)
|
||||
printf "Bluetooth\n" > /tmp/sxmo_audio_out_device 2>/dev/null || true
|
||||
printf "Bluetooth\n"
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
if [ -r /tmp/sxmo_audio_out_device ]; then
|
||||
read -r dev < /tmp/sxmo_audio_out_device 2>/dev/null || dev=""
|
||||
if [ -n "$dev" ]; then
|
||||
normalize_out_dev "$dev"
|
||||
printf "\n"
|
||||
dev="$(normalize_out_dev "$dev")"
|
||||
if [ "$dev" = "Bluetooth" ] && [ -z "$(find_bt_sink)" ]; then
|
||||
dev="Speaker"
|
||||
printf "%s\n" "$dev" > /tmp/sxmo_audio_out_device 2>/dev/null || true
|
||||
fi
|
||||
printf "%s\n" "$dev"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
@@ -116,12 +139,14 @@ deviceget() {
|
||||
read -r dev < "$CFG_DIR/audio_out_device" 2>/dev/null || dev=""
|
||||
if [ -n "$dev" ]; then
|
||||
dev="$(normalize_out_dev "$dev")"
|
||||
if [ "$dev" = "Bluetooth" ] && [ -z "$(find_bt_sink)" ]; then
|
||||
dev="Speaker"
|
||||
fi
|
||||
printf "%s\n" "$dev" > /tmp/sxmo_audio_out_device 2>/dev/null || true
|
||||
printf "%s\n" "$dev"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
sink="$(pactl get-default-sink 2>/dev/null || true)"
|
||||
case "$sink" in
|
||||
*Earpiece*) dev="Earpiece" ;;
|
||||
*Headphones*) dev="Headphones" ;;
|
||||
@@ -132,11 +157,23 @@ deviceget() {
|
||||
}
|
||||
|
||||
devicegetinput() {
|
||||
src="$(pactl get-default-source 2>/dev/null || true)"
|
||||
case "$src" in
|
||||
bluez_input.*)
|
||||
printf "Bluetooth\n" > /tmp/sxmo_audio_in_device 2>/dev/null || true
|
||||
printf "Bluetooth\n"
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
if [ -r /tmp/sxmo_audio_in_device ]; then
|
||||
read -r in_dev < /tmp/sxmo_audio_in_device 2>/dev/null || in_dev=""
|
||||
if [ -n "$in_dev" ]; then
|
||||
normalize_in_dev "$in_dev"
|
||||
printf "\n"
|
||||
in_dev="$(normalize_in_dev "$in_dev")"
|
||||
if [ "$in_dev" = "Bluetooth" ] && [ -z "$(find_bt_source)" ]; then
|
||||
in_dev="Mic1"
|
||||
printf "%s\n" "$in_dev" > /tmp/sxmo_audio_in_device 2>/dev/null || true
|
||||
fi
|
||||
printf "%s\n" "$in_dev"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
@@ -144,12 +181,14 @@ devicegetinput() {
|
||||
read -r in_dev < "$CFG_DIR/audio_in_device" 2>/dev/null || in_dev=""
|
||||
if [ -n "$in_dev" ]; then
|
||||
in_dev="$(normalize_in_dev "$in_dev")"
|
||||
if [ "$in_dev" = "Bluetooth" ] && [ -z "$(find_bt_source)" ]; then
|
||||
in_dev="Mic1"
|
||||
fi
|
||||
printf "%s\n" "$in_dev" > /tmp/sxmo_audio_in_device 2>/dev/null || true
|
||||
printf "%s\n" "$in_dev"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
src="$(pactl get-default-source 2>/dev/null || true)"
|
||||
case "$src" in
|
||||
*Headset*) in_dev="Headset" ;;
|
||||
*) in_dev="Mic1" ;;
|
||||
@@ -251,6 +290,18 @@ apply_alsa_out() {
|
||||
amixer -c 0 cset "name='RX2 Digital Volume'" 0 >/dev/null 2>&1 || true
|
||||
fi
|
||||
;;
|
||||
Bluetooth)
|
||||
amixer -c 0 -q sset 'SPK DAC' off 2>/dev/null || amixer -c 0 cset "name='SPK DAC Switch'" 0 >/dev/null 2>&1 || true
|
||||
amixer -c 0 cset "name='EAR_S'" 'ZERO' >/dev/null 2>&1 || true
|
||||
amixer -c 0 cset "name='HPHL'" 'ZERO' >/dev/null 2>&1 || true
|
||||
amixer -c 0 cset "name='HPHR'" 'ZERO' >/dev/null 2>&1 || true
|
||||
amixer -c 0 cset "name='RX1 MIX1 INP1'" 'ZERO' >/dev/null 2>&1 || true
|
||||
amixer -c 0 cset "name='RX2 MIX1 INP1'" 'ZERO' >/dev/null 2>&1 || true
|
||||
amixer -c 0 cset "name='RX3 MIX1 INP1'" 'ZERO' >/dev/null 2>&1 || true
|
||||
amixer -c 0 cset "name='RX1 Digital Volume'" 0 >/dev/null 2>&1 || true
|
||||
amixer -c 0 cset "name='RX2 Digital Volume'" 0 >/dev/null 2>&1 || true
|
||||
amixer -c 0 cset "name='RX3 Digital Volume'" 0 >/dev/null 2>&1 || true
|
||||
;;
|
||||
*)
|
||||
amixer -c 0 cset "name='EAR_S'" 'ZERO' >/dev/null 2>&1 || true
|
||||
amixer -c 0 cset "name='HPHL'" 'ZERO' >/dev/null 2>&1 || true
|
||||
@@ -274,7 +325,11 @@ apply_alsa_out() {
|
||||
|
||||
if [ "$eff_pct" -gt 0 ]; then
|
||||
wpctl set-mute @DEFAULT_AUDIO_SINK@ 0 >/dev/null 2>&1 || true
|
||||
wpctl set-volume @DEFAULT_AUDIO_SINK@ 100% >/dev/null 2>&1 || true
|
||||
if [ "$dev" = "Bluetooth" ]; then
|
||||
wpctl set-volume @DEFAULT_AUDIO_SINK@ "${eff_pct}%" >/dev/null 2>&1 || true
|
||||
else
|
||||
wpctl set-volume @DEFAULT_AUDIO_SINK@ 100% >/dev/null 2>&1 || true
|
||||
fi
|
||||
else
|
||||
wpctl set-mute @DEFAULT_AUDIO_SINK@ 1 >/dev/null 2>&1 || true
|
||||
fi
|
||||
@@ -324,7 +379,11 @@ apply_alsa_in() {
|
||||
|
||||
if [ "$eff_pct" -gt 0 ]; then
|
||||
wpctl set-mute @DEFAULT_AUDIO_SOURCE@ 0 >/dev/null 2>&1 || true
|
||||
wpctl set-volume @DEFAULT_AUDIO_SOURCE@ 100% >/dev/null 2>&1 || true
|
||||
if [ "$in_dev" = "Bluetooth" ]; then
|
||||
wpctl set-volume @DEFAULT_AUDIO_SOURCE@ "${eff_pct}%" >/dev/null 2>&1 || true
|
||||
else
|
||||
wpctl set-volume @DEFAULT_AUDIO_SOURCE@ 100% >/dev/null 2>&1 || true
|
||||
fi
|
||||
else
|
||||
wpctl set-mute @DEFAULT_AUDIO_SOURCE@ 1 >/dev/null 2>&1 || true
|
||||
fi
|
||||
@@ -333,6 +392,8 @@ apply_alsa_in() {
|
||||
profile_for_devices() {
|
||||
out_dev="$(normalize_out_dev "$1")"
|
||||
in_dev="$(normalize_in_dev "$2")"
|
||||
[ "$out_dev" = "Bluetooth" ] && out_dev="Speaker"
|
||||
[ "$in_dev" = "Bluetooth" ] && in_dev="Mic1"
|
||||
case "${out_dev}:${in_dev}" in
|
||||
Headphones:Headset) printf "HiFi (Headphones, Headset)" ;;
|
||||
Headphones:Mic1) printf "HiFi (Headphones, Mic1)" ;;
|
||||
@@ -349,10 +410,24 @@ sync_pipewire_profile() {
|
||||
prof="$(profile_for_devices "$out_dev" "$in_dev")"
|
||||
pactl set-card-profile alsa_card.comprC0 off >/dev/null 2>&1 || true
|
||||
pactl set-card-profile "$ALSA_CARD" "$prof" >/dev/null 2>&1 || true
|
||||
sink_name="alsa_output.platform-7702000.sound.HiFi__${out_dev}__sink"
|
||||
src_name="alsa_input.platform-7702000.sound.HiFi__${in_dev}__source"
|
||||
pactl set-default-sink "$sink_name" >/dev/null 2>&1 || true
|
||||
pactl set-default-source "$src_name" >/dev/null 2>&1 || true
|
||||
if [ "$out_dev" = "Bluetooth" ]; then
|
||||
bt_sink="$(find_bt_sink)"
|
||||
if [ -n "$bt_sink" ]; then
|
||||
pactl set-default-sink "$bt_sink" >/dev/null 2>&1 || true
|
||||
fi
|
||||
else
|
||||
sink_name="alsa_output.platform-7702000.sound.HiFi__${out_dev}__sink"
|
||||
pactl set-default-sink "$sink_name" >/dev/null 2>&1 || true
|
||||
fi
|
||||
if [ "$in_dev" = "Bluetooth" ]; then
|
||||
bt_src="$(find_bt_source)"
|
||||
if [ -n "$bt_src" ]; then
|
||||
pactl set-default-source "$bt_src" >/dev/null 2>&1 || true
|
||||
fi
|
||||
else
|
||||
src_name="alsa_input.platform-7702000.sound.HiFi__${in_dev}__source"
|
||||
pactl set-default-source "$src_name" >/dev/null 2>&1 || true
|
||||
fi
|
||||
}
|
||||
|
||||
notifyvol() {
|
||||
@@ -523,28 +598,56 @@ devicesetinput() {
|
||||
}
|
||||
|
||||
devicelist() {
|
||||
printf "Speaker\nEarpiece\nHeadphones\n"
|
||||
if [ -n "$(find_bt_sink)" ]; then
|
||||
printf "Bluetooth\nSpeaker\nEarpiece\nHeadphones\n"
|
||||
else
|
||||
printf "Speaker\nEarpiece\nHeadphones\n"
|
||||
fi
|
||||
}
|
||||
|
||||
devicelistinput() {
|
||||
printf "Mic1\nHeadset\n"
|
||||
if [ -n "$(find_bt_source)" ]; then
|
||||
printf "Bluetooth\nMic1\nHeadset\n"
|
||||
else
|
||||
printf "Mic1\nHeadset\n"
|
||||
fi
|
||||
}
|
||||
|
||||
devicecycle() {
|
||||
dir="${1:-next}"
|
||||
cur="$(deviceget)"
|
||||
has_bt=0
|
||||
[ -n "$(find_bt_sink)" ] && has_bt=1
|
||||
if [ "$dir" = "prev" ]; then
|
||||
case "$cur" in
|
||||
Speaker) next="Headphones" ;;
|
||||
Earpiece) next="Speaker" ;;
|
||||
*) next="Earpiece" ;;
|
||||
esac
|
||||
if [ "$has_bt" = "1" ]; then
|
||||
case "$cur" in
|
||||
Bluetooth) next="Headphones" ;;
|
||||
Speaker) next="Bluetooth" ;;
|
||||
Earpiece) next="Speaker" ;;
|
||||
*) next="Earpiece" ;;
|
||||
esac
|
||||
else
|
||||
case "$cur" in
|
||||
Speaker) next="Headphones" ;;
|
||||
Earpiece) next="Speaker" ;;
|
||||
*) next="Earpiece" ;;
|
||||
esac
|
||||
fi
|
||||
else
|
||||
case "$cur" in
|
||||
Speaker) next="Earpiece" ;;
|
||||
Earpiece) next="Headphones" ;;
|
||||
*) next="Speaker" ;;
|
||||
esac
|
||||
if [ "$has_bt" = "1" ]; then
|
||||
case "$cur" in
|
||||
Bluetooth) next="Speaker" ;;
|
||||
Speaker) next="Earpiece" ;;
|
||||
Earpiece) next="Headphones" ;;
|
||||
*) next="Bluetooth" ;;
|
||||
esac
|
||||
else
|
||||
case "$cur" in
|
||||
Speaker) next="Earpiece" ;;
|
||||
Earpiece) next="Headphones" ;;
|
||||
*) next="Speaker" ;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
deviceset "$next"
|
||||
printf "%s\n" "$next"
|
||||
@@ -570,6 +673,7 @@ devicegetdefaultsource() {
|
||||
sourceset() {
|
||||
pactl set-default-source "$1" >/dev/null 2>&1 || true
|
||||
case "$1" in
|
||||
bluez_input.*|*Bluetooth*) devicesetinput Bluetooth ;;
|
||||
*Headset*) devicesetinput Headset ;;
|
||||
*) devicesetinput Mic1 ;;
|
||||
esac
|
||||
@@ -578,6 +682,7 @@ sourceset() {
|
||||
sinkset() {
|
||||
pactl set-default-sink "$1" >/dev/null 2>&1 || true
|
||||
case "$1" in
|
||||
bluez_output.*|*Bluetooth*) deviceset Bluetooth ;;
|
||||
*Earpiece*) deviceset Earpiece ;;
|
||||
*Headphones*) deviceset Headphones ;;
|
||||
*) deviceset Speaker ;;
|
||||
@@ -616,7 +721,7 @@ profileset() {
|
||||
|
||||
_outportssubmenu() {
|
||||
active_out="$(deviceget)"
|
||||
for dev in Speaker Earpiece Headphones; do
|
||||
for dev in $(devicelist); do
|
||||
if [ "$active_out" = "$dev" ]; then
|
||||
icon="$icon_ton"
|
||||
else
|
||||
@@ -629,7 +734,7 @@ _outportssubmenu() {
|
||||
|
||||
_inportssubmenu() {
|
||||
active_in="$(devicegetinput)"
|
||||
for dev in Mic1 Headset; do
|
||||
for dev in $(devicelistinput); do
|
||||
if [ "$active_in" = "$dev" ]; then
|
||||
icon="$icon_ton"
|
||||
else
|
||||
|
||||
Reference in new issue
Block a user