mirror of
https://github.com/torvalds/linux.git
synced 2024-11-24 21:21:41 +00:00
[media] v4l: add buffer exporting via dmabuf
This patch adds extension to V4L2 api. A new ioctl VIDIOC_EXPBUF is added. The ioctl is used to export an mmap buffer as a DMABUF file descriptor. Signed-off-by: Tomasz Stanislawski <t.stanislaws@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Tested-by: Mauro Carvalho Chehab <mchehab@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
parent
c60520fa50
commit
b799d09a15
@ -1018,6 +1018,7 @@ long v4l2_compat_ioctl32(struct file *file, unsigned int cmd, unsigned long arg)
|
||||
case VIDIOC_S_FBUF32:
|
||||
case VIDIOC_OVERLAY32:
|
||||
case VIDIOC_QBUF32:
|
||||
case VIDIOC_EXPBUF:
|
||||
case VIDIOC_DQBUF32:
|
||||
case VIDIOC_STREAMON32:
|
||||
case VIDIOC_STREAMOFF32:
|
||||
|
@ -571,6 +571,7 @@ static void determine_valid_ioctls(struct video_device *vdev)
|
||||
SET_VALID_IOCTL(ops, VIDIOC_REQBUFS, vidioc_reqbufs);
|
||||
SET_VALID_IOCTL(ops, VIDIOC_QUERYBUF, vidioc_querybuf);
|
||||
SET_VALID_IOCTL(ops, VIDIOC_QBUF, vidioc_qbuf);
|
||||
SET_VALID_IOCTL(ops, VIDIOC_EXPBUF, vidioc_expbuf);
|
||||
SET_VALID_IOCTL(ops, VIDIOC_DQBUF, vidioc_dqbuf);
|
||||
SET_VALID_IOCTL(ops, VIDIOC_STREAMON, vidioc_streamon);
|
||||
SET_VALID_IOCTL(ops, VIDIOC_STREAMOFF, vidioc_streamoff);
|
||||
|
@ -454,6 +454,15 @@ static void v4l_print_buffer(const void *arg, bool write_only)
|
||||
tc->type, tc->flags, tc->frames, *(__u32 *)tc->userbits);
|
||||
}
|
||||
|
||||
static void v4l_print_exportbuffer(const void *arg, bool write_only)
|
||||
{
|
||||
const struct v4l2_exportbuffer *p = arg;
|
||||
|
||||
pr_cont("fd=%d, type=%s, index=%u, plane=%u, flags=0x%08x\n",
|
||||
p->fd, prt_names(p->type, v4l2_type_names),
|
||||
p->index, p->plane, p->flags);
|
||||
}
|
||||
|
||||
static void v4l_print_create_buffers(const void *arg, bool write_only)
|
||||
{
|
||||
const struct v4l2_create_buffers *p = arg;
|
||||
@ -1961,6 +1970,7 @@ static struct v4l2_ioctl_info v4l2_ioctls[] = {
|
||||
IOCTL_INFO_STD(VIDIOC_S_FBUF, vidioc_s_fbuf, v4l_print_framebuffer, INFO_FL_PRIO),
|
||||
IOCTL_INFO_FNC(VIDIOC_OVERLAY, v4l_overlay, v4l_print_u32, INFO_FL_PRIO),
|
||||
IOCTL_INFO_FNC(VIDIOC_QBUF, v4l_qbuf, v4l_print_buffer, INFO_FL_QUEUE),
|
||||
IOCTL_INFO_STD(VIDIOC_EXPBUF, vidioc_expbuf, v4l_print_exportbuffer, INFO_FL_QUEUE | INFO_FL_CLEAR(v4l2_exportbuffer, flags)),
|
||||
IOCTL_INFO_FNC(VIDIOC_DQBUF, v4l_dqbuf, v4l_print_buffer, INFO_FL_QUEUE),
|
||||
IOCTL_INFO_FNC(VIDIOC_STREAMON, v4l_streamon, v4l_print_buftype, INFO_FL_PRIO | INFO_FL_QUEUE),
|
||||
IOCTL_INFO_FNC(VIDIOC_STREAMOFF, v4l_streamoff, v4l_print_buftype, INFO_FL_PRIO | INFO_FL_QUEUE),
|
||||
|
@ -111,6 +111,8 @@ struct v4l2_ioctl_ops {
|
||||
int (*vidioc_reqbufs) (struct file *file, void *fh, struct v4l2_requestbuffers *b);
|
||||
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_expbuf) (struct file *file, void *fh,
|
||||
struct v4l2_exportbuffer *e);
|
||||
int (*vidioc_dqbuf) (struct file *file, void *fh, struct v4l2_buffer *b);
|
||||
|
||||
int (*vidioc_create_bufs)(struct file *file, void *fh, struct v4l2_create_buffers *b);
|
||||
|
@ -694,6 +694,33 @@ struct v4l2_buffer {
|
||||
#define V4L2_BUF_FLAG_NO_CACHE_INVALIDATE 0x0800
|
||||
#define V4L2_BUF_FLAG_NO_CACHE_CLEAN 0x1000
|
||||
|
||||
/**
|
||||
* struct v4l2_exportbuffer - export of video buffer as DMABUF file descriptor
|
||||
*
|
||||
* @index: id number of the buffer
|
||||
* @type: enum v4l2_buf_type; buffer type (type == *_MPLANE for
|
||||
* multiplanar buffers);
|
||||
* @plane: index of the plane to be exported, 0 for single plane queues
|
||||
* @flags: flags for newly created file, currently only O_CLOEXEC is
|
||||
* supported, refer to manual of open syscall for more details
|
||||
* @fd: file descriptor associated with DMABUF (set by driver)
|
||||
*
|
||||
* Contains data used for exporting a video buffer as DMABUF file descriptor.
|
||||
* The buffer is identified by a 'cookie' returned by VIDIOC_QUERYBUF
|
||||
* (identical to the cookie used to mmap() the buffer to userspace). All
|
||||
* reserved fields must be set to zero. The field reserved0 is expected to
|
||||
* become a structure 'type' allowing an alternative layout of the structure
|
||||
* content. Therefore this field should not be used for any other extensions.
|
||||
*/
|
||||
struct v4l2_exportbuffer {
|
||||
__u32 type; /* enum v4l2_buf_type */
|
||||
__u32 index;
|
||||
__u32 plane;
|
||||
__u32 flags;
|
||||
__s32 fd;
|
||||
__u32 reserved[11];
|
||||
};
|
||||
|
||||
/*
|
||||
* O V E R L A Y P R E V I E W
|
||||
*/
|
||||
@ -1895,6 +1922,7 @@ struct v4l2_create_buffers {
|
||||
#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, struct v4l2_exportbuffer)
|
||||
#define VIDIOC_DQBUF _IOWR('V', 17, struct v4l2_buffer)
|
||||
#define VIDIOC_STREAMON _IOW('V', 18, int)
|
||||
#define VIDIOC_STREAMOFF _IOW('V', 19, int)
|
||||
|
Loading…
Reference in New Issue
Block a user