18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * videobuf2-v4l2.h - V4L2 driver helper framework
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Copyright (C) 2010 Samsung Electronics
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * Author: Pawel Osciak <pawel@osciak.com>
78c2ecf20Sopenharmony_ci *
88c2ecf20Sopenharmony_ci * This program is free software; you can redistribute it and/or modify
98c2ecf20Sopenharmony_ci * it under the terms of the GNU General Public License as published by
108c2ecf20Sopenharmony_ci * the Free Software Foundation.
118c2ecf20Sopenharmony_ci */
128c2ecf20Sopenharmony_ci#ifndef _MEDIA_VIDEOBUF2_V4L2_H
138c2ecf20Sopenharmony_ci#define _MEDIA_VIDEOBUF2_V4L2_H
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#include <linux/videodev2.h>
168c2ecf20Sopenharmony_ci#include <media/videobuf2-core.h>
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci#if VB2_MAX_FRAME != VIDEO_MAX_FRAME
198c2ecf20Sopenharmony_ci#error VB2_MAX_FRAME != VIDEO_MAX_FRAME
208c2ecf20Sopenharmony_ci#endif
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci#if VB2_MAX_PLANES != VIDEO_MAX_PLANES
238c2ecf20Sopenharmony_ci#error VB2_MAX_PLANES != VIDEO_MAX_PLANES
248c2ecf20Sopenharmony_ci#endif
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_cistruct video_device;
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci/**
298c2ecf20Sopenharmony_ci * struct vb2_v4l2_buffer - video buffer information for v4l2.
308c2ecf20Sopenharmony_ci *
318c2ecf20Sopenharmony_ci * @vb2_buf:	embedded struct &vb2_buffer.
328c2ecf20Sopenharmony_ci * @flags:	buffer informational flags.
338c2ecf20Sopenharmony_ci * @field:	field order of the image in the buffer, as defined by
348c2ecf20Sopenharmony_ci *		&enum v4l2_field.
358c2ecf20Sopenharmony_ci * @timecode:	frame timecode.
368c2ecf20Sopenharmony_ci * @sequence:	sequence count of this frame.
378c2ecf20Sopenharmony_ci * @request_fd:	the request_fd associated with this buffer
388c2ecf20Sopenharmony_ci * @is_held:	if true, then this capture buffer was held
398c2ecf20Sopenharmony_ci * @planes:	plane information (userptr/fd, length, bytesused, data_offset).
408c2ecf20Sopenharmony_ci *
418c2ecf20Sopenharmony_ci * Should contain enough information to be able to cover all the fields
428c2ecf20Sopenharmony_ci * of &struct v4l2_buffer at ``videodev2.h``.
438c2ecf20Sopenharmony_ci */
448c2ecf20Sopenharmony_cistruct vb2_v4l2_buffer {
458c2ecf20Sopenharmony_ci	struct vb2_buffer	vb2_buf;
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ci	__u32			flags;
488c2ecf20Sopenharmony_ci	__u32			field;
498c2ecf20Sopenharmony_ci	struct v4l2_timecode	timecode;
508c2ecf20Sopenharmony_ci	__u32			sequence;
518c2ecf20Sopenharmony_ci	__s32			request_fd;
528c2ecf20Sopenharmony_ci	bool			is_held;
538c2ecf20Sopenharmony_ci	struct vb2_plane	planes[VB2_MAX_PLANES];
548c2ecf20Sopenharmony_ci};
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci/* VB2 V4L2 flags as set in vb2_queue.subsystem_flags */
578c2ecf20Sopenharmony_ci#define VB2_V4L2_FL_SUPPORTS_M2M_HOLD_CAPTURE_BUF (1 << 0)
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci/*
608c2ecf20Sopenharmony_ci * to_vb2_v4l2_buffer() - cast struct vb2_buffer * to struct vb2_v4l2_buffer *
618c2ecf20Sopenharmony_ci */
628c2ecf20Sopenharmony_ci#define to_vb2_v4l2_buffer(vb) \
638c2ecf20Sopenharmony_ci	container_of(vb, struct vb2_v4l2_buffer, vb2_buf)
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci/**
668c2ecf20Sopenharmony_ci * vb2_find_timestamp() - Find buffer with given timestamp in the queue
678c2ecf20Sopenharmony_ci *
688c2ecf20Sopenharmony_ci * @q:		pointer to &struct vb2_queue with videobuf2 queue.
698c2ecf20Sopenharmony_ci * @timestamp:	the timestamp to find.
708c2ecf20Sopenharmony_ci * @start_idx:	the start index (usually 0) in the buffer array to start
718c2ecf20Sopenharmony_ci *		searching from. Note that there may be multiple buffers
728c2ecf20Sopenharmony_ci *		with the same timestamp value, so you can restart the search
738c2ecf20Sopenharmony_ci *		by setting @start_idx to the previously found index + 1.
748c2ecf20Sopenharmony_ci *
758c2ecf20Sopenharmony_ci * Returns the buffer index of the buffer with the given @timestamp, or
768c2ecf20Sopenharmony_ci * -1 if no buffer with @timestamp was found.
778c2ecf20Sopenharmony_ci */
788c2ecf20Sopenharmony_ciint vb2_find_timestamp(const struct vb2_queue *q, u64 timestamp,
798c2ecf20Sopenharmony_ci		       unsigned int start_idx);
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_ciint vb2_querybuf(struct vb2_queue *q, struct v4l2_buffer *b);
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ci/**
848c2ecf20Sopenharmony_ci * vb2_reqbufs() - Wrapper for vb2_core_reqbufs() that also verifies
858c2ecf20Sopenharmony_ci * the memory and type values.
868c2ecf20Sopenharmony_ci *
878c2ecf20Sopenharmony_ci * @q:		pointer to &struct vb2_queue with videobuf2 queue.
888c2ecf20Sopenharmony_ci * @req:	&struct v4l2_requestbuffers passed from userspace to
898c2ecf20Sopenharmony_ci *		&v4l2_ioctl_ops->vidioc_reqbufs handler in driver.
908c2ecf20Sopenharmony_ci */
918c2ecf20Sopenharmony_ciint vb2_reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req);
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ci/**
948c2ecf20Sopenharmony_ci * vb2_create_bufs() - Wrapper for vb2_core_create_bufs() that also verifies
958c2ecf20Sopenharmony_ci * the memory and type values.
968c2ecf20Sopenharmony_ci *
978c2ecf20Sopenharmony_ci * @q:		pointer to &struct vb2_queue with videobuf2 queue.
988c2ecf20Sopenharmony_ci * @create:	creation parameters, passed from userspace to
998c2ecf20Sopenharmony_ci *		&v4l2_ioctl_ops->vidioc_create_bufs handler in driver
1008c2ecf20Sopenharmony_ci */
1018c2ecf20Sopenharmony_ciint vb2_create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create);
1028c2ecf20Sopenharmony_ci
1038c2ecf20Sopenharmony_ci/**
1048c2ecf20Sopenharmony_ci * vb2_prepare_buf() - Pass ownership of a buffer from userspace to the kernel
1058c2ecf20Sopenharmony_ci *
1068c2ecf20Sopenharmony_ci * @q:		pointer to &struct vb2_queue with videobuf2 queue.
1078c2ecf20Sopenharmony_ci * @mdev:	pointer to &struct media_device, may be NULL.
1088c2ecf20Sopenharmony_ci * @b:		buffer structure passed from userspace to
1098c2ecf20Sopenharmony_ci *		&v4l2_ioctl_ops->vidioc_prepare_buf handler in driver
1108c2ecf20Sopenharmony_ci *
1118c2ecf20Sopenharmony_ci * Should be called from &v4l2_ioctl_ops->vidioc_prepare_buf ioctl handler
1128c2ecf20Sopenharmony_ci * of a driver.
1138c2ecf20Sopenharmony_ci *
1148c2ecf20Sopenharmony_ci * This function:
1158c2ecf20Sopenharmony_ci *
1168c2ecf20Sopenharmony_ci * #) verifies the passed buffer,
1178c2ecf20Sopenharmony_ci * #) calls &vb2_ops->buf_prepare callback in the driver (if provided),
1188c2ecf20Sopenharmony_ci *    in which driver-specific buffer initialization can be performed.
1198c2ecf20Sopenharmony_ci * #) if @b->request_fd is non-zero and @mdev->ops->req_queue is set,
1208c2ecf20Sopenharmony_ci *    then bind the prepared buffer to the request.
1218c2ecf20Sopenharmony_ci *
1228c2ecf20Sopenharmony_ci * The return values from this function are intended to be directly returned
1238c2ecf20Sopenharmony_ci * from &v4l2_ioctl_ops->vidioc_prepare_buf handler in driver.
1248c2ecf20Sopenharmony_ci */
1258c2ecf20Sopenharmony_ciint vb2_prepare_buf(struct vb2_queue *q, struct media_device *mdev,
1268c2ecf20Sopenharmony_ci		    struct v4l2_buffer *b);
1278c2ecf20Sopenharmony_ci
1288c2ecf20Sopenharmony_ci/**
1298c2ecf20Sopenharmony_ci * vb2_qbuf() - Queue a buffer from userspace
1308c2ecf20Sopenharmony_ci * @q:		pointer to &struct vb2_queue with videobuf2 queue.
1318c2ecf20Sopenharmony_ci * @mdev:	pointer to &struct media_device, may be NULL.
1328c2ecf20Sopenharmony_ci * @b:		buffer structure passed from userspace to
1338c2ecf20Sopenharmony_ci *		&v4l2_ioctl_ops->vidioc_qbuf handler in driver
1348c2ecf20Sopenharmony_ci *
1358c2ecf20Sopenharmony_ci * Should be called from &v4l2_ioctl_ops->vidioc_qbuf handler of a driver.
1368c2ecf20Sopenharmony_ci *
1378c2ecf20Sopenharmony_ci * This function:
1388c2ecf20Sopenharmony_ci *
1398c2ecf20Sopenharmony_ci * #) verifies the passed buffer;
1408c2ecf20Sopenharmony_ci * #) if @b->request_fd is non-zero and @mdev->ops->req_queue is set,
1418c2ecf20Sopenharmony_ci *    then bind the buffer to the request.
1428c2ecf20Sopenharmony_ci * #) if necessary, calls &vb2_ops->buf_prepare callback in the driver
1438c2ecf20Sopenharmony_ci *    (if provided), in which driver-specific buffer initialization can
1448c2ecf20Sopenharmony_ci *    be performed;
1458c2ecf20Sopenharmony_ci * #) if streaming is on, queues the buffer in driver by the means of
1468c2ecf20Sopenharmony_ci *    &vb2_ops->buf_queue callback for processing.
1478c2ecf20Sopenharmony_ci *
1488c2ecf20Sopenharmony_ci * The return values from this function are intended to be directly returned
1498c2ecf20Sopenharmony_ci * from &v4l2_ioctl_ops->vidioc_qbuf handler in driver.
1508c2ecf20Sopenharmony_ci */
1518c2ecf20Sopenharmony_ciint vb2_qbuf(struct vb2_queue *q, struct media_device *mdev,
1528c2ecf20Sopenharmony_ci	     struct v4l2_buffer *b);
1538c2ecf20Sopenharmony_ci
1548c2ecf20Sopenharmony_ci/**
1558c2ecf20Sopenharmony_ci * vb2_expbuf() - Export a buffer as a file descriptor
1568c2ecf20Sopenharmony_ci * @q:		pointer to &struct vb2_queue with videobuf2 queue.
1578c2ecf20Sopenharmony_ci * @eb:		export buffer structure passed from userspace to
1588c2ecf20Sopenharmony_ci *		&v4l2_ioctl_ops->vidioc_expbuf handler in driver
1598c2ecf20Sopenharmony_ci *
1608c2ecf20Sopenharmony_ci * The return values from this function are intended to be directly returned
1618c2ecf20Sopenharmony_ci * from &v4l2_ioctl_ops->vidioc_expbuf handler in driver.
1628c2ecf20Sopenharmony_ci */
1638c2ecf20Sopenharmony_ciint vb2_expbuf(struct vb2_queue *q, struct v4l2_exportbuffer *eb);
1648c2ecf20Sopenharmony_ci
1658c2ecf20Sopenharmony_ci/**
1668c2ecf20Sopenharmony_ci * vb2_dqbuf() - Dequeue a buffer to the userspace
1678c2ecf20Sopenharmony_ci * @q:		pointer to &struct vb2_queue with videobuf2 queue.
1688c2ecf20Sopenharmony_ci * @b:		buffer structure passed from userspace to
1698c2ecf20Sopenharmony_ci *		&v4l2_ioctl_ops->vidioc_dqbuf handler in driver
1708c2ecf20Sopenharmony_ci * @nonblocking: if true, this call will not sleep waiting for a buffer if no
1718c2ecf20Sopenharmony_ci *		 buffers ready for dequeuing are present. Normally the driver
1728c2ecf20Sopenharmony_ci *		 would be passing (&file->f_flags & %O_NONBLOCK) here
1738c2ecf20Sopenharmony_ci *
1748c2ecf20Sopenharmony_ci * Should be called from &v4l2_ioctl_ops->vidioc_dqbuf ioctl handler
1758c2ecf20Sopenharmony_ci * of a driver.
1768c2ecf20Sopenharmony_ci *
1778c2ecf20Sopenharmony_ci * This function:
1788c2ecf20Sopenharmony_ci *
1798c2ecf20Sopenharmony_ci * #) verifies the passed buffer;
1808c2ecf20Sopenharmony_ci * #) calls &vb2_ops->buf_finish callback in the driver (if provided), in which
1818c2ecf20Sopenharmony_ci *    driver can perform any additional operations that may be required before
1828c2ecf20Sopenharmony_ci *    returning the buffer to userspace, such as cache sync;
1838c2ecf20Sopenharmony_ci * #) the buffer struct members are filled with relevant information for
1848c2ecf20Sopenharmony_ci *    the userspace.
1858c2ecf20Sopenharmony_ci *
1868c2ecf20Sopenharmony_ci * The return values from this function are intended to be directly returned
1878c2ecf20Sopenharmony_ci * from &v4l2_ioctl_ops->vidioc_dqbuf handler in driver.
1888c2ecf20Sopenharmony_ci */
1898c2ecf20Sopenharmony_ciint vb2_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool nonblocking);
1908c2ecf20Sopenharmony_ci
1918c2ecf20Sopenharmony_ci/**
1928c2ecf20Sopenharmony_ci * vb2_streamon - start streaming
1938c2ecf20Sopenharmony_ci * @q:		pointer to &struct vb2_queue with videobuf2 queue.
1948c2ecf20Sopenharmony_ci * @type:	type argument passed from userspace to vidioc_streamon handler,
1958c2ecf20Sopenharmony_ci *		as defined by &enum v4l2_buf_type.
1968c2ecf20Sopenharmony_ci *
1978c2ecf20Sopenharmony_ci * Should be called from &v4l2_ioctl_ops->vidioc_streamon handler of a driver.
1988c2ecf20Sopenharmony_ci *
1998c2ecf20Sopenharmony_ci * This function:
2008c2ecf20Sopenharmony_ci *
2018c2ecf20Sopenharmony_ci * 1) verifies current state
2028c2ecf20Sopenharmony_ci * 2) passes any previously queued buffers to the driver and starts streaming
2038c2ecf20Sopenharmony_ci *
2048c2ecf20Sopenharmony_ci * The return values from this function are intended to be directly returned
2058c2ecf20Sopenharmony_ci * from &v4l2_ioctl_ops->vidioc_streamon handler in the driver.
2068c2ecf20Sopenharmony_ci */
2078c2ecf20Sopenharmony_ciint vb2_streamon(struct vb2_queue *q, enum v4l2_buf_type type);
2088c2ecf20Sopenharmony_ci
2098c2ecf20Sopenharmony_ci/**
2108c2ecf20Sopenharmony_ci * vb2_streamoff - stop streaming
2118c2ecf20Sopenharmony_ci * @q:		pointer to &struct vb2_queue with videobuf2 queue.
2128c2ecf20Sopenharmony_ci * @type:	type argument passed from userspace to vidioc_streamoff handler
2138c2ecf20Sopenharmony_ci *
2148c2ecf20Sopenharmony_ci * Should be called from vidioc_streamoff handler of a driver.
2158c2ecf20Sopenharmony_ci *
2168c2ecf20Sopenharmony_ci * This function:
2178c2ecf20Sopenharmony_ci *
2188c2ecf20Sopenharmony_ci * #) verifies current state,
2198c2ecf20Sopenharmony_ci * #) stop streaming and dequeues any queued buffers, including those previously
2208c2ecf20Sopenharmony_ci *    passed to the driver (after waiting for the driver to finish).
2218c2ecf20Sopenharmony_ci *
2228c2ecf20Sopenharmony_ci * This call can be used for pausing playback.
2238c2ecf20Sopenharmony_ci * The return values from this function are intended to be directly returned
2248c2ecf20Sopenharmony_ci * from vidioc_streamoff handler in the driver
2258c2ecf20Sopenharmony_ci */
2268c2ecf20Sopenharmony_ciint vb2_streamoff(struct vb2_queue *q, enum v4l2_buf_type type);
2278c2ecf20Sopenharmony_ci
2288c2ecf20Sopenharmony_ci/**
2298c2ecf20Sopenharmony_ci * vb2_queue_init() - initialize a videobuf2 queue
2308c2ecf20Sopenharmony_ci * @q:		pointer to &struct vb2_queue with videobuf2 queue.
2318c2ecf20Sopenharmony_ci *
2328c2ecf20Sopenharmony_ci * The vb2_queue structure should be allocated by the driver. The driver is
2338c2ecf20Sopenharmony_ci * responsible of clearing it's content and setting initial values for some
2348c2ecf20Sopenharmony_ci * required entries before calling this function.
2358c2ecf20Sopenharmony_ci * q->ops, q->mem_ops, q->type and q->io_modes are mandatory. Please refer
2368c2ecf20Sopenharmony_ci * to the struct vb2_queue description in include/media/videobuf2-core.h
2378c2ecf20Sopenharmony_ci * for more information.
2388c2ecf20Sopenharmony_ci */
2398c2ecf20Sopenharmony_ciint __must_check vb2_queue_init(struct vb2_queue *q);
2408c2ecf20Sopenharmony_ci
2418c2ecf20Sopenharmony_ci/**
2428c2ecf20Sopenharmony_ci * vb2_queue_init_name() - initialize a videobuf2 queue with a name
2438c2ecf20Sopenharmony_ci * @q:		pointer to &struct vb2_queue with videobuf2 queue.
2448c2ecf20Sopenharmony_ci * @name:	the queue name
2458c2ecf20Sopenharmony_ci *
2468c2ecf20Sopenharmony_ci * This function initializes the vb2_queue exactly like vb2_queue_init(),
2478c2ecf20Sopenharmony_ci * and additionally sets the queue name. The queue name is used for logging
2488c2ecf20Sopenharmony_ci * purpose, and should uniquely identify the queue within the context of the
2498c2ecf20Sopenharmony_ci * device it belongs to. This is useful to attribute kernel log messages to the
2508c2ecf20Sopenharmony_ci * right queue for m2m devices or other devices that handle multiple queues.
2518c2ecf20Sopenharmony_ci */
2528c2ecf20Sopenharmony_ciint __must_check vb2_queue_init_name(struct vb2_queue *q, const char *name);
2538c2ecf20Sopenharmony_ci
2548c2ecf20Sopenharmony_ci/**
2558c2ecf20Sopenharmony_ci * vb2_queue_release() - stop streaming, release the queue and free memory
2568c2ecf20Sopenharmony_ci * @q:		pointer to &struct vb2_queue with videobuf2 queue.
2578c2ecf20Sopenharmony_ci *
2588c2ecf20Sopenharmony_ci * This function stops streaming and performs necessary clean ups, including
2598c2ecf20Sopenharmony_ci * freeing video buffer memory. The driver is responsible for freeing
2608c2ecf20Sopenharmony_ci * the vb2_queue structure itself.
2618c2ecf20Sopenharmony_ci */
2628c2ecf20Sopenharmony_civoid vb2_queue_release(struct vb2_queue *q);
2638c2ecf20Sopenharmony_ci
2648c2ecf20Sopenharmony_ci/**
2658c2ecf20Sopenharmony_ci * vb2_poll() - implements poll userspace operation
2668c2ecf20Sopenharmony_ci * @q:		pointer to &struct vb2_queue with videobuf2 queue.
2678c2ecf20Sopenharmony_ci * @file:	file argument passed to the poll file operation handler
2688c2ecf20Sopenharmony_ci * @wait:	wait argument passed to the poll file operation handler
2698c2ecf20Sopenharmony_ci *
2708c2ecf20Sopenharmony_ci * This function implements poll file operation handler for a driver.
2718c2ecf20Sopenharmony_ci * For CAPTURE queues, if a buffer is ready to be dequeued, the userspace will
2728c2ecf20Sopenharmony_ci * be informed that the file descriptor of a video device is available for
2738c2ecf20Sopenharmony_ci * reading.
2748c2ecf20Sopenharmony_ci * For OUTPUT queues, if a buffer is ready to be dequeued, the file descriptor
2758c2ecf20Sopenharmony_ci * will be reported as available for writing.
2768c2ecf20Sopenharmony_ci *
2778c2ecf20Sopenharmony_ci * If the driver uses struct v4l2_fh, then vb2_poll() will also check for any
2788c2ecf20Sopenharmony_ci * pending events.
2798c2ecf20Sopenharmony_ci *
2808c2ecf20Sopenharmony_ci * The return values from this function are intended to be directly returned
2818c2ecf20Sopenharmony_ci * from poll handler in driver.
2828c2ecf20Sopenharmony_ci */
2838c2ecf20Sopenharmony_ci__poll_t vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait);
2848c2ecf20Sopenharmony_ci
2858c2ecf20Sopenharmony_ci/*
2868c2ecf20Sopenharmony_ci * The following functions are not part of the vb2 core API, but are simple
2878c2ecf20Sopenharmony_ci * helper functions that you can use in your struct v4l2_file_operations,
2888c2ecf20Sopenharmony_ci * struct v4l2_ioctl_ops and struct vb2_ops. They will serialize if vb2_queue->lock
2898c2ecf20Sopenharmony_ci * or video_device->lock is set, and they will set and test vb2_queue->owner
2908c2ecf20Sopenharmony_ci * to check if the calling filehandle is permitted to do the queuing operation.
2918c2ecf20Sopenharmony_ci */
2928c2ecf20Sopenharmony_ci
2938c2ecf20Sopenharmony_ci/* struct v4l2_ioctl_ops helpers */
2948c2ecf20Sopenharmony_ci
2958c2ecf20Sopenharmony_ciint vb2_ioctl_reqbufs(struct file *file, void *priv,
2968c2ecf20Sopenharmony_ci			  struct v4l2_requestbuffers *p);
2978c2ecf20Sopenharmony_ciint vb2_ioctl_create_bufs(struct file *file, void *priv,
2988c2ecf20Sopenharmony_ci			  struct v4l2_create_buffers *p);
2998c2ecf20Sopenharmony_ciint vb2_ioctl_prepare_buf(struct file *file, void *priv,
3008c2ecf20Sopenharmony_ci			  struct v4l2_buffer *p);
3018c2ecf20Sopenharmony_ciint vb2_ioctl_querybuf(struct file *file, void *priv, struct v4l2_buffer *p);
3028c2ecf20Sopenharmony_ciint vb2_ioctl_qbuf(struct file *file, void *priv, struct v4l2_buffer *p);
3038c2ecf20Sopenharmony_ciint vb2_ioctl_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p);
3048c2ecf20Sopenharmony_ciint vb2_ioctl_streamon(struct file *file, void *priv, enum v4l2_buf_type i);
3058c2ecf20Sopenharmony_ciint vb2_ioctl_streamoff(struct file *file, void *priv, enum v4l2_buf_type i);
3068c2ecf20Sopenharmony_ciint vb2_ioctl_expbuf(struct file *file, void *priv,
3078c2ecf20Sopenharmony_ci	struct v4l2_exportbuffer *p);
3088c2ecf20Sopenharmony_ci
3098c2ecf20Sopenharmony_ci/* struct v4l2_file_operations helpers */
3108c2ecf20Sopenharmony_ci
3118c2ecf20Sopenharmony_ciint vb2_fop_mmap(struct file *file, struct vm_area_struct *vma);
3128c2ecf20Sopenharmony_ciint vb2_fop_release(struct file *file);
3138c2ecf20Sopenharmony_ciint _vb2_fop_release(struct file *file, struct mutex *lock);
3148c2ecf20Sopenharmony_cissize_t vb2_fop_write(struct file *file, const char __user *buf,
3158c2ecf20Sopenharmony_ci		size_t count, loff_t *ppos);
3168c2ecf20Sopenharmony_cissize_t vb2_fop_read(struct file *file, char __user *buf,
3178c2ecf20Sopenharmony_ci		size_t count, loff_t *ppos);
3188c2ecf20Sopenharmony_ci__poll_t vb2_fop_poll(struct file *file, poll_table *wait);
3198c2ecf20Sopenharmony_ci#ifndef CONFIG_MMU
3208c2ecf20Sopenharmony_ciunsigned long vb2_fop_get_unmapped_area(struct file *file, unsigned long addr,
3218c2ecf20Sopenharmony_ci		unsigned long len, unsigned long pgoff, unsigned long flags);
3228c2ecf20Sopenharmony_ci#endif
3238c2ecf20Sopenharmony_ci
3248c2ecf20Sopenharmony_ci/**
3258c2ecf20Sopenharmony_ci * vb2_video_unregister_device - unregister the video device and release queue
3268c2ecf20Sopenharmony_ci *
3278c2ecf20Sopenharmony_ci * @vdev: pointer to &struct video_device
3288c2ecf20Sopenharmony_ci *
3298c2ecf20Sopenharmony_ci * If the driver uses vb2_fop_release()/_vb2_fop_release(), then it should use
3308c2ecf20Sopenharmony_ci * vb2_video_unregister_device() instead of video_unregister_device().
3318c2ecf20Sopenharmony_ci *
3328c2ecf20Sopenharmony_ci * This function will call video_unregister_device() and then release the
3338c2ecf20Sopenharmony_ci * vb2_queue if streaming is in progress. This will stop streaming and
3348c2ecf20Sopenharmony_ci * this will simplify the unbind sequence since after this call all subdevs
3358c2ecf20Sopenharmony_ci * will have stopped streaming as well.
3368c2ecf20Sopenharmony_ci */
3378c2ecf20Sopenharmony_civoid vb2_video_unregister_device(struct video_device *vdev);
3388c2ecf20Sopenharmony_ci
3398c2ecf20Sopenharmony_ci/**
3408c2ecf20Sopenharmony_ci * vb2_ops_wait_prepare - helper function to lock a struct &vb2_queue
3418c2ecf20Sopenharmony_ci *
3428c2ecf20Sopenharmony_ci * @vq: pointer to &struct vb2_queue
3438c2ecf20Sopenharmony_ci *
3448c2ecf20Sopenharmony_ci * ..note:: only use if vq->lock is non-NULL.
3458c2ecf20Sopenharmony_ci */
3468c2ecf20Sopenharmony_civoid vb2_ops_wait_prepare(struct vb2_queue *vq);
3478c2ecf20Sopenharmony_ci
3488c2ecf20Sopenharmony_ci/**
3498c2ecf20Sopenharmony_ci * vb2_ops_wait_finish - helper function to unlock a struct &vb2_queue
3508c2ecf20Sopenharmony_ci *
3518c2ecf20Sopenharmony_ci * @vq: pointer to &struct vb2_queue
3528c2ecf20Sopenharmony_ci *
3538c2ecf20Sopenharmony_ci * ..note:: only use if vq->lock is non-NULL.
3548c2ecf20Sopenharmony_ci */
3558c2ecf20Sopenharmony_civoid vb2_ops_wait_finish(struct vb2_queue *vq);
3568c2ecf20Sopenharmony_ci
3578c2ecf20Sopenharmony_cistruct media_request;
3588c2ecf20Sopenharmony_ciint vb2_request_validate(struct media_request *req);
3598c2ecf20Sopenharmony_civoid vb2_request_queue(struct media_request *req);
3608c2ecf20Sopenharmony_ci
3618c2ecf20Sopenharmony_ci#endif /* _MEDIA_VIDEOBUF2_V4L2_H */
362