uvc_queue.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #ifndef _UVC_QUEUE_H_
  2. #define _UVC_QUEUE_H_
  3. #ifdef __KERNEL__
  4. #include <linux/kernel.h>
  5. #include <linux/poll.h>
  6. #include <linux/videodev2.h>
  7. /* Maximum frame size in bytes, for sanity checking. */
  8. #define UVC_MAX_FRAME_SIZE (16*1024*1024)
  9. /* Maximum number of video buffers. */
  10. #define UVC_MAX_VIDEO_BUFFERS 32
  11. /* ------------------------------------------------------------------------
  12. * Structures.
  13. */
  14. enum uvc_buffer_state {
  15. UVC_BUF_STATE_IDLE = 0,
  16. UVC_BUF_STATE_QUEUED = 1,
  17. UVC_BUF_STATE_ACTIVE = 2,
  18. UVC_BUF_STATE_DONE = 3,
  19. UVC_BUF_STATE_ERROR = 4,
  20. };
  21. struct uvc_buffer {
  22. unsigned long vma_use_count;
  23. struct list_head stream;
  24. /* Touched by interrupt handler. */
  25. struct v4l2_buffer buf;
  26. struct list_head queue;
  27. wait_queue_head_t wait;
  28. enum uvc_buffer_state state;
  29. };
  30. #define UVC_QUEUE_STREAMING (1 << 0)
  31. #define UVC_QUEUE_DISCONNECTED (1 << 1)
  32. #define UVC_QUEUE_DROP_INCOMPLETE (1 << 2)
  33. #define UVC_QUEUE_PAUSED (1 << 3)
  34. struct uvc_video_queue {
  35. enum v4l2_buf_type type;
  36. void *mem;
  37. unsigned int flags;
  38. __u32 sequence;
  39. unsigned int count;
  40. unsigned int buf_size;
  41. unsigned int buf_used;
  42. struct uvc_buffer buffer[UVC_MAX_VIDEO_BUFFERS];
  43. struct mutex mutex; /* protects buffers and mainqueue */
  44. spinlock_t irqlock; /* protects irqqueue */
  45. struct list_head mainqueue;
  46. struct list_head irqqueue;
  47. };
  48. static inline int uvc_queue_streaming(struct uvc_video_queue *queue)
  49. {
  50. return queue->flags & UVC_QUEUE_STREAMING;
  51. }
  52. #endif /* __KERNEL__ */
  53. #endif /* _UVC_QUEUE_H_ */