From cca648556dd0c096aa7210ee5a2b962efae36440 Mon Sep 17 00:00:00 2001 From: HiFiPHile Date: Wed, 26 Aug 2026 15:54:38 +0200 Subject: audio: add UAC2 host streaming support Add protocol-selectable UAC1/UAC2 parsing, UAC2 terminal and Feature Unit topology, Clock Source discovery, sampling-frequency ranges, and protocol-specific stream controls. Cover UAC2 playback, capture, control discovery, and malformed descriptors with unit tests. Signed-off-by: HiFiPHile --- examples/host/audio_host/src/audio_app.c | 2 +- examples/host/audio_host/src/main.c | 2 +- examples/host/audio_host/src/tusb_config.h | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) (limited to 'examples/host/audio_host/src') diff --git a/examples/host/audio_host/src/audio_app.c b/examples/host/audio_host/src/audio_app.c index 9a1434284..4623dff5a 100644 --- a/examples/host/audio_host/src/audio_app.c +++ b/examples/host/audio_host/src/audio_app.c @@ -30,7 +30,7 @@ // - SAMPLE_RATES: sample rates tried in order, first match wins (44.1 kHz stereo by default) #define AUDIO_MAX_FRAME_COUNT 48 #define AUDIO_MAX_CHANNELS 2 -#define SAMPLE_RATES {48000, 44100} +#define SAMPLE_RATES {44100, 48000} #define FEATURE_UNIT_VOLUME_DB (-6 * 256) static uint8_t audio_idx = TUSB_INDEX_INVALID_8; // index of the selected audio device static uint8_t cap_stream_idx = TUSB_INDEX_INVALID_8; // capture stream index diff --git a/examples/host/audio_host/src/main.c b/examples/host/audio_host/src/main.c index 3a3e18ab7..45c468f23 100644 --- a/examples/host/audio_host/src/main.c +++ b/examples/host/audio_host/src/main.c @@ -31,7 +31,7 @@ int main(void) { board_init(); printf("TinyUSB Host USB Audio Example\r\n"); - printf("Connect a USB Audio Device (UAC 1.0) to test\r\n"); + printf("Connect a USB Audio Device (UAC 1.0 or 2.0) to test\r\n"); // init host stack on configured roothub port tusb_rhport_init_t host_init = {.role = TUSB_ROLE_HOST, .speed = TUSB_SPEED_AUTO}; diff --git a/examples/host/audio_host/src/tusb_config.h b/examples/host/audio_host/src/tusb_config.h index 9b7f3c94b..5c2d54993 100644 --- a/examples/host/audio_host/src/tusb_config.h +++ b/examples/host/audio_host/src/tusb_config.h @@ -87,6 +87,9 @@ extern "C" { #define CFG_TUH_MSC 0 #define CFG_TUH_VENDOR 0 #define CFG_TUH_AUDIO 1 +#ifndef CFG_TUH_AUDIO_PROTOCOLS + #define CFG_TUH_AUDIO_PROTOCOLS (TUH_AUDIO_PROTOCOL_UAC1 | TUH_AUDIO_PROTOCOL_UAC2) +#endif // max device support (excluding hub device): 1 hub typically has 4 ports #define CFG_TUH_DEVICE_MAX (3 * CFG_TUH_HUB + 1) -- cgit v1.3.1