1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3 * v4l2 uvc internal API header
4 *
5 * Some commonly needed functions for uvc drivers
6 */
7
8 #ifndef __LINUX_V4L2_UVC_H
9 #define __LINUX_V4L2_UVC_H
10
11 /* ------------------------------------------------------------------------
12 * GUIDs
13 */
14 #define UVC_GUID_UVC_CAMERA \
15 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
16 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}
17 #define UVC_GUID_UVC_OUTPUT \
18 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
19 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02}
20 #define UVC_GUID_UVC_MEDIA_TRANSPORT_INPUT \
21 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
22 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03}
23 #define UVC_GUID_UVC_PROCESSING \
24 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
25 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01}
26 #define UVC_GUID_UVC_SELECTOR \
27 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
28 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02}
29 #define UVC_GUID_EXT_GPIO_CONTROLLER \
30 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
31 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03}
32
33 #define UVC_GUID_FORMAT_MJPEG \
34 { 'M', 'J', 'P', 'G', 0x00, 0x00, 0x10, 0x00, \
35 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
36 #define UVC_GUID_FORMAT_YUY2 \
37 { 'Y', 'U', 'Y', '2', 0x00, 0x00, 0x10, 0x00, \
38 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
39 #define UVC_GUID_FORMAT_YUY2_ISIGHT \
40 { 'Y', 'U', 'Y', '2', 0x00, 0x00, 0x10, 0x00, \
41 0x80, 0x00, 0x00, 0x00, 0x00, 0x38, 0x9b, 0x71}
42 #define UVC_GUID_FORMAT_NV12 \
43 { 'N', 'V', '1', '2', 0x00, 0x00, 0x10, 0x00, \
44 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
45 #define UVC_GUID_FORMAT_YV12 \
46 { 'Y', 'V', '1', '2', 0x00, 0x00, 0x10, 0x00, \
47 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
48 #define UVC_GUID_FORMAT_I420 \
49 { 'I', '4', '2', '0', 0x00, 0x00, 0x10, 0x00, \
50 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
51 #define UVC_GUID_FORMAT_UYVY \
52 { 'U', 'Y', 'V', 'Y', 0x00, 0x00, 0x10, 0x00, \
53 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
54 #define UVC_GUID_FORMAT_Y800 \
55 { 'Y', '8', '0', '0', 0x00, 0x00, 0x10, 0x00, \
56 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
57 #define UVC_GUID_FORMAT_Y8 \
58 { 'Y', '8', ' ', ' ', 0x00, 0x00, 0x10, 0x00, \
59 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
60 #define UVC_GUID_FORMAT_Y10 \
61 { 'Y', '1', '0', ' ', 0x00, 0x00, 0x10, 0x00, \
62 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
63 #define UVC_GUID_FORMAT_Y12 \
64 { 'Y', '1', '2', ' ', 0x00, 0x00, 0x10, 0x00, \
65 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
66 #define UVC_GUID_FORMAT_Y16 \
67 { 'Y', '1', '6', ' ', 0x00, 0x00, 0x10, 0x00, \
68 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
69 #define UVC_GUID_FORMAT_BY8 \
70 { 'B', 'Y', '8', ' ', 0x00, 0x00, 0x10, 0x00, \
71 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
72 #define UVC_GUID_FORMAT_BA81 \
73 { 'B', 'A', '8', '1', 0x00, 0x00, 0x10, 0x00, \
74 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
75 #define UVC_GUID_FORMAT_GBRG \
76 { 'G', 'B', 'R', 'G', 0x00, 0x00, 0x10, 0x00, \
77 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
78 #define UVC_GUID_FORMAT_GRBG \
79 { 'G', 'R', 'B', 'G', 0x00, 0x00, 0x10, 0x00, \
80 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
81 #define UVC_GUID_FORMAT_RGGB \
82 { 'R', 'G', 'G', 'B', 0x00, 0x00, 0x10, 0x00, \
83 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
84 #define UVC_GUID_FORMAT_BG16 \
85 { 'B', 'G', '1', '6', 0x00, 0x00, 0x10, 0x00, \
86 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
87 #define UVC_GUID_FORMAT_GB16 \
88 { 'G', 'B', '1', '6', 0x00, 0x00, 0x10, 0x00, \
89 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
90 #define UVC_GUID_FORMAT_RG16 \
91 { 'R', 'G', '1', '6', 0x00, 0x00, 0x10, 0x00, \
92 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
93 #define UVC_GUID_FORMAT_GR16 \
94 { 'G', 'R', '1', '6', 0x00, 0x00, 0x10, 0x00, \
95 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
96 #define UVC_GUID_FORMAT_RGBP \
97 { 'R', 'G', 'B', 'P', 0x00, 0x00, 0x10, 0x00, \
98 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
99 #define UVC_GUID_FORMAT_BGR3 \
100 { 0x7d, 0xeb, 0x36, 0xe4, 0x4f, 0x52, 0xce, 0x11, \
101 0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}
102 #define UVC_GUID_FORMAT_M420 \
103 { 'M', '4', '2', '0', 0x00, 0x00, 0x10, 0x00, \
104 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
105
106 #define UVC_GUID_FORMAT_H264 \
107 { 'H', '2', '6', '4', 0x00, 0x00, 0x10, 0x00, \
108 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
109 #define UVC_GUID_FORMAT_H265 \
110 { 'H', '2', '6', '5', 0x00, 0x00, 0x10, 0x00, \
111 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
112 #define UVC_GUID_FORMAT_Y8I \
113 { 'Y', '8', 'I', ' ', 0x00, 0x00, 0x10, 0x00, \
114 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
115 #define UVC_GUID_FORMAT_Y12I \
116 { 'Y', '1', '2', 'I', 0x00, 0x00, 0x10, 0x00, \
117 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
118 #define UVC_GUID_FORMAT_Z16 \
119 { 'Z', '1', '6', ' ', 0x00, 0x00, 0x10, 0x00, \
120 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
121 #define UVC_GUID_FORMAT_RW10 \
122 { 'R', 'W', '1', '0', 0x00, 0x00, 0x10, 0x00, \
123 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
124 #define UVC_GUID_FORMAT_INVZ \
125 { 'I', 'N', 'V', 'Z', 0x90, 0x2d, 0x58, 0x4a, \
126 0x92, 0x0b, 0x77, 0x3f, 0x1f, 0x2c, 0x55, 0x6b}
127 #define UVC_GUID_FORMAT_INZI \
128 { 'I', 'N', 'Z', 'I', 0x66, 0x1a, 0x42, 0xa2, \
129 0x90, 0x65, 0xd0, 0x18, 0x14, 0xa8, 0xef, 0x8a}
130 #define UVC_GUID_FORMAT_INVI \
131 { 'I', 'N', 'V', 'I', 0xdb, 0x57, 0x49, 0x5e, \
132 0x8e, 0x3f, 0xf4, 0x79, 0x53, 0x2b, 0x94, 0x6f}
133 #define UVC_GUID_FORMAT_CNF4 \
134 { 'C', ' ', ' ', ' ', 0x00, 0x00, 0x10, 0x00, \
135 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
136
137 #define UVC_GUID_FORMAT_D3DFMT_L8 \
138 {0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, \
139 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
140 #define UVC_GUID_FORMAT_KSMEDIA_L8_IR \
141 {0x32, 0x00, 0x00, 0x00, 0x02, 0x00, 0x10, 0x00, \
142 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
143
144 #define UVC_GUID_FORMAT_HEVC \
145 { 'H', 'E', 'V', 'C', 0x00, 0x00, 0x10, 0x00, \
146 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
147
148 /* ------------------------------------------------------------------------
149 * Video formats
150 */
151
152 struct uvc_format_desc {
153 char *name;
154 u8 guid[16];
155 u32 fcc;
156 };
157
158 static struct uvc_format_desc uvc_fmts[] = {
159 {
160 .name = "YUV 4:2:2 (YUYV)",
161 .guid = UVC_GUID_FORMAT_YUY2,
162 .fcc = V4L2_PIX_FMT_YUYV,
163 },
164 {
165 .name = "YUV 4:2:2 (YUYV)",
166 .guid = UVC_GUID_FORMAT_YUY2_ISIGHT,
167 .fcc = V4L2_PIX_FMT_YUYV,
168 },
169 {
170 .name = "YUV 4:2:0 (NV12)",
171 .guid = UVC_GUID_FORMAT_NV12,
172 .fcc = V4L2_PIX_FMT_NV12,
173 },
174 {
175 .name = "MJPEG",
176 .guid = UVC_GUID_FORMAT_MJPEG,
177 .fcc = V4L2_PIX_FMT_MJPEG,
178 },
179 {
180 .name = "YVU 4:2:0 (YV12)",
181 .guid = UVC_GUID_FORMAT_YV12,
182 .fcc = V4L2_PIX_FMT_YVU420,
183 },
184 {
185 .name = "YUV 4:2:0 (I420)",
186 .guid = UVC_GUID_FORMAT_I420,
187 .fcc = V4L2_PIX_FMT_YUV420,
188 },
189 {
190 .name = "YUV 4:2:0 (M420)",
191 .guid = UVC_GUID_FORMAT_M420,
192 .fcc = V4L2_PIX_FMT_M420,
193 },
194 {
195 .name = "YUV 4:2:2 (UYVY)",
196 .guid = UVC_GUID_FORMAT_UYVY,
197 .fcc = V4L2_PIX_FMT_UYVY,
198 },
199 {
200 .name = "Greyscale 8-bit (Y800)",
201 .guid = UVC_GUID_FORMAT_Y800,
202 .fcc = V4L2_PIX_FMT_GREY,
203 },
204 {
205 .name = "Greyscale 8-bit (Y8 )",
206 .guid = UVC_GUID_FORMAT_Y8,
207 .fcc = V4L2_PIX_FMT_GREY,
208 },
209 {
210 .name = "Greyscale 8-bit (D3DFMT_L8)",
211 .guid = UVC_GUID_FORMAT_D3DFMT_L8,
212 .fcc = V4L2_PIX_FMT_GREY,
213 },
214 {
215 .name = "IR 8-bit (L8_IR)",
216 .guid = UVC_GUID_FORMAT_KSMEDIA_L8_IR,
217 .fcc = V4L2_PIX_FMT_GREY,
218 },
219 {
220 .name = "Greyscale 10-bit (Y10 )",
221 .guid = UVC_GUID_FORMAT_Y10,
222 .fcc = V4L2_PIX_FMT_Y10,
223 },
224 {
225 .name = "Greyscale 12-bit (Y12 )",
226 .guid = UVC_GUID_FORMAT_Y12,
227 .fcc = V4L2_PIX_FMT_Y12,
228 },
229 {
230 .name = "Greyscale 16-bit (Y16 )",
231 .guid = UVC_GUID_FORMAT_Y16,
232 .fcc = V4L2_PIX_FMT_Y16,
233 },
234 {
235 .name = "BGGR Bayer (BY8 )",
236 .guid = UVC_GUID_FORMAT_BY8,
237 .fcc = V4L2_PIX_FMT_SBGGR8,
238 },
239 {
240 .name = "BGGR Bayer (BA81)",
241 .guid = UVC_GUID_FORMAT_BA81,
242 .fcc = V4L2_PIX_FMT_SBGGR8,
243 },
244 {
245 .name = "GBRG Bayer (GBRG)",
246 .guid = UVC_GUID_FORMAT_GBRG,
247 .fcc = V4L2_PIX_FMT_SGBRG8,
248 },
249 {
250 .name = "GRBG Bayer (GRBG)",
251 .guid = UVC_GUID_FORMAT_GRBG,
252 .fcc = V4L2_PIX_FMT_SGRBG8,
253 },
254 {
255 .name = "RGGB Bayer (RGGB)",
256 .guid = UVC_GUID_FORMAT_RGGB,
257 .fcc = V4L2_PIX_FMT_SRGGB8,
258 },
259 {
260 .name = "RGB565",
261 .guid = UVC_GUID_FORMAT_RGBP,
262 .fcc = V4L2_PIX_FMT_RGB565,
263 },
264 {
265 .name = "BGR 8:8:8 (BGR3)",
266 .guid = UVC_GUID_FORMAT_BGR3,
267 .fcc = V4L2_PIX_FMT_BGR24,
268 },
269 {
270 .name = "H.264",
271 .guid = UVC_GUID_FORMAT_H264,
272 .fcc = V4L2_PIX_FMT_H264,
273 },
274 {
275 .name = "H.265",
276 .guid = UVC_GUID_FORMAT_H265,
277 .fcc = V4L2_PIX_FMT_HEVC,
278 },
279 {
280 .name = "Greyscale 8 L/R (Y8I)",
281 .guid = UVC_GUID_FORMAT_Y8I,
282 .fcc = V4L2_PIX_FMT_Y8I,
283 },
284 {
285 .name = "Greyscale 12 L/R (Y12I)",
286 .guid = UVC_GUID_FORMAT_Y12I,
287 .fcc = V4L2_PIX_FMT_Y12I,
288 },
289 {
290 .name = "Depth data 16-bit (Z16)",
291 .guid = UVC_GUID_FORMAT_Z16,
292 .fcc = V4L2_PIX_FMT_Z16,
293 },
294 {
295 .name = "Bayer 10-bit (SRGGB10P)",
296 .guid = UVC_GUID_FORMAT_RW10,
297 .fcc = V4L2_PIX_FMT_SRGGB10P,
298 },
299 {
300 .name = "Bayer 16-bit (SBGGR16)",
301 .guid = UVC_GUID_FORMAT_BG16,
302 .fcc = V4L2_PIX_FMT_SBGGR16,
303 },
304 {
305 .name = "Bayer 16-bit (SGBRG16)",
306 .guid = UVC_GUID_FORMAT_GB16,
307 .fcc = V4L2_PIX_FMT_SGBRG16,
308 },
309 {
310 .name = "Bayer 16-bit (SRGGB16)",
311 .guid = UVC_GUID_FORMAT_RG16,
312 .fcc = V4L2_PIX_FMT_SRGGB16,
313 },
314 {
315 .name = "Bayer 16-bit (SGRBG16)",
316 .guid = UVC_GUID_FORMAT_GR16,
317 .fcc = V4L2_PIX_FMT_SGRBG16,
318 },
319 {
320 .name = "Depth data 16-bit (Z16)",
321 .guid = UVC_GUID_FORMAT_INVZ,
322 .fcc = V4L2_PIX_FMT_Z16,
323 },
324 {
325 .name = "Greyscale 10-bit (Y10 )",
326 .guid = UVC_GUID_FORMAT_INVI,
327 .fcc = V4L2_PIX_FMT_Y10,
328 },
329 {
330 .name = "IR:Depth 26-bit (INZI)",
331 .guid = UVC_GUID_FORMAT_INZI,
332 .fcc = V4L2_PIX_FMT_INZI,
333 },
334 {
335 .name = "4-bit Depth Confidence (Packed)",
336 .guid = UVC_GUID_FORMAT_CNF4,
337 .fcc = V4L2_PIX_FMT_CNF4,
338 },
339 {
340 .name = "HEVC",
341 .guid = UVC_GUID_FORMAT_HEVC,
342 .fcc = V4L2_PIX_FMT_HEVC,
343 },
344 };
345
uvc_format_by_guid(const u8 guid[16])346 static inline struct uvc_format_desc *uvc_format_by_guid(const u8 guid[16])
347 {
348 unsigned int len = ARRAY_SIZE(uvc_fmts);
349 unsigned int i;
350
351 for (i = 0; i < len; ++i) {
352 if (memcmp(guid, uvc_fmts[i].guid, 16) == 0)
353 return &uvc_fmts[i];
354 }
355
356 return NULL;
357 }
358
359 #endif /* __LINUX_V4L2_UVC_H */
360