@@ -709,11 +709,6 @@ static bool _open_vs_itf(uint8_t rhport, videod_streaming_interface_t *stm, uint
709
709
stm -> desc .ep [i ] = (uint16_t ) (cur - desc );
710
710
TU_LOG2 (" open EP%02x\n" , _desc_ep_addr (cur ));
711
711
}
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
-
717
712
TU_LOG2 (" done\n" );
718
713
return true;
719
714
}
@@ -992,8 +987,15 @@ static int handle_video_stm_cs_req(uint8_t rhport, uint8_t stage,
992
987
TU_VERIFY (_update_streaming_parameters (self , param ), VIDEO_ERROR_INVALID_VALUE_WITHIN_RANGE );
993
988
/* Set the negotiated value */
994
989
self -> max_payload_transfer_size = param -> dwMaxPayloadTransferSize ;
990
+ int ret = VIDEO_ERROR_NONE ;
995
991
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 ;
997
999
}
998
1000
}
999
1001
return VIDEO_ERROR_NONE ;
@@ -1166,6 +1168,7 @@ uint16_t videod_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uin
1166
1168
tusb_desc_vc_itf_t const * vc = _get_desc_vc (self );
1167
1169
uint_fast8_t bInCollection = vc -> ctl .bInCollection ;
1168
1170
1171
+ videod_streaming_interface_t * default_stm = NULL ;
1169
1172
/* Find the end of the video interface descriptor */
1170
1173
void const * cur = _next_desc_itf (itf_desc , end );
1171
1174
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
1183
1186
stm -> desc .beg = (uint16_t ) ((uintptr_t )cur - (uintptr_t )itf_desc );
1184
1187
cur = _next_desc_itf (cur , end );
1185
1188
stm -> desc .end = (uint16_t ) ((uintptr_t )cur - (uintptr_t )itf_desc );
1189
+ if (!default_stm ) default_stm = stm ;
1186
1190
}
1191
+ TU_VERIFY (_open_vs_itf (rhport , default_stm , 0 ), 0 );
1187
1192
self -> len = (uint16_t ) ((uintptr_t )cur - (uintptr_t )itf_desc );
1188
1193
return (uint16_t ) ((uintptr_t )cur - (uintptr_t )itf_desc );
1189
1194
}
0 commit comments