diff options
Diffstat (limited to 'drivers/media/platform/omap3isp/ispqueue.h')
-rw-r--r-- | drivers/media/platform/omap3isp/ispqueue.h | 188 |
1 files changed, 0 insertions, 188 deletions
diff --git a/drivers/media/platform/omap3isp/ispqueue.h b/drivers/media/platform/omap3isp/ispqueue.h deleted file mode 100644 index 3e048ad65647..000000000000 --- a/drivers/media/platform/omap3isp/ispqueue.h +++ /dev/null | |||
@@ -1,188 +0,0 @@ | |||
1 | /* | ||
2 | * ispqueue.h | ||
3 | * | ||
4 | * TI OMAP3 ISP - Video buffers queue handling | ||
5 | * | ||
6 | * Copyright (C) 2010 Nokia Corporation | ||
7 | * | ||
8 | * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com> | ||
9 | * Sakari Ailus <sakari.ailus@iki.fi> | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License version 2 as | ||
13 | * published by the Free Software Foundation. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, but | ||
16 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
18 | * General Public License for more details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU General Public License | ||
21 | * along with this program; if not, write to the Free Software | ||
22 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
23 | * 02110-1301 USA | ||
24 | */ | ||
25 | |||
26 | #ifndef OMAP3_ISP_QUEUE_H | ||
27 | #define OMAP3_ISP_QUEUE_H | ||
28 | |||
29 | #include <linux/kernel.h> | ||
30 | #include <linux/list.h> | ||
31 | #include <linux/mm_types.h> | ||
32 | #include <linux/mutex.h> | ||
33 | #include <linux/videodev2.h> | ||
34 | #include <linux/wait.h> | ||
35 | |||
36 | struct isp_video_queue; | ||
37 | struct page; | ||
38 | struct scatterlist; | ||
39 | |||
40 | #define ISP_VIDEO_MAX_BUFFERS 16 | ||
41 | |||
42 | /** | ||
43 | * enum isp_video_buffer_state - ISP video buffer state | ||
44 | * @ISP_BUF_STATE_IDLE: The buffer is under userspace control (dequeued | ||
45 | * or not queued yet). | ||
46 | * @ISP_BUF_STATE_QUEUED: The buffer has been queued but isn't used by the | ||
47 | * device yet. | ||
48 | * @ISP_BUF_STATE_ACTIVE: The buffer is in use for an active video transfer. | ||
49 | * @ISP_BUF_STATE_ERROR: The device is done with the buffer and an error | ||
50 | * occurred. For capture device the buffer likely contains corrupted data or | ||
51 | * no data at all. | ||
52 | * @ISP_BUF_STATE_DONE: The device is done with the buffer and no error occurred. | ||
53 | * For capture devices the buffer contains valid data. | ||
54 | */ | ||
55 | enum isp_video_buffer_state { | ||
56 | ISP_BUF_STATE_IDLE, | ||
57 | ISP_BUF_STATE_QUEUED, | ||
58 | ISP_BUF_STATE_ACTIVE, | ||
59 | ISP_BUF_STATE_ERROR, | ||
60 | ISP_BUF_STATE_DONE, | ||
61 | }; | ||
62 | |||
63 | /** | ||
64 | * struct isp_video_buffer - ISP video buffer | ||
65 | * @vma_use_count: Number of times the buffer is mmap'ed to userspace | ||
66 | * @stream: List head for insertion into main queue | ||
67 | * @queue: ISP buffers queue this buffer belongs to | ||
68 | * @prepared: Whether the buffer has been prepared | ||
69 | * @skip_cache: Whether to skip cache management operations for this buffer | ||
70 | * @vaddr: Memory virtual address (for kernel buffers) | ||
71 | * @vm_flags: Buffer VMA flags (for userspace buffers) | ||
72 | * @offset: Offset inside the first page (for userspace buffers) | ||
73 | * @npages: Number of pages (for userspace buffers) | ||
74 | * @pages: Pages table (for userspace non-VM_PFNMAP buffers) | ||
75 | * @paddr: Memory physical address (for userspace VM_PFNMAP buffers) | ||
76 | * @sglen: Number of elements in the scatter list (for non-VM_PFNMAP buffers) | ||
77 | * @sglist: Scatter list (for non-VM_PFNMAP buffers) | ||
78 | * @vbuf: V4L2 buffer | ||
79 | * @irqlist: List head for insertion into IRQ queue | ||
80 | * @state: Current buffer state | ||
81 | * @wait: Wait queue to signal buffer completion | ||
82 | */ | ||
83 | struct isp_video_buffer { | ||
84 | unsigned long vma_use_count; | ||
85 | struct list_head stream; | ||
86 | struct isp_video_queue *queue; | ||
87 | unsigned int prepared:1; | ||
88 | bool skip_cache; | ||
89 | |||
90 | /* For kernel buffers. */ | ||
91 | void *vaddr; | ||
92 | |||
93 | /* For userspace buffers. */ | ||
94 | vm_flags_t vm_flags; | ||
95 | unsigned long offset; | ||
96 | unsigned int npages; | ||
97 | struct page **pages; | ||
98 | dma_addr_t paddr; | ||
99 | |||
100 | /* For all buffers except VM_PFNMAP. */ | ||
101 | unsigned int sglen; | ||
102 | struct scatterlist *sglist; | ||
103 | |||
104 | /* Touched by the interrupt handler. */ | ||
105 | struct v4l2_buffer vbuf; | ||
106 | struct list_head irqlist; | ||
107 | enum isp_video_buffer_state state; | ||
108 | wait_queue_head_t wait; | ||
109 | }; | ||
110 | |||
111 | #define to_isp_video_buffer(vb) container_of(vb, struct isp_video_buffer, vb) | ||
112 | |||
113 | /** | ||
114 | * struct isp_video_queue_operations - Driver-specific operations | ||
115 | * @queue_prepare: Called before allocating buffers. Drivers should clamp the | ||
116 | * number of buffers according to their requirements, and must return the | ||
117 | * buffer size in bytes. | ||
118 | * @buffer_prepare: Called the first time a buffer is queued, or after changing | ||
119 | * the userspace memory address for a USERPTR buffer, with the queue lock | ||
120 | * held. Drivers should perform device-specific buffer preparation (such as | ||
121 | * mapping the buffer memory in an IOMMU). This operation is optional. | ||
122 | * @buffer_queue: Called when a buffer is being added to the queue with the | ||
123 | * queue irqlock spinlock held. | ||
124 | * @buffer_cleanup: Called before freeing buffers, or before changing the | ||
125 | * userspace memory address for a USERPTR buffer, with the queue lock held. | ||
126 | * Drivers must perform cleanup operations required to undo the | ||
127 | * buffer_prepare call. This operation is optional. | ||
128 | */ | ||
129 | struct isp_video_queue_operations { | ||
130 | void (*queue_prepare)(struct isp_video_queue *queue, | ||
131 | unsigned int *nbuffers, unsigned int *size); | ||
132 | int (*buffer_prepare)(struct isp_video_buffer *buf); | ||
133 | void (*buffer_queue)(struct isp_video_buffer *buf); | ||
134 | void (*buffer_cleanup)(struct isp_video_buffer *buf); | ||
135 | }; | ||
136 | |||
137 | /** | ||
138 | * struct isp_video_queue - ISP video buffers queue | ||
139 | * @type: Type of video buffers handled by this queue | ||
140 | * @ops: Queue operations | ||
141 | * @dev: Device used for DMA operations | ||
142 | * @bufsize: Size of a driver-specific buffer object | ||
143 | * @count: Number of currently allocated buffers | ||
144 | * @buffers: ISP video buffers | ||
145 | * @lock: Mutex to protect access to the buffers, main queue and state | ||
146 | * @irqlock: Spinlock to protect access to the IRQ queue | ||
147 | * @streaming: Queue state, indicates whether the queue is streaming | ||
148 | * @queue: List of all queued buffers | ||
149 | */ | ||
150 | struct isp_video_queue { | ||
151 | enum v4l2_buf_type type; | ||
152 | const struct isp_video_queue_operations *ops; | ||
153 | struct device *dev; | ||
154 | unsigned int bufsize; | ||
155 | |||
156 | unsigned int count; | ||
157 | struct isp_video_buffer *buffers[ISP_VIDEO_MAX_BUFFERS]; | ||
158 | struct mutex lock; | ||
159 | spinlock_t irqlock; | ||
160 | |||
161 | unsigned int streaming:1; | ||
162 | |||
163 | struct list_head queue; | ||
164 | }; | ||
165 | |||
166 | int omap3isp_video_queue_cleanup(struct isp_video_queue *queue); | ||
167 | int omap3isp_video_queue_init(struct isp_video_queue *queue, | ||
168 | enum v4l2_buf_type type, | ||
169 | const struct isp_video_queue_operations *ops, | ||
170 | struct device *dev, unsigned int bufsize); | ||
171 | |||
172 | int omap3isp_video_queue_reqbufs(struct isp_video_queue *queue, | ||
173 | struct v4l2_requestbuffers *rb); | ||
174 | int omap3isp_video_queue_querybuf(struct isp_video_queue *queue, | ||
175 | struct v4l2_buffer *vbuf); | ||
176 | int omap3isp_video_queue_qbuf(struct isp_video_queue *queue, | ||
177 | struct v4l2_buffer *vbuf); | ||
178 | int omap3isp_video_queue_dqbuf(struct isp_video_queue *queue, | ||
179 | struct v4l2_buffer *vbuf, int nonblocking); | ||
180 | int omap3isp_video_queue_streamon(struct isp_video_queue *queue); | ||
181 | void omap3isp_video_queue_streamoff(struct isp_video_queue *queue); | ||
182 | void omap3isp_video_queue_discard_done(struct isp_video_queue *queue); | ||
183 | int omap3isp_video_queue_mmap(struct isp_video_queue *queue, | ||
184 | struct vm_area_struct *vma); | ||
185 | unsigned int omap3isp_video_queue_poll(struct isp_video_queue *queue, | ||
186 | struct file *file, poll_table *wait); | ||
187 | |||
188 | #endif /* OMAP3_ISP_QUEUE_H */ | ||