aboutsummaryrefslogtreecommitdiffstats
path: root/include/media
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@s-opensource.com>2016-09-08 09:16:36 -0400
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2016-09-09 09:13:25 -0400
commit5fa5edbe59a7ab8ab649268fcb578662dfb7ca99 (patch)
treec42439a6f5d15e0201ec934c412cb8bca8c8e846 /include/media
parentdcbd87358929ed989732a9866e683e33d0018461 (diff)
[media] v4l2-mem2mem.h: document the public structures
Most structures here are not documented. Add a documentation for them. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'include/media')
-rw-r--r--include/media/v4l2-mem2mem.h67
1 files changed, 51 insertions, 16 deletions
diff --git a/include/media/v4l2-mem2mem.h b/include/media/v4l2-mem2mem.h
index 00410bd14772..cfa4f5e521a7 100644
--- a/include/media/v4l2-mem2mem.h
+++ b/include/media/v4l2-mem2mem.h
@@ -41,9 +41,9 @@
41 * This function does not have to (and will usually not) wait 41 * This function does not have to (and will usually not) wait
42 * until the device enters a state when it can be stopped. 42 * until the device enters a state when it can be stopped.
43 * @lock: optional. Define a driver's own lock callback, instead of using 43 * @lock: optional. Define a driver's own lock callback, instead of using
44 * m2m_ctx->q_lock. 44 * &v4l2_m2m_ctx->q_lock.
45 * @unlock: optional. Define a driver's own unlock callback, instead of 45 * @unlock: optional. Define a driver's own unlock callback, instead of
46 * using m2m_ctx->q_lock. 46 * using &v4l2_m2m_ctx->q_lock.
47 */ 47 */
48struct v4l2_m2m_ops { 48struct v4l2_m2m_ops {
49 void (*device_run)(void *priv); 49 void (*device_run)(void *priv);
@@ -53,31 +53,59 @@ struct v4l2_m2m_ops {
53 void (*unlock)(void *priv); 53 void (*unlock)(void *priv);
54}; 54};
55 55
56/**
57 * struct v4l2_m2m_dev - opaque struct used to represent a V4L2 M2M device.
58 *
59 * This structure is has the per-device context for a memory to memory
60 * device, and it is used internally at v4l2-mem2mem.c.
61 */
56struct v4l2_m2m_dev; 62struct v4l2_m2m_dev;
57 63
64/**
65 * struct v4l2_m2m_queue_ctx - represents a queue for buffers ready to be
66 * processed
67 *
68 * @q: pointer to struct &vb2_queue
69 * @rdy_queue: List of V4L2 mem-to-mem queues
70 * @rdy_spinlock: spin lock to protect the struct usage
71 * @num_rdy: number of buffers ready to be processed
72 * @buffered: is the queue buffered?
73 *
74 * Queue for buffers ready to be processed as soon as this
75 * instance receives access to the device.
76 */
77
58struct v4l2_m2m_queue_ctx { 78struct v4l2_m2m_queue_ctx {
59/* private: internal use only */
60 struct vb2_queue q; 79 struct vb2_queue q;
61 80
62 /* Queue for buffers ready to be processed as soon as this
63 * instance receives access to the device */
64 struct list_head rdy_queue; 81 struct list_head rdy_queue;
65 spinlock_t rdy_spinlock; 82 spinlock_t rdy_spinlock;
66 u8 num_rdy; 83 u8 num_rdy;
67 bool buffered; 84 bool buffered;
68}; 85};
69 86
87/**
88 * struct v4l2_m2m_ctx - Memory to memory context structure
89 *
90 * @q_lock: struct &mutex lock
91 * @m2m_dev: pointer to struct &v4l2_m2m_dev
92 * @cap_q_ctx: Capture (output to memory) queue context
93 * @out_q_ctx: Output (input from memory) queue context
94 * @queue: List of memory to memory contexts
95 * @job_flags: Job queue flags, used internally by v4l2-mem2mem.c:
96 * %TRANS_QUEUED, %TRANS_RUNNING and %TRANS_ABORT.
97 * @finished: Wait queue used to signalize when a job queue finished.
98 * @priv: Instance private data
99 */
70struct v4l2_m2m_ctx { 100struct v4l2_m2m_ctx {
71 /* optional cap/out vb2 queues lock */ 101 /* optional cap/out vb2 queues lock */
72 struct mutex *q_lock; 102 struct mutex *q_lock;
73 103
74/* private: internal use only */ 104 /* internal use only */
75 struct v4l2_m2m_dev *m2m_dev; 105 struct v4l2_m2m_dev *m2m_dev;
76 106
77 /* Capture (output to memory) queue context */
78 struct v4l2_m2m_queue_ctx cap_q_ctx; 107 struct v4l2_m2m_queue_ctx cap_q_ctx;
79 108
80 /* Output (input from memory) queue context */
81 struct v4l2_m2m_queue_ctx out_q_ctx; 109 struct v4l2_m2m_queue_ctx out_q_ctx;
82 110
83 /* For device job queue */ 111 /* For device job queue */
@@ -85,10 +113,15 @@ struct v4l2_m2m_ctx {
85 unsigned long job_flags; 113 unsigned long job_flags;
86 wait_queue_head_t finished; 114 wait_queue_head_t finished;
87 115
88 /* Instance private data */
89 void *priv; 116 void *priv;
90}; 117};
91 118
119/**
120 * struct v4l2_m2m_buffer - Memory to memory buffer
121 *
122 * @vb: pointer to struct &vb2_v4l2_buffer
123 * @list: list of m2m buffers
124 */
92struct v4l2_m2m_buffer { 125struct v4l2_m2m_buffer {
93 struct vb2_v4l2_buffer vb; 126 struct vb2_v4l2_buffer vb;
94 struct list_head list; 127 struct list_head list;
@@ -145,9 +178,9 @@ void v4l2_m2m_try_schedule(struct v4l2_m2m_ctx *m2m_ctx);
145 * Should be called as soon as possible after reaching a state which allows 178 * Should be called as soon as possible after reaching a state which allows
146 * other instances to take control of the device. 179 * other instances to take control of the device.
147 * 180 *
148 * This function has to be called only after device_run() callback has been 181 * This function has to be called only after &v4l2_m2m_ops->device_run
149 * called on the driver. To prevent recursion, it should not be called directly 182 * callback has been called on the driver. To prevent recursion, it should
150 * from the device_run() callback though. 183 * not be called directly from the &v4l2_m2m_ops->device_run callback though.
151 */ 184 */
152void v4l2_m2m_job_finish(struct v4l2_m2m_dev *m2m_dev, 185void v4l2_m2m_job_finish(struct v4l2_m2m_dev *m2m_dev,
153 struct v4l2_m2m_ctx *m2m_ctx); 186 struct v4l2_m2m_ctx *m2m_ctx);
@@ -292,7 +325,9 @@ int v4l2_m2m_mmap(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
292 * 325 *
293 * @m2m_ops: pointer to struct v4l2_m2m_ops 326 * @m2m_ops: pointer to struct v4l2_m2m_ops
294 * 327 *
295 * Usually called from driver's probe() function. 328 * Usually called from driver's ``probe()`` function.
329 *
330 * Return: returns an opaque pointer to the internal data to handle M2M context
296 */ 331 */
297struct v4l2_m2m_dev *v4l2_m2m_init(const struct v4l2_m2m_ops *m2m_ops); 332struct v4l2_m2m_dev *v4l2_m2m_init(const struct v4l2_m2m_ops *m2m_ops);
298 333
@@ -301,7 +336,7 @@ struct v4l2_m2m_dev *v4l2_m2m_init(const struct v4l2_m2m_ops *m2m_ops);
301 * 336 *
302 * @m2m_dev: pointer to struct &v4l2_m2m_dev 337 * @m2m_dev: pointer to struct &v4l2_m2m_dev
303 * 338 *
304 * Usually called from driver's remove() function. 339 * Usually called from driver's ``remove()`` function.
305 */ 340 */
306void v4l2_m2m_release(struct v4l2_m2m_dev *m2m_dev); 341void v4l2_m2m_release(struct v4l2_m2m_dev *m2m_dev);
307 342
@@ -313,7 +348,7 @@ void v4l2_m2m_release(struct v4l2_m2m_dev *m2m_dev);
313 * @queue_init: a callback for queue type-specific initialization function 348 * @queue_init: a callback for queue type-specific initialization function
314 * to be used for initializing videobuf_queues 349 * to be used for initializing videobuf_queues
315 * 350 *
316 * Usually called from driver's open() function. 351 * Usually called from driver's ``open()`` function.
317 */ 352 */
318struct v4l2_m2m_ctx *v4l2_m2m_ctx_init(struct v4l2_m2m_dev *m2m_dev, 353struct v4l2_m2m_ctx *v4l2_m2m_ctx_init(struct v4l2_m2m_dev *m2m_dev,
319 void *drv_priv, 354 void *drv_priv,
@@ -346,7 +381,7 @@ void v4l2_m2m_ctx_release(struct v4l2_m2m_ctx *m2m_ctx);
346 * @m2m_ctx: m2m context assigned to the instance given by struct &v4l2_m2m_ctx 381 * @m2m_ctx: m2m context assigned to the instance given by struct &v4l2_m2m_ctx
347 * @vbuf: pointer to struct &vb2_v4l2_buffer 382 * @vbuf: pointer to struct &vb2_v4l2_buffer
348 * 383 *
349 * Call from buf_queue(), videobuf_queue_ops callback. 384 * Call from videobuf_queue_ops->ops->buf_queue, videobuf_queue_ops callback.
350 */ 385 */
351void v4l2_m2m_buf_queue(struct v4l2_m2m_ctx *m2m_ctx, 386void v4l2_m2m_buf_queue(struct v4l2_m2m_ctx *m2m_ctx,
352 struct vb2_v4l2_buffer *vbuf); 387 struct vb2_v4l2_buffer *vbuf);