-
Notifications
You must be signed in to change notification settings - Fork 1.3k
audio: Add UAC1.0 support #3270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: Mengsk <admin@hifiphile.com>
Signed-off-by: Mengsk <admin@hifiphile.com>
Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: Mengsk <admin@hifiphile.com>
Signed-off-by: Mengsk <admin@hifiphile.com>
There was a problem hiding this 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 |
Signed-off-by: HiFiPhile <admin@hifiphile.com>
3a9fec6 to
a944c0d
Compare
Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: Mengsk <admin@hifiphile.com>
|
@codex review |
There was a problem hiding this 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
|
@codex merge master branch to this PR |
|
For now, I can only help with PRs you've created. |
|
@copilot merge master branch to this PR |
Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: HiFiPhile <admin@hifiphile.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gates Failed
Prevent hotspot decline
(2 hotspots with Complex Method, Complex Conditional, Bumpy Road Ahead, Deep, Nested Complexity)
Enforce critical code health rules
(2 files with Bumpy Road Ahead, Deep, Nested Complexity)
Enforce advisory code health rules
(5 files with Complex Method, Overall Code Complexity, Code Duplication, Complex Conditional)
Gates Passed
1 Quality Gates Passed
See analysis details in CodeScene
Reason for failure
| Prevent hotspot decline | Violations | Code Health Impact | |
|---|---|---|---|
| usbd.c | 3 rules in this hotspot | 5.74 → 5.14 | Suppress |
| audio_device.c | 3 rules in this hotspot | 3.71 → 3.44 | Suppress |
| Enforce critical code health rules | Violations | Code Health Impact | |
|---|---|---|---|
| usbd.c | 1 critical rule | 5.74 → 5.14 | Suppress |
| audio_device.c | 1 critical rule | 3.71 → 3.44 | Suppress |
| Enforce advisory code health rules | Violations | Code Health Impact | |
|---|---|---|---|
| main.c | 2 advisory rules | 9.61 → 8.29 | Suppress |
| main.c | 2 advisory rules | 8.17 → 7.29 | Suppress |
| main.c | 2 advisory rules | 9.24 → 8.49 | Suppress |
| usbd.c | 2 advisory rules | 5.74 → 5.14 | Suppress |
| audio_device.c | 2 advisory rules | 3.71 → 3.44 | Suppress |
Quality Gate Profile: Clean Code Collective
Want more control? Customize Code Health rules or catch issues early with our IDE extension and CLI tool.
hathach
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perfect !! Thank you very much, I didn't test but go through code changes. It looks great, audio is by far the most complicated driver. I think its descriptor is too complicated to have template descirptor as macro. I will try to improve it later on with typedef struct like video example. Thank you very much for putting lots of effort into the driver.

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
audio.hwith prefixaudio10_, UAC2 renamed with prefixaudio20_usbd.h, refactor fixed size descriptor macros to use auto size with the help ofTU_ARGS_APPLY_EXPANDAudio device
CFG_TUD_AUDIO_FUNC_n_DESC_LENconfigCFG_TUD_AUDIO_ENABLE_FEEDBACK_FORMAT_CORRECTION, now UAC1 always use 3-bytes 10.14 format while UAC2 always use 4-bytes 16.16 formatExamples
Testing
On STM32F407 & STM32F723:
tinyusb/examples/device/uac2_speaker_fb/src/usb_descriptors.h
Line 137 in 6e153a9