uvcvideo.h 17 KB

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