diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2010-05-02 14:57:41 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-05-20 16:21:41 -0400 |
commit | cdda479f15cd13fa50a913ca85129c0437cc7b91 (patch) | |
tree | 5189c428d5f23f738dbf3e8e555c6f48da540b3a /drivers/usb/gadget/uvc_queue.h | |
parent | 910f8d0cede74beff1eee93cf9cf2a28d7600e66 (diff) |
USB gadget: video class function driver
This USB video class function driver implements a video capture device from the
host's point of view. It creates a V4L2 output device on the gadget's side to
transfer data from a userspace application over USB.
The UVC-specific descriptors are passed by the gadget driver to the UVC
function driver, making them completely configurable without any modification
to the function's driver code.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/gadget/uvc_queue.h')
-rw-r--r-- | drivers/usb/gadget/uvc_queue.h | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/drivers/usb/gadget/uvc_queue.h b/drivers/usb/gadget/uvc_queue.h new file mode 100644 index 000000000000..7f5a33fe7ae2 --- /dev/null +++ b/drivers/usb/gadget/uvc_queue.h | |||
@@ -0,0 +1,89 @@ | |||
1 | #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> | ||
9 | |||
10 | /* Maximum frame size in bytes, for sanity checking. */ | ||
11 | #define UVC_MAX_FRAME_SIZE (16*1024*1024) | ||
12 | /* Maximum number of video buffers. */ | ||
13 | #define UVC_MAX_VIDEO_BUFFERS 32 | ||
14 | |||
15 | /* ------------------------------------------------------------------------ | ||
16 | * Structures. | ||
17 | */ | ||
18 | |||
19 | enum uvc_buffer_state { | ||
20 | UVC_BUF_STATE_IDLE = 0, | ||
21 | UVC_BUF_STATE_QUEUED = 1, | ||
22 | UVC_BUF_STATE_ACTIVE = 2, | ||
23 | UVC_BUF_STATE_DONE = 3, | ||
24 | UVC_BUF_STATE_ERROR = 4, | ||
25 | }; | ||
26 | |||
27 | struct uvc_buffer { | ||
28 | unsigned long vma_use_count; | ||
29 | struct list_head stream; | ||
30 | |||
31 | /* Touched by interrupt handler. */ | ||
32 | struct v4l2_buffer buf; | ||
33 | struct list_head queue; | ||
34 | wait_queue_head_t wait; | ||
35 | enum uvc_buffer_state state; | ||
36 | }; | ||
37 | |||
38 | #define UVC_QUEUE_STREAMING (1 << 0) | ||
39 | #define UVC_QUEUE_DISCONNECTED (1 << 1) | ||
40 | #define UVC_QUEUE_DROP_INCOMPLETE (1 << 2) | ||
41 | #define UVC_QUEUE_PAUSED (1 << 3) | ||
42 | |||
43 | struct uvc_video_queue { | ||
44 | enum v4l2_buf_type type; | ||
45 | |||
46 | void *mem; | ||
47 | unsigned int flags; | ||
48 | __u32 sequence; | ||
49 | |||
50 | unsigned int count; | ||
51 | unsigned int buf_size; | ||
52 | unsigned int buf_used; | ||
53 | struct uvc_buffer buffer[UVC_MAX_VIDEO_BUFFERS]; | ||
54 | struct mutex mutex; /* protects buffers and mainqueue */ | ||
55 | spinlock_t irqlock; /* protects irqqueue */ | ||
56 | |||
57 | struct list_head mainqueue; | ||
58 | struct list_head irqqueue; | ||
59 | }; | ||
60 | |||
61 | extern void uvc_queue_init(struct uvc_video_queue *queue, | ||
62 | enum v4l2_buf_type type); | ||
63 | extern int uvc_alloc_buffers(struct uvc_video_queue *queue, | ||
64 | unsigned int nbuffers, unsigned int buflength); | ||
65 | extern int uvc_free_buffers(struct uvc_video_queue *queue); | ||
66 | extern int uvc_query_buffer(struct uvc_video_queue *queue, | ||
67 | struct v4l2_buffer *v4l2_buf); | ||
68 | extern int uvc_queue_buffer(struct uvc_video_queue *queue, | ||
69 | struct v4l2_buffer *v4l2_buf); | ||
70 | extern int uvc_dequeue_buffer(struct uvc_video_queue *queue, | ||
71 | struct v4l2_buffer *v4l2_buf, int nonblocking); | ||
72 | extern int uvc_queue_enable(struct uvc_video_queue *queue, int enable); | ||
73 | extern void uvc_queue_cancel(struct uvc_video_queue *queue, int disconnect); | ||
74 | extern struct uvc_buffer *uvc_queue_next_buffer(struct uvc_video_queue *queue, | ||
75 | struct uvc_buffer *buf); | ||
76 | extern unsigned int uvc_queue_poll(struct uvc_video_queue *queue, | ||
77 | struct file *file, poll_table *wait); | ||
78 | extern int uvc_queue_mmap(struct uvc_video_queue *queue, | ||
79 | struct vm_area_struct *vma); | ||
80 | static inline int uvc_queue_streaming(struct uvc_video_queue *queue) | ||
81 | { | ||
82 | return queue->flags & UVC_QUEUE_STREAMING; | ||
83 | } | ||
84 | extern struct uvc_buffer *uvc_queue_head(struct uvc_video_queue *queue); | ||
85 | |||
86 | #endif /* __KERNEL__ */ | ||
87 | |||
88 | #endif /* _UVC_QUEUE_H_ */ | ||
89 | |||