1 // SPDX-License-Identifier: GPL-2.0-or-later 2 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> 9 10 /* ------------------------------------------------------------------------ 11 * Video formats 12 */ 13 14 static const struct uvc_format_desc uvc_fmts[] = { 15 { 16 .guid = UVC_GUID_FORMAT_YUY2, 17 .fcc = V4L2_PIX_FMT_YUYV, 18 }, 19 { 20 .guid = UVC_GUID_FORMAT_YUY2_ISIGHT, 21 .fcc = V4L2_PIX_FMT_YUYV, 22 }, 23 { 24 .guid = UVC_GUID_FORMAT_NV12, 25 .fcc = V4L2_PIX_FMT_NV12, 26 }, 27 { 28 .guid = UVC_GUID_FORMAT_MJPEG, 29 .fcc = V4L2_PIX_FMT_MJPEG, 30 }, 31 { 32 .guid = UVC_GUID_FORMAT_YV12, 33 .fcc = V4L2_PIX_FMT_YVU420, 34 }, 35 { 36 .guid = UVC_GUID_FORMAT_I420, 37 .fcc = V4L2_PIX_FMT_YUV420, 38 }, 39 { 40 .guid = UVC_GUID_FORMAT_M420, 41 .fcc = V4L2_PIX_FMT_M420, 42 }, 43 { 44 .guid = UVC_GUID_FORMAT_UYVY, 45 .fcc = V4L2_PIX_FMT_UYVY, 46 }, 47 { 48 .guid = UVC_GUID_FORMAT_Y800, 49 .fcc = V4L2_PIX_FMT_GREY, 50 }, 51 { 52 .guid = UVC_GUID_FORMAT_Y8, 53 .fcc = V4L2_PIX_FMT_GREY, 54 }, 55 { 56 .guid = UVC_GUID_FORMAT_D3DFMT_L8, 57 .fcc = V4L2_PIX_FMT_GREY, 58 }, 59 { 60 .guid = UVC_GUID_FORMAT_KSMEDIA_L8_IR, 61 .fcc = V4L2_PIX_FMT_GREY, 62 }, 63 { 64 .guid = UVC_GUID_FORMAT_Y10, 65 .fcc = V4L2_PIX_FMT_Y10, 66 }, 67 { 68 .guid = UVC_GUID_FORMAT_Y12, 69 .fcc = V4L2_PIX_FMT_Y12, 70 }, 71 { 72 .guid = UVC_GUID_FORMAT_Y16, 73 .fcc = V4L2_PIX_FMT_Y16, 74 }, 75 { 76 .guid = UVC_GUID_FORMAT_BY8, 77 .fcc = V4L2_PIX_FMT_SBGGR8, 78 }, 79 { 80 .guid = UVC_GUID_FORMAT_BA81, 81 .fcc = V4L2_PIX_FMT_SBGGR8, 82 }, 83 { 84 .guid = UVC_GUID_FORMAT_GBRG, 85 .fcc = V4L2_PIX_FMT_SGBRG8, 86 }, 87 { 88 .guid = UVC_GUID_FORMAT_GRBG, 89 .fcc = V4L2_PIX_FMT_SGRBG8, 90 }, 91 { 92 .guid = UVC_GUID_FORMAT_RGGB, 93 .fcc = V4L2_PIX_FMT_SRGGB8, 94 }, 95 { 96 .guid = UVC_GUID_FORMAT_RGBP, 97 .fcc = V4L2_PIX_FMT_RGB565, 98 }, 99 { 100 .guid = UVC_GUID_FORMAT_BGR3, 101 .fcc = V4L2_PIX_FMT_BGR24, 102 }, 103 { 104 .guid = UVC_GUID_FORMAT_BGR4, 105 .fcc = V4L2_PIX_FMT_XBGR32, 106 }, 107 { 108 .guid = UVC_GUID_FORMAT_H264, 109 .fcc = V4L2_PIX_FMT_H264, 110 }, 111 { 112 .guid = UVC_GUID_FORMAT_H265, 113 .fcc = V4L2_PIX_FMT_HEVC, 114 }, 115 { 116 .guid = UVC_GUID_FORMAT_Y8I, 117 .fcc = V4L2_PIX_FMT_Y8I, 118 }, 119 { 120 .guid = UVC_GUID_FORMAT_Y12I, 121 .fcc = V4L2_PIX_FMT_Y12I, 122 }, 123 { 124 .guid = UVC_GUID_FORMAT_Z16, 125 .fcc = V4L2_PIX_FMT_Z16, 126 }, 127 { 128 .guid = UVC_GUID_FORMAT_RW10, 129 .fcc = V4L2_PIX_FMT_SRGGB10P, 130 }, 131 { 132 .guid = UVC_GUID_FORMAT_BG16, 133 .fcc = V4L2_PIX_FMT_SBGGR16, 134 }, 135 { 136 .guid = UVC_GUID_FORMAT_GB16, 137 .fcc = V4L2_PIX_FMT_SGBRG16, 138 }, 139 { 140 .guid = UVC_GUID_FORMAT_RG16, 141 .fcc = V4L2_PIX_FMT_SRGGB16, 142 }, 143 { 144 .guid = UVC_GUID_FORMAT_GR16, 145 .fcc = V4L2_PIX_FMT_SGRBG16, 146 }, 147 { 148 .guid = UVC_GUID_FORMAT_INVZ, 149 .fcc = V4L2_PIX_FMT_Z16, 150 }, 151 { 152 .guid = UVC_GUID_FORMAT_INVI, 153 .fcc = V4L2_PIX_FMT_Y10, 154 }, 155 { 156 .guid = UVC_GUID_FORMAT_INZI, 157 .fcc = V4L2_PIX_FMT_INZI, 158 }, 159 { 160 .guid = UVC_GUID_FORMAT_CNF4, 161 .fcc = V4L2_PIX_FMT_CNF4, 162 }, 163 { 164 .guid = UVC_GUID_FORMAT_HEVC, 165 .fcc = V4L2_PIX_FMT_HEVC, 166 }, 167 }; 168 169 const struct uvc_format_desc *uvc_format_by_guid(const u8 guid[16]) 170 { 171 unsigned int len = ARRAY_SIZE(uvc_fmts); 172 unsigned int i; 173 174 for (i = 0; i < len; ++i) { 175 if (memcmp(guid, uvc_fmts[i].guid, 16) == 0) 176 return &uvc_fmts[i]; 177 } 178 179 return NULL; 180 } 181 EXPORT_SYMBOL_GPL(uvc_format_by_guid); 182 183 MODULE_LICENSE("GPL"); 184