xref: /OK3568_Linux_fs/kernel/include/media/videobuf2-v4l2.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * videobuf2-v4l2.h - V4L2 driver helper framework
3*4882a593Smuzhiyun  *
4*4882a593Smuzhiyun  * Copyright (C) 2010 Samsung Electronics
5*4882a593Smuzhiyun  *
6*4882a593Smuzhiyun  * Author: Pawel Osciak <pawel@osciak.com>
7*4882a593Smuzhiyun  *
8*4882a593Smuzhiyun  * This program is free software; you can redistribute it and/or modify
9*4882a593Smuzhiyun  * it under the terms of the GNU General Public License as published by
10*4882a593Smuzhiyun  * the Free Software Foundation.
11*4882a593Smuzhiyun  */
12*4882a593Smuzhiyun #ifndef _MEDIA_VIDEOBUF2_V4L2_H
13*4882a593Smuzhiyun #define _MEDIA_VIDEOBUF2_V4L2_H
14*4882a593Smuzhiyun 
15*4882a593Smuzhiyun #include <linux/videodev2.h>
16*4882a593Smuzhiyun #include <linux/android_kabi.h>
17*4882a593Smuzhiyun #include <media/videobuf2-core.h>
18*4882a593Smuzhiyun 
19*4882a593Smuzhiyun #if VB2_MAX_FRAME != VIDEO_MAX_FRAME
20*4882a593Smuzhiyun #error VB2_MAX_FRAME != VIDEO_MAX_FRAME
21*4882a593Smuzhiyun #endif
22*4882a593Smuzhiyun 
23*4882a593Smuzhiyun #if VB2_MAX_PLANES != VIDEO_MAX_PLANES
24*4882a593Smuzhiyun #error VB2_MAX_PLANES != VIDEO_MAX_PLANES
25*4882a593Smuzhiyun #endif
26*4882a593Smuzhiyun 
27*4882a593Smuzhiyun struct video_device;
28*4882a593Smuzhiyun 
29*4882a593Smuzhiyun /**
30*4882a593Smuzhiyun  * struct vb2_v4l2_buffer - video buffer information for v4l2.
31*4882a593Smuzhiyun  *
32*4882a593Smuzhiyun  * @vb2_buf:	embedded struct &vb2_buffer.
33*4882a593Smuzhiyun  * @flags:	buffer informational flags.
34*4882a593Smuzhiyun  * @field:	field order of the image in the buffer, as defined by
35*4882a593Smuzhiyun  *		&enum v4l2_field.
36*4882a593Smuzhiyun  * @timecode:	frame timecode.
37*4882a593Smuzhiyun  * @sequence:	sequence count of this frame.
38*4882a593Smuzhiyun  * @request_fd:	the request_fd associated with this buffer
39*4882a593Smuzhiyun  * @is_held:	if true, then this capture buffer was held
40*4882a593Smuzhiyun  * @planes:	plane information (userptr/fd, length, bytesused, data_offset).
41*4882a593Smuzhiyun  *
42*4882a593Smuzhiyun  * Should contain enough information to be able to cover all the fields
43*4882a593Smuzhiyun  * of &struct v4l2_buffer at ``videodev2.h``.
44*4882a593Smuzhiyun  */
45*4882a593Smuzhiyun struct vb2_v4l2_buffer {
46*4882a593Smuzhiyun 	struct vb2_buffer	vb2_buf;
47*4882a593Smuzhiyun 
48*4882a593Smuzhiyun 	__u32			flags;
49*4882a593Smuzhiyun 	__u32			field;
50*4882a593Smuzhiyun 	struct v4l2_timecode	timecode;
51*4882a593Smuzhiyun 	__u32			sequence;
52*4882a593Smuzhiyun 	__s32			request_fd;
53*4882a593Smuzhiyun 	bool			is_held;
54*4882a593Smuzhiyun 	struct vb2_plane	planes[VB2_MAX_PLANES];
55*4882a593Smuzhiyun 
56*4882a593Smuzhiyun 	ANDROID_KABI_RESERVE(1);
57*4882a593Smuzhiyun };
58*4882a593Smuzhiyun 
59*4882a593Smuzhiyun /* VB2 V4L2 flags as set in vb2_queue.subsystem_flags */
60*4882a593Smuzhiyun #define VB2_V4L2_FL_SUPPORTS_M2M_HOLD_CAPTURE_BUF (1 << 0)
61*4882a593Smuzhiyun 
62*4882a593Smuzhiyun /*
63*4882a593Smuzhiyun  * to_vb2_v4l2_buffer() - cast struct vb2_buffer * to struct vb2_v4l2_buffer *
64*4882a593Smuzhiyun  */
65*4882a593Smuzhiyun #define to_vb2_v4l2_buffer(vb) \
66*4882a593Smuzhiyun 	container_of(vb, struct vb2_v4l2_buffer, vb2_buf)
67*4882a593Smuzhiyun 
68*4882a593Smuzhiyun /**
69*4882a593Smuzhiyun  * vb2_find_timestamp() - Find buffer with given timestamp in the queue
70*4882a593Smuzhiyun  *
71*4882a593Smuzhiyun  * @q:		pointer to &struct vb2_queue with videobuf2 queue.
72*4882a593Smuzhiyun  * @timestamp:	the timestamp to find.
73*4882a593Smuzhiyun  * @start_idx:	the start index (usually 0) in the buffer array to start
74*4882a593Smuzhiyun  *		searching from. Note that there may be multiple buffers
75*4882a593Smuzhiyun  *		with the same timestamp value, so you can restart the search
76*4882a593Smuzhiyun  *		by setting @start_idx to the previously found index + 1.
77*4882a593Smuzhiyun  *
78*4882a593Smuzhiyun  * Returns the buffer index of the buffer with the given @timestamp, or
79*4882a593Smuzhiyun  * -1 if no buffer with @timestamp was found.
80*4882a593Smuzhiyun  */
81*4882a593Smuzhiyun int vb2_find_timestamp(const struct vb2_queue *q, u64 timestamp,
82*4882a593Smuzhiyun 		       unsigned int start_idx);
83*4882a593Smuzhiyun 
84*4882a593Smuzhiyun int vb2_querybuf(struct vb2_queue *q, struct v4l2_buffer *b);
85*4882a593Smuzhiyun 
86*4882a593Smuzhiyun /**
87*4882a593Smuzhiyun  * vb2_reqbufs() - Wrapper for vb2_core_reqbufs() that also verifies
88*4882a593Smuzhiyun  * the memory and type values.
89*4882a593Smuzhiyun  *
90*4882a593Smuzhiyun  * @q:		pointer to &struct vb2_queue with videobuf2 queue.
91*4882a593Smuzhiyun  * @req:	&struct v4l2_requestbuffers passed from userspace to
92*4882a593Smuzhiyun  *		&v4l2_ioctl_ops->vidioc_reqbufs handler in driver.
93*4882a593Smuzhiyun  */
94*4882a593Smuzhiyun int vb2_reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req);
95*4882a593Smuzhiyun 
96*4882a593Smuzhiyun /**
97*4882a593Smuzhiyun  * vb2_create_bufs() - Wrapper for vb2_core_create_bufs() that also verifies
98*4882a593Smuzhiyun  * the memory and type values.
99*4882a593Smuzhiyun  *
100*4882a593Smuzhiyun  * @q:		pointer to &struct vb2_queue with videobuf2 queue.
101*4882a593Smuzhiyun  * @create:	creation parameters, passed from userspace to
102*4882a593Smuzhiyun  *		&v4l2_ioctl_ops->vidioc_create_bufs handler in driver
103*4882a593Smuzhiyun  */
104*4882a593Smuzhiyun int vb2_create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create);
105*4882a593Smuzhiyun 
106*4882a593Smuzhiyun /**
107*4882a593Smuzhiyun  * vb2_prepare_buf() - Pass ownership of a buffer from userspace to the kernel
108*4882a593Smuzhiyun  *
109*4882a593Smuzhiyun  * @q:		pointer to &struct vb2_queue with videobuf2 queue.
110*4882a593Smuzhiyun  * @mdev:	pointer to &struct media_device, may be NULL.
111*4882a593Smuzhiyun  * @b:		buffer structure passed from userspace to
112*4882a593Smuzhiyun  *		&v4l2_ioctl_ops->vidioc_prepare_buf handler in driver
113*4882a593Smuzhiyun  *
114*4882a593Smuzhiyun  * Should be called from &v4l2_ioctl_ops->vidioc_prepare_buf ioctl handler
115*4882a593Smuzhiyun  * of a driver.
116*4882a593Smuzhiyun  *
117*4882a593Smuzhiyun  * This function:
118*4882a593Smuzhiyun  *
119*4882a593Smuzhiyun  * #) verifies the passed buffer,
120*4882a593Smuzhiyun  * #) calls &vb2_ops->buf_prepare callback in the driver (if provided),
121*4882a593Smuzhiyun  *    in which driver-specific buffer initialization can be performed.
122*4882a593Smuzhiyun  * #) if @b->request_fd is non-zero and @mdev->ops->req_queue is set,
123*4882a593Smuzhiyun  *    then bind the prepared buffer to the request.
124*4882a593Smuzhiyun  *
125*4882a593Smuzhiyun  * The return values from this function are intended to be directly returned
126*4882a593Smuzhiyun  * from &v4l2_ioctl_ops->vidioc_prepare_buf handler in driver.
127*4882a593Smuzhiyun  */
128*4882a593Smuzhiyun int vb2_prepare_buf(struct vb2_queue *q, struct media_device *mdev,
129*4882a593Smuzhiyun 		    struct v4l2_buffer *b);
130*4882a593Smuzhiyun 
131*4882a593Smuzhiyun /**
132*4882a593Smuzhiyun  * vb2_qbuf() - Queue a buffer from userspace
133*4882a593Smuzhiyun  * @q:		pointer to &struct vb2_queue with videobuf2 queue.
134*4882a593Smuzhiyun  * @mdev:	pointer to &struct media_device, may be NULL.
135*4882a593Smuzhiyun  * @b:		buffer structure passed from userspace to
136*4882a593Smuzhiyun  *		&v4l2_ioctl_ops->vidioc_qbuf handler in driver
137*4882a593Smuzhiyun  *
138*4882a593Smuzhiyun  * Should be called from &v4l2_ioctl_ops->vidioc_qbuf handler of a driver.
139*4882a593Smuzhiyun  *
140*4882a593Smuzhiyun  * This function:
141*4882a593Smuzhiyun  *
142*4882a593Smuzhiyun  * #) verifies the passed buffer;
143*4882a593Smuzhiyun  * #) if @b->request_fd is non-zero and @mdev->ops->req_queue is set,
144*4882a593Smuzhiyun  *    then bind the buffer to the request.
145*4882a593Smuzhiyun  * #) if necessary, calls &vb2_ops->buf_prepare callback in the driver
146*4882a593Smuzhiyun  *    (if provided), in which driver-specific buffer initialization can
147*4882a593Smuzhiyun  *    be performed;
148*4882a593Smuzhiyun  * #) if streaming is on, queues the buffer in driver by the means of
149*4882a593Smuzhiyun  *    &vb2_ops->buf_queue callback for processing.
150*4882a593Smuzhiyun  *
151*4882a593Smuzhiyun  * The return values from this function are intended to be directly returned
152*4882a593Smuzhiyun  * from &v4l2_ioctl_ops->vidioc_qbuf handler in driver.
153*4882a593Smuzhiyun  */
154*4882a593Smuzhiyun int vb2_qbuf(struct vb2_queue *q, struct media_device *mdev,
155*4882a593Smuzhiyun 	     struct v4l2_buffer *b);
156*4882a593Smuzhiyun 
157*4882a593Smuzhiyun /**
158*4882a593Smuzhiyun  * vb2_expbuf() - Export a buffer as a file descriptor
159*4882a593Smuzhiyun  * @q:		pointer to &struct vb2_queue with videobuf2 queue.
160*4882a593Smuzhiyun  * @eb:		export buffer structure passed from userspace to
161*4882a593Smuzhiyun  *		&v4l2_ioctl_ops->vidioc_expbuf handler in driver
162*4882a593Smuzhiyun  *
163*4882a593Smuzhiyun  * The return values from this function are intended to be directly returned
164*4882a593Smuzhiyun  * from &v4l2_ioctl_ops->vidioc_expbuf handler in driver.
165*4882a593Smuzhiyun  */
166*4882a593Smuzhiyun int vb2_expbuf(struct vb2_queue *q, struct v4l2_exportbuffer *eb);
167*4882a593Smuzhiyun 
168*4882a593Smuzhiyun /**
169*4882a593Smuzhiyun  * vb2_dqbuf() - Dequeue a buffer to the userspace
170*4882a593Smuzhiyun  * @q:		pointer to &struct vb2_queue with videobuf2 queue.
171*4882a593Smuzhiyun  * @b:		buffer structure passed from userspace to
172*4882a593Smuzhiyun  *		&v4l2_ioctl_ops->vidioc_dqbuf handler in driver
173*4882a593Smuzhiyun  * @nonblocking: if true, this call will not sleep waiting for a buffer if no
174*4882a593Smuzhiyun  *		 buffers ready for dequeuing are present. Normally the driver
175*4882a593Smuzhiyun  *		 would be passing (&file->f_flags & %O_NONBLOCK) here
176*4882a593Smuzhiyun  *
177*4882a593Smuzhiyun  * Should be called from &v4l2_ioctl_ops->vidioc_dqbuf ioctl handler
178*4882a593Smuzhiyun  * of a driver.
179*4882a593Smuzhiyun  *
180*4882a593Smuzhiyun  * This function:
181*4882a593Smuzhiyun  *
182*4882a593Smuzhiyun  * #) verifies the passed buffer;
183*4882a593Smuzhiyun  * #) calls &vb2_ops->buf_finish callback in the driver (if provided), in which
184*4882a593Smuzhiyun  *    driver can perform any additional operations that may be required before
185*4882a593Smuzhiyun  *    returning the buffer to userspace, such as cache sync;
186*4882a593Smuzhiyun  * #) the buffer struct members are filled with relevant information for
187*4882a593Smuzhiyun  *    the userspace.
188*4882a593Smuzhiyun  *
189*4882a593Smuzhiyun  * The return values from this function are intended to be directly returned
190*4882a593Smuzhiyun  * from &v4l2_ioctl_ops->vidioc_dqbuf handler in driver.
191*4882a593Smuzhiyun  */
192*4882a593Smuzhiyun int vb2_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool nonblocking);
193*4882a593Smuzhiyun 
194*4882a593Smuzhiyun /**
195*4882a593Smuzhiyun  * vb2_streamon - start streaming
196*4882a593Smuzhiyun  * @q:		pointer to &struct vb2_queue with videobuf2 queue.
197*4882a593Smuzhiyun  * @type:	type argument passed from userspace to vidioc_streamon handler,
198*4882a593Smuzhiyun  *		as defined by &enum v4l2_buf_type.
199*4882a593Smuzhiyun  *
200*4882a593Smuzhiyun  * Should be called from &v4l2_ioctl_ops->vidioc_streamon handler of a driver.
201*4882a593Smuzhiyun  *
202*4882a593Smuzhiyun  * This function:
203*4882a593Smuzhiyun  *
204*4882a593Smuzhiyun  * 1) verifies current state
205*4882a593Smuzhiyun  * 2) passes any previously queued buffers to the driver and starts streaming
206*4882a593Smuzhiyun  *
207*4882a593Smuzhiyun  * The return values from this function are intended to be directly returned
208*4882a593Smuzhiyun  * from &v4l2_ioctl_ops->vidioc_streamon handler in the driver.
209*4882a593Smuzhiyun  */
210*4882a593Smuzhiyun int vb2_streamon(struct vb2_queue *q, enum v4l2_buf_type type);
211*4882a593Smuzhiyun 
212*4882a593Smuzhiyun /**
213*4882a593Smuzhiyun  * vb2_streamoff - stop streaming
214*4882a593Smuzhiyun  * @q:		pointer to &struct vb2_queue with videobuf2 queue.
215*4882a593Smuzhiyun  * @type:	type argument passed from userspace to vidioc_streamoff handler
216*4882a593Smuzhiyun  *
217*4882a593Smuzhiyun  * Should be called from vidioc_streamoff handler of a driver.
218*4882a593Smuzhiyun  *
219*4882a593Smuzhiyun  * This function:
220*4882a593Smuzhiyun  *
221*4882a593Smuzhiyun  * #) verifies current state,
222*4882a593Smuzhiyun  * #) stop streaming and dequeues any queued buffers, including those previously
223*4882a593Smuzhiyun  *    passed to the driver (after waiting for the driver to finish).
224*4882a593Smuzhiyun  *
225*4882a593Smuzhiyun  * This call can be used for pausing playback.
226*4882a593Smuzhiyun  * The return values from this function are intended to be directly returned
227*4882a593Smuzhiyun  * from vidioc_streamoff handler in the driver
228*4882a593Smuzhiyun  */
229*4882a593Smuzhiyun int vb2_streamoff(struct vb2_queue *q, enum v4l2_buf_type type);
230*4882a593Smuzhiyun 
231*4882a593Smuzhiyun /**
232*4882a593Smuzhiyun  * vb2_queue_init() - initialize a videobuf2 queue
233*4882a593Smuzhiyun  * @q:		pointer to &struct vb2_queue with videobuf2 queue.
234*4882a593Smuzhiyun  *
235*4882a593Smuzhiyun  * The vb2_queue structure should be allocated by the driver. The driver is
236*4882a593Smuzhiyun  * responsible of clearing it's content and setting initial values for some
237*4882a593Smuzhiyun  * required entries before calling this function.
238*4882a593Smuzhiyun  * q->ops, q->mem_ops, q->type and q->io_modes are mandatory. Please refer
239*4882a593Smuzhiyun  * to the struct vb2_queue description in include/media/videobuf2-core.h
240*4882a593Smuzhiyun  * for more information.
241*4882a593Smuzhiyun  */
242*4882a593Smuzhiyun int __must_check vb2_queue_init(struct vb2_queue *q);
243*4882a593Smuzhiyun 
244*4882a593Smuzhiyun /**
245*4882a593Smuzhiyun  * vb2_queue_init_name() - initialize a videobuf2 queue with a name
246*4882a593Smuzhiyun  * @q:		pointer to &struct vb2_queue with videobuf2 queue.
247*4882a593Smuzhiyun  * @name:	the queue name
248*4882a593Smuzhiyun  *
249*4882a593Smuzhiyun  * This function initializes the vb2_queue exactly like vb2_queue_init(),
250*4882a593Smuzhiyun  * and additionally sets the queue name. The queue name is used for logging
251*4882a593Smuzhiyun  * purpose, and should uniquely identify the queue within the context of the
252*4882a593Smuzhiyun  * device it belongs to. This is useful to attribute kernel log messages to the
253*4882a593Smuzhiyun  * right queue for m2m devices or other devices that handle multiple queues.
254*4882a593Smuzhiyun  */
255*4882a593Smuzhiyun int __must_check vb2_queue_init_name(struct vb2_queue *q, const char *name);
256*4882a593Smuzhiyun 
257*4882a593Smuzhiyun /**
258*4882a593Smuzhiyun  * vb2_queue_release() - stop streaming, release the queue and free memory
259*4882a593Smuzhiyun  * @q:		pointer to &struct vb2_queue with videobuf2 queue.
260*4882a593Smuzhiyun  *
261*4882a593Smuzhiyun  * This function stops streaming and performs necessary clean ups, including
262*4882a593Smuzhiyun  * freeing video buffer memory. The driver is responsible for freeing
263*4882a593Smuzhiyun  * the vb2_queue structure itself.
264*4882a593Smuzhiyun  */
265*4882a593Smuzhiyun void vb2_queue_release(struct vb2_queue *q);
266*4882a593Smuzhiyun 
267*4882a593Smuzhiyun /**
268*4882a593Smuzhiyun  * vb2_poll() - implements poll userspace operation
269*4882a593Smuzhiyun  * @q:		pointer to &struct vb2_queue with videobuf2 queue.
270*4882a593Smuzhiyun  * @file:	file argument passed to the poll file operation handler
271*4882a593Smuzhiyun  * @wait:	wait argument passed to the poll file operation handler
272*4882a593Smuzhiyun  *
273*4882a593Smuzhiyun  * This function implements poll file operation handler for a driver.
274*4882a593Smuzhiyun  * For CAPTURE queues, if a buffer is ready to be dequeued, the userspace will
275*4882a593Smuzhiyun  * be informed that the file descriptor of a video device is available for
276*4882a593Smuzhiyun  * reading.
277*4882a593Smuzhiyun  * For OUTPUT queues, if a buffer is ready to be dequeued, the file descriptor
278*4882a593Smuzhiyun  * will be reported as available for writing.
279*4882a593Smuzhiyun  *
280*4882a593Smuzhiyun  * If the driver uses struct v4l2_fh, then vb2_poll() will also check for any
281*4882a593Smuzhiyun  * pending events.
282*4882a593Smuzhiyun  *
283*4882a593Smuzhiyun  * The return values from this function are intended to be directly returned
284*4882a593Smuzhiyun  * from poll handler in driver.
285*4882a593Smuzhiyun  */
286*4882a593Smuzhiyun __poll_t vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait);
287*4882a593Smuzhiyun 
288*4882a593Smuzhiyun /*
289*4882a593Smuzhiyun  * The following functions are not part of the vb2 core API, but are simple
290*4882a593Smuzhiyun  * helper functions that you can use in your struct v4l2_file_operations,
291*4882a593Smuzhiyun  * struct v4l2_ioctl_ops and struct vb2_ops. They will serialize if vb2_queue->lock
292*4882a593Smuzhiyun  * or video_device->lock is set, and they will set and test vb2_queue->owner
293*4882a593Smuzhiyun  * to check if the calling filehandle is permitted to do the queuing operation.
294*4882a593Smuzhiyun  */
295*4882a593Smuzhiyun 
296*4882a593Smuzhiyun /* struct v4l2_ioctl_ops helpers */
297*4882a593Smuzhiyun 
298*4882a593Smuzhiyun int vb2_ioctl_reqbufs(struct file *file, void *priv,
299*4882a593Smuzhiyun 			  struct v4l2_requestbuffers *p);
300*4882a593Smuzhiyun int vb2_ioctl_create_bufs(struct file *file, void *priv,
301*4882a593Smuzhiyun 			  struct v4l2_create_buffers *p);
302*4882a593Smuzhiyun int vb2_ioctl_prepare_buf(struct file *file, void *priv,
303*4882a593Smuzhiyun 			  struct v4l2_buffer *p);
304*4882a593Smuzhiyun int vb2_ioctl_querybuf(struct file *file, void *priv, struct v4l2_buffer *p);
305*4882a593Smuzhiyun int vb2_ioctl_qbuf(struct file *file, void *priv, struct v4l2_buffer *p);
306*4882a593Smuzhiyun int vb2_ioctl_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p);
307*4882a593Smuzhiyun int vb2_ioctl_streamon(struct file *file, void *priv, enum v4l2_buf_type i);
308*4882a593Smuzhiyun int vb2_ioctl_streamoff(struct file *file, void *priv, enum v4l2_buf_type i);
309*4882a593Smuzhiyun int vb2_ioctl_expbuf(struct file *file, void *priv,
310*4882a593Smuzhiyun 	struct v4l2_exportbuffer *p);
311*4882a593Smuzhiyun 
312*4882a593Smuzhiyun /* struct v4l2_file_operations helpers */
313*4882a593Smuzhiyun 
314*4882a593Smuzhiyun int vb2_fop_mmap(struct file *file, struct vm_area_struct *vma);
315*4882a593Smuzhiyun int vb2_fop_release(struct file *file);
316*4882a593Smuzhiyun int _vb2_fop_release(struct file *file, struct mutex *lock);
317*4882a593Smuzhiyun ssize_t vb2_fop_write(struct file *file, const char __user *buf,
318*4882a593Smuzhiyun 		size_t count, loff_t *ppos);
319*4882a593Smuzhiyun ssize_t vb2_fop_read(struct file *file, char __user *buf,
320*4882a593Smuzhiyun 		size_t count, loff_t *ppos);
321*4882a593Smuzhiyun __poll_t vb2_fop_poll(struct file *file, poll_table *wait);
322*4882a593Smuzhiyun #ifndef CONFIG_MMU
323*4882a593Smuzhiyun unsigned long vb2_fop_get_unmapped_area(struct file *file, unsigned long addr,
324*4882a593Smuzhiyun 		unsigned long len, unsigned long pgoff, unsigned long flags);
325*4882a593Smuzhiyun #endif
326*4882a593Smuzhiyun 
327*4882a593Smuzhiyun /**
328*4882a593Smuzhiyun  * vb2_video_unregister_device - unregister the video device and release queue
329*4882a593Smuzhiyun  *
330*4882a593Smuzhiyun  * @vdev: pointer to &struct video_device
331*4882a593Smuzhiyun  *
332*4882a593Smuzhiyun  * If the driver uses vb2_fop_release()/_vb2_fop_release(), then it should use
333*4882a593Smuzhiyun  * vb2_video_unregister_device() instead of video_unregister_device().
334*4882a593Smuzhiyun  *
335*4882a593Smuzhiyun  * This function will call video_unregister_device() and then release the
336*4882a593Smuzhiyun  * vb2_queue if streaming is in progress. This will stop streaming and
337*4882a593Smuzhiyun  * this will simplify the unbind sequence since after this call all subdevs
338*4882a593Smuzhiyun  * will have stopped streaming as well.
339*4882a593Smuzhiyun  */
340*4882a593Smuzhiyun void vb2_video_unregister_device(struct video_device *vdev);
341*4882a593Smuzhiyun 
342*4882a593Smuzhiyun /**
343*4882a593Smuzhiyun  * vb2_ops_wait_prepare - helper function to lock a struct &vb2_queue
344*4882a593Smuzhiyun  *
345*4882a593Smuzhiyun  * @vq: pointer to &struct vb2_queue
346*4882a593Smuzhiyun  *
347*4882a593Smuzhiyun  * ..note:: only use if vq->lock is non-NULL.
348*4882a593Smuzhiyun  */
349*4882a593Smuzhiyun void vb2_ops_wait_prepare(struct vb2_queue *vq);
350*4882a593Smuzhiyun 
351*4882a593Smuzhiyun /**
352*4882a593Smuzhiyun  * vb2_ops_wait_finish - helper function to unlock a struct &vb2_queue
353*4882a593Smuzhiyun  *
354*4882a593Smuzhiyun  * @vq: pointer to &struct vb2_queue
355*4882a593Smuzhiyun  *
356*4882a593Smuzhiyun  * ..note:: only use if vq->lock is non-NULL.
357*4882a593Smuzhiyun  */
358*4882a593Smuzhiyun void vb2_ops_wait_finish(struct vb2_queue *vq);
359*4882a593Smuzhiyun 
360*4882a593Smuzhiyun struct media_request;
361*4882a593Smuzhiyun int vb2_request_validate(struct media_request *req);
362*4882a593Smuzhiyun void vb2_request_queue(struct media_request *req);
363*4882a593Smuzhiyun 
364*4882a593Smuzhiyun #endif /* _MEDIA_VIDEOBUF2_V4L2_H */
365