feat: audio stack working — pulseaudio + x6200_control + voice_rec
- Add pulseaudio in system mode - Add alsactl restore with correct mixer state from Aether - Add x6200-control package (I2C hardware control library) - Audio chain: pulseaudio -> x6200_control_init -> voice_rec -> speaker
This commit is contained in:
40
br2_external/board/x6200/rootfs-overlay/etc/init.d/S50alsa
Executable file
40
br2_external/board/x6200/rootfs-overlay/etc/init.d/S50alsa
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Alsa config
|
||||
#
|
||||
|
||||
source /etc/profile
|
||||
|
||||
start() {
|
||||
printf "Restore alsa"
|
||||
alsactl restore
|
||||
echo "OK"
|
||||
}
|
||||
|
||||
stop() {
|
||||
printf "Store alsa"
|
||||
# alsactl store
|
||||
echo "OK"
|
||||
}
|
||||
|
||||
restart() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart|reload)
|
||||
restart
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart}"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
exit $?
|
||||
45
br2_external/board/x6200/rootfs-overlay/etc/init.d/S50pulseaudio
Executable file
45
br2_external/board/x6200/rootfs-overlay/etc/init.d/S50pulseaudio
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Starts pulseaudio.
|
||||
#
|
||||
|
||||
|
||||
start() {
|
||||
printf "Starting pulseaudio: "
|
||||
umask 007
|
||||
/usr/bin/pulseaudio \
|
||||
--system \
|
||||
--daemonize \
|
||||
--disallow-exit \
|
||||
--exit-idle-time=-1 \
|
||||
--use-pid-file \
|
||||
--disable-shm
|
||||
echo "OK"
|
||||
}
|
||||
stop() {
|
||||
printf "Stopping pulseaudio: "
|
||||
PULSE_RUNTIME_PATH=/var/run/pulse /usr/bin/pulseaudio --kill
|
||||
echo "OK"
|
||||
}
|
||||
restart() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart|reload)
|
||||
restart
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart}"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
exit $?
|
||||
|
||||
59
br2_external/board/x6200/rootfs-overlay/etc/init.d/S70mestre-audio
Executable file
59
br2_external/board/x6200/rootfs-overlay/etc/init.d/S70mestre-audio
Executable file
@@ -0,0 +1,59 @@
|
||||
#!/bin/sh
|
||||
# S70mestre-audio — X6200 audio hardware init
|
||||
#
|
||||
# Initializes the X6200's audio routing via I2C:
|
||||
# 1. Calls x6200_control_init() to establish MCU state
|
||||
# 2. Sets speaker volume
|
||||
# 3. Switches audio routing from RX-radio to SoC DAC (voice_rec)
|
||||
#
|
||||
# Must run after S50pulseaudio (pulseaudio must hold PCM open first
|
||||
# to keep ALSA clocks active).
|
||||
#
|
||||
# The voice_rec bit (0x00008 in sple_atue_trx register, cmd 12)
|
||||
# switches the X6200's internal audio mux from the RF receiver
|
||||
# to the SoC DAC — allowing piHPSDR/aplay to be heard in the speaker.
|
||||
|
||||
VOLUME=50
|
||||
|
||||
do_init() {
|
||||
python3 << EOF
|
||||
import ctypes
|
||||
lib = ctypes.CDLL("libaether_x6200_control.so")
|
||||
lib.x6200_control_init.restype = ctypes.c_bool
|
||||
lib.x6200_control_rxvol_set.argtypes = [ctypes.c_uint8]
|
||||
lib.x6200_control_spmode_set.argtypes = [ctypes.c_bool]
|
||||
|
||||
if not lib.x6200_control_init():
|
||||
raise SystemExit("x6200_control_init() failed")
|
||||
|
||||
lib.x6200_control_rxvol_set($VOLUME)
|
||||
lib.x6200_control_spmode_set(False) # Speaker mode (not headphone)
|
||||
EOF
|
||||
}
|
||||
|
||||
do_voice_rec() {
|
||||
# Switch audio routing: RX-radio -> SoC DAC (voice_rec bit = 0x00008)
|
||||
i2ctransfer -y 0 w6@0x72 0x00 0x30 0x08 0x00 0x00 0x00
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
echo "Starting mestre-audio"
|
||||
do_init && do_voice_rec && echo "OK" || echo "FAILED"
|
||||
;;
|
||||
stop)
|
||||
echo "Stopping mestre-audio"
|
||||
# Switch back to RX-radio audio
|
||||
i2ctransfer -y 0 w6@0x72 0x00 0x30 0x00 0x00 0x00 0x00
|
||||
echo "OK"
|
||||
;;
|
||||
restart)
|
||||
$0 stop
|
||||
sleep 1
|
||||
$0 start
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart}" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
23
br2_external/board/x6200/rootfs-overlay/etc/init.d/S96keepalive
Executable file
23
br2_external/board/x6200/rootfs-overlay/etc/init.d/S96keepalive
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
# S96keepalive — X6200 PMU keepalive
|
||||
#
|
||||
# The X6200 powers itself off after ~180s unless the AXP PMU receives
|
||||
# periodic I2C traffic. This script starts the keepalive daemon at boot.
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
echo "Starting keepalive"
|
||||
/usr/sbin/i2c_keepalive.sh >/dev/null 2>&1 &
|
||||
;;
|
||||
stop)
|
||||
echo "Stopping keepalive"
|
||||
killall i2c_keepalive.sh 2>/dev/null || true
|
||||
;;
|
||||
restart)
|
||||
$0 stop; sleep 1; $0 start
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart}" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
Reference in New Issue
Block a user