summaryrefslogtreecommitdiff
path: root/src/class
diff options
context:
space:
mode:
authorMark K Cowan <[email protected]>2022-10-26 21:40:30 +0300
committerMark K Cowan <[email protected]>2022-10-26 21:40:30 +0300
commit15ed45e1a33210c5e949801a77aabd544fa170ed (patch)
treeb9306db9f4d2ab1189c6b1ab3b359c9376a8d125 /src/class
parent025d3477e81e07ddc2db78193e8957cdb1050516 (diff)
clean up descriptor search for interrupt endpoint
Diffstat (limited to 'src/class')
-rw-r--r--src/class/audio/audio_device.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/src/class/audio/audio_device.c b/src/class/audio/audio_device.c
index 05339f9ce..efa06cf70 100644
--- a/src/class/audio/audio_device.c
+++ b/src/class/audio/audio_device.c
@@ -1090,40 +1090,36 @@ static bool set_int_ctr_number(audiod_function_t *audio)
uint8_t const *p_desc_end = audio->p_desc + audio->desc_length - TUD_AUDIO_DESC_IAD_LEN;
- // p_desc starts at required interface with alternate setting zero
- while (p_desc < p_desc_end)
+ bool found = false;
+ while (!found && p_desc < p_desc_end)
{
- // Find correct interface
- if (tu_desc_type(p_desc) == TUSB_DESC_INTERFACE && ((tusb_desc_interface_t const * )p_desc)->bInterfaceNumber == 0 && ((tusb_desc_interface_t const * )p_desc)->bAlternateSetting == 0)
+ // For each interface/alternate
+ if (tu_desc_type(p_desc) == TUSB_DESC_INTERFACE)
{
-
uint8_t foundEPs = 0, nEps = ((tusb_desc_interface_t const * )p_desc)->bNumEndpoints;
- while (foundEPs < nEps && p_desc < p_desc_end)
+ while (!found && foundEPs < nEps && p_desc < p_desc_end)
{
- // found :n endpoint
+ // For each endpoint
if (tu_desc_type(p_desc) == TUSB_DESC_ENDPOINT)
{
tusb_desc_endpoint_t const* desc_ep = (tusb_desc_endpoint_t const *) p_desc;
-
uint8_t const ep_addr = desc_ep->bEndpointAddress;
-
+ // If endpoint is input-direction and interrupt-type
if (tu_edpt_dir(ep_addr) == TUSB_DIR_IN && desc_ep->bmAttributes.xfer == 0x03) // Check if usage is interrupt EP
{
+ // Store endpoint number and open endpoint
audio->ep_int_ctr = ep_addr;
TU_ASSERT(usbd_edpt_open(audio->rhport, desc_ep));
+ found = true;
}
-
foundEPs += 1;
}
p_desc = tu_desc_next(p_desc);
}
- break;
}
p_desc = tu_desc_next(p_desc);
}
-
- return true;
-
+ return found;
}
#endif