From: Gustavo Padovan <gustavo@padovan.org>
To: linux-media@vger.kernel.org
Cc: Hans Verkuil <hverkuil@xs4all.nl>,
Mauro Carvalho Chehab <mchehab@osg.samsung.com>,
Shuah Khan <shuahkh@osg.samsung.com>,
Pawel Osciak <pawel@osciak.com>,
Alexandre Courbot <acourbot@chromium.org>,
Sakari Ailus <sakari.ailus@iki.fi>,
Brian Starkey <brian.starkey@arm.com>,
Thierry Escande <thierry.escande@collabora.com>,
linux-kernel@vger.kernel.org,
Gustavo Padovan <gustavo.padovan@collabora.com>
Subject: [PATCH v7 3/6] [media] vb2: add explicit fence user API
Date: Wed, 10 Jan 2018 14:07:29 -0200 [thread overview]
Message-ID: <20180110160732.7722-4-gustavo@padovan.org> (raw)
In-Reply-To: <20180110160732.7722-1-gustavo@padovan.org>
From: Gustavo Padovan <gustavo.padovan@collabora.com>
Turn the reserved2 field into fence_fd that we will use to send
an in-fence to the kernel and return an out-fence from the kernel to
userspace.
Two new flags were added, V4L2_BUF_FLAG_IN_FENCE, that should be used
when sending a fence to the kernel to be waited on, and
V4L2_BUF_FLAG_OUT_FENCE, to ask the kernel to give back an out-fence.
v5:
- keep using reserved2 field for cpia2
- set fence_fd to 0 for now, for compat with userspace(Mauro)
v4:
- make it a union with reserved2 and fence_fd (Hans Verkuil)
v3:
- make the out_fence refer to the current buffer (Hans Verkuil)
v2: add documentation
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.com>
---
Documentation/media/uapi/v4l/buffer.rst | 15 +++++++++++++++
drivers/media/common/videobuf/videobuf2-v4l2.c | 2 +-
drivers/media/v4l2-core/v4l2-compat-ioctl32.c | 4 ++--
include/uapi/linux/videodev2.h | 7 ++++++-
4 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/Documentation/media/uapi/v4l/buffer.rst b/Documentation/media/uapi/v4l/buffer.rst
index ae6ee73f151c..eeefbd2547e7 100644
--- a/Documentation/media/uapi/v4l/buffer.rst
+++ b/Documentation/media/uapi/v4l/buffer.rst
@@ -648,6 +648,21 @@ Buffer Flags
- Start Of Exposure. The buffer timestamp has been taken when the
exposure of the frame has begun. This is only valid for the
``V4L2_BUF_TYPE_VIDEO_CAPTURE`` buffer type.
+ * .. _`V4L2-BUF-FLAG-IN-FENCE`:
+
+ - ``V4L2_BUF_FLAG_IN_FENCE``
+ - 0x00200000
+ - Ask V4L2 to wait on fence passed in ``fence_fd`` field. The buffer
+ won't be queued to the driver until the fence signals.
+
+ * .. _`V4L2-BUF-FLAG-OUT-FENCE`:
+
+ - ``V4L2_BUF_FLAG_OUT_FENCE``
+ - 0x00400000
+ - Request a fence to be attached to the buffer. The ``fence_fd``
+ field on
+ :ref:`VIDIOC_QBUF` is used as a return argument to send the out-fence
+ fd to userspace.
diff --git a/drivers/media/common/videobuf/videobuf2-v4l2.c b/drivers/media/common/videobuf/videobuf2-v4l2.c
index fac3cd6f901d..d838524a459e 100644
--- a/drivers/media/common/videobuf/videobuf2-v4l2.c
+++ b/drivers/media/common/videobuf/videobuf2-v4l2.c
@@ -203,7 +203,7 @@ static void __fill_v4l2_buffer(struct vb2_buffer *vb, void *pb)
b->timestamp = ns_to_timeval(vb->timestamp);
b->timecode = vbuf->timecode;
b->sequence = vbuf->sequence;
- b->reserved2 = 0;
+ b->fence_fd = 0;
b->reserved = 0;
if (q->is_multiplanar) {
diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
index e48d59046086..a11a0a2bed47 100644
--- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
+++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
@@ -370,7 +370,7 @@ struct v4l2_buffer32 {
__s32 fd;
} m;
__u32 length;
- __u32 reserved2;
+ __s32 fence_fd;
__u32 reserved;
};
@@ -533,7 +533,7 @@ static int put_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user
put_user(kp->timestamp.tv_usec, &up->timestamp.tv_usec) ||
copy_to_user(&up->timecode, &kp->timecode, sizeof(struct v4l2_timecode)) ||
put_user(kp->sequence, &up->sequence) ||
- put_user(kp->reserved2, &up->reserved2) ||
+ put_user(kp->fence_fd, &up->fence_fd) ||
put_user(kp->reserved, &up->reserved) ||
put_user(kp->length, &up->length))
return -EFAULT;
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 58894cfe9479..2d424aebdd1e 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -933,7 +933,10 @@ struct v4l2_buffer {
__s32 fd;
} m;
__u32 length;
- __u32 reserved2;
+ union {
+ __s32 fence_fd;
+ __u32 reserved2;
+ };
__u32 reserved;
};
@@ -970,6 +973,8 @@ struct v4l2_buffer {
#define V4L2_BUF_FLAG_TSTAMP_SRC_SOE 0x00010000
/* mem2mem encoder/decoder */
#define V4L2_BUF_FLAG_LAST 0x00100000
+#define V4L2_BUF_FLAG_IN_FENCE 0x00200000
+#define V4L2_BUF_FLAG_OUT_FENCE 0x00400000
/**
* struct v4l2_exportbuffer - export of video buffer as DMABUF file descriptor
--
2.14.3
next prev parent reply other threads:[~2018-01-10 16:10 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-10 16:07 [PATCH v7 0/6] V4L2 Explicit Synchronization Gustavo Padovan
2018-01-10 16:07 ` [PATCH v7 1/6] [media] vb2: add is_unordered callback for drivers Gustavo Padovan
2018-01-12 11:57 ` Hans Verkuil
2018-01-15 7:11 ` Alexandre Courbot
2018-01-15 12:01 ` Gustavo Padovan
2018-01-15 12:14 ` Hans Verkuil
2018-01-15 17:55 ` Gustavo Padovan
2018-01-16 2:35 ` Alexandre Courbot
2018-01-10 16:07 ` [PATCH v7 2/6] [media] v4l: add 'unordered' flag to format description ioctl Gustavo Padovan
2018-01-12 12:05 ` Hans Verkuil
2018-01-10 16:07 ` Gustavo Padovan [this message]
2018-01-12 12:15 ` [PATCH v7 3/6] [media] vb2: add explicit fence user API Hans Verkuil
2018-01-12 12:20 ` Hans Verkuil
2018-01-10 16:07 ` [PATCH v7 4/6] [media] vb2: add in-fence support to QBUF Gustavo Padovan
2018-01-12 13:46 ` Hans Verkuil
2018-01-18 17:38 ` Gustavo Padovan
2018-01-10 16:07 ` [PATCH v7 5/6] [media] vb2: add out-fence " Gustavo Padovan
2018-01-12 14:05 ` Hans Verkuil
2018-01-19 13:12 ` Gustavo Padovan
2018-01-15 7:12 ` Alexandre Courbot
2018-01-19 13:43 ` Gustavo Padovan
2018-01-10 16:07 ` [PATCH v7 6/6] [media] v4l: Document explicit synchronization behavior Gustavo Padovan
2018-01-12 14:48 ` Hans Verkuil
2018-01-10 16:44 ` [PATCH v7 0/6] V4L2 Explicit Synchronization Nicolas Dufresne
2018-01-10 17:11 ` Gustavo Padovan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180110160732.7722-4-gustavo@padovan.org \
--to=gustavo@padovan.org \
--cc=acourbot@chromium.org \
--cc=brian.starkey@arm.com \
--cc=gustavo.padovan@collabora.com \
--cc=hverkuil@xs4all.nl \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@osg.samsung.com \
--cc=pawel@osciak.com \
--cc=sakari.ailus@iki.fi \
--cc=shuahkh@osg.samsung.com \
--cc=thierry.escande@collabora.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox