uvc_queue.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. #include <media/videobuf2-core.h>
  8. /* Maximum frame size in bytes, for sanity checking. */
  9. #define UVC_MAX_FRAME_SIZE (16*1024*1024)
  10. /* Maximum number of video buffers. */
  11. #define UVC_MAX_VIDEO_BUFFERS 32
  12. /* ------------------------------------------------------------------------
  13. * Structures.
  14. */
  15. enum uvc_buffer_state {
  16. UVC_BUF_STATE_IDLE = 0,
  17. UVC_BUF_STATE_QUEUED = 1,
  18. UVC_BUF_STATE_ACTIVE = 2,
  19. UVC_BUF_STATE_DONE = 3,
  20. UVC_BUF_STATE_ERROR = 4,
  21. };
  22. struct uvc_buffer {
  23. struct vb2_buffer buf;
  24. struct list_head queue;
  25. enum uvc_buffer_state state;
  26. void *mem;
  27. unsigned int length;
  28. unsigned int bytesused;
  29. };
  30. #define UVC_QUEUE_DISCONNECTED (1 << 0)
  31. #define UVC_QUEUE_DROP_INCOMPLETE (1 << 1)
  32. #define UVC_QUEUE_PAUSED (1 << 2)
  33. struct uvc_video_queue {
  34. struct vb2_queue queue;
  35. struct mutex mutex; /* Protects queue */
  36. unsigned int flags;
  37. __u32 sequence;
  38. unsigned int buf_used;
  39. spinlock_t irqlock; /* Protects flags and irqqueue */
  40. struct list_head irqqueue;
  41. };
  42. static inline int uvc_queue_streaming(struct uvc_video_queue *queue)
  43. {
  44. return vb2_is_streaming(&queue->queue);
  45. }
  46. #endif /* __KERNEL__ */
  47. #endif /* _UVC_QUEUE_H_ */