mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-14 05:36:42 +07:00
media: vb2: set reqbufs/create_bufs capabilities
Set the capabilities field of v4l2_requestbuffers and v4l2_create_buffers. The various mapping modes were easy, but for signaling the request capability a new 'supports_requests' bitfield was added to videobuf2-core.h (and set in vim2m and vivid). Drivers have to set this bitfield for any queue where requests are supported. Signed-off-by: Hans Verkuil <hansverk@cisco.com> Reviewed-by: Tomasz Figa <tfiga@chromium.org> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
This commit is contained in:
parent
f35f5d72e7
commit
e5079cf113
@ -384,7 +384,7 @@ static int vb2_queue_or_prepare_buf(struct vb2_queue *q, struct media_device *md
|
|||||||
return -EPERM;
|
return -EPERM;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
} else if (q->uses_qbuf) {
|
} else if (q->uses_qbuf || !q->supports_requests) {
|
||||||
dprintk(1, "%s: queue does not use requests\n", opname);
|
dprintk(1, "%s: queue does not use requests\n", opname);
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
}
|
}
|
||||||
@ -619,10 +619,24 @@ int vb2_querybuf(struct vb2_queue *q, struct v4l2_buffer *b)
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL(vb2_querybuf);
|
EXPORT_SYMBOL(vb2_querybuf);
|
||||||
|
|
||||||
|
static void fill_buf_caps(struct vb2_queue *q, u32 *caps)
|
||||||
|
{
|
||||||
|
*caps = 0;
|
||||||
|
if (q->io_modes & VB2_MMAP)
|
||||||
|
*caps |= V4L2_BUF_CAP_SUPPORTS_MMAP;
|
||||||
|
if (q->io_modes & VB2_USERPTR)
|
||||||
|
*caps |= V4L2_BUF_CAP_SUPPORTS_USERPTR;
|
||||||
|
if (q->io_modes & VB2_DMABUF)
|
||||||
|
*caps |= V4L2_BUF_CAP_SUPPORTS_DMABUF;
|
||||||
|
if (q->supports_requests)
|
||||||
|
*caps |= V4L2_BUF_CAP_SUPPORTS_REQUESTS;
|
||||||
|
}
|
||||||
|
|
||||||
int vb2_reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req)
|
int vb2_reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req)
|
||||||
{
|
{
|
||||||
int ret = vb2_verify_memory_type(q, req->memory, req->type);
|
int ret = vb2_verify_memory_type(q, req->memory, req->type);
|
||||||
|
|
||||||
|
fill_buf_caps(q, &req->capabilities);
|
||||||
return ret ? ret : vb2_core_reqbufs(q, req->memory, &req->count);
|
return ret ? ret : vb2_core_reqbufs(q, req->memory, &req->count);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(vb2_reqbufs);
|
EXPORT_SYMBOL_GPL(vb2_reqbufs);
|
||||||
@ -654,6 +668,7 @@ int vb2_create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create)
|
|||||||
int ret = vb2_verify_memory_type(q, create->memory, f->type);
|
int ret = vb2_verify_memory_type(q, create->memory, f->type);
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
|
fill_buf_caps(q, &create->capabilities);
|
||||||
create->index = q->num_buffers;
|
create->index = q->num_buffers;
|
||||||
if (create->count == 0)
|
if (create->count == 0)
|
||||||
return ret != -EBUSY ? ret : 0;
|
return ret != -EBUSY ? ret : 0;
|
||||||
@ -861,6 +876,7 @@ int vb2_ioctl_reqbufs(struct file *file, void *priv,
|
|||||||
struct video_device *vdev = video_devdata(file);
|
struct video_device *vdev = video_devdata(file);
|
||||||
int res = vb2_verify_memory_type(vdev->queue, p->memory, p->type);
|
int res = vb2_verify_memory_type(vdev->queue, p->memory, p->type);
|
||||||
|
|
||||||
|
fill_buf_caps(vdev->queue, &p->capabilities);
|
||||||
if (res)
|
if (res)
|
||||||
return res;
|
return res;
|
||||||
if (vb2_queue_is_busy(vdev, file))
|
if (vb2_queue_is_busy(vdev, file))
|
||||||
@ -882,6 +898,7 @@ int vb2_ioctl_create_bufs(struct file *file, void *priv,
|
|||||||
p->format.type);
|
p->format.type);
|
||||||
|
|
||||||
p->index = vdev->queue->num_buffers;
|
p->index = vdev->queue->num_buffers;
|
||||||
|
fill_buf_caps(vdev->queue, &p->capabilities);
|
||||||
/*
|
/*
|
||||||
* If count == 0, then just check if memory and type are valid.
|
* If count == 0, then just check if memory and type are valid.
|
||||||
* Any -EBUSY result from vb2_verify_memory_type can be mapped to 0.
|
* Any -EBUSY result from vb2_verify_memory_type can be mapped to 0.
|
||||||
|
@ -855,6 +855,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq, struct vb2_queue *ds
|
|||||||
src_vq->mem_ops = &vb2_vmalloc_memops;
|
src_vq->mem_ops = &vb2_vmalloc_memops;
|
||||||
src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
|
src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
|
||||||
src_vq->lock = &ctx->dev->dev_mutex;
|
src_vq->lock = &ctx->dev->dev_mutex;
|
||||||
|
src_vq->supports_requests = true;
|
||||||
|
|
||||||
ret = vb2_queue_init(src_vq);
|
ret = vb2_queue_init(src_vq);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
@ -1077,6 +1077,7 @@ static int vivid_create_instance(struct platform_device *pdev, int inst)
|
|||||||
q->min_buffers_needed = 2;
|
q->min_buffers_needed = 2;
|
||||||
q->lock = &dev->mutex;
|
q->lock = &dev->mutex;
|
||||||
q->dev = dev->v4l2_dev.dev;
|
q->dev = dev->v4l2_dev.dev;
|
||||||
|
q->supports_requests = true;
|
||||||
|
|
||||||
ret = vb2_queue_init(q);
|
ret = vb2_queue_init(q);
|
||||||
if (ret)
|
if (ret)
|
||||||
@ -1097,6 +1098,7 @@ static int vivid_create_instance(struct platform_device *pdev, int inst)
|
|||||||
q->min_buffers_needed = 2;
|
q->min_buffers_needed = 2;
|
||||||
q->lock = &dev->mutex;
|
q->lock = &dev->mutex;
|
||||||
q->dev = dev->v4l2_dev.dev;
|
q->dev = dev->v4l2_dev.dev;
|
||||||
|
q->supports_requests = true;
|
||||||
|
|
||||||
ret = vb2_queue_init(q);
|
ret = vb2_queue_init(q);
|
||||||
if (ret)
|
if (ret)
|
||||||
@ -1117,6 +1119,7 @@ static int vivid_create_instance(struct platform_device *pdev, int inst)
|
|||||||
q->min_buffers_needed = 2;
|
q->min_buffers_needed = 2;
|
||||||
q->lock = &dev->mutex;
|
q->lock = &dev->mutex;
|
||||||
q->dev = dev->v4l2_dev.dev;
|
q->dev = dev->v4l2_dev.dev;
|
||||||
|
q->supports_requests = true;
|
||||||
|
|
||||||
ret = vb2_queue_init(q);
|
ret = vb2_queue_init(q);
|
||||||
if (ret)
|
if (ret)
|
||||||
@ -1137,6 +1140,7 @@ static int vivid_create_instance(struct platform_device *pdev, int inst)
|
|||||||
q->min_buffers_needed = 2;
|
q->min_buffers_needed = 2;
|
||||||
q->lock = &dev->mutex;
|
q->lock = &dev->mutex;
|
||||||
q->dev = dev->v4l2_dev.dev;
|
q->dev = dev->v4l2_dev.dev;
|
||||||
|
q->supports_requests = true;
|
||||||
|
|
||||||
ret = vb2_queue_init(q);
|
ret = vb2_queue_init(q);
|
||||||
if (ret)
|
if (ret)
|
||||||
@ -1156,6 +1160,7 @@ static int vivid_create_instance(struct platform_device *pdev, int inst)
|
|||||||
q->min_buffers_needed = 8;
|
q->min_buffers_needed = 8;
|
||||||
q->lock = &dev->mutex;
|
q->lock = &dev->mutex;
|
||||||
q->dev = dev->v4l2_dev.dev;
|
q->dev = dev->v4l2_dev.dev;
|
||||||
|
q->supports_requests = true;
|
||||||
|
|
||||||
ret = vb2_queue_init(q);
|
ret = vb2_queue_init(q);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
@ -251,7 +251,8 @@ struct v4l2_create_buffers32 {
|
|||||||
__u32 count;
|
__u32 count;
|
||||||
__u32 memory; /* enum v4l2_memory */
|
__u32 memory; /* enum v4l2_memory */
|
||||||
struct v4l2_format32 format;
|
struct v4l2_format32 format;
|
||||||
__u32 reserved[8];
|
__u32 capabilities;
|
||||||
|
__u32 reserved[7];
|
||||||
};
|
};
|
||||||
|
|
||||||
static int __bufsize_v4l2_format(struct v4l2_format32 __user *p32, u32 *size)
|
static int __bufsize_v4l2_format(struct v4l2_format32 __user *p32, u32 *size)
|
||||||
@ -411,6 +412,7 @@ static int put_v4l2_create32(struct v4l2_create_buffers __user *p64,
|
|||||||
if (!access_ok(VERIFY_WRITE, p32, sizeof(*p32)) ||
|
if (!access_ok(VERIFY_WRITE, p32, sizeof(*p32)) ||
|
||||||
copy_in_user(p32, p64,
|
copy_in_user(p32, p64,
|
||||||
offsetof(struct v4l2_create_buffers32, format)) ||
|
offsetof(struct v4l2_create_buffers32, format)) ||
|
||||||
|
assign_in_user(&p32->capabilities, &p64->capabilities) ||
|
||||||
copy_in_user(p32->reserved, p64->reserved, sizeof(p64->reserved)))
|
copy_in_user(p32->reserved, p64->reserved, sizeof(p64->reserved)))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
return __put_v4l2_format32(&p64->format, &p32->format);
|
return __put_v4l2_format32(&p64->format, &p32->format);
|
||||||
|
@ -1877,7 +1877,7 @@ static int v4l_reqbufs(const struct v4l2_ioctl_ops *ops,
|
|||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
CLEAR_AFTER_FIELD(p, memory);
|
CLEAR_AFTER_FIELD(p, capabilities);
|
||||||
|
|
||||||
return ops->vidioc_reqbufs(file, fh, p);
|
return ops->vidioc_reqbufs(file, fh, p);
|
||||||
}
|
}
|
||||||
@ -1918,7 +1918,7 @@ static int v4l_create_bufs(const struct v4l2_ioctl_ops *ops,
|
|||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
CLEAR_AFTER_FIELD(create, format);
|
CLEAR_AFTER_FIELD(create, capabilities);
|
||||||
|
|
||||||
v4l_sanitize_format(&create->format);
|
v4l_sanitize_format(&create->format);
|
||||||
|
|
||||||
|
@ -472,6 +472,7 @@ struct vb2_buf_ops {
|
|||||||
* @quirk_poll_must_check_waiting_for_buffers: Return %EPOLLERR at poll when QBUF
|
* @quirk_poll_must_check_waiting_for_buffers: Return %EPOLLERR at poll when QBUF
|
||||||
* has not been called. This is a vb1 idiom that has been adopted
|
* has not been called. This is a vb1 idiom that has been adopted
|
||||||
* also by vb2.
|
* also by vb2.
|
||||||
|
* @supports_requests: this queue supports the Request API.
|
||||||
* @uses_qbuf: qbuf was used directly for this queue. Set to 1 the first
|
* @uses_qbuf: qbuf was used directly for this queue. Set to 1 the first
|
||||||
* time this is called. Set to 0 when the queue is canceled.
|
* time this is called. Set to 0 when the queue is canceled.
|
||||||
* If this is 1, then you cannot queue buffers from a request.
|
* If this is 1, then you cannot queue buffers from a request.
|
||||||
@ -545,6 +546,7 @@ struct vb2_queue {
|
|||||||
unsigned fileio_write_immediately:1;
|
unsigned fileio_write_immediately:1;
|
||||||
unsigned allow_zero_bytesused:1;
|
unsigned allow_zero_bytesused:1;
|
||||||
unsigned quirk_poll_must_check_waiting_for_buffers:1;
|
unsigned quirk_poll_must_check_waiting_for_buffers:1;
|
||||||
|
unsigned supports_requests:1;
|
||||||
unsigned uses_qbuf:1;
|
unsigned uses_qbuf:1;
|
||||||
unsigned uses_requests:1;
|
unsigned uses_requests:1;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user