@@ -755,15 +755,20 @@ static bool _open_vs_itf(uint8_t rhport, videod_streaming_interface_t *stm, uint
755
755
TU_LOG_DRV (" reopen VS %d\r\n" , altnum );
756
756
uint8_t const * desc = _videod_itf [stm -> index_vc ].beg ;
757
757
758
+ #ifndef TUP_DCD_EDPT_ISO_ALLOC
758
759
/* Close endpoints of previous settings. */
759
760
for (i = 0 ; i < TU_ARRAY_SIZE (stm -> desc .ep ); ++ i ) {
760
761
uint_fast16_t ofs_ep = stm -> desc .ep [i ];
761
762
if (!ofs_ep ) break ;
762
- uint8_t ep_adr = _desc_ep_addr (desc + ofs_ep );
763
- usbd_edpt_close (rhport , ep_adr );
764
- stm -> desc .ep [i ] = 0 ;
765
- TU_LOG_DRV (" close EP%02x\r\n" , ep_adr );
763
+ tusb_desc_endpoint_t const * ep = (tusb_desc_endpoint_t const * )(desc + ofs_ep );
764
+ /* Only ISO endpoints needs to be closed */
765
+ if (ep -> bmAttributes .xfer == TUSB_XFER_ISOCHRONOUS ) {
766
+ usbd_edpt_close (rhport , ep -> bEndpointAddress );
767
+ stm -> desc .ep [i ] = 0 ;
768
+ TU_LOG_DRV (" close EP%02x\r\n" , ep -> bEndpointAddress );
769
+ }
766
770
}
771
+ #endif
767
772
768
773
/* clear transfer management information */
769
774
stm -> buffer = NULL ;
@@ -788,16 +793,18 @@ static bool _open_vs_itf(uint8_t rhport, videod_streaming_interface_t *stm, uint
788
793
TU_ASSERT (cur < end );
789
794
tusb_desc_endpoint_t const * ep = (tusb_desc_endpoint_t const * )cur ;
790
795
uint_fast32_t max_size = stm -> max_payload_transfer_size ;
791
- if (altnum ) {
792
- if ((TUSB_XFER_ISOCHRONOUS == ep -> bmAttributes .xfer ) &&
793
- (tu_edpt_packet_size (ep ) < max_size )) {
794
- /* FS must be less than or equal to max packet size */
795
- return false;
796
- }
796
+ if (altnum && (TUSB_XFER_ISOCHRONOUS == ep -> bmAttributes .xfer )) {
797
+ /* FS must be less than or equal to max packet size */
798
+ TU_VERIFY (tu_edpt_packet_size (ep ) >= max_size );
799
+ #ifdef TUP_DCD_EDPT_ISO_ALLOC
800
+ usbd_edpt_iso_activate (rhport , ep );
801
+ #else
802
+ TU_ASSERT (usbd_edpt_open (rhport , ep ));
803
+ #endif
797
804
} else {
798
805
TU_VERIFY (TUSB_XFER_BULK == ep -> bmAttributes .xfer );
806
+ TU_ASSERT (usbd_edpt_open (rhport , ep ));
799
807
}
800
- TU_ASSERT (usbd_edpt_open (rhport , ep ));
801
808
stm -> desc .ep [i ] = (uint16_t ) (cur - desc );
802
809
TU_LOG_DRV (" open EP%02x\r\n" , _desc_ep_addr (cur ));
803
810
}
@@ -1283,6 +1290,24 @@ uint16_t videod_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uin
1283
1290
cur = _next_desc_itf (cur , end );
1284
1291
stm -> desc .end = (uint16_t ) ((uintptr_t )cur - (uintptr_t )itf_desc );
1285
1292
stm -> state = VS_STATE_PROBING ;
1293
+ #ifdef TUP_DCD_EDPT_ISO_ALLOC
1294
+ /* Allocate ISO endpoints */
1295
+ uint16_t ep_size = 0 ;
1296
+ uint16_t ep_addr = 0 ;
1297
+ uint8_t const * p_desc = (uint8_t const * )itf_desc + stm -> desc .beg ;
1298
+ uint8_t const * p_desc_end = (uint8_t const * )itf_desc + stm -> desc .end ;
1299
+ while (p_desc < p_desc_end ) {
1300
+ if (tu_desc_type (p_desc ) == TUSB_DESC_ENDPOINT ) {
1301
+ tusb_desc_endpoint_t const * desc_ep = (tusb_desc_endpoint_t const * ) p_desc ;
1302
+ if (desc_ep -> bmAttributes .xfer == TUSB_XFER_ISOCHRONOUS ) {
1303
+ ep_addr = desc_ep -> bEndpointAddress ;
1304
+ ep_size = TU_MAX (tu_edpt_packet_size (desc_ep ), ep_size );
1305
+ }
1306
+ }
1307
+ p_desc = tu_desc_next (p_desc );
1308
+ }
1309
+ if (ep_addr > 0 && ep_size > 0 ) usbd_edpt_iso_alloc (rhport , ep_addr , ep_size );
1310
+ #endif
1286
1311
if (0 == stm_idx && 1 == bInCollection ) {
1287
1312
/* If there is only one streaming interface and no alternate settings,
1288
1313
* host may not issue set_interface so open the streaming interface here. */
0 commit comments