Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

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