1 // SPDX-License-Identifier: GPL-2.0-or-later
3 #include <linux/kernel.h>
4 #include <linux/module.h>
5 #include <linux/string.h>
6 #include <linux/types.h>
7 #include <linux/usb/uvc.h>
8 #include <linux/videodev2.h>
10 /* ------------------------------------------------------------------------
14 static const struct uvc_format_desc uvc_fmts
[] = {
16 .guid
= UVC_GUID_FORMAT_YUY2
,
17 .fcc
= V4L2_PIX_FMT_YUYV
,
20 .guid
= UVC_GUID_FORMAT_YUY2_ISIGHT
,
21 .fcc
= V4L2_PIX_FMT_YUYV
,
24 .guid
= UVC_GUID_FORMAT_NV12
,
25 .fcc
= V4L2_PIX_FMT_NV12
,
28 .guid
= UVC_GUID_FORMAT_MJPEG
,
29 .fcc
= V4L2_PIX_FMT_MJPEG
,
32 .guid
= UVC_GUID_FORMAT_YV12
,
33 .fcc
= V4L2_PIX_FMT_YVU420
,
36 .guid
= UVC_GUID_FORMAT_I420
,
37 .fcc
= V4L2_PIX_FMT_YUV420
,
40 .guid
= UVC_GUID_FORMAT_M420
,
41 .fcc
= V4L2_PIX_FMT_M420
,
44 .guid
= UVC_GUID_FORMAT_UYVY
,
45 .fcc
= V4L2_PIX_FMT_UYVY
,
48 .guid
= UVC_GUID_FORMAT_Y800
,
49 .fcc
= V4L2_PIX_FMT_GREY
,
52 .guid
= UVC_GUID_FORMAT_Y8
,
53 .fcc
= V4L2_PIX_FMT_GREY
,
56 .guid
= UVC_GUID_FORMAT_D3DFMT_L8
,
57 .fcc
= V4L2_PIX_FMT_GREY
,
60 .guid
= UVC_GUID_FORMAT_KSMEDIA_L8_IR
,
61 .fcc
= V4L2_PIX_FMT_GREY
,
64 .guid
= UVC_GUID_FORMAT_Y10
,
65 .fcc
= V4L2_PIX_FMT_Y10
,
68 .guid
= UVC_GUID_FORMAT_Y12
,
69 .fcc
= V4L2_PIX_FMT_Y12
,
72 .guid
= UVC_GUID_FORMAT_Y16
,
73 .fcc
= V4L2_PIX_FMT_Y16
,
76 .guid
= UVC_GUID_FORMAT_BY8
,
77 .fcc
= V4L2_PIX_FMT_SBGGR8
,
80 .guid
= UVC_GUID_FORMAT_BA81
,
81 .fcc
= V4L2_PIX_FMT_SBGGR8
,
84 .guid
= UVC_GUID_FORMAT_GBRG
,
85 .fcc
= V4L2_PIX_FMT_SGBRG8
,
88 .guid
= UVC_GUID_FORMAT_GRBG
,
89 .fcc
= V4L2_PIX_FMT_SGRBG8
,
92 .guid
= UVC_GUID_FORMAT_RGGB
,
93 .fcc
= V4L2_PIX_FMT_SRGGB8
,
96 .guid
= UVC_GUID_FORMAT_RGBP
,
97 .fcc
= V4L2_PIX_FMT_RGB565
,
100 .guid
= UVC_GUID_FORMAT_BGR3
,
101 .fcc
= V4L2_PIX_FMT_BGR24
,
104 .guid
= UVC_GUID_FORMAT_BGR4
,
105 .fcc
= V4L2_PIX_FMT_XBGR32
,
108 .guid
= UVC_GUID_FORMAT_H264
,
109 .fcc
= V4L2_PIX_FMT_H264
,
112 .guid
= UVC_GUID_FORMAT_H265
,
113 .fcc
= V4L2_PIX_FMT_HEVC
,
116 .guid
= UVC_GUID_FORMAT_Y8I
,
117 .fcc
= V4L2_PIX_FMT_Y8I
,
120 .guid
= UVC_GUID_FORMAT_Y12I
,
121 .fcc
= V4L2_PIX_FMT_Y12I
,
124 .guid
= UVC_GUID_FORMAT_Z16
,
125 .fcc
= V4L2_PIX_FMT_Z16
,
128 .guid
= UVC_GUID_FORMAT_RW10
,
129 .fcc
= V4L2_PIX_FMT_SRGGB10P
,
132 .guid
= UVC_GUID_FORMAT_BG16
,
133 .fcc
= V4L2_PIX_FMT_SBGGR16
,
136 .guid
= UVC_GUID_FORMAT_GB16
,
137 .fcc
= V4L2_PIX_FMT_SGBRG16
,
140 .guid
= UVC_GUID_FORMAT_RG16
,
141 .fcc
= V4L2_PIX_FMT_SRGGB16
,
144 .guid
= UVC_GUID_FORMAT_GR16
,
145 .fcc
= V4L2_PIX_FMT_SGRBG16
,
148 .guid
= UVC_GUID_FORMAT_INVZ
,
149 .fcc
= V4L2_PIX_FMT_Z16
,
152 .guid
= UVC_GUID_FORMAT_INVI
,
153 .fcc
= V4L2_PIX_FMT_Y10
,
156 .guid
= UVC_GUID_FORMAT_INZI
,
157 .fcc
= V4L2_PIX_FMT_INZI
,
160 .guid
= UVC_GUID_FORMAT_CNF4
,
161 .fcc
= V4L2_PIX_FMT_CNF4
,
164 .guid
= UVC_GUID_FORMAT_HEVC
,
165 .fcc
= V4L2_PIX_FMT_HEVC
,
169 const struct uvc_format_desc
*uvc_format_by_guid(const u8 guid
[16])
171 unsigned int len
= ARRAY_SIZE(uvc_fmts
);
174 for (i
= 0; i
< len
; ++i
) {
175 if (memcmp(guid
, uvc_fmts
[i
].guid
, 16) == 0)
181 EXPORT_SYMBOL_GPL(uvc_format_by_guid
);
183 MODULE_DESCRIPTION("USB Video Class common code");
184 MODULE_LICENSE("GPL");