From: Marek Szyprowski <m.szyprowski@samsung.com>
To: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: linaro-mm-sig@lists.linaro.org, linux-media@vger.kernel.org,
Tomasz Stanislawski <t.stanislaws@samsung.com>,
Kyungmin Park <kyungmin.park@samsung.com>
Subject: [PATCH 2/6] v4l: add buffer exporting via shrbuf
Date: Tue, 02 Aug 2011 11:50:59 +0200 [thread overview]
Message-ID: <4E37C883.4040102@samsung.com> (raw)
In-Reply-To: <4E37C7D7.40301@samsung.com>
From: Tomasz Stanislawski <t.stanislaws@samsung.com>
This patch adds extension to V4L2 api. It allow to export a mmap buffer
as file
descriptor. New ioctl VIDIOC_EXPBUF is added. It takes a buffer offset
used by
mmap and return a file descriptor on success.
Signed-off-by: Tomasz Stanislawski <t.stanislaws@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
drivers/media/video/v4l2-ioctl.c | 10 ++++++++++
include/linux/videodev2.h | 8 ++++++++
include/media/v4l2-ioctl.h | 1 +
3 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/drivers/media/video/v4l2-ioctl.c
b/drivers/media/video/v4l2-ioctl.c
index 660b486..0a19fd4 100644
--- a/drivers/media/video/v4l2-ioctl.c
+++ b/drivers/media/video/v4l2-ioctl.c
@@ -1145,6 +1145,16 @@ static long __video_do_ioctl(struct file *file,
dbgbuf(cmd, vfd, p);
break;
}
+ case VIDIOC_EXPBUF:
+ {
+ unsigned int *p = arg;
+
+ if (!ops->vidioc_expbuf)
+ break;
+
+ ret = ops->vidioc_expbuf(file, fh, *p);
+ break;
+ }
case VIDIOC_DQBUF:
{
struct v4l2_buffer *p = arg;
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index 7c77c4e..cae7908 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -185,6 +185,7 @@ enum v4l2_memory {
V4L2_MEMORY_MMAP = 1,
V4L2_MEMORY_USERPTR = 2,
V4L2_MEMORY_OVERLAY = 3,
+ V4L2_MEMORY_SHRBUF = 4,
};
/* see also http://vektor.theorem.ca/graphics/ycbcr/ */
@@ -564,6 +565,8 @@ struct v4l2_requestbuffers {
* should be passed to mmap() called on the video node)
* @userptr: when memory is V4L2_MEMORY_USERPTR, a userspace
pointer
* pointing to this plane
+ * @fd: when memory is V4L2_MEMORY_SHRBUF, a userspace file
+ * descriptor associated with this plane
* @data_offset: offset in the plane to the start of data; usually 0,
* unless there is a header in front of the data
*
@@ -578,6 +581,7 @@ struct v4l2_plane {
union {
__u32 mem_offset;
unsigned long userptr;
+ int fd;
} m;
__u32 data_offset;
__u32 reserved[11];
@@ -600,6 +604,8 @@ struct v4l2_plane {
* (or a "cookie" that should be passed to mmap() as offset)
* @userptr: for non-multiplanar buffers with memory ==
V4L2_MEMORY_USERPTR;
* a userspace pointer pointing to this buffer
+ * @fd: for non-multiplanar buffers with memory ==
V4L2_MEMORY_SHRBUF;
+ * a userspace file descriptor associated with this buffer
* @planes: for multiplanar buffers; userspace pointer to the array
of plane
* info structs for this buffer
* @length: size in bytes of the buffer (NOT its payload) for
single-plane
@@ -626,6 +632,7 @@ struct v4l2_buffer {
__u32 offset;
unsigned long userptr;
struct v4l2_plane *planes;
+ int fd;
} m;
__u32 length;
__u32 input;
@@ -1868,6 +1875,7 @@ struct v4l2_dbg_chip_ident {
#define VIDIOC_S_FBUF _IOW('V', 11, struct v4l2_framebuffer)
#define VIDIOC_OVERLAY _IOW('V', 14, int)
#define VIDIOC_QBUF _IOWR('V', 15, struct v4l2_buffer)
+#define VIDIOC_EXPBUF _IOWR('V', 16, unsigned int)
#define VIDIOC_DQBUF _IOWR('V', 17, struct v4l2_buffer)
#define VIDIOC_STREAMON _IOW('V', 18, int)
#define VIDIOC_STREAMOFF _IOW('V', 19, int)
diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
index dd9f1e7..20932e3 100644
--- a/include/media/v4l2-ioctl.h
+++ b/include/media/v4l2-ioctl.h
@@ -121,6 +121,7 @@ struct v4l2_ioctl_ops {
int (*vidioc_querybuf)(struct file *file, void *fh, struct
v4l2_buffer *b);
int (*vidioc_qbuf) (struct file *file, void *fh, struct
v4l2_buffer *b);
int (*vidioc_dqbuf) (struct file *file, void *fh, struct
v4l2_buffer *b);
+ int (*vidioc_expbuf) (struct file *file, void *fh, unsigned int
offset);
int (*vidioc_overlay) (struct file *file, void *fh, unsigned int i);
--
1.7.6
next prev parent reply other threads:[~2011-08-02 9:51 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-02 9:48 Buffer sharing proof-of-concept Marek Szyprowski
2011-08-02 9:49 ` [PATCH 1/6] drivers: base: add shared buffer framework Marek Szyprowski
2011-08-02 18:09 ` [Linaro-mm-sig] " Clark, Rob
2011-08-02 9:50 ` Marek Szyprowski [this message]
2011-08-02 9:52 ` [PATCH 3/6] v4l: vb2: add support for shared buffer (shrbuf) Marek Szyprowski
2011-08-02 9:53 ` [PATCH 4/6] v4l: vb2: integrate dma-contig allocator with shrbuf Marek Szyprowski
2011-08-02 9:53 ` [PATCH 5/6] v4l: fimc: integrate capture i-face " Marek Szyprowski
2011-08-02 9:54 ` [PATCH 6/6] v4l: s5p-tv: mixer: integrate " Marek Szyprowski
2011-08-02 11:59 ` [Linaro-mm-sig] Buffer sharing proof-of-concept KyongHo Cho
2011-08-02 14:48 ` Marek Szyprowski
2011-08-02 15:44 ` Jordan Crouse
2011-08-03 9:33 ` Tom Cooksey
2011-08-03 15:12 ` Jordan Crouse
2011-08-04 8:58 ` Daniel Vetter
2011-08-04 11:14 ` Clark, Rob
2011-08-04 12:34 ` Daniel Vetter
2011-08-04 16:19 ` Clark, Rob
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=4E37C883.4040102@samsung.com \
--to=m.szyprowski@samsung.com \
--cc=kyungmin.park@samsung.com \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-media@vger.kernel.org \
--cc=t.stanislaws@samsung.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.