diff options
author | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2016-09-08 09:16:27 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2016-09-09 09:05:32 -0400 |
commit | 4781646c1e13b23ed31eb12f7e314824d98ce066 (patch) | |
tree | e1a60c3f9d443a1bb145b7144590d66fbdcebd18 /include/media | |
parent | 82631b5bb268f670613db110177483ae3e85f913 (diff) |
[media] v4l2-mem2mem.h: move descriptions from .c file
Several routines are somewhat documented at v4l2-mem2mem.c
file. Move what's there to the header file.
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'include/media')
-rw-r--r-- | include/media/v4l2-mem2mem.h | 132 |
1 files changed, 132 insertions, 0 deletions
diff --git a/include/media/v4l2-mem2mem.h b/include/media/v4l2-mem2mem.h index 5a9597dd1ee0..e5449a2c8475 100644 --- a/include/media/v4l2-mem2mem.h +++ b/include/media/v4l2-mem2mem.h | |||
@@ -94,13 +94,52 @@ struct v4l2_m2m_buffer { | |||
94 | struct list_head list; | 94 | struct list_head list; |
95 | }; | 95 | }; |
96 | 96 | ||
97 | /** | ||
98 | * v4l2_m2m_get_curr_priv() - return driver private data for the currently | ||
99 | * running instance or NULL if no instance is running | ||
100 | */ | ||
97 | void *v4l2_m2m_get_curr_priv(struct v4l2_m2m_dev *m2m_dev); | 101 | void *v4l2_m2m_get_curr_priv(struct v4l2_m2m_dev *m2m_dev); |
98 | 102 | ||
103 | /** | ||
104 | * v4l2_m2m_get_vq() - return vb2_queue for the given type | ||
105 | */ | ||
99 | struct vb2_queue *v4l2_m2m_get_vq(struct v4l2_m2m_ctx *m2m_ctx, | 106 | struct vb2_queue *v4l2_m2m_get_vq(struct v4l2_m2m_ctx *m2m_ctx, |
100 | enum v4l2_buf_type type); | 107 | enum v4l2_buf_type type); |
101 | 108 | ||
109 | /** | ||
110 | * v4l2_m2m_try_schedule() - check whether an instance is ready to be added to | ||
111 | * the pending job queue and add it if so. | ||
112 | * @m2m_ctx: m2m context assigned to the instance to be checked | ||
113 | * | ||
114 | * There are three basic requirements an instance has to meet to be able to run: | ||
115 | * 1) at least one source buffer has to be queued, | ||
116 | * 2) at least one destination buffer has to be queued, | ||
117 | * 3) streaming has to be on. | ||
118 | * | ||
119 | * If a queue is buffered (for example a decoder hardware ringbuffer that has | ||
120 | * to be drained before doing streamoff), allow scheduling without v4l2 buffers | ||
121 | * on that queue. | ||
122 | * | ||
123 | * There may also be additional, custom requirements. In such case the driver | ||
124 | * should supply a custom callback (job_ready in v4l2_m2m_ops) that should | ||
125 | * return 1 if the instance is ready. | ||
126 | * An example of the above could be an instance that requires more than one | ||
127 | * src/dst buffer per transaction. | ||
128 | */ | ||
102 | void v4l2_m2m_try_schedule(struct v4l2_m2m_ctx *m2m_ctx); | 129 | void v4l2_m2m_try_schedule(struct v4l2_m2m_ctx *m2m_ctx); |
103 | 130 | ||
131 | /** | ||
132 | * v4l2_m2m_job_finish() - inform the framework that a job has been finished | ||
133 | * and have it clean up | ||
134 | * | ||
135 | * Called by a driver to yield back the device after it has finished with it. | ||
136 | * Should be called as soon as possible after reaching a state which allows | ||
137 | * other instances to take control of the device. | ||
138 | * | ||
139 | * This function has to be called only after device_run() callback has been | ||
140 | * called on the driver. To prevent recursion, it should not be called directly | ||
141 | * from the device_run() callback though. | ||
142 | */ | ||
104 | void v4l2_m2m_job_finish(struct v4l2_m2m_dev *m2m_dev, | 143 | void v4l2_m2m_job_finish(struct v4l2_m2m_dev *m2m_dev, |
105 | struct v4l2_m2m_ctx *m2m_ctx); | 144 | struct v4l2_m2m_ctx *m2m_ctx); |
106 | 145 | ||
@@ -110,38 +149,114 @@ v4l2_m2m_buf_done(struct vb2_v4l2_buffer *buf, enum vb2_buffer_state state) | |||
110 | vb2_buffer_done(&buf->vb2_buf, state); | 149 | vb2_buffer_done(&buf->vb2_buf, state); |
111 | } | 150 | } |
112 | 151 | ||
152 | /** | ||
153 | * v4l2_m2m_reqbufs() - multi-queue-aware REQBUFS multiplexer | ||
154 | */ | ||
113 | int v4l2_m2m_reqbufs(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, | 155 | int v4l2_m2m_reqbufs(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, |
114 | struct v4l2_requestbuffers *reqbufs); | 156 | struct v4l2_requestbuffers *reqbufs); |
115 | 157 | ||
158 | /** | ||
159 | * v4l2_m2m_querybuf() - multi-queue-aware QUERYBUF multiplexer | ||
160 | * | ||
161 | * See v4l2_m2m_mmap() documentation for details. | ||
162 | */ | ||
116 | int v4l2_m2m_querybuf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, | 163 | int v4l2_m2m_querybuf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, |
117 | struct v4l2_buffer *buf); | 164 | struct v4l2_buffer *buf); |
118 | 165 | ||
166 | /** | ||
167 | * v4l2_m2m_qbuf() - enqueue a source or destination buffer, depending on | ||
168 | * the type | ||
169 | */ | ||
119 | int v4l2_m2m_qbuf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, | 170 | int v4l2_m2m_qbuf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, |
120 | struct v4l2_buffer *buf); | 171 | struct v4l2_buffer *buf); |
172 | |||
173 | /** | ||
174 | * v4l2_m2m_dqbuf() - dequeue a source or destination buffer, depending on | ||
175 | * the type | ||
176 | */ | ||
121 | int v4l2_m2m_dqbuf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, | 177 | int v4l2_m2m_dqbuf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, |
122 | struct v4l2_buffer *buf); | 178 | struct v4l2_buffer *buf); |
179 | |||
180 | /** | ||
181 | * v4l2_m2m_prepare_buf() - prepare a source or destination buffer, depending on | ||
182 | * the type | ||
183 | */ | ||
123 | int v4l2_m2m_prepare_buf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, | 184 | int v4l2_m2m_prepare_buf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, |
124 | struct v4l2_buffer *buf); | 185 | struct v4l2_buffer *buf); |
186 | |||
187 | /** | ||
188 | * v4l2_m2m_create_bufs() - create a source or destination buffer, depending | ||
189 | * on the type | ||
190 | */ | ||
125 | int v4l2_m2m_create_bufs(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, | 191 | int v4l2_m2m_create_bufs(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, |
126 | struct v4l2_create_buffers *create); | 192 | struct v4l2_create_buffers *create); |
127 | 193 | ||
194 | /** | ||
195 | * v4l2_m2m_expbuf() - export a source or destination buffer, depending on | ||
196 | * the type | ||
197 | */ | ||
128 | int v4l2_m2m_expbuf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, | 198 | int v4l2_m2m_expbuf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, |
129 | struct v4l2_exportbuffer *eb); | 199 | struct v4l2_exportbuffer *eb); |
130 | 200 | ||
201 | /** | ||
202 | * v4l2_m2m_streamon() - turn on streaming for a video queue | ||
203 | */ | ||
131 | int v4l2_m2m_streamon(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, | 204 | int v4l2_m2m_streamon(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, |
132 | enum v4l2_buf_type type); | 205 | enum v4l2_buf_type type); |
206 | |||
207 | /** | ||
208 | * v4l2_m2m_streamoff() - turn off streaming for a video queue | ||
209 | */ | ||
133 | int v4l2_m2m_streamoff(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, | 210 | int v4l2_m2m_streamoff(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, |
134 | enum v4l2_buf_type type); | 211 | enum v4l2_buf_type type); |
135 | 212 | ||
213 | /** | ||
214 | * v4l2_m2m_poll() - poll replacement, for destination buffers only | ||
215 | * | ||
216 | * Call from the driver's poll() function. Will poll both queues. If a buffer | ||
217 | * is available to dequeue (with dqbuf) from the source queue, this will | ||
218 | * indicate that a non-blocking write can be performed, while read will be | ||
219 | * returned in case of the destination queue. | ||
220 | */ | ||
136 | unsigned int v4l2_m2m_poll(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, | 221 | unsigned int v4l2_m2m_poll(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, |
137 | struct poll_table_struct *wait); | 222 | struct poll_table_struct *wait); |
138 | 223 | ||
224 | /** | ||
225 | * v4l2_m2m_mmap() - source and destination queues-aware mmap multiplexer | ||
226 | * | ||
227 | * Call from driver's mmap() function. Will handle mmap() for both queues | ||
228 | * seamlessly for videobuffer, which will receive normal per-queue offsets and | ||
229 | * proper videobuf queue pointers. The differentiation is made outside videobuf | ||
230 | * by adding a predefined offset to buffers from one of the queues and | ||
231 | * subtracting it before passing it back to videobuf. Only drivers (and | ||
232 | * thus applications) receive modified offsets. | ||
233 | */ | ||
139 | int v4l2_m2m_mmap(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, | 234 | int v4l2_m2m_mmap(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, |
140 | struct vm_area_struct *vma); | 235 | struct vm_area_struct *vma); |
141 | 236 | ||
237 | /** | ||
238 | * v4l2_m2m_init() - initialize per-driver m2m data | ||
239 | * | ||
240 | * Usually called from driver's probe() function. | ||
241 | */ | ||
142 | struct v4l2_m2m_dev *v4l2_m2m_init(const struct v4l2_m2m_ops *m2m_ops); | 242 | struct v4l2_m2m_dev *v4l2_m2m_init(const struct v4l2_m2m_ops *m2m_ops); |
243 | |||
244 | /** | ||
245 | * v4l2_m2m_release() - cleans up and frees a m2m_dev structure | ||
246 | * | ||
247 | * Usually called from driver's remove() function. | ||
248 | */ | ||
143 | void v4l2_m2m_release(struct v4l2_m2m_dev *m2m_dev); | 249 | void v4l2_m2m_release(struct v4l2_m2m_dev *m2m_dev); |
144 | 250 | ||
251 | /** | ||
252 | * v4l2_m2m_ctx_init() - allocate and initialize a m2m context | ||
253 | * @priv - driver's instance private data | ||
254 | * @m2m_dev - a previously initialized m2m_dev struct | ||
255 | * @vq_init - a callback for queue type-specific initialization function to be | ||
256 | * used for initializing videobuf_queues | ||
257 | * | ||
258 | * Usually called from driver's open() function. | ||
259 | */ | ||
145 | struct v4l2_m2m_ctx *v4l2_m2m_ctx_init(struct v4l2_m2m_dev *m2m_dev, | 260 | struct v4l2_m2m_ctx *v4l2_m2m_ctx_init(struct v4l2_m2m_dev *m2m_dev, |
146 | void *drv_priv, | 261 | void *drv_priv, |
147 | int (*queue_init)(void *priv, struct vb2_queue *src_vq, struct vb2_queue *dst_vq)); | 262 | int (*queue_init)(void *priv, struct vb2_queue *src_vq, struct vb2_queue *dst_vq)); |
@@ -158,8 +273,18 @@ static inline void v4l2_m2m_set_dst_buffered(struct v4l2_m2m_ctx *m2m_ctx, | |||
158 | m2m_ctx->cap_q_ctx.buffered = buffered; | 273 | m2m_ctx->cap_q_ctx.buffered = buffered; |
159 | } | 274 | } |
160 | 275 | ||
276 | /** | ||
277 | * v4l2_m2m_ctx_release() - release m2m context | ||
278 | * | ||
279 | * Usually called from driver's release() function. | ||
280 | */ | ||
161 | void v4l2_m2m_ctx_release(struct v4l2_m2m_ctx *m2m_ctx); | 281 | void v4l2_m2m_ctx_release(struct v4l2_m2m_ctx *m2m_ctx); |
162 | 282 | ||
283 | /** | ||
284 | * v4l2_m2m_buf_queue() - add a buffer to the proper ready buffers list. | ||
285 | * | ||
286 | * Call from buf_queue(), videobuf_queue_ops callback. | ||
287 | */ | ||
163 | void v4l2_m2m_buf_queue(struct v4l2_m2m_ctx *m2m_ctx, | 288 | void v4l2_m2m_buf_queue(struct v4l2_m2m_ctx *m2m_ctx, |
164 | struct vb2_v4l2_buffer *vbuf); | 289 | struct vb2_v4l2_buffer *vbuf); |
165 | 290 | ||
@@ -187,6 +312,9 @@ unsigned int v4l2_m2m_num_dst_bufs_ready(struct v4l2_m2m_ctx *m2m_ctx) | |||
187 | return m2m_ctx->cap_q_ctx.num_rdy; | 312 | return m2m_ctx->cap_q_ctx.num_rdy; |
188 | } | 313 | } |
189 | 314 | ||
315 | /** | ||
316 | * v4l2_m2m_next_buf() - return next buffer from the list of ready buffers | ||
317 | */ | ||
190 | void *v4l2_m2m_next_buf(struct v4l2_m2m_queue_ctx *q_ctx); | 318 | void *v4l2_m2m_next_buf(struct v4l2_m2m_queue_ctx *q_ctx); |
191 | 319 | ||
192 | /** | 320 | /** |
@@ -233,6 +361,10 @@ struct vb2_queue *v4l2_m2m_get_dst_vq(struct v4l2_m2m_ctx *m2m_ctx) | |||
233 | return &m2m_ctx->cap_q_ctx.q; | 361 | return &m2m_ctx->cap_q_ctx.q; |
234 | } | 362 | } |
235 | 363 | ||
364 | /** | ||
365 | * v4l2_m2m_buf_remove() - take off a buffer from the list of ready buffers and | ||
366 | * return it | ||
367 | */ | ||
236 | void *v4l2_m2m_buf_remove(struct v4l2_m2m_queue_ctx *q_ctx); | 368 | void *v4l2_m2m_buf_remove(struct v4l2_m2m_queue_ctx *q_ctx); |
237 | 369 | ||
238 | /** | 370 | /** |