Skip to content

Commit e508831

Browse files
committed
Update handle streaming interface
1 parent 78732d6 commit e508831

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/class/video/video_device.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,7 +1168,6 @@ uint16_t videod_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uin
11681168
tusb_desc_vc_itf_t const *vc = _get_desc_vc(self);
11691169
uint_fast8_t bInCollection = vc->ctl.bInCollection;
11701170

1171-
videod_streaming_interface_t *default_stm = NULL;
11721171
/* Find the end of the video interface descriptor */
11731172
void const *cur = _next_desc_itf(itf_desc, end);
11741173
for (uint8_t stm_idx = 0; stm_idx < bInCollection; ++stm_idx) {
@@ -1186,9 +1185,16 @@ uint16_t videod_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uin
11861185
stm->desc.beg = (uint16_t) ((uintptr_t)cur - (uintptr_t)itf_desc);
11871186
cur = _next_desc_itf(cur, end);
11881187
stm->desc.end = (uint16_t) ((uintptr_t)cur - (uintptr_t)itf_desc);
1189-
if (!default_stm) default_stm = stm;
1188+
if (0 == stm_idx && 1 == bInCollection) {
1189+
/* If there is only one streaming interface and no alternate settings,
1190+
* host may not issue set_interface so open the streaming interface here. */
1191+
uint8_t const *sbeg = (uint8_t const*)itf_desc + stm->desc.beg;
1192+
uint8_t const *send = (uint8_t const*)itf_desc + stm->desc.end;
1193+
if (end == _find_desc_itf(sbeg, send, _desc_itfnum(sbeg), 1)) {
1194+
TU_VERIFY(_open_vs_itf(rhport, stm, 0), 0);
1195+
}
1196+
}
11901197
}
1191-
TU_VERIFY(_open_vs_itf(rhport, default_stm, 0), 0);
11921198
self->len = (uint16_t) ((uintptr_t)cur - (uintptr_t)itf_desc);
11931199
return (uint16_t) ((uintptr_t)cur - (uintptr_t)itf_desc);
11941200
}
@@ -1201,7 +1207,6 @@ bool videod_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request_
12011207
int err;
12021208
TU_VERIFY(request->bmRequestType_bit.recipient == TUSB_REQ_RCPT_INTERFACE);
12031209
uint_fast8_t itfnum = tu_u16_low(request->wIndex);
1204-
12051210
/* Identify which control interface to use */
12061211
uint_fast8_t itf;
12071212
for (itf = 0; itf < CFG_TUD_VIDEO; ++itf) {

0 commit comments

Comments
 (0)