@@ -680,24 +680,30 @@ static bool _open_vs_itf(uint8_t rhport, videod_streaming_interface_t *stm, uint
680
680
(video_probe_and_commit_control_t * )& stm -> ep_buf ;
681
681
tu_memclr (param , sizeof (* param ));
682
682
TU_LOG2 (" done 0\n" );
683
- return _update_streaming_parameters (stm , param );
683
+ if (!_update_streaming_parameters (stm , param ))
684
+ return false;
685
+ /* Open bulk endpoint if present. */
686
+ for (i = 0 , cur = tu_desc_next (cur ); i < numeps ; ++ i , cur = tu_desc_next (cur )) {
687
+ cur = _find_desc_ep (cur , end );
688
+ TU_ASSERT (cur < end );
689
+ tusb_desc_endpoint_t const * ep = (tusb_desc_endpoint_t const * )cur ;
690
+ TU_VERIFY (TUSB_XFER_BULK == ep -> bmAttributes .xfer );
691
+ TU_ASSERT (usbd_edpt_open (rhport , ep ));
692
+ stm -> desc .ep [i ] = (uint16_t )(cur - desc );
693
+ TU_LOG2 (" open EP%02x\n" , _desc_ep_addr (cur ));
694
+ }
695
+ return true;
684
696
}
685
- /* Open endpoints of the new settings. */
697
+ /* Open isochronous endpoints of the new settings. */
686
698
for (i = 0 , cur = tu_desc_next (cur ); i < numeps ; ++ i , cur = tu_desc_next (cur )) {
687
699
cur = _find_desc_ep (cur , end );
688
700
TU_ASSERT (cur < end );
689
701
tusb_desc_endpoint_t const * ep = (tusb_desc_endpoint_t const * )cur ;
690
- if (!stm -> max_payload_transfer_size ) {
691
- video_probe_and_commit_control_t const * param = (video_probe_and_commit_control_t const * )& stm -> ep_buf ;
692
- uint_fast32_t max_size = param -> dwMaxPayloadTransferSize ;
693
- if ((TUSB_XFER_ISOCHRONOUS == ep -> bmAttributes .xfer ) &&
694
- (tu_edpt_packet_size (ep ) < max_size ))
695
- {
696
- /* FS must be less than or equal to max packet size */
697
- return false;
698
- }
699
- /* Set the negotiated value */
700
- stm -> max_payload_transfer_size = max_size ;
702
+ uint_fast32_t max_size = stm -> max_payload_transfer_size ;
703
+ if ((TUSB_XFER_ISOCHRONOUS == ep -> bmAttributes .xfer ) &&
704
+ (tu_edpt_packet_size (ep ) < max_size )) {
705
+ /* FS must be less than or equal to max packet size */
706
+ return false;
701
707
}
702
708
TU_ASSERT (usbd_edpt_open (rhport , ep ));
703
709
stm -> desc .ep [i ] = (uint16_t ) (cur - desc );
@@ -982,9 +988,12 @@ static int handle_video_stm_cs_req(uint8_t rhport, uint8_t stage,
982
988
TU_VERIFY (sizeof (video_probe_and_commit_control_t ) >= request -> wLength , VIDEO_ERROR_UNKNOWN );
983
989
TU_VERIFY (tud_control_xfer (rhport , request , self -> ep_buf , sizeof (video_probe_and_commit_control_t )), VIDEO_ERROR_UNKNOWN );
984
990
} else if (stage == CONTROL_STAGE_DATA ) {
985
- TU_VERIFY (_update_streaming_parameters (self , (video_probe_and_commit_control_t * )self -> ep_buf ), VIDEO_ERROR_INVALID_VALUE_WITHIN_RANGE );
991
+ video_probe_and_commit_control_t * param = (video_probe_and_commit_control_t * )self -> ep_buf ;
992
+ TU_VERIFY (_update_streaming_parameters (self , param ), VIDEO_ERROR_INVALID_VALUE_WITHIN_RANGE );
993
+ /* Set the negotiated value */
994
+ self -> max_payload_transfer_size = param -> dwMaxPayloadTransferSize ;
986
995
if (tud_video_commit_cb ) {
987
- return tud_video_commit_cb (self -> index_vc , self -> index_vs , ( video_probe_and_commit_control_t * ) self -> ep_buf );
996
+ return tud_video_commit_cb (self -> index_vc , self -> index_vs , param );
988
997
}
989
998
}
990
999
return VIDEO_ERROR_NONE ;
0 commit comments