blob: b66585e304e26a0101658399dde52dc4d59200a9 [file] [log] [blame]
Junghak Sungc1399902015-09-22 10:30:29 -03001/*
2 * videobuf2-v4l2.h - V4L2 driver helper framework
3 *
4 * Copyright (C) 2010 Samsung Electronics
5 *
6 * Author: Pawel Osciak <pawel@osciak.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation.
11 */
12#ifndef _MEDIA_VIDEOBUF2_V4L2_H
13#define _MEDIA_VIDEOBUF2_V4L2_H
14
Junghak Sung2d700712015-09-22 10:30:30 -030015#include <linux/videodev2.h>
Junghak Sungc1399902015-09-22 10:30:29 -030016#include <media/videobuf2-core.h>
17
Junghak Sungbed04f92015-10-06 06:37:47 -030018#if VB2_MAX_FRAME != VIDEO_MAX_FRAME
19#error VB2_MAX_FRAME != VIDEO_MAX_FRAME
20#endif
21
22#if VB2_MAX_PLANES != VIDEO_MAX_PLANES
23#error VB2_MAX_PLANES != VIDEO_MAX_PLANES
24#endif
25
Hans Verkuilf729ef52020-07-13 13:30:42 +020026struct video_device;
27
Junghak Sung2d700712015-09-22 10:30:30 -030028/**
Mauro Carvalho Chehab9fbe71b2017-10-09 05:36:52 -040029 * struct vb2_v4l2_buffer - video buffer information for v4l2.
Mauro Carvalho Chehabbf4404b2016-09-08 18:01:44 -030030 *
Mauro Carvalho Chehab9fbe71b2017-10-09 05:36:52 -040031 * @vb2_buf: embedded struct &vb2_buffer.
32 * @flags: buffer informational flags.
33 * @field: field order of the image in the buffer, as defined by
34 * &enum v4l2_field.
35 * @timecode: frame timecode.
36 * @sequence: sequence count of this frame.
Hans Verkuil394dc582018-05-30 02:46:22 -040037 * @request_fd: the request_fd associated with this buffer
Hans Verkuil137272c2019-10-11 06:32:40 -030038 * @is_held: if true, then this capture buffer was held
Hans Verkuildb6e8d52018-05-21 04:54:45 -040039 * @planes: plane information (userptr/fd, length, bytesused, data_offset).
Mauro Carvalho Chehabbf4404b2016-09-08 18:01:44 -030040 *
Junghak Sung2d700712015-09-22 10:30:30 -030041 * Should contain enough information to be able to cover all the fields
Mauro Carvalho Chehab9fbe71b2017-10-09 05:36:52 -040042 * of &struct v4l2_buffer at ``videodev2.h``.
Junghak Sung2d700712015-09-22 10:30:30 -030043 */
44struct vb2_v4l2_buffer {
45 struct vb2_buffer vb2_buf;
46
47 __u32 flags;
48 __u32 field;
Junghak Sung2d700712015-09-22 10:30:30 -030049 struct v4l2_timecode timecode;
50 __u32 sequence;
Hans Verkuil394dc582018-05-30 02:46:22 -040051 __s32 request_fd;
Hans Verkuil137272c2019-10-11 06:32:40 -030052 bool is_held;
Hans Verkuildb6e8d52018-05-21 04:54:45 -040053 struct vb2_plane planes[VB2_MAX_PLANES];
Junghak Sung2d700712015-09-22 10:30:30 -030054};
55
Hans Verkuil137272c2019-10-11 06:32:40 -030056/* VB2 V4L2 flags as set in vb2_queue.subsystem_flags */
57#define VB2_V4L2_FL_SUPPORTS_M2M_HOLD_CAPTURE_BUF (1 << 0)
58
Mauro Carvalho Chehabd383b572015-10-01 14:23:35 -030059/*
Junghak Sung2d700712015-09-22 10:30:30 -030060 * to_vb2_v4l2_buffer() - cast struct vb2_buffer * to struct vb2_v4l2_buffer *
61 */
62#define to_vb2_v4l2_buffer(vb) \
Mauro Carvalho Chehabd383b572015-10-01 14:23:35 -030063 container_of(vb, struct vb2_v4l2_buffer, vb2_buf)
Junghak Sung2d700712015-09-22 10:30:30 -030064
Hans Verkuil245ede42018-10-24 06:51:01 -040065/**
66 * vb2_find_timestamp() - Find buffer with given timestamp in the queue
67 *
68 * @q: pointer to &struct vb2_queue with videobuf2 queue.
Hans Verkuil03535e72019-01-24 06:47:49 -020069 * @timestamp: the timestamp to find.
Hans Verkuil245ede42018-10-24 06:51:01 -040070 * @start_idx: the start index (usually 0) in the buffer array to start
71 * searching from. Note that there may be multiple buffers
72 * with the same timestamp value, so you can restart the search
73 * by setting @start_idx to the previously found index + 1.
74 *
75 * Returns the buffer index of the buffer with the given @timestamp, or
76 * -1 if no buffer with @timestamp was found.
77 */
78int vb2_find_timestamp(const struct vb2_queue *q, u64 timestamp,
79 unsigned int start_idx);
80
Junghak Sung3c5be982015-10-06 06:37:49 -030081int vb2_querybuf(struct vb2_queue *q, struct v4l2_buffer *b);
Mauro Carvalho Chehab24ade5b2016-09-08 14:22:00 -030082
83/**
84 * vb2_reqbufs() - Wrapper for vb2_core_reqbufs() that also verifies
85 * the memory and type values.
Mauro Carvalho Chehabbf4404b2016-09-08 18:01:44 -030086 *
Mauro Carvalho Chehab9fbe71b2017-10-09 05:36:52 -040087 * @q: pointer to &struct vb2_queue with videobuf2 queue.
88 * @req: &struct v4l2_requestbuffers passed from userspace to
89 * &v4l2_ioctl_ops->vidioc_reqbufs handler in driver.
Mauro Carvalho Chehab24ade5b2016-09-08 14:22:00 -030090 */
Junghak Sung3c5be982015-10-06 06:37:49 -030091int vb2_reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req);
92
Mauro Carvalho Chehab24ade5b2016-09-08 14:22:00 -030093/**
94 * vb2_create_bufs() - Wrapper for vb2_core_create_bufs() that also verifies
95 * the memory and type values.
Mauro Carvalho Chehabbf4404b2016-09-08 18:01:44 -030096 *
Mauro Carvalho Chehab9fbe71b2017-10-09 05:36:52 -040097 * @q: pointer to &struct vb2_queue with videobuf2 queue.
98 * @create: creation parameters, passed from userspace to
99 * &v4l2_ioctl_ops->vidioc_create_bufs handler in driver
Mauro Carvalho Chehab24ade5b2016-09-08 14:22:00 -0300100 */
Junghak Sung3c5be982015-10-06 06:37:49 -0300101int vb2_create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create);
Mauro Carvalho Chehab24ade5b2016-09-08 14:22:00 -0300102
103/**
104 * vb2_prepare_buf() - Pass ownership of a buffer from userspace to the kernel
Mauro Carvalho Chehabbf4404b2016-09-08 18:01:44 -0300105 *
Mauro Carvalho Chehab9fbe71b2017-10-09 05:36:52 -0400106 * @q: pointer to &struct vb2_queue with videobuf2 queue.
Hans Verkuil394dc582018-05-30 02:46:22 -0400107 * @mdev: pointer to &struct media_device, may be NULL.
Mauro Carvalho Chehab9fbe71b2017-10-09 05:36:52 -0400108 * @b: buffer structure passed from userspace to
109 * &v4l2_ioctl_ops->vidioc_prepare_buf handler in driver
Mauro Carvalho Chehab24ade5b2016-09-08 14:22:00 -0300110 *
Mauro Carvalho Chehab9fbe71b2017-10-09 05:36:52 -0400111 * Should be called from &v4l2_ioctl_ops->vidioc_prepare_buf ioctl handler
112 * of a driver.
113 *
Mauro Carvalho Chehab24ade5b2016-09-08 14:22:00 -0300114 * This function:
Mauro Carvalho Chehabbf4404b2016-09-08 18:01:44 -0300115 *
116 * #) verifies the passed buffer,
Mauro Carvalho Chehab9fbe71b2017-10-09 05:36:52 -0400117 * #) calls &vb2_ops->buf_prepare callback in the driver (if provided),
118 * in which driver-specific buffer initialization can be performed.
Hans Verkuil394dc582018-05-30 02:46:22 -0400119 * #) if @b->request_fd is non-zero and @mdev->ops->req_queue is set,
120 * then bind the prepared buffer to the request.
Mauro Carvalho Chehab24ade5b2016-09-08 14:22:00 -0300121 *
122 * The return values from this function are intended to be directly returned
Mauro Carvalho Chehab9fbe71b2017-10-09 05:36:52 -0400123 * from &v4l2_ioctl_ops->vidioc_prepare_buf handler in driver.
Mauro Carvalho Chehab24ade5b2016-09-08 14:22:00 -0300124 */
Hans Verkuil394dc582018-05-30 02:46:22 -0400125int vb2_prepare_buf(struct vb2_queue *q, struct media_device *mdev,
126 struct v4l2_buffer *b);
Junghak Sung3c5be982015-10-06 06:37:49 -0300127
Mauro Carvalho Chehab24ade5b2016-09-08 14:22:00 -0300128/**
129 * vb2_qbuf() - Queue a buffer from userspace
Mauro Carvalho Chehab9fbe71b2017-10-09 05:36:52 -0400130 * @q: pointer to &struct vb2_queue with videobuf2 queue.
Hans Verkuil394dc582018-05-30 02:46:22 -0400131 * @mdev: pointer to &struct media_device, may be NULL.
Mauro Carvalho Chehab9fbe71b2017-10-09 05:36:52 -0400132 * @b: buffer structure passed from userspace to
133 * &v4l2_ioctl_ops->vidioc_qbuf handler in driver
Mauro Carvalho Chehab24ade5b2016-09-08 14:22:00 -0300134 *
Mauro Carvalho Chehab9fbe71b2017-10-09 05:36:52 -0400135 * Should be called from &v4l2_ioctl_ops->vidioc_qbuf handler of a driver.
Mauro Carvalho Chehabbf4404b2016-09-08 18:01:44 -0300136 *
Mauro Carvalho Chehab24ade5b2016-09-08 14:22:00 -0300137 * This function:
Mauro Carvalho Chehabbf4404b2016-09-08 18:01:44 -0300138 *
Mauro Carvalho Chehab9fbe71b2017-10-09 05:36:52 -0400139 * #) verifies the passed buffer;
Hans Verkuil394dc582018-05-30 02:46:22 -0400140 * #) if @b->request_fd is non-zero and @mdev->ops->req_queue is set,
141 * then bind the buffer to the request.
Mauro Carvalho Chehab9fbe71b2017-10-09 05:36:52 -0400142 * #) if necessary, calls &vb2_ops->buf_prepare callback in the driver
143 * (if provided), in which driver-specific buffer initialization can
144 * be performed;
145 * #) if streaming is on, queues the buffer in driver by the means of
146 * &vb2_ops->buf_queue callback for processing.
Mauro Carvalho Chehab24ade5b2016-09-08 14:22:00 -0300147 *
148 * The return values from this function are intended to be directly returned
Mauro Carvalho Chehab9fbe71b2017-10-09 05:36:52 -0400149 * from &v4l2_ioctl_ops->vidioc_qbuf handler in driver.
Mauro Carvalho Chehab24ade5b2016-09-08 14:22:00 -0300150 */
Hans Verkuil394dc582018-05-30 02:46:22 -0400151int vb2_qbuf(struct vb2_queue *q, struct media_device *mdev,
152 struct v4l2_buffer *b);
Mauro Carvalho Chehab24ade5b2016-09-08 14:22:00 -0300153
154/**
155 * vb2_expbuf() - Export a buffer as a file descriptor
Mauro Carvalho Chehab9fbe71b2017-10-09 05:36:52 -0400156 * @q: pointer to &struct vb2_queue with videobuf2 queue.
157 * @eb: export buffer structure passed from userspace to
158 * &v4l2_ioctl_ops->vidioc_expbuf handler in driver
Mauro Carvalho Chehab24ade5b2016-09-08 14:22:00 -0300159 *
160 * The return values from this function are intended to be directly returned
Mauro Carvalho Chehab9fbe71b2017-10-09 05:36:52 -0400161 * from &v4l2_ioctl_ops->vidioc_expbuf handler in driver.
Mauro Carvalho Chehab24ade5b2016-09-08 14:22:00 -0300162 */
Junghak Sung3c5be982015-10-06 06:37:49 -0300163int vb2_expbuf(struct vb2_queue *q, struct v4l2_exportbuffer *eb);
Mauro Carvalho Chehab24ade5b2016-09-08 14:22:00 -0300164
165/**
166 * vb2_dqbuf() - Dequeue a buffer to the userspace
Mauro Carvalho Chehab9fbe71b2017-10-09 05:36:52 -0400167 * @q: pointer to &struct vb2_queue with videobuf2 queue.
168 * @b: buffer structure passed from userspace to
169 * &v4l2_ioctl_ops->vidioc_dqbuf handler in driver
Mauro Carvalho Chehab24ade5b2016-09-08 14:22:00 -0300170 * @nonblocking: if true, this call will not sleep waiting for a buffer if no
171 * buffers ready for dequeuing are present. Normally the driver
Mauro Carvalho Chehab9fbe71b2017-10-09 05:36:52 -0400172 * would be passing (&file->f_flags & %O_NONBLOCK) here
Mauro Carvalho Chehab24ade5b2016-09-08 14:22:00 -0300173 *
Mauro Carvalho Chehab9fbe71b2017-10-09 05:36:52 -0400174 * Should be called from &v4l2_ioctl_ops->vidioc_dqbuf ioctl handler
175 * of a driver.
Mauro Carvalho Chehabbf4404b2016-09-08 18:01:44 -0300176 *
Mauro Carvalho Chehab24ade5b2016-09-08 14:22:00 -0300177 * This function:
Mauro Carvalho Chehabbf4404b2016-09-08 18:01:44 -0300178 *
Mauro Carvalho Chehab9fbe71b2017-10-09 05:36:52 -0400179 * #) verifies the passed buffer;
180 * #) calls &vb2_ops->buf_finish callback in the driver (if provided), in which
Mauro Carvalho Chehab24ade5b2016-09-08 14:22:00 -0300181 * driver can perform any additional operations that may be required before
Mauro Carvalho Chehab9fbe71b2017-10-09 05:36:52 -0400182 * returning the buffer to userspace, such as cache sync;
Mauro Carvalho Chehabbf4404b2016-09-08 18:01:44 -0300183 * #) the buffer struct members are filled with relevant information for
Mauro Carvalho Chehab24ade5b2016-09-08 14:22:00 -0300184 * the userspace.
185 *
186 * The return values from this function are intended to be directly returned
Mauro Carvalho Chehab9fbe71b2017-10-09 05:36:52 -0400187 * from &v4l2_ioctl_ops->vidioc_dqbuf handler in driver.
Mauro Carvalho Chehab24ade5b2016-09-08 14:22:00 -0300188 */
Junghak Sung3c5be982015-10-06 06:37:49 -0300189int vb2_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool nonblocking);
190
Mauro Carvalho Chehab24ade5b2016-09-08 14:22:00 -0300191/**
192 * vb2_streamon - start streaming
Mauro Carvalho Chehab9fbe71b2017-10-09 05:36:52 -0400193 * @q: pointer to &struct vb2_queue with videobuf2 queue.
194 * @type: type argument passed from userspace to vidioc_streamon handler,
195 * as defined by &enum v4l2_buf_type.
Mauro Carvalho Chehab24ade5b2016-09-08 14:22:00 -0300196 *
Mauro Carvalho Chehab9fbe71b2017-10-09 05:36:52 -0400197 * Should be called from &v4l2_ioctl_ops->vidioc_streamon handler of a driver.
Mauro Carvalho Chehabbf4404b2016-09-08 18:01:44 -0300198 *
Mauro Carvalho Chehab24ade5b2016-09-08 14:22:00 -0300199 * This function:
Mauro Carvalho Chehabbf4404b2016-09-08 18:01:44 -0300200 *
Mauro Carvalho Chehab24ade5b2016-09-08 14:22:00 -0300201 * 1) verifies current state
202 * 2) passes any previously queued buffers to the driver and starts streaming
203 *
204 * The return values from this function are intended to be directly returned
Mauro Carvalho Chehab9fbe71b2017-10-09 05:36:52 -0400205 * from &v4l2_ioctl_ops->vidioc_streamon handler in the driver.
Mauro Carvalho Chehab24ade5b2016-09-08 14:22:00 -0300206 */
Junghak Sung3c5be982015-10-06 06:37:49 -0300207int vb2_streamon(struct vb2_queue *q, enum v4l2_buf_type type);
Mauro Carvalho Chehab24ade5b2016-09-08 14:22:00 -0300208
209/**
210 * vb2_streamoff - stop streaming
Mauro Carvalho Chehab9fbe71b2017-10-09 05:36:52 -0400211 * @q: pointer to &struct vb2_queue with videobuf2 queue.
Mauro Carvalho Chehab24ade5b2016-09-08 14:22:00 -0300212 * @type: type argument passed from userspace to vidioc_streamoff handler
213 *
214 * Should be called from vidioc_streamoff handler of a driver.
Mauro Carvalho Chehabbf4404b2016-09-08 18:01:44 -0300215 *
Mauro Carvalho Chehab24ade5b2016-09-08 14:22:00 -0300216 * This function:
Mauro Carvalho Chehabbf4404b2016-09-08 18:01:44 -0300217 *
218 * #) verifies current state,
219 * #) stop streaming and dequeues any queued buffers, including those previously
Mauro Carvalho Chehab24ade5b2016-09-08 14:22:00 -0300220 * passed to the driver (after waiting for the driver to finish).
221 *
222 * This call can be used for pausing playback.
223 * The return values from this function are intended to be directly returned
224 * from vidioc_streamoff handler in the driver
225 */
Junghak Sung3c5be982015-10-06 06:37:49 -0300226int vb2_streamoff(struct vb2_queue *q, enum v4l2_buf_type type);
227
Mauro Carvalho Chehab24ade5b2016-09-08 14:22:00 -0300228/**
229 * vb2_queue_init() - initialize a videobuf2 queue
Mauro Carvalho Chehab9fbe71b2017-10-09 05:36:52 -0400230 * @q: pointer to &struct vb2_queue with videobuf2 queue.
Mauro Carvalho Chehab24ade5b2016-09-08 14:22:00 -0300231 *
232 * The vb2_queue structure should be allocated by the driver. The driver is
233 * responsible of clearing it's content and setting initial values for some
234 * required entries before calling this function.
235 * q->ops, q->mem_ops, q->type and q->io_modes are mandatory. Please refer
236 * to the struct vb2_queue description in include/media/videobuf2-core.h
237 * for more information.
238 */
Junghak Sung3c5be982015-10-06 06:37:49 -0300239int __must_check vb2_queue_init(struct vb2_queue *q);
Mauro Carvalho Chehab24ade5b2016-09-08 14:22:00 -0300240
241/**
Laurent Pinchartb8209352020-06-21 02:23:43 +0200242 * vb2_queue_init_name() - initialize a videobuf2 queue with a name
243 * @q: pointer to &struct vb2_queue with videobuf2 queue.
244 * @name: the queue name
245 *
246 * This function initializes the vb2_queue exactly like vb2_queue_init(),
247 * and additionally sets the queue name. The queue name is used for logging
248 * purpose, and should uniquely identify the queue within the context of the
249 * device it belongs to. This is useful to attribute kernel log messages to the
250 * right queue for m2m devices or other devices that handle multiple queues.
251 */
252int __must_check vb2_queue_init_name(struct vb2_queue *q, const char *name);
253
254/**
Mauro Carvalho Chehab24ade5b2016-09-08 14:22:00 -0300255 * vb2_queue_release() - stop streaming, release the queue and free memory
Mauro Carvalho Chehab9fbe71b2017-10-09 05:36:52 -0400256 * @q: pointer to &struct vb2_queue with videobuf2 queue.
Mauro Carvalho Chehab24ade5b2016-09-08 14:22:00 -0300257 *
258 * This function stops streaming and performs necessary clean ups, including
259 * freeing video buffer memory. The driver is responsible for freeing
260 * the vb2_queue structure itself.
261 */
Junghak Sung3c5be982015-10-06 06:37:49 -0300262void vb2_queue_release(struct vb2_queue *q);
Mauro Carvalho Chehab24ade5b2016-09-08 14:22:00 -0300263
264/**
Tomi Valkeinena810ed02021-04-12 13:02:09 +0200265 * vb2_queue_change_type() - change the type of an inactive vb2_queue
266 * @q: pointer to &struct vb2_queue with videobuf2 queue.
267 * @type: the type to change to (V4L2_BUF_TYPE_VIDEO_*)
268 *
269 * This function changes the type of the vb2_queue. This is only possible
270 * if the queue is not busy (i.e. no buffers have been allocated).
271 *
272 * vb2_queue_change_type() can be used to support multiple buffer types using
273 * the same queue. The driver can implement v4l2_ioctl_ops.vidioc_reqbufs and
274 * v4l2_ioctl_ops.vidioc_create_bufs functions and call vb2_queue_change_type()
275 * before calling vb2_ioctl_reqbufs() or vb2_ioctl_create_bufs(), and thus
276 * "lock" the buffer type until the buffers have been released.
277 */
278int vb2_queue_change_type(struct vb2_queue *q, unsigned int type);
279
280/**
Mauro Carvalho Chehab24ade5b2016-09-08 14:22:00 -0300281 * vb2_poll() - implements poll userspace operation
Mauro Carvalho Chehab9fbe71b2017-10-09 05:36:52 -0400282 * @q: pointer to &struct vb2_queue with videobuf2 queue.
Mauro Carvalho Chehab24ade5b2016-09-08 14:22:00 -0300283 * @file: file argument passed to the poll file operation handler
284 * @wait: wait argument passed to the poll file operation handler
285 *
286 * This function implements poll file operation handler for a driver.
287 * For CAPTURE queues, if a buffer is ready to be dequeued, the userspace will
288 * be informed that the file descriptor of a video device is available for
289 * reading.
290 * For OUTPUT queues, if a buffer is ready to be dequeued, the file descriptor
291 * will be reported as available for writing.
292 *
293 * If the driver uses struct v4l2_fh, then vb2_poll() will also check for any
294 * pending events.
295 *
296 * The return values from this function are intended to be directly returned
297 * from poll handler in driver.
298 */
Al Viroc23e0cb2017-07-03 03:02:56 -0400299__poll_t vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait);
Junghak Sung3c5be982015-10-06 06:37:49 -0300300
301/*
302 * The following functions are not part of the vb2 core API, but are simple
303 * helper functions that you can use in your struct v4l2_file_operations,
304 * struct v4l2_ioctl_ops and struct vb2_ops. They will serialize if vb2_queue->lock
305 * or video_device->lock is set, and they will set and test vb2_queue->owner
306 * to check if the calling filehandle is permitted to do the queuing operation.
307 */
308
309/* struct v4l2_ioctl_ops helpers */
310
311int vb2_ioctl_reqbufs(struct file *file, void *priv,
312 struct v4l2_requestbuffers *p);
313int vb2_ioctl_create_bufs(struct file *file, void *priv,
314 struct v4l2_create_buffers *p);
315int vb2_ioctl_prepare_buf(struct file *file, void *priv,
316 struct v4l2_buffer *p);
317int vb2_ioctl_querybuf(struct file *file, void *priv, struct v4l2_buffer *p);
318int vb2_ioctl_qbuf(struct file *file, void *priv, struct v4l2_buffer *p);
319int vb2_ioctl_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p);
320int vb2_ioctl_streamon(struct file *file, void *priv, enum v4l2_buf_type i);
321int vb2_ioctl_streamoff(struct file *file, void *priv, enum v4l2_buf_type i);
322int vb2_ioctl_expbuf(struct file *file, void *priv,
323 struct v4l2_exportbuffer *p);
324
325/* struct v4l2_file_operations helpers */
326
327int vb2_fop_mmap(struct file *file, struct vm_area_struct *vma);
328int vb2_fop_release(struct file *file);
329int _vb2_fop_release(struct file *file, struct mutex *lock);
330ssize_t vb2_fop_write(struct file *file, const char __user *buf,
331 size_t count, loff_t *ppos);
332ssize_t vb2_fop_read(struct file *file, char __user *buf,
333 size_t count, loff_t *ppos);
Al Viroc23e0cb2017-07-03 03:02:56 -0400334__poll_t vb2_fop_poll(struct file *file, poll_table *wait);
Junghak Sung3c5be982015-10-06 06:37:49 -0300335#ifndef CONFIG_MMU
336unsigned long vb2_fop_get_unmapped_area(struct file *file, unsigned long addr,
337 unsigned long len, unsigned long pgoff, unsigned long flags);
338#endif
339
Mauro Carvalho Chehabdba2d122016-09-08 18:12:18 -0300340/**
Hans Verkuilf729ef52020-07-13 13:30:42 +0200341 * vb2_video_unregister_device - unregister the video device and release queue
342 *
343 * @vdev: pointer to &struct video_device
344 *
345 * If the driver uses vb2_fop_release()/_vb2_fop_release(), then it should use
346 * vb2_video_unregister_device() instead of video_unregister_device().
347 *
348 * This function will call video_unregister_device() and then release the
349 * vb2_queue if streaming is in progress. This will stop streaming and
350 * this will simplify the unbind sequence since after this call all subdevs
351 * will have stopped streaming as well.
352 */
353void vb2_video_unregister_device(struct video_device *vdev);
354
355/**
Mauro Carvalho Chehabdba2d122016-09-08 18:12:18 -0300356 * vb2_ops_wait_prepare - helper function to lock a struct &vb2_queue
357 *
Mauro Carvalho Chehab9fbe71b2017-10-09 05:36:52 -0400358 * @vq: pointer to &struct vb2_queue
Mauro Carvalho Chehabdba2d122016-09-08 18:12:18 -0300359 *
360 * ..note:: only use if vq->lock is non-NULL.
361 */
Junghak Sung3c5be982015-10-06 06:37:49 -0300362void vb2_ops_wait_prepare(struct vb2_queue *vq);
Mauro Carvalho Chehabdba2d122016-09-08 18:12:18 -0300363
364/**
365 * vb2_ops_wait_finish - helper function to unlock a struct &vb2_queue
366 *
Mauro Carvalho Chehab9fbe71b2017-10-09 05:36:52 -0400367 * @vq: pointer to &struct vb2_queue
Mauro Carvalho Chehabdba2d122016-09-08 18:12:18 -0300368 *
369 * ..note:: only use if vq->lock is non-NULL.
370 */
Junghak Sung3c5be982015-10-06 06:37:49 -0300371void vb2_ops_wait_finish(struct vb2_queue *vq);
372
Hans Verkuil86f6bd32018-05-21 04:54:52 -0400373struct media_request;
374int vb2_request_validate(struct media_request *req);
375void vb2_request_queue(struct media_request *req);
376
Junghak Sungc1399902015-09-22 10:30:29 -0300377#endif /* _MEDIA_VIDEOBUF2_V4L2_H */