Repository navigation
fix: route audio to a USB DAC connected at power-on on tg5040 - #866
Open
cjwhitedev wants to merge 1 commit into
Open
cjwhitedev wants to merge 1 commit into
cjwhitedev wants to merge 1 commit into
Conversation
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.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #865
What
In the tg5040
MinUI.pak/launch.sh, beforeaudiomonstarts: if ALSA card 0 is a USB audio device, unbind and rebind that USB device.Why
A USB DAC that is already connected at power-on registers before the internal codec and takes card 0, pushing
audiocodecto card 1.audiomonfinds the DAC and writes.asoundrcfor card 0, but playback still goes to the speaker. After a physical replug the codec is card 0 and the DAC card 1, the layout the rest of the audio path expects (seeAUDIO_SINK_USBDAC's "assumes being exposed as card 1"), and audio reaches the DAC.Rebinding the device in software gives the same card order as a replug. The USB device is found from
/sys/class/sound/card0/device, so it doesn't depend on which port or DAC is used. Nothing happens when no USB audio device holds card 0, and the extra 1 s delay only applies in that case.Testing
On a TrimUI Brick (NextUI 6.15.0 with this
launch.sh), DAC: TTGK KM-HIFI-384KHZ:Not tested on the Smart Pro, which uses the same script. tg5050 isn't changed.
AI disclosure
This change was written with the help of an AI coding assistant (GitHub Copilot). I directed the work, reviewed the changes, and tested them on my own TrimUI Brick as described above.