aboutsummaryrefslogtreecommitdiffstats
path: root/include/media/v4l2-mem2mem.h
diff options
context:
space:
mode:
authorMarek Szyprowski <m.szyprowski@samsung.com>2011-01-12 04:50:24 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-03-21 19:31:35 -0400
commit908a0d7c588ef87e5cf0a26805e6002a78ac9d13 (patch)
tree91e0cb5cc13fd6f1c01867b327d6b751db131da1 /include/media/v4l2-mem2mem.h
parent53b5d5749b6fcca37c7ad60cd40feafadd390b70 (diff)
[media] v4l: mem2mem: port to videobuf2
Port memory-to-memory framework to videobuf2 framework. Add support for multi-planar Video for Linux 2 API extensions to the memory-to-memory driver framework. Based on the original patch written by Pawel Osciak. Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'include/media/v4l2-mem2mem.h')
-rw-r--r--include/media/v4l2-mem2mem.h56
1 files changed, 35 insertions, 21 deletions
diff --git a/include/media/v4l2-mem2mem.h b/include/media/v4l2-mem2mem.h
index 8d149f1c58d..bf5eaaf3bd9 100644
--- a/include/media/v4l2-mem2mem.h
+++ b/include/media/v4l2-mem2mem.h
@@ -17,7 +17,7 @@
17#ifndef _MEDIA_V4L2_MEM2MEM_H 17#ifndef _MEDIA_V4L2_MEM2MEM_H
18#define _MEDIA_V4L2_MEM2MEM_H 18#define _MEDIA_V4L2_MEM2MEM_H
19 19
20#include <media/videobuf-core.h> 20#include <media/videobuf2-core.h>
21 21
22/** 22/**
23 * struct v4l2_m2m_ops - mem-to-mem device driver callbacks 23 * struct v4l2_m2m_ops - mem-to-mem device driver callbacks
@@ -45,17 +45,20 @@ struct v4l2_m2m_ops {
45 void (*device_run)(void *priv); 45 void (*device_run)(void *priv);
46 int (*job_ready)(void *priv); 46 int (*job_ready)(void *priv);
47 void (*job_abort)(void *priv); 47 void (*job_abort)(void *priv);
48 void (*lock)(void *priv);
49 void (*unlock)(void *priv);
48}; 50};
49 51
50struct v4l2_m2m_dev; 52struct v4l2_m2m_dev;
51 53
52struct v4l2_m2m_queue_ctx { 54struct v4l2_m2m_queue_ctx {
53/* private: internal use only */ 55/* private: internal use only */
54 struct videobuf_queue q; 56 struct vb2_queue q;
55 57
56 /* Queue for buffers ready to be processed as soon as this 58 /* Queue for buffers ready to be processed as soon as this
57 * instance receives access to the device */ 59 * instance receives access to the device */
58 struct list_head rdy_queue; 60 struct list_head rdy_queue;
61 spinlock_t rdy_spinlock;
59 u8 num_rdy; 62 u8 num_rdy;
60}; 63};
61 64
@@ -72,19 +75,31 @@ struct v4l2_m2m_ctx {
72 /* For device job queue */ 75 /* For device job queue */
73 struct list_head queue; 76 struct list_head queue;
74 unsigned long job_flags; 77 unsigned long job_flags;
78 wait_queue_head_t finished;
75 79
76 /* Instance private data */ 80 /* Instance private data */
77 void *priv; 81 void *priv;
78}; 82};
79 83
84struct v4l2_m2m_buffer {
85 struct vb2_buffer vb;
86 struct list_head list;
87};
88
80void *v4l2_m2m_get_curr_priv(struct v4l2_m2m_dev *m2m_dev); 89void *v4l2_m2m_get_curr_priv(struct v4l2_m2m_dev *m2m_dev);
81 90
82struct videobuf_queue *v4l2_m2m_get_vq(struct v4l2_m2m_ctx *m2m_ctx, 91struct vb2_queue *v4l2_m2m_get_vq(struct v4l2_m2m_ctx *m2m_ctx,
83 enum v4l2_buf_type type); 92 enum v4l2_buf_type type);
84 93
85void v4l2_m2m_job_finish(struct v4l2_m2m_dev *m2m_dev, 94void v4l2_m2m_job_finish(struct v4l2_m2m_dev *m2m_dev,
86 struct v4l2_m2m_ctx *m2m_ctx); 95 struct v4l2_m2m_ctx *m2m_ctx);
87 96
97static inline void
98v4l2_m2m_buf_done(struct vb2_buffer *buf, enum vb2_buffer_state state)
99{
100 vb2_buffer_done(buf, state);
101}
102
88int v4l2_m2m_reqbufs(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, 103int v4l2_m2m_reqbufs(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
89 struct v4l2_requestbuffers *reqbufs); 104 struct v4l2_requestbuffers *reqbufs);
90 105
@@ -110,13 +125,13 @@ int v4l2_m2m_mmap(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
110struct v4l2_m2m_dev *v4l2_m2m_init(struct v4l2_m2m_ops *m2m_ops); 125struct v4l2_m2m_dev *v4l2_m2m_init(struct v4l2_m2m_ops *m2m_ops);
111void v4l2_m2m_release(struct v4l2_m2m_dev *m2m_dev); 126void v4l2_m2m_release(struct v4l2_m2m_dev *m2m_dev);
112 127
113struct v4l2_m2m_ctx *v4l2_m2m_ctx_init(void *priv, struct v4l2_m2m_dev *m2m_dev, 128struct v4l2_m2m_ctx *v4l2_m2m_ctx_init(struct v4l2_m2m_dev *m2m_dev,
114 void (*vq_init)(void *priv, struct videobuf_queue *, 129 void *drv_priv,
115 enum v4l2_buf_type)); 130 int (*queue_init)(void *priv, struct vb2_queue *src_vq, struct vb2_queue *dst_vq));
131
116void v4l2_m2m_ctx_release(struct v4l2_m2m_ctx *m2m_ctx); 132void v4l2_m2m_ctx_release(struct v4l2_m2m_ctx *m2m_ctx);
117 133
118void v4l2_m2m_buf_queue(struct v4l2_m2m_ctx *m2m_ctx, struct videobuf_queue *vq, 134void v4l2_m2m_buf_queue(struct v4l2_m2m_ctx *m2m_ctx, struct vb2_buffer *vb);
119 struct videobuf_buffer *vb);
120 135
121/** 136/**
122 * v4l2_m2m_num_src_bufs_ready() - return the number of source buffers ready for 137 * v4l2_m2m_num_src_bufs_ready() - return the number of source buffers ready for
@@ -138,7 +153,7 @@ unsigned int v4l2_m2m_num_dst_bufs_ready(struct v4l2_m2m_ctx *m2m_ctx)
138 return m2m_ctx->out_q_ctx.num_rdy; 153 return m2m_ctx->out_q_ctx.num_rdy;
139} 154}
140 155
141void *v4l2_m2m_next_buf(struct v4l2_m2m_ctx *m2m_ctx, enum v4l2_buf_type type); 156void *v4l2_m2m_next_buf(struct v4l2_m2m_queue_ctx *q_ctx);
142 157
143/** 158/**
144 * v4l2_m2m_next_src_buf() - return next source buffer from the list of ready 159 * v4l2_m2m_next_src_buf() - return next source buffer from the list of ready
@@ -146,7 +161,7 @@ void *v4l2_m2m_next_buf(struct v4l2_m2m_ctx *m2m_ctx, enum v4l2_buf_type type);
146 */ 161 */
147static inline void *v4l2_m2m_next_src_buf(struct v4l2_m2m_ctx *m2m_ctx) 162static inline void *v4l2_m2m_next_src_buf(struct v4l2_m2m_ctx *m2m_ctx)
148{ 163{
149 return v4l2_m2m_next_buf(m2m_ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); 164 return v4l2_m2m_next_buf(&m2m_ctx->out_q_ctx);
150} 165}
151 166
152/** 167/**
@@ -155,29 +170,28 @@ static inline void *v4l2_m2m_next_src_buf(struct v4l2_m2m_ctx *m2m_ctx)
155 */ 170 */
156static inline void *v4l2_m2m_next_dst_buf(struct v4l2_m2m_ctx *m2m_ctx) 171static inline void *v4l2_m2m_next_dst_buf(struct v4l2_m2m_ctx *m2m_ctx)
157{ 172{
158 return v4l2_m2m_next_buf(m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); 173 return v4l2_m2m_next_buf(&m2m_ctx->cap_q_ctx);
159} 174}
160 175
161/** 176/**
162 * v4l2_m2m_get_src_vq() - return videobuf_queue for source buffers 177 * v4l2_m2m_get_src_vq() - return vb2_queue for source buffers
163 */ 178 */
164static inline 179static inline
165struct videobuf_queue *v4l2_m2m_get_src_vq(struct v4l2_m2m_ctx *m2m_ctx) 180struct vb2_queue *v4l2_m2m_get_src_vq(struct v4l2_m2m_ctx *m2m_ctx)
166{ 181{
167 return v4l2_m2m_get_vq(m2m_ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); 182 return &m2m_ctx->out_q_ctx.q;
168} 183}
169 184
170/** 185/**
171 * v4l2_m2m_get_dst_vq() - return videobuf_queue for destination buffers 186 * v4l2_m2m_get_dst_vq() - return vb2_queue for destination buffers
172 */ 187 */
173static inline 188static inline
174struct videobuf_queue *v4l2_m2m_get_dst_vq(struct v4l2_m2m_ctx *m2m_ctx) 189struct vb2_queue *v4l2_m2m_get_dst_vq(struct v4l2_m2m_ctx *m2m_ctx)
175{ 190{
176 return v4l2_m2m_get_vq(m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); 191 return &m2m_ctx->cap_q_ctx.q;
177} 192}
178 193
179void *v4l2_m2m_buf_remove(struct v4l2_m2m_ctx *m2m_ctx, 194void *v4l2_m2m_buf_remove(struct v4l2_m2m_queue_ctx *q_ctx);
180 enum v4l2_buf_type type);
181 195
182/** 196/**
183 * v4l2_m2m_src_buf_remove() - take off a source buffer from the list of ready 197 * v4l2_m2m_src_buf_remove() - take off a source buffer from the list of ready
@@ -185,7 +199,7 @@ void *v4l2_m2m_buf_remove(struct v4l2_m2m_ctx *m2m_ctx,
185 */ 199 */
186static inline void *v4l2_m2m_src_buf_remove(struct v4l2_m2m_ctx *m2m_ctx) 200static inline void *v4l2_m2m_src_buf_remove(struct v4l2_m2m_ctx *m2m_ctx)
187{ 201{
188 return v4l2_m2m_buf_remove(m2m_ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); 202 return v4l2_m2m_buf_remove(&m2m_ctx->out_q_ctx);
189} 203}
190 204
191/** 205/**
@@ -194,7 +208,7 @@ static inline void *v4l2_m2m_src_buf_remove(struct v4l2_m2m_ctx *m2m_ctx)
194 */ 208 */
195static inline void *v4l2_m2m_dst_buf_remove(struct v4l2_m2m_ctx *m2m_ctx) 209static inline void *v4l2_m2m_dst_buf_remove(struct v4l2_m2m_ctx *m2m_ctx)
196{ 210{
197 return v4l2_m2m_buf_remove(m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); 211 return v4l2_m2m_buf_remove(&m2m_ctx->cap_q_ctx);
198} 212}
199 213
200#endif /* _MEDIA_V4L2_MEM2MEM_H */ 214#endif /* _MEDIA_V4L2_MEM2MEM_H */