@@ -67,6 +67,7 @@ typedef union {
6767 uint8_t bDescriptorType ;
6868 uint8_t bDescriptorSubType ;
6969 uint8_t bFormatIndex ;
70+ uint8_t bNumFrameDescriptors ;
7071 };
7172 tusb_desc_cs_video_fmt_uncompressed_t uncompressed ;
7273 tusb_desc_cs_video_fmt_mjpeg_t mjpeg ;
@@ -437,11 +438,11 @@ static bool _update_streaming_parameters(videod_streaming_interface_t const *stm
437438 tusb_desc_cs_video_fmt_t const * fmt = _find_desc_format (tu_desc_next (vs ), end , fmtnum );
438439 TU_ASSERT (fmt != end );
439440
440- switch (fmt -> bDescriptorSubtype ) {
441+ switch (fmt -> bDescriptorSubType ) {
441442 case VIDEO_CS_ITF_VS_FORMAT_UNCOMPRESSED :
442443 param -> wCompQuality = 1 ; /* 1 to 10000 */
443444 break ;
444- case VIDEO_CS_ITF_VS_FORMAT_MJPEG ;
445+ case VIDEO_CS_ITF_VS_FORMAT_MJPEG :
445446 break ;
446447 default : return false;
447448 }
@@ -459,11 +460,11 @@ static bool _update_streaming_parameters(videod_streaming_interface_t const *stm
459460 /* Set the parameters determined by the frame */
460461 uint_fast32_t frame_size = param -> dwMaxVideoFrameSize ;
461462 if (!frame_size ) {
462- switch (fmt -> bDescriptorSubtype ) {
463+ switch (fmt -> bDescriptorSubType ) {
463464 case VIDEO_CS_ITF_VS_FORMAT_UNCOMPRESSED :
464465 frame_size = (uint_fast32_t )frm -> uncompressed .wWidth * frm -> uncompressed .wHeight * fmt -> uncompressed .bBitsPerPixel / 8 ;
465466 break ;
466- case VIDEO_CS_ITF_VS_FORMAT_MJPEG ;
467+ case VIDEO_CS_ITF_VS_FORMAT_MJPEG :
467468 frame_size = (uint_fast32_t )frm -> mjpeg .wWidth * frm -> mjpeg .wHeight * 16 / 8 ; /* YUV422 */
468469 break ;
469470 default : break ;
@@ -473,11 +474,12 @@ static bool _update_streaming_parameters(videod_streaming_interface_t const *stm
473474
474475 uint_fast32_t interval = param -> dwFrameInterval ;
475476 if (!interval ) {
476- if ((1 < frm -> bFrameIntervalType ) ||
477- ((0 == frm -> bFrameIntervalType ) && (frm -> dwFrameInterval [1 ] != frm -> dwFrameInterval [0 ]))) {
477+ if ((1 < frm -> uncompressed .bFrameIntervalType ) ||
478+ ((0 == frm -> uncompressed .bFrameIntervalType ) &&
479+ (frm -> uncompressed .dwFrameInterval [1 ] != frm -> uncompressed .dwFrameInterval [0 ]))) {
478480 return true;
479481 }
480- interval = frm -> dwFrameInterval [0 ];
482+ interval = frm -> uncompressed . dwFrameInterval [0 ];
481483 param -> dwFrameInterval = interval ;
482484 }
483485 uint_fast32_t interval_ms = interval / 10000 ;
@@ -709,6 +711,7 @@ static bool _open_vs_itf(uint8_t rhport, videod_streaming_interface_t *stm, uint
709711 video_probe_and_commit_control_t * param =
710712 (video_probe_and_commit_control_t * )& stm -> ep_buf ;
711713 tu_memclr (param , sizeof (* param ));
714+ TU_LOG2 (" done 0\n" );
712715 return _update_streaming_parameters (stm , param );
713716 }
714717 /* Open endpoints of the new settings. */
@@ -737,6 +740,7 @@ static bool _open_vs_itf(uint8_t rhport, videod_streaming_interface_t *stm, uint
737740 hdr -> bHeaderLength = sizeof (* hdr );
738741 hdr -> bmHeaderInfo = 0 ;
739742
743+ TU_LOG2 (" done\n" );
740744 return true;
741745}
742746
@@ -809,7 +813,7 @@ static int handle_video_ctl_cs_req(uint8_t rhport, uint8_t stage,
809813 if (stage == CONTROL_STAGE_SETUP ) {
810814 TU_VERIFY (1 == request -> wLength , VIDEO_ERROR_UNKNOWN );
811815 TU_VERIFY (tud_control_xfer (rhport , request , & self -> power_mode , sizeof (self -> power_mode )), VIDEO_ERROR_UNKNOWN );
812- } else if (stage == CONTROL_STAGE_ACK ) {
816+ } else if (stage == CONTROL_STAGE_DATA ) {
813817 if (tud_video_power_mode_cb ) return tud_video_power_mode_cb (ctl_idx , self -> power_mode );
814818 }
815819 return VIDEO_ERROR_NONE ;
@@ -954,7 +958,7 @@ static int handle_video_stm_cs_req(uint8_t rhport, uint8_t stage,
954958 TU_VERIFY (sizeof (video_probe_and_commit_control_t ) == request -> wLength , VIDEO_ERROR_UNKNOWN );
955959 TU_VERIFY (tud_control_xfer (rhport , request , self -> ep_buf , sizeof (video_probe_and_commit_control_t )),
956960 VIDEO_ERROR_UNKNOWN );
957- } else if (stage == CONTROL_STAGE_ACK ) {
961+ } else if (stage == CONTROL_STAGE_DATA ) {
958962 TU_VERIFY (_update_streaming_parameters (self , (video_probe_and_commit_control_t * )self -> ep_buf ),
959963 VIDEO_ERROR_INVALID_VALUE_WITHIN_RANGE );
960964 }
@@ -1009,7 +1013,7 @@ static int handle_video_stm_cs_req(uint8_t rhport, uint8_t stage,
10091013 if (stage == CONTROL_STAGE_SETUP ) {
10101014 TU_VERIFY (sizeof (video_probe_and_commit_control_t ) == request -> wLength , VIDEO_ERROR_UNKNOWN );
10111015 TU_VERIFY (tud_control_xfer (rhport , request , self -> ep_buf , sizeof (video_probe_and_commit_control_t )), VIDEO_ERROR_UNKNOWN );
1012- } else if (stage == CONTROL_STAGE_ACK ) {
1016+ } else if (stage == CONTROL_STAGE_DATA ) {
10131017 TU_VERIFY (_update_streaming_parameters (self , (video_probe_and_commit_control_t * )self -> ep_buf ), VIDEO_ERROR_INVALID_VALUE_WITHIN_RANGE );
10141018 if (tud_video_commit_cb ) {
10151019 return tud_video_commit_cb (self -> index_vc , self -> index_vs , (video_probe_and_commit_control_t * )self -> ep_buf );
0 commit comments