hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/include/media/videobuf2-v4l2.h
....@@ -13,6 +13,7 @@
1313 #define _MEDIA_VIDEOBUF2_V4L2_H
1414
1515 #include <linux/videodev2.h>
16
+#include <linux/android_kabi.h>
1617 #include <media/videobuf2-core.h>
1718
1819 #if VB2_MAX_FRAME != VIDEO_MAX_FRAME
....@@ -23,6 +24,8 @@
2324 #error VB2_MAX_PLANES != VIDEO_MAX_PLANES
2425 #endif
2526
27
+struct video_device;
28
+
2629 /**
2730 * struct vb2_v4l2_buffer - video buffer information for v4l2.
2831 *
....@@ -32,6 +35,9 @@
3235 * &enum v4l2_field.
3336 * @timecode: frame timecode.
3437 * @sequence: sequence count of this frame.
38
+ * @request_fd: the request_fd associated with this buffer
39
+ * @is_held: if true, then this capture buffer was held
40
+ * @planes: plane information (userptr/fd, length, bytesused, data_offset).
3541 *
3642 * Should contain enough information to be able to cover all the fields
3743 * of &struct v4l2_buffer at ``videodev2.h``.
....@@ -43,13 +49,37 @@
4349 __u32 field;
4450 struct v4l2_timecode timecode;
4551 __u32 sequence;
52
+ __s32 request_fd;
53
+ bool is_held;
54
+ struct vb2_plane planes[VB2_MAX_PLANES];
55
+
56
+ ANDROID_KABI_RESERVE(1);
4657 };
58
+
59
+/* VB2 V4L2 flags as set in vb2_queue.subsystem_flags */
60
+#define VB2_V4L2_FL_SUPPORTS_M2M_HOLD_CAPTURE_BUF (1 << 0)
4761
4862 /*
4963 * to_vb2_v4l2_buffer() - cast struct vb2_buffer * to struct vb2_v4l2_buffer *
5064 */
5165 #define to_vb2_v4l2_buffer(vb) \
5266 container_of(vb, struct vb2_v4l2_buffer, vb2_buf)
67
+
68
+/**
69
+ * vb2_find_timestamp() - Find buffer with given timestamp in the queue
70
+ *
71
+ * @q: pointer to &struct vb2_queue with videobuf2 queue.
72
+ * @timestamp: the timestamp to find.
73
+ * @start_idx: the start index (usually 0) in the buffer array to start
74
+ * searching from. Note that there may be multiple buffers
75
+ * with the same timestamp value, so you can restart the search
76
+ * by setting @start_idx to the previously found index + 1.
77
+ *
78
+ * Returns the buffer index of the buffer with the given @timestamp, or
79
+ * -1 if no buffer with @timestamp was found.
80
+ */
81
+int vb2_find_timestamp(const struct vb2_queue *q, u64 timestamp,
82
+ unsigned int start_idx);
5383
5484 int vb2_querybuf(struct vb2_queue *q, struct v4l2_buffer *b);
5585
....@@ -77,6 +107,7 @@
77107 * vb2_prepare_buf() - Pass ownership of a buffer from userspace to the kernel
78108 *
79109 * @q: pointer to &struct vb2_queue with videobuf2 queue.
110
+ * @mdev: pointer to &struct media_device, may be NULL.
80111 * @b: buffer structure passed from userspace to
81112 * &v4l2_ioctl_ops->vidioc_prepare_buf handler in driver
82113 *
....@@ -88,15 +119,19 @@
88119 * #) verifies the passed buffer,
89120 * #) calls &vb2_ops->buf_prepare callback in the driver (if provided),
90121 * in which driver-specific buffer initialization can be performed.
122
+ * #) if @b->request_fd is non-zero and @mdev->ops->req_queue is set,
123
+ * then bind the prepared buffer to the request.
91124 *
92125 * The return values from this function are intended to be directly returned
93126 * from &v4l2_ioctl_ops->vidioc_prepare_buf handler in driver.
94127 */
95
-int vb2_prepare_buf(struct vb2_queue *q, struct v4l2_buffer *b);
128
+int vb2_prepare_buf(struct vb2_queue *q, struct media_device *mdev,
129
+ struct v4l2_buffer *b);
96130
97131 /**
98132 * vb2_qbuf() - Queue a buffer from userspace
99133 * @q: pointer to &struct vb2_queue with videobuf2 queue.
134
+ * @mdev: pointer to &struct media_device, may be NULL.
100135 * @b: buffer structure passed from userspace to
101136 * &v4l2_ioctl_ops->vidioc_qbuf handler in driver
102137 *
....@@ -105,6 +140,8 @@
105140 * This function:
106141 *
107142 * #) verifies the passed buffer;
143
+ * #) if @b->request_fd is non-zero and @mdev->ops->req_queue is set,
144
+ * then bind the buffer to the request.
108145 * #) if necessary, calls &vb2_ops->buf_prepare callback in the driver
109146 * (if provided), in which driver-specific buffer initialization can
110147 * be performed;
....@@ -114,7 +151,8 @@
114151 * The return values from this function are intended to be directly returned
115152 * from &v4l2_ioctl_ops->vidioc_qbuf handler in driver.
116153 */
117
-int vb2_qbuf(struct vb2_queue *q, struct v4l2_buffer *b);
154
+int vb2_qbuf(struct vb2_queue *q, struct media_device *mdev,
155
+ struct v4l2_buffer *b);
118156
119157 /**
120158 * vb2_expbuf() - Export a buffer as a file descriptor
....@@ -204,6 +242,19 @@
204242 int __must_check vb2_queue_init(struct vb2_queue *q);
205243
206244 /**
245
+ * vb2_queue_init_name() - initialize a videobuf2 queue with a name
246
+ * @q: pointer to &struct vb2_queue with videobuf2 queue.
247
+ * @name: the queue name
248
+ *
249
+ * This function initializes the vb2_queue exactly like vb2_queue_init(),
250
+ * and additionally sets the queue name. The queue name is used for logging
251
+ * purpose, and should uniquely identify the queue within the context of the
252
+ * device it belongs to. This is useful to attribute kernel log messages to the
253
+ * right queue for m2m devices or other devices that handle multiple queues.
254
+ */
255
+int __must_check vb2_queue_init_name(struct vb2_queue *q, const char *name);
256
+
257
+/**
207258 * vb2_queue_release() - stop streaming, release the queue and free memory
208259 * @q: pointer to &struct vb2_queue with videobuf2 queue.
209260 *
....@@ -274,6 +325,21 @@
274325 #endif
275326
276327 /**
328
+ * vb2_video_unregister_device - unregister the video device and release queue
329
+ *
330
+ * @vdev: pointer to &struct video_device
331
+ *
332
+ * If the driver uses vb2_fop_release()/_vb2_fop_release(), then it should use
333
+ * vb2_video_unregister_device() instead of video_unregister_device().
334
+ *
335
+ * This function will call video_unregister_device() and then release the
336
+ * vb2_queue if streaming is in progress. This will stop streaming and
337
+ * this will simplify the unbind sequence since after this call all subdevs
338
+ * will have stopped streaming as well.
339
+ */
340
+void vb2_video_unregister_device(struct video_device *vdev);
341
+
342
+/**
277343 * vb2_ops_wait_prepare - helper function to lock a struct &vb2_queue
278344 *
279345 * @vq: pointer to &struct vb2_queue
....@@ -291,4 +357,8 @@
291357 */
292358 void vb2_ops_wait_finish(struct vb2_queue *vq);
293359
360
+struct media_request;
361
+int vb2_request_validate(struct media_request *req);
362
+void vb2_request_queue(struct media_request *req);
363
+
294364 #endif /* _MEDIA_VIDEOBUF2_V4L2_H */