Skip to content

USB DAC connected at power-on plays through the speaker on TrimUI Brick #865

Open

Description

@cjwhitedev

Environment

  • TrimUI Brick (tg5040), NextUI 6.15.0
  • USB-C DAC: TTGK KM-HIFI-384KHZ

Problem

If the DAC is already plugged in when the Brick powers on, audio plays through the internal speaker. It only works if the DAC is plugged in after boot, or unplugged and plugged back in. This is the "plugged in during boot" case from #715.

Cause

At boot the USB DAC registers before the internal codec and takes ALSA card 0:

 0 [KMHIFI384KHZ   ]: USB-Audio - KM-HIFI-384KHZ
 1 [audiocodec     ]: audiocodec - audiocodec

audiomon does find it at startup. Its log shows Found existing USB audio device at startup, Updated .asoundrc with USB audio device: 0 and SetAudioSink(2). Even so, playback (Rockbox in my case) goes to the speaker.

After replugging, the codec is card 0 and the DAC card 1, and everything works. The settings code also assumes this layout (AUDIO_SINK_USBDAC 2 // assumes being exposed as card 1 to alsa).

Rebinding the DAC in software after boot gives the same result as a physical replug: the codec moves to card 0, the DAC to card 1, and audio goes to the DAC:

echo 1-1 > /sys/bus/usb/drivers/usb/unbind
echo 1-1 > /sys/bus/usb/drivers/usb/bind

Proposed fix

In the tg5040 MinUI.pak/launch.sh, before audiomon starts: if card 0 is a USB audio device, unbind and rebind that USB device. I'll open a PR linked to this issue.

AI disclosure

This issue was investigated and written with the help of an AI coding assistant (GitHub Copilot). I directed the investigation, reviewed the findings, and confirmed them on my own TrimUI Brick.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions