diff options
Diffstat (limited to 'include/media/v4l2-mem2mem.h')
-rw-r--r-- | include/media/v4l2-mem2mem.h | 56 |
1 files changed, 35 insertions, 21 deletions
diff --git a/include/media/v4l2-mem2mem.h b/include/media/v4l2-mem2mem.h index 8d149f1c58d0..bf5eaaf3bd97 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 | ||
50 | struct v4l2_m2m_dev; | 52 | struct v4l2_m2m_dev; |
51 | 53 | ||
52 | struct v4l2_m2m_queue_ctx { | 54 | struct 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 | ||
84 | struct v4l2_m2m_buffer { | ||
85 | struct vb2_buffer vb; | ||
86 | struct list_head list; | ||
87 | }; | ||
88 | |||
80 | void *v4l2_m2m_get_curr_priv(struct v4l2_m2m_dev *m2m_dev); | 89 | void *v4l2_m2m_get_curr_priv(struct v4l2_m2m_dev *m2m_dev); |
81 | 90 | ||
82 | struct videobuf_queue *v4l2_m2m_get_vq(struct v4l2_m2m_ctx *m2m_ctx, | 91 | struct 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 | ||
85 | void v4l2_m2m_job_finish(struct v4l2_m2m_dev *m2m_dev, | 94 | void 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 | ||
97 | static inline void | ||
98 | v4l2_m2m_buf_done(struct vb2_buffer *buf, enum vb2_buffer_state state) | ||
99 | { | ||
100 | vb2_buffer_done(buf, state); | ||
101 | } | ||
102 | |||
88 | int v4l2_m2m_reqbufs(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, | 103 | int 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, | |||
110 | struct v4l2_m2m_dev *v4l2_m2m_init(struct v4l2_m2m_ops *m2m_ops); | 125 | struct v4l2_m2m_dev *v4l2_m2m_init(struct v4l2_m2m_ops *m2m_ops); |
111 | void v4l2_m2m_release(struct v4l2_m2m_dev *m2m_dev); | 126 | void v4l2_m2m_release(struct v4l2_m2m_dev *m2m_dev); |
112 | 127 | ||
113 | struct v4l2_m2m_ctx *v4l2_m2m_ctx_init(void *priv, struct v4l2_m2m_dev *m2m_dev, | 128 | struct 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 | |||
116 | void v4l2_m2m_ctx_release(struct v4l2_m2m_ctx *m2m_ctx); | 132 | void v4l2_m2m_ctx_release(struct v4l2_m2m_ctx *m2m_ctx); |
117 | 133 | ||
118 | void v4l2_m2m_buf_queue(struct v4l2_m2m_ctx *m2m_ctx, struct videobuf_queue *vq, | 134 | void 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 | ||
141 | void *v4l2_m2m_next_buf(struct v4l2_m2m_ctx *m2m_ctx, enum v4l2_buf_type type); | 156 | void *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 | */ |
147 | static inline void *v4l2_m2m_next_src_buf(struct v4l2_m2m_ctx *m2m_ctx) | 162 | static 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 | */ |
156 | static inline void *v4l2_m2m_next_dst_buf(struct v4l2_m2m_ctx *m2m_ctx) | 171 | static 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 | */ |
164 | static inline | 179 | static inline |
165 | struct videobuf_queue *v4l2_m2m_get_src_vq(struct v4l2_m2m_ctx *m2m_ctx) | 180 | struct 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 | */ |
173 | static inline | 188 | static inline |
174 | struct videobuf_queue *v4l2_m2m_get_dst_vq(struct v4l2_m2m_ctx *m2m_ctx) | 189 | struct 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 | ||
179 | void *v4l2_m2m_buf_remove(struct v4l2_m2m_ctx *m2m_ctx, | 194 | void *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 | */ |
186 | static inline void *v4l2_m2m_src_buf_remove(struct v4l2_m2m_ctx *m2m_ctx) | 200 | static 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 | */ |
195 | static inline void *v4l2_m2m_dst_buf_remove(struct v4l2_m2m_ctx *m2m_ctx) | 209 | static 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 */ |