diff options
| author | HiFiPHile <[email protected]> | 2026-08-27 03:36:11 +0200 |
|---|---|---|
| committer | HiFiPHile <[email protected]> | 2026-08-27 10:34:34 +0200 |
| commit | 544ba0453a02bbee3243f592a088eb6838614dfd (patch) | |
| tree | 148b6a67245a23392e865d30670125a3ddb080a2 /src | |
| parent | 178426720cbe2f170872cc1469329570d37726a3 (diff) | |
audio: classify feedback endpoints by protocol
Use UAC1 synchronization attributes and UAC2 endpoint usage fields according to the active protocol. This prevents UAC2 audio-data IN endpoints from being mistaken for explicit feedback endpoints.
Signed-off-by: HiFiPHile <[email protected]>
Diffstat (limited to 'src')
| -rw-r--r-- | src/class/audio/audio_host.c | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/src/class/audio/audio_host.c b/src/class/audio/audio_host.c index c73e9f225..5c7ce5f8e 100644 --- a/src/class/audio/audio_host.c +++ b/src/class/audio/audio_host.c @@ -1297,15 +1297,28 @@ static const uint8_t *audioh_parse_as(audioh_interface_t *p_audio, const audioh_ break; } - const uint8_t usage = desc_endpoint->bmAttributes.usage; - const bool implicit_feedback = - usage == (TUSB_ISO_EP_ATT_IMPLICIT_FB >> 4) && tu_edpt_dir(desc_endpoint->bEndpointAddress) == TUSB_DIR_IN; - const bool explicit_feedback = - tu_edpt_dir(desc_endpoint->bEndpointAddress) == TUSB_DIR_IN && - (usage == (TUSB_ISO_EP_ATT_EXPLICIT_FB >> 4) || - (usage == (TUSB_ISO_EP_ATT_DATA >> 4) && desc_endpoint->bmAttributes.sync == TUSB_ISO_EP_ATT_NO_SYNC)); + bool is_data_ep = false; + bool is_explicit_feedback = false; + switch (p_audio->protocol) { + #if CFG_TUH_AUDIO_PROTOCOLS & TUH_AUDIO_PROTOCOL_UAC1 + case AUDIO_INT_PROTOCOL_CODE_V1: + is_data_ep = desc_endpoint->bmAttributes.sync != TUSB_ISO_EP_ATT_NO_SYNC; + is_explicit_feedback = tu_edpt_dir(desc_endpoint->bEndpointAddress) == TUSB_DIR_IN && !is_data_ep; + break; + #endif + #if CFG_TUH_AUDIO_PROTOCOLS & TUH_AUDIO_PROTOCOL_UAC2 + case AUDIO_INT_PROTOCOL_CODE_V2: + is_data_ep = desc_endpoint->bmAttributes.usage == (TUSB_ISO_EP_ATT_DATA >> 4) || + desc_endpoint->bmAttributes.usage == (TUSB_ISO_EP_ATT_IMPLICIT_FB >> 4); + is_explicit_feedback = tu_edpt_dir(desc_endpoint->bEndpointAddress) == TUSB_DIR_IN && + desc_endpoint->bmAttributes.usage == (TUSB_ISO_EP_ATT_EXPLICIT_FB >> 4); + break; + #endif + default: + break; + } - if (explicit_feedback) { + if (is_explicit_feedback) { const uint16_t fb_ep_size = tu_edpt_packet_size(desc_endpoint); if (has_feedback_ep || (fb_ep_size != 3 && fb_ep_size != 4)) { TU_LOG_DRV(" AUDIO AS itf %u alt %u: invalid/extra feedback ep %02x ignored\r\n", itf_num, alt, @@ -1325,7 +1338,7 @@ static const uint8_t *audioh_parse_as(audioh_interface_t *p_audio, const audioh_ break; } - if (usage == (TUSB_ISO_EP_ATT_DATA >> 4) || implicit_feedback) { + if (is_data_ep) { if (has_data_ep) { TU_LOG_DRV(" AUDIO AS itf %u alt %u: extra data ep %02x ignored\r\n", itf_num, alt, desc_endpoint->bEndpointAddress); |
