Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 2 | #ifndef _USB_VIDEO_H_ |
| 3 | #define _USB_VIDEO_H_ |
| 4 | |
Laurent Pinchart | 227bd5b | 2011-07-30 16:19:49 -0300 | [diff] [blame] | 5 | #ifndef __KERNEL__ |
| 6 | #error "The uvcvideo.h header is deprecated, use linux/uvcvideo.h instead." |
| 7 | #endif /* __KERNEL__ */ |
| 8 | |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 9 | #include <linux/kernel.h> |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 10 | #include <linux/poll.h> |
Laurent Pinchart | 4ffc2d8 | 2010-01-21 05:39:52 -0300 | [diff] [blame] | 11 | #include <linux/usb.h> |
Laurent Pinchart | de05f63 | 2009-06-26 12:15:38 -0300 | [diff] [blame] | 12 | #include <linux/usb/video.h> |
Laurent Pinchart | 5f70881 | 2010-11-21 17:15:44 -0300 | [diff] [blame] | 13 | #include <linux/uvcvideo.h> |
Laurent Pinchart | 227bd5b | 2011-07-30 16:19:49 -0300 | [diff] [blame] | 14 | #include <linux/videodev2.h> |
Guennadi Liakhovetski | e5225c8 | 2018-07-26 04:17:53 -0400 | [diff] [blame] | 15 | #include <linux/workqueue.h> |
Laurent Pinchart | 5a254d7 | 2010-01-21 05:39:47 -0300 | [diff] [blame] | 16 | #include <media/media-device.h> |
| 17 | #include <media/v4l2-device.h> |
Hans de Goede | b401200 | 2012-04-08 12:59:51 -0300 | [diff] [blame] | 18 | #include <media/v4l2-event.h> |
| 19 | #include <media/v4l2-fh.h> |
Junghak Sung | c139990 | 2015-09-22 10:30:29 -0300 | [diff] [blame] | 20 | #include <media/videobuf2-v4l2.h> |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 21 | |
| 22 | /* -------------------------------------------------------------------------- |
| 23 | * UVC constants |
| 24 | */ |
| 25 | |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 26 | #define UVC_TERM_INPUT 0x0000 |
| 27 | #define UVC_TERM_OUTPUT 0x8000 |
Laurent Pinchart | 6241d8c | 2009-11-25 12:00:22 -0300 | [diff] [blame] | 28 | #define UVC_TERM_DIRECTION(term) ((term)->type & 0x8000) |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 29 | |
| 30 | #define UVC_ENTITY_TYPE(entity) ((entity)->type & 0x7fff) |
| 31 | #define UVC_ENTITY_IS_UNIT(entity) (((entity)->type & 0xff00) == 0) |
| 32 | #define UVC_ENTITY_IS_TERM(entity) (((entity)->type & 0xff00) != 0) |
| 33 | #define UVC_ENTITY_IS_ITERM(entity) \ |
Laurent Pinchart | 8e11359 | 2009-07-01 20:24:47 -0300 | [diff] [blame] | 34 | (UVC_ENTITY_IS_TERM(entity) && \ |
| 35 | ((entity)->type & 0x8000) == UVC_TERM_INPUT) |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 36 | #define UVC_ENTITY_IS_OTERM(entity) \ |
Laurent Pinchart | 8e11359 | 2009-07-01 20:24:47 -0300 | [diff] [blame] | 37 | (UVC_ENTITY_IS_TERM(entity) && \ |
| 38 | ((entity)->type & 0x8000) == UVC_TERM_OUTPUT) |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 39 | |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 40 | |
| 41 | /* ------------------------------------------------------------------------ |
| 42 | * GUIDs |
| 43 | */ |
| 44 | #define UVC_GUID_UVC_CAMERA \ |
| 45 | {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ |
| 46 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01} |
| 47 | #define UVC_GUID_UVC_OUTPUT \ |
| 48 | {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ |
| 49 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02} |
| 50 | #define UVC_GUID_UVC_MEDIA_TRANSPORT_INPUT \ |
| 51 | {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ |
| 52 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03} |
| 53 | #define UVC_GUID_UVC_PROCESSING \ |
| 54 | {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ |
| 55 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01} |
| 56 | #define UVC_GUID_UVC_SELECTOR \ |
| 57 | {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ |
| 58 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02} |
| 59 | |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 60 | #define UVC_GUID_FORMAT_MJPEG \ |
| 61 | { 'M', 'J', 'P', 'G', 0x00, 0x00, 0x10, 0x00, \ |
| 62 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} |
| 63 | #define UVC_GUID_FORMAT_YUY2 \ |
| 64 | { 'Y', 'U', 'Y', '2', 0x00, 0x00, 0x10, 0x00, \ |
| 65 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} |
Daniel Ritz | 68f194e | 2009-12-12 14:57:17 -0300 | [diff] [blame] | 66 | #define UVC_GUID_FORMAT_YUY2_ISIGHT \ |
| 67 | { 'Y', 'U', 'Y', '2', 0x00, 0x00, 0x10, 0x00, \ |
| 68 | 0x80, 0x00, 0x00, 0x00, 0x00, 0x38, 0x9b, 0x71} |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 69 | #define UVC_GUID_FORMAT_NV12 \ |
| 70 | { 'N', 'V', '1', '2', 0x00, 0x00, 0x10, 0x00, \ |
| 71 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} |
| 72 | #define UVC_GUID_FORMAT_YV12 \ |
| 73 | { 'Y', 'V', '1', '2', 0x00, 0x00, 0x10, 0x00, \ |
| 74 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} |
| 75 | #define UVC_GUID_FORMAT_I420 \ |
| 76 | { 'I', '4', '2', '0', 0x00, 0x00, 0x10, 0x00, \ |
| 77 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} |
| 78 | #define UVC_GUID_FORMAT_UYVY \ |
| 79 | { 'U', 'Y', 'V', 'Y', 0x00, 0x00, 0x10, 0x00, \ |
| 80 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} |
| 81 | #define UVC_GUID_FORMAT_Y800 \ |
| 82 | { 'Y', '8', '0', '0', 0x00, 0x00, 0x10, 0x00, \ |
| 83 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} |
Stefan Muenzel | ca47e71 | 2012-07-28 19:49:14 -0300 | [diff] [blame] | 84 | #define UVC_GUID_FORMAT_Y8 \ |
| 85 | { 'Y', '8', ' ', ' ', 0x00, 0x00, 0x10, 0x00, \ |
| 86 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} |
| 87 | #define UVC_GUID_FORMAT_Y10 \ |
| 88 | { 'Y', '1', '0', ' ', 0x00, 0x00, 0x10, 0x00, \ |
| 89 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} |
| 90 | #define UVC_GUID_FORMAT_Y12 \ |
| 91 | { 'Y', '1', '2', ' ', 0x00, 0x00, 0x10, 0x00, \ |
| 92 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} |
Laurent Pinchart | 61421206 | 2010-04-12 10:41:22 -0300 | [diff] [blame] | 93 | #define UVC_GUID_FORMAT_Y16 \ |
| 94 | { 'Y', '1', '6', ' ', 0x00, 0x00, 0x10, 0x00, \ |
| 95 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 96 | #define UVC_GUID_FORMAT_BY8 \ |
| 97 | { 'B', 'Y', '8', ' ', 0x00, 0x00, 0x10, 0x00, \ |
| 98 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} |
Edgar Thier | e72ed08 | 2014-02-20 04:12:51 -0300 | [diff] [blame] | 99 | #define UVC_GUID_FORMAT_BA81 \ |
| 100 | { 'B', 'A', '8', '1', 0x00, 0x00, 0x10, 0x00, \ |
| 101 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} |
| 102 | #define UVC_GUID_FORMAT_GBRG \ |
| 103 | { 'G', 'B', 'R', 'G', 0x00, 0x00, 0x10, 0x00, \ |
| 104 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} |
| 105 | #define UVC_GUID_FORMAT_GRBG \ |
| 106 | { 'G', 'R', 'B', 'G', 0x00, 0x00, 0x10, 0x00, \ |
| 107 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} |
| 108 | #define UVC_GUID_FORMAT_RGGB \ |
| 109 | { 'R', 'G', 'G', 'B', 0x00, 0x00, 0x10, 0x00, \ |
| 110 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} |
Edgar Thier | eb165a2 | 2016-11-15 03:33:10 -0200 | [diff] [blame] | 111 | #define UVC_GUID_FORMAT_BG16 \ |
| 112 | { 'B', 'G', '1', '6', 0x00, 0x00, 0x10, 0x00, \ |
| 113 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} |
| 114 | #define UVC_GUID_FORMAT_GB16 \ |
| 115 | { 'G', 'B', '1', '6', 0x00, 0x00, 0x10, 0x00, \ |
| 116 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} |
| 117 | #define UVC_GUID_FORMAT_RG16 \ |
| 118 | { 'R', 'G', '1', '6', 0x00, 0x00, 0x10, 0x00, \ |
| 119 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} |
| 120 | #define UVC_GUID_FORMAT_GR16 \ |
| 121 | { 'G', 'R', '1', '6', 0x00, 0x00, 0x10, 0x00, \ |
| 122 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} |
Laurent Pinchart | 5079107 | 2011-03-06 08:32:04 -0300 | [diff] [blame] | 123 | #define UVC_GUID_FORMAT_RGBP \ |
| 124 | { 'R', 'G', 'B', 'P', 0x00, 0x00, 0x10, 0x00, \ |
| 125 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} |
William Manley | 1b8dc32 | 2014-12-08 15:57:58 -0300 | [diff] [blame] | 126 | #define UVC_GUID_FORMAT_BGR3 \ |
| 127 | { 0x7d, 0xeb, 0x36, 0xe4, 0x4f, 0x52, 0xce, 0x11, \ |
| 128 | 0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70} |
Hans de Goede | 7225a1d | 2011-05-11 09:56:20 -0300 | [diff] [blame] | 129 | #define UVC_GUID_FORMAT_M420 \ |
| 130 | { 'M', '4', '2', '0', 0x00, 0x00, 0x10, 0x00, \ |
| 131 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 132 | |
Stephan Lachowsky | 25ad8a8 | 2011-01-28 16:38:58 -0300 | [diff] [blame] | 133 | #define UVC_GUID_FORMAT_H264 \ |
| 134 | { 'H', '2', '6', '4', 0x00, 0x00, 0x10, 0x00, \ |
| 135 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} |
Aviv Greenberg | 5d8d8db | 2016-02-03 15:08:52 -0200 | [diff] [blame] | 136 | #define UVC_GUID_FORMAT_Y8I \ |
| 137 | { 'Y', '8', 'I', ' ', 0x00, 0x00, 0x10, 0x00, \ |
| 138 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} |
| 139 | #define UVC_GUID_FORMAT_Y12I \ |
| 140 | { 'Y', '1', '2', 'I', 0x00, 0x00, 0x10, 0x00, \ |
| 141 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} |
| 142 | #define UVC_GUID_FORMAT_Z16 \ |
| 143 | { 'Z', '1', '6', ' ', 0x00, 0x00, 0x10, 0x00, \ |
| 144 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} |
| 145 | #define UVC_GUID_FORMAT_RW10 \ |
| 146 | { 'R', 'W', '1', '0', 0x00, 0x00, 0x10, 0x00, \ |
| 147 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} |
Daniel Patrick Johnson | c4a0968 | 2017-03-02 20:43:20 -0300 | [diff] [blame] | 148 | #define UVC_GUID_FORMAT_INVZ \ |
| 149 | { 'I', 'N', 'V', 'Z', 0x90, 0x2d, 0x58, 0x4a, \ |
| 150 | 0x92, 0x0b, 0x77, 0x3f, 0x1f, 0x2c, 0x55, 0x6b} |
| 151 | #define UVC_GUID_FORMAT_INZI \ |
| 152 | { 'I', 'N', 'Z', 'I', 0x66, 0x1a, 0x42, 0xa2, \ |
| 153 | 0x90, 0x65, 0xd0, 0x18, 0x14, 0xa8, 0xef, 0x8a} |
| 154 | #define UVC_GUID_FORMAT_INVI \ |
| 155 | { 'I', 'N', 'V', 'I', 0xdb, 0x57, 0x49, 0x5e, \ |
| 156 | 0x8e, 0x3f, 0xf4, 0x79, 0x53, 0x2b, 0x94, 0x6f} |
Sergey Dorodnicov | 38e9b92 | 2018-09-12 02:42:07 -0400 | [diff] [blame^] | 157 | #define UVC_GUID_FORMAT_CNF4 \ |
| 158 | { 'C', ' ', ' ', ' ', 0x00, 0x00, 0x10, 0x00, \ |
| 159 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} |
Stephan Lachowsky | 25ad8a8 | 2011-01-28 16:38:58 -0300 | [diff] [blame] | 160 | |
Nicolas Dufresne | e96cdc9 | 2017-11-06 15:13:28 -0500 | [diff] [blame] | 161 | #define UVC_GUID_FORMAT_D3DFMT_L8 \ |
| 162 | {0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, \ |
| 163 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} |
Laurent Pinchart | 557a5c7 | 2018-03-21 05:16:40 -0400 | [diff] [blame] | 164 | #define UVC_GUID_FORMAT_KSMEDIA_L8_IR \ |
| 165 | {0x32, 0x00, 0x00, 0x00, 0x02, 0x00, 0x10, 0x00, \ |
| 166 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} |
Nicolas Dufresne | e96cdc9 | 2017-11-06 15:13:28 -0500 | [diff] [blame] | 167 | |
| 168 | |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 169 | /* ------------------------------------------------------------------------ |
| 170 | * Driver specific constants. |
| 171 | */ |
| 172 | |
Mauro Carvalho Chehab | fd3e582 | 2011-06-25 13:50:37 -0300 | [diff] [blame] | 173 | #define DRIVER_VERSION "1.1.1" |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 174 | |
| 175 | /* Number of isochronous URBs. */ |
| 176 | #define UVC_URBS 5 |
Laurent Pinchart | efdc8a9 | 2009-01-18 17:46:30 -0300 | [diff] [blame] | 177 | /* Maximum number of packets per URB. */ |
| 178 | #define UVC_MAX_PACKETS 32 |
Ming Lei | a31a405 | 2008-09-16 03:32:20 -0300 | [diff] [blame] | 179 | /* Maximum status buffer size in bytes of interrupt URB. */ |
| 180 | #define UVC_MAX_STATUS_SIZE 16 |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 181 | |
Jim Lin | da6df1c | 2017-08-08 08:56:20 -0400 | [diff] [blame] | 182 | #define UVC_CTRL_CONTROL_TIMEOUT 500 |
Laurent Pinchart | 56d15cd | 2010-01-19 08:59:21 -0300 | [diff] [blame] | 183 | #define UVC_CTRL_STREAMING_TIMEOUT 5000 |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 184 | |
Martin Rubli | 8fb91b3 | 2010-09-08 04:15:23 -0300 | [diff] [blame] | 185 | /* Maximum allowed number of control mappings per device */ |
| 186 | #define UVC_MAX_CONTROL_MAPPINGS 1024 |
Haogang Chen | 806e23e | 2011-11-29 18:32:25 -0300 | [diff] [blame] | 187 | #define UVC_MAX_CONTROL_MENU_ENTRIES 32 |
Martin Rubli | 8fb91b3 | 2010-09-08 04:15:23 -0300 | [diff] [blame] | 188 | |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 189 | /* Devices quirks */ |
| 190 | #define UVC_QUIRK_STATUS_INTERVAL 0x00000001 |
| 191 | #define UVC_QUIRK_PROBE_MINMAX 0x00000002 |
| 192 | #define UVC_QUIRK_PROBE_EXTRAFIELDS 0x00000004 |
| 193 | #define UVC_QUIRK_BUILTIN_ISIGHT 0x00000008 |
| 194 | #define UVC_QUIRK_STREAM_NO_FID 0x00000010 |
| 195 | #define UVC_QUIRK_IGNORE_SELECTOR_UNIT 0x00000020 |
Laurent Pinchart | 50144ae | 2009-02-16 17:41:52 -0300 | [diff] [blame] | 196 | #define UVC_QUIRK_FIX_BANDWIDTH 0x00000080 |
Laurent Pinchart | bab6f66 | 2009-07-19 18:39:56 -0300 | [diff] [blame] | 197 | #define UVC_QUIRK_PROBE_DEF 0x00000100 |
Laurent Pinchart | 86d8b6a | 2010-09-16 12:37:26 -0300 | [diff] [blame] | 198 | #define UVC_QUIRK_RESTRICT_FRAME_RATE 0x00000200 |
William Manley | 17e1319 | 2014-03-13 09:38:48 -0300 | [diff] [blame] | 199 | #define UVC_QUIRK_RESTORE_CTRLS_ON_INIT 0x00000400 |
Philipp Zabel | e1b78a3 | 2014-08-06 17:50:49 -0300 | [diff] [blame] | 200 | #define UVC_QUIRK_FORCE_Y8 0x00000800 |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 201 | |
| 202 | /* Format flags */ |
| 203 | #define UVC_FMT_FLAG_COMPRESSED 0x00000001 |
| 204 | #define UVC_FMT_FLAG_STREAM 0x00000002 |
| 205 | |
| 206 | /* ------------------------------------------------------------------------ |
| 207 | * Structures. |
| 208 | */ |
| 209 | |
| 210 | struct uvc_device; |
| 211 | |
| 212 | /* TODO: Put the most frequently accessed fields at the beginning of |
| 213 | * structures to maximize cache efficiency. |
| 214 | */ |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 215 | struct uvc_control_info { |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 216 | struct list_head mappings; |
| 217 | |
Laurent Pinchart | 2c6b222 | 2018-01-16 12:45:36 -0500 | [diff] [blame] | 218 | u8 entity[16]; |
| 219 | u8 index; /* Bit index in bmControls */ |
| 220 | u8 selector; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 221 | |
Laurent Pinchart | 2c6b222 | 2018-01-16 12:45:36 -0500 | [diff] [blame] | 222 | u16 size; |
| 223 | u32 flags; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 224 | }; |
| 225 | |
| 226 | struct uvc_control_mapping { |
| 227 | struct list_head list; |
Hans de Goede | b401200 | 2012-04-08 12:59:51 -0300 | [diff] [blame] | 228 | struct list_head ev_subs; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 229 | |
Laurent Pinchart | 2c6b222 | 2018-01-16 12:45:36 -0500 | [diff] [blame] | 230 | u32 id; |
| 231 | u8 name[32]; |
| 232 | u8 entity[16]; |
| 233 | u8 selector; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 234 | |
Laurent Pinchart | 2c6b222 | 2018-01-16 12:45:36 -0500 | [diff] [blame] | 235 | u8 size; |
| 236 | u8 offset; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 237 | enum v4l2_ctrl_type v4l2_type; |
Laurent Pinchart | 2c6b222 | 2018-01-16 12:45:36 -0500 | [diff] [blame] | 238 | u32 data_type; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 239 | |
Laurent Pinchart | 52a4eb3 | 2018-08-06 18:25:33 -0400 | [diff] [blame] | 240 | const struct uvc_menu_info *menu_info; |
Laurent Pinchart | 2c6b222 | 2018-01-16 12:45:36 -0500 | [diff] [blame] | 241 | u32 menu_count; |
Laurent Pinchart | 9768352 | 2008-12-16 06:46:32 -0300 | [diff] [blame] | 242 | |
Laurent Pinchart | 2c6b222 | 2018-01-16 12:45:36 -0500 | [diff] [blame] | 243 | u32 master_id; |
| 244 | s32 master_manual; |
| 245 | u32 slave_ids[2]; |
Hans de Goede | 55afeb8 | 2012-04-08 12:59:52 -0300 | [diff] [blame] | 246 | |
Laurent Pinchart | 2c6b222 | 2018-01-16 12:45:36 -0500 | [diff] [blame] | 247 | s32 (*get)(struct uvc_control_mapping *mapping, u8 query, |
| 248 | const u8 *data); |
| 249 | void (*set)(struct uvc_control_mapping *mapping, s32 value, |
| 250 | u8 *data); |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 251 | }; |
| 252 | |
| 253 | struct uvc_control { |
| 254 | struct uvc_entity *entity; |
Laurent Pinchart | 071c8bb | 2010-09-29 16:00:08 -0300 | [diff] [blame] | 255 | struct uvc_control_info info; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 256 | |
Laurent Pinchart | 2c6b222 | 2018-01-16 12:45:36 -0500 | [diff] [blame] | 257 | u8 index; /* Used to match the uvc_control entry with a |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 258 | uvc_control_info. */ |
Laurent Pinchart | 2c6b222 | 2018-01-16 12:45:36 -0500 | [diff] [blame] | 259 | u8 dirty:1, |
| 260 | loaded:1, |
| 261 | modified:1, |
| 262 | cached:1, |
| 263 | initialized:1; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 264 | |
Laurent Pinchart | 2c6b222 | 2018-01-16 12:45:36 -0500 | [diff] [blame] | 265 | u8 *uvc_data; |
Guennadi Liakhovetski | e5225c8 | 2018-07-26 04:17:53 -0400 | [diff] [blame] | 266 | |
| 267 | struct uvc_fh *handle; /* File handle that last changed the control. */ |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 268 | }; |
| 269 | |
| 270 | struct uvc_format_desc { |
| 271 | char *name; |
Laurent Pinchart | 2c6b222 | 2018-01-16 12:45:36 -0500 | [diff] [blame] | 272 | u8 guid[16]; |
| 273 | u32 fcc; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 274 | }; |
| 275 | |
| 276 | /* The term 'entity' refers to both UVC units and UVC terminals. |
| 277 | * |
| 278 | * The type field is either the terminal type (wTerminalType in the terminal |
| 279 | * descriptor), or the unit type (bDescriptorSubtype in the unit descriptor). |
| 280 | * As the bDescriptorSubtype field is one byte long, the type value will |
| 281 | * always have a null MSB for units. All terminal types defined by the UVC |
| 282 | * specification have a non-null MSB, so it is safe to use the MSB to |
| 283 | * differentiate between units and terminals as long as the descriptor parsing |
| 284 | * code makes sure terminal types have a non-null MSB. |
| 285 | * |
| 286 | * For terminals, the type's most significant bit stores the terminal |
| 287 | * direction (either UVC_TERM_INPUT or UVC_TERM_OUTPUT). The type field should |
| 288 | * always be accessed with the UVC_ENTITY_* macros and never directly. |
| 289 | */ |
| 290 | |
Laurent Pinchart | 8be8ec6 | 2012-08-03 04:35:10 -0300 | [diff] [blame] | 291 | #define UVC_ENTITY_FLAG_DEFAULT (1 << 0) |
| 292 | |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 293 | struct uvc_entity { |
| 294 | struct list_head list; /* Entity as part of a UVC device. */ |
| 295 | struct list_head chain; /* Entity as part of a video device |
| 296 | * chain. */ |
Laurent Pinchart | 8be8ec6 | 2012-08-03 04:35:10 -0300 | [diff] [blame] | 297 | unsigned int flags; |
| 298 | |
Laurent Pinchart | 2c6b222 | 2018-01-16 12:45:36 -0500 | [diff] [blame] | 299 | u8 id; |
| 300 | u16 type; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 301 | char name[64]; |
| 302 | |
Laurent Pinchart | 4ffc2d8 | 2010-01-21 05:39:52 -0300 | [diff] [blame] | 303 | /* Media controller-related fields. */ |
Laurent Pinchart | 8a65a94 | 2010-01-21 08:56:19 -0300 | [diff] [blame] | 304 | struct video_device *vdev; |
Laurent Pinchart | 4ffc2d8 | 2010-01-21 05:39:52 -0300 | [diff] [blame] | 305 | struct v4l2_subdev subdev; |
| 306 | unsigned int num_pads; |
| 307 | unsigned int num_links; |
| 308 | struct media_pad *pads; |
| 309 | |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 310 | union { |
| 311 | struct { |
Laurent Pinchart | 2c6b222 | 2018-01-16 12:45:36 -0500 | [diff] [blame] | 312 | u16 wObjectiveFocalLengthMin; |
| 313 | u16 wObjectiveFocalLengthMax; |
| 314 | u16 wOcularFocalLength; |
| 315 | u8 bControlSize; |
| 316 | u8 *bmControls; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 317 | } camera; |
| 318 | |
| 319 | struct { |
Laurent Pinchart | 2c6b222 | 2018-01-16 12:45:36 -0500 | [diff] [blame] | 320 | u8 bControlSize; |
| 321 | u8 *bmControls; |
| 322 | u8 bTransportModeSize; |
| 323 | u8 *bmTransportModes; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 324 | } media; |
| 325 | |
| 326 | struct { |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 327 | } output; |
| 328 | |
| 329 | struct { |
Laurent Pinchart | 2c6b222 | 2018-01-16 12:45:36 -0500 | [diff] [blame] | 330 | u16 wMaxMultiplier; |
| 331 | u8 bControlSize; |
| 332 | u8 *bmControls; |
| 333 | u8 bmVideoStandards; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 334 | } processing; |
| 335 | |
| 336 | struct { |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 337 | } selector; |
| 338 | |
| 339 | struct { |
Laurent Pinchart | 2c6b222 | 2018-01-16 12:45:36 -0500 | [diff] [blame] | 340 | u8 guidExtensionCode[16]; |
| 341 | u8 bNumControls; |
| 342 | u8 bControlSize; |
| 343 | u8 *bmControls; |
| 344 | u8 *bmControlsType; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 345 | } extension; |
| 346 | }; |
| 347 | |
Laurent Pinchart | 2c6b222 | 2018-01-16 12:45:36 -0500 | [diff] [blame] | 348 | u8 bNrInPins; |
| 349 | u8 *baSourceID; |
Laurent Pinchart | 8ca5a63 | 2009-11-25 12:00:30 -0300 | [diff] [blame] | 350 | |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 351 | unsigned int ncontrols; |
| 352 | struct uvc_control *controls; |
| 353 | }; |
| 354 | |
| 355 | struct uvc_frame { |
Laurent Pinchart | 2c6b222 | 2018-01-16 12:45:36 -0500 | [diff] [blame] | 356 | u8 bFrameIndex; |
| 357 | u8 bmCapabilities; |
| 358 | u16 wWidth; |
| 359 | u16 wHeight; |
| 360 | u32 dwMinBitRate; |
| 361 | u32 dwMaxBitRate; |
| 362 | u32 dwMaxVideoFrameBufferSize; |
| 363 | u8 bFrameIntervalType; |
| 364 | u32 dwDefaultFrameInterval; |
| 365 | u32 *dwFrameInterval; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 366 | }; |
| 367 | |
| 368 | struct uvc_format { |
Laurent Pinchart | 2c6b222 | 2018-01-16 12:45:36 -0500 | [diff] [blame] | 369 | u8 type; |
| 370 | u8 index; |
| 371 | u8 bpp; |
| 372 | u8 colorspace; |
| 373 | u32 fcc; |
| 374 | u32 flags; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 375 | |
| 376 | char name[32]; |
| 377 | |
| 378 | unsigned int nframes; |
| 379 | struct uvc_frame *frame; |
| 380 | }; |
| 381 | |
| 382 | struct uvc_streaming_header { |
Laurent Pinchart | 2c6b222 | 2018-01-16 12:45:36 -0500 | [diff] [blame] | 383 | u8 bNumFormats; |
| 384 | u8 bEndpointAddress; |
| 385 | u8 bTerminalLink; |
| 386 | u8 bControlSize; |
| 387 | u8 *bmaControls; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 388 | /* The following fields are used by input headers only. */ |
Laurent Pinchart | 2c6b222 | 2018-01-16 12:45:36 -0500 | [diff] [blame] | 389 | u8 bmInfo; |
| 390 | u8 bStillCaptureMethod; |
| 391 | u8 bTriggerSupport; |
| 392 | u8 bTriggerUsage; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 393 | }; |
| 394 | |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 395 | enum uvc_buffer_state { |
Laurent Pinchart | 2c2d264 | 2009-01-03 19:12:40 -0300 | [diff] [blame] | 396 | UVC_BUF_STATE_IDLE = 0, |
| 397 | UVC_BUF_STATE_QUEUED = 1, |
| 398 | UVC_BUF_STATE_ACTIVE = 2, |
Laurent Pinchart | d7c0d43 | 2009-12-16 21:20:45 -0300 | [diff] [blame] | 399 | UVC_BUF_STATE_READY = 3, |
| 400 | UVC_BUF_STATE_DONE = 4, |
| 401 | UVC_BUF_STATE_ERROR = 5, |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 402 | }; |
| 403 | |
| 404 | struct uvc_buffer { |
Junghak Sung | 2d70071 | 2015-09-22 10:30:30 -0300 | [diff] [blame] | 405 | struct vb2_v4l2_buffer buf; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 406 | struct list_head queue; |
Laurent Pinchart | 6998b6f | 2011-10-24 11:53:59 -0300 | [diff] [blame] | 407 | |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 408 | enum uvc_buffer_state state; |
Laurent Pinchart | 9bde9f2 | 2010-06-17 06:52:37 -0300 | [diff] [blame] | 409 | unsigned int error; |
Laurent Pinchart | 3d95e93 | 2011-10-24 11:49:19 -0300 | [diff] [blame] | 410 | |
| 411 | void *mem; |
| 412 | unsigned int length; |
| 413 | unsigned int bytesused; |
Laurent Pinchart | 66847ef | 2011-09-24 10:46:55 -0300 | [diff] [blame] | 414 | |
| 415 | u32 pts; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 416 | }; |
| 417 | |
Laurent Pinchart | 6998b6f | 2011-10-24 11:53:59 -0300 | [diff] [blame] | 418 | #define UVC_QUEUE_DISCONNECTED (1 << 0) |
| 419 | #define UVC_QUEUE_DROP_CORRUPTED (1 << 1) |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 420 | |
| 421 | struct uvc_video_queue { |
Laurent Pinchart | 6998b6f | 2011-10-24 11:53:59 -0300 | [diff] [blame] | 422 | struct vb2_queue queue; |
| 423 | struct mutex mutex; /* Protects queue */ |
Laurent Pinchart | ff92420 | 2008-12-28 22:32:29 -0300 | [diff] [blame] | 424 | |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 425 | unsigned int flags; |
Laurent Pinchart | ff92420 | 2008-12-28 22:32:29 -0300 | [diff] [blame] | 426 | unsigned int buf_used; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 427 | |
Laurent Pinchart | 6998b6f | 2011-10-24 11:53:59 -0300 | [diff] [blame] | 428 | spinlock_t irqlock; /* Protects irqqueue */ |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 429 | struct list_head irqqueue; |
| 430 | }; |
| 431 | |
Laurent Pinchart | 8e11359 | 2009-07-01 20:24:47 -0300 | [diff] [blame] | 432 | struct uvc_video_chain { |
| 433 | struct uvc_device *dev; |
| 434 | struct list_head list; |
| 435 | |
Laurent Pinchart | 6241d8c | 2009-11-25 12:00:22 -0300 | [diff] [blame] | 436 | struct list_head entities; /* All entities */ |
Laurent Pinchart | 8e11359 | 2009-07-01 20:24:47 -0300 | [diff] [blame] | 437 | struct uvc_entity *processing; /* Processing unit */ |
| 438 | struct uvc_entity *selector; /* Selector unit */ |
Laurent Pinchart | 8e11359 | 2009-07-01 20:24:47 -0300 | [diff] [blame] | 439 | |
Laurent Pinchart | 27a61c1 | 2010-10-02 09:04:53 -0300 | [diff] [blame] | 440 | struct mutex ctrl_mutex; /* Protects ctrl.info */ |
Laurent Pinchart | f887e99 | 2012-08-28 18:38:58 -0300 | [diff] [blame] | 441 | |
Laurent Pinchart | 0550513 | 2012-08-28 20:29:56 -0300 | [diff] [blame] | 442 | struct v4l2_prio_state prio; /* V4L2 priority state */ |
Laurent Pinchart | f887e99 | 2012-08-28 18:38:58 -0300 | [diff] [blame] | 443 | u32 caps; /* V4L2 chain-wide caps */ |
Laurent Pinchart | 8e11359 | 2009-07-01 20:24:47 -0300 | [diff] [blame] | 444 | }; |
| 445 | |
Alexey Fisher | 7bc5edb | 2011-11-03 11:40:08 -0300 | [diff] [blame] | 446 | struct uvc_stats_frame { |
| 447 | unsigned int size; /* Number of bytes captured */ |
| 448 | unsigned int first_data; /* Index of the first non-empty packet */ |
| 449 | |
| 450 | unsigned int nb_packets; /* Number of packets */ |
| 451 | unsigned int nb_empty; /* Number of empty packets */ |
| 452 | unsigned int nb_invalid; /* Number of packets with an invalid header */ |
| 453 | unsigned int nb_errors; /* Number of packets with the error bit set */ |
Laurent Pinchart | 25738cb | 2011-11-03 12:30:17 -0300 | [diff] [blame] | 454 | |
| 455 | unsigned int nb_pts; /* Number of packets with a PTS timestamp */ |
| 456 | unsigned int nb_pts_diffs; /* Number of PTS differences inside a frame */ |
| 457 | unsigned int last_pts_diff; /* Index of the last PTS difference */ |
| 458 | bool has_initial_pts; /* Whether the first non-empty packet has a PTS */ |
| 459 | bool has_early_pts; /* Whether a PTS is present before the first non-empty packet */ |
| 460 | u32 pts; /* PTS of the last packet */ |
| 461 | |
| 462 | unsigned int nb_scr; /* Number of packets with a SCR timestamp */ |
| 463 | unsigned int nb_scr_diffs; /* Number of SCR.STC differences inside a frame */ |
| 464 | u16 scr_sof; /* SCR.SOF of the last packet */ |
| 465 | u32 scr_stc; /* SCR.STC of the last packet */ |
Alexey Fisher | 7bc5edb | 2011-11-03 11:40:08 -0300 | [diff] [blame] | 466 | }; |
| 467 | |
| 468 | struct uvc_stats_stream { |
Arnd Bergmann | a70b8b2 | 2017-11-27 08:19:53 -0500 | [diff] [blame] | 469 | ktime_t start_ts; /* Stream start timestamp */ |
| 470 | ktime_t stop_ts; /* Stream stop timestamp */ |
Alexey Fisher | 7bc5edb | 2011-11-03 11:40:08 -0300 | [diff] [blame] | 471 | |
| 472 | unsigned int nb_frames; /* Number of frames */ |
| 473 | |
| 474 | unsigned int nb_packets; /* Number of packets */ |
| 475 | unsigned int nb_empty; /* Number of empty packets */ |
| 476 | unsigned int nb_invalid; /* Number of packets with an invalid header */ |
| 477 | unsigned int nb_errors; /* Number of packets with the error bit set */ |
Laurent Pinchart | 25738cb | 2011-11-03 12:30:17 -0300 | [diff] [blame] | 478 | |
| 479 | unsigned int nb_pts_constant; /* Number of frames with constant PTS */ |
| 480 | unsigned int nb_pts_early; /* Number of frames with early PTS */ |
| 481 | unsigned int nb_pts_initial; /* Number of frames with initial PTS */ |
| 482 | |
| 483 | unsigned int nb_scr_count_ok; /* Number of frames with at least one SCR per non empty packet */ |
| 484 | unsigned int nb_scr_diffs_ok; /* Number of frames with varying SCR.STC */ |
| 485 | unsigned int scr_sof_count; /* STC.SOF counter accumulated since stream start */ |
| 486 | unsigned int scr_sof; /* STC.SOF of the last packet */ |
| 487 | unsigned int min_sof; /* Minimum STC.SOF value */ |
| 488 | unsigned int max_sof; /* Maximum STC.SOF value */ |
Alexey Fisher | 7bc5edb | 2011-11-03 11:40:08 -0300 | [diff] [blame] | 489 | }; |
| 490 | |
Guennadi Liakhovetski | 088ead2 | 2017-12-06 10:15:40 -0500 | [diff] [blame] | 491 | #define UVC_METATADA_BUF_SIZE 1024 |
| 492 | |
Laurent Pinchart | 35f02a6 | 2009-06-28 08:37:50 -0300 | [diff] [blame] | 493 | struct uvc_streaming { |
| 494 | struct list_head list; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 495 | struct uvc_device *dev; |
Hans Verkuil | d8da751 | 2015-03-09 13:34:11 -0300 | [diff] [blame] | 496 | struct video_device vdev; |
Laurent Pinchart | 8e11359 | 2009-07-01 20:24:47 -0300 | [diff] [blame] | 497 | struct uvc_video_chain *chain; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 498 | atomic_t active; |
Laurent Pinchart | 35f02a6 | 2009-06-28 08:37:50 -0300 | [diff] [blame] | 499 | |
| 500 | struct usb_interface *intf; |
| 501 | int intfnum; |
Laurent Pinchart | 2c6b222 | 2018-01-16 12:45:36 -0500 | [diff] [blame] | 502 | u16 maxpsize; |
Laurent Pinchart | 35f02a6 | 2009-06-28 08:37:50 -0300 | [diff] [blame] | 503 | |
| 504 | struct uvc_streaming_header header; |
| 505 | enum v4l2_buf_type type; |
| 506 | |
| 507 | unsigned int nformats; |
| 508 | struct uvc_format *format; |
| 509 | |
| 510 | struct uvc_streaming_control ctrl; |
Laurent Pinchart | 815adc4 | 2012-08-28 18:38:58 -0300 | [diff] [blame] | 511 | struct uvc_format *def_format; |
Laurent Pinchart | 35f02a6 | 2009-06-28 08:37:50 -0300 | [diff] [blame] | 512 | struct uvc_format *cur_format; |
| 513 | struct uvc_frame *cur_frame; |
Guennadi Liakhovetski | e93e7fd | 2014-09-09 04:42:43 -0300 | [diff] [blame] | 514 | |
Laurent Pinchart | 6947756 | 2010-11-21 13:36:34 -0300 | [diff] [blame] | 515 | /* Protect access to ctrl, cur_format, cur_frame and hardware video |
| 516 | * probe control. |
| 517 | */ |
Laurent Pinchart | 35f02a6 | 2009-06-28 08:37:50 -0300 | [diff] [blame] | 518 | struct mutex mutex; |
| 519 | |
Laurent Pinchart | 6998b6f | 2011-10-24 11:53:59 -0300 | [diff] [blame] | 520 | /* Buffers queue. */ |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 521 | unsigned int frozen : 1; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 522 | struct uvc_video_queue queue; |
Laurent Pinchart | 35f02a6 | 2009-06-28 08:37:50 -0300 | [diff] [blame] | 523 | void (*decode) (struct urb *urb, struct uvc_streaming *video, |
Guennadi Liakhovetski | 088ead2 | 2017-12-06 10:15:40 -0500 | [diff] [blame] | 524 | struct uvc_buffer *buf, struct uvc_buffer *meta_buf); |
| 525 | |
| 526 | struct { |
| 527 | struct video_device vdev; |
| 528 | struct uvc_video_queue queue; |
Laurent Pinchart | 2c6b222 | 2018-01-16 12:45:36 -0500 | [diff] [blame] | 529 | u32 format; |
Guennadi Liakhovetski | 088ead2 | 2017-12-06 10:15:40 -0500 | [diff] [blame] | 530 | } meta; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 531 | |
| 532 | /* Context data used by the bulk completion handler. */ |
| 533 | struct { |
Laurent Pinchart | 2c6b222 | 2018-01-16 12:45:36 -0500 | [diff] [blame] | 534 | u8 header[256]; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 535 | unsigned int header_size; |
| 536 | int skip_payload; |
Laurent Pinchart | 2c6b222 | 2018-01-16 12:45:36 -0500 | [diff] [blame] | 537 | u32 payload_size; |
| 538 | u32 max_payload_size; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 539 | } bulk; |
| 540 | |
| 541 | struct urb *urb[UVC_URBS]; |
| 542 | char *urb_buffer[UVC_URBS]; |
Laurent Pinchart | e01117c | 2008-07-04 00:36:21 -0300 | [diff] [blame] | 543 | dma_addr_t urb_dma[UVC_URBS]; |
| 544 | unsigned int urb_size; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 545 | |
Laurent Pinchart | 2c6b222 | 2018-01-16 12:45:36 -0500 | [diff] [blame] | 546 | u32 sequence; |
| 547 | u8 last_fid; |
Alexey Fisher | edbaa39 | 2011-11-03 09:39:37 -0300 | [diff] [blame] | 548 | |
| 549 | /* debugfs */ |
| 550 | struct dentry *debugfs_dir; |
Alexey Fisher | 7bc5edb | 2011-11-03 11:40:08 -0300 | [diff] [blame] | 551 | struct { |
| 552 | struct uvc_stats_frame frame; |
| 553 | struct uvc_stats_stream stream; |
| 554 | } stats; |
Laurent Pinchart | 66847ef | 2011-09-24 10:46:55 -0300 | [diff] [blame] | 555 | |
| 556 | /* Timestamps support. */ |
| 557 | struct uvc_clock { |
| 558 | struct uvc_clock_sample { |
| 559 | u32 dev_stc; |
| 560 | u16 dev_sof; |
Laurent Pinchart | 66847ef | 2011-09-24 10:46:55 -0300 | [diff] [blame] | 561 | u16 host_sof; |
Arnd Bergmann | 828ee8c | 2017-11-27 08:19:54 -0500 | [diff] [blame] | 562 | ktime_t host_time; |
Laurent Pinchart | 66847ef | 2011-09-24 10:46:55 -0300 | [diff] [blame] | 563 | } *samples; |
| 564 | |
| 565 | unsigned int head; |
| 566 | unsigned int count; |
| 567 | unsigned int size; |
| 568 | |
| 569 | u16 last_sof; |
| 570 | u16 sof_offset; |
| 571 | |
Guennadi Liakhovetski | 088ead2 | 2017-12-06 10:15:40 -0500 | [diff] [blame] | 572 | u8 last_scr[6]; |
| 573 | |
Laurent Pinchart | 66847ef | 2011-09-24 10:46:55 -0300 | [diff] [blame] | 574 | spinlock_t lock; |
| 575 | } clock; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 576 | }; |
| 577 | |
Laurent Pinchart | 3a03284 | 2018-08-17 04:50:02 -0400 | [diff] [blame] | 578 | struct uvc_device_info { |
| 579 | u32 quirks; |
| 580 | u32 meta_format; |
| 581 | }; |
| 582 | |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 583 | struct uvc_device { |
| 584 | struct usb_device *udev; |
| 585 | struct usb_interface *intf; |
Laurent Pinchart | 44f0079 | 2008-11-08 19:14:50 -0300 | [diff] [blame] | 586 | unsigned long warnings; |
Laurent Pinchart | 2c6b222 | 2018-01-16 12:45:36 -0500 | [diff] [blame] | 587 | u32 quirks; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 588 | int intfnum; |
| 589 | char name[32]; |
| 590 | |
Laurent Pinchart | 3a03284 | 2018-08-17 04:50:02 -0400 | [diff] [blame] | 591 | const struct uvc_device_info *info; |
| 592 | |
Laurent Pinchart | 17706f5 | 2013-04-25 22:28:51 -0300 | [diff] [blame] | 593 | struct mutex lock; /* Protects users */ |
| 594 | unsigned int users; |
Martin Rubli | 8fb91b3 | 2010-09-08 04:15:23 -0300 | [diff] [blame] | 595 | atomic_t nmappings; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 596 | |
| 597 | /* Video control interface */ |
Laurent Pinchart | 5a254d7 | 2010-01-21 05:39:47 -0300 | [diff] [blame] | 598 | #ifdef CONFIG_MEDIA_CONTROLLER |
| 599 | struct media_device mdev; |
| 600 | #endif |
| 601 | struct v4l2_device vdev; |
Laurent Pinchart | 2c6b222 | 2018-01-16 12:45:36 -0500 | [diff] [blame] | 602 | u16 uvc_version; |
| 603 | u32 clock_frequency; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 604 | |
| 605 | struct list_head entities; |
Laurent Pinchart | 8e11359 | 2009-07-01 20:24:47 -0300 | [diff] [blame] | 606 | struct list_head chains; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 607 | |
Laurent Pinchart | 35f02a6 | 2009-06-28 08:37:50 -0300 | [diff] [blame] | 608 | /* Video Streaming interfaces */ |
| 609 | struct list_head streams; |
Guennadi Liakhovetski | 9d15cd9 | 2017-08-08 08:56:23 -0400 | [diff] [blame] | 610 | struct kref ref; |
Laurent Pinchart | 35f02a6 | 2009-06-28 08:37:50 -0300 | [diff] [blame] | 611 | |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 612 | /* Status Interrupt Endpoint */ |
| 613 | struct usb_host_endpoint *int_ep; |
| 614 | struct urb *int_urb; |
Laurent Pinchart | 2c6b222 | 2018-01-16 12:45:36 -0500 | [diff] [blame] | 615 | u8 *status; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 616 | struct input_dev *input; |
Laurent Pinchart | f180152 | 2009-01-22 12:45:10 -0300 | [diff] [blame] | 617 | char input_phys[64]; |
Guennadi Liakhovetski | e5225c8 | 2018-07-26 04:17:53 -0400 | [diff] [blame] | 618 | |
| 619 | struct uvc_ctrl_work { |
| 620 | struct work_struct work; |
| 621 | struct urb *urb; |
| 622 | struct uvc_video_chain *chain; |
| 623 | struct uvc_control *ctrl; |
| 624 | const void *data; |
| 625 | } async_ctrl; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 626 | }; |
| 627 | |
| 628 | enum uvc_handle_state { |
| 629 | UVC_HANDLE_PASSIVE = 0, |
| 630 | UVC_HANDLE_ACTIVE = 1, |
| 631 | }; |
| 632 | |
| 633 | struct uvc_fh { |
Hans de Goede | b401200 | 2012-04-08 12:59:51 -0300 | [diff] [blame] | 634 | struct v4l2_fh vfh; |
Laurent Pinchart | 8e11359 | 2009-07-01 20:24:47 -0300 | [diff] [blame] | 635 | struct uvc_video_chain *chain; |
Laurent Pinchart | 35f02a6 | 2009-06-28 08:37:50 -0300 | [diff] [blame] | 636 | struct uvc_streaming *stream; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 637 | enum uvc_handle_state state; |
| 638 | }; |
| 639 | |
| 640 | struct uvc_driver { |
| 641 | struct usb_driver driver; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 642 | }; |
| 643 | |
| 644 | /* ------------------------------------------------------------------------ |
| 645 | * Debugging, printing and logging |
| 646 | */ |
| 647 | |
| 648 | #define UVC_TRACE_PROBE (1 << 0) |
| 649 | #define UVC_TRACE_DESCR (1 << 1) |
| 650 | #define UVC_TRACE_CONTROL (1 << 2) |
| 651 | #define UVC_TRACE_FORMAT (1 << 3) |
| 652 | #define UVC_TRACE_CAPTURE (1 << 4) |
| 653 | #define UVC_TRACE_CALLS (1 << 5) |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 654 | #define UVC_TRACE_FRAME (1 << 7) |
| 655 | #define UVC_TRACE_SUSPEND (1 << 8) |
| 656 | #define UVC_TRACE_STATUS (1 << 9) |
Laurent Pinchart | 663a419 | 2009-08-06 11:41:17 -0300 | [diff] [blame] | 657 | #define UVC_TRACE_VIDEO (1 << 10) |
Alexey Fisher | 7bc5edb | 2011-11-03 11:40:08 -0300 | [diff] [blame] | 658 | #define UVC_TRACE_STATS (1 << 11) |
Laurent Pinchart | 66847ef | 2011-09-24 10:46:55 -0300 | [diff] [blame] | 659 | #define UVC_TRACE_CLOCK (1 << 12) |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 660 | |
Laurent Pinchart | 44f0079 | 2008-11-08 19:14:50 -0300 | [diff] [blame] | 661 | #define UVC_WARN_MINMAX 0 |
| 662 | #define UVC_WARN_PROBE_DEF 1 |
Laurent Pinchart | c4d99f8 | 2010-09-30 09:04:03 -0300 | [diff] [blame] | 663 | #define UVC_WARN_XU_GET_RES 2 |
Laurent Pinchart | 44f0079 | 2008-11-08 19:14:50 -0300 | [diff] [blame] | 664 | |
Laurent Pinchart | 310fe52 | 2009-12-09 22:57:48 -0300 | [diff] [blame] | 665 | extern unsigned int uvc_clock_param; |
Laurent Pinchart | 0fbd8ee | 2008-12-06 16:25:14 -0300 | [diff] [blame] | 666 | extern unsigned int uvc_no_drop_param; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 667 | extern unsigned int uvc_trace_param; |
Laurent Pinchart | b232a01 | 2009-10-09 20:55:23 -0300 | [diff] [blame] | 668 | extern unsigned int uvc_timeout_param; |
Laurent Pinchart | 5d0fd3c | 2015-07-27 11:06:48 -0300 | [diff] [blame] | 669 | extern unsigned int uvc_hw_timestamps_param; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 670 | |
| 671 | #define uvc_trace(flag, msg...) \ |
| 672 | do { \ |
| 673 | if (uvc_trace_param & flag) \ |
| 674 | printk(KERN_DEBUG "uvcvideo: " msg); \ |
| 675 | } while (0) |
| 676 | |
Laurent Pinchart | 44f0079 | 2008-11-08 19:14:50 -0300 | [diff] [blame] | 677 | #define uvc_warn_once(dev, warn, msg...) \ |
| 678 | do { \ |
| 679 | if (!test_and_set_bit(warn, &dev->warnings)) \ |
| 680 | printk(KERN_INFO "uvcvideo: " msg); \ |
| 681 | } while (0) |
| 682 | |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 683 | #define uvc_printk(level, msg...) \ |
| 684 | printk(level "uvcvideo: " msg) |
| 685 | |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 686 | /* -------------------------------------------------------------------------- |
| 687 | * Internal functions. |
| 688 | */ |
| 689 | |
| 690 | /* Core driver */ |
| 691 | extern struct uvc_driver uvc_driver; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 692 | |
Laurent Pinchart | cb9cd6c | 2018-01-16 12:32:54 -0500 | [diff] [blame] | 693 | struct uvc_entity *uvc_entity_by_id(struct uvc_device *dev, int id); |
Laurent Pinchart | 4ffc2d8 | 2010-01-21 05:39:52 -0300 | [diff] [blame] | 694 | |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 695 | /* Video buffers queue management. */ |
Laurent Pinchart | cb9cd6c | 2018-01-16 12:32:54 -0500 | [diff] [blame] | 696 | int uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type, |
| 697 | int drop_corrupted); |
| 698 | void uvc_queue_release(struct uvc_video_queue *queue); |
| 699 | int uvc_request_buffers(struct uvc_video_queue *queue, |
| 700 | struct v4l2_requestbuffers *rb); |
| 701 | int uvc_query_buffer(struct uvc_video_queue *queue, |
| 702 | struct v4l2_buffer *v4l2_buf); |
| 703 | int uvc_create_buffers(struct uvc_video_queue *queue, |
| 704 | struct v4l2_create_buffers *v4l2_cb); |
| 705 | int uvc_queue_buffer(struct uvc_video_queue *queue, |
Hans Verkuil | 394dc58 | 2018-05-30 02:46:22 -0400 | [diff] [blame] | 706 | struct media_device *mdev, |
Laurent Pinchart | cb9cd6c | 2018-01-16 12:32:54 -0500 | [diff] [blame] | 707 | struct v4l2_buffer *v4l2_buf); |
| 708 | int uvc_export_buffer(struct uvc_video_queue *queue, |
| 709 | struct v4l2_exportbuffer *exp); |
| 710 | int uvc_dequeue_buffer(struct uvc_video_queue *queue, |
| 711 | struct v4l2_buffer *v4l2_buf, int nonblocking); |
| 712 | int uvc_queue_streamon(struct uvc_video_queue *queue, enum v4l2_buf_type type); |
| 713 | int uvc_queue_streamoff(struct uvc_video_queue *queue, enum v4l2_buf_type type); |
| 714 | void uvc_queue_cancel(struct uvc_video_queue *queue, int disconnect); |
| 715 | struct uvc_buffer *uvc_queue_next_buffer(struct uvc_video_queue *queue, |
| 716 | struct uvc_buffer *buf); |
| 717 | int uvc_queue_mmap(struct uvc_video_queue *queue, |
| 718 | struct vm_area_struct *vma); |
| 719 | __poll_t uvc_queue_poll(struct uvc_video_queue *queue, struct file *file, |
| 720 | poll_table *wait); |
Bob Liu | 7296944 | 2011-04-29 07:11:35 -0300 | [diff] [blame] | 721 | #ifndef CONFIG_MMU |
Laurent Pinchart | cb9cd6c | 2018-01-16 12:32:54 -0500 | [diff] [blame] | 722 | unsigned long uvc_queue_get_unmapped_area(struct uvc_video_queue *queue, |
| 723 | unsigned long pgoff); |
Bob Liu | 7296944 | 2011-04-29 07:11:35 -0300 | [diff] [blame] | 724 | #endif |
Laurent Pinchart | cb9cd6c | 2018-01-16 12:32:54 -0500 | [diff] [blame] | 725 | int uvc_queue_allocated(struct uvc_video_queue *queue); |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 726 | static inline int uvc_queue_streaming(struct uvc_video_queue *queue) |
| 727 | { |
Laurent Pinchart | 6998b6f | 2011-10-24 11:53:59 -0300 | [diff] [blame] | 728 | return vb2_is_streaming(&queue->queue); |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 729 | } |
| 730 | |
| 731 | /* V4L2 interface */ |
Laurent Pinchart | d5e90b7 | 2010-09-30 10:17:54 -0300 | [diff] [blame] | 732 | extern const struct v4l2_ioctl_ops uvc_ioctl_ops; |
Hans Verkuil | bec4366 | 2008-12-30 06:58:20 -0300 | [diff] [blame] | 733 | extern const struct v4l2_file_operations uvc_fops; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 734 | |
Laurent Pinchart | 4ffc2d8 | 2010-01-21 05:39:52 -0300 | [diff] [blame] | 735 | /* Media controller */ |
Laurent Pinchart | cb9cd6c | 2018-01-16 12:32:54 -0500 | [diff] [blame] | 736 | int uvc_mc_register_entities(struct uvc_video_chain *chain); |
| 737 | void uvc_mc_cleanup_entity(struct uvc_entity *entity); |
Laurent Pinchart | 4ffc2d8 | 2010-01-21 05:39:52 -0300 | [diff] [blame] | 738 | |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 739 | /* Video */ |
Laurent Pinchart | cb9cd6c | 2018-01-16 12:32:54 -0500 | [diff] [blame] | 740 | int uvc_video_init(struct uvc_streaming *stream); |
| 741 | int uvc_video_suspend(struct uvc_streaming *stream); |
| 742 | int uvc_video_resume(struct uvc_streaming *stream, int reset); |
| 743 | int uvc_video_enable(struct uvc_streaming *stream, int enable); |
| 744 | int uvc_probe_video(struct uvc_streaming *stream, |
| 745 | struct uvc_streaming_control *probe); |
Laurent Pinchart | 2c6b222 | 2018-01-16 12:45:36 -0500 | [diff] [blame] | 746 | int uvc_query_ctrl(struct uvc_device *dev, u8 query, u8 unit, |
| 747 | u8 intfnum, u8 cs, void *data, u16 size); |
Laurent Pinchart | 66847ef | 2011-09-24 10:46:55 -0300 | [diff] [blame] | 748 | void uvc_video_clock_update(struct uvc_streaming *stream, |
Junghak Sung | 2d70071 | 2015-09-22 10:30:30 -0300 | [diff] [blame] | 749 | struct vb2_v4l2_buffer *vbuf, |
Laurent Pinchart | 66847ef | 2011-09-24 10:46:55 -0300 | [diff] [blame] | 750 | struct uvc_buffer *buf); |
Guennadi Liakhovetski | 088ead2 | 2017-12-06 10:15:40 -0500 | [diff] [blame] | 751 | int uvc_meta_register(struct uvc_streaming *stream); |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 752 | |
Laurent Pinchart | 31a96f4 | 2017-12-04 18:05:17 -0500 | [diff] [blame] | 753 | int uvc_register_video_device(struct uvc_device *dev, |
| 754 | struct uvc_streaming *stream, |
| 755 | struct video_device *vdev, |
| 756 | struct uvc_video_queue *queue, |
| 757 | enum v4l2_buf_type type, |
| 758 | const struct v4l2_file_operations *fops, |
| 759 | const struct v4l2_ioctl_ops *ioctl_ops); |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 760 | |
| 761 | /* Status */ |
Laurent Pinchart | cb9cd6c | 2018-01-16 12:32:54 -0500 | [diff] [blame] | 762 | int uvc_status_init(struct uvc_device *dev); |
| 763 | void uvc_status_cleanup(struct uvc_device *dev); |
| 764 | int uvc_status_start(struct uvc_device *dev, gfp_t flags); |
| 765 | void uvc_status_stop(struct uvc_device *dev); |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 766 | |
| 767 | /* Controls */ |
Hans de Goede | b401200 | 2012-04-08 12:59:51 -0300 | [diff] [blame] | 768 | extern const struct v4l2_subscribed_event_ops uvc_ctrl_sub_ev_ops; |
| 769 | |
Laurent Pinchart | cb9cd6c | 2018-01-16 12:32:54 -0500 | [diff] [blame] | 770 | int uvc_query_v4l2_ctrl(struct uvc_video_chain *chain, |
| 771 | struct v4l2_queryctrl *v4l2_ctrl); |
| 772 | int uvc_query_v4l2_menu(struct uvc_video_chain *chain, |
| 773 | struct v4l2_querymenu *query_menu); |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 774 | |
Laurent Pinchart | cb9cd6c | 2018-01-16 12:32:54 -0500 | [diff] [blame] | 775 | int uvc_ctrl_add_mapping(struct uvc_video_chain *chain, |
| 776 | const struct uvc_control_mapping *mapping); |
| 777 | int uvc_ctrl_init_device(struct uvc_device *dev); |
| 778 | void uvc_ctrl_cleanup_device(struct uvc_device *dev); |
| 779 | int uvc_ctrl_restore_values(struct uvc_device *dev); |
Guennadi Liakhovetski | e5225c8 | 2018-07-26 04:17:53 -0400 | [diff] [blame] | 780 | bool uvc_ctrl_status_event(struct urb *urb, struct uvc_video_chain *chain, |
| 781 | struct uvc_control *ctrl, const u8 *data); |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 782 | |
Laurent Pinchart | cb9cd6c | 2018-01-16 12:32:54 -0500 | [diff] [blame] | 783 | int uvc_ctrl_begin(struct uvc_video_chain *chain); |
| 784 | int __uvc_ctrl_commit(struct uvc_fh *handle, int rollback, |
| 785 | const struct v4l2_ext_control *xctrls, |
| 786 | unsigned int xctrls_count); |
Hans de Goede | b401200 | 2012-04-08 12:59:51 -0300 | [diff] [blame] | 787 | static inline int uvc_ctrl_commit(struct uvc_fh *handle, |
Laurent Pinchart | cb9cd6c | 2018-01-16 12:32:54 -0500 | [diff] [blame] | 788 | const struct v4l2_ext_control *xctrls, |
| 789 | unsigned int xctrls_count) |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 790 | { |
Hans de Goede | b401200 | 2012-04-08 12:59:51 -0300 | [diff] [blame] | 791 | return __uvc_ctrl_commit(handle, 0, xctrls, xctrls_count); |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 792 | } |
Hans de Goede | b401200 | 2012-04-08 12:59:51 -0300 | [diff] [blame] | 793 | static inline int uvc_ctrl_rollback(struct uvc_fh *handle) |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 794 | { |
Hans de Goede | b401200 | 2012-04-08 12:59:51 -0300 | [diff] [blame] | 795 | return __uvc_ctrl_commit(handle, 1, NULL, 0); |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 796 | } |
| 797 | |
Laurent Pinchart | cb9cd6c | 2018-01-16 12:32:54 -0500 | [diff] [blame] | 798 | int uvc_ctrl_get(struct uvc_video_chain *chain, struct v4l2_ext_control *xctrl); |
Guennadi Liakhovetski | e5225c8 | 2018-07-26 04:17:53 -0400 | [diff] [blame] | 799 | int uvc_ctrl_set(struct uvc_fh *handle, struct v4l2_ext_control *xctrl); |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 800 | |
Laurent Pinchart | cb9cd6c | 2018-01-16 12:32:54 -0500 | [diff] [blame] | 801 | int uvc_xu_ctrl_query(struct uvc_video_chain *chain, |
| 802 | struct uvc_xu_control_query *xqry); |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 803 | |
| 804 | /* Utility functions */ |
Laurent Pinchart | 1e304c4 | 2018-01-16 12:35:17 -0500 | [diff] [blame] | 805 | void uvc_simplify_fraction(u32 *numerator, u32 *denominator, |
Laurent Pinchart | cb9cd6c | 2018-01-16 12:32:54 -0500 | [diff] [blame] | 806 | unsigned int n_terms, unsigned int threshold); |
Laurent Pinchart | 1e304c4 | 2018-01-16 12:35:17 -0500 | [diff] [blame] | 807 | u32 uvc_fraction_to_interval(u32 numerator, u32 denominator); |
Laurent Pinchart | cb9cd6c | 2018-01-16 12:32:54 -0500 | [diff] [blame] | 808 | struct usb_host_endpoint *uvc_find_endpoint(struct usb_host_interface *alts, |
Laurent Pinchart | 2c6b222 | 2018-01-16 12:45:36 -0500 | [diff] [blame] | 809 | u8 epaddr); |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 810 | |
| 811 | /* Quirks support */ |
Laurent Pinchart | 35f02a6 | 2009-06-28 08:37:50 -0300 | [diff] [blame] | 812 | void uvc_video_decode_isight(struct urb *urb, struct uvc_streaming *stream, |
Laurent Pinchart | cb9cd6c | 2018-01-16 12:32:54 -0500 | [diff] [blame] | 813 | struct uvc_buffer *buf, |
| 814 | struct uvc_buffer *meta_buf); |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 815 | |
Alexey Fisher | 7bc5edb | 2011-11-03 11:40:08 -0300 | [diff] [blame] | 816 | /* debugfs and statistics */ |
Jaejoong Kim | 39dc3aa | 2017-01-11 23:31:21 -0200 | [diff] [blame] | 817 | void uvc_debugfs_init(void); |
Alexey Fisher | edbaa39 | 2011-11-03 09:39:37 -0300 | [diff] [blame] | 818 | void uvc_debugfs_cleanup(void); |
Jaejoong Kim | 39dc3aa | 2017-01-11 23:31:21 -0200 | [diff] [blame] | 819 | void uvc_debugfs_init_stream(struct uvc_streaming *stream); |
Alexey Fisher | edbaa39 | 2011-11-03 09:39:37 -0300 | [diff] [blame] | 820 | void uvc_debugfs_cleanup_stream(struct uvc_streaming *stream); |
| 821 | |
Alexey Fisher | 7bc5edb | 2011-11-03 11:40:08 -0300 | [diff] [blame] | 822 | size_t uvc_video_stats_dump(struct uvc_streaming *stream, char *buf, |
| 823 | size_t size); |
| 824 | |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 825 | #endif |