uvcvideo.h 17 KB

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