uvcvideo.h 17 KB

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