Site logo
Stories around the Genode Operating System RSS feed
Josef Söntgen avatar

Configuration of the USB audio driver component


This post lends a hand for configuring the usb_audio driver component introduced in 26.11 and points to readily available pkgs for Sculpt 26.10.

First things first, the usb_audio pkg for Sculpt OS 26.10 can be found in cnuke → Multimedia and is available for arm_v8a and x86_64.

Before deploying the pkg, make sure the mixer option is available and its configuration was adapted (/model/option/mixer):

❶ Add the following policy nodes that allow playback:

 + policy | label: usb_audio -> left  | record: left  | period_ms: 10 | jitter_ms: 5 | volume: 1.0
 + policy | label: usb_audio -> right | record: right | period_ms: 10 | jitter_ms: 5 | volume: 1.0

❷ Add the following mix nodes for allowing recording:

 + mix usb_mic_left  | + play | label: usb_audio -> mic_left
 + mix usb_mic_right | + play | label: usb_audio -> mic_right

In the end, a stripped-down mixer option could look like this:

 option
 + child mixer | pkg: record_play_mixer | priority: driver
   + config | jitter_ms: 10 | warning_rate_ms: 0

 […]

     + mix left
       + play | label_suffix: -> left  | volume: 0.5
     + mix right
       + play | label_suffix: -> right | volume: 0.5

 […]

     + mix usb_mic_left  | + play | label: usb_audio -> mic_left
     + mix usb_mic_right | + play | label: usb_audio -> mic_right

 […]

     + policy | label: usb_audio -> left  | record: left  | period_ms: 10 | jitter_ms: 5 | volume: 1.0
     + policy | label: usb_audio -> right | record: right | period_ms: 10 | jitter_ms: 5 | volume: 1.0

   + connect | + report | + child report
 -

Additional information about the record_play_mixer component can be found in its README.

Likewise, the usb_audio driver needs to be granted access to the device in question. We have to extend the usb configuration (/model/child/usb) by adding a policy node containing the vendor and product id:

 + policy | label_prefix: usb_audio ->
   + device | vendor_id: 0x0d8c | product_id: 0x0014

Now is a good time to deploy the usb_audio pkg and connect the services accordingly:

  • Play and Record → mixer

  • Report → report

  • Usb → usb

and under Resource assignment… choose at least Multimedia.

The driver should now start up and will wait for the device to be plugged in. Since the driver is unconfigured it will complain that there exists no profile for the device. It should, however, have created a devices and mixer report in /report/usb_audio:

 devices
 + device | number: 0 | direction: playback | node: pcmC0D0p | name: USB Audio
 + device | number: 0 | direction: capture | node: pcmC0D0c | name: USB Audio
 -
 mixer
 + control Playback Channel Map | id: 0 | channel: 0 | type: int | value: 0 | min: 0 | max: 36
 + control Playback Channel Map | id: 0 | channel: 1 | type: int | value: 0 | min: 0 | max: 36
 + control Capture Channel Map | id: 1 | channel: 0 | type: int | value: 0 | min: 0 | max: 36
 + control Mic Playback Switch | id: 2 | channel: 0 | type: bool | value: false
 + control Mic Playback Volume | id: 3 | channel: 0 | type: int | value: 16 | min: 0 | max: 31
 + control Speaker Playback Switch | id: 4 | channel: 0 | type: bool | value: true
 + control Speaker Playback Volume | id: 5 | channel: 0 | type: int | value: 27 | min: 0 | max: 37
 + control Speaker Playback Volume | id: 5 | channel: 1 | type: int | value: 27 | min: 0 | max: 37
 + control Mic Capture Switch | id: 6 | channel: 0 | type: bool | value: true
 + control Mic Capture Volume | id: 7 | channel: 0 | type: int | value: 20 | min: 0 | max: 35
 + control Auto Gain Control | id: 8 | channel: 0 | type: bool | value: true
 -

These reports give you a hint on how to create a profile for your device, see the complete usb_audio option for this device in its entirety:

 option
 + child usb_audio | pkg: cnuke/pkg/usb_audio/2026-11-26 | priority: driver
   + config | report_mixer: yes | report_devices: yes
    + profile | vendor_id: 0x0d8c | product_id: 0x0014
       + devices | playback:     pcmC0D0p
                 | mic_internal: pcmC0D0c
                 | speaker_internal_id: 4
                 | mic_internal_id:     6
       + playback | samplerate: 48000 | channels: 2 | samplebits: 16
       + capture  | samplerate: 48000 | channels: 1 | samplebits: 16
       x control Playback Channel Map    | id: 0 | channel: 0 | type: int  | value: 0 | min: 0 | max: 36
       x control Playback Channel Map    | id: 0 | channel: 1 | type: int  | value: 0 | min: 0 | max: 36
       x control Capture Channel Map     | id: 1 | channel: 0 | type: int  | value: 0 | min: 0 | max: 36
       x control Mic Playback Switch     | id: 2 | channel: 0 | type: bool | value: false
       + control Mic Playback Volume     | id: 3 | channel: 0 | type: int  | value: 16 | min: 0 | max: 31
       x control Speaker Playback Switch | id: 4 | channel: 0 | type: bool | value: true
       + control Speaker Playback Volume | id: 5 | channel: 0 | type: int  | value: 37 | min: 0 | max: 37
       + control Speaker Playback Volume | id: 5 | channel: 1 | type: int  | value: 37 | min: 0 | max: 37
       x control Mic Capture Switch      | id: 6 | channel: 0 | type: bool | value: true
       + control Mic Capture Volume      | id: 7 | channel: 0 | type: int  | value: 20 | min: 0 | max: 35
       + control Auto Gain Control       | id: 8 | channel: 0 | type: bool | value: true
 -

The devices node is populated with information from the devices as well as the mixer report. The id attributes correspond to the control nodes with the same id and are remains from the pc_audio configuration, where the driver manages these mixer control switches automatically.

Besides the various control nodes, you may have noticed the playback and capture nodes in the configuration. They denote how the playback and recording streams should be configured. Although the driver tries to probe certain settings itself, we noticed that it not always works properly. As this area is still work-in-progress, for now it is best to provide these parameters explicitly.

In case this information is not known beforehand, resorting to tools like lsusb(8) if you are running a Linux distribution, is the way to go at the moment.

The following snippet of lsusb's output shows the supported parameters for the playback

 AudioStreaming Interface Descriptor:
   bLength                14
   bDescriptorType        36
   bDescriptorSubtype      2 (FORMAT_TYPE)
   bFormatType             1 (FORMAT_TYPE_I)
   bNrChannels             2
   bSubframeSize           2
   bBitResolution         16
   bSamFreqType            2 Discrete
   tSamFreq[ 0]        48000
   tSamFreq[ 1]        44100

and recording interface

 AudioStreaming Interface Descriptor:
    bLength                14
    bDescriptorType        36
    bDescriptorSubtype      2 (FORMAT_TYPE)
    bFormatType             1 (FORMAT_TYPE_I)
    bNrChannels             1
    bSubframeSize           2
    bBitResolution         16
    bSamFreqType            2 Discrete
    tSamFreq[ 0]        48000
    tSamFreq[ 1]        44100

of this UAC1 device. The tSamFreq, bNrChannels and bBitResolution fields provide the values for the attributes in the playback and capture nodes.

It goes without saying, since this driver is new and for the most part was produced as a show-piece for the microkernelized USB stack, things can be sometimes rough around the edges.

The driver can be pre-configured for multiple devices and—while it will only drive one device at a time—can make use of different devices in sequence without being restarted in between. That being said, to profit from the configuration flexibility of the record_play_mixer component, it is useful to have one configured option per device.

In my testing, setting the volume values once to around 80% of the max value in the driver configuration and using the mixer option to steer the volume at run-time worked well.