mikroSDK Reference Manual
video.h
1/*
2 * The MIT License (MIT)
3 *
4 * Copyright (c) 2021 Koji KITAYAMA
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 *
24 * This file is part of the TinyUSB stack.
25 */
26
27#ifndef TUSB_VIDEO_H_
28#define TUSB_VIDEO_H_
29
30#include "common/tusb_common.h"
31
32// Table 3-19 Color Matching Descriptor
33typedef enum {
34 VIDEO_COLOR_PRIMARIES_UNDEFINED = 0x00,
35 VIDEO_COLOR_PRIMARIES_BT709, // sRGB (default)
36 VIDEO_COLOR_PRIMARIES_BT470_2M,
37 VIDEO_COLOR_PRIMARIES_BT470_2BG,
38 VIDEO_COLOR_PRIMARIES_SMPTE170M,
39 VIDEO_COLOR_PRIMARIES_SMPTE240M,
40} video_color_primaries_t;
41
42// Table 3-19 Color Matching Descriptor
43typedef enum {
44 VIDEO_COLOR_XFER_CH_UNDEFINED = 0x00,
45 VIDEO_COLOR_XFER_CH_BT709, // default
46 VIDEO_COLOR_XFER_CH_BT470_2M,
47 VIDEO_COLOR_XFER_CH_BT470_2BG,
48 VIDEO_COLOR_XFER_CH_SMPTE170M,
49 VIDEO_COLOR_XFER_CH_SMPTE240M,
50 VIDEO_COLOR_XFER_CH_LINEAR,
51 VIDEO_COLOR_XFER_CH_SRGB,
52} video_color_transfer_characteristics_t;
53
54// Table 3-19 Color Matching Descriptor
55typedef enum {
56 VIDEO_COLOR_COEF_UNDEFINED = 0x00,
57 VIDEO_COLOR_COEF_BT709,
58 VIDEO_COLOR_COEF_FCC,
59 VIDEO_COLOR_COEF_BT470_2BG,
60 VIDEO_COLOR_COEF_SMPTE170M, // BT.601 default
61 VIDEO_COLOR_COEF_SMPTE240M,
62} video_color_matrix_coefficients_t;
63
64/* 4.2.1.2 Request Error Code Control */
65typedef enum {
66 VIDEO_ERROR_NONE = 0, /* The request succeeded. */
67 VIDEO_ERROR_NOT_READY,
68 VIDEO_ERROR_WRONG_STATE,
69 VIDEO_ERROR_POWER,
70 VIDEO_ERROR_OUT_OF_RANGE,
71 VIDEO_ERROR_INVALID_UNIT,
72 VIDEO_ERROR_INVALID_CONTROL,
73 VIDEO_ERROR_INVALID_REQUEST,
74 VIDEO_ERROR_INVALID_VALUE_WITHIN_RANGE,
75 VIDEO_ERROR_UNKNOWN = 0xFF,
76} video_error_code_t;
77
78/* A.2 Interface Subclass */
79typedef enum {
80 VIDEO_SUBCLASS_UNDEFINED = 0x00,
81 VIDEO_SUBCLASS_CONTROL,
82 VIDEO_SUBCLASS_STREAMING,
83 VIDEO_SUBCLASS_INTERFACE_COLLECTION,
84} video_subclass_type_t;
85
86/* A.3 Interface Protocol */
87typedef enum {
88 VIDEO_ITF_PROTOCOL_UNDEFINED = 0x00,
89 VIDEO_ITF_PROTOCOL_15,
90} video_interface_protocol_code_t;
91
92/* A.5 Class-Specific VideoControl Interface Descriptor Subtypes */
93typedef enum {
94 VIDEO_CS_ITF_VC_UNDEFINED = 0x00,
95 VIDEO_CS_ITF_VC_HEADER,
96 VIDEO_CS_ITF_VC_INPUT_TERMINAL,
97 VIDEO_CS_ITF_VC_OUTPUT_TERMINAL,
98 VIDEO_CS_ITF_VC_SELECTOR_UNIT,
99 VIDEO_CS_ITF_VC_PROCESSING_UNIT,
100 VIDEO_CS_ITF_VC_EXTENSION_UNIT,
101 VIDEO_CS_ITF_VC_ENCODING_UNIT,
102 VIDEO_CS_ITF_VC_MAX,
103} video_cs_vc_interface_subtype_t;
104
105/* A.6 Class-Specific VideoStreaming Interface Descriptor Subtypes */
106typedef enum {
107 VIDEO_CS_ITF_VS_UNDEFINED = 0x00,
108 VIDEO_CS_ITF_VS_INPUT_HEADER = 0x01,
109 VIDEO_CS_ITF_VS_OUTPUT_HEADER = 0x02,
110 VIDEO_CS_ITF_VS_STILL_IMAGE_FRAME = 0x03,
111 VIDEO_CS_ITF_VS_FORMAT_UNCOMPRESSED = 0x04,
112 VIDEO_CS_ITF_VS_FRAME_UNCOMPRESSED = 0x05,
113 VIDEO_CS_ITF_VS_FORMAT_MJPEG = 0x06,
114 VIDEO_CS_ITF_VS_FRAME_MJPEG = 0x07,
115 VIDEO_CS_ITF_VS_FORMAT_MPEG2TS = 0x0A,
116 VIDEO_CS_ITF_VS_FORMAT_DV = 0x0C,
117 VIDEO_CS_ITF_VS_COLORFORMAT = 0x0D,
118 VIDEO_CS_ITF_VS_FORMAT_FRAME_BASED = 0x10,
119 VIDEO_CS_ITF_VS_FRAME_FRAME_BASED = 0x11,
120 VIDEO_CS_ITF_VS_FORMAT_STREAM_BASED = 0x12,
121 VIDEO_CS_ITF_VS_FORMAT_H264 = 0x13,
122 VIDEO_CS_ITF_VS_FRAME_H264 = 0x14,
123 VIDEO_CS_ITF_VS_FORMAT_H264_SIMULCAST = 0x15,
124 VIDEO_CS_ITF_VS_FORMAT_VP8 = 0x16,
125 VIDEO_CS_ITF_VS_FRAME_VP8 = 0x17,
126 VIDEO_CS_ITF_VS_FORMAT_VP8_SIMULCAST = 0x18,
127} video_cs_vs_interface_subtype_t;
128
129/* A.7. Class-Specific Endpoint Descriptor Subtypes */
130typedef enum {
131 VIDEO_CS_EP_UNDEFINED = 0x00,
132 VIDEO_CS_EP_GENERAL,
133 VIDEO_CS_EP_ENDPOINT,
134 VIDEO_CS_EP_INTERRUPT
135} video_cs_ep_subtype_t;
136
137/* A.8 Class-Specific Request Codes */
138typedef enum {
139 VIDEO_REQUEST_UNDEFINED = 0x00,
140 VIDEO_REQUEST_SET_CUR = 0x01,
141 VIDEO_REQUEST_SET_CUR_ALL = 0x11,
142 VIDEO_REQUEST_GET_CUR = 0x81,
143 VIDEO_REQUEST_GET_MIN = 0x82,
144 VIDEO_REQUEST_GET_MAX = 0x83,
145 VIDEO_REQUEST_GET_RES = 0x84,
146 VIDEO_REQUEST_GET_LEN = 0x85,
147 VIDEO_REQUEST_GET_INFO = 0x86,
148 VIDEO_REQUEST_GET_DEF = 0x87,
149 VIDEO_REQUEST_GET_CUR_ALL = 0x91,
150 VIDEO_REQUEST_GET_MIN_ALL = 0x92,
151 VIDEO_REQUEST_GET_MAX_ALL = 0x93,
152 VIDEO_REQUEST_GET_RES_ALL = 0x94,
153 VIDEO_REQUEST_GET_DEF_ALL = 0x97
154} video_control_request_t;
155
156/* A.9.1 VideoControl Interface Control Selectors */
157typedef enum {
158 VIDEO_VC_CTL_UNDEFINED = 0x00,
159 VIDEO_VC_CTL_VIDEO_POWER_MODE,
160 VIDEO_VC_CTL_REQUEST_ERROR_CODE,
161} video_interface_control_selector_t;
162
163/* A.9.8 VideoStreaming Interface Control Selectors */
164typedef enum {
165 VIDEO_VS_CTL_UNDEFINED = 0x00,
166 VIDEO_VS_CTL_PROBE,
167 VIDEO_VS_CTL_COMMIT,
168 VIDEO_VS_CTL_STILL_PROBE,
169 VIDEO_VS_CTL_STILL_COMMIT,
170 VIDEO_VS_CTL_STILL_IMAGE_TRIGGER,
171 VIDEO_VS_CTL_STREAM_ERROR_CODE,
172 VIDEO_VS_CTL_GENERATE_KEY_FRAME,
173 VIDEO_VS_CTL_UPDATE_FRAME_SEGMENT,
174 VIDEO_VS_CTL_SYNCH_DELAY_CONTROL,
175} video_interface_streaming_selector_t;
176
177/* B. Terminal Types */
178typedef enum {
179 // Terminal
180 VIDEO_TT_VENDOR_SPECIFIC = 0x0100,
181 VIDEO_TT_STREAMING = 0x0101,
182
183 // Input
184 VIDEO_ITT_VENDOR_SPECIFIC = 0x0200,
185 VIDEO_ITT_CAMERA = 0x0201,
186 VIDEO_ITT_MEDIA_TRANSPORT_INPUT = 0x0202,
187
188 // Output
189 VIDEO_OTT_VENDOR_SPECIFIC = 0x0300,
190 VIDEO_OTT_DISPLAY = 0x0301,
191 VIDEO_OTT_MEDIA_TRANSPORT_OUTPUT = 0x0302,
192
193 // External
194 VIDEO_ETT_VENDOR_SPEIFIC = 0x0400,
195 VIDEO_ETT_COMPOSITE_CONNECTOR = 0x0401,
196 VIDEO_ETT_SVIDEO_CONNECTOR = 0x0402,
197 VIDEO_ETT_COMPONENT_CONNECTOR = 0x0403,
198} video_terminal_type_t;
199
200//--------------------------------------------------------------------+
201// Descriptors
202//--------------------------------------------------------------------+
203
204/* 2.3.4.2 */
205typedef struct TU_ATTR_PACKED {
206 uint8_t bLength;
207 uint8_t bDescriptorType;
208 uint8_t bDescriptorSubType;
209 uint16_t bcdUVC;
210 uint16_t wTotalLength;
211 uint32_t dwClockFrequency;
212 uint8_t bInCollection;
213 uint8_t baInterfaceNr[];
215
216/* 2.4.3.3 */
217typedef struct TU_ATTR_PACKED {
218 uint8_t bHeaderLength;
219 union {
220 uint8_t bmHeaderInfo;
221 struct {
222 uint8_t FrameID: 1;
223 uint8_t EndOfFrame: 1;
224 uint8_t PresentationTime: 1;
225 uint8_t SourceClockReference: 1;
226 uint8_t PayloadSpecific: 1;
227 uint8_t StillImage: 1;
228 uint8_t Error: 1;
229 uint8_t EndOfHeader: 1;
230 };
231 };
233
234/* 3.9.2.1 */
235typedef struct TU_ATTR_PACKED {
236 uint8_t bLength;
237 uint8_t bDescriptorType;
238 uint8_t bDescriptorSubType;
239 uint8_t bNumFormats;
240 uint16_t wTotalLength;
241 uint8_t bEndpointAddress;
242 uint8_t bmInfo;
243 uint8_t bTerminalLink;
244 uint8_t bStillCaptureMethod;
245 uint8_t bTriggerSupport;
246 uint8_t bTriggerUsage;
247 uint8_t bControlSize;
248 uint8_t bmaControls[];
250
251/* 3.9.2.2 */
252typedef struct TU_ATTR_PACKED {
253 uint8_t bLength;
254 uint8_t bDescriptorType;
255 uint8_t bDescriptorSubType;
256 uint8_t bNumFormats;
257 uint16_t wTotalLength;
258 uint8_t bEndpointAddress;
259 uint8_t bTerminalLink;
260 uint8_t bControlSize;
261 uint8_t bmaControls[];
263
264typedef struct TU_ATTR_PACKED {
265 uint8_t bLength;
266 uint8_t bDescriptorType;
267 uint8_t bDescriptorSubType;
268 uint8_t bNumFormats;
269 uint16_t wTotalLength;
270 uint8_t bEndpointAddress;
271 union {
272 struct {
273 uint8_t bmInfo;
274 uint8_t bTerminalLink;
275 uint8_t bStillCaptureMethod;
276 uint8_t bTriggerSupport;
277 uint8_t bTriggerUsage;
278 uint8_t bControlSize;
279 uint8_t bmaControls[];
280 } input;
281 struct {
282 uint8_t bEndpointAddress;
283 uint8_t bTerminalLink;
284 uint8_t bControlSize;
285 uint8_t bmaControls[];
286 } output;
287 };
289
290typedef struct TU_ATTR_PACKED {
291 uint8_t bLength;
292 uint8_t bDescriptorType;
293 uint8_t bDescriptorSubType;
294 uint8_t bFormatIndex;
295 uint8_t bNumFrameDescriptors;
296 uint8_t guidFormat[16];
297 uint8_t bBitsPerPixel;
298 uint8_t bDefaultFrameIndex;
299 uint8_t bAspectRatioX;
300 uint8_t bAspectRatioY;
301 uint8_t bmInterlaceFlags;
302 uint8_t bCopyProtect;
304
305typedef struct TU_ATTR_PACKED {
306 uint8_t bLength;
307 uint8_t bDescriptorType;
308 uint8_t bDescriptorSubType;
309 uint8_t bFormatIndex;
310 uint8_t bNumFrameDescriptors;
311 uint8_t bmFlags;
312 uint8_t bDefaultFrameIndex;
313 uint8_t bAspectRatioX;
314 uint8_t bAspectRatioY;
315 uint8_t bmInterlaceFlags;
316 uint8_t bCopyProtect;
318
319typedef struct TU_ATTR_PACKED {
320 uint8_t bLength;
321 uint8_t bDescriptorType;
322 uint8_t bDescriptorSubType;
323 uint8_t bFormatIndex;
324 uint32_t dwMaxVideoFrameBufferSize; /* deprecated */
325 uint8_t bFormatType;
327
328typedef struct TU_ATTR_PACKED {
329 uint8_t bLength;
330 uint8_t bDescriptorType;
331 uint8_t bDescriptorSubType;
332 uint8_t bFormatIndex;
333 uint8_t bNumFrameDescriptors;
334 uint8_t guidFormat[16];
335 uint8_t bBitsPerPixel;
336 uint8_t bDefaultFrameIndex;
337 uint8_t bAspectRatioX;
338 uint8_t bAspectRatioY;
339 uint8_t bmInterlaceFlags;
340 uint8_t bCopyProtect;
341 uint8_t bVaribaleSize;
343
344typedef struct TU_ATTR_PACKED {
345 uint8_t bLength;
346 uint8_t bDescriptorType;
347 uint8_t bDescriptorSubType;
348 uint8_t bFrameIndex;
349 uint8_t bmCapabilities;
350 uint16_t wWidth;
351 uint16_t wHeight;
352 uint32_t dwMinBitRate;
353 uint32_t dwMaxBitRate;
354 uint32_t dwMaxVideoFrameBufferSize; /* deprecated */
355 uint32_t dwDefaultFrameInterval;
356 uint8_t bFrameIntervalType;
357 uint32_t dwFrameInterval[];
359
361
362typedef struct TU_ATTR_PACKED {
363 uint8_t bLength;
364 uint8_t bDescriptorType;
365 uint8_t bDescriptorSubType;
366 uint8_t bFrameIndex;
367 uint8_t bmCapabilities;
368 uint16_t wWidth;
369 uint16_t wHeight;
370 uint32_t dwMinBitRate;
371 uint32_t dwMaxBitRate;
372 uint32_t dwDefaultFrameInterval;
373 uint8_t bFrameIntervalType;
374 uint32_t dwBytesPerLine;
375 uint32_t dwFrameInterval[];
377
378//--------------------------------------------------------------------+
379// Requests
380//--------------------------------------------------------------------+
381
382/* 4.3.1.1 */
383typedef struct TU_ATTR_PACKED {
384 union {
385 uint8_t bmHint;
386 struct TU_ATTR_PACKED {
387 uint16_t dwFrameInterval: 1;
388 uint16_t wKeyFrameRatel : 1;
389 uint16_t wPFrameRate : 1;
390 uint16_t wCompQuality : 1;
391 uint16_t wCompWindowSize: 1;
392 uint16_t : 0;
393 } Hint;
394 };
395 uint8_t bFormatIndex;
396 uint8_t bFrameIndex;
397 uint32_t dwFrameInterval;
398 uint16_t wKeyFrameRate;
399 uint16_t wPFrameRate;
400 uint16_t wCompQuality;
401 uint16_t wCompWindowSize;
402 uint16_t wDelay;
403 uint32_t dwMaxVideoFrameSize;
404 uint32_t dwMaxPayloadTransferSize;
405 uint32_t dwClockFrequency;
406 union {
407 uint8_t bmFramingInfo;
408 struct TU_ATTR_PACKED {
409 uint8_t FrameID : 1;
410 uint8_t EndOfFrame: 1;
411 uint8_t EndOfSlice: 1;
412 uint8_t : 0;
413 } FramingInfo;
414 };
415 uint8_t bPreferedVersion;
416 uint8_t bMinVersion;
417 uint8_t bMaxVersion;
418 uint8_t bUsage;
419 uint8_t bBitDepthLuma;
420 uint8_t bmSettings;
421 uint8_t bMaxNumberOfRefFramesPlus1;
422 uint16_t bmRateControlModes;
423 uint64_t bmLayoutPerStream;
425
426TU_VERIFY_STATIC( sizeof(video_probe_and_commit_control_t) == 48, "size is not correct");
427
428#define TUD_VIDEO_DESC_IAD_LEN 8
429#define TUD_VIDEO_DESC_STD_VC_LEN 9
430#define TUD_VIDEO_DESC_CS_VC_LEN 12
431#define TUD_VIDEO_DESC_INPUT_TERM_LEN 8
432#define TUD_VIDEO_DESC_OUTPUT_TERM_LEN 9
433#define TUD_VIDEO_DESC_CAMERA_TERM_LEN 18
434#define TUD_VIDEO_DESC_STD_VS_LEN 9
435#define TUD_VIDEO_DESC_CS_VS_IN_LEN 13
436#define TUD_VIDEO_DESC_CS_VS_OUT_LEN 9
437#define TUD_VIDEO_DESC_CS_VS_FMT_UNCOMPR_LEN 27
438#define TUD_VIDEO_DESC_CS_VS_FMT_MJPEG_LEN 11
439#define TUD_VIDEO_DESC_CS_VS_FRM_UNCOMPR_CONT_LEN 38
440#define TUD_VIDEO_DESC_CS_VS_FRM_UNCOMPR_DISC_LEN 26
441#define TUD_VIDEO_DESC_CS_VS_FRM_MJPEG_CONT_LEN 38
442#define TUD_VIDEO_DESC_CS_VS_FRM_MJPEG_DISC_LEN 26
443#define TUD_VIDEO_DESC_CS_VS_COLOR_MATCHING_LEN 6
444
445/* 2.2 compression formats */
446#define TUD_VIDEO_GUID_YUY2 0x59,0x55,0x59,0x32,0x00,0x00,0x10,0x00,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71
447#define TUD_VIDEO_GUID_NV12 0x4E,0x56,0x31,0x32,0x00,0x00,0x10,0x00,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71
448#define TUD_VIDEO_GUID_M420 0x4D,0x34,0x32,0x30,0x00,0x00,0x10,0x00,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71
449#define TUD_VIDEO_GUID_I420 0x49,0x34,0x32,0x30,0x00,0x00,0x10,0x00,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71
450
451#define TUD_VIDEO_DESC_IAD(_firstitf, _nitfs, _stridx) \
452 TUD_VIDEO_DESC_IAD_LEN, TUSB_DESC_INTERFACE_ASSOCIATION, \
453 _firstitf, _nitfs, TUSB_CLASS_VIDEO, VIDEO_SUBCLASS_INTERFACE_COLLECTION, \
454 VIDEO_ITF_PROTOCOL_UNDEFINED, _stridx
455
456#define TUD_VIDEO_DESC_STD_VC(_itfnum, _nEPs, _stridx) \
457 TUD_VIDEO_DESC_STD_VC_LEN, TUSB_DESC_INTERFACE, _itfnum, /* fixed to zero */ 0x00, \
458 _nEPs, TUSB_CLASS_VIDEO, VIDEO_SUBCLASS_CONTROL, VIDEO_ITF_PROTOCOL_15, _stridx
459
460/* 3.7.2 */
461#define TUD_VIDEO_DESC_CS_VC(_bcdUVC, _totallen, _clkfreq, ...) \
462 TUD_VIDEO_DESC_CS_VC_LEN + (TU_ARGS_NUM(__VA_ARGS__)), TUSB_DESC_CS_INTERFACE, VIDEO_CS_ITF_VC_HEADER, \
463 U16_TO_U8S_LE(_bcdUVC), U16_TO_U8S_LE((_totallen) + TUD_VIDEO_DESC_CS_VC_LEN + (TU_ARGS_NUM(__VA_ARGS__))), \
464 U32_TO_U8S_LE(_clkfreq), TU_ARGS_NUM(__VA_ARGS__), __VA_ARGS__
465
466/* 3.7.2.1 */
467#define TUD_VIDEO_DESC_INPUT_TERM(_tid, _tt, _at, _stridx) \
468 TUD_VIDEO_DESC_INPUT_TERM_LEN, TUSB_DESC_CS_INTERFACE, VIDEO_CS_ITF_VC_INPUT_TERMINAL, \
469 _tid, U16_TO_U8S_LE(_tt), _at, _stridx
470
471/* 3.7.2.2 */
472#define TUD_VIDEO_DESC_OUTPUT_TERM(_tid, _tt, _at, _srcid, _stridx) \
473 TUD_VIDEO_DESC_OUTPUT_TERM_LEN, TUSB_DESC_CS_INTERFACE, VIDEO_CS_ITF_VC_OUTPUT_TERMINAL, \
474 _tid, U16_TO_U8S_LE(_tt), _at, _srcid, _stridx
475
476/* 3.7.2.3 */
477#define TUD_VIDEO_DESC_CAMERA_TERM(_tid, _at, _stridx, _focal_min, _focal_max, _focal, _ctls) \
478 TUD_VIDEO_DESC_CAMERA_TERM_LEN, TUSB_DESC_CS_INTERFACE, VIDEO_CS_ITF_VC_INPUT_TERMINAL, \
479 _tid, U16_TO_U8S_LE(VIDEO_ITT_CAMERA), _at, _stridx, \
480 U16_TO_U8S_LE(_focal_min), U16_TO_U8S_LE(_focal_max), U16_TO_U8S_LE(_focal), 3, \
481 TU_U32_BYTE0(_ctls), TU_U32_BYTE1(_ctls), TU_U32_BYTE2(_ctls)
482
483/* 3.9.1 */
484#define TUD_VIDEO_DESC_STD_VS(_itfnum, _alt, _epn, _stridx) \
485 TUD_VIDEO_DESC_STD_VS_LEN, TUSB_DESC_INTERFACE, _itfnum, _alt, \
486 _epn, TUSB_CLASS_VIDEO, VIDEO_SUBCLASS_STREAMING, VIDEO_ITF_PROTOCOL_15, _stridx
487
488/* 3.9.2.1 */
489#define TUD_VIDEO_DESC_CS_VS_INPUT(_numfmt, _totallen, _ep, _inf, _termlnk, _sticaptmeth, _trgspt, _trgusg, ...) \
490 TUD_VIDEO_DESC_CS_VS_IN_LEN + (_numfmt) * (TU_ARGS_NUM(__VA_ARGS__)), TUSB_DESC_CS_INTERFACE, \
491 VIDEO_CS_ITF_VS_INPUT_HEADER, _numfmt, \
492 U16_TO_U8S_LE((_totallen) + TUD_VIDEO_DESC_CS_VS_IN_LEN + (_numfmt) * (TU_ARGS_NUM(__VA_ARGS__))), \
493 _ep, _inf, _termlnk, _sticaptmeth, _trgspt, _trgusg, (TU_ARGS_NUM(__VA_ARGS__)), __VA_ARGS__
494
495/* 3.9.2.2 */
496#define TUD_VIDEO_DESC_CS_VS_OUTPUT(_numfmt, _totallen, _ep, _inf, _termlnk, ...) \
497 TUD_VIDEO_DESC_CS_VS_OUT_LEN + (_numfmt) * (TU_ARGS_NUM(__VA_ARGS__)), TUSB_DESC_CS_INTERFACE, \
498 VIDEO_CS_ITF_VS_OUTPUT_HEADER, _numfmt, \
499 U16_TO_U8S_LE((_totallen) + TUD_VIDEO_DESC_CS_VS_OUT_LEN + (_numfmt) * (TU_ARGS_NUM(__VA_ARGS__))), \
500 _ep, _inf, _termlnk, (TU_ARGS_NUM(__VA_ARGS__)), __VA_ARGS__
501
502/* Uncompressed 3.1.1 */
503#define TUD_VIDEO_GUID(_g0,_g1,_g2,_g3,_g4,_g5,_g6,_g7,_g8,_g9,_g10,_g11,_g12,_g13,_g14,_g15) _g0,_g1,_g2,_g3,_g4,_g5,_g6,_g7,_g8,_g9,_g10,_g11,_g12,_g13,_g14,_g15
504
505#define TUD_VIDEO_DESC_CS_VS_FMT_UNCOMPR(_fmtidx, _numfrmdesc, \
506 _guid, _bitsperpix, _frmidx, _asrx, _asry, _interlace, _cp) \
507 TUD_VIDEO_DESC_CS_VS_FMT_UNCOMPR_LEN, TUSB_DESC_CS_INTERFACE, VIDEO_CS_ITF_VS_FORMAT_UNCOMPRESSED, \
508 _fmtidx, _numfrmdesc, TUD_VIDEO_GUID(_guid), \
509 _bitsperpix, _frmidx, _asrx, _asry, _interlace, _cp
510
511/* Uncompressed 3.1.2 Table 3-3 */
512#define TUD_VIDEO_DESC_CS_VS_FRM_UNCOMPR_CONT(_frmidx, _cap, _width, _height, _minbr, _maxbr, _maxfrmbufsz, _frminterval, _minfrminterval, _maxfrminterval, _frmintervalstep) \
513 TUD_VIDEO_DESC_CS_VS_FRM_UNCOMPR_CONT_LEN, TUSB_DESC_CS_INTERFACE, VIDEO_CS_ITF_VS_FRAME_UNCOMPRESSED, \
514 _frmidx, _cap, U16_TO_U8S_LE(_width), U16_TO_U8S_LE(_height), U32_TO_U8S_LE(_minbr), U32_TO_U8S_LE(_maxbr), \
515 U32_TO_U8S_LE(_maxfrmbufsz), U32_TO_U8S_LE(_frminterval), 0, \
516 U32_TO_U8S_LE(_minfrminterval), U32_TO_U8S_LE(_maxfrminterval), U32_TO_U8S_LE(_frmintervalstep)
517
518/* Uncompressed 3.1.2 Table 3-4 */
519#define TUD_VIDEO_DESC_CS_VS_FRM_UNCOMPR_DISC(_frmidx, _cap, _width, _height, _minbr, _maxbr, _maxfrmbufsz, _frminterval, ...) \
520 TUD_VIDEO_DESC_CS_VS_FRM_UNCOMPR_DISC_LEN + (TU_ARGS_NUM(__VA_ARGS__)) * 4, \
521 TUSB_DESC_CS_INTERFACE, VIDEO_CS_ITF_VS_FRAME_UNCOMPRESSED, \
522 _frmidx, _cap, U16_TO_U8S_LE(_width), U16_TO_U8S_LE(_height), U32_TO_U8S_LE(_minbr), U32_TO_U8S_LE(_maxbr), \
523 U32_TO_U8S_LE(_maxfrmbufsz), U32_TO_U8S_LE(_frminterval), (TU_ARGS_NUM(__VA_ARGS__)), __VA_ARGS__
524
525/* Motion-JPEG 3.1.1 Table 3-1 */
526#define TUD_VIDEO_DESC_CS_VS_FMT_MJPEG(_fmtidx, _numfrmdesc, _fixed_sz, _frmidx, _asrx, _asry, _interlace, _cp) \
527 TUD_VIDEO_DESC_CS_VS_FMT_MJPEG_LEN, TUSB_DESC_CS_INTERFACE, VIDEO_CS_ITF_VS_FORMAT_MJPEG, \
528 _fmtidx, _numfrmdesc, _fixed_sz, _frmidx, _asrx, _asry, _interlace, _cp
529
530/* Motion-JPEG 3.1.1 Table 3-2 and 3-3 */
531#define TUD_VIDEO_DESC_CS_VS_FRM_MJPEG_CONT(_frmidx, _cap, _width, _height, _minbr, _maxbr, _maxfrmbufsz, _frminterval, _minfrminterval, _maxfrminterval, _frmintervalstep) \
532 TUD_VIDEO_DESC_CS_VS_FRM_MJPEG_CONT_LEN, TUSB_DESC_CS_INTERFACE, VIDEO_CS_ITF_VS_FRAME_MJPEG, \
533 _frmidx, _cap, U16_TO_U8S_LE(_width), U16_TO_U8S_LE(_height), U32_TO_U8S_LE(_minbr), U32_TO_U8S_LE(_maxbr), \
534 U32_TO_U8S_LE(_maxfrmbufsz), U32_TO_U8S_LE(_frminterval), 0, \
535 U32_TO_U8S_LE(_minfrminterval), U32_TO_U8S_LE(_maxfrminterval), U32_TO_U8S_LE(_frmintervalstep)
536
537/* Motion-JPEG 3.1.1 Table 3-2 and 3-4 */
538#define TUD_VIDEO_DESC_CS_VS_FRM_MJPEG_DISC(_frmidx, _cap, _width, _height, _minbr, _maxbr, _maxfrmbufsz, _frminterval, ...) \
539 TUD_VIDEO_DESC_CS_VS_FRM_MJPEG_DISC_LEN + (TU_ARGS_NUM(__VA_ARGS__)) * 4, \
540 TUSB_DESC_CS_INTERFACE, VIDEO_CS_VS_INTERFACE_FRAME_MJPEG, \
541 _frmidx, _cap, U16_TO_U8S_LE(_width), U16_TO_U8S_LE(_height), U32_TO_U8S_LE(_minbr), U32_TO_U8S_LE(_maxbr), \
542 U32_TO_U8S_LE(_maxfrmbufsz), U32_TO_U8S_LE(_frminterval), (TU_ARGS_NUM(__VA_ARGS__)), __VA_ARGS__
543
544/* 3.9.2.6 */
545#define TUD_VIDEO_DESC_CS_VS_COLOR_MATCHING(_color, _trns, _mat) \
546 TUD_VIDEO_DESC_CS_VS_COLOR_MATCHING_LEN, \
547 TUSB_DESC_CS_INTERFACE, VIDEO_CS_ITF_VS_COLORFORMAT, \
548 _color, _trns, _mat
549
550/* 3.10.1.1 */
551#define TUD_VIDEO_DESC_EP_ISO(_ep, _epsize, _ep_interval) \
552 7, TUSB_DESC_ENDPOINT, _ep, (uint8_t) (TUSB_XFER_ISOCHRONOUS | TUSB_ISO_EP_ATT_ASYNCHRONOUS),\
553 U16_TO_U8S_LE(_epsize), _ep_interval
554
555/* 3.10.1.2 */
556#define TUD_VIDEO_DESC_EP_BULK(_ep, _epsize, _ep_interval) \
557 7, TUSB_DESC_ENDPOINT, _ep, TUSB_XFER_BULK, U16_TO_U8S_LE(_epsize), _ep_interval
558
559#endif
uint8_t bDescriptorSubType
Descriptor SubType. Value: AUDIO_CS_AC_INTERFACE_HEADER.
Definition audio.h:658
uint8_t bDescriptorType
Descriptor Type. Value: TUSB_DESC_CS_INTERFACE.
Definition audio.h:657
uint8_t bLength
Size of this descriptor in bytes: 9.
Definition audio.h:656
AUDIO Channel Cluster Descriptor (4.1)
Definition audio.h:647
uint16_t wTotalLength
Total number of bytes returned for the class-specific AudioControl interface descriptor....
Definition audio.h:661
uint8_t bTerminalLink
The Terminal ID of the Terminal to which this interface is connected.
Definition audio.h:784
uint8_t bFormatType
Constant identifying the Format Type the AudioStreaming interface is using. See: audio_format_type_t.
Definition audio.h:786