From f8fa961e4348c490637ebcb7086abd4b61dc0674 Mon Sep 17 00:00:00 2001 From: CJ White <30122110+cjwhitedev@users.noreply.github.com> Date: Thu, 15 Oct 2026 12:01:02 -0400 Subject: [PATCH] fix: route audio to a USB DAC connected at power-on on tg5040 A USB DAC that is already plugged in when the device boots registers before the internal audiocodec and takes ALSA card 0, pushing the codec to card 1. audiomon still writes .asoundrc for the DAC, but playback goes to the speaker until the DAC is unplugged and plugged back in, which leaves the codec on card 0 and the DAC on card 1. At boot, if card 0 is a USB audio device, unbind and rebind that USB device before audiomon starts, giving the same card order as a hotplug. --- skeleton/SYSTEM/tg5040/paks/MinUI.pak/launch.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/skeleton/SYSTEM/tg5040/paks/MinUI.pak/launch.sh b/skeleton/SYSTEM/tg5040/paks/MinUI.pak/launch.sh index 685ec4cf8..65134b32f 100755 --- a/skeleton/SYSTEM/tg5040/paks/MinUI.pak/launch.sh +++ b/skeleton/SYSTEM/tg5040/paks/MinUI.pak/launch.sh @@ -119,6 +119,14 @@ sh "$SYSTEM_PATH/bin/governor.sh" "auto" keymon.elf & # &> $SDCARD_PATH/keymon.txt & batmon.elf & # &> $SDCARD_PATH/batmon.txt & +# a USB DAC present at power-on takes card 0 from the codec; a software replug restores codec 0, DAC 1 +if grep -q '^ 0 \[.*\]: USB-Audio' /proc/asound/cards 2>/dev/null; then + usbdev=$(basename "$(dirname "$(readlink -f /sys/class/sound/card0/device)")") + echo "$usbdev" > /sys/bus/usb/drivers/usb/unbind + sleep 1 + echo "$usbdev" > /sys/bus/usb/drivers/usb/bind +fi + # start fresh, will be populated on the next connect rm -f $USERDATA_PATH/.asoundrc audiomon.elf & # &> $SDCARD_PATH/audiomon.txt &