Skip to content

Conversation

HiFiPhile
Copy link
Collaborator

@HiFiPhile HiFiPhile commented Sep 30, 2025

Describe the PR

This PR adds USB Audio Class 1.0 (UAC1) support, now audio device driver supports both UAC1 and UAC2 with dynamic switching possibility based on host capabilities.

For asynchronous OUT with feedback, now it's recommended to use UAC1 for Full-Speed device for better OS compatibility, while UAC2 is recommended only for High-Speed device for better performance.

Let me break down this PR:

USBD

  • Add UAC1 constants to audio.h with prefix audio10_, UAC2 renamed with prefix audio20_
  • Add UAC1 descriptor macros to usbd.h, refactor fixed size descriptor macros to use auto size with the help of TU_ARGS_APPLY_EXPAND
  • Support UAC1 without IAD (Interface Association Descriptor)

Audio device

  • Add UAC1 descriptor parsing and control request handling
  • Update IN flow control to support UAC1 (OUT feedback by FIFO counting is auto supported)
  • Calculate descriptor length by driver, remove CFG_TUD_AUDIO_FUNC_n_DESC_LEN config
  • Remove CFG_TUD_AUDIO_ENABLE_FEEDBACK_FORMAT_CORRECTION, now UAC1 always use 3-bytes 10.14 format while UAC2 always use 4-bytes 16.16 format

Examples

  • uac2_speaker_fb: Add UAC1 support with automatic fallback based on host capabilities
    • Remove OS guessing quirks
  • audio_test_multi_rate: Add UAC1 support with automatic fallback based on host capabilities
  • uac2_headset: Add UAC1 support with automatic fallback based on host capabilities
    • UAC1 status interrupt is not supported by most OS, if you need volume control either use UAC2 or old day HID interface

Testing

On STM32F407 & STM32F723:

Example OS UAC1 (FS) UAC2 (HS)
uac2_speaker_fb Windows 10
uac2_speaker_fb macOS 13
uac2_speaker_fb Archlinux
audio_test_multi_rate Windows 10
audio_test_multi_rate macOS 13
audio_test_multi_rate Archlinux
uac2_headset Windows 10
uac2_headset macOS 13 Seems OK, can't verify in VM Seems OK, can't verify in VM
uac2_headset Archlinux

@Copilot Copilot AI review requested due to automatic review settings September 30, 2025 15:57
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds comprehensive USB Audio Class 1.0 (UAC1) support to TinyUSB's audio device driver, enabling dynamic switching between UAC1 and UAC2 based on host capabilities. The implementation focuses on improving compatibility with Full-Speed devices by recommending UAC1 for better OS compatibility while maintaining UAC2 for High-Speed performance.

  • Adds complete UAC1 constants, descriptors, and macros with audio10_ prefix
  • Implements UAC1 descriptor parsing and control request handling in audio device driver
  • Updates examples to support both UAC1 and UAC2 with automatic fallback capability

Reviewed Changes

Copilot reviewed 37 out of 37 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/device/usbd.h Adds UAC1 descriptor templates and renames UAC2 macros for clarity
src/device/usbd.c Adds UAC1 device support without IAD descriptor handling
src/common/tusb_compiler.h Adds TU_ARGS_APPLY_EXPAND macro for variable argument expansion
src/common/tusb_common.h Adds U24 byte manipulation macros for UAC1 feedback format
src/class/midi/midi_host.c Updates to use renamed UAC1 constants
src/class/audio/audio_device.h Removes deprecated config options and adds version detection API
src/class/audio/audio_device.c Implements UAC1 parsing, control handling, and feedback format logic
src/class/audio/audio.h Comprehensive UAC1/UAC2 constants reorganization and new descriptors
examples/device/uac2_speaker_fb/* Removes OS guessing quirks, adds UAC1/UAC2 dual support
examples/device/uac2_headset/* Updates to use renamed UAC2 constants
examples/device/cdc_uac2/* Updates to use renamed UAC2 constants

@HiFiPhile
Copy link
Collaborator Author

HiFiPhile commented Oct 1, 2025

I've an issue with DWC2 where sometimes it can't send IN ISO packet (a ZLP is sent instead of data) when bInterval > 1

It seems like packet needs to scheduled manually when bInterval > 1, at least even/odd toggling is needed.
image

Signed-off-by: HiFiPhile <[email protected]>
@HiFiPhile HiFiPhile force-pushed the uac1 branch 2 times, most recently from 3a9fec6 to a944c0d Compare October 1, 2025 07:46
Signed-off-by: HiFiPhile <[email protected]>
@hathach
Copy link
Owner

hathach commented Oct 4, 2025

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting

@hathach
Copy link
Owner

hathach commented Oct 4, 2025

@codex merge master branch to this PR

Copy link

For now, I can only help with PRs you've created.

@hathach
Copy link
Owner

hathach commented Oct 4, 2025

@copilot merge master branch to this PR

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants