3434
3535#include "video_device.h"
3636
37+ // Level where CFG_TUSB_DEBUG must be at least for this driver is logged
38+ #ifndef CFG_TUD_VIDEO_LOG_LEVEL
39+ #define CFG_TUD_VIDEO_LOG_LEVEL CFG_TUD_LOG_LEVEL
40+ #endif
41+
42+ #define TU_LOG_DRV (...) TU_LOG(CFG_TUD_VIDEO_LOG_LEVEL, __VA_ARGS__)
43+
3744//--------------------------------------------------------------------+
3845// MACRO CONSTANT TYPEDEF
3946//--------------------------------------------------------------------+
@@ -609,17 +616,17 @@ static bool _close_vc_itf(uint8_t rhport, videod_interface_t *self)
609616 * @param[in] altnum The target alternate setting number. */
610617static bool _open_vc_itf (uint8_t rhport , videod_interface_t * self , uint_fast8_t altnum )
611618{
612- TU_LOG2 (" open VC %d\n" , altnum );
619+ TU_LOG_DRV (" open VC %d\n" , altnum );
613620 uint8_t const * beg = self -> beg ;
614621 uint8_t const * end = beg + self -> len ;
615622
616623 /* The first descriptor is a video control interface descriptor. */
617624 uint8_t const * cur = _find_desc_itf (beg , end , _desc_itfnum (beg ), altnum );
618- TU_LOG2 (" cur %d\n" , cur - beg );
625+ TU_LOG_DRV (" cur %d\n" , cur - beg );
619626 TU_VERIFY (cur < end );
620627
621628 tusb_desc_vc_itf_t const * vc = (tusb_desc_vc_itf_t const * )cur ;
622- TU_LOG2 (" bInCollection %d\n" , vc -> ctl .bInCollection );
629+ TU_LOG_DRV (" bInCollection %d\n" , vc -> ctl .bInCollection );
623630 /* Support for up to 2 streaming interfaces only. */
624631 TU_ASSERT (vc -> ctl .bInCollection <= CFG_TUD_VIDEO_STREAMING );
625632
@@ -628,7 +635,7 @@ static bool _open_vc_itf(uint8_t rhport, videod_interface_t *self, uint_fast8_t
628635
629636 /* Advance to the next descriptor after the class-specific VC interface header descriptor. */
630637 cur += vc -> std .bLength + vc -> ctl .bLength ;
631- TU_LOG2 (" bNumEndpoints %d\n" , vc -> std .bNumEndpoints );
638+ TU_LOG_DRV (" bNumEndpoints %d\n" , vc -> std .bNumEndpoints );
632639 /* Open the notification endpoint if it exist. */
633640 if (vc -> std .bNumEndpoints ) {
634641 /* Support for 1 endpoint only. */
@@ -662,7 +669,7 @@ static bool _init_vs_configuration(videod_streaming_interface_t *stm)
662669static bool _open_vs_itf (uint8_t rhport , videod_streaming_interface_t * stm , uint_fast8_t altnum )
663670{
664671 uint_fast8_t i ;
665- TU_LOG2 (" reopen VS %d\n" , altnum );
672+ TU_LOG_DRV (" reopen VS %d\n" , altnum );
666673 uint8_t const * desc = _videod_itf [stm -> index_vc ].beg ;
667674
668675 /* Close endpoints of previous settings. */
@@ -672,7 +679,7 @@ static bool _open_vs_itf(uint8_t rhport, videod_streaming_interface_t *stm, uint
672679 uint8_t ep_adr = _desc_ep_addr (desc + ofs_ep );
673680 usbd_edpt_close (rhport , ep_adr );
674681 stm -> desc .ep [i ] = 0 ;
675- TU_LOG2 (" close EP%02x\n" , ep_adr );
682+ TU_LOG_DRV (" close EP%02x\n" , ep_adr );
676683 }
677684
678685 /* clear transfer management information */
@@ -709,12 +716,12 @@ static bool _open_vs_itf(uint8_t rhport, videod_streaming_interface_t *stm, uint
709716 }
710717 TU_ASSERT (usbd_edpt_open (rhport , ep ));
711718 stm -> desc .ep [i ] = (uint16_t ) (cur - desc );
712- TU_LOG2 (" open EP%02x\n" , _desc_ep_addr (cur ));
719+ TU_LOG_DRV (" open EP%02x\n" , _desc_ep_addr (cur ));
713720 }
714721 if (altnum ) {
715722 stm -> state = VS_STATE_STREAMING ;
716723 }
717- TU_LOG2 (" done\n" );
724+ TU_LOG_DRV (" done\n" );
718725 return true;
719726}
720727
0 commit comments