diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2010-07-10 14:03:20 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-08-02 15:43:15 -0400 |
commit | bbafc0cb6c52c40647f561854db5fbac4d608186 (patch) | |
tree | d10c23e4e0a7ae5e169f7b7c627c6a762b0a2d56 | |
parent | c89f66f629f0e94806e3ec6f8f77b61a8feed39f (diff) |
V4L/DVB: uvc: Move constants and structures definitions to linux/usb/video.h
The UVC host and gadget drivers both define constants and structures in
private header files. Move all those definitions to linux/usb/video.h
where they can be shared by the two drivers (and be available for
userspace applications).
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/video/uvc/uvcvideo.h | 19 | ||||
-rw-r--r-- | drivers/usb/gadget/f_uvc.c | 16 | ||||
-rw-r--r-- | drivers/usb/gadget/f_uvc.h | 352 | ||||
-rw-r--r-- | drivers/usb/gadget/uvc.h | 36 | ||||
-rw-r--r-- | drivers/usb/gadget/webcam.c | 24 | ||||
-rw-r--r-- | include/linux/usb/video.h | 397 |
6 files changed, 418 insertions, 426 deletions
diff --git a/drivers/media/video/uvc/uvcvideo.h b/drivers/media/video/uvc/uvcvideo.h index 47b20e7e3786..ac272456fbfd 100644 --- a/drivers/media/video/uvc/uvcvideo.h +++ b/drivers/media/video/uvc/uvcvideo.h | |||
@@ -196,25 +196,6 @@ struct uvc_device; | |||
196 | /* TODO: Put the most frequently accessed fields at the beginning of | 196 | /* TODO: Put the most frequently accessed fields at the beginning of |
197 | * structures to maximize cache efficiency. | 197 | * structures to maximize cache efficiency. |
198 | */ | 198 | */ |
199 | struct uvc_streaming_control { | ||
200 | __u16 bmHint; | ||
201 | __u8 bFormatIndex; | ||
202 | __u8 bFrameIndex; | ||
203 | __u32 dwFrameInterval; | ||
204 | __u16 wKeyFrameRate; | ||
205 | __u16 wPFrameRate; | ||
206 | __u16 wCompQuality; | ||
207 | __u16 wCompWindowSize; | ||
208 | __u16 wDelay; | ||
209 | __u32 dwMaxVideoFrameSize; | ||
210 | __u32 dwMaxPayloadTransferSize; | ||
211 | __u32 dwClockFrequency; | ||
212 | __u8 bmFramingInfo; | ||
213 | __u8 bPreferedVersion; | ||
214 | __u8 bMinVersion; | ||
215 | __u8 bMaxVersion; | ||
216 | }; | ||
217 | |||
218 | struct uvc_control_info { | 199 | struct uvc_control_info { |
219 | struct list_head list; | 200 | struct list_head list; |
220 | struct list_head mappings; | 201 | struct list_head mappings; |
diff --git a/drivers/usb/gadget/f_uvc.c b/drivers/usb/gadget/f_uvc.c index dbe6db0184fd..be446b7e7eaa 100644 --- a/drivers/usb/gadget/f_uvc.c +++ b/drivers/usb/gadget/f_uvc.c | |||
@@ -61,12 +61,12 @@ static struct usb_gadget_strings *uvc_function_strings[] = { | |||
61 | #define UVC_INTF_VIDEO_STREAMING 1 | 61 | #define UVC_INTF_VIDEO_STREAMING 1 |
62 | 62 | ||
63 | static struct usb_interface_assoc_descriptor uvc_iad __initdata = { | 63 | static struct usb_interface_assoc_descriptor uvc_iad __initdata = { |
64 | .bLength = USB_DT_INTERFACE_ASSOCIATION_SIZE, | 64 | .bLength = sizeof(uvc_iad), |
65 | .bDescriptorType = USB_DT_INTERFACE_ASSOCIATION, | 65 | .bDescriptorType = USB_DT_INTERFACE_ASSOCIATION, |
66 | .bFirstInterface = 0, | 66 | .bFirstInterface = 0, |
67 | .bInterfaceCount = 2, | 67 | .bInterfaceCount = 2, |
68 | .bFunctionClass = USB_CLASS_VIDEO, | 68 | .bFunctionClass = USB_CLASS_VIDEO, |
69 | .bFunctionSubClass = 0x03, | 69 | .bFunctionSubClass = UVC_SC_VIDEO_INTERFACE_COLLECTION, |
70 | .bFunctionProtocol = 0x00, | 70 | .bFunctionProtocol = 0x00, |
71 | .iFunction = 0, | 71 | .iFunction = 0, |
72 | }; | 72 | }; |
@@ -78,7 +78,7 @@ static struct usb_interface_descriptor uvc_control_intf __initdata = { | |||
78 | .bAlternateSetting = 0, | 78 | .bAlternateSetting = 0, |
79 | .bNumEndpoints = 1, | 79 | .bNumEndpoints = 1, |
80 | .bInterfaceClass = USB_CLASS_VIDEO, | 80 | .bInterfaceClass = USB_CLASS_VIDEO, |
81 | .bInterfaceSubClass = 0x01, | 81 | .bInterfaceSubClass = UVC_SC_VIDEOCONTROL, |
82 | .bInterfaceProtocol = 0x00, | 82 | .bInterfaceProtocol = 0x00, |
83 | .iInterface = 0, | 83 | .iInterface = 0, |
84 | }; | 84 | }; |
@@ -106,7 +106,7 @@ static struct usb_interface_descriptor uvc_streaming_intf_alt0 __initdata = { | |||
106 | .bAlternateSetting = 0, | 106 | .bAlternateSetting = 0, |
107 | .bNumEndpoints = 0, | 107 | .bNumEndpoints = 0, |
108 | .bInterfaceClass = USB_CLASS_VIDEO, | 108 | .bInterfaceClass = USB_CLASS_VIDEO, |
109 | .bInterfaceSubClass = 0x02, | 109 | .bInterfaceSubClass = UVC_SC_VIDEOSTREAMING, |
110 | .bInterfaceProtocol = 0x00, | 110 | .bInterfaceProtocol = 0x00, |
111 | .iInterface = 0, | 111 | .iInterface = 0, |
112 | }; | 112 | }; |
@@ -118,7 +118,7 @@ static struct usb_interface_descriptor uvc_streaming_intf_alt1 __initdata = { | |||
118 | .bAlternateSetting = 1, | 118 | .bAlternateSetting = 1, |
119 | .bNumEndpoints = 1, | 119 | .bNumEndpoints = 1, |
120 | .bInterfaceClass = USB_CLASS_VIDEO, | 120 | .bInterfaceClass = USB_CLASS_VIDEO, |
121 | .bInterfaceSubClass = 0x02, | 121 | .bInterfaceSubClass = UVC_SC_VIDEOSTREAMING, |
122 | .bInterfaceProtocol = 0x00, | 122 | .bInterfaceProtocol = 0x00, |
123 | .iInterface = 0, | 123 | .iInterface = 0, |
124 | }; | 124 | }; |
@@ -603,15 +603,15 @@ uvc_bind_config(struct usb_configuration *c, | |||
603 | 603 | ||
604 | /* Validate the descriptors. */ | 604 | /* Validate the descriptors. */ |
605 | if (control == NULL || control[0] == NULL || | 605 | if (control == NULL || control[0] == NULL || |
606 | control[0]->bDescriptorSubType != UVC_DT_HEADER) | 606 | control[0]->bDescriptorSubType != UVC_VC_HEADER) |
607 | goto error; | 607 | goto error; |
608 | 608 | ||
609 | if (fs_streaming == NULL || fs_streaming[0] == NULL || | 609 | if (fs_streaming == NULL || fs_streaming[0] == NULL || |
610 | fs_streaming[0]->bDescriptorSubType != UVC_DT_INPUT_HEADER) | 610 | fs_streaming[0]->bDescriptorSubType != UVC_VS_INPUT_HEADER) |
611 | goto error; | 611 | goto error; |
612 | 612 | ||
613 | if (hs_streaming == NULL || hs_streaming[0] == NULL || | 613 | if (hs_streaming == NULL || hs_streaming[0] == NULL || |
614 | hs_streaming[0]->bDescriptorSubType != UVC_DT_INPUT_HEADER) | 614 | hs_streaming[0]->bDescriptorSubType != UVC_VS_INPUT_HEADER) |
615 | goto error; | 615 | goto error; |
616 | 616 | ||
617 | uvc->desc.control = control; | 617 | uvc->desc.control = control; |
diff --git a/drivers/usb/gadget/f_uvc.h b/drivers/usb/gadget/f_uvc.h index 8a5db7c4fe7c..e18a6636c283 100644 --- a/drivers/usb/gadget/f_uvc.h +++ b/drivers/usb/gadget/f_uvc.h | |||
@@ -15,357 +15,7 @@ | |||
15 | #define _F_UVC_H_ | 15 | #define _F_UVC_H_ |
16 | 16 | ||
17 | #include <linux/usb/composite.h> | 17 | #include <linux/usb/composite.h> |
18 | 18 | #include <linux/usb/video.h> | |
19 | #define USB_CLASS_VIDEO_CONTROL 1 | ||
20 | #define USB_CLASS_VIDEO_STREAMING 2 | ||
21 | |||
22 | struct uvc_descriptor_header { | ||
23 | __u8 bLength; | ||
24 | __u8 bDescriptorType; | ||
25 | __u8 bDescriptorSubType; | ||
26 | } __attribute__ ((packed)); | ||
27 | |||
28 | struct uvc_header_descriptor { | ||
29 | __u8 bLength; | ||
30 | __u8 bDescriptorType; | ||
31 | __u8 bDescriptorSubType; | ||
32 | __u16 bcdUVC; | ||
33 | __u16 wTotalLength; | ||
34 | __u32 dwClockFrequency; | ||
35 | __u8 bInCollection; | ||
36 | __u8 baInterfaceNr[]; | ||
37 | } __attribute__((__packed__)); | ||
38 | |||
39 | #define UVC_HEADER_DESCRIPTOR(n) uvc_header_descriptor_##n | ||
40 | |||
41 | #define DECLARE_UVC_HEADER_DESCRIPTOR(n) \ | ||
42 | struct UVC_HEADER_DESCRIPTOR(n) { \ | ||
43 | __u8 bLength; \ | ||
44 | __u8 bDescriptorType; \ | ||
45 | __u8 bDescriptorSubType; \ | ||
46 | __u16 bcdUVC; \ | ||
47 | __u16 wTotalLength; \ | ||
48 | __u32 dwClockFrequency; \ | ||
49 | __u8 bInCollection; \ | ||
50 | __u8 baInterfaceNr[n]; \ | ||
51 | } __attribute__ ((packed)) | ||
52 | |||
53 | struct uvc_input_terminal_descriptor { | ||
54 | __u8 bLength; | ||
55 | __u8 bDescriptorType; | ||
56 | __u8 bDescriptorSubType; | ||
57 | __u8 bTerminalID; | ||
58 | __u16 wTerminalType; | ||
59 | __u8 bAssocTerminal; | ||
60 | __u8 iTerminal; | ||
61 | } __attribute__((__packed__)); | ||
62 | |||
63 | struct uvc_output_terminal_descriptor { | ||
64 | __u8 bLength; | ||
65 | __u8 bDescriptorType; | ||
66 | __u8 bDescriptorSubType; | ||
67 | __u8 bTerminalID; | ||
68 | __u16 wTerminalType; | ||
69 | __u8 bAssocTerminal; | ||
70 | __u8 bSourceID; | ||
71 | __u8 iTerminal; | ||
72 | } __attribute__((__packed__)); | ||
73 | |||
74 | struct uvc_camera_terminal_descriptor { | ||
75 | __u8 bLength; | ||
76 | __u8 bDescriptorType; | ||
77 | __u8 bDescriptorSubType; | ||
78 | __u8 bTerminalID; | ||
79 | __u16 wTerminalType; | ||
80 | __u8 bAssocTerminal; | ||
81 | __u8 iTerminal; | ||
82 | __u16 wObjectiveFocalLengthMin; | ||
83 | __u16 wObjectiveFocalLengthMax; | ||
84 | __u16 wOcularFocalLength; | ||
85 | __u8 bControlSize; | ||
86 | __u8 bmControls[3]; | ||
87 | } __attribute__((__packed__)); | ||
88 | |||
89 | struct uvc_selector_unit_descriptor { | ||
90 | __u8 bLength; | ||
91 | __u8 bDescriptorType; | ||
92 | __u8 bDescriptorSubType; | ||
93 | __u8 bUnitID; | ||
94 | __u8 bNrInPins; | ||
95 | __u8 baSourceID[0]; | ||
96 | __u8 iSelector; | ||
97 | } __attribute__((__packed__)); | ||
98 | |||
99 | #define UVC_SELECTOR_UNIT_DESCRIPTOR(n) \ | ||
100 | uvc_selector_unit_descriptor_##n | ||
101 | |||
102 | #define DECLARE_UVC_SELECTOR_UNIT_DESCRIPTOR(n) \ | ||
103 | struct UVC_SELECTOR_UNIT_DESCRIPTOR(n) { \ | ||
104 | __u8 bLength; \ | ||
105 | __u8 bDescriptorType; \ | ||
106 | __u8 bDescriptorSubType; \ | ||
107 | __u8 bUnitID; \ | ||
108 | __u8 bNrInPins; \ | ||
109 | __u8 baSourceID[n]; \ | ||
110 | __u8 iSelector; \ | ||
111 | } __attribute__ ((packed)) | ||
112 | |||
113 | struct uvc_processing_unit_descriptor { | ||
114 | __u8 bLength; | ||
115 | __u8 bDescriptorType; | ||
116 | __u8 bDescriptorSubType; | ||
117 | __u8 bUnitID; | ||
118 | __u8 bSourceID; | ||
119 | __u16 wMaxMultiplier; | ||
120 | __u8 bControlSize; | ||
121 | __u8 bmControls[2]; | ||
122 | __u8 iProcessing; | ||
123 | } __attribute__((__packed__)); | ||
124 | |||
125 | struct uvc_extension_unit_descriptor { | ||
126 | __u8 bLength; | ||
127 | __u8 bDescriptorType; | ||
128 | __u8 bDescriptorSubType; | ||
129 | __u8 bUnitID; | ||
130 | __u8 guidExtensionCode[16]; | ||
131 | __u8 bNumControls; | ||
132 | __u8 bNrInPins; | ||
133 | __u8 baSourceID[0]; | ||
134 | __u8 bControlSize; | ||
135 | __u8 bmControls[0]; | ||
136 | __u8 iExtension; | ||
137 | } __attribute__((__packed__)); | ||
138 | |||
139 | #define UVC_EXTENSION_UNIT_DESCRIPTOR(p, n) \ | ||
140 | uvc_extension_unit_descriptor_##p_##n | ||
141 | |||
142 | #define DECLARE_UVC_EXTENSION_UNIT_DESCRIPTOR(p, n) \ | ||
143 | struct UVC_EXTENSION_UNIT_DESCRIPTOR(p, n) { \ | ||
144 | __u8 bLength; \ | ||
145 | __u8 bDescriptorType; \ | ||
146 | __u8 bDescriptorSubType; \ | ||
147 | __u8 bUnitID; \ | ||
148 | __u8 guidExtensionCode[16]; \ | ||
149 | __u8 bNumControls; \ | ||
150 | __u8 bNrInPins; \ | ||
151 | __u8 baSourceID[p]; \ | ||
152 | __u8 bControlSize; \ | ||
153 | __u8 bmControls[n]; \ | ||
154 | __u8 iExtension; \ | ||
155 | } __attribute__ ((packed)) | ||
156 | |||
157 | struct uvc_control_endpoint_descriptor { | ||
158 | __u8 bLength; | ||
159 | __u8 bDescriptorType; | ||
160 | __u8 bDescriptorSubType; | ||
161 | __u16 wMaxTransferSize; | ||
162 | } __attribute__((__packed__)); | ||
163 | |||
164 | #define UVC_DT_HEADER 1 | ||
165 | #define UVC_DT_INPUT_TERMINAL 2 | ||
166 | #define UVC_DT_OUTPUT_TERMINAL 3 | ||
167 | #define UVC_DT_SELECTOR_UNIT 4 | ||
168 | #define UVC_DT_PROCESSING_UNIT 5 | ||
169 | #define UVC_DT_EXTENSION_UNIT 6 | ||
170 | |||
171 | #define UVC_DT_HEADER_SIZE(n) (12+(n)) | ||
172 | #define UVC_DT_INPUT_TERMINAL_SIZE 8 | ||
173 | #define UVC_DT_OUTPUT_TERMINAL_SIZE 9 | ||
174 | #define UVC_DT_CAMERA_TERMINAL_SIZE(n) (15+(n)) | ||
175 | #define UVC_DT_SELECTOR_UNIT_SIZE(n) (6+(n)) | ||
176 | #define UVC_DT_PROCESSING_UNIT_SIZE(n) (9+(n)) | ||
177 | #define UVC_DT_EXTENSION_UNIT_SIZE(p,n) (24+(p)+(n)) | ||
178 | #define UVC_DT_CONTROL_ENDPOINT_SIZE 5 | ||
179 | |||
180 | struct uvc_input_header_descriptor { | ||
181 | __u8 bLength; | ||
182 | __u8 bDescriptorType; | ||
183 | __u8 bDescriptorSubType; | ||
184 | __u8 bNumFormats; | ||
185 | __u16 wTotalLength; | ||
186 | __u8 bEndpointAddress; | ||
187 | __u8 bmInfo; | ||
188 | __u8 bTerminalLink; | ||
189 | __u8 bStillCaptureMethod; | ||
190 | __u8 bTriggerSupport; | ||
191 | __u8 bTriggerUsage; | ||
192 | __u8 bControlSize; | ||
193 | __u8 bmaControls[]; | ||
194 | } __attribute__((__packed__)); | ||
195 | |||
196 | #define UVC_INPUT_HEADER_DESCRIPTOR(n, p) \ | ||
197 | uvc_input_header_descriptor_##n_##p | ||
198 | |||
199 | #define DECLARE_UVC_INPUT_HEADER_DESCRIPTOR(n, p) \ | ||
200 | struct UVC_INPUT_HEADER_DESCRIPTOR(n, p) { \ | ||
201 | __u8 bLength; \ | ||
202 | __u8 bDescriptorType; \ | ||
203 | __u8 bDescriptorSubType; \ | ||
204 | __u8 bNumFormats; \ | ||
205 | __u16 wTotalLength; \ | ||
206 | __u8 bEndpointAddress; \ | ||
207 | __u8 bmInfo; \ | ||
208 | __u8 bTerminalLink; \ | ||
209 | __u8 bStillCaptureMethod; \ | ||
210 | __u8 bTriggerSupport; \ | ||
211 | __u8 bTriggerUsage; \ | ||
212 | __u8 bControlSize; \ | ||
213 | __u8 bmaControls[p][n]; \ | ||
214 | } __attribute__ ((packed)) | ||
215 | |||
216 | struct uvc_output_header_descriptor { | ||
217 | __u8 bLength; | ||
218 | __u8 bDescriptorType; | ||
219 | __u8 bDescriptorSubType; | ||
220 | __u8 bNumFormats; | ||
221 | __u16 wTotalLength; | ||
222 | __u8 bEndpointAddress; | ||
223 | __u8 bTerminalLink; | ||
224 | __u8 bControlSize; | ||
225 | __u8 bmaControls[]; | ||
226 | } __attribute__((__packed__)); | ||
227 | |||
228 | #define UVC_OUTPUT_HEADER_DESCRIPTOR(n, p) \ | ||
229 | uvc_output_header_descriptor_##n_##p | ||
230 | |||
231 | #define DECLARE_UVC_OUTPUT_HEADER_DESCRIPTOR(n, p) \ | ||
232 | struct UVC_OUTPUT_HEADER_DESCRIPTOR(n, p) { \ | ||
233 | __u8 bLength; \ | ||
234 | __u8 bDescriptorType; \ | ||
235 | __u8 bDescriptorSubType; \ | ||
236 | __u8 bNumFormats; \ | ||
237 | __u16 wTotalLength; \ | ||
238 | __u8 bEndpointAddress; \ | ||
239 | __u8 bTerminalLink; \ | ||
240 | __u8 bControlSize; \ | ||
241 | __u8 bmaControls[p][n]; \ | ||
242 | } __attribute__ ((packed)) | ||
243 | |||
244 | struct uvc_format_uncompressed { | ||
245 | __u8 bLength; | ||
246 | __u8 bDescriptorType; | ||
247 | __u8 bDescriptorSubType; | ||
248 | __u8 bFormatIndex; | ||
249 | __u8 bNumFrameDescriptors; | ||
250 | __u8 guidFormat[16]; | ||
251 | __u8 bBitsPerPixel; | ||
252 | __u8 bDefaultFrameIndex; | ||
253 | __u8 bAspectRatioX; | ||
254 | __u8 bAspectRatioY; | ||
255 | __u8 bmInterfaceFlags; | ||
256 | __u8 bCopyProtect; | ||
257 | } __attribute__((__packed__)); | ||
258 | |||
259 | struct uvc_frame_uncompressed { | ||
260 | __u8 bLength; | ||
261 | __u8 bDescriptorType; | ||
262 | __u8 bDescriptorSubType; | ||
263 | __u8 bFrameIndex; | ||
264 | __u8 bmCapabilities; | ||
265 | __u16 wWidth; | ||
266 | __u16 wHeight; | ||
267 | __u32 dwMinBitRate; | ||
268 | __u32 dwMaxBitRate; | ||
269 | __u32 dwMaxVideoFrameBufferSize; | ||
270 | __u32 dwDefaultFrameInterval; | ||
271 | __u8 bFrameIntervalType; | ||
272 | __u32 dwFrameInterval[]; | ||
273 | } __attribute__((__packed__)); | ||
274 | |||
275 | #define UVC_FRAME_UNCOMPRESSED(n) \ | ||
276 | uvc_frame_uncompressed_##n | ||
277 | |||
278 | #define DECLARE_UVC_FRAME_UNCOMPRESSED(n) \ | ||
279 | struct UVC_FRAME_UNCOMPRESSED(n) { \ | ||
280 | __u8 bLength; \ | ||
281 | __u8 bDescriptorType; \ | ||
282 | __u8 bDescriptorSubType; \ | ||
283 | __u8 bFrameIndex; \ | ||
284 | __u8 bmCapabilities; \ | ||
285 | __u16 wWidth; \ | ||
286 | __u16 wHeight; \ | ||
287 | __u32 dwMinBitRate; \ | ||
288 | __u32 dwMaxBitRate; \ | ||
289 | __u32 dwMaxVideoFrameBufferSize; \ | ||
290 | __u32 dwDefaultFrameInterval; \ | ||
291 | __u8 bFrameIntervalType; \ | ||
292 | __u32 dwFrameInterval[n]; \ | ||
293 | } __attribute__ ((packed)) | ||
294 | |||
295 | struct uvc_format_mjpeg { | ||
296 | __u8 bLength; | ||
297 | __u8 bDescriptorType; | ||
298 | __u8 bDescriptorSubType; | ||
299 | __u8 bFormatIndex; | ||
300 | __u8 bNumFrameDescriptors; | ||
301 | __u8 bmFlags; | ||
302 | __u8 bDefaultFrameIndex; | ||
303 | __u8 bAspectRatioX; | ||
304 | __u8 bAspectRatioY; | ||
305 | __u8 bmInterfaceFlags; | ||
306 | __u8 bCopyProtect; | ||
307 | } __attribute__((__packed__)); | ||
308 | |||
309 | struct uvc_frame_mjpeg { | ||
310 | __u8 bLength; | ||
311 | __u8 bDescriptorType; | ||
312 | __u8 bDescriptorSubType; | ||
313 | __u8 bFrameIndex; | ||
314 | __u8 bmCapabilities; | ||
315 | __u16 wWidth; | ||
316 | __u16 wHeight; | ||
317 | __u32 dwMinBitRate; | ||
318 | __u32 dwMaxBitRate; | ||
319 | __u32 dwMaxVideoFrameBufferSize; | ||
320 | __u32 dwDefaultFrameInterval; | ||
321 | __u8 bFrameIntervalType; | ||
322 | __u32 dwFrameInterval[]; | ||
323 | } __attribute__((__packed__)); | ||
324 | |||
325 | #define UVC_FRAME_MJPEG(n) \ | ||
326 | uvc_frame_mjpeg_##n | ||
327 | |||
328 | #define DECLARE_UVC_FRAME_MJPEG(n) \ | ||
329 | struct UVC_FRAME_MJPEG(n) { \ | ||
330 | __u8 bLength; \ | ||
331 | __u8 bDescriptorType; \ | ||
332 | __u8 bDescriptorSubType; \ | ||
333 | __u8 bFrameIndex; \ | ||
334 | __u8 bmCapabilities; \ | ||
335 | __u16 wWidth; \ | ||
336 | __u16 wHeight; \ | ||
337 | __u32 dwMinBitRate; \ | ||
338 | __u32 dwMaxBitRate; \ | ||
339 | __u32 dwMaxVideoFrameBufferSize; \ | ||
340 | __u32 dwDefaultFrameInterval; \ | ||
341 | __u8 bFrameIntervalType; \ | ||
342 | __u32 dwFrameInterval[n]; \ | ||
343 | } __attribute__ ((packed)) | ||
344 | |||
345 | struct uvc_color_matching_descriptor { | ||
346 | __u8 bLength; | ||
347 | __u8 bDescriptorType; | ||
348 | __u8 bDescriptorSubType; | ||
349 | __u8 bColorPrimaries; | ||
350 | __u8 bTransferCharacteristics; | ||
351 | __u8 bMatrixCoefficients; | ||
352 | } __attribute__((__packed__)); | ||
353 | |||
354 | #define UVC_DT_INPUT_HEADER 1 | ||
355 | #define UVC_DT_OUTPUT_HEADER 2 | ||
356 | #define UVC_DT_FORMAT_UNCOMPRESSED 4 | ||
357 | #define UVC_DT_FRAME_UNCOMPRESSED 5 | ||
358 | #define UVC_DT_FORMAT_MJPEG 6 | ||
359 | #define UVC_DT_FRAME_MJPEG 7 | ||
360 | #define UVC_DT_COLOR_MATCHING 13 | ||
361 | |||
362 | #define UVC_DT_INPUT_HEADER_SIZE(n, p) (13+(n*p)) | ||
363 | #define UVC_DT_OUTPUT_HEADER_SIZE(n, p) (9+(n*p)) | ||
364 | #define UVC_DT_FORMAT_UNCOMPRESSED_SIZE 27 | ||
365 | #define UVC_DT_FRAME_UNCOMPRESSED_SIZE(n) (26+4*(n)) | ||
366 | #define UVC_DT_FORMAT_MJPEG_SIZE 11 | ||
367 | #define UVC_DT_FRAME_MJPEG_SIZE(n) (26+4*(n)) | ||
368 | #define UVC_DT_COLOR_MATCHING_SIZE 6 | ||
369 | 19 | ||
370 | extern int uvc_bind_config(struct usb_configuration *c, | 20 | extern int uvc_bind_config(struct usb_configuration *c, |
371 | const struct uvc_descriptor_header * const *control, | 21 | const struct uvc_descriptor_header * const *control, |
diff --git a/drivers/usb/gadget/uvc.h b/drivers/usb/gadget/uvc.h index e92454cddd7d..5b7919460fd2 100644 --- a/drivers/usb/gadget/uvc.h +++ b/drivers/usb/gadget/uvc.h | |||
@@ -48,39 +48,6 @@ struct uvc_event | |||
48 | #define UVC_INTF_STREAMING 1 | 48 | #define UVC_INTF_STREAMING 1 |
49 | 49 | ||
50 | /* ------------------------------------------------------------------------ | 50 | /* ------------------------------------------------------------------------ |
51 | * UVC constants & structures | ||
52 | */ | ||
53 | |||
54 | /* Values for bmHeaderInfo (Video and Still Image Payload Headers, 2.4.3.3) */ | ||
55 | #define UVC_STREAM_EOH (1 << 7) | ||
56 | #define UVC_STREAM_ERR (1 << 6) | ||
57 | #define UVC_STREAM_STI (1 << 5) | ||
58 | #define UVC_STREAM_RES (1 << 4) | ||
59 | #define UVC_STREAM_SCR (1 << 3) | ||
60 | #define UVC_STREAM_PTS (1 << 2) | ||
61 | #define UVC_STREAM_EOF (1 << 1) | ||
62 | #define UVC_STREAM_FID (1 << 0) | ||
63 | |||
64 | struct uvc_streaming_control { | ||
65 | __u16 bmHint; | ||
66 | __u8 bFormatIndex; | ||
67 | __u8 bFrameIndex; | ||
68 | __u32 dwFrameInterval; | ||
69 | __u16 wKeyFrameRate; | ||
70 | __u16 wPFrameRate; | ||
71 | __u16 wCompQuality; | ||
72 | __u16 wCompWindowSize; | ||
73 | __u16 wDelay; | ||
74 | __u32 dwMaxVideoFrameSize; | ||
75 | __u32 dwMaxPayloadTransferSize; | ||
76 | __u32 dwClockFrequency; | ||
77 | __u8 bmFramingInfo; | ||
78 | __u8 bPreferedVersion; | ||
79 | __u8 bMinVersion; | ||
80 | __u8 bMaxVersion; | ||
81 | } __attribute__((__packed__)); | ||
82 | |||
83 | /* ------------------------------------------------------------------------ | ||
84 | * Debugging, printing and logging | 51 | * Debugging, printing and logging |
85 | */ | 52 | */ |
86 | 53 | ||
@@ -137,9 +104,6 @@ extern unsigned int uvc_gadget_trace_param; | |||
137 | #define UVC_MAX_REQUEST_SIZE 64 | 104 | #define UVC_MAX_REQUEST_SIZE 64 |
138 | #define UVC_MAX_EVENTS 4 | 105 | #define UVC_MAX_EVENTS 4 |
139 | 106 | ||
140 | #define USB_DT_INTERFACE_ASSOCIATION_SIZE 8 | ||
141 | #define USB_CLASS_MISC 0xef | ||
142 | |||
143 | /* ------------------------------------------------------------------------ | 107 | /* ------------------------------------------------------------------------ |
144 | * Structures | 108 | * Structures |
145 | */ | 109 | */ |
diff --git a/drivers/usb/gadget/webcam.c b/drivers/usb/gadget/webcam.c index f5f3030cc416..288d21155abe 100644 --- a/drivers/usb/gadget/webcam.c +++ b/drivers/usb/gadget/webcam.c | |||
@@ -90,7 +90,7 @@ DECLARE_UVC_HEADER_DESCRIPTOR(1); | |||
90 | static const struct UVC_HEADER_DESCRIPTOR(1) uvc_control_header = { | 90 | static const struct UVC_HEADER_DESCRIPTOR(1) uvc_control_header = { |
91 | .bLength = UVC_DT_HEADER_SIZE(1), | 91 | .bLength = UVC_DT_HEADER_SIZE(1), |
92 | .bDescriptorType = USB_DT_CS_INTERFACE, | 92 | .bDescriptorType = USB_DT_CS_INTERFACE, |
93 | .bDescriptorSubType = UVC_DT_HEADER, | 93 | .bDescriptorSubType = UVC_VC_HEADER, |
94 | .bcdUVC = cpu_to_le16(0x0100), | 94 | .bcdUVC = cpu_to_le16(0x0100), |
95 | .wTotalLength = 0, /* dynamic */ | 95 | .wTotalLength = 0, /* dynamic */ |
96 | .dwClockFrequency = cpu_to_le32(48000000), | 96 | .dwClockFrequency = cpu_to_le32(48000000), |
@@ -101,7 +101,7 @@ static const struct UVC_HEADER_DESCRIPTOR(1) uvc_control_header = { | |||
101 | static const struct uvc_camera_terminal_descriptor uvc_camera_terminal = { | 101 | static const struct uvc_camera_terminal_descriptor uvc_camera_terminal = { |
102 | .bLength = UVC_DT_CAMERA_TERMINAL_SIZE(3), | 102 | .bLength = UVC_DT_CAMERA_TERMINAL_SIZE(3), |
103 | .bDescriptorType = USB_DT_CS_INTERFACE, | 103 | .bDescriptorType = USB_DT_CS_INTERFACE, |
104 | .bDescriptorSubType = UVC_DT_INPUT_TERMINAL, | 104 | .bDescriptorSubType = UVC_VC_INPUT_TERMINAL, |
105 | .bTerminalID = 1, | 105 | .bTerminalID = 1, |
106 | .wTerminalType = cpu_to_le16(0x0201), | 106 | .wTerminalType = cpu_to_le16(0x0201), |
107 | .bAssocTerminal = 0, | 107 | .bAssocTerminal = 0, |
@@ -118,7 +118,7 @@ static const struct uvc_camera_terminal_descriptor uvc_camera_terminal = { | |||
118 | static const struct uvc_processing_unit_descriptor uvc_processing = { | 118 | static const struct uvc_processing_unit_descriptor uvc_processing = { |
119 | .bLength = UVC_DT_PROCESSING_UNIT_SIZE(2), | 119 | .bLength = UVC_DT_PROCESSING_UNIT_SIZE(2), |
120 | .bDescriptorType = USB_DT_CS_INTERFACE, | 120 | .bDescriptorType = USB_DT_CS_INTERFACE, |
121 | .bDescriptorSubType = UVC_DT_PROCESSING_UNIT, | 121 | .bDescriptorSubType = UVC_VC_PROCESSING_UNIT, |
122 | .bUnitID = 2, | 122 | .bUnitID = 2, |
123 | .bSourceID = 1, | 123 | .bSourceID = 1, |
124 | .wMaxMultiplier = cpu_to_le16(16*1024), | 124 | .wMaxMultiplier = cpu_to_le16(16*1024), |
@@ -131,7 +131,7 @@ static const struct uvc_processing_unit_descriptor uvc_processing = { | |||
131 | static const struct uvc_output_terminal_descriptor uvc_output_terminal = { | 131 | static const struct uvc_output_terminal_descriptor uvc_output_terminal = { |
132 | .bLength = UVC_DT_OUTPUT_TERMINAL_SIZE, | 132 | .bLength = UVC_DT_OUTPUT_TERMINAL_SIZE, |
133 | .bDescriptorType = USB_DT_CS_INTERFACE, | 133 | .bDescriptorType = USB_DT_CS_INTERFACE, |
134 | .bDescriptorSubType = UVC_DT_OUTPUT_TERMINAL, | 134 | .bDescriptorSubType = UVC_VC_OUTPUT_TERMINAL, |
135 | .bTerminalID = 3, | 135 | .bTerminalID = 3, |
136 | .wTerminalType = cpu_to_le16(0x0101), | 136 | .wTerminalType = cpu_to_le16(0x0101), |
137 | .bAssocTerminal = 0, | 137 | .bAssocTerminal = 0, |
@@ -144,7 +144,7 @@ DECLARE_UVC_INPUT_HEADER_DESCRIPTOR(1, 2); | |||
144 | static const struct UVC_INPUT_HEADER_DESCRIPTOR(1, 2) uvc_input_header = { | 144 | static const struct UVC_INPUT_HEADER_DESCRIPTOR(1, 2) uvc_input_header = { |
145 | .bLength = UVC_DT_INPUT_HEADER_SIZE(1, 2), | 145 | .bLength = UVC_DT_INPUT_HEADER_SIZE(1, 2), |
146 | .bDescriptorType = USB_DT_CS_INTERFACE, | 146 | .bDescriptorType = USB_DT_CS_INTERFACE, |
147 | .bDescriptorSubType = UVC_DT_INPUT_HEADER, | 147 | .bDescriptorSubType = UVC_VS_INPUT_HEADER, |
148 | .bNumFormats = 2, | 148 | .bNumFormats = 2, |
149 | .wTotalLength = 0, /* dynamic */ | 149 | .wTotalLength = 0, /* dynamic */ |
150 | .bEndpointAddress = 0, /* dynamic */ | 150 | .bEndpointAddress = 0, /* dynamic */ |
@@ -161,7 +161,7 @@ static const struct UVC_INPUT_HEADER_DESCRIPTOR(1, 2) uvc_input_header = { | |||
161 | static const struct uvc_format_uncompressed uvc_format_yuv = { | 161 | static const struct uvc_format_uncompressed uvc_format_yuv = { |
162 | .bLength = UVC_DT_FORMAT_UNCOMPRESSED_SIZE, | 162 | .bLength = UVC_DT_FORMAT_UNCOMPRESSED_SIZE, |
163 | .bDescriptorType = USB_DT_CS_INTERFACE, | 163 | .bDescriptorType = USB_DT_CS_INTERFACE, |
164 | .bDescriptorSubType = UVC_DT_FORMAT_UNCOMPRESSED, | 164 | .bDescriptorSubType = UVC_VS_FORMAT_UNCOMPRESSED, |
165 | .bFormatIndex = 1, | 165 | .bFormatIndex = 1, |
166 | .bNumFrameDescriptors = 2, | 166 | .bNumFrameDescriptors = 2, |
167 | .guidFormat = | 167 | .guidFormat = |
@@ -181,7 +181,7 @@ DECLARE_UVC_FRAME_UNCOMPRESSED(3); | |||
181 | static const struct UVC_FRAME_UNCOMPRESSED(3) uvc_frame_yuv_360p = { | 181 | static const struct UVC_FRAME_UNCOMPRESSED(3) uvc_frame_yuv_360p = { |
182 | .bLength = UVC_DT_FRAME_UNCOMPRESSED_SIZE(3), | 182 | .bLength = UVC_DT_FRAME_UNCOMPRESSED_SIZE(3), |
183 | .bDescriptorType = USB_DT_CS_INTERFACE, | 183 | .bDescriptorType = USB_DT_CS_INTERFACE, |
184 | .bDescriptorSubType = UVC_DT_FRAME_UNCOMPRESSED, | 184 | .bDescriptorSubType = UVC_VS_FRAME_UNCOMPRESSED, |
185 | .bFrameIndex = 1, | 185 | .bFrameIndex = 1, |
186 | .bmCapabilities = 0, | 186 | .bmCapabilities = 0, |
187 | .wWidth = cpu_to_le16(640), | 187 | .wWidth = cpu_to_le16(640), |
@@ -199,7 +199,7 @@ static const struct UVC_FRAME_UNCOMPRESSED(3) uvc_frame_yuv_360p = { | |||
199 | static const struct UVC_FRAME_UNCOMPRESSED(1) uvc_frame_yuv_720p = { | 199 | static const struct UVC_FRAME_UNCOMPRESSED(1) uvc_frame_yuv_720p = { |
200 | .bLength = UVC_DT_FRAME_UNCOMPRESSED_SIZE(1), | 200 | .bLength = UVC_DT_FRAME_UNCOMPRESSED_SIZE(1), |
201 | .bDescriptorType = USB_DT_CS_INTERFACE, | 201 | .bDescriptorType = USB_DT_CS_INTERFACE, |
202 | .bDescriptorSubType = UVC_DT_FRAME_UNCOMPRESSED, | 202 | .bDescriptorSubType = UVC_VS_FRAME_UNCOMPRESSED, |
203 | .bFrameIndex = 2, | 203 | .bFrameIndex = 2, |
204 | .bmCapabilities = 0, | 204 | .bmCapabilities = 0, |
205 | .wWidth = cpu_to_le16(1280), | 205 | .wWidth = cpu_to_le16(1280), |
@@ -215,7 +215,7 @@ static const struct UVC_FRAME_UNCOMPRESSED(1) uvc_frame_yuv_720p = { | |||
215 | static const struct uvc_format_mjpeg uvc_format_mjpg = { | 215 | static const struct uvc_format_mjpeg uvc_format_mjpg = { |
216 | .bLength = UVC_DT_FORMAT_MJPEG_SIZE, | 216 | .bLength = UVC_DT_FORMAT_MJPEG_SIZE, |
217 | .bDescriptorType = USB_DT_CS_INTERFACE, | 217 | .bDescriptorType = USB_DT_CS_INTERFACE, |
218 | .bDescriptorSubType = UVC_DT_FORMAT_MJPEG, | 218 | .bDescriptorSubType = UVC_VS_FORMAT_MJPEG, |
219 | .bFormatIndex = 2, | 219 | .bFormatIndex = 2, |
220 | .bNumFrameDescriptors = 2, | 220 | .bNumFrameDescriptors = 2, |
221 | .bmFlags = 0, | 221 | .bmFlags = 0, |
@@ -232,7 +232,7 @@ DECLARE_UVC_FRAME_MJPEG(3); | |||
232 | static const struct UVC_FRAME_MJPEG(3) uvc_frame_mjpg_360p = { | 232 | static const struct UVC_FRAME_MJPEG(3) uvc_frame_mjpg_360p = { |
233 | .bLength = UVC_DT_FRAME_MJPEG_SIZE(3), | 233 | .bLength = UVC_DT_FRAME_MJPEG_SIZE(3), |
234 | .bDescriptorType = USB_DT_CS_INTERFACE, | 234 | .bDescriptorType = USB_DT_CS_INTERFACE, |
235 | .bDescriptorSubType = UVC_DT_FRAME_MJPEG, | 235 | .bDescriptorSubType = UVC_VS_FRAME_MJPEG, |
236 | .bFrameIndex = 1, | 236 | .bFrameIndex = 1, |
237 | .bmCapabilities = 0, | 237 | .bmCapabilities = 0, |
238 | .wWidth = cpu_to_le16(640), | 238 | .wWidth = cpu_to_le16(640), |
@@ -250,7 +250,7 @@ static const struct UVC_FRAME_MJPEG(3) uvc_frame_mjpg_360p = { | |||
250 | static const struct UVC_FRAME_MJPEG(1) uvc_frame_mjpg_720p = { | 250 | static const struct UVC_FRAME_MJPEG(1) uvc_frame_mjpg_720p = { |
251 | .bLength = UVC_DT_FRAME_MJPEG_SIZE(1), | 251 | .bLength = UVC_DT_FRAME_MJPEG_SIZE(1), |
252 | .bDescriptorType = USB_DT_CS_INTERFACE, | 252 | .bDescriptorType = USB_DT_CS_INTERFACE, |
253 | .bDescriptorSubType = UVC_DT_FRAME_MJPEG, | 253 | .bDescriptorSubType = UVC_VS_FRAME_MJPEG, |
254 | .bFrameIndex = 2, | 254 | .bFrameIndex = 2, |
255 | .bmCapabilities = 0, | 255 | .bmCapabilities = 0, |
256 | .wWidth = cpu_to_le16(1280), | 256 | .wWidth = cpu_to_le16(1280), |
@@ -266,7 +266,7 @@ static const struct UVC_FRAME_MJPEG(1) uvc_frame_mjpg_720p = { | |||
266 | static const struct uvc_color_matching_descriptor uvc_color_matching = { | 266 | static const struct uvc_color_matching_descriptor uvc_color_matching = { |
267 | .bLength = UVC_DT_COLOR_MATCHING_SIZE, | 267 | .bLength = UVC_DT_COLOR_MATCHING_SIZE, |
268 | .bDescriptorType = USB_DT_CS_INTERFACE, | 268 | .bDescriptorType = USB_DT_CS_INTERFACE, |
269 | .bDescriptorSubType = UVC_DT_COLOR_MATCHING, | 269 | .bDescriptorSubType = UVC_VS_COLORFORMAT, |
270 | .bColorPrimaries = 1, | 270 | .bColorPrimaries = 1, |
271 | .bTransferCharacteristics = 1, | 271 | .bTransferCharacteristics = 1, |
272 | .bMatrixCoefficients = 4, | 272 | .bMatrixCoefficients = 4, |
diff --git a/include/linux/usb/video.h b/include/linux/usb/video.h index 2d5b7fc6a265..3b3b95e01f71 100644 --- a/include/linux/usb/video.h +++ b/include/linux/usb/video.h | |||
@@ -160,6 +160,16 @@ | |||
160 | #define UVC_STATUS_TYPE_CONTROL 1 | 160 | #define UVC_STATUS_TYPE_CONTROL 1 |
161 | #define UVC_STATUS_TYPE_STREAMING 2 | 161 | #define UVC_STATUS_TYPE_STREAMING 2 |
162 | 162 | ||
163 | /* 2.4.3.3. Payload Header Information */ | ||
164 | #define UVC_STREAM_EOH (1 << 7) | ||
165 | #define UVC_STREAM_ERR (1 << 6) | ||
166 | #define UVC_STREAM_STI (1 << 5) | ||
167 | #define UVC_STREAM_RES (1 << 4) | ||
168 | #define UVC_STREAM_SCR (1 << 3) | ||
169 | #define UVC_STREAM_PTS (1 << 2) | ||
170 | #define UVC_STREAM_EOF (1 << 1) | ||
171 | #define UVC_STREAM_FID (1 << 0) | ||
172 | |||
163 | /* 4.1.2. Control Capabilities */ | 173 | /* 4.1.2. Control Capabilities */ |
164 | #define UVC_CONTROL_CAP_GET (1 << 0) | 174 | #define UVC_CONTROL_CAP_GET (1 << 0) |
165 | #define UVC_CONTROL_CAP_SET (1 << 1) | 175 | #define UVC_CONTROL_CAP_SET (1 << 1) |
@@ -167,5 +177,392 @@ | |||
167 | #define UVC_CONTROL_CAP_AUTOUPDATE (1 << 3) | 177 | #define UVC_CONTROL_CAP_AUTOUPDATE (1 << 3) |
168 | #define UVC_CONTROL_CAP_ASYNCHRONOUS (1 << 4) | 178 | #define UVC_CONTROL_CAP_ASYNCHRONOUS (1 << 4) |
169 | 179 | ||
180 | /* ------------------------------------------------------------------------ | ||
181 | * UVC structures | ||
182 | */ | ||
183 | |||
184 | /* All UVC descriptors have these 3 fields at the beginning */ | ||
185 | struct uvc_descriptor_header { | ||
186 | __u8 bLength; | ||
187 | __u8 bDescriptorType; | ||
188 | __u8 bDescriptorSubType; | ||
189 | } __attribute__((packed)); | ||
190 | |||
191 | /* 3.7.2. Video Control Interface Header Descriptor */ | ||
192 | struct uvc_header_descriptor { | ||
193 | __u8 bLength; | ||
194 | __u8 bDescriptorType; | ||
195 | __u8 bDescriptorSubType; | ||
196 | __u16 bcdUVC; | ||
197 | __u16 wTotalLength; | ||
198 | __u32 dwClockFrequency; | ||
199 | __u8 bInCollection; | ||
200 | __u8 baInterfaceNr[]; | ||
201 | } __attribute__((__packed__)); | ||
202 | |||
203 | #define UVC_DT_HEADER_SIZE(n) (12+(n)) | ||
204 | |||
205 | #define UVC_HEADER_DESCRIPTOR(n) \ | ||
206 | uvc_header_descriptor_##n | ||
207 | |||
208 | #define DECLARE_UVC_HEADER_DESCRIPTOR(n) \ | ||
209 | struct UVC_HEADER_DESCRIPTOR(n) { \ | ||
210 | __u8 bLength; \ | ||
211 | __u8 bDescriptorType; \ | ||
212 | __u8 bDescriptorSubType; \ | ||
213 | __u16 bcdUVC; \ | ||
214 | __u16 wTotalLength; \ | ||
215 | __u32 dwClockFrequency; \ | ||
216 | __u8 bInCollection; \ | ||
217 | __u8 baInterfaceNr[n]; \ | ||
218 | } __attribute__ ((packed)) | ||
219 | |||
220 | /* 3.7.2.1. Input Terminal Descriptor */ | ||
221 | struct uvc_input_terminal_descriptor { | ||
222 | __u8 bLength; | ||
223 | __u8 bDescriptorType; | ||
224 | __u8 bDescriptorSubType; | ||
225 | __u8 bTerminalID; | ||
226 | __u16 wTerminalType; | ||
227 | __u8 bAssocTerminal; | ||
228 | __u8 iTerminal; | ||
229 | } __attribute__((__packed__)); | ||
230 | |||
231 | #define UVC_DT_INPUT_TERMINAL_SIZE 8 | ||
232 | |||
233 | /* 3.7.2.2. Output Terminal Descriptor */ | ||
234 | struct uvc_output_terminal_descriptor { | ||
235 | __u8 bLength; | ||
236 | __u8 bDescriptorType; | ||
237 | __u8 bDescriptorSubType; | ||
238 | __u8 bTerminalID; | ||
239 | __u16 wTerminalType; | ||
240 | __u8 bAssocTerminal; | ||
241 | __u8 bSourceID; | ||
242 | __u8 iTerminal; | ||
243 | } __attribute__((__packed__)); | ||
244 | |||
245 | #define UVC_DT_OUTPUT_TERMINAL_SIZE 9 | ||
246 | |||
247 | /* 3.7.2.3. Camera Terminal Descriptor */ | ||
248 | struct uvc_camera_terminal_descriptor { | ||
249 | __u8 bLength; | ||
250 | __u8 bDescriptorType; | ||
251 | __u8 bDescriptorSubType; | ||
252 | __u8 bTerminalID; | ||
253 | __u16 wTerminalType; | ||
254 | __u8 bAssocTerminal; | ||
255 | __u8 iTerminal; | ||
256 | __u16 wObjectiveFocalLengthMin; | ||
257 | __u16 wObjectiveFocalLengthMax; | ||
258 | __u16 wOcularFocalLength; | ||
259 | __u8 bControlSize; | ||
260 | __u8 bmControls[3]; | ||
261 | } __attribute__((__packed__)); | ||
262 | |||
263 | #define UVC_DT_CAMERA_TERMINAL_SIZE(n) (15+(n)) | ||
264 | |||
265 | /* 3.7.2.4. Selector Unit Descriptor */ | ||
266 | struct uvc_selector_unit_descriptor { | ||
267 | __u8 bLength; | ||
268 | __u8 bDescriptorType; | ||
269 | __u8 bDescriptorSubType; | ||
270 | __u8 bUnitID; | ||
271 | __u8 bNrInPins; | ||
272 | __u8 baSourceID[0]; | ||
273 | __u8 iSelector; | ||
274 | } __attribute__((__packed__)); | ||
275 | |||
276 | #define UVC_DT_SELECTOR_UNIT_SIZE(n) (6+(n)) | ||
277 | |||
278 | #define UVC_SELECTOR_UNIT_DESCRIPTOR(n) \ | ||
279 | uvc_selector_unit_descriptor_##n | ||
280 | |||
281 | #define DECLARE_UVC_SELECTOR_UNIT_DESCRIPTOR(n) \ | ||
282 | struct UVC_SELECTOR_UNIT_DESCRIPTOR(n) { \ | ||
283 | __u8 bLength; \ | ||
284 | __u8 bDescriptorType; \ | ||
285 | __u8 bDescriptorSubType; \ | ||
286 | __u8 bUnitID; \ | ||
287 | __u8 bNrInPins; \ | ||
288 | __u8 baSourceID[n]; \ | ||
289 | __u8 iSelector; \ | ||
290 | } __attribute__ ((packed)) | ||
291 | |||
292 | /* 3.7.2.5. Processing Unit Descriptor */ | ||
293 | struct uvc_processing_unit_descriptor { | ||
294 | __u8 bLength; | ||
295 | __u8 bDescriptorType; | ||
296 | __u8 bDescriptorSubType; | ||
297 | __u8 bUnitID; | ||
298 | __u8 bSourceID; | ||
299 | __u16 wMaxMultiplier; | ||
300 | __u8 bControlSize; | ||
301 | __u8 bmControls[2]; | ||
302 | __u8 iProcessing; | ||
303 | } __attribute__((__packed__)); | ||
304 | |||
305 | #define UVC_DT_PROCESSING_UNIT_SIZE(n) (9+(n)) | ||
306 | |||
307 | /* 3.7.2.6. Extension Unit Descriptor */ | ||
308 | struct uvc_extension_unit_descriptor { | ||
309 | __u8 bLength; | ||
310 | __u8 bDescriptorType; | ||
311 | __u8 bDescriptorSubType; | ||
312 | __u8 bUnitID; | ||
313 | __u8 guidExtensionCode[16]; | ||
314 | __u8 bNumControls; | ||
315 | __u8 bNrInPins; | ||
316 | __u8 baSourceID[0]; | ||
317 | __u8 bControlSize; | ||
318 | __u8 bmControls[0]; | ||
319 | __u8 iExtension; | ||
320 | } __attribute__((__packed__)); | ||
321 | |||
322 | #define UVC_DT_EXTENSION_UNIT_SIZE(p, n) (24+(p)+(n)) | ||
323 | |||
324 | #define UVC_EXTENSION_UNIT_DESCRIPTOR(p, n) \ | ||
325 | uvc_extension_unit_descriptor_##p_##n | ||
326 | |||
327 | #define DECLARE_UVC_EXTENSION_UNIT_DESCRIPTOR(p, n) \ | ||
328 | struct UVC_EXTENSION_UNIT_DESCRIPTOR(p, n) { \ | ||
329 | __u8 bLength; \ | ||
330 | __u8 bDescriptorType; \ | ||
331 | __u8 bDescriptorSubType; \ | ||
332 | __u8 bUnitID; \ | ||
333 | __u8 guidExtensionCode[16]; \ | ||
334 | __u8 bNumControls; \ | ||
335 | __u8 bNrInPins; \ | ||
336 | __u8 baSourceID[p]; \ | ||
337 | __u8 bControlSize; \ | ||
338 | __u8 bmControls[n]; \ | ||
339 | __u8 iExtension; \ | ||
340 | } __attribute__ ((packed)) | ||
341 | |||
342 | /* 3.8.2.2. Video Control Interrupt Endpoint Descriptor */ | ||
343 | struct uvc_control_endpoint_descriptor { | ||
344 | __u8 bLength; | ||
345 | __u8 bDescriptorType; | ||
346 | __u8 bDescriptorSubType; | ||
347 | __u16 wMaxTransferSize; | ||
348 | } __attribute__((__packed__)); | ||
349 | |||
350 | #define UVC_DT_CONTROL_ENDPOINT_SIZE 5 | ||
351 | |||
352 | /* 3.9.2.1. Input Header Descriptor */ | ||
353 | struct uvc_input_header_descriptor { | ||
354 | __u8 bLength; | ||
355 | __u8 bDescriptorType; | ||
356 | __u8 bDescriptorSubType; | ||
357 | __u8 bNumFormats; | ||
358 | __u16 wTotalLength; | ||
359 | __u8 bEndpointAddress; | ||
360 | __u8 bmInfo; | ||
361 | __u8 bTerminalLink; | ||
362 | __u8 bStillCaptureMethod; | ||
363 | __u8 bTriggerSupport; | ||
364 | __u8 bTriggerUsage; | ||
365 | __u8 bControlSize; | ||
366 | __u8 bmaControls[]; | ||
367 | } __attribute__((__packed__)); | ||
368 | |||
369 | #define UVC_DT_INPUT_HEADER_SIZE(n, p) (13+(n*p)) | ||
370 | |||
371 | #define UVC_INPUT_HEADER_DESCRIPTOR(n, p) \ | ||
372 | uvc_input_header_descriptor_##n_##p | ||
373 | |||
374 | #define DECLARE_UVC_INPUT_HEADER_DESCRIPTOR(n, p) \ | ||
375 | struct UVC_INPUT_HEADER_DESCRIPTOR(n, p) { \ | ||
376 | __u8 bLength; \ | ||
377 | __u8 bDescriptorType; \ | ||
378 | __u8 bDescriptorSubType; \ | ||
379 | __u8 bNumFormats; \ | ||
380 | __u16 wTotalLength; \ | ||
381 | __u8 bEndpointAddress; \ | ||
382 | __u8 bmInfo; \ | ||
383 | __u8 bTerminalLink; \ | ||
384 | __u8 bStillCaptureMethod; \ | ||
385 | __u8 bTriggerSupport; \ | ||
386 | __u8 bTriggerUsage; \ | ||
387 | __u8 bControlSize; \ | ||
388 | __u8 bmaControls[p][n]; \ | ||
389 | } __attribute__ ((packed)) | ||
390 | |||
391 | /* 3.9.2.2. Output Header Descriptor */ | ||
392 | struct uvc_output_header_descriptor { | ||
393 | __u8 bLength; | ||
394 | __u8 bDescriptorType; | ||
395 | __u8 bDescriptorSubType; | ||
396 | __u8 bNumFormats; | ||
397 | __u16 wTotalLength; | ||
398 | __u8 bEndpointAddress; | ||
399 | __u8 bTerminalLink; | ||
400 | __u8 bControlSize; | ||
401 | __u8 bmaControls[]; | ||
402 | } __attribute__((__packed__)); | ||
403 | |||
404 | #define UVC_DT_OUTPUT_HEADER_SIZE(n, p) (9+(n*p)) | ||
405 | |||
406 | #define UVC_OUTPUT_HEADER_DESCRIPTOR(n, p) \ | ||
407 | uvc_output_header_descriptor_##n_##p | ||
408 | |||
409 | #define DECLARE_UVC_OUTPUT_HEADER_DESCRIPTOR(n, p) \ | ||
410 | struct UVC_OUTPUT_HEADER_DESCRIPTOR(n, p) { \ | ||
411 | __u8 bLength; \ | ||
412 | __u8 bDescriptorType; \ | ||
413 | __u8 bDescriptorSubType; \ | ||
414 | __u8 bNumFormats; \ | ||
415 | __u16 wTotalLength; \ | ||
416 | __u8 bEndpointAddress; \ | ||
417 | __u8 bTerminalLink; \ | ||
418 | __u8 bControlSize; \ | ||
419 | __u8 bmaControls[p][n]; \ | ||
420 | } __attribute__ ((packed)) | ||
421 | |||
422 | /* 3.9.2.6. Color matching descriptor */ | ||
423 | struct uvc_color_matching_descriptor { | ||
424 | __u8 bLength; | ||
425 | __u8 bDescriptorType; | ||
426 | __u8 bDescriptorSubType; | ||
427 | __u8 bColorPrimaries; | ||
428 | __u8 bTransferCharacteristics; | ||
429 | __u8 bMatrixCoefficients; | ||
430 | } __attribute__((__packed__)); | ||
431 | |||
432 | #define UVC_DT_COLOR_MATCHING_SIZE 6 | ||
433 | |||
434 | /* 4.3.1.1. Video Probe and Commit Controls */ | ||
435 | struct uvc_streaming_control { | ||
436 | __u16 bmHint; | ||
437 | __u8 bFormatIndex; | ||
438 | __u8 bFrameIndex; | ||
439 | __u32 dwFrameInterval; | ||
440 | __u16 wKeyFrameRate; | ||
441 | __u16 wPFrameRate; | ||
442 | __u16 wCompQuality; | ||
443 | __u16 wCompWindowSize; | ||
444 | __u16 wDelay; | ||
445 | __u32 dwMaxVideoFrameSize; | ||
446 | __u32 dwMaxPayloadTransferSize; | ||
447 | __u32 dwClockFrequency; | ||
448 | __u8 bmFramingInfo; | ||
449 | __u8 bPreferedVersion; | ||
450 | __u8 bMinVersion; | ||
451 | __u8 bMaxVersion; | ||
452 | } __attribute__((__packed__)); | ||
453 | |||
454 | /* Uncompressed Payload - 3.1.1. Uncompressed Video Format Descriptor */ | ||
455 | struct uvc_format_uncompressed { | ||
456 | __u8 bLength; | ||
457 | __u8 bDescriptorType; | ||
458 | __u8 bDescriptorSubType; | ||
459 | __u8 bFormatIndex; | ||
460 | __u8 bNumFrameDescriptors; | ||
461 | __u8 guidFormat[16]; | ||
462 | __u8 bBitsPerPixel; | ||
463 | __u8 bDefaultFrameIndex; | ||
464 | __u8 bAspectRatioX; | ||
465 | __u8 bAspectRatioY; | ||
466 | __u8 bmInterfaceFlags; | ||
467 | __u8 bCopyProtect; | ||
468 | } __attribute__((__packed__)); | ||
469 | |||
470 | #define UVC_DT_FORMAT_UNCOMPRESSED_SIZE 27 | ||
471 | |||
472 | /* Uncompressed Payload - 3.1.2. Uncompressed Video Frame Descriptor */ | ||
473 | struct uvc_frame_uncompressed { | ||
474 | __u8 bLength; | ||
475 | __u8 bDescriptorType; | ||
476 | __u8 bDescriptorSubType; | ||
477 | __u8 bFrameIndex; | ||
478 | __u8 bmCapabilities; | ||
479 | __u16 wWidth; | ||
480 | __u16 wHeight; | ||
481 | __u32 dwMinBitRate; | ||
482 | __u32 dwMaxBitRate; | ||
483 | __u32 dwMaxVideoFrameBufferSize; | ||
484 | __u32 dwDefaultFrameInterval; | ||
485 | __u8 bFrameIntervalType; | ||
486 | __u32 dwFrameInterval[]; | ||
487 | } __attribute__((__packed__)); | ||
488 | |||
489 | #define UVC_DT_FRAME_UNCOMPRESSED_SIZE(n) (26+4*(n)) | ||
490 | |||
491 | #define UVC_FRAME_UNCOMPRESSED(n) \ | ||
492 | uvc_frame_uncompressed_##n | ||
493 | |||
494 | #define DECLARE_UVC_FRAME_UNCOMPRESSED(n) \ | ||
495 | struct UVC_FRAME_UNCOMPRESSED(n) { \ | ||
496 | __u8 bLength; \ | ||
497 | __u8 bDescriptorType; \ | ||
498 | __u8 bDescriptorSubType; \ | ||
499 | __u8 bFrameIndex; \ | ||
500 | __u8 bmCapabilities; \ | ||
501 | __u16 wWidth; \ | ||
502 | __u16 wHeight; \ | ||
503 | __u32 dwMinBitRate; \ | ||
504 | __u32 dwMaxBitRate; \ | ||
505 | __u32 dwMaxVideoFrameBufferSize; \ | ||
506 | __u32 dwDefaultFrameInterval; \ | ||
507 | __u8 bFrameIntervalType; \ | ||
508 | __u32 dwFrameInterval[n]; \ | ||
509 | } __attribute__ ((packed)) | ||
510 | |||
511 | /* MJPEG Payload - 3.1.1. MJPEG Video Format Descriptor */ | ||
512 | struct uvc_format_mjpeg { | ||
513 | __u8 bLength; | ||
514 | __u8 bDescriptorType; | ||
515 | __u8 bDescriptorSubType; | ||
516 | __u8 bFormatIndex; | ||
517 | __u8 bNumFrameDescriptors; | ||
518 | __u8 bmFlags; | ||
519 | __u8 bDefaultFrameIndex; | ||
520 | __u8 bAspectRatioX; | ||
521 | __u8 bAspectRatioY; | ||
522 | __u8 bmInterfaceFlags; | ||
523 | __u8 bCopyProtect; | ||
524 | } __attribute__((__packed__)); | ||
525 | |||
526 | #define UVC_DT_FORMAT_MJPEG_SIZE 11 | ||
527 | |||
528 | /* MJPEG Payload - 3.1.2. MJPEG Video Frame Descriptor */ | ||
529 | struct uvc_frame_mjpeg { | ||
530 | __u8 bLength; | ||
531 | __u8 bDescriptorType; | ||
532 | __u8 bDescriptorSubType; | ||
533 | __u8 bFrameIndex; | ||
534 | __u8 bmCapabilities; | ||
535 | __u16 wWidth; | ||
536 | __u16 wHeight; | ||
537 | __u32 dwMinBitRate; | ||
538 | __u32 dwMaxBitRate; | ||
539 | __u32 dwMaxVideoFrameBufferSize; | ||
540 | __u32 dwDefaultFrameInterval; | ||
541 | __u8 bFrameIntervalType; | ||
542 | __u32 dwFrameInterval[]; | ||
543 | } __attribute__((__packed__)); | ||
544 | |||
545 | #define UVC_DT_FRAME_MJPEG_SIZE(n) (26+4*(n)) | ||
546 | |||
547 | #define UVC_FRAME_MJPEG(n) \ | ||
548 | uvc_frame_mjpeg_##n | ||
549 | |||
550 | #define DECLARE_UVC_FRAME_MJPEG(n) \ | ||
551 | struct UVC_FRAME_MJPEG(n) { \ | ||
552 | __u8 bLength; \ | ||
553 | __u8 bDescriptorType; \ | ||
554 | __u8 bDescriptorSubType; \ | ||
555 | __u8 bFrameIndex; \ | ||
556 | __u8 bmCapabilities; \ | ||
557 | __u16 wWidth; \ | ||
558 | __u16 wHeight; \ | ||
559 | __u32 dwMinBitRate; \ | ||
560 | __u32 dwMaxBitRate; \ | ||
561 | __u32 dwMaxVideoFrameBufferSize; \ | ||
562 | __u32 dwDefaultFrameInterval; \ | ||
563 | __u8 bFrameIntervalType; \ | ||
564 | __u32 dwFrameInterval[n]; \ | ||
565 | } __attribute__ ((packed)) | ||
566 | |||
170 | #endif /* __LINUX_USB_VIDEO_H */ | 567 | #endif /* __LINUX_USB_VIDEO_H */ |
171 | 568 | ||