Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 1 | #ifndef _USB_VIDEO_H_ |
| 2 | #define _USB_VIDEO_H_ |
| 3 | |
| 4 | #include <linux/kernel.h> |
| 5 | #include <linux/videodev2.h> |
| 6 | |
Laurent Pinchart | 5f70881 | 2010-11-21 17:15:44 -0300 | [diff] [blame] | 7 | #ifndef __KERNEL__ |
| 8 | /* |
| 9 | * This header provides binary compatibility with applications using the private |
| 10 | * uvcvideo API. This API is deprecated and will be removed in 2.6.42. |
| 11 | * Applications should be recompiled against the public linux/uvcvideo.h header. |
| 12 | */ |
| 13 | #warn "The uvcvideo.h header is deprecated, use linux/uvcvideo.h instead." |
| 14 | |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 15 | /* |
| 16 | * Dynamic controls |
| 17 | */ |
| 18 | |
| 19 | /* Data types for UVC control data */ |
| 20 | #define UVC_CTRL_DATA_TYPE_RAW 0 |
| 21 | #define UVC_CTRL_DATA_TYPE_SIGNED 1 |
| 22 | #define UVC_CTRL_DATA_TYPE_UNSIGNED 2 |
| 23 | #define UVC_CTRL_DATA_TYPE_BOOLEAN 3 |
| 24 | #define UVC_CTRL_DATA_TYPE_ENUM 4 |
| 25 | #define UVC_CTRL_DATA_TYPE_BITMASK 5 |
| 26 | |
| 27 | /* Control flags */ |
| 28 | #define UVC_CONTROL_SET_CUR (1 << 0) |
| 29 | #define UVC_CONTROL_GET_CUR (1 << 1) |
| 30 | #define UVC_CONTROL_GET_MIN (1 << 2) |
| 31 | #define UVC_CONTROL_GET_MAX (1 << 3) |
| 32 | #define UVC_CONTROL_GET_RES (1 << 4) |
| 33 | #define UVC_CONTROL_GET_DEF (1 << 5) |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 34 | #define UVC_CONTROL_RESTORE (1 << 6) |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 35 | #define UVC_CONTROL_AUTO_UPDATE (1 << 7) |
| 36 | |
| 37 | #define UVC_CONTROL_GET_RANGE (UVC_CONTROL_GET_CUR | UVC_CONTROL_GET_MIN | \ |
| 38 | UVC_CONTROL_GET_MAX | UVC_CONTROL_GET_RES | \ |
| 39 | UVC_CONTROL_GET_DEF) |
| 40 | |
Laurent Pinchart | 561474c | 2010-02-18 16:38:52 -0300 | [diff] [blame] | 41 | struct uvc_menu_info { |
| 42 | __u32 value; |
| 43 | __u8 name[32]; |
| 44 | }; |
| 45 | |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 46 | struct uvc_xu_control_mapping { |
| 47 | __u32 id; |
| 48 | __u8 name[32]; |
| 49 | __u8 entity[16]; |
| 50 | __u8 selector; |
| 51 | |
| 52 | __u8 size; |
| 53 | __u8 offset; |
Martin Rubli | fe78d18 | 2010-10-02 19:10:16 -0300 | [diff] [blame] | 54 | __u32 v4l2_type; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 55 | __u32 data_type; |
Laurent Pinchart | 561474c | 2010-02-18 16:38:52 -0300 | [diff] [blame] | 56 | |
| 57 | struct uvc_menu_info __user *menu_info; |
| 58 | __u32 menu_count; |
| 59 | |
| 60 | __u32 reserved[4]; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 61 | }; |
| 62 | |
Laurent Pinchart | 5f70881 | 2010-11-21 17:15:44 -0300 | [diff] [blame] | 63 | #endif |
| 64 | |
| 65 | struct uvc_xu_control_info { |
| 66 | __u8 entity[16]; |
| 67 | __u8 index; |
| 68 | __u8 selector; |
| 69 | __u16 size; |
| 70 | __u32 flags; |
| 71 | }; |
| 72 | |
| 73 | struct uvc_xu_control_mapping_old { |
| 74 | __u8 reserved[64]; |
| 75 | }; |
| 76 | |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 77 | struct uvc_xu_control { |
| 78 | __u8 unit; |
| 79 | __u8 selector; |
| 80 | __u16 size; |
| 81 | __u8 __user *data; |
| 82 | }; |
| 83 | |
Laurent Pinchart | 5f70881 | 2010-11-21 17:15:44 -0300 | [diff] [blame] | 84 | #ifndef __KERNEL__ |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 85 | #define UVCIOC_CTRL_ADD _IOW('U', 1, struct uvc_xu_control_info) |
Laurent Pinchart | 561474c | 2010-02-18 16:38:52 -0300 | [diff] [blame] | 86 | #define UVCIOC_CTRL_MAP_OLD _IOWR('U', 2, struct uvc_xu_control_mapping_old) |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 87 | #define UVCIOC_CTRL_MAP _IOWR('U', 2, struct uvc_xu_control_mapping) |
| 88 | #define UVCIOC_CTRL_GET _IOWR('U', 3, struct uvc_xu_control) |
| 89 | #define UVCIOC_CTRL_SET _IOW('U', 4, struct uvc_xu_control) |
Laurent Pinchart | 5f70881 | 2010-11-21 17:15:44 -0300 | [diff] [blame] | 90 | #else |
| 91 | #define __UVCIOC_CTRL_ADD _IOW('U', 1, struct uvc_xu_control_info) |
| 92 | #define __UVCIOC_CTRL_MAP_OLD _IOWR('U', 2, struct uvc_xu_control_mapping_old) |
| 93 | #define __UVCIOC_CTRL_MAP _IOWR('U', 2, struct uvc_xu_control_mapping) |
| 94 | #define __UVCIOC_CTRL_GET _IOWR('U', 3, struct uvc_xu_control) |
| 95 | #define __UVCIOC_CTRL_SET _IOW('U', 4, struct uvc_xu_control) |
| 96 | #endif |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 97 | |
| 98 | #ifdef __KERNEL__ |
| 99 | |
| 100 | #include <linux/poll.h> |
Laurent Pinchart | 4ffc2d8 | 2010-01-21 05:39:52 -0300 | [diff] [blame] | 101 | #include <linux/usb.h> |
Laurent Pinchart | de05f63 | 2009-06-26 12:15:38 -0300 | [diff] [blame] | 102 | #include <linux/usb/video.h> |
Laurent Pinchart | 5f70881 | 2010-11-21 17:15:44 -0300 | [diff] [blame] | 103 | #include <linux/uvcvideo.h> |
Laurent Pinchart | 5a254d7 | 2010-01-21 05:39:47 -0300 | [diff] [blame] | 104 | #include <media/media-device.h> |
| 105 | #include <media/v4l2-device.h> |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 106 | |
| 107 | /* -------------------------------------------------------------------------- |
| 108 | * UVC constants |
| 109 | */ |
| 110 | |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 111 | #define UVC_TERM_INPUT 0x0000 |
| 112 | #define UVC_TERM_OUTPUT 0x8000 |
Laurent Pinchart | 6241d8c | 2009-11-25 12:00:22 -0300 | [diff] [blame] | 113 | #define UVC_TERM_DIRECTION(term) ((term)->type & 0x8000) |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 114 | |
| 115 | #define UVC_ENTITY_TYPE(entity) ((entity)->type & 0x7fff) |
| 116 | #define UVC_ENTITY_IS_UNIT(entity) (((entity)->type & 0xff00) == 0) |
| 117 | #define UVC_ENTITY_IS_TERM(entity) (((entity)->type & 0xff00) != 0) |
| 118 | #define UVC_ENTITY_IS_ITERM(entity) \ |
Laurent Pinchart | 8e11359 | 2009-07-01 20:24:47 -0300 | [diff] [blame] | 119 | (UVC_ENTITY_IS_TERM(entity) && \ |
| 120 | ((entity)->type & 0x8000) == UVC_TERM_INPUT) |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 121 | #define UVC_ENTITY_IS_OTERM(entity) \ |
Laurent Pinchart | 8e11359 | 2009-07-01 20:24:47 -0300 | [diff] [blame] | 122 | (UVC_ENTITY_IS_TERM(entity) && \ |
| 123 | ((entity)->type & 0x8000) == UVC_TERM_OUTPUT) |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 124 | |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 125 | |
| 126 | /* ------------------------------------------------------------------------ |
| 127 | * GUIDs |
| 128 | */ |
| 129 | #define UVC_GUID_UVC_CAMERA \ |
| 130 | {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ |
| 131 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01} |
| 132 | #define UVC_GUID_UVC_OUTPUT \ |
| 133 | {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ |
| 134 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02} |
| 135 | #define UVC_GUID_UVC_MEDIA_TRANSPORT_INPUT \ |
| 136 | {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ |
| 137 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03} |
| 138 | #define UVC_GUID_UVC_PROCESSING \ |
| 139 | {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ |
| 140 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01} |
| 141 | #define UVC_GUID_UVC_SELECTOR \ |
| 142 | {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ |
| 143 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02} |
| 144 | |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 145 | #define UVC_GUID_FORMAT_MJPEG \ |
| 146 | { 'M', 'J', 'P', 'G', 0x00, 0x00, 0x10, 0x00, \ |
| 147 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} |
| 148 | #define UVC_GUID_FORMAT_YUY2 \ |
| 149 | { 'Y', 'U', 'Y', '2', 0x00, 0x00, 0x10, 0x00, \ |
| 150 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} |
Daniel Ritz | 68f194e | 2009-12-12 14:57:17 -0300 | [diff] [blame] | 151 | #define UVC_GUID_FORMAT_YUY2_ISIGHT \ |
| 152 | { 'Y', 'U', 'Y', '2', 0x00, 0x00, 0x10, 0x00, \ |
| 153 | 0x80, 0x00, 0x00, 0x00, 0x00, 0x38, 0x9b, 0x71} |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 154 | #define UVC_GUID_FORMAT_NV12 \ |
| 155 | { 'N', 'V', '1', '2', 0x00, 0x00, 0x10, 0x00, \ |
| 156 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} |
| 157 | #define UVC_GUID_FORMAT_YV12 \ |
| 158 | { 'Y', 'V', '1', '2', 0x00, 0x00, 0x10, 0x00, \ |
| 159 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} |
| 160 | #define UVC_GUID_FORMAT_I420 \ |
| 161 | { 'I', '4', '2', '0', 0x00, 0x00, 0x10, 0x00, \ |
| 162 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} |
| 163 | #define UVC_GUID_FORMAT_UYVY \ |
| 164 | { 'U', 'Y', 'V', 'Y', 0x00, 0x00, 0x10, 0x00, \ |
| 165 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} |
| 166 | #define UVC_GUID_FORMAT_Y800 \ |
| 167 | { 'Y', '8', '0', '0', 0x00, 0x00, 0x10, 0x00, \ |
| 168 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} |
Laurent Pinchart | 61421206 | 2010-04-12 10:41:22 -0300 | [diff] [blame] | 169 | #define UVC_GUID_FORMAT_Y16 \ |
| 170 | { 'Y', '1', '6', ' ', 0x00, 0x00, 0x10, 0x00, \ |
| 171 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 172 | #define UVC_GUID_FORMAT_BY8 \ |
| 173 | { 'B', 'Y', '8', ' ', 0x00, 0x00, 0x10, 0x00, \ |
| 174 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} |
Laurent Pinchart | 5079107 | 2011-03-06 08:32:04 -0300 | [diff] [blame] | 175 | #define UVC_GUID_FORMAT_RGBP \ |
| 176 | { 'R', 'G', 'B', 'P', 0x00, 0x00, 0x10, 0x00, \ |
| 177 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} |
Hans de Goede | 7225a1d | 2011-05-11 09:56:20 -0300 | [diff] [blame] | 178 | #define UVC_GUID_FORMAT_M420 \ |
| 179 | { 'M', '4', '2', '0', 0x00, 0x00, 0x10, 0x00, \ |
| 180 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 181 | |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 182 | /* ------------------------------------------------------------------------ |
| 183 | * Driver specific constants. |
| 184 | */ |
| 185 | |
Mauro Carvalho Chehab | fd3e582 | 2011-06-25 13:50:37 -0300 | [diff] [blame] | 186 | #define DRIVER_VERSION "1.1.1" |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 187 | |
| 188 | /* Number of isochronous URBs. */ |
| 189 | #define UVC_URBS 5 |
Laurent Pinchart | efdc8a9 | 2009-01-18 17:46:30 -0300 | [diff] [blame] | 190 | /* Maximum number of packets per URB. */ |
| 191 | #define UVC_MAX_PACKETS 32 |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 192 | /* Maximum number of video buffers. */ |
| 193 | #define UVC_MAX_VIDEO_BUFFERS 32 |
Ming Lei | a31a405 | 2008-09-16 03:32:20 -0300 | [diff] [blame] | 194 | /* Maximum status buffer size in bytes of interrupt URB. */ |
| 195 | #define UVC_MAX_STATUS_SIZE 16 |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 196 | |
| 197 | #define UVC_CTRL_CONTROL_TIMEOUT 300 |
Laurent Pinchart | 56d15cd | 2010-01-19 08:59:21 -0300 | [diff] [blame] | 198 | #define UVC_CTRL_STREAMING_TIMEOUT 5000 |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 199 | |
Martin Rubli | 8fb91b3 | 2010-09-08 04:15:23 -0300 | [diff] [blame] | 200 | /* Maximum allowed number of control mappings per device */ |
| 201 | #define UVC_MAX_CONTROL_MAPPINGS 1024 |
| 202 | |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 203 | /* Devices quirks */ |
| 204 | #define UVC_QUIRK_STATUS_INTERVAL 0x00000001 |
| 205 | #define UVC_QUIRK_PROBE_MINMAX 0x00000002 |
| 206 | #define UVC_QUIRK_PROBE_EXTRAFIELDS 0x00000004 |
| 207 | #define UVC_QUIRK_BUILTIN_ISIGHT 0x00000008 |
| 208 | #define UVC_QUIRK_STREAM_NO_FID 0x00000010 |
| 209 | #define UVC_QUIRK_IGNORE_SELECTOR_UNIT 0x00000020 |
Laurent Pinchart | 50144ae | 2009-02-16 17:41:52 -0300 | [diff] [blame] | 210 | #define UVC_QUIRK_FIX_BANDWIDTH 0x00000080 |
Laurent Pinchart | bab6f66 | 2009-07-19 18:39:56 -0300 | [diff] [blame] | 211 | #define UVC_QUIRK_PROBE_DEF 0x00000100 |
Laurent Pinchart | 86d8b6a | 2010-09-16 12:37:26 -0300 | [diff] [blame] | 212 | #define UVC_QUIRK_RESTRICT_FRAME_RATE 0x00000200 |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 213 | |
| 214 | /* Format flags */ |
| 215 | #define UVC_FMT_FLAG_COMPRESSED 0x00000001 |
| 216 | #define UVC_FMT_FLAG_STREAM 0x00000002 |
| 217 | |
| 218 | /* ------------------------------------------------------------------------ |
| 219 | * Structures. |
| 220 | */ |
| 221 | |
| 222 | struct uvc_device; |
| 223 | |
| 224 | /* TODO: Put the most frequently accessed fields at the beginning of |
| 225 | * structures to maximize cache efficiency. |
| 226 | */ |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 227 | struct uvc_control_info { |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 228 | struct list_head mappings; |
| 229 | |
| 230 | __u8 entity[16]; |
Laurent Pinchart | ba2fa99 | 2010-09-20 05:53:21 -0300 | [diff] [blame] | 231 | __u8 index; /* Bit index in bmControls */ |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 232 | __u8 selector; |
| 233 | |
| 234 | __u16 size; |
| 235 | __u32 flags; |
| 236 | }; |
| 237 | |
| 238 | struct uvc_control_mapping { |
| 239 | struct list_head list; |
| 240 | |
| 241 | struct uvc_control_info *ctrl; |
| 242 | |
| 243 | __u32 id; |
| 244 | __u8 name[32]; |
| 245 | __u8 entity[16]; |
| 246 | __u8 selector; |
| 247 | |
| 248 | __u8 size; |
| 249 | __u8 offset; |
| 250 | enum v4l2_ctrl_type v4l2_type; |
| 251 | __u32 data_type; |
| 252 | |
| 253 | struct uvc_menu_info *menu_info; |
| 254 | __u32 menu_count; |
Laurent Pinchart | 9768352 | 2008-12-16 06:46:32 -0300 | [diff] [blame] | 255 | |
| 256 | __s32 (*get) (struct uvc_control_mapping *mapping, __u8 query, |
| 257 | const __u8 *data); |
| 258 | void (*set) (struct uvc_control_mapping *mapping, __s32 value, |
| 259 | __u8 *data); |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 260 | }; |
| 261 | |
| 262 | struct uvc_control { |
| 263 | struct uvc_entity *entity; |
Laurent Pinchart | 071c8bb | 2010-09-29 16:00:08 -0300 | [diff] [blame] | 264 | struct uvc_control_info info; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 265 | |
| 266 | __u8 index; /* Used to match the uvc_control entry with a |
| 267 | uvc_control_info. */ |
Laurent Pinchart | 071c8bb | 2010-09-29 16:00:08 -0300 | [diff] [blame] | 268 | __u8 dirty:1, |
| 269 | loaded:1, |
| 270 | modified:1, |
| 271 | cached:1, |
| 272 | initialized:1; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 273 | |
Laurent Pinchart | b30ece5 | 2010-06-18 11:31:24 -0300 | [diff] [blame] | 274 | __u8 *uvc_data; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 275 | }; |
| 276 | |
| 277 | struct uvc_format_desc { |
| 278 | char *name; |
| 279 | __u8 guid[16]; |
| 280 | __u32 fcc; |
| 281 | }; |
| 282 | |
| 283 | /* The term 'entity' refers to both UVC units and UVC terminals. |
| 284 | * |
| 285 | * The type field is either the terminal type (wTerminalType in the terminal |
| 286 | * descriptor), or the unit type (bDescriptorSubtype in the unit descriptor). |
| 287 | * As the bDescriptorSubtype field is one byte long, the type value will |
| 288 | * always have a null MSB for units. All terminal types defined by the UVC |
| 289 | * specification have a non-null MSB, so it is safe to use the MSB to |
| 290 | * differentiate between units and terminals as long as the descriptor parsing |
| 291 | * code makes sure terminal types have a non-null MSB. |
| 292 | * |
| 293 | * For terminals, the type's most significant bit stores the terminal |
| 294 | * direction (either UVC_TERM_INPUT or UVC_TERM_OUTPUT). The type field should |
| 295 | * always be accessed with the UVC_ENTITY_* macros and never directly. |
| 296 | */ |
| 297 | |
| 298 | struct uvc_entity { |
| 299 | struct list_head list; /* Entity as part of a UVC device. */ |
| 300 | struct list_head chain; /* Entity as part of a video device |
| 301 | * chain. */ |
| 302 | __u8 id; |
| 303 | __u16 type; |
| 304 | char name[64]; |
| 305 | |
Laurent Pinchart | 4ffc2d8 | 2010-01-21 05:39:52 -0300 | [diff] [blame] | 306 | /* Media controller-related fields. */ |
Laurent Pinchart | 8a65a94 | 2010-01-21 08:56:19 -0300 | [diff] [blame] | 307 | struct video_device *vdev; |
Laurent Pinchart | 4ffc2d8 | 2010-01-21 05:39:52 -0300 | [diff] [blame] | 308 | struct v4l2_subdev subdev; |
| 309 | unsigned int num_pads; |
| 310 | unsigned int num_links; |
| 311 | struct media_pad *pads; |
| 312 | |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 313 | union { |
| 314 | struct { |
| 315 | __u16 wObjectiveFocalLengthMin; |
| 316 | __u16 wObjectiveFocalLengthMax; |
| 317 | __u16 wOcularFocalLength; |
| 318 | __u8 bControlSize; |
| 319 | __u8 *bmControls; |
| 320 | } camera; |
| 321 | |
| 322 | struct { |
| 323 | __u8 bControlSize; |
| 324 | __u8 *bmControls; |
| 325 | __u8 bTransportModeSize; |
| 326 | __u8 *bmTransportModes; |
| 327 | } media; |
| 328 | |
| 329 | struct { |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 330 | } output; |
| 331 | |
| 332 | struct { |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 333 | __u16 wMaxMultiplier; |
| 334 | __u8 bControlSize; |
| 335 | __u8 *bmControls; |
| 336 | __u8 bmVideoStandards; |
| 337 | } processing; |
| 338 | |
| 339 | struct { |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 340 | } selector; |
| 341 | |
| 342 | struct { |
| 343 | __u8 guidExtensionCode[16]; |
| 344 | __u8 bNumControls; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 345 | __u8 bControlSize; |
| 346 | __u8 *bmControls; |
| 347 | __u8 *bmControlsType; |
| 348 | } extension; |
| 349 | }; |
| 350 | |
Laurent Pinchart | 8ca5a63 | 2009-11-25 12:00:30 -0300 | [diff] [blame] | 351 | __u8 bNrInPins; |
| 352 | __u8 *baSourceID; |
| 353 | |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 354 | unsigned int ncontrols; |
| 355 | struct uvc_control *controls; |
| 356 | }; |
| 357 | |
| 358 | struct uvc_frame { |
| 359 | __u8 bFrameIndex; |
| 360 | __u8 bmCapabilities; |
| 361 | __u16 wWidth; |
| 362 | __u16 wHeight; |
| 363 | __u32 dwMinBitRate; |
| 364 | __u32 dwMaxBitRate; |
| 365 | __u32 dwMaxVideoFrameBufferSize; |
| 366 | __u8 bFrameIntervalType; |
| 367 | __u32 dwDefaultFrameInterval; |
| 368 | __u32 *dwFrameInterval; |
| 369 | }; |
| 370 | |
| 371 | struct uvc_format { |
| 372 | __u8 type; |
| 373 | __u8 index; |
| 374 | __u8 bpp; |
| 375 | __u8 colorspace; |
| 376 | __u32 fcc; |
| 377 | __u32 flags; |
| 378 | |
| 379 | char name[32]; |
| 380 | |
| 381 | unsigned int nframes; |
| 382 | struct uvc_frame *frame; |
| 383 | }; |
| 384 | |
| 385 | struct uvc_streaming_header { |
| 386 | __u8 bNumFormats; |
| 387 | __u8 bEndpointAddress; |
| 388 | __u8 bTerminalLink; |
| 389 | __u8 bControlSize; |
| 390 | __u8 *bmaControls; |
| 391 | /* The following fields are used by input headers only. */ |
| 392 | __u8 bmInfo; |
| 393 | __u8 bStillCaptureMethod; |
| 394 | __u8 bTriggerSupport; |
| 395 | __u8 bTriggerUsage; |
| 396 | }; |
| 397 | |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 398 | enum uvc_buffer_state { |
Laurent Pinchart | 2c2d264 | 2009-01-03 19:12:40 -0300 | [diff] [blame] | 399 | UVC_BUF_STATE_IDLE = 0, |
| 400 | UVC_BUF_STATE_QUEUED = 1, |
| 401 | UVC_BUF_STATE_ACTIVE = 2, |
Laurent Pinchart | d7c0d43 | 2009-12-16 21:20:45 -0300 | [diff] [blame] | 402 | UVC_BUF_STATE_READY = 3, |
| 403 | UVC_BUF_STATE_DONE = 4, |
| 404 | UVC_BUF_STATE_ERROR = 5, |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 405 | }; |
| 406 | |
| 407 | struct uvc_buffer { |
| 408 | unsigned long vma_use_count; |
| 409 | struct list_head stream; |
| 410 | |
| 411 | /* Touched by interrupt handler. */ |
| 412 | struct v4l2_buffer buf; |
| 413 | struct list_head queue; |
| 414 | wait_queue_head_t wait; |
| 415 | enum uvc_buffer_state state; |
Laurent Pinchart | 9bde9f2 | 2010-06-17 06:52:37 -0300 | [diff] [blame] | 416 | unsigned int error; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 417 | }; |
| 418 | |
| 419 | #define UVC_QUEUE_STREAMING (1 << 0) |
| 420 | #define UVC_QUEUE_DISCONNECTED (1 << 1) |
Laurent Pinchart | 9bde9f2 | 2010-06-17 06:52:37 -0300 | [diff] [blame] | 421 | #define UVC_QUEUE_DROP_CORRUPTED (1 << 2) |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 422 | |
| 423 | struct uvc_video_queue { |
Laurent Pinchart | ff92420 | 2008-12-28 22:32:29 -0300 | [diff] [blame] | 424 | enum v4l2_buf_type type; |
| 425 | |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 426 | void *mem; |
| 427 | unsigned int flags; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 428 | |
| 429 | unsigned int count; |
| 430 | unsigned int buf_size; |
Laurent Pinchart | ff92420 | 2008-12-28 22:32:29 -0300 | [diff] [blame] | 431 | unsigned int buf_used; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 432 | struct uvc_buffer buffer[UVC_MAX_VIDEO_BUFFERS]; |
| 433 | struct mutex mutex; /* protects buffers and mainqueue */ |
| 434 | spinlock_t irqlock; /* protects irqqueue */ |
| 435 | |
| 436 | struct list_head mainqueue; |
| 437 | struct list_head irqqueue; |
| 438 | }; |
| 439 | |
Laurent Pinchart | 8e11359 | 2009-07-01 20:24:47 -0300 | [diff] [blame] | 440 | struct uvc_video_chain { |
| 441 | struct uvc_device *dev; |
| 442 | struct list_head list; |
| 443 | |
Laurent Pinchart | 6241d8c | 2009-11-25 12:00:22 -0300 | [diff] [blame] | 444 | struct list_head entities; /* All entities */ |
Laurent Pinchart | 8e11359 | 2009-07-01 20:24:47 -0300 | [diff] [blame] | 445 | struct uvc_entity *processing; /* Processing unit */ |
| 446 | struct uvc_entity *selector; /* Selector unit */ |
Laurent Pinchart | 8e11359 | 2009-07-01 20:24:47 -0300 | [diff] [blame] | 447 | |
Laurent Pinchart | 27a61c1 | 2010-10-02 09:04:53 -0300 | [diff] [blame] | 448 | struct mutex ctrl_mutex; /* Protects ctrl.info */ |
Laurent Pinchart | 8e11359 | 2009-07-01 20:24:47 -0300 | [diff] [blame] | 449 | }; |
| 450 | |
Laurent Pinchart | 35f02a6 | 2009-06-28 08:37:50 -0300 | [diff] [blame] | 451 | struct uvc_streaming { |
| 452 | struct list_head list; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 453 | struct uvc_device *dev; |
| 454 | struct video_device *vdev; |
Laurent Pinchart | 8e11359 | 2009-07-01 20:24:47 -0300 | [diff] [blame] | 455 | struct uvc_video_chain *chain; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 456 | atomic_t active; |
Laurent Pinchart | 35f02a6 | 2009-06-28 08:37:50 -0300 | [diff] [blame] | 457 | |
| 458 | struct usb_interface *intf; |
| 459 | int intfnum; |
| 460 | __u16 maxpsize; |
| 461 | |
| 462 | struct uvc_streaming_header header; |
| 463 | enum v4l2_buf_type type; |
| 464 | |
| 465 | unsigned int nformats; |
| 466 | struct uvc_format *format; |
| 467 | |
| 468 | struct uvc_streaming_control ctrl; |
| 469 | struct uvc_format *cur_format; |
| 470 | struct uvc_frame *cur_frame; |
Laurent Pinchart | 6947756 | 2010-11-21 13:36:34 -0300 | [diff] [blame] | 471 | /* Protect access to ctrl, cur_format, cur_frame and hardware video |
| 472 | * probe control. |
| 473 | */ |
Laurent Pinchart | 35f02a6 | 2009-06-28 08:37:50 -0300 | [diff] [blame] | 474 | struct mutex mutex; |
| 475 | |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 476 | unsigned int frozen : 1; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 477 | struct uvc_video_queue queue; |
Laurent Pinchart | 35f02a6 | 2009-06-28 08:37:50 -0300 | [diff] [blame] | 478 | void (*decode) (struct urb *urb, struct uvc_streaming *video, |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 479 | struct uvc_buffer *buf); |
| 480 | |
| 481 | /* Context data used by the bulk completion handler. */ |
| 482 | struct { |
| 483 | __u8 header[256]; |
| 484 | unsigned int header_size; |
| 485 | int skip_payload; |
| 486 | __u32 payload_size; |
| 487 | __u32 max_payload_size; |
| 488 | } bulk; |
| 489 | |
| 490 | struct urb *urb[UVC_URBS]; |
| 491 | char *urb_buffer[UVC_URBS]; |
Laurent Pinchart | e01117c | 2008-07-04 00:36:21 -0300 | [diff] [blame] | 492 | dma_addr_t urb_dma[UVC_URBS]; |
| 493 | unsigned int urb_size; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 494 | |
Laurent Pinchart | 650b95f | 2010-10-02 11:06:05 -0300 | [diff] [blame] | 495 | __u32 sequence; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 496 | __u8 last_fid; |
| 497 | }; |
| 498 | |
| 499 | enum uvc_device_state { |
| 500 | UVC_DEV_DISCONNECTED = 1, |
| 501 | }; |
| 502 | |
| 503 | struct uvc_device { |
| 504 | struct usb_device *udev; |
| 505 | struct usb_interface *intf; |
Laurent Pinchart | 44f0079 | 2008-11-08 19:14:50 -0300 | [diff] [blame] | 506 | unsigned long warnings; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 507 | __u32 quirks; |
| 508 | int intfnum; |
| 509 | char name[32]; |
| 510 | |
| 511 | enum uvc_device_state state; |
Laurent Pinchart | 04a37e0 | 2009-05-19 10:08:03 -0300 | [diff] [blame] | 512 | atomic_t users; |
Martin Rubli | 8fb91b3 | 2010-09-08 04:15:23 -0300 | [diff] [blame] | 513 | atomic_t nmappings; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 514 | |
| 515 | /* Video control interface */ |
Laurent Pinchart | 5a254d7 | 2010-01-21 05:39:47 -0300 | [diff] [blame] | 516 | #ifdef CONFIG_MEDIA_CONTROLLER |
| 517 | struct media_device mdev; |
| 518 | #endif |
| 519 | struct v4l2_device vdev; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 520 | __u16 uvc_version; |
| 521 | __u32 clock_frequency; |
| 522 | |
| 523 | struct list_head entities; |
Laurent Pinchart | 8e11359 | 2009-07-01 20:24:47 -0300 | [diff] [blame] | 524 | struct list_head chains; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 525 | |
Laurent Pinchart | 35f02a6 | 2009-06-28 08:37:50 -0300 | [diff] [blame] | 526 | /* Video Streaming interfaces */ |
| 527 | struct list_head streams; |
Laurent Pinchart | 716fdee | 2009-09-29 21:07:19 -0300 | [diff] [blame] | 528 | atomic_t nstreams; |
Laurent Pinchart | 35f02a6 | 2009-06-28 08:37:50 -0300 | [diff] [blame] | 529 | |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 530 | /* Status Interrupt Endpoint */ |
| 531 | struct usb_host_endpoint *int_ep; |
| 532 | struct urb *int_urb; |
Ming Lei | a31a405 | 2008-09-16 03:32:20 -0300 | [diff] [blame] | 533 | __u8 *status; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 534 | struct input_dev *input; |
Laurent Pinchart | f180152 | 2009-01-22 12:45:10 -0300 | [diff] [blame] | 535 | char input_phys[64]; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 536 | }; |
| 537 | |
| 538 | enum uvc_handle_state { |
| 539 | UVC_HANDLE_PASSIVE = 0, |
| 540 | UVC_HANDLE_ACTIVE = 1, |
| 541 | }; |
| 542 | |
| 543 | struct uvc_fh { |
Laurent Pinchart | 8e11359 | 2009-07-01 20:24:47 -0300 | [diff] [blame] | 544 | struct uvc_video_chain *chain; |
Laurent Pinchart | 35f02a6 | 2009-06-28 08:37:50 -0300 | [diff] [blame] | 545 | struct uvc_streaming *stream; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 546 | enum uvc_handle_state state; |
| 547 | }; |
| 548 | |
| 549 | struct uvc_driver { |
| 550 | struct usb_driver driver; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 551 | }; |
| 552 | |
| 553 | /* ------------------------------------------------------------------------ |
| 554 | * Debugging, printing and logging |
| 555 | */ |
| 556 | |
| 557 | #define UVC_TRACE_PROBE (1 << 0) |
| 558 | #define UVC_TRACE_DESCR (1 << 1) |
| 559 | #define UVC_TRACE_CONTROL (1 << 2) |
| 560 | #define UVC_TRACE_FORMAT (1 << 3) |
| 561 | #define UVC_TRACE_CAPTURE (1 << 4) |
| 562 | #define UVC_TRACE_CALLS (1 << 5) |
| 563 | #define UVC_TRACE_IOCTL (1 << 6) |
| 564 | #define UVC_TRACE_FRAME (1 << 7) |
| 565 | #define UVC_TRACE_SUSPEND (1 << 8) |
| 566 | #define UVC_TRACE_STATUS (1 << 9) |
Laurent Pinchart | 663a419 | 2009-08-06 11:41:17 -0300 | [diff] [blame] | 567 | #define UVC_TRACE_VIDEO (1 << 10) |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 568 | |
Laurent Pinchart | 44f0079 | 2008-11-08 19:14:50 -0300 | [diff] [blame] | 569 | #define UVC_WARN_MINMAX 0 |
| 570 | #define UVC_WARN_PROBE_DEF 1 |
| 571 | |
Laurent Pinchart | 310fe52 | 2009-12-09 22:57:48 -0300 | [diff] [blame] | 572 | extern unsigned int uvc_clock_param; |
Laurent Pinchart | 0fbd8ee | 2008-12-06 16:25:14 -0300 | [diff] [blame] | 573 | extern unsigned int uvc_no_drop_param; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 574 | extern unsigned int uvc_trace_param; |
Laurent Pinchart | b232a01 | 2009-10-09 20:55:23 -0300 | [diff] [blame] | 575 | extern unsigned int uvc_timeout_param; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 576 | |
| 577 | #define uvc_trace(flag, msg...) \ |
| 578 | do { \ |
| 579 | if (uvc_trace_param & flag) \ |
| 580 | printk(KERN_DEBUG "uvcvideo: " msg); \ |
| 581 | } while (0) |
| 582 | |
Laurent Pinchart | 44f0079 | 2008-11-08 19:14:50 -0300 | [diff] [blame] | 583 | #define uvc_warn_once(dev, warn, msg...) \ |
| 584 | do { \ |
| 585 | if (!test_and_set_bit(warn, &dev->warnings)) \ |
| 586 | printk(KERN_INFO "uvcvideo: " msg); \ |
| 587 | } while (0) |
| 588 | |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 589 | #define uvc_printk(level, msg...) \ |
| 590 | printk(level "uvcvideo: " msg) |
| 591 | |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 592 | /* -------------------------------------------------------------------------- |
| 593 | * Internal functions. |
| 594 | */ |
| 595 | |
| 596 | /* Core driver */ |
| 597 | extern struct uvc_driver uvc_driver; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 598 | |
Laurent Pinchart | 4ffc2d8 | 2010-01-21 05:39:52 -0300 | [diff] [blame] | 599 | extern struct uvc_entity *uvc_entity_by_id(struct uvc_device *dev, int id); |
| 600 | |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 601 | /* Video buffers queue management. */ |
Laurent Pinchart | ff92420 | 2008-12-28 22:32:29 -0300 | [diff] [blame] | 602 | extern void uvc_queue_init(struct uvc_video_queue *queue, |
Laurent Pinchart | 9bde9f2 | 2010-06-17 06:52:37 -0300 | [diff] [blame] | 603 | enum v4l2_buf_type type, int drop_corrupted); |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 604 | extern int uvc_alloc_buffers(struct uvc_video_queue *queue, |
| 605 | unsigned int nbuffers, unsigned int buflength); |
| 606 | extern int uvc_free_buffers(struct uvc_video_queue *queue); |
| 607 | extern int uvc_query_buffer(struct uvc_video_queue *queue, |
| 608 | struct v4l2_buffer *v4l2_buf); |
| 609 | extern int uvc_queue_buffer(struct uvc_video_queue *queue, |
| 610 | struct v4l2_buffer *v4l2_buf); |
| 611 | extern int uvc_dequeue_buffer(struct uvc_video_queue *queue, |
| 612 | struct v4l2_buffer *v4l2_buf, int nonblocking); |
| 613 | extern int uvc_queue_enable(struct uvc_video_queue *queue, int enable); |
| 614 | extern void uvc_queue_cancel(struct uvc_video_queue *queue, int disconnect); |
| 615 | extern struct uvc_buffer *uvc_queue_next_buffer(struct uvc_video_queue *queue, |
| 616 | struct uvc_buffer *buf); |
Laurent Pinchart | 4aa2759 | 2010-11-21 15:18:08 -0300 | [diff] [blame] | 617 | extern int uvc_queue_mmap(struct uvc_video_queue *queue, |
| 618 | struct vm_area_struct *vma); |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 619 | extern unsigned int uvc_queue_poll(struct uvc_video_queue *queue, |
| 620 | struct file *file, poll_table *wait); |
Bob Liu | 7296944 | 2011-04-29 07:11:35 -0300 | [diff] [blame] | 621 | #ifndef CONFIG_MMU |
| 622 | extern unsigned long uvc_queue_get_unmapped_area(struct uvc_video_queue *queue, |
| 623 | unsigned long pgoff); |
| 624 | #endif |
Laurent Pinchart | 23ff604 | 2009-06-04 09:26:39 -0300 | [diff] [blame] | 625 | extern int uvc_queue_allocated(struct uvc_video_queue *queue); |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 626 | static inline int uvc_queue_streaming(struct uvc_video_queue *queue) |
| 627 | { |
| 628 | return queue->flags & UVC_QUEUE_STREAMING; |
| 629 | } |
| 630 | |
| 631 | /* V4L2 interface */ |
Hans Verkuil | bec4366 | 2008-12-30 06:58:20 -0300 | [diff] [blame] | 632 | extern const struct v4l2_file_operations uvc_fops; |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 633 | |
Laurent Pinchart | 4ffc2d8 | 2010-01-21 05:39:52 -0300 | [diff] [blame] | 634 | /* Media controller */ |
| 635 | extern int uvc_mc_register_entities(struct uvc_video_chain *chain); |
| 636 | extern void uvc_mc_cleanup_entity(struct uvc_entity *entity); |
| 637 | |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 638 | /* Video */ |
Laurent Pinchart | 35f02a6 | 2009-06-28 08:37:50 -0300 | [diff] [blame] | 639 | extern int uvc_video_init(struct uvc_streaming *stream); |
| 640 | extern int uvc_video_suspend(struct uvc_streaming *stream); |
Ming Lei | dd182e5 | 2011-07-16 00:51:00 -0300 | [diff] [blame] | 641 | extern int uvc_video_resume(struct uvc_streaming *stream, int reset); |
Laurent Pinchart | 35f02a6 | 2009-06-28 08:37:50 -0300 | [diff] [blame] | 642 | extern int uvc_video_enable(struct uvc_streaming *stream, int enable); |
| 643 | extern int uvc_probe_video(struct uvc_streaming *stream, |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 644 | struct uvc_streaming_control *probe); |
Laurent Pinchart | 35f02a6 | 2009-06-28 08:37:50 -0300 | [diff] [blame] | 645 | extern int uvc_commit_video(struct uvc_streaming *stream, |
Laurent Pinchart | 44f0079 | 2008-11-08 19:14:50 -0300 | [diff] [blame] | 646 | struct uvc_streaming_control *ctrl); |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 647 | extern int uvc_query_ctrl(struct uvc_device *dev, __u8 query, __u8 unit, |
| 648 | __u8 intfnum, __u8 cs, void *data, __u16 size); |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 649 | |
| 650 | /* Status */ |
| 651 | extern int uvc_status_init(struct uvc_device *dev); |
| 652 | extern void uvc_status_cleanup(struct uvc_device *dev); |
Laurent Pinchart | 04a37e0 | 2009-05-19 10:08:03 -0300 | [diff] [blame] | 653 | extern int uvc_status_start(struct uvc_device *dev); |
| 654 | extern void uvc_status_stop(struct uvc_device *dev); |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 655 | extern int uvc_status_suspend(struct uvc_device *dev); |
| 656 | extern int uvc_status_resume(struct uvc_device *dev); |
| 657 | |
| 658 | /* Controls */ |
Laurent Pinchart | 8e11359 | 2009-07-01 20:24:47 -0300 | [diff] [blame] | 659 | extern int uvc_query_v4l2_ctrl(struct uvc_video_chain *chain, |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 660 | struct v4l2_queryctrl *v4l2_ctrl); |
Laurent Pinchart | 23d9f3e | 2010-11-21 07:58:54 -0300 | [diff] [blame] | 661 | extern int uvc_query_v4l2_menu(struct uvc_video_chain *chain, |
| 662 | struct v4l2_querymenu *query_menu); |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 663 | |
Laurent Pinchart | ba2fa99 | 2010-09-20 05:53:21 -0300 | [diff] [blame] | 664 | extern int uvc_ctrl_add_mapping(struct uvc_video_chain *chain, |
| 665 | const struct uvc_control_mapping *mapping); |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 666 | extern int uvc_ctrl_init_device(struct uvc_device *dev); |
| 667 | extern void uvc_ctrl_cleanup_device(struct uvc_device *dev); |
| 668 | extern int uvc_ctrl_resume_device(struct uvc_device *dev); |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 669 | |
Laurent Pinchart | 8e11359 | 2009-07-01 20:24:47 -0300 | [diff] [blame] | 670 | extern int uvc_ctrl_begin(struct uvc_video_chain *chain); |
| 671 | extern int __uvc_ctrl_commit(struct uvc_video_chain *chain, int rollback); |
| 672 | static inline int uvc_ctrl_commit(struct uvc_video_chain *chain) |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 673 | { |
Laurent Pinchart | 8e11359 | 2009-07-01 20:24:47 -0300 | [diff] [blame] | 674 | return __uvc_ctrl_commit(chain, 0); |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 675 | } |
Laurent Pinchart | 8e11359 | 2009-07-01 20:24:47 -0300 | [diff] [blame] | 676 | static inline int uvc_ctrl_rollback(struct uvc_video_chain *chain) |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 677 | { |
Laurent Pinchart | 8e11359 | 2009-07-01 20:24:47 -0300 | [diff] [blame] | 678 | return __uvc_ctrl_commit(chain, 1); |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 679 | } |
| 680 | |
Laurent Pinchart | 8e11359 | 2009-07-01 20:24:47 -0300 | [diff] [blame] | 681 | extern int uvc_ctrl_get(struct uvc_video_chain *chain, |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 682 | struct v4l2_ext_control *xctrl); |
Laurent Pinchart | 8e11359 | 2009-07-01 20:24:47 -0300 | [diff] [blame] | 683 | extern int uvc_ctrl_set(struct uvc_video_chain *chain, |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 684 | struct v4l2_ext_control *xctrl); |
| 685 | |
Laurent Pinchart | 8e11359 | 2009-07-01 20:24:47 -0300 | [diff] [blame] | 686 | extern int uvc_xu_ctrl_query(struct uvc_video_chain *chain, |
Martin Rubli | fe78d18 | 2010-10-02 19:10:16 -0300 | [diff] [blame] | 687 | struct uvc_xu_control_query *xqry); |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 688 | |
| 689 | /* Utility functions */ |
| 690 | extern void uvc_simplify_fraction(uint32_t *numerator, uint32_t *denominator, |
| 691 | unsigned int n_terms, unsigned int threshold); |
| 692 | extern uint32_t uvc_fraction_to_interval(uint32_t numerator, |
| 693 | uint32_t denominator); |
| 694 | extern struct usb_host_endpoint *uvc_find_endpoint( |
| 695 | struct usb_host_interface *alts, __u8 epaddr); |
| 696 | |
| 697 | /* Quirks support */ |
Laurent Pinchart | 35f02a6 | 2009-06-28 08:37:50 -0300 | [diff] [blame] | 698 | void uvc_video_decode_isight(struct urb *urb, struct uvc_streaming *stream, |
Laurent Pinchart | c0efd23 | 2008-06-30 15:04:50 -0300 | [diff] [blame] | 699 | struct uvc_buffer *buf); |
| 700 | |
| 701 | #endif /* __KERNEL__ */ |
| 702 | |
| 703 | #endif |