162306a36Sopenharmony_ci/*
262306a36Sopenharmony_ci * videobuf2-v4l2.h - V4L2 driver helper framework
362306a36Sopenharmony_ci *
462306a36Sopenharmony_ci * Copyright (C) 2010 Samsung Electronics
562306a36Sopenharmony_ci *
662306a36Sopenharmony_ci * Author: Pawel Osciak <pawel@osciak.com>
762306a36Sopenharmony_ci *
862306a36Sopenharmony_ci * This program is free software; you can redistribute it and/or modify
962306a36Sopenharmony_ci * it under the terms of the GNU General Public License as published by
1062306a36Sopenharmony_ci * the Free Software Foundation.
1162306a36Sopenharmony_ci */
1262306a36Sopenharmony_ci#ifndef _MEDIA_VIDEOBUF2_V4L2_H
1362306a36Sopenharmony_ci#define _MEDIA_VIDEOBUF2_V4L2_H
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci#include <linux/videodev2.h>
1662306a36Sopenharmony_ci#include <media/videobuf2-core.h>
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci#if VB2_MAX_FRAME != VIDEO_MAX_FRAME
1962306a36Sopenharmony_ci#error VB2_MAX_FRAME != VIDEO_MAX_FRAME
2062306a36Sopenharmony_ci#endif
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ci#if VB2_MAX_PLANES != VIDEO_MAX_PLANES
2362306a36Sopenharmony_ci#error VB2_MAX_PLANES != VIDEO_MAX_PLANES
2462306a36Sopenharmony_ci#endif
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_cistruct video_device;
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ci/**
2962306a36Sopenharmony_ci * struct vb2_v4l2_buffer - video buffer information for v4l2.
3062306a36Sopenharmony_ci *
3162306a36Sopenharmony_ci * @vb2_buf:	embedded struct &vb2_buffer.
3262306a36Sopenharmony_ci * @flags:	buffer informational flags.
3362306a36Sopenharmony_ci * @field:	field order of the image in the buffer, as defined by
3462306a36Sopenharmony_ci *		&enum v4l2_field.
3562306a36Sopenharmony_ci * @timecode:	frame timecode.
3662306a36Sopenharmony_ci * @sequence:	sequence count of this frame.
3762306a36Sopenharmony_ci * @request_fd:	the request_fd associated with this buffer
3862306a36Sopenharmony_ci * @is_held:	if true, then this capture buffer was held
3962306a36Sopenharmony_ci * @planes:	plane information (userptr/fd, length, bytesused, data_offset).
4062306a36Sopenharmony_ci *
4162306a36Sopenharmony_ci * Should contain enough information to be able to cover all the fields
4262306a36Sopenharmony_ci * of &struct v4l2_buffer at ``videodev2.h``.
4362306a36Sopenharmony_ci */
4462306a36Sopenharmony_cistruct vb2_v4l2_buffer {
4562306a36Sopenharmony_ci	struct vb2_buffer	vb2_buf;
4662306a36Sopenharmony_ci
4762306a36Sopenharmony_ci	__u32			flags;
4862306a36Sopenharmony_ci	__u32			field;
4962306a36Sopenharmony_ci	struct v4l2_timecode	timecode;
5062306a36Sopenharmony_ci	__u32			sequence;
5162306a36Sopenharmony_ci	__s32			request_fd;
5262306a36Sopenharmony_ci	bool			is_held;
5362306a36Sopenharmony_ci	struct vb2_plane	planes[VB2_MAX_PLANES];
5462306a36Sopenharmony_ci};
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ci/* VB2 V4L2 flags as set in vb2_queue.subsystem_flags */
5762306a36Sopenharmony_ci#define VB2_V4L2_FL_SUPPORTS_M2M_HOLD_CAPTURE_BUF (1 << 0)
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ci/*
6062306a36Sopenharmony_ci * to_vb2_v4l2_buffer() - cast struct vb2_buffer * to struct vb2_v4l2_buffer *
6162306a36Sopenharmony_ci */
6262306a36Sopenharmony_ci#define to_vb2_v4l2_buffer(vb) \
6362306a36Sopenharmony_ci	container_of(vb, struct vb2_v4l2_buffer, vb2_buf)
6462306a36Sopenharmony_ci
6562306a36Sopenharmony_ci/**
6662306a36Sopenharmony_ci * vb2_find_buffer() - Find a buffer with given timestamp
6762306a36Sopenharmony_ci *
6862306a36Sopenharmony_ci * @q:		pointer to &struct vb2_queue with videobuf2 queue.
6962306a36Sopenharmony_ci * @timestamp:	the timestamp to find.
7062306a36Sopenharmony_ci *
7162306a36Sopenharmony_ci * Returns the buffer with the given @timestamp, or NULL if not found.
7262306a36Sopenharmony_ci */
7362306a36Sopenharmony_cistruct vb2_buffer *vb2_find_buffer(struct vb2_queue *q, u64 timestamp);
7462306a36Sopenharmony_ci
7562306a36Sopenharmony_ciint vb2_querybuf(struct vb2_queue *q, struct v4l2_buffer *b);
7662306a36Sopenharmony_ci
7762306a36Sopenharmony_ci/**
7862306a36Sopenharmony_ci * vb2_reqbufs() - Wrapper for vb2_core_reqbufs() that also verifies
7962306a36Sopenharmony_ci * the memory and type values.
8062306a36Sopenharmony_ci *
8162306a36Sopenharmony_ci * @q:		pointer to &struct vb2_queue with videobuf2 queue.
8262306a36Sopenharmony_ci * @req:	&struct v4l2_requestbuffers passed from userspace to
8362306a36Sopenharmony_ci *		&v4l2_ioctl_ops->vidioc_reqbufs handler in driver.
8462306a36Sopenharmony_ci */
8562306a36Sopenharmony_ciint vb2_reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req);
8662306a36Sopenharmony_ci
8762306a36Sopenharmony_ci/**
8862306a36Sopenharmony_ci * vb2_create_bufs() - Wrapper for vb2_core_create_bufs() that also verifies
8962306a36Sopenharmony_ci * the memory and type values.
9062306a36Sopenharmony_ci *
9162306a36Sopenharmony_ci * @q:		pointer to &struct vb2_queue with videobuf2 queue.
9262306a36Sopenharmony_ci * @create:	creation parameters, passed from userspace to
9362306a36Sopenharmony_ci *		&v4l2_ioctl_ops->vidioc_create_bufs handler in driver
9462306a36Sopenharmony_ci */
9562306a36Sopenharmony_ciint vb2_create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create);
9662306a36Sopenharmony_ci
9762306a36Sopenharmony_ci/**
9862306a36Sopenharmony_ci * vb2_prepare_buf() - Pass ownership of a buffer from userspace to the kernel
9962306a36Sopenharmony_ci *
10062306a36Sopenharmony_ci * @q:		pointer to &struct vb2_queue with videobuf2 queue.
10162306a36Sopenharmony_ci * @mdev:	pointer to &struct media_device, may be NULL.
10262306a36Sopenharmony_ci * @b:		buffer structure passed from userspace to
10362306a36Sopenharmony_ci *		&v4l2_ioctl_ops->vidioc_prepare_buf handler in driver
10462306a36Sopenharmony_ci *
10562306a36Sopenharmony_ci * Should be called from &v4l2_ioctl_ops->vidioc_prepare_buf ioctl handler
10662306a36Sopenharmony_ci * of a driver.
10762306a36Sopenharmony_ci *
10862306a36Sopenharmony_ci * This function:
10962306a36Sopenharmony_ci *
11062306a36Sopenharmony_ci * #) verifies the passed buffer,
11162306a36Sopenharmony_ci * #) calls &vb2_ops->buf_prepare callback in the driver (if provided),
11262306a36Sopenharmony_ci *    in which driver-specific buffer initialization can be performed.
11362306a36Sopenharmony_ci * #) if @b->request_fd is non-zero and @mdev->ops->req_queue is set,
11462306a36Sopenharmony_ci *    then bind the prepared buffer to the request.
11562306a36Sopenharmony_ci *
11662306a36Sopenharmony_ci * The return values from this function are intended to be directly returned
11762306a36Sopenharmony_ci * from &v4l2_ioctl_ops->vidioc_prepare_buf handler in driver.
11862306a36Sopenharmony_ci */
11962306a36Sopenharmony_ciint vb2_prepare_buf(struct vb2_queue *q, struct media_device *mdev,
12062306a36Sopenharmony_ci		    struct v4l2_buffer *b);
12162306a36Sopenharmony_ci
12262306a36Sopenharmony_ci/**
12362306a36Sopenharmony_ci * vb2_qbuf() - Queue a buffer from userspace
12462306a36Sopenharmony_ci * @q:		pointer to &struct vb2_queue with videobuf2 queue.
12562306a36Sopenharmony_ci * @mdev:	pointer to &struct media_device, may be NULL.
12662306a36Sopenharmony_ci * @b:		buffer structure passed from userspace to
12762306a36Sopenharmony_ci *		&v4l2_ioctl_ops->vidioc_qbuf handler in driver
12862306a36Sopenharmony_ci *
12962306a36Sopenharmony_ci * Should be called from &v4l2_ioctl_ops->vidioc_qbuf handler of a driver.
13062306a36Sopenharmony_ci *
13162306a36Sopenharmony_ci * This function:
13262306a36Sopenharmony_ci *
13362306a36Sopenharmony_ci * #) verifies the passed buffer;
13462306a36Sopenharmony_ci * #) if @b->request_fd is non-zero and @mdev->ops->req_queue is set,
13562306a36Sopenharmony_ci *    then bind the buffer to the request.
13662306a36Sopenharmony_ci * #) if necessary, calls &vb2_ops->buf_prepare callback in the driver
13762306a36Sopenharmony_ci *    (if provided), in which driver-specific buffer initialization can
13862306a36Sopenharmony_ci *    be performed;
13962306a36Sopenharmony_ci * #) if streaming is on, queues the buffer in driver by the means of
14062306a36Sopenharmony_ci *    &vb2_ops->buf_queue callback for processing.
14162306a36Sopenharmony_ci *
14262306a36Sopenharmony_ci * The return values from this function are intended to be directly returned
14362306a36Sopenharmony_ci * from &v4l2_ioctl_ops->vidioc_qbuf handler in driver.
14462306a36Sopenharmony_ci */
14562306a36Sopenharmony_ciint vb2_qbuf(struct vb2_queue *q, struct media_device *mdev,
14662306a36Sopenharmony_ci	     struct v4l2_buffer *b);
14762306a36Sopenharmony_ci
14862306a36Sopenharmony_ci/**
14962306a36Sopenharmony_ci * vb2_expbuf() - Export a buffer as a file descriptor
15062306a36Sopenharmony_ci * @q:		pointer to &struct vb2_queue with videobuf2 queue.
15162306a36Sopenharmony_ci * @eb:		export buffer structure passed from userspace to
15262306a36Sopenharmony_ci *		&v4l2_ioctl_ops->vidioc_expbuf handler in driver
15362306a36Sopenharmony_ci *
15462306a36Sopenharmony_ci * The return values from this function are intended to be directly returned
15562306a36Sopenharmony_ci * from &v4l2_ioctl_ops->vidioc_expbuf handler in driver.
15662306a36Sopenharmony_ci */
15762306a36Sopenharmony_ciint vb2_expbuf(struct vb2_queue *q, struct v4l2_exportbuffer *eb);
15862306a36Sopenharmony_ci
15962306a36Sopenharmony_ci/**
16062306a36Sopenharmony_ci * vb2_dqbuf() - Dequeue a buffer to the userspace
16162306a36Sopenharmony_ci * @q:		pointer to &struct vb2_queue with videobuf2 queue.
16262306a36Sopenharmony_ci * @b:		buffer structure passed from userspace to
16362306a36Sopenharmony_ci *		&v4l2_ioctl_ops->vidioc_dqbuf handler in driver
16462306a36Sopenharmony_ci * @nonblocking: if true, this call will not sleep waiting for a buffer if no
16562306a36Sopenharmony_ci *		 buffers ready for dequeuing are present. Normally the driver
16662306a36Sopenharmony_ci *		 would be passing (&file->f_flags & %O_NONBLOCK) here
16762306a36Sopenharmony_ci *
16862306a36Sopenharmony_ci * Should be called from &v4l2_ioctl_ops->vidioc_dqbuf ioctl handler
16962306a36Sopenharmony_ci * of a driver.
17062306a36Sopenharmony_ci *
17162306a36Sopenharmony_ci * This function:
17262306a36Sopenharmony_ci *
17362306a36Sopenharmony_ci * #) verifies the passed buffer;
17462306a36Sopenharmony_ci * #) calls &vb2_ops->buf_finish callback in the driver (if provided), in which
17562306a36Sopenharmony_ci *    driver can perform any additional operations that may be required before
17662306a36Sopenharmony_ci *    returning the buffer to userspace, such as cache sync;
17762306a36Sopenharmony_ci * #) the buffer struct members are filled with relevant information for
17862306a36Sopenharmony_ci *    the userspace.
17962306a36Sopenharmony_ci *
18062306a36Sopenharmony_ci * The return values from this function are intended to be directly returned
18162306a36Sopenharmony_ci * from &v4l2_ioctl_ops->vidioc_dqbuf handler in driver.
18262306a36Sopenharmony_ci */
18362306a36Sopenharmony_ciint vb2_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool nonblocking);
18462306a36Sopenharmony_ci
18562306a36Sopenharmony_ci/**
18662306a36Sopenharmony_ci * vb2_streamon - start streaming
18762306a36Sopenharmony_ci * @q:		pointer to &struct vb2_queue with videobuf2 queue.
18862306a36Sopenharmony_ci * @type:	type argument passed from userspace to vidioc_streamon handler,
18962306a36Sopenharmony_ci *		as defined by &enum v4l2_buf_type.
19062306a36Sopenharmony_ci *
19162306a36Sopenharmony_ci * Should be called from &v4l2_ioctl_ops->vidioc_streamon handler of a driver.
19262306a36Sopenharmony_ci *
19362306a36Sopenharmony_ci * This function:
19462306a36Sopenharmony_ci *
19562306a36Sopenharmony_ci * 1) verifies current state
19662306a36Sopenharmony_ci * 2) passes any previously queued buffers to the driver and starts streaming
19762306a36Sopenharmony_ci *
19862306a36Sopenharmony_ci * The return values from this function are intended to be directly returned
19962306a36Sopenharmony_ci * from &v4l2_ioctl_ops->vidioc_streamon handler in the driver.
20062306a36Sopenharmony_ci */
20162306a36Sopenharmony_ciint vb2_streamon(struct vb2_queue *q, enum v4l2_buf_type type);
20262306a36Sopenharmony_ci
20362306a36Sopenharmony_ci/**
20462306a36Sopenharmony_ci * vb2_streamoff - stop streaming
20562306a36Sopenharmony_ci * @q:		pointer to &struct vb2_queue with videobuf2 queue.
20662306a36Sopenharmony_ci * @type:	type argument passed from userspace to vidioc_streamoff handler
20762306a36Sopenharmony_ci *
20862306a36Sopenharmony_ci * Should be called from vidioc_streamoff handler of a driver.
20962306a36Sopenharmony_ci *
21062306a36Sopenharmony_ci * This function:
21162306a36Sopenharmony_ci *
21262306a36Sopenharmony_ci * #) verifies current state,
21362306a36Sopenharmony_ci * #) stop streaming and dequeues any queued buffers, including those previously
21462306a36Sopenharmony_ci *    passed to the driver (after waiting for the driver to finish).
21562306a36Sopenharmony_ci *
21662306a36Sopenharmony_ci * This call can be used for pausing playback.
21762306a36Sopenharmony_ci * The return values from this function are intended to be directly returned
21862306a36Sopenharmony_ci * from vidioc_streamoff handler in the driver
21962306a36Sopenharmony_ci */
22062306a36Sopenharmony_ciint vb2_streamoff(struct vb2_queue *q, enum v4l2_buf_type type);
22162306a36Sopenharmony_ci
22262306a36Sopenharmony_ci/**
22362306a36Sopenharmony_ci * vb2_queue_init() - initialize a videobuf2 queue
22462306a36Sopenharmony_ci * @q:		pointer to &struct vb2_queue with videobuf2 queue.
22562306a36Sopenharmony_ci *
22662306a36Sopenharmony_ci * The vb2_queue structure should be allocated by the driver. The driver is
22762306a36Sopenharmony_ci * responsible of clearing it's content and setting initial values for some
22862306a36Sopenharmony_ci * required entries before calling this function.
22962306a36Sopenharmony_ci * q->ops, q->mem_ops, q->type and q->io_modes are mandatory. Please refer
23062306a36Sopenharmony_ci * to the struct vb2_queue description in include/media/videobuf2-core.h
23162306a36Sopenharmony_ci * for more information.
23262306a36Sopenharmony_ci */
23362306a36Sopenharmony_ciint __must_check vb2_queue_init(struct vb2_queue *q);
23462306a36Sopenharmony_ci
23562306a36Sopenharmony_ci/**
23662306a36Sopenharmony_ci * vb2_queue_init_name() - initialize a videobuf2 queue with a name
23762306a36Sopenharmony_ci * @q:		pointer to &struct vb2_queue with videobuf2 queue.
23862306a36Sopenharmony_ci * @name:	the queue name
23962306a36Sopenharmony_ci *
24062306a36Sopenharmony_ci * This function initializes the vb2_queue exactly like vb2_queue_init(),
24162306a36Sopenharmony_ci * and additionally sets the queue name. The queue name is used for logging
24262306a36Sopenharmony_ci * purpose, and should uniquely identify the queue within the context of the
24362306a36Sopenharmony_ci * device it belongs to. This is useful to attribute kernel log messages to the
24462306a36Sopenharmony_ci * right queue for m2m devices or other devices that handle multiple queues.
24562306a36Sopenharmony_ci */
24662306a36Sopenharmony_ciint __must_check vb2_queue_init_name(struct vb2_queue *q, const char *name);
24762306a36Sopenharmony_ci
24862306a36Sopenharmony_ci/**
24962306a36Sopenharmony_ci * vb2_queue_release() - stop streaming, release the queue and free memory
25062306a36Sopenharmony_ci * @q:		pointer to &struct vb2_queue with videobuf2 queue.
25162306a36Sopenharmony_ci *
25262306a36Sopenharmony_ci * This function stops streaming and performs necessary clean ups, including
25362306a36Sopenharmony_ci * freeing video buffer memory. The driver is responsible for freeing
25462306a36Sopenharmony_ci * the vb2_queue structure itself.
25562306a36Sopenharmony_ci */
25662306a36Sopenharmony_civoid vb2_queue_release(struct vb2_queue *q);
25762306a36Sopenharmony_ci
25862306a36Sopenharmony_ci/**
25962306a36Sopenharmony_ci * vb2_queue_change_type() - change the type of an inactive vb2_queue
26062306a36Sopenharmony_ci * @q:		pointer to &struct vb2_queue with videobuf2 queue.
26162306a36Sopenharmony_ci * @type:	the type to change to (V4L2_BUF_TYPE_VIDEO_*)
26262306a36Sopenharmony_ci *
26362306a36Sopenharmony_ci * This function changes the type of the vb2_queue. This is only possible
26462306a36Sopenharmony_ci * if the queue is not busy (i.e. no buffers have been allocated).
26562306a36Sopenharmony_ci *
26662306a36Sopenharmony_ci * vb2_queue_change_type() can be used to support multiple buffer types using
26762306a36Sopenharmony_ci * the same queue. The driver can implement v4l2_ioctl_ops.vidioc_reqbufs and
26862306a36Sopenharmony_ci * v4l2_ioctl_ops.vidioc_create_bufs functions and call vb2_queue_change_type()
26962306a36Sopenharmony_ci * before calling vb2_ioctl_reqbufs() or vb2_ioctl_create_bufs(), and thus
27062306a36Sopenharmony_ci * "lock" the buffer type until the buffers have been released.
27162306a36Sopenharmony_ci */
27262306a36Sopenharmony_ciint vb2_queue_change_type(struct vb2_queue *q, unsigned int type);
27362306a36Sopenharmony_ci
27462306a36Sopenharmony_ci/**
27562306a36Sopenharmony_ci * vb2_poll() - implements poll userspace operation
27662306a36Sopenharmony_ci * @q:		pointer to &struct vb2_queue with videobuf2 queue.
27762306a36Sopenharmony_ci * @file:	file argument passed to the poll file operation handler
27862306a36Sopenharmony_ci * @wait:	wait argument passed to the poll file operation handler
27962306a36Sopenharmony_ci *
28062306a36Sopenharmony_ci * This function implements poll file operation handler for a driver.
28162306a36Sopenharmony_ci * For CAPTURE queues, if a buffer is ready to be dequeued, the userspace will
28262306a36Sopenharmony_ci * be informed that the file descriptor of a video device is available for
28362306a36Sopenharmony_ci * reading.
28462306a36Sopenharmony_ci * For OUTPUT queues, if a buffer is ready to be dequeued, the file descriptor
28562306a36Sopenharmony_ci * will be reported as available for writing.
28662306a36Sopenharmony_ci *
28762306a36Sopenharmony_ci * If the driver uses struct v4l2_fh, then vb2_poll() will also check for any
28862306a36Sopenharmony_ci * pending events.
28962306a36Sopenharmony_ci *
29062306a36Sopenharmony_ci * The return values from this function are intended to be directly returned
29162306a36Sopenharmony_ci * from poll handler in driver.
29262306a36Sopenharmony_ci */
29362306a36Sopenharmony_ci__poll_t vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait);
29462306a36Sopenharmony_ci
29562306a36Sopenharmony_ci/*
29662306a36Sopenharmony_ci * The following functions are not part of the vb2 core API, but are simple
29762306a36Sopenharmony_ci * helper functions that you can use in your struct v4l2_file_operations,
29862306a36Sopenharmony_ci * struct v4l2_ioctl_ops and struct vb2_ops. They will serialize if vb2_queue->lock
29962306a36Sopenharmony_ci * or video_device->lock is set, and they will set and test the queue owner
30062306a36Sopenharmony_ci * (vb2_queue->owner) to check if the calling filehandle is permitted to do the
30162306a36Sopenharmony_ci * queuing operation.
30262306a36Sopenharmony_ci */
30362306a36Sopenharmony_ci
30462306a36Sopenharmony_ci/**
30562306a36Sopenharmony_ci * vb2_queue_is_busy() - check if the queue is busy
30662306a36Sopenharmony_ci * @q:		pointer to &struct vb2_queue with videobuf2 queue.
30762306a36Sopenharmony_ci * @file:	file through which the vb2 queue access is performed
30862306a36Sopenharmony_ci *
30962306a36Sopenharmony_ci * The queue is considered busy if it has an owner and the owner is not the
31062306a36Sopenharmony_ci * @file.
31162306a36Sopenharmony_ci *
31262306a36Sopenharmony_ci * Queue ownership is acquired and checked by some of the v4l2_ioctl_ops helpers
31362306a36Sopenharmony_ci * below. Drivers can also use this function directly when they need to
31462306a36Sopenharmony_ci * open-code ioctl handlers, for instance to add additional checks between the
31562306a36Sopenharmony_ci * queue ownership test and the call to the corresponding vb2 operation.
31662306a36Sopenharmony_ci */
31762306a36Sopenharmony_cistatic inline bool vb2_queue_is_busy(struct vb2_queue *q, struct file *file)
31862306a36Sopenharmony_ci{
31962306a36Sopenharmony_ci	return q->owner && q->owner != file->private_data;
32062306a36Sopenharmony_ci}
32162306a36Sopenharmony_ci
32262306a36Sopenharmony_ci/* struct v4l2_ioctl_ops helpers */
32362306a36Sopenharmony_ci
32462306a36Sopenharmony_ciint vb2_ioctl_reqbufs(struct file *file, void *priv,
32562306a36Sopenharmony_ci			  struct v4l2_requestbuffers *p);
32662306a36Sopenharmony_ciint vb2_ioctl_create_bufs(struct file *file, void *priv,
32762306a36Sopenharmony_ci			  struct v4l2_create_buffers *p);
32862306a36Sopenharmony_ciint vb2_ioctl_prepare_buf(struct file *file, void *priv,
32962306a36Sopenharmony_ci			  struct v4l2_buffer *p);
33062306a36Sopenharmony_ciint vb2_ioctl_querybuf(struct file *file, void *priv, struct v4l2_buffer *p);
33162306a36Sopenharmony_ciint vb2_ioctl_qbuf(struct file *file, void *priv, struct v4l2_buffer *p);
33262306a36Sopenharmony_ciint vb2_ioctl_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p);
33362306a36Sopenharmony_ciint vb2_ioctl_streamon(struct file *file, void *priv, enum v4l2_buf_type i);
33462306a36Sopenharmony_ciint vb2_ioctl_streamoff(struct file *file, void *priv, enum v4l2_buf_type i);
33562306a36Sopenharmony_ciint vb2_ioctl_expbuf(struct file *file, void *priv,
33662306a36Sopenharmony_ci	struct v4l2_exportbuffer *p);
33762306a36Sopenharmony_ci
33862306a36Sopenharmony_ci/* struct v4l2_file_operations helpers */
33962306a36Sopenharmony_ci
34062306a36Sopenharmony_ciint vb2_fop_mmap(struct file *file, struct vm_area_struct *vma);
34162306a36Sopenharmony_ciint vb2_fop_release(struct file *file);
34262306a36Sopenharmony_ciint _vb2_fop_release(struct file *file, struct mutex *lock);
34362306a36Sopenharmony_cissize_t vb2_fop_write(struct file *file, const char __user *buf,
34462306a36Sopenharmony_ci		size_t count, loff_t *ppos);
34562306a36Sopenharmony_cissize_t vb2_fop_read(struct file *file, char __user *buf,
34662306a36Sopenharmony_ci		size_t count, loff_t *ppos);
34762306a36Sopenharmony_ci__poll_t vb2_fop_poll(struct file *file, poll_table *wait);
34862306a36Sopenharmony_ci#ifndef CONFIG_MMU
34962306a36Sopenharmony_ciunsigned long vb2_fop_get_unmapped_area(struct file *file, unsigned long addr,
35062306a36Sopenharmony_ci		unsigned long len, unsigned long pgoff, unsigned long flags);
35162306a36Sopenharmony_ci#endif
35262306a36Sopenharmony_ci
35362306a36Sopenharmony_ci/**
35462306a36Sopenharmony_ci * vb2_video_unregister_device - unregister the video device and release queue
35562306a36Sopenharmony_ci *
35662306a36Sopenharmony_ci * @vdev: pointer to &struct video_device
35762306a36Sopenharmony_ci *
35862306a36Sopenharmony_ci * If the driver uses vb2_fop_release()/_vb2_fop_release(), then it should use
35962306a36Sopenharmony_ci * vb2_video_unregister_device() instead of video_unregister_device().
36062306a36Sopenharmony_ci *
36162306a36Sopenharmony_ci * This function will call video_unregister_device() and then release the
36262306a36Sopenharmony_ci * vb2_queue if streaming is in progress. This will stop streaming and
36362306a36Sopenharmony_ci * this will simplify the unbind sequence since after this call all subdevs
36462306a36Sopenharmony_ci * will have stopped streaming as well.
36562306a36Sopenharmony_ci */
36662306a36Sopenharmony_civoid vb2_video_unregister_device(struct video_device *vdev);
36762306a36Sopenharmony_ci
36862306a36Sopenharmony_ci/**
36962306a36Sopenharmony_ci * vb2_ops_wait_prepare - helper function to lock a struct &vb2_queue
37062306a36Sopenharmony_ci *
37162306a36Sopenharmony_ci * @vq: pointer to &struct vb2_queue
37262306a36Sopenharmony_ci *
37362306a36Sopenharmony_ci * ..note:: only use if vq->lock is non-NULL.
37462306a36Sopenharmony_ci */
37562306a36Sopenharmony_civoid vb2_ops_wait_prepare(struct vb2_queue *vq);
37662306a36Sopenharmony_ci
37762306a36Sopenharmony_ci/**
37862306a36Sopenharmony_ci * vb2_ops_wait_finish - helper function to unlock a struct &vb2_queue
37962306a36Sopenharmony_ci *
38062306a36Sopenharmony_ci * @vq: pointer to &struct vb2_queue
38162306a36Sopenharmony_ci *
38262306a36Sopenharmony_ci * ..note:: only use if vq->lock is non-NULL.
38362306a36Sopenharmony_ci */
38462306a36Sopenharmony_civoid vb2_ops_wait_finish(struct vb2_queue *vq);
38562306a36Sopenharmony_ci
38662306a36Sopenharmony_cistruct media_request;
38762306a36Sopenharmony_ciint vb2_request_validate(struct media_request *req);
38862306a36Sopenharmony_civoid vb2_request_queue(struct media_request *req);
38962306a36Sopenharmony_ci
39062306a36Sopenharmony_ci#endif /* _MEDIA_VIDEOBUF2_V4L2_H */
391