1 | /*
|
---|
2 | * Copyright 2016, Adrien Destugues, pulkomandy@pulkomandy.tk
|
---|
3 | * Distributed under terms of the MIT license.
|
---|
4 | */
|
---|
5 |
|
---|
6 |
|
---|
7 | #ifndef USB_VIDEO_H
|
---|
8 | #define USB_VIDEO_H
|
---|
9 |
|
---|
10 |
|
---|
11 | // Based on specification for UVC version 1.5.
|
---|
12 |
|
---|
13 |
|
---|
14 | #include <BeBuild.h> // for _PACKED definition
|
---|
15 | #include <lendian_bitfield.h>
|
---|
16 | #include <SupportDefs.h>
|
---|
17 |
|
---|
18 |
|
---|
19 | enum { // Video Interface Class Code
|
---|
20 | USB_VIDEO_INTERFACE_VIDEO_CLASS = 0x0e
|
---|
21 | };
|
---|
22 |
|
---|
23 |
|
---|
24 | enum { // Video Interface Subclasses
|
---|
25 | USB_VIDEO_INTERFACE_UNDEFINED_SUBCLASS = 0x00,
|
---|
26 | USB_VIDEO_INTERFACE_VIDEOCONTROL_SUBCLASS = 0x01,
|
---|
27 | USB_VIDEO_INTERFACE_VIDEOSTREAMING_SUBCLASS = 0x02,
|
---|
28 | USB_VIDEO_INTERFACE_COLLECTION_SUBCLASS = 0x03,
|
---|
29 | };
|
---|
30 |
|
---|
31 |
|
---|
32 | enum { // Video Interface Protocol Codes
|
---|
33 | USB_VIDEO_PROTOCOL_UNDEFINED = 0x00,
|
---|
34 | USB_VIDEO_PROTOCOL_15 = 0x01,
|
---|
35 | };
|
---|
36 |
|
---|
37 |
|
---|
38 | enum { // Video Interface Class-Specific Descriptor Types
|
---|
39 | USB_VIDEO_CS_UNDEFINED = 0x20,
|
---|
40 | USB_VIDEO_CS_DEVICE = 0x21,
|
---|
41 | USB_VIDEO_CS_CONFIGURATION = 0x22,
|
---|
42 | USB_VIDEO_CS_STRING = 0x23,
|
---|
43 | USB_VIDEO_CS_INTERFACE = 0x24,
|
---|
44 | USB_VIDEO_CS_ENDPOINT = 0x25,
|
---|
45 | };
|
---|
46 |
|
---|
47 |
|
---|
48 | enum { // Video Class-Specific VideoControl Interface descriptor subtypes
|
---|
49 | USB_VIDEO_VC_DESCRIPTOR_UNDEFINED = 0x00,
|
---|
50 | USB_VIDEO_VC_HEADER = 0x01,
|
---|
51 | USB_VIDEO_VC_INPUT_TERMINAL = 0x02,
|
---|
52 | USB_VIDEO_VC_OUTPUT_TERMINAL = 0x03,
|
---|
53 | USB_VIDEO_VC_SELECTOR_UNIT = 0x04,
|
---|
54 | USB_VIDEO_VC_PROCESSING_UNIT = 0x05,
|
---|
55 | USB_VIDEO_VC_EXTENSION_UNIT = 0x06,
|
---|
56 | USB_VIDEO_VC_ENCODING_UNIT = 0x07,
|
---|
57 | };
|
---|
58 |
|
---|
59 |
|
---|
60 | enum { // Video Class-Specific VideoStreaming Interface descriptor subtypes
|
---|
61 | USB_VIDEO_VS_UNDEFINED = 0x00,
|
---|
62 | USB_VIDEO_VS_INPUT_HEADER = 0x01,
|
---|
63 | USB_VIDEO_VS_OUTPUT_HEADER = 0x02,
|
---|
64 | USB_VIDEO_VS_STILL_IMAGE_FRAME = 0x03,
|
---|
65 | USB_VIDEO_VS_FORMAT_UNCOMPRESSED = 0x04,
|
---|
66 | USB_VIDEO_VS_FRAME_UNCOMPRESSED = 0x05,
|
---|
67 | USB_VIDEO_VS_FORMAT_MJPEG = 0x06,
|
---|
68 | USB_VIDEO_VS_FRAME_MJPEG = 0x07,
|
---|
69 | USB_VIDEO_VS_FORMAT_MPEG2TS = 0x0a,
|
---|
70 | USB_VIDEO_VS_FORMAT_DV = 0x0c,
|
---|
71 | USB_VIDEO_VS_COLORFORMAT = 0x0d,
|
---|
72 | USB_VIDEO_VS_FORMAT_FRAME_BASED = 0x10,
|
---|
73 | USB_VIDEO_VS_FRAME_FRAME_BASED = 0x11,
|
---|
74 | USB_VIDEO_VS_FORMAT_STREAM_BASED = 0x12,
|
---|
75 | USB_VIDEO_VS_FORMAT_H264 = 0x13,
|
---|
76 | USB_VIDEO_VS_FRAME_H264 = 0x14,
|
---|
77 | USB_VIDEO_VS_FORMAT_H264_SIMULCAST = 0x15,
|
---|
78 | USB_VIDEO_VS_FORMAT_VP8 = 0x16,
|
---|
79 | USB_VIDEO_VS_FRAME_VP8 = 0x17,
|
---|
80 | USB_VIDEO_VS_FORMAT_VP8_SIMULCAST = 0x18,
|
---|
81 | };
|
---|
82 |
|
---|
83 |
|
---|
84 | enum { // Video Streaming Interface Control Selectors
|
---|
85 | USB_VIDEO_VS_CONTROL_UNDEFINED = 0x00,
|
---|
86 | USB_VIDEO_VS_PROBE_CONTROL = 0x01,
|
---|
87 | USB_VIDEO_VS_COMMIT_CONTROL = 0x02,
|
---|
88 | USB_VIDEO_VS_STILL_PROBE_CONTROL = 0x03,
|
---|
89 | USB_VIDEO_VS_STILL_COMMIT_CONTROL = 0x04,
|
---|
90 | USB_VIDEO_VS_STILL_IMAGE_TRIGGER_CONTROL = 0x05,
|
---|
91 | USB_VIDEO_VS_STREAM_ERROR_CODE_CONTROL = 0x06,
|
---|
92 | USB_VIDEO_VS_GENERATE_KEY_FRAME_CONTROL = 0x07,
|
---|
93 | USB_VIDEO_VS_UPDATE_FRAME_SEGMENT_CONTROL = 0x08,
|
---|
94 | USB_VIDEO_VS_SYNCH_DELAY_CONTROL = 0x09
|
---|
95 | };
|
---|
96 |
|
---|
97 |
|
---|
98 | enum {
|
---|
99 | // USB Terminal Types
|
---|
100 | USB_VIDEO_VENDOR_USB_IO = 0x100,
|
---|
101 | USB_VIDEO_STREAMING_USB_IO = 0x101,
|
---|
102 | // Input terminal types
|
---|
103 | USB_VIDEO_VENDOR_IN = 0x200,
|
---|
104 | USB_VIDEO_CAMERA_IN = 0x201,
|
---|
105 | USB_VIDEO_MEDIA_TRANSPORT_IN = 0x202,
|
---|
106 | // Output terminal types
|
---|
107 | USB_VIDEO_VENDOR_OUT = 0x300,
|
---|
108 | USB_VIDEO_DISPLAY_OUT = 0x301,
|
---|
109 | USB_VIDEO_MEDIA_TRANSPORT_OUT = 0x302,
|
---|
110 | // External terminal types
|
---|
111 | USB_VIDEO_VENDOR_EXT = 0x400,
|
---|
112 | USB_VIDEO_COMPOSITE_EXT = 0x401,
|
---|
113 | USB_VIDEO_SVIDEO_EXT = 0x402,
|
---|
114 | USB_VIDEO_COMPONENT_EXT = 0x403,
|
---|
115 | };
|
---|
116 |
|
---|
117 |
|
---|
118 | enum { // Video Class-Specific Endpoint Descriptor Subtypes
|
---|
119 | EP_SUBTYPE_UNDEFINED = 0x00,
|
---|
120 | EP_SUBTYPE_GENERAL = 0x01,
|
---|
121 | EP_SUBTYPE_ENDPOINT = 0x02,
|
---|
122 | EP_SUBTYPE_INTERRUPT = 0x03,
|
---|
123 | };
|
---|
124 |
|
---|
125 |
|
---|
126 | enum { // Terminal Control Selectors
|
---|
127 | USB_VIDEO_TE_CONTROL_UNDEFINED = 0x00
|
---|
128 | };
|
---|
129 |
|
---|
130 |
|
---|
131 | enum { // Selector Unit Control Selectors
|
---|
132 | USB_VIDEO_SU_CONTROL_UNDEFINED = 0x00,
|
---|
133 | USB_VIDEO_SU_INPUT_SELECT_CONTROL = 0x01
|
---|
134 | };
|
---|
135 |
|
---|
136 |
|
---|
137 | enum { // Video Class-Specific Request Codes
|
---|
138 | USB_VIDEO_RC_UNDEFINED = 0x00,
|
---|
139 | USB_VIDEO_RC_SET_CUR = 0x01,
|
---|
140 | USB_VIDEO_RC_GET_CUR = 0x81,
|
---|
141 | USB_VIDEO_RC_GET_MIN = 0x82,
|
---|
142 | USB_VIDEO_RC_GET_MAX = 0x83,
|
---|
143 | USB_VIDEO_RC_GET_RES = 0x84,
|
---|
144 | USB_VIDEO_RC_GET_LEN = 0x85,
|
---|
145 | USB_VIDEO_RC_GET_INFO = 0x86,
|
---|
146 | USB_VIDEO_RC_GET_DEF = 0x87
|
---|
147 | };
|
---|
148 |
|
---|
149 |
|
---|
150 | enum { // Camera Terminal Control Selectors
|
---|
151 | USB_VIDEO_CT_CONTROL_UNDEFINED = 0x00,
|
---|
152 | USB_VIDEO_CT_SCANNING_MODE_CONTROL = 0x01,
|
---|
153 | USB_VIDEO_CT_AE_MODE_CONTROL = 0x02,
|
---|
154 | USB_VIDEO_CT_AE_PRIORITY_CONTROL = 0x03,
|
---|
155 | USB_VIDEO_CT_EXPOSURE_TIME_ABSOLUTE_CONTROL = 0x04,
|
---|
156 | USB_VIDEO_CT_EXPOSURE_TIME_RELATIVE_CONTROL = 0x05,
|
---|
157 | USB_VIDEO_CT_FOCUS_ABSOLUTE_CONTROL = 0x06,
|
---|
158 | USB_VIDEO_CT_FOCUS_RELATIVE_CONTROL = 0x07,
|
---|
159 | USB_VIDEO_CT_FOCUS_AUTO_CONTROL = 0x08,
|
---|
160 | USB_VIDEO_CT_IRIS_ABSOLUTE_CONTROL = 0x09,
|
---|
161 | USB_VIDEO_CT_IRIS_RELATIVE_CONTROL = 0x0A,
|
---|
162 | USB_VIDEO_CT_ZOOM_ABSOLUTE_CONTROL = 0x0B,
|
---|
163 | USB_VIDEO_CT_ZOOM_RELATIVE_CONTROL = 0x0C,
|
---|
164 | USB_VIDEO_CT_PANTILT_ABSOLUTE_CONTROL = 0x0D,
|
---|
165 | USB_VIDEO_CT_PANTILT_RELATIVE_CONTROL = 0x0E,
|
---|
166 | USB_VIDEO_CT_ROLL_ABSOLUTE_CONTROL = 0x0F,
|
---|
167 | USB_VIDEO_CT_ROLL_RELATIVE_CONTROL = 0x10,
|
---|
168 | USB_VIDEO_CT_PRIVACY_CONTROL = 0x11
|
---|
169 | };
|
---|
170 |
|
---|
171 |
|
---|
172 | enum { // Processing Unit Control Selectors
|
---|
173 | USB_VIDEO_PU_CONTROL_UNDEFINED = 0x00,
|
---|
174 | USB_VIDEO_PU_BACKLIGHT_COMPENSATION_CONTROL = 0x01,
|
---|
175 | USB_VIDEO_PU_BRIGHTNESS_CONTROL = 0x02,
|
---|
176 | USB_VIDEO_PU_CONTRAST_CONTROL = 0x03,
|
---|
177 | USB_VIDEO_PU_GAIN_CONTROL = 0x04,
|
---|
178 | USB_VIDEO_PU_POWER_LINE_FREQUENCY_CONTROL = 0x05,
|
---|
179 | USB_VIDEO_PU_HUE_CONTROL = 0x06,
|
---|
180 | USB_VIDEO_PU_SATURATION_CONTROL = 0x07,
|
---|
181 | USB_VIDEO_PU_SHARPNESS_CONTROL = 0x08,
|
---|
182 | USB_VIDEO_PU_GAMMA_CONTROL = 0x09,
|
---|
183 | USB_VIDEO_PU_WHITE_BALANCE_TEMPERATURE_CONTROL = 0x0A,
|
---|
184 | USB_VIDEO_PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL = 0x0B,
|
---|
185 | USB_VIDEO_PU_WHITE_BALANCE_TEMPERATURE_COMPONENT_CONTROL = 0x0C,
|
---|
186 | USB_VIDEO_PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL = 0x0D,
|
---|
187 | USB_VIDEO_PU_DIGITAL_MULTIPLEXER_CONTROL = 0x0E,
|
---|
188 | USB_VIDEO_PU_DIGITAL_MULTIPLEXER_LIMIT_CONTROL = 0x0F,
|
---|
189 | USB_VIDEO_PU_HUE_AUTO_CONTROL = 0x10,
|
---|
190 | USB_VIDEO_PU_ANALOG_VIDEO_STANDARD_CONTROL = 0x11,
|
---|
191 | USB_VIDEO_PU_ANALOG_LOCK_STATUS_CONTROL = 0x12
|
---|
192 | };
|
---|
193 |
|
---|
194 |
|
---|
195 | enum { // Extension Unit Control Selectors
|
---|
196 | USB_VIDEO_XU_CONTROL_UNDEFINED = 0x00
|
---|
197 | };
|
---|
198 |
|
---|
199 |
|
---|
200 | /*!
|
---|
201 | Struct status_packet_format includes two common fields and other fields
|
---|
202 | that depend on the type of the originator field of the first status_type
|
---|
203 | struct. The orignator bitfield of the status_type struct can have the
|
---|
204 | following values: 0 = reserved, 1 = VideoControl interface,
|
---|
205 | 2 = VideoStreaming interface. The second common status_packet_format field
|
---|
206 | orignator includes ID of the Terminal, Unit or Interface that reports the
|
---|
207 | interrupt.
|
---|
208 | If the orginator bitfield value is 1 (VideoControl interface) then third
|
---|
209 | field of the status_packet_format is event field that includes value 0x00
|
---|
210 | for control change. Other values (0x01 - 0xFF) are reserved.
|
---|
211 | The fourth field selector reports the Control Selector of the control that
|
---|
212 | have issued the interrupt.
|
---|
213 | The fifth field attribute specifies the type of control change: 0x00 is
|
---|
214 | Control value change, 0x01 is Control info change, 0x02 is Control failure
|
---|
215 | change and values 0x03 - 0xFF are reserved.
|
---|
216 | After that can be several value fields that can include values 0x00, 0x01
|
---|
217 | and 0x02.
|
---|
218 | If the originator bitfield value is 2 (VideoStreaming interface) then
|
---|
219 | third field of the status_packet_format is event field that can have
|
---|
220 | value 0x00 (Button Press) or values 0x01 - 0xFF (Stream errors).
|
---|
221 | If event value is 0x00 (Button Press) there is only one value field. It
|
---|
222 | can include values 0x00 (Button released) or 0x01 (Button pressed). If
|
---|
223 | event value was some Stream error value, then there can be several value
|
---|
224 | fields.
|
---|
225 | */
|
---|
226 |
|
---|
227 |
|
---|
228 | typedef struct {
|
---|
229 | struct status_type {
|
---|
230 | LBITFIELD8_2 (
|
---|
231 | originator: 4,
|
---|
232 | reserved: 4
|
---|
233 | );
|
---|
234 | } status_type;
|
---|
235 | uint8 originator;
|
---|
236 | union {
|
---|
237 | struct videocontrol_interface_as_orignator {
|
---|
238 | uint8 event;
|
---|
239 | uint8 selector;
|
---|
240 | uint8 attribute;
|
---|
241 | uint8* value;
|
---|
242 | } videocontrol_interface_as_orignator;
|
---|
243 | struct videostreaming_interface_as_originator {
|
---|
244 | uint8 event;
|
---|
245 | uint8* value;
|
---|
246 | } videostreaming_interface_as_originator;
|
---|
247 | } originators;
|
---|
248 | } _PACKED usb_video_status_packet_format;
|
---|
249 |
|
---|
250 |
|
---|
251 | typedef struct std_vc_interface_descriptor {
|
---|
252 | uint8 length; // 9 bytes
|
---|
253 | uint8 descriptor_type;
|
---|
254 | uint8 interface_number;
|
---|
255 | uint8 alternate_setting;
|
---|
256 | uint8 num_endpoints;
|
---|
257 | uint8 interface_class;
|
---|
258 | uint8 interface_sub_class;
|
---|
259 | uint8 interface_protocol;
|
---|
260 | // Not used. Must be set to USB_VIDEO_PC_PROTOCOL_UNDEFINED
|
---|
261 | uint8 interface;
|
---|
262 | } _PACKED usb_video_standard_vc_interface_descriptor;
|
---|
263 |
|
---|
264 |
|
---|
265 | typedef struct std_video_interface_collection_iad {
|
---|
266 | uint8 length; // 8 bytes
|
---|
267 | uint8 descriptor_type;
|
---|
268 | uint8 first_interface;
|
---|
269 | uint8 interface_count;
|
---|
270 | uint8 function_class;
|
---|
271 | uint8 function_sub_class;
|
---|
272 | uint8 function_protocol;
|
---|
273 | // Not used. Must be set to USB_VIDEO_PC_PROTOCOL_UNDEFINED
|
---|
274 | uint8 function;
|
---|
275 | } _PACKED usb_video_standard_video_interface_collection_iad;
|
---|
276 |
|
---|
277 |
|
---|
278 | typedef struct selector_unit_descriptor {
|
---|
279 | uint8 length; // 6 bytes + nr_in_pins
|
---|
280 | uint8 descriptor_type;
|
---|
281 | uint8 descriptor_sub_type;
|
---|
282 | uint8 unit_id;
|
---|
283 | uint8 nr_in_pins;
|
---|
284 | uint8* source_id;
|
---|
285 | uint8 selector;
|
---|
286 | } _PACKED usb_video_selector_unit_descriptor;
|
---|
287 |
|
---|
288 |
|
---|
289 | typedef struct payload_header_format {
|
---|
290 | uint8 header_length;
|
---|
291 | struct header_info {
|
---|
292 | LBITFIELD8_8 (
|
---|
293 | frame_id: 1,
|
---|
294 | end_of_frame: 1,
|
---|
295 | presentation_time: 1,
|
---|
296 | source_clock_reference: 1,
|
---|
297 | reserved: 1,
|
---|
298 | still_image: 1,
|
---|
299 | error: 1,
|
---|
300 | end_of_header: 1
|
---|
301 | );
|
---|
302 | } _header_info;
|
---|
303 | } _PACKED usb_video_payload_header_format;
|
---|
304 |
|
---|
305 |
|
---|
306 | struct payload_header_format_extended_fields {
|
---|
307 | uint32 presentation_time;
|
---|
308 | uint8 source_clock[6];
|
---|
309 | } _PACKED usb_video_payload_header_format_extended_fields;
|
---|
310 |
|
---|
311 |
|
---|
312 | typedef struct {
|
---|
313 | uint8 length;
|
---|
314 | uint8 descriptor_type; // USB_AUDIO_CS_INTERFACE
|
---|
315 | uint8 descriptor_subtype; // USB_AUDIO_AC_HEADER
|
---|
316 | uint16 bcd_release_no;
|
---|
317 | uint16 total_length;
|
---|
318 | uint32 clock_frequency;
|
---|
319 | uint8 in_collection;
|
---|
320 | uint8 interface_numbers[0];
|
---|
321 | } _PACKED usb_videocontrol_header_descriptor;
|
---|
322 |
|
---|
323 |
|
---|
324 | typedef struct extension_unit_descriptor {
|
---|
325 | uint8 length; // 24 bytes + nr_in_pins + control_size
|
---|
326 | uint8 descriptor_type;
|
---|
327 | uint8 descriptor_sub_type;
|
---|
328 | uint8 unit_id;
|
---|
329 | uint8 guid_extension_code[16];
|
---|
330 | uint8 num_controls;
|
---|
331 | uint8 nr_in_pins;
|
---|
332 | uint8* source_id;
|
---|
333 | uint8 control_size;
|
---|
334 | struct controls {
|
---|
335 | LBITFIELD8_8 (
|
---|
336 | vendor_specific0 : 1,
|
---|
337 | vendor_specific1 : 1,
|
---|
338 | vendor_specific2 : 1,
|
---|
339 | vendor_specific3 : 1,
|
---|
340 | vendor_specific4 : 1,
|
---|
341 | vendor_specific5 : 1,
|
---|
342 | vendor_specific6 : 1,
|
---|
343 | vendor_specific7 : 1
|
---|
344 | );
|
---|
345 | } * _controls;
|
---|
346 | uint8 extension;
|
---|
347 | } _PACKED usb_video_extension_unit_descriptor;
|
---|
348 |
|
---|
349 |
|
---|
350 | typedef struct std_vc_interrupt_endpoint_descriptor {
|
---|
351 | uint8 length; // 7 bytes
|
---|
352 | uint8 descriptor_type;
|
---|
353 | struct end_point_address {
|
---|
354 | LBITFIELD8_3 (
|
---|
355 | endpoint_number: 4, // Determined by the designer
|
---|
356 | reserved: 3, // Reserved. Set to zero.
|
---|
357 | direction: 1 // 0 = OUT, 1 = IN
|
---|
358 | );
|
---|
359 | } _end_point_address;
|
---|
360 | struct attributes {
|
---|
361 | LBITFIELD8_3 (
|
---|
362 | transfer_type: 2, // Must be set to 11 (Interrupt)
|
---|
363 | synchronization_type: 2, // Must be set to 00 (None)
|
---|
364 | reserved: 4 // Reserved. Must be set to zero
|
---|
365 | );
|
---|
366 | } _attributes;
|
---|
367 | uint16 max_packet_size;
|
---|
368 | uint8 interval;
|
---|
369 | } _PACKED usb_video_vc_interrupt_endpoint_descriptor;
|
---|
370 |
|
---|
371 |
|
---|
372 | typedef struct std_vs_interface_descriptor {
|
---|
373 | uint8 length; // 9 bytes
|
---|
374 | uint8 descriptor_type;
|
---|
375 | uint8 interface_number;
|
---|
376 | uint8 alternate_setting;
|
---|
377 | uint8 num_endpoints;
|
---|
378 | uint8 interface_class;
|
---|
379 | uint8 interface_sub_class;
|
---|
380 | uint8 interface_protocol;
|
---|
381 | // Not used. Must be set to USB_VIDEO_PC_PROTOCOL_UNDEFINED
|
---|
382 | uint8 interface;
|
---|
383 | } _PACKED usb_video_standard_vs_interface_descriptor;
|
---|
384 |
|
---|
385 |
|
---|
386 | typedef struct class_specific_vc_interrupt_endpoint_descriptor {
|
---|
387 | uint8 length; // 5 bytes
|
---|
388 | uint8 descriptor_type;
|
---|
389 | uint8 descriptor_sub_type;
|
---|
390 | uint16 max_transfer_size;
|
---|
391 | } _PACKED usb_video_class_specific_vc_interrupt_endpoint_descriptor;
|
---|
392 |
|
---|
393 |
|
---|
394 | // Input Terminal Descriptor
|
---|
395 | // 1.5: Table 3-4, page 50
|
---|
396 | typedef struct {
|
---|
397 | uint8 length;
|
---|
398 | uint8 descriptor_type; // USB_VIDEO_CS_INTERFACE
|
---|
399 | uint8 descriptor_subtype; // USB_VIDEO_VC_INPUT_TERMINAL
|
---|
400 | uint8 terminal_id;
|
---|
401 | uint16 terminal_type;
|
---|
402 | uint8 assoc_terminal;
|
---|
403 | uint8 terminal;
|
---|
404 |
|
---|
405 | union {
|
---|
406 | struct {
|
---|
407 | uint16 focal_length_min;
|
---|
408 | uint16 focal_length_max;
|
---|
409 | uint16 focal_length;
|
---|
410 | uint8 control_size;
|
---|
411 | uint8 controls[3];
|
---|
412 | } _PACKED camera;
|
---|
413 | };
|
---|
414 | } _PACKED usb_video_input_terminal_descriptor;
|
---|
415 |
|
---|
416 |
|
---|
417 | typedef struct class_specific_vs_interface_input_header_descriptor {
|
---|
418 | uint8 length; // 13 bytes + (num_formats*control_size)
|
---|
419 | uint8 descriptor_type;
|
---|
420 | uint8 descriptor_sub_type;
|
---|
421 | uint8 num_formats;
|
---|
422 | uint16 total_length;
|
---|
423 | struct endpoint_address {
|
---|
424 | LBITFIELD8_3 (
|
---|
425 | endpoint_number: 4, // Determined by the designer
|
---|
426 | reserved: 3, // Set to zero.
|
---|
427 | direction: 1 // 0 = OUT, 1 = IN
|
---|
428 | );
|
---|
429 | } _endpoint_address;
|
---|
430 | struct info {
|
---|
431 | LBITFIELD8_2 (
|
---|
432 | dynamic_format_change_support: 1,
|
---|
433 | reserved: 7 // Set to zero.
|
---|
434 | );
|
---|
435 | } _info;
|
---|
436 | uint8 terminal_link;
|
---|
437 | uint8 still_capture_method;
|
---|
438 | uint8 trigger_support;
|
---|
439 | uint8 trigger_usage;
|
---|
440 | uint8 control_size;
|
---|
441 | struct ma_controls {
|
---|
442 | // For four first bits, a bit set to 1 indicates that the named field
|
---|
443 | // is supported by the Video Probe and Commit Control when
|
---|
444 | // its format_index is 1:
|
---|
445 | LBITFIELD8_7 (
|
---|
446 | key_frame_rate: 1,
|
---|
447 | p_frame_rate: 1,
|
---|
448 | comp_quality: 1,
|
---|
449 | comp_window_size: 1,
|
---|
450 | // For the next two bits, a bit set to 1 indicates that the named
|
---|
451 | // control is supported by the device when
|
---|
452 | // format_index is 1:
|
---|
453 | generate_key_frame: 1,
|
---|
454 | update_frame_segment: 1,
|
---|
455 | reserved: 2 // (control_size*8-1): Set to zero.
|
---|
456 | );
|
---|
457 | } * _ma_controls;
|
---|
458 | } _PACKED usb_video_class_specific_vs_interface_input_header_descriptor;
|
---|
459 |
|
---|
460 |
|
---|
461 |
|
---|
462 | // Output terminal descriptor
|
---|
463 | // 1.5: Table 3-5, page 51
|
---|
464 | typedef struct {
|
---|
465 | uint8 length;
|
---|
466 | uint8 descriptor_type; // USB_VIDEO_CS_INTERFACE
|
---|
467 | uint8 descriptor_subtype; // USB_VIDEO_VC_OUTPUT_TERMINAL
|
---|
468 | uint8 terminal_id;
|
---|
469 | uint16 terminal_type;
|
---|
470 | uint8 assoc_terminal;
|
---|
471 | uint8 source_id;
|
---|
472 | uint8 terminal;
|
---|
473 | } _PACKED usb_video_output_terminal_descriptor;
|
---|
474 |
|
---|
475 |
|
---|
476 | typedef struct class_specific_vs_interface_output_header_descriptor {
|
---|
477 | uint8 length; // 9 + (num_formats*control_size)
|
---|
478 | uint8 descriptor_type;
|
---|
479 | uint8 descriptor_sub_type;
|
---|
480 | uint8 num_formats;
|
---|
481 | uint16 total_length;
|
---|
482 | struct endpoint_address {
|
---|
483 | LBITFIELD8_3 (
|
---|
484 | endpoint_number: 4, // Determined by the designer
|
---|
485 | reserved: 3, // Set to zero.
|
---|
486 | direction: 1 // 0 = OUT
|
---|
487 | );
|
---|
488 | } _endpoint_address;
|
---|
489 | uint8 terminal_link;
|
---|
490 | uint8 control_size;
|
---|
491 | struct ma_controls {
|
---|
492 | // For four first bits, a bit set to 1 indicates that the named field
|
---|
493 | // is supported by the Video Probe and Commit Control when its
|
---|
494 | // format_index is 1:
|
---|
495 | LBITFIELD8_5 (
|
---|
496 | key_frame_rate: 1,
|
---|
497 | p_frame_rate: 1,
|
---|
498 | comp_quality: 1,
|
---|
499 | comp_window_size: 1,
|
---|
500 | reserved: 4 // (control_size*8-1) Set to zero.
|
---|
501 | );
|
---|
502 | } * _ma_controls;
|
---|
503 | } _PACKED usb_video_class_specific_vs_interface_output_header_descriptor;
|
---|
504 |
|
---|
505 |
|
---|
506 | // Processing unit descriptor
|
---|
507 | // 1.5: Table 3-8, page 54
|
---|
508 | typedef struct {
|
---|
509 | uint8 length;
|
---|
510 | uint8 descriptor_type;
|
---|
511 | uint8 descriptor_subtype;
|
---|
512 | uint8 unit_id;
|
---|
513 | uint8 source_id;
|
---|
514 | uint16 max_multiplier;
|
---|
515 | uint8 control_size;
|
---|
516 | #if B_HOST_IS_LENDIAN
|
---|
517 | struct controls {
|
---|
518 | struct control_a {
|
---|
519 | LBITFIELD16 (
|
---|
520 | brightness: 1,
|
---|
521 | contrast: 1,
|
---|
522 | hue: 1,
|
---|
523 | saturation: 1,
|
---|
524 | sharpness: 1,
|
---|
525 | gamma: 1,
|
---|
526 | white_balance_temperature: 1,
|
---|
527 | white_balance_component: 1,
|
---|
528 | backlight_compensation: 1,
|
---|
529 | gain: 1,
|
---|
530 | power_line_frequency: 1,
|
---|
531 | hue_auto: 1,
|
---|
532 | white_balance_temperature_auto: 1,
|
---|
533 | white_balance_component_auto: 1,
|
---|
534 | digital_multiplier: 1,
|
---|
535 | digital_multiplier_limit: 1
|
---|
536 | );
|
---|
537 | } _control_a;
|
---|
538 | struct control_b {
|
---|
539 | LBITFIELD3 (
|
---|
540 | analog_video_standard: 1,
|
---|
541 | analog_video_lock_status: 1,
|
---|
542 | reserved: 14 // Reserved. Se to zero.
|
---|
543 | );
|
---|
544 | } _control_b;
|
---|
545 | } _controls;
|
---|
546 | #else
|
---|
547 | struct controls {
|
---|
548 | struct control_b {
|
---|
549 | LBITFIELD3 (
|
---|
550 | analog_video_standard: 1,
|
---|
551 | analog_video_lock_status: 1,
|
---|
552 | reserved: 14 // Reserved. Se to zero.
|
---|
553 | );
|
---|
554 | } _control_b;
|
---|
555 | struct control_a {
|
---|
556 | LBITFIELD16 (
|
---|
557 | brightness: 1,
|
---|
558 | contrast: 1,
|
---|
559 | hue: 1,
|
---|
560 | saturation: 1,
|
---|
561 | sharpness: 1,
|
---|
562 | gamma: 1,
|
---|
563 | white_balance_temperature: 1,
|
---|
564 | white_balance_component: 1,
|
---|
565 | backlight_compensation: 1,
|
---|
566 | gain: 1,
|
---|
567 | power_line_frequency: 1,
|
---|
568 | hue_auto: 1,
|
---|
569 | white_balance_temperature_auto: 1,
|
---|
570 | white_balance_component_auto: 1,
|
---|
571 | digital_multiplier: 1,
|
---|
572 | digital_multiplier_limit: 1
|
---|
573 | );
|
---|
574 | } _control_a;
|
---|
575 | } _controls;
|
---|
576 | #endif
|
---|
577 | uint8 processing;
|
---|
578 | struct video_standards {
|
---|
579 | LBITFIELD8_8 (
|
---|
580 | none: 1,
|
---|
581 | ntsc_525_60: 1,
|
---|
582 | pal_625_50: 1,
|
---|
583 | secam_625_50: 1,
|
---|
584 | ntsc_625_50: 1,
|
---|
585 | pal_525_60: 1,
|
---|
586 | reserved6: 1, // Reserved. Set to zero.
|
---|
587 | reserved7: 1 // Reserved. Set to zero.
|
---|
588 | );
|
---|
589 | } _video_standards;
|
---|
590 | } _PACKED usb_video_processing_unit_descriptor;
|
---|
591 |
|
---|
592 |
|
---|
593 | typedef struct camera_terminal_descriptor {
|
---|
594 | uint8 length; // 15 + control_size bytes
|
---|
595 | uint8 descriptor_type;
|
---|
596 | uint8 descriptor_sub_type;
|
---|
597 | uint8 terminal_id;
|
---|
598 | uint16 terminal_type;
|
---|
599 | uint8 assoc_terminal;
|
---|
600 | uint8 terminal;
|
---|
601 | uint16 objective_focal_length_min;
|
---|
602 | uint16 objective_focal_length_max;
|
---|
603 | uint16 ocular_focal_length;
|
---|
604 | uint8 control_size;
|
---|
605 | #if B_HOST_IS_LENDIAN
|
---|
606 | struct controls {
|
---|
607 | struct control_a {
|
---|
608 | LBITFIELD16 (
|
---|
609 | scanning_mode: 1,
|
---|
610 | auto_exposure_mode: 1,
|
---|
611 | auto_exposure_priority: 1,
|
---|
612 | exposure_time_absolute: 1,
|
---|
613 | exposure_time_relative: 1,
|
---|
614 | focus_absolute: 1,
|
---|
615 | focus_relative: 1,
|
---|
616 | iris_absolute: 1,
|
---|
617 | iris_relative: 1,
|
---|
618 | zoom_absolute: 1,
|
---|
619 | zoom_relative: 1,
|
---|
620 | pan_tilt_absolute: 1,
|
---|
621 | pan_tilt_relative: 1,
|
---|
622 | roll_absolute: 1,
|
---|
623 | roll_relative: 1,
|
---|
624 | reserved15: 1
|
---|
625 | );
|
---|
626 | } _control_a;
|
---|
627 | struct control_b {
|
---|
628 | LBITFIELD4 (
|
---|
629 | reserved16: 1,
|
---|
630 | focus_auto: 1,
|
---|
631 | privacy: 1,
|
---|
632 | // D19...(control_size*8-1): Reserved, set to zero.
|
---|
633 | reserved: 13
|
---|
634 | );
|
---|
635 | } _contorl_b;
|
---|
636 | } _controls;
|
---|
637 | #else
|
---|
638 | struct controls {
|
---|
639 | struct control_b {
|
---|
640 | LBITFIELD4 (
|
---|
641 | reserved16: 1,
|
---|
642 | focus_auto: 1,
|
---|
643 | privacy: 1,
|
---|
644 | // D19...(control_size*8-1): Reserved, set to zero.
|
---|
645 | reserved: 13
|
---|
646 | );
|
---|
647 | } _contorl_b;
|
---|
648 | struct control_a {
|
---|
649 | LBITFIELD16 (
|
---|
650 | scanning_mode: 1,
|
---|
651 | auto_exposure_mode: 1,
|
---|
652 | auto_exposure_priority: 1,
|
---|
653 | exposure_time_absolute: 1,
|
---|
654 | exposure_time_relative: 1,
|
---|
655 | focus_absolute: 1,
|
---|
656 | focus_relative: 1,
|
---|
657 | iris_absolute: 1,
|
---|
658 | iris_relative: 1,
|
---|
659 | zoom_absolute: 1,
|
---|
660 | zoom_relative: 1,
|
---|
661 | pan_tilt_absolute: 1,
|
---|
662 | pan_tilt_relative: 1,
|
---|
663 | roll_absolute: 1,
|
---|
664 | roll_relative: 1,
|
---|
665 | reserved15: 1
|
---|
666 | );
|
---|
667 | } _control_a;
|
---|
668 | } _controls;
|
---|
669 | #endif
|
---|
670 | } _PACKED usb_video_camera_terminal_descriptor;
|
---|
671 |
|
---|
672 |
|
---|
673 | struct usb_video_frame_descriptor {
|
---|
674 | uint8 length;
|
---|
675 | uint8 descriptor_type;
|
---|
676 | uint8 descriptor_subtype;
|
---|
677 | uint8 frame_index;
|
---|
678 | uint8 capabilities;
|
---|
679 | uint16 width;
|
---|
680 | uint16 height;
|
---|
681 | uint32 min_bit_rate;
|
---|
682 | uint32 max_bit_rate;
|
---|
683 | uint32 max_video_frame_buffer_size;
|
---|
684 | uint32 default_frame_interval;
|
---|
685 | uint8 frame_interval_type;
|
---|
686 | union {
|
---|
687 | struct {
|
---|
688 | uint32 min_frame_interval;
|
---|
689 | uint32 max_frame_tnterval;
|
---|
690 | uint32 frame_interval_step;
|
---|
691 | } continuous;
|
---|
692 | uint32 discrete_frame_intervals[0];
|
---|
693 | };
|
---|
694 | } _PACKED;
|
---|
695 |
|
---|
696 |
|
---|
697 | typedef struct video_probe_and_commit_controls {
|
---|
698 | uint8 length; // 34 bytes
|
---|
699 | struct hint {
|
---|
700 | LBITFIELD5 (
|
---|
701 | frame_interval: 1,
|
---|
702 | key_frame_rate: 1,
|
---|
703 | p_frame_rate: 1,
|
---|
704 | comp_quality: 1,
|
---|
705 | reserved: 12
|
---|
706 | );
|
---|
707 | } _hint;
|
---|
708 | uint8 format_index;
|
---|
709 | uint8 frame_index;
|
---|
710 | uint32 frame_interval;
|
---|
711 | uint16 key_frame_rate;
|
---|
712 | uint16 p_frame_rate;
|
---|
713 | uint16 comp_quality;
|
---|
714 | uint16 comp_window_size;
|
---|
715 | uint16 delay;
|
---|
716 | uint32 max_video_frame_size;
|
---|
717 | uint32 max_payload_transfer_size;
|
---|
718 | uint32 clock_frequency;
|
---|
719 | struct framing_info {
|
---|
720 | LBITFIELD8_3 (
|
---|
721 | is_frame_id_required: 1,
|
---|
722 | is_end_of_frame_present: 1,
|
---|
723 | reserved: 6
|
---|
724 | );
|
---|
725 | } _framing_info;
|
---|
726 | uint8 prefered_version;
|
---|
727 | uint8 min_version;
|
---|
728 | uint8 max_version;
|
---|
729 | } _PACKED usb_video_video_probe_and_commit_controls;
|
---|
730 |
|
---|
731 |
|
---|
732 | typedef struct video_still_probe_control_and_still_commit_control {
|
---|
733 | uint8 length; // 11 bytes
|
---|
734 | uint8 frame_index;
|
---|
735 | uint8 compression_index;
|
---|
736 | uint32 max_video_frame_size;
|
---|
737 | uint32 max_payload_transfer_size;
|
---|
738 | } _PACKED usb_video_video_still_probe_control_and_still_commit_control;
|
---|
739 |
|
---|
740 |
|
---|
741 | typedef struct still_image_frame_descriptor {
|
---|
742 | // 10 bytes + (4 * num_image_size_patterns) - 4 + num_compression_pattern
|
---|
743 | uint8 length;
|
---|
744 | uint8 descriptor_type;
|
---|
745 | uint8 descriptor_sub_type;
|
---|
746 | uint8 endpoint_address;
|
---|
747 | uint8 num_image_size_patterns;
|
---|
748 | struct pattern_size {
|
---|
749 | uint16 width;
|
---|
750 | uint16 height;
|
---|
751 | } * _pattern_size;
|
---|
752 | uint8 num_compression_pattern;
|
---|
753 | uint8* compression;
|
---|
754 | } _PACKED usb_video_still_image_frame_descriptor;
|
---|
755 |
|
---|
756 |
|
---|
757 | typedef struct std_vs_bulk_still_image_data_endpoint_descriptor {
|
---|
758 | uint8 length; // 7 bytes
|
---|
759 | struct endpoint_address {
|
---|
760 | LBITFIELD8_3 (
|
---|
761 | endpoint_number: 4, // Determined by the designer
|
---|
762 | reserved: 3,
|
---|
763 | direction: 1 // Set to 1 = IN endpoint)
|
---|
764 | );
|
---|
765 | } _endpoint_address;
|
---|
766 | struct attributes {
|
---|
767 | LBITFIELD8_2 (
|
---|
768 | transfer_type: 2, // Set to 10 = Bulk
|
---|
769 | reserved: 6
|
---|
770 | );
|
---|
771 | } _attributes;
|
---|
772 | uint16 max_packet_size;
|
---|
773 | uint8 interval;
|
---|
774 | } _PACKED usb_video_standard_vs_bulk_still_image_data_endpoint_descriptor;
|
---|
775 |
|
---|
776 |
|
---|
777 | typedef struct color_matching_descriptor {
|
---|
778 | uint8 length; // 6 bytes
|
---|
779 | uint8 descriptor_type;
|
---|
780 | uint8 descriptor_sub_type;
|
---|
781 | uint8 color_primaries;
|
---|
782 | uint8 transfer_characteristics;
|
---|
783 | uint8 matrix_coefficients;
|
---|
784 | } _PACKED usb_video_color_matching_descriptor;
|
---|
785 |
|
---|
786 |
|
---|
787 | typedef struct std_vs_isochronous_video_data_endpoint_descriptor {
|
---|
788 | uint8 length; // 7 bytes
|
---|
789 | uint8 descriptor_type;
|
---|
790 | struct endpoint_address {
|
---|
791 | LBITFIELD8_3 (
|
---|
792 | endpoint_number: 4, // Determined by the designer
|
---|
793 | reserved: 3, // Reset to zero.
|
---|
794 | direction: 1 // 0 = OUT endpoint, 1 = IN endpoint
|
---|
795 | );
|
---|
796 | } _endpoint_address;
|
---|
797 | struct attributes {
|
---|
798 | LBITFIELD8_3 (
|
---|
799 | transfer_type: 2, // 01 = isochronous
|
---|
800 | synchronization_type: 2, // 01 = asynchronous
|
---|
801 | reserved: 4
|
---|
802 | );
|
---|
803 | } _attributes;
|
---|
804 | uint16 max_packet_size;
|
---|
805 | uint8 interval;
|
---|
806 | } _PACKED usb_video_std_vs_isochronous_video_data_endpoint_descriptor;
|
---|
807 |
|
---|
808 |
|
---|
809 | typedef struct std_vs_bulk_video_data_endpoint_descriptor {
|
---|
810 | uint8 length; // 7 bytes
|
---|
811 | uint8 descriptor_type;
|
---|
812 | struct endpoint_address {
|
---|
813 | LBITFIELD8_3 (
|
---|
814 | endpoint_number: 4, // Determined by the designer
|
---|
815 | reserved: 3, // Reset to zero.
|
---|
816 | direction: 1 // 0 = OUT endpoint
|
---|
817 | );
|
---|
818 | } _endpoint_address;
|
---|
819 | struct attributes {
|
---|
820 | LBITFIELD8_2 (
|
---|
821 | transfer_type: 2, // Set to 10 = Bulk
|
---|
822 | reserved: 6
|
---|
823 | );
|
---|
824 | } _attributes;
|
---|
825 | uint16 max_packet_size;
|
---|
826 | uint8 interval;
|
---|
827 | } _PACKED usb_video_standard_vs_bulk_video_data_endpoint_descriptor;
|
---|
828 |
|
---|
829 |
|
---|
830 | #endif /* !USB_VIDEO_H */
|
---|