uvcvideo.h 17 KB

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