uvcvideo.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  1. #ifndef _USB_VIDEO_H_
  2. #define _USB_VIDEO_H_
  3. #ifndef __KERNEL__
  4. #error "The uvcvideo.h header is deprecated, use linux/uvcvideo.h instead."
  5. #endif /* __KERNEL__ */
  6. #include <linux/kernel.h>
  7. #include <linux/poll.h>
  8. #include <linux/usb.h>
  9. #include <linux/usb/video.h>
  10. #include <linux/uvcvideo.h>
  11. #include <linux/videodev2.h>
  12. #include <media/media-device.h>
  13. #include <media/v4l2-device.h>
  14. /* --------------------------------------------------------------------------
  15. * UVC constants
  16. */
  17. #define UVC_TERM_INPUT 0x0000
  18. #define UVC_TERM_OUTPUT 0x8000
  19. #define UVC_TERM_DIRECTION(term) ((term)->type & 0x8000)
  20. #define UVC_ENTITY_TYPE(entity) ((entity)->type & 0x7fff)
  21. #define UVC_ENTITY_IS_UNIT(entity) (((entity)->type & 0xff00) == 0)
  22. #define UVC_ENTITY_IS_TERM(entity) (((entity)->type & 0xff00) != 0)
  23. #define UVC_ENTITY_IS_ITERM(entity) \
  24. (UVC_ENTITY_IS_TERM(entity) && \
  25. ((entity)->type & 0x8000) == UVC_TERM_INPUT)
  26. #define UVC_ENTITY_IS_OTERM(entity) \
  27. (UVC_ENTITY_IS_TERM(entity) && \
  28. ((entity)->type & 0x8000) == UVC_TERM_OUTPUT)
  29. /* ------------------------------------------------------------------------
  30. * GUIDs
  31. */
  32. #define UVC_GUID_UVC_CAMERA \
  33. {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
  34. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}
  35. #define UVC_GUID_UVC_OUTPUT \
  36. {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
  37. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02}
  38. #define UVC_GUID_UVC_MEDIA_TRANSPORT_INPUT \
  39. {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
  40. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03}
  41. #define UVC_GUID_UVC_PROCESSING \
  42. {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
  43. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01}
  44. #define UVC_GUID_UVC_SELECTOR \
  45. {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
  46. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02}
  47. #define UVC_GUID_FORMAT_MJPEG \
  48. { 'M', 'J', 'P', 'G', 0x00, 0x00, 0x10, 0x00, \
  49. 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
  50. #define UVC_GUID_FORMAT_YUY2 \
  51. { 'Y', 'U', 'Y', '2', 0x00, 0x00, 0x10, 0x00, \
  52. 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
  53. #define UVC_GUID_FORMAT_YUY2_ISIGHT \
  54. { 'Y', 'U', 'Y', '2', 0x00, 0x00, 0x10, 0x00, \
  55. 0x80, 0x00, 0x00, 0x00, 0x00, 0x38, 0x9b, 0x71}
  56. #define UVC_GUID_FORMAT_NV12 \
  57. { 'N', 'V', '1', '2', 0x00, 0x00, 0x10, 0x00, \
  58. 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
  59. #define UVC_GUID_FORMAT_YV12 \
  60. { 'Y', 'V', '1', '2', 0x00, 0x00, 0x10, 0x00, \
  61. 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
  62. #define UVC_GUID_FORMAT_I420 \
  63. { 'I', '4', '2', '0', 0x00, 0x00, 0x10, 0x00, \
  64. 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
  65. #define UVC_GUID_FORMAT_UYVY \
  66. { 'U', 'Y', 'V', 'Y', 0x00, 0x00, 0x10, 0x00, \
  67. 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
  68. #define UVC_GUID_FORMAT_Y800 \
  69. { 'Y', '8', '0', '0', 0x00, 0x00, 0x10, 0x00, \
  70. 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
  71. #define UVC_GUID_FORMAT_Y16 \
  72. { 'Y', '1', '6', ' ', 0x00, 0x00, 0x10, 0x00, \
  73. 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
  74. #define UVC_GUID_FORMAT_BY8 \
  75. { 'B', 'Y', '8', ' ', 0x00, 0x00, 0x10, 0x00, \
  76. 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
  77. #define UVC_GUID_FORMAT_RGBP \
  78. { 'R', 'G', 'B', 'P', 0x00, 0x00, 0x10, 0x00, \
  79. 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
  80. #define UVC_GUID_FORMAT_M420 \
  81. { 'M', '4', '2', '0', 0x00, 0x00, 0x10, 0x00, \
  82. 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
  83. /* ------------------------------------------------------------------------
  84. * Driver specific constants.
  85. */
  86. #define DRIVER_VERSION "1.1.1"
  87. /* Number of isochronous URBs. */
  88. #define UVC_URBS 5
  89. /* Maximum number of packets per URB. */
  90. #define UVC_MAX_PACKETS 32
  91. /* Maximum number of video buffers. */
  92. #define UVC_MAX_VIDEO_BUFFERS 32
  93. /* Maximum status buffer size in bytes of interrupt URB. */
  94. #define UVC_MAX_STATUS_SIZE 16
  95. #define UVC_CTRL_CONTROL_TIMEOUT 300
  96. #define UVC_CTRL_STREAMING_TIMEOUT 5000
  97. /* Maximum allowed number of control mappings per device */
  98. #define UVC_MAX_CONTROL_MAPPINGS 1024
  99. /* Devices quirks */
  100. #define UVC_QUIRK_STATUS_INTERVAL 0x00000001
  101. #define UVC_QUIRK_PROBE_MINMAX 0x00000002
  102. #define UVC_QUIRK_PROBE_EXTRAFIELDS 0x00000004
  103. #define UVC_QUIRK_BUILTIN_ISIGHT 0x00000008
  104. #define UVC_QUIRK_STREAM_NO_FID 0x00000010
  105. #define UVC_QUIRK_IGNORE_SELECTOR_UNIT 0x00000020
  106. #define UVC_QUIRK_FIX_BANDWIDTH 0x00000080
  107. #define UVC_QUIRK_PROBE_DEF 0x00000100
  108. #define UVC_QUIRK_RESTRICT_FRAME_RATE 0x00000200
  109. /* Format flags */
  110. #define UVC_FMT_FLAG_COMPRESSED 0x00000001
  111. #define UVC_FMT_FLAG_STREAM 0x00000002
  112. /* ------------------------------------------------------------------------
  113. * Structures.
  114. */
  115. struct uvc_device;
  116. /* TODO: Put the most frequently accessed fields at the beginning of
  117. * structures to maximize cache efficiency.
  118. */
  119. struct uvc_control_info {
  120. struct list_head mappings;
  121. __u8 entity[16];
  122. __u8 index; /* Bit index in bmControls */
  123. __u8 selector;
  124. __u16 size;
  125. __u32 flags;
  126. };
  127. struct uvc_control_mapping {
  128. struct list_head list;
  129. struct uvc_control_info *ctrl;
  130. __u32 id;
  131. __u8 name[32];
  132. __u8 entity[16];
  133. __u8 selector;
  134. __u8 size;
  135. __u8 offset;
  136. enum v4l2_ctrl_type v4l2_type;
  137. __u32 data_type;
  138. struct uvc_menu_info *menu_info;
  139. __u32 menu_count;
  140. __s32 (*get) (struct uvc_control_mapping *mapping, __u8 query,
  141. const __u8 *data);
  142. void (*set) (struct uvc_control_mapping *mapping, __s32 value,
  143. __u8 *data);
  144. };
  145. struct uvc_control {
  146. struct uvc_entity *entity;
  147. struct uvc_control_info info;
  148. __u8 index; /* Used to match the uvc_control entry with a
  149. uvc_control_info. */
  150. __u8 dirty:1,
  151. loaded:1,
  152. modified:1,
  153. cached:1,
  154. initialized:1;
  155. __u8 *uvc_data;
  156. };
  157. struct uvc_format_desc {
  158. char *name;
  159. __u8 guid[16];
  160. __u32 fcc;
  161. };
  162. /* The term 'entity' refers to both UVC units and UVC terminals.
  163. *
  164. * The type field is either the terminal type (wTerminalType in the terminal
  165. * descriptor), or the unit type (bDescriptorSubtype in the unit descriptor).
  166. * As the bDescriptorSubtype field is one byte long, the type value will
  167. * always have a null MSB for units. All terminal types defined by the UVC
  168. * specification have a non-null MSB, so it is safe to use the MSB to
  169. * differentiate between units and terminals as long as the descriptor parsing
  170. * code makes sure terminal types have a non-null MSB.
  171. *
  172. * For terminals, the type's most significant bit stores the terminal
  173. * direction (either UVC_TERM_INPUT or UVC_TERM_OUTPUT). The type field should
  174. * always be accessed with the UVC_ENTITY_* macros and never directly.
  175. */
  176. struct uvc_entity {
  177. struct list_head list; /* Entity as part of a UVC device. */
  178. struct list_head chain; /* Entity as part of a video device
  179. * chain. */
  180. __u8 id;
  181. __u16 type;
  182. char name[64];
  183. /* Media controller-related fields. */
  184. struct video_device *vdev;
  185. struct v4l2_subdev subdev;
  186. unsigned int num_pads;
  187. unsigned int num_links;
  188. struct media_pad *pads;
  189. union {
  190. struct {
  191. __u16 wObjectiveFocalLengthMin;
  192. __u16 wObjectiveFocalLengthMax;
  193. __u16 wOcularFocalLength;
  194. __u8 bControlSize;
  195. __u8 *bmControls;
  196. } camera;
  197. struct {
  198. __u8 bControlSize;
  199. __u8 *bmControls;
  200. __u8 bTransportModeSize;
  201. __u8 *bmTransportModes;
  202. } media;
  203. struct {
  204. } output;
  205. struct {
  206. __u16 wMaxMultiplier;
  207. __u8 bControlSize;
  208. __u8 *bmControls;
  209. __u8 bmVideoStandards;
  210. } processing;
  211. struct {
  212. } selector;
  213. struct {
  214. __u8 guidExtensionCode[16];
  215. __u8 bNumControls;
  216. __u8 bControlSize;
  217. __u8 *bmControls;
  218. __u8 *bmControlsType;
  219. } extension;
  220. };
  221. __u8 bNrInPins;
  222. __u8 *baSourceID;
  223. unsigned int ncontrols;
  224. struct uvc_control *controls;
  225. };
  226. struct uvc_frame {
  227. __u8 bFrameIndex;
  228. __u8 bmCapabilities;
  229. __u16 wWidth;
  230. __u16 wHeight;
  231. __u32 dwMinBitRate;
  232. __u32 dwMaxBitRate;
  233. __u32 dwMaxVideoFrameBufferSize;
  234. __u8 bFrameIntervalType;
  235. __u32 dwDefaultFrameInterval;
  236. __u32 *dwFrameInterval;
  237. };
  238. struct uvc_format {
  239. __u8 type;
  240. __u8 index;
  241. __u8 bpp;
  242. __u8 colorspace;
  243. __u32 fcc;
  244. __u32 flags;
  245. char name[32];
  246. unsigned int nframes;
  247. struct uvc_frame *frame;
  248. };
  249. struct uvc_streaming_header {
  250. __u8 bNumFormats;
  251. __u8 bEndpointAddress;
  252. __u8 bTerminalLink;
  253. __u8 bControlSize;
  254. __u8 *bmaControls;
  255. /* The following fields are used by input headers only. */
  256. __u8 bmInfo;
  257. __u8 bStillCaptureMethod;
  258. __u8 bTriggerSupport;
  259. __u8 bTriggerUsage;
  260. };
  261. enum uvc_buffer_state {
  262. UVC_BUF_STATE_IDLE = 0,
  263. UVC_BUF_STATE_QUEUED = 1,
  264. UVC_BUF_STATE_ACTIVE = 2,
  265. UVC_BUF_STATE_READY = 3,
  266. UVC_BUF_STATE_DONE = 4,
  267. UVC_BUF_STATE_ERROR = 5,
  268. };
  269. struct uvc_buffer {
  270. unsigned long vma_use_count;
  271. struct list_head stream;
  272. /* Touched by interrupt handler. */
  273. struct v4l2_buffer buf;
  274. struct list_head queue;
  275. wait_queue_head_t wait;
  276. enum uvc_buffer_state state;
  277. unsigned int error;
  278. };
  279. #define UVC_QUEUE_STREAMING (1 << 0)
  280. #define UVC_QUEUE_DISCONNECTED (1 << 1)
  281. #define UVC_QUEUE_DROP_CORRUPTED (1 << 2)
  282. struct uvc_video_queue {
  283. enum v4l2_buf_type type;
  284. void *mem;
  285. unsigned int flags;
  286. unsigned int count;
  287. unsigned int buf_size;
  288. unsigned int buf_used;
  289. struct uvc_buffer buffer[UVC_MAX_VIDEO_BUFFERS];
  290. struct mutex mutex; /* protects buffers and mainqueue */
  291. spinlock_t irqlock; /* protects irqqueue */
  292. struct list_head mainqueue;
  293. struct list_head irqqueue;
  294. };
  295. struct uvc_video_chain {
  296. struct uvc_device *dev;
  297. struct list_head list;
  298. struct list_head entities; /* All entities */
  299. struct uvc_entity *processing; /* Processing unit */
  300. struct uvc_entity *selector; /* Selector unit */
  301. struct mutex ctrl_mutex; /* Protects ctrl.info */
  302. };
  303. struct uvc_streaming {
  304. struct list_head list;
  305. struct uvc_device *dev;
  306. struct video_device *vdev;
  307. struct uvc_video_chain *chain;
  308. atomic_t active;
  309. struct usb_interface *intf;
  310. int intfnum;
  311. __u16 maxpsize;
  312. struct uvc_streaming_header header;
  313. enum v4l2_buf_type type;
  314. unsigned int nformats;
  315. struct uvc_format *format;
  316. struct uvc_streaming_control ctrl;
  317. struct uvc_format *cur_format;
  318. struct uvc_frame *cur_frame;
  319. /* Protect access to ctrl, cur_format, cur_frame and hardware video
  320. * probe control.
  321. */
  322. struct mutex mutex;
  323. unsigned int frozen : 1;
  324. struct uvc_video_queue queue;
  325. void (*decode) (struct urb *urb, struct uvc_streaming *video,
  326. struct uvc_buffer *buf);
  327. /* Context data used by the bulk completion handler. */
  328. struct {
  329. __u8 header[256];
  330. unsigned int header_size;
  331. int skip_payload;
  332. __u32 payload_size;
  333. __u32 max_payload_size;
  334. } bulk;
  335. struct urb *urb[UVC_URBS];
  336. char *urb_buffer[UVC_URBS];
  337. dma_addr_t urb_dma[UVC_URBS];
  338. unsigned int urb_size;
  339. __u32 sequence;
  340. __u8 last_fid;
  341. };
  342. enum uvc_device_state {
  343. UVC_DEV_DISCONNECTED = 1,
  344. };
  345. struct uvc_device {
  346. struct usb_device *udev;
  347. struct usb_interface *intf;
  348. unsigned long warnings;
  349. __u32 quirks;
  350. int intfnum;
  351. char name[32];
  352. enum uvc_device_state state;
  353. atomic_t users;
  354. atomic_t nmappings;
  355. /* Video control interface */
  356. #ifdef CONFIG_MEDIA_CONTROLLER
  357. struct media_device mdev;
  358. #endif
  359. struct v4l2_device vdev;
  360. __u16 uvc_version;
  361. __u32 clock_frequency;
  362. struct list_head entities;
  363. struct list_head chains;
  364. /* Video Streaming interfaces */
  365. struct list_head streams;
  366. atomic_t nstreams;
  367. /* Status Interrupt Endpoint */
  368. struct usb_host_endpoint *int_ep;
  369. struct urb *int_urb;
  370. __u8 *status;
  371. struct input_dev *input;
  372. char input_phys[64];
  373. };
  374. enum uvc_handle_state {
  375. UVC_HANDLE_PASSIVE = 0,
  376. UVC_HANDLE_ACTIVE = 1,
  377. };
  378. struct uvc_fh {
  379. struct uvc_video_chain *chain;
  380. struct uvc_streaming *stream;
  381. enum uvc_handle_state state;
  382. };
  383. struct uvc_driver {
  384. struct usb_driver driver;
  385. };
  386. /* ------------------------------------------------------------------------
  387. * Debugging, printing and logging
  388. */
  389. #define UVC_TRACE_PROBE (1 << 0)
  390. #define UVC_TRACE_DESCR (1 << 1)
  391. #define UVC_TRACE_CONTROL (1 << 2)
  392. #define UVC_TRACE_FORMAT (1 << 3)
  393. #define UVC_TRACE_CAPTURE (1 << 4)
  394. #define UVC_TRACE_CALLS (1 << 5)
  395. #define UVC_TRACE_IOCTL (1 << 6)
  396. #define UVC_TRACE_FRAME (1 << 7)
  397. #define UVC_TRACE_SUSPEND (1 << 8)
  398. #define UVC_TRACE_STATUS (1 << 9)
  399. #define UVC_TRACE_VIDEO (1 << 10)
  400. #define UVC_WARN_MINMAX 0
  401. #define UVC_WARN_PROBE_DEF 1
  402. extern unsigned int uvc_clock_param;
  403. extern unsigned int uvc_no_drop_param;
  404. extern unsigned int uvc_trace_param;
  405. extern unsigned int uvc_timeout_param;
  406. #define uvc_trace(flag, msg...) \
  407. do { \
  408. if (uvc_trace_param & flag) \
  409. printk(KERN_DEBUG "uvcvideo: " msg); \
  410. } while (0)
  411. #define uvc_warn_once(dev, warn, msg...) \
  412. do { \
  413. if (!test_and_set_bit(warn, &dev->warnings)) \
  414. printk(KERN_INFO "uvcvideo: " msg); \
  415. } while (0)
  416. #define uvc_printk(level, msg...) \
  417. printk(level "uvcvideo: " msg)
  418. /* --------------------------------------------------------------------------
  419. * Internal functions.
  420. */
  421. /* Core driver */
  422. extern struct uvc_driver uvc_driver;
  423. extern struct uvc_entity *uvc_entity_by_id(struct uvc_device *dev, int id);
  424. /* Video buffers queue management. */
  425. extern void uvc_queue_init(struct uvc_video_queue *queue,
  426. enum v4l2_buf_type type, int drop_corrupted);
  427. extern int uvc_alloc_buffers(struct uvc_video_queue *queue,
  428. unsigned int nbuffers, unsigned int buflength);
  429. extern int uvc_free_buffers(struct uvc_video_queue *queue);
  430. extern int uvc_query_buffer(struct uvc_video_queue *queue,
  431. struct v4l2_buffer *v4l2_buf);
  432. extern int uvc_queue_buffer(struct uvc_video_queue *queue,
  433. struct v4l2_buffer *v4l2_buf);
  434. extern int uvc_dequeue_buffer(struct uvc_video_queue *queue,
  435. struct v4l2_buffer *v4l2_buf, int nonblocking);
  436. extern int uvc_queue_enable(struct uvc_video_queue *queue, int enable);
  437. extern void uvc_queue_cancel(struct uvc_video_queue *queue, int disconnect);
  438. extern struct uvc_buffer *uvc_queue_next_buffer(struct uvc_video_queue *queue,
  439. struct uvc_buffer *buf);
  440. extern int uvc_queue_mmap(struct uvc_video_queue *queue,
  441. struct vm_area_struct *vma);
  442. extern unsigned int uvc_queue_poll(struct uvc_video_queue *queue,
  443. struct file *file, poll_table *wait);
  444. #ifndef CONFIG_MMU
  445. extern unsigned long uvc_queue_get_unmapped_area(struct uvc_video_queue *queue,
  446. unsigned long pgoff);
  447. #endif
  448. extern int uvc_queue_allocated(struct uvc_video_queue *queue);
  449. static inline int uvc_queue_streaming(struct uvc_video_queue *queue)
  450. {
  451. return queue->flags & UVC_QUEUE_STREAMING;
  452. }
  453. /* V4L2 interface */
  454. extern const struct v4l2_file_operations uvc_fops;
  455. /* Media controller */
  456. extern int uvc_mc_register_entities(struct uvc_video_chain *chain);
  457. extern void uvc_mc_cleanup_entity(struct uvc_entity *entity);
  458. /* Video */
  459. extern int uvc_video_init(struct uvc_streaming *stream);
  460. extern int uvc_video_suspend(struct uvc_streaming *stream);
  461. extern int uvc_video_resume(struct uvc_streaming *stream, int reset);
  462. extern int uvc_video_enable(struct uvc_streaming *stream, int enable);
  463. extern int uvc_probe_video(struct uvc_streaming *stream,
  464. struct uvc_streaming_control *probe);
  465. extern int uvc_commit_video(struct uvc_streaming *stream,
  466. struct uvc_streaming_control *ctrl);
  467. extern int uvc_query_ctrl(struct uvc_device *dev, __u8 query, __u8 unit,
  468. __u8 intfnum, __u8 cs, void *data, __u16 size);
  469. /* Status */
  470. extern int uvc_status_init(struct uvc_device *dev);
  471. extern void uvc_status_cleanup(struct uvc_device *dev);
  472. extern int uvc_status_start(struct uvc_device *dev);
  473. extern void uvc_status_stop(struct uvc_device *dev);
  474. extern int uvc_status_suspend(struct uvc_device *dev);
  475. extern int uvc_status_resume(struct uvc_device *dev);
  476. /* Controls */
  477. extern int uvc_query_v4l2_ctrl(struct uvc_video_chain *chain,
  478. struct v4l2_queryctrl *v4l2_ctrl);
  479. extern int uvc_query_v4l2_menu(struct uvc_video_chain *chain,
  480. struct v4l2_querymenu *query_menu);
  481. extern int uvc_ctrl_add_mapping(struct uvc_video_chain *chain,
  482. const struct uvc_control_mapping *mapping);
  483. extern int uvc_ctrl_init_device(struct uvc_device *dev);
  484. extern void uvc_ctrl_cleanup_device(struct uvc_device *dev);
  485. extern int uvc_ctrl_resume_device(struct uvc_device *dev);
  486. extern int uvc_ctrl_begin(struct uvc_video_chain *chain);
  487. extern int __uvc_ctrl_commit(struct uvc_video_chain *chain, int rollback);
  488. static inline int uvc_ctrl_commit(struct uvc_video_chain *chain)
  489. {
  490. return __uvc_ctrl_commit(chain, 0);
  491. }
  492. static inline int uvc_ctrl_rollback(struct uvc_video_chain *chain)
  493. {
  494. return __uvc_ctrl_commit(chain, 1);
  495. }
  496. extern int uvc_ctrl_get(struct uvc_video_chain *chain,
  497. struct v4l2_ext_control *xctrl);
  498. extern int uvc_ctrl_set(struct uvc_video_chain *chain,
  499. struct v4l2_ext_control *xctrl);
  500. extern int uvc_xu_ctrl_query(struct uvc_video_chain *chain,
  501. struct uvc_xu_control_query *xqry);
  502. /* Utility functions */
  503. extern void uvc_simplify_fraction(uint32_t *numerator, uint32_t *denominator,
  504. unsigned int n_terms, unsigned int threshold);
  505. extern uint32_t uvc_fraction_to_interval(uint32_t numerator,
  506. uint32_t denominator);
  507. extern struct usb_host_endpoint *uvc_find_endpoint(
  508. struct usb_host_interface *alts, __u8 epaddr);
  509. /* Quirks support */
  510. void uvc_video_decode_isight(struct urb *urb, struct uvc_streaming *stream,
  511. struct uvc_buffer *buf);
  512. #endif