From d4856804ff19d08518cc22f3860b53c497a7a106 Mon Sep 17 00:00:00 2001 From: David Gwilliam Date: Wed, 24 Jun 2026 17:31:00 -0700 Subject: [PATCH] Fix onboard audio: apply ALSA UCM HiFi verb before Pd start - Add alsaucm -c hw:0 set _verb HiFi to start-synth.sh (onboard mode) - Add UCM verb to install.sh - Add UCM verb to justfile fix-ucm recipe - Without this, the DSP audio routing is not configured and no sound reaches the headphone output --- install.sh | 19 +++++++++++++++++++ justfile | 20 ++++++++++++++++++-- scripts/start-synth.sh | 8 ++++++++ 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 424851c..3a60ee6 100755 --- a/install.sh +++ b/install.sh @@ -9,10 +9,29 @@ for svc in "${SERVICES[@]}"; do sudo cp "$REPO/system/$svc.service" /etc/systemd/system/ done +# Apply UCM HiFi verb to configure DSP audio routing +if command -v alsaucm &>/dev/null; then + alsaucm -c hw:0 set _verb HiFi && echo "[OK] UCM HiFi verb applied" +fi + # Fix UCM bug (must survive OS updates) FILE=/usr/share/alsa/ucm2/codecs/qcom-lpass/rx-macro/HeadphoneEnableSeq.conf +NEED_FIX=0 +# Remove invalid RX HPH Mode line if grep -q "RX HPH Mode" "$FILE" 2>/dev/null; then sudo sed -i '/RX HPH Mode/d' "$FILE" + NEED_FIX=1 +fi +# Add missing RX INT0_1/INT1_1 INTERP controls (blocks audio on some boards) +if ! grep -q "RX INT0_1 INTERP" "$FILE" 2>/dev/null; then + echo ' cset "name=RX INT0_1 INTERP" "RX INT0_1 MIX1"' | sudo tee -a "$FILE" >/dev/null + NEED_FIX=1 +fi +if ! grep -q "RX INT1_1 INTERP" "$FILE" 2>/dev/null; then + echo ' cset "name=RX INT1_1 INTERP" "RX INT1_1 MIX1"' | sudo tee -a "$FILE" >/dev/null + NEED_FIX=1 +fi +if [ "$NEED_FIX" = "1" ]; then echo "[OK] UCM HeadphoneEnableSeq patched" fi diff --git a/justfile b/justfile index 349879a..e8454c8 100644 --- a/justfile +++ b/justfile @@ -149,8 +149,24 @@ reboot: # Must run once after OS updates or first install. fix-ucm: @ssh {{SSH_OPTS}} "{{BOARD_USER}}@{{BOARD_HOST}}" "\ - if grep -q 'RX HPH Mode' /usr/share/alsa/ucm2/codecs/qcom-lpass/rx-macro/HeadphoneEnableSeq.conf 2>/dev/null; then \ - echo '{{BOARD_PASS}}' | sudo -S sed -i '/RX HPH Mode/d' /usr/share/alsa/ucm2/codecs/qcom-lpass/rx-macro/HeadphoneEnableSeq.conf && \ + echo '{{BOARD_PASS}}' | sudo -S alsaucm -c hw:0 set _verb HiFi 2>/dev/null && \ + echo '[OK] UCM verb applied' || \ + echo '[WARN] UCM verb failed' && \ + FILE=/usr/share/alsa/ucm2/codecs/qcom-lpass/rx-macro/HeadphoneEnableSeq.conf && \ + FIXED=0 && \ + if grep -q 'RX HPH Mode' \"\$FILE\" 2>/dev/null; then \ + echo '{{BOARD_PASS}}' | sudo -S sed -i '/RX HPH Mode/d' \"\$FILE\" && \ + FIXED=1; \ + fi && \ + if ! grep -q 'RX INT0_1 INTERP' \"\$FILE\" 2>/dev/null; then \ + echo ' cset \"name=RX INT0_1 INTERP\" \"RX INT0_1 MIX1\"' | sudo tee -a \"\$FILE\" >/dev/null && \ + FIXED=1; \ + fi && \ + if ! grep -q 'RX INT1_1 INTERP' \"\$FILE\" 2>/dev/null; then \ + echo ' cset \"name=RX INT1_1 INTERP\" \"RX INT1_1 MIX1\"' | sudo tee -a \"\$FILE\" >/dev/null && \ + FIXED=1; \ + fi && \ + if [ \"\$FIXED\" = \"1\" ]; then \ sudo systemctl restart wireplumber && \ echo '[OK] UCM HeadphoneEnableSeq patched'; \ else \ diff --git a/scripts/start-synth.sh b/scripts/start-synth.sh index 92a045f..677f3dc 100755 --- a/scripts/start-synth.sh +++ b/scripts/start-synth.sh @@ -64,6 +64,14 @@ fi if [ "$MODE" = "onboard" ] || [ "$MODE" = "i2s" ]; then info "Mode: Onboard audio (PMIC headphone / line out on JMISC)" AUDIO_OPTS=(-audiooutdev 0 -inchannels 0 -outchannels 1) + # Apply ALSA UCM HiFi verb to configure DSP routing (required for audio) + if command -v alsaucm &>/dev/null; then + alsaucm -c hw:0 set _verb HiFi 2>/dev/null && \ + info " UCM HiFi verb applied" || \ + info " UCM HiFi verb failed" + else + info " alsaucm not found — skipping UCM config" + fi fi if [ "$MODE" = "loopback" ]; then