Fix FreeBSD build.
[haiku.git] / headers / os / drivers / usb / USB_video.h
blob2c3fb00f6eb4fd75c32323f7d447b9f2b8295341
1 /*
2 * Copyright 2016, Adrien Destugues, pulkomandy@pulkomandy.tk
3 * Distributed under terms of the MIT license.
4 */
7 #ifndef USB_VIDEO_H
8 #define USB_VIDEO_H
11 // Based on specification for UVC version 1.5.
14 #include <SupportDefs.h>
17 #define USB_VIDEO_DEVICE_CLASS 0x0E
19 enum { // Video Interface Subclasses
20 USB_VIDEO_INTERFACE_UNDEFINED_SUBCLASS = 0x00,
21 USB_VIDEO_INTERFACE_VIDEOCONTROL_SUBCLASS = 0x01,
22 USB_VIDEO_INTERFACE_VIDEOSTREAMING_SUBCLASS,
23 USB_VIDEO_INTERFACE_COLLECTION_SUBCLASS,
27 enum { // Video Interface Protocol Codes
28 USB_VIDEO_PROTOCOL_UNDEFINED = 0x00,
29 USB_VIDEO_PROTOCOL_15 = 0x01,
33 enum { // Video Interface Class-Specific Descriptor Types
34 USB_VIDEO_CS_UNDEFINED = 0x20,
35 USB_VIDEO_CS_DEVICE = 0x21,
36 USB_VIDEO_CS_CONFIGURATION = 0x22,
37 USB_VIDEO_CS_STRING = 0x23,
38 USB_VIDEO_CS_INTERFACE = 0x24,
39 USB_VIDEO_CS_ENDPOINT = 0x25,
43 enum { // Video Class-Specific VideoControl Interface descriptor subtypes
44 USB_VIDEO_VC_DESCRIPTOR_UNDEFINED = 0x00,
45 USB_VIDEO_VC_HEADER = 0x01,
46 USB_VIDEO_VC_INPUT_TERMINAL = 0x02,
47 USB_VIDEO_VC_OUTPUT_TERMINAL = 0x03,
48 USB_VIDEO_VC_SELECTOR_UNIT = 0x04,
49 USB_VIDEO_VC_PROCESSING_UNIT = 0x05,
50 USB_VIDEO_VC_EXTENSION_UNIT = 0x06,
51 USB_VIDEO_VC_ENCODING_UNIT = 0x07,
55 enum { // Video Class-Specific VideoStreaming Interface descriptor subtypes
56 USB_VIDEO_VS_UNDEFINED = 0x00,
57 USB_VIDEO_VS_INPUT_HEADER = 0x01,
58 USB_VIDEO_VS_OUTPUT_HEADER = 0x02,
59 USB_VIDEO_VS_STILL_IMAGE_FRAME = 0x03,
60 USB_VIDEO_VS_FORMAT_UNCOMPRESSED = 0x04,
61 USB_VIDEO_VS_FRAME_UNCOMPRESSED = 0x05,
62 USB_VIDEO_VS_FORMAT_MJPEG = 0x06,
63 USB_VIDEO_VS_FRAME_MJPEG = 0x07,
64 USB_VIDEO_VS_FORMAT_MPEG2TS = 0x0a,
65 USB_VIDEO_VS_FORMAT_DV = 0x0c,
66 USB_VIDEO_VS_COLORFORMAT = 0x0d,
67 USB_VIDEO_VS_FORMAT_FRAME_BASED = 0x10,
68 USB_VIDEO_VS_FRAME_FRAME_BASED = 0x11,
69 USB_VIDEO_VS_FORMAT_STREAM_BASED = 0x12,
70 USB_VIDEO_VS_FORMAT_H264 = 0x13,
71 USB_VIDEO_VS_FRAME_H264 = 0x14,
72 USB_VIDEO_VS_FORMAT_H264_SIMULCAST = 0x15,
73 USB_VIDEO_VS_FORMAT_VP8 = 0x16,
74 USB_VIDEO_VS_FRAME_VP8 = 0x17,
75 USB_VIDEO_VS_FORMAT_VP8_SIMULCAST = 0x18,
79 enum {
80 // USB Terminal Types
81 USB_VIDEO_VENDOR_USB_IO = 0x100,
82 USB_VIDEO_STREAMING_USB_IO = 0x101,
83 // Input terminal types
84 USB_VIDEO_VENDOR_IN = 0x200,
85 USB_VIDEO_CAMERA_IN = 0x201,
86 USB_VIDEO_MEDIA_TRANSPORT_IN = 0x202,
87 // Output terminal types
88 USB_VIDEO_VENDOR_OUT = 0x300,
89 USB_VIDEO_DISPLAY_OUT = 0x301,
90 USB_VIDEO_MEDIA_TRANSPORT_OUT = 0x302,
91 // External terminal types
92 USB_VIDEO_VENDOR_EXT = 0x400,
93 USB_VIDEO_COMPOSITE_EXT = 0x401,
94 USB_VIDEO_SVIDEO_EXT = 0x402,
95 USB_VIDEO_COMPONENT_EXT = 0x403,
99 enum {
100 EP_SUBTYPE_UNDEFINED = 0x00,
101 EP_SUBTYPE_GENERAL = 0x01,
102 EP_SUBTYPE_ENDPOINT = 0x02,
103 EP_SUBTYPE_INTERRUPT = 0x03,
107 // Class Specific Video Control Interface Header
108 // 1.5: Table 3-3 p.48
109 typedef struct {
110 uint8 length;
111 uint8 descriptor_type; // USB_AUDIO_CS_INTERFACE
112 uint8 descriptor_subtype; // USB_AUDIO_AC_HEADER
113 uint16 bcd_release_no;
114 uint16 total_length;
115 uint32 clock_frequency;
116 uint8 in_collection;
117 uint8 interface_numbers[0];
118 } _PACKED usb_videocontrol_header_descriptor;
121 // Input Terminal Descriptor
122 // 1.5: Table 3-4, page 50
123 typedef struct {
124 uint8 length;
125 uint8 descriptor_type; // USB_VIDEO_CS_INTERFACE
126 uint8 descriptor_subtype; // USB_VIDEO_VC_INPUT_TERMINAL
127 uint8 terminal_id;
128 uint16 terminal_type;
129 uint8 assoc_terminal;
130 uint8 terminal;
132 union {
133 struct {
134 uint16 focal_length_min;
135 uint16 focal_length_max;
136 uint16 focal_length;
137 uint8 control_size;
138 uint8 controls[3];
139 } _PACKED camera;
141 } _PACKED usb_video_input_terminal_descriptor;
144 // Output terminal descriptor
145 // 1.5: Table 3-5, page 51
146 typedef struct {
147 uint8 length;
148 uint8 descriptor_type; // USB_VIDEO_CS_INTERFACE
149 uint8 descriptor_subtype; // USB_VIDEO_VC_OUTPUT_TERMINAL
150 uint8 terminal_id;
151 uint16 terminal_type;
152 uint8 assoc_terminal;
153 uint8 source_id;
154 uint8 terminal;
155 } _PACKED usb_video_output_terminal_descriptor;
158 // Processing unit descriptor
159 // 1.5: Table 3-8, page 54
160 typedef struct {
161 uint8 length;
162 uint8 descriptor_type;
163 uint8 descriptor_subtype;
164 uint8 unit_id;
165 uint8 source_id;
166 uint16 max_multiplier;
167 uint8 control_size;
168 uint8 controls[3];
169 uint8 processing;
170 uint8 video_standards;
171 } _PACKED usb_video_processing_unit_descriptor;
174 struct usb_video_frame_descriptor {
175 uint8 length;
176 uint8 descriptor_type;
177 uint8 descriptor_subtype;
178 uint8 frame_index;
179 uint8 capabilities;
180 uint16 width;
181 uint16 height;
182 uint32 min_bit_rate;
183 uint32 max_bit_rate;
184 uint32 max_video_frame_buffer_size;
185 uint32 default_frame_interval;
186 uint8 frame_interval_type;
187 union {
188 struct {
189 uint32 min_frame_interval;
190 uint32 max_frame_tnterval;
191 uint32 frame_interval_step;
192 } continuous;
193 uint32 discrete_frame_intervals[0];
195 } _PACKED;
198 #endif /* !USB_VIDEO_H */