blob: 8e76ce982f1eadb525b2045e8c7549c6255a723d [file] [log] [blame]
Laurent Pinchartcdda4792010-05-02 20:57:41 +02001#ifndef _UVC_QUEUE_H_
2#define _UVC_QUEUE_H_
3
4#ifdef __KERNEL__
5
6#include <linux/kernel.h>
7#include <linux/poll.h>
8#include <linux/videodev2.h>
Bhupesh Sharmad6925222013-03-28 15:11:52 +05309#include <media/videobuf2-core.h>
Laurent Pinchartcdda4792010-05-02 20:57:41 +020010
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
15
16/* ------------------------------------------------------------------------
17 * Structures.
18 */
19
20enum 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,
26};
27
28struct uvc_buffer {
Bhupesh Sharmad6925222013-03-28 15:11:52 +053029 struct vb2_buffer buf;
Laurent Pinchartcdda4792010-05-02 20:57:41 +020030 struct list_head queue;
Bhupesh Sharmad6925222013-03-28 15:11:52 +053031
Laurent Pinchartcdda4792010-05-02 20:57:41 +020032 enum uvc_buffer_state state;
Bhupesh Sharmad6925222013-03-28 15:11:52 +053033 void *mem;
34 unsigned int length;
35 unsigned int bytesused;
Laurent Pinchartcdda4792010-05-02 20:57:41 +020036};
37
Bhupesh Sharmad6925222013-03-28 15:11:52 +053038#define UVC_QUEUE_DISCONNECTED (1 << 0)
39#define UVC_QUEUE_DROP_INCOMPLETE (1 << 1)
40#define UVC_QUEUE_PAUSED (1 << 2)
Laurent Pinchartcdda4792010-05-02 20:57:41 +020041
42struct uvc_video_queue {
Bhupesh Sharmad6925222013-03-28 15:11:52 +053043 struct vb2_queue queue;
44 struct mutex mutex; /* Protects queue */
Laurent Pinchartcdda4792010-05-02 20:57:41 +020045
Laurent Pinchartcdda4792010-05-02 20:57:41 +020046 unsigned int flags;
47 __u32 sequence;
48
Laurent Pinchartcdda4792010-05-02 20:57:41 +020049 unsigned int buf_used;
Laurent Pinchartcdda4792010-05-02 20:57:41 +020050
Bhupesh Sharmad6925222013-03-28 15:11:52 +053051 spinlock_t irqlock; /* Protects flags and irqqueue */
Laurent Pinchartcdda4792010-05-02 20:57:41 +020052 struct list_head irqqueue;
53};
54
Laurent Pinchartcdda4792010-05-02 20:57:41 +020055static inline int uvc_queue_streaming(struct uvc_video_queue *queue)
56{
Bhupesh Sharmad6925222013-03-28 15:11:52 +053057 return vb2_is_streaming(&queue->queue);
Laurent Pinchartcdda4792010-05-02 20:57:41 +020058}
Laurent Pinchartcdda4792010-05-02 20:57:41 +020059
60#endif /* __KERNEL__ */
61
62#endif /* _UVC_QUEUE_H_ */
63