diff mbox series

[RFC,3/3] media: rkisp1-params: Override vb2_queue.buf_ops

Message ID 20240603152548.107158-4-jacopo.mondi@ideasonboard.com
State New
Headers show
Series [RFC,1/3] media: videobuf2: WARN if !vb2_queue.buf_ops | expand

Commit Message

Jacopo Mondi June 3, 2024, 3:25 p.m. UTC
Override the implementation of vb2_queue.buf_ops to allow a
driver-specific behaviour in the buffer initialization operation.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
 .../platform/rockchip/rkisp1/rkisp1-params.c   | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-params.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-params.c
index 0290f25a4ab6..4bb92d076e84 100644
--- a/drivers/media/platform/rockchip/rkisp1/rkisp1-params.c
+++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-params.c
@@ -2455,6 +2455,21 @@  static const struct vb2_ops rkisp1_params_vb2_ops = {
 
 };
 
+static void rkisp1_params_vb2_buf_init_buffer(struct vb2_buffer *vb)
+{
+	/* TODO */
+
+	vb2_buf_init_buffer(vb);
+}
+
+static const struct vb2_buf_ops rkisp1_params_vb2_buf_ops = {
+	.verify_planes_array	= vb2_buf_verify_planes_array,
+	.init_buffer		= rkisp1_params_vb2_buf_init_buffer,
+	.fill_user_buffer	= vb2_buf_fill_v4l2_buffer,
+	.fill_vb2_buffer	= vb2_buf_fill_vb2_buffer,
+	.copy_timestamp		= vb2_buf_copy_timestamp,
+};
+
 static const struct v4l2_file_operations rkisp1_params_fops = {
 	.mmap = vb2_fop_mmap,
 	.unlocked_ioctl = video_ioctl2,
@@ -2474,12 +2489,13 @@  static int rkisp1_params_init_vb2_queue(struct vb2_queue *q,
 	q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF;
 	q->drv_priv = params;
 	q->ops = &rkisp1_params_vb2_ops;
+	q->buf_ops = &rkisp1_params_vb2_buf_ops;
 	q->mem_ops = &vb2_vmalloc_memops;
 	q->buf_struct_size = sizeof(struct rkisp1_buffer);
 	q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
 	q->lock = &node->vlock;
 
-	return vb2_queue_init(q);
+	return  vb2_queue_init(q);
 }
 
 int rkisp1_params_register(struct rkisp1_device *rkisp1)