@@ -80,7 +80,7 @@ typedef struct TU_ATTR_PACKED {
80
80
81
81
/* video control interface */
82
82
typedef struct TU_ATTR_PACKED {
83
- void const * beg ; /* The head of the first video control interface descriptor */
83
+ uint8_t const * beg ; /* The head of the first video control interface descriptor */
84
84
uint16_t len ; /* Byte length of the descriptors */
85
85
uint16_t cur ; /* offset for current video control interface */
86
86
uint8_t stm [CFG_TUD_VIDEO_STREAMING ]; /* Indices of streaming interface */
@@ -108,19 +108,19 @@ static uint8_t const _cap_get_set = 0x3u; /* support for GET and SET */
108
108
* @param[in] desc interface descriptor
109
109
*
110
110
* @return bInterfaceNumber */
111
- static inline uint8_t _desc_itfnum (void const * desc )
111
+ static inline uint8_t _desc_itfnum (uint8_t const * desc )
112
112
{
113
- return (( uint8_t const * ) desc ) [2 ];
113
+ return desc [2 ];
114
114
}
115
115
116
116
/** Get endpoint address from the endpoint descriptor
117
117
*
118
118
* @param[in] desc endpoint descriptor
119
119
*
120
120
* @return bEndpointAddress */
121
- static inline uint8_t _desc_ep_addr (void const * desc )
121
+ static inline uint8_t _desc_ep_addr (uint8_t const * desc )
122
122
{
123
- return (( uint8_t const * ) desc ) [2 ];
123
+ return desc [2 ];
124
124
}
125
125
126
126
/** Get instance of streaming interface
@@ -146,7 +146,7 @@ static tusb_desc_vc_itf_t const* _get_desc_vc(videod_interface_t const *self)
146
146
static tusb_desc_vs_itf_t const * _get_desc_vs (videod_streaming_interface_t const * self )
147
147
{
148
148
if (!self -> desc .cur ) return NULL ;
149
- void const * desc = _videod_itf [self -> index_vc ].beg ;
149
+ uint8_t const * desc = _videod_itf [self -> index_vc ].beg ;
150
150
return (tusb_desc_vs_itf_t const * )(desc + self -> desc .cur );
151
151
}
152
152
@@ -158,9 +158,9 @@ static tusb_desc_vs_itf_t const* _get_desc_vs(videod_streaming_interface_t const
158
158
*
159
159
* @return The pointer for interface descriptor.
160
160
* @retval end did not found interface descriptor */
161
- static void const * _find_desc (void const * beg , void const * end , uint_fast8_t desc_type )
161
+ static uint8_t const * _find_desc (uint8_t const * beg , uint8_t const * end , uint_fast8_t desc_type )
162
162
{
163
- void const * cur = beg ;
163
+ uint8_t const * cur = beg ;
164
164
while ((cur < end ) && (desc_type != tu_desc_type (cur ))) {
165
165
cur = tu_desc_next (cur );
166
166
}
@@ -177,14 +177,13 @@ static void const* _find_desc(void const *beg, void const *end, uint_fast8_t des
177
177
*
178
178
* @return The pointer for interface descriptor.
179
179
* @retval end did not found interface descriptor */
180
- static void const * _find_desc_3 (void const * beg , void const * end ,
181
- uint_fast8_t desc_type ,
182
- uint_fast8_t element_0 ,
183
- uint_fast8_t element_1 )
180
+ static uint8_t const * _find_desc_3 (uint8_t const * beg , uint8_t const * end ,
181
+ uint_fast8_t desc_type ,
182
+ uint_fast8_t element_0 ,
183
+ uint_fast8_t element_1 )
184
184
{
185
- for (void const * cur = beg ; cur < end ; cur = _find_desc (cur , end , desc_type )) {
186
- uint8_t const * p = (uint8_t const * )cur ;
187
- if ((p [2 ] == element_0 ) && (p [3 ] == element_1 )) {
185
+ for (uint8_t const * cur = beg ; cur < end ; cur = _find_desc (cur , end , desc_type )) {
186
+ if ((cur [2 ] == element_0 ) && (cur [3 ] == element_1 )) {
188
187
return cur ;
189
188
}
190
189
cur = tu_desc_next (cur );
@@ -199,9 +198,9 @@ static void const* _find_desc_3(void const *beg, void const *end,
199
198
*
200
199
* @return The pointer for interface descriptor.
201
200
* @retval end did not found interface descriptor */
202
- static void const * _next_desc_itf (void const * beg , void const * end )
201
+ static uint8_t const * _next_desc_itf (void const * beg , uint8_t const * end )
203
202
{
204
- void const * cur = beg ;
203
+ uint8_t const * cur = beg ;
205
204
uint_fast8_t itfnum = ((tusb_desc_interface_t const * )cur )-> bInterfaceNumber ;
206
205
while ((cur < end ) &&
207
206
(itfnum == ((tusb_desc_interface_t const * )cur )-> bInterfaceNumber )) {
@@ -219,7 +218,7 @@ static void const* _next_desc_itf(void const *beg, void const *end)
219
218
*
220
219
* @return The pointer for interface descriptor.
221
220
* @retval end did not found interface descriptor */
222
- static inline void const * _find_desc_itf (void const * beg , void const * end , uint_fast8_t itfnum , uint_fast8_t altnum )
221
+ static inline uint8_t const * _find_desc_itf (uint8_t const * beg , uint8_t const * end , uint_fast8_t itfnum , uint_fast8_t altnum )
223
222
{
224
223
return _find_desc_3 (beg , end , TUSB_DESC_INTERFACE , itfnum , altnum );
225
224
}
@@ -233,9 +232,9 @@ static inline void const* _find_desc_itf(void const *beg, void const *end, uint_
233
232
*
234
233
* @return The pointer for endpoint descriptor.
235
234
* @retval end did not found endpoint descriptor */
236
- static void const * _find_desc_ep (void const * beg , void const * end )
235
+ static uint8_t const * _find_desc_ep (uint8_t const * beg , uint8_t const * end )
237
236
{
238
- for (void const * cur = beg ; cur < end ; cur = tu_desc_next (cur )) {
237
+ for (uint8_t const * cur = beg ; cur < end ; cur = tu_desc_next (cur )) {
239
238
uint_fast8_t desc_type = tu_desc_type (cur );
240
239
if (TUSB_DESC_ENDPOINT == desc_type ) return cur ;
241
240
if (TUSB_DESC_INTERFACE == desc_type ) break ;
@@ -251,17 +250,17 @@ static void const* _find_desc_ep(void const *beg, void const *end)
251
250
*
252
251
* @return The pointer for interface descriptor.
253
252
* @retval end did not found interface descriptor */
254
- static void const * _find_desc_entity (void const * desc , uint_fast8_t entityid )
253
+ static uint8_t const * _find_desc_entity (void const * desc , uint_fast8_t entityid )
255
254
{
256
255
tusb_desc_vc_itf_t const * vc = (tusb_desc_vc_itf_t const * )desc ;
257
- void const * beg = vc ;
258
- void const * end = beg + vc -> std .bLength + vc -> ctl .wTotalLength ;
259
- for (void const * cur = beg ; cur < end ; cur = _find_desc (cur , end , TUSB_DESC_CS_INTERFACE )) {
256
+ uint8_t const * beg = desc ;
257
+ uint8_t const * end = beg + vc -> std .bLength + vc -> ctl .wTotalLength ;
258
+ for (uint8_t const * cur = beg ; cur < end ; cur = _find_desc (cur , end , TUSB_DESC_CS_INTERFACE )) {
260
259
tusb_desc_cs_video_entity_itf_t const * itf = (tusb_desc_cs_video_entity_itf_t const * )cur ;
261
260
if ((VIDEO_CS_ITF_VC_INPUT_TERMINAL <= itf -> bDescriptorSubtype
262
261
&& itf -> bDescriptorSubtype < VIDEO_CS_ITF_VC_MAX )
263
262
&& itf -> bEntityId == entityid ) {
264
- return itf ;
263
+ return cur ;
265
264
}
266
265
cur = tu_desc_next (cur );
267
266
}
@@ -272,18 +271,18 @@ static void const* _find_desc_entity(void const *desc, uint_fast8_t entityid)
272
271
static inline void const * _end_of_streaming_descriptor (void const * desc )
273
272
{
274
273
tusb_desc_vs_itf_t const * vs = (tusb_desc_vs_itf_t const * )desc ;
275
- return desc + vs -> std .bLength + vs -> stm .wTotalLength ;
274
+ return ( uint8_t const * ) desc + vs -> std .bLength + vs -> stm .wTotalLength ;
276
275
}
277
276
278
277
/** Find the first format descriptor with the specified format number. */
279
- static inline tusb_desc_cs_video_fmt_uncompressed_t const * _find_desc_format (void const * beg , void const * end , uint_fast8_t fmtnum )
278
+ static inline tusb_desc_cs_video_fmt_uncompressed_t const * _find_desc_format (uint8_t const * beg , uint8_t const * end , uint_fast8_t fmtnum )
280
279
{
281
280
return (tusb_desc_cs_video_fmt_uncompressed_t const * )
282
281
_find_desc_3 (beg , end , TUSB_DESC_CS_INTERFACE , VIDEO_CS_ITF_VS_FORMAT_UNCOMPRESSED , fmtnum );
283
282
}
284
283
285
284
/** Find the first frame descriptor with the specified format number. */
286
- static inline tusb_desc_cs_video_frm_uncompressed_t const * _find_desc_frame (void const * beg , void const * end , uint_fast8_t frmnum )
285
+ static inline tusb_desc_cs_video_frm_uncompressed_t const * _find_desc_frame (uint8_t const * beg , uint8_t const * end , uint_fast8_t frmnum )
287
286
{
288
287
return (tusb_desc_cs_video_frm_uncompressed_t const * )
289
288
_find_desc_3 (beg , end , TUSB_DESC_CS_INTERFACE , VIDEO_CS_ITF_VS_FRAME_UNCOMPRESSED , frmnum );
@@ -485,9 +484,9 @@ static bool _close_vc_itf(uint8_t rhport, videod_interface_t *self)
485
484
{
486
485
tusb_desc_vc_itf_t const * vc = _get_desc_vc (self );
487
486
/* The next descriptor after the class-specific VC interface header descriptor. */
488
- void const * cur = (void const * )vc + vc -> std .bLength + vc -> ctl .bLength ;
487
+ uint8_t const * cur = (uint8_t const * )vc + vc -> std .bLength + vc -> ctl .bLength ;
489
488
/* The end of the video control interface descriptor. */
490
- void const * end = (void const * )vc + vc -> std .bLength + vc -> ctl .wTotalLength ;
489
+ uint8_t const * end = (uint8_t const * )vc + vc -> std .bLength + vc -> ctl .wTotalLength ;
491
490
if (vc -> std .bNumEndpoints ) {
492
491
/* Find the notification endpoint descriptor. */
493
492
cur = _find_desc (cur , end , TUSB_DESC_ENDPOINT );
@@ -506,10 +505,10 @@ static bool _close_vc_itf(uint8_t rhport, videod_interface_t *self)
506
505
static bool _open_vc_itf (uint8_t rhport , videod_interface_t * self , uint_fast8_t altnum )
507
506
{
508
507
TU_LOG2 (" open VC %d\n" , altnum );
509
- void const * beg = self -> beg ;
510
- void const * end = beg + self -> len ;
508
+ uint8_t const * beg = self -> beg ;
509
+ uint8_t const * end = beg + self -> len ;
511
510
/* The first descriptor is a video control interface descriptor. */
512
- void const * cur = _find_desc_itf (beg , end , _desc_itfnum (beg ), altnum );
511
+ uint8_t const * cur = _find_desc_itf (beg , end , _desc_itfnum (beg ), altnum );
513
512
TU_LOG2 (" cur %d\n" , cur - beg );
514
513
TU_VERIFY (cur < end );
515
514
@@ -534,7 +533,7 @@ static bool _open_vc_itf(uint8_t rhport, videod_interface_t *self, uint_fast8_t
534
533
/* Open the notification endpoint */
535
534
TU_ASSERT (usbd_edpt_open (rhport , notif ));
536
535
}
537
- self -> cur = (uint16_t ) ((void const * )vc - beg );
536
+ self -> cur = (uint16_t ) ((uint8_t const * )vc - beg );
538
537
return true;
539
538
}
540
539
@@ -546,7 +545,7 @@ static bool _open_vs_itf(uint8_t rhport, videod_streaming_interface_t *stm, uint
546
545
{
547
546
uint_fast8_t i ;
548
547
TU_LOG2 (" reopen VS %d\n" , altnum );
549
- void const * desc = _videod_itf [stm -> index_vc ].beg ;
548
+ uint8_t const * desc = _videod_itf [stm -> index_vc ].beg ;
550
549
551
550
/* Close endpoints of previous settings. */
552
551
for (i = 0 ; i < TU_ARRAY_SIZE (stm -> desc .ep ); ++ i ) {
@@ -563,9 +562,9 @@ static bool _open_vs_itf(uint8_t rhport, videod_streaming_interface_t *stm, uint
563
562
stm -> offset = 0 ;
564
563
565
564
/* Find a alternate interface */
566
- void const * beg = desc + stm -> desc .beg ;
567
- void const * end = desc + stm -> desc .end ;
568
- void const * cur = _find_desc_itf (beg , end , _desc_itfnum (beg ), altnum );
565
+ uint8_t const * beg = desc + stm -> desc .beg ;
566
+ uint8_t const * end = desc + stm -> desc .end ;
567
+ uint8_t const * cur = _find_desc_itf (beg , end , _desc_itfnum (beg ), altnum );
569
568
TU_VERIFY (cur < end );
570
569
uint_fast8_t numeps = ((tusb_desc_interface_t const * )cur )-> bNumEndpoints ;
571
570
TU_ASSERT (numeps <= TU_ARRAY_SIZE (stm -> desc .ep ));
@@ -977,7 +976,7 @@ bool tud_video_n_frame_xfer(uint_fast8_t ctl_idx, uint_fast8_t stm_idx, void *bu
977
976
if (!stm || !stm -> desc .ep [0 ] || stm -> buffer ) return false;
978
977
979
978
/* Find EP address */
980
- void const * desc = _videod_itf [stm -> index_vc ].beg ;
979
+ uint8_t const * desc = _videod_itf [stm -> index_vc ].beg ;
981
980
uint8_t ep_addr = 0 ;
982
981
for (uint_fast8_t i = 0 ; i < CFG_TUD_VIDEO_STREAMING ; ++ i ) {
983
982
uint_fast16_t ofs_ep = stm -> desc .ep [i ];
@@ -1044,15 +1043,15 @@ uint16_t videod_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uin
1044
1043
}
1045
1044
TU_ASSERT (ctl_idx < CFG_TUD_VIDEO , 0 );
1046
1045
1047
- void const * end = (void const * )itf_desc + max_len ;
1048
- self -> beg = itf_desc ;
1046
+ uint8_t const * end = (uint8_t const * )itf_desc + max_len ;
1047
+ self -> beg = ( uint8_t const * ) itf_desc ;
1049
1048
self -> len = max_len ;
1050
1049
/*------------- Video Control Interface -------------*/
1051
1050
TU_VERIFY (_open_vc_itf (rhport , self , 0 ), 0 );
1052
1051
tusb_desc_vc_itf_t const * vc = _get_desc_vc (self );
1053
1052
uint_fast8_t bInCollection = vc -> ctl .bInCollection ;
1054
1053
/* Find the end of the video interface descriptor */
1055
- void const * cur = _next_desc_itf (itf_desc , end );
1054
+ uint8_t const * cur = _next_desc_itf (itf_desc , end );
1056
1055
for (uint8_t stm_idx = 0 ; stm_idx < bInCollection ; ++ stm_idx ) {
1057
1056
videod_streaming_interface_t * stm = NULL ;
1058
1057
/* find free streaming interface handle */
@@ -1085,7 +1084,7 @@ bool videod_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request_
1085
1084
/* Identify which control interface to use */
1086
1085
uint_fast8_t itf ;
1087
1086
for (itf = 0 ; itf < CFG_TUD_VIDEO ; ++ itf ) {
1088
- void const * desc = _videod_itf [itf ].beg ;
1087
+ uint8_t const * desc = _videod_itf [itf ].beg ;
1089
1088
if (!desc ) continue ;
1090
1089
if (itfnum == _desc_itfnum (desc )) break ;
1091
1090
}
@@ -1101,7 +1100,7 @@ bool videod_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request_
1101
1100
for (itf = 0 ; itf < CFG_TUD_VIDEO_STREAMING ; ++ itf ) {
1102
1101
videod_streaming_interface_t * stm = & _videod_streaming_itf [itf ];
1103
1102
if (!stm -> desc .beg ) continue ;
1104
- void const * desc = _videod_itf [stm -> index_vc ].beg ;
1103
+ uint8_t const * desc = _videod_itf [stm -> index_vc ].beg ;
1105
1104
if (itfnum == _desc_itfnum (desc + stm -> desc .beg )) break ;
1106
1105
}
1107
1106
@@ -1127,7 +1126,7 @@ bool videod_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint3
1127
1126
uint_fast16_t const ep_ofs = stm -> desc .ep [0 ];
1128
1127
if (!ep_ofs ) continue ;
1129
1128
ctl = & _videod_itf [stm -> index_vc ];
1130
- void const * desc = ctl -> beg ;
1129
+ uint8_t const * desc = ctl -> beg ;
1131
1130
if (ep_addr == _desc_ep_addr (desc + ep_ofs )) break ;
1132
1131
}
1133
1132
0 commit comments