Skip to content

Commit 78732d6

Browse files
committed
Fix streaming interface handling
1 parent 97f9321 commit 78732d6

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/class/video/video_device.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -709,11 +709,6 @@ static bool _open_vs_itf(uint8_t rhport, videod_streaming_interface_t *stm, uint
709709
stm->desc.ep[i] = (uint16_t) (cur - desc);
710710
TU_LOG2(" open EP%02x\n", _desc_ep_addr(cur));
711711
}
712-
/* initialize payload header */
713-
tusb_video_payload_header_t *hdr = (tusb_video_payload_header_t*)stm->ep_buf;
714-
hdr->bHeaderLength = sizeof(*hdr);
715-
hdr->bmHeaderInfo = 0;
716-
717712
TU_LOG2(" done\n");
718713
return true;
719714
}
@@ -992,8 +987,15 @@ static int handle_video_stm_cs_req(uint8_t rhport, uint8_t stage,
992987
TU_VERIFY(_update_streaming_parameters(self, param), VIDEO_ERROR_INVALID_VALUE_WITHIN_RANGE);
993988
/* Set the negotiated value */
994989
self->max_payload_transfer_size = param->dwMaxPayloadTransferSize;
990+
int ret = VIDEO_ERROR_NONE;
995991
if (tud_video_commit_cb) {
996-
return tud_video_commit_cb(self->index_vc, self->index_vs, param);
992+
ret = tud_video_commit_cb(self->index_vc, self->index_vs, param);
993+
}
994+
if (VIDEO_ERROR_NONE == ret) {
995+
/* initialize payload header */
996+
tusb_video_payload_header_t *hdr = (tusb_video_payload_header_t*)self->ep_buf;
997+
hdr->bHeaderLength = sizeof(*hdr);
998+
hdr->bmHeaderInfo = 0;
997999
}
9981000
}
9991001
return VIDEO_ERROR_NONE;
@@ -1166,6 +1168,7 @@ uint16_t videod_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uin
11661168
tusb_desc_vc_itf_t const *vc = _get_desc_vc(self);
11671169
uint_fast8_t bInCollection = vc->ctl.bInCollection;
11681170

1171+
videod_streaming_interface_t *default_stm = NULL;
11691172
/* Find the end of the video interface descriptor */
11701173
void const *cur = _next_desc_itf(itf_desc, end);
11711174
for (uint8_t stm_idx = 0; stm_idx < bInCollection; ++stm_idx) {
@@ -1183,7 +1186,9 @@ uint16_t videod_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uin
11831186
stm->desc.beg = (uint16_t) ((uintptr_t)cur - (uintptr_t)itf_desc);
11841187
cur = _next_desc_itf(cur, end);
11851188
stm->desc.end = (uint16_t) ((uintptr_t)cur - (uintptr_t)itf_desc);
1189+
if (!default_stm) default_stm = stm;
11861190
}
1191+
TU_VERIFY(_open_vs_itf(rhport, default_stm, 0), 0);
11871192
self->len = (uint16_t) ((uintptr_t)cur - (uintptr_t)itf_desc);
11881193
return (uint16_t) ((uintptr_t)cur - (uintptr_t)itf_desc);
11891194
}

0 commit comments

Comments
 (0)