diff options
| author | YixingShen <[email protected]> | 2026-03-07 22:56:28 +0800 |
|---|---|---|
| committer | YixingShen <[email protected]> | 2026-03-07 22:56:28 +0800 |
| commit | 2a0802c6a56dc3849fe21d376908aff07131a111 (patch) | |
| tree | 136ee5ca9dec5f058ad8477f37c3f4b843c1a3a5 /src | |
| parent | 0a45308a296251e4376815b21f89f0038c75a60e (diff) | |
fixed _end_of_control_descriptor logic. wTotalLength does not include Standard Endpoint Descriptor and Class-specific VC Interrupt Endpoint Descriptor,
so fix that _end_of_control_descriptor include Standard Endpoint Descriptor and Class-specific VC Interrupt Endpoint Descriptor. It will also fix _close_vc_itf, _open_vc_itf. _find_desc_entity parsing.
Diffstat (limited to 'src')
| -rw-r--r-- | src/class/video/video_device.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/class/video/video_device.c b/src/class/video/video_device.c index 85ffcd627..a65d83d8f 100644 --- a/src/class/video/video_device.c +++ b/src/class/video/video_device.c @@ -392,7 +392,13 @@ static void const* _find_desc_ep(void const *beg, void const *end) static inline void const* _end_of_control_descriptor(void const *desc) { tusb_desc_vc_itf_t const *vc = (tusb_desc_vc_itf_t const *)desc; - return ((uint8_t const*) desc) + vc->std.bLength + tu_le16toh(vc->ctl.wTotalLength); + uint8_t const *end = (uint8_t const*)desc + vc->std.bLength + + tu_le16toh(vc->ctl.wTotalLength); + if (vc->std.bNumEndpoints) { + end += sizeof(tusb_desc_endpoint_t); // standard EP descriptor + end += 5; // class-specific EP descriptor (fixed 5 bytes per UVC spec) + } + return end; } /** Find the first entity descriptor with the entity ID @@ -771,7 +777,7 @@ static bool _open_vc_itf(uint8_t rhport, videod_interface_t *self, uint_fast8_t TU_ASSERT(vc->ctl.bInCollection <= CFG_TUD_VIDEO_STREAMING); /* Update to point the end of the video control interface descriptor. */ - end = (uint8_t const *) _end_of_control_descriptor(cur) + sizeof(tusb_desc_endpoint_t); + end = _end_of_control_descriptor(cur); /* Advance to the next descriptor after the class-specific VC interface header descriptor. */ cur += vc->std.bLength + vc->ctl.bLength; |
