uvcvideo.h 17 KB

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