6 #include <linux/kernel.h>
7 #include <linux/poll.h>
8 #include <linux/videodev2.h>
9 #include <media/videobuf2-core.h>
11 /* Maximum frame size in bytes, for sanity checking. */
12 #define UVC_MAX_FRAME_SIZE (16*1024*1024)
13 /* Maximum number of video buffers. */
14 #define UVC_MAX_VIDEO_BUFFERS 32
16 /* ------------------------------------------------------------------------
20 enum uvc_buffer_state
{
21 UVC_BUF_STATE_IDLE
= 0,
22 UVC_BUF_STATE_QUEUED
= 1,
23 UVC_BUF_STATE_ACTIVE
= 2,
24 UVC_BUF_STATE_DONE
= 3,
25 UVC_BUF_STATE_ERROR
= 4,
29 struct vb2_buffer buf
;
30 struct list_head queue
;
32 enum uvc_buffer_state state
;
35 unsigned int bytesused
;
38 #define UVC_QUEUE_DISCONNECTED (1 << 0)
39 #define UVC_QUEUE_DROP_INCOMPLETE (1 << 1)
40 #define UVC_QUEUE_PAUSED (1 << 2)
42 struct uvc_video_queue
{
43 struct vb2_queue queue
;
48 unsigned int buf_used
;
50 spinlock_t irqlock
; /* Protects flags and irqqueue */
51 struct list_head irqqueue
;
54 static inline int uvc_queue_streaming(struct uvc_video_queue
*queue
)
56 return vb2_is_streaming(&queue
->queue
);
59 int uvcg_queue_init(struct uvc_video_queue
*queue
, enum v4l2_buf_type type
,
62 void uvcg_free_buffers(struct uvc_video_queue
*queue
);
64 int uvcg_alloc_buffers(struct uvc_video_queue
*queue
,
65 struct v4l2_requestbuffers
*rb
);
67 int uvcg_query_buffer(struct uvc_video_queue
*queue
, struct v4l2_buffer
*buf
);
69 int uvcg_queue_buffer(struct uvc_video_queue
*queue
, struct v4l2_buffer
*buf
);
71 int uvcg_dequeue_buffer(struct uvc_video_queue
*queue
,
72 struct v4l2_buffer
*buf
, int nonblocking
);
74 unsigned int uvcg_queue_poll(struct uvc_video_queue
*queue
,
75 struct file
*file
, poll_table
*wait
);
77 int uvcg_queue_mmap(struct uvc_video_queue
*queue
, struct vm_area_struct
*vma
);
80 unsigned long uvcg_queue_get_unmapped_area(struct uvc_video_queue
*queue
,
82 #endif /* CONFIG_MMU */
84 void uvcg_queue_cancel(struct uvc_video_queue
*queue
, int disconnect
);
86 int uvcg_queue_enable(struct uvc_video_queue
*queue
, int enable
);
88 struct uvc_buffer
*uvcg_queue_next_buffer(struct uvc_video_queue
*queue
,
89 struct uvc_buffer
*buf
);
91 struct uvc_buffer
*uvcg_queue_head(struct uvc_video_queue
*queue
);
93 #endif /* __KERNEL__ */
95 #endif /* _UVC_QUEUE_H_ */