@@ -2354,6 +2354,9 @@ int vb2_core_queue_init(struct vb2_queue *q)
if (WARN_ON(q->requires_requests && !q->supports_requests))
return -EINVAL;
+ if (WARN_ON(q->supports_ro_requests && !q->supports_requests))
+ return -EINVAL;
+
INIT_LIST_HEAD(&q->queued_list);
INIT_LIST_HEAD(&q->done_list);
spin_lock_init(&q->done_lock);
@@ -717,7 +717,9 @@ static void fill_buf_caps(struct vb2_queue *q, u32 *caps)
if (q->allow_cache_hints && q->io_modes & VB2_MMAP)
*caps |= V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS;
#ifdef CONFIG_MEDIA_CONTROLLER_REQUEST_API
- if (q->supports_requests)
+ if (q->supports_ro_requests)
+ *caps |= V4L2_BUF_CAP_SUPPORTS_RO_REQUESTS;
+ else if (q->supports_requests)
*caps |= V4L2_BUF_CAP_SUPPORTS_REQUESTS;
#endif
}
@@ -713,7 +713,8 @@ int v4l2_m2m_qbuf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
vq = v4l2_m2m_get_vq(m2m_ctx, buf->type);
if (V4L2_TYPE_IS_CAPTURE(vq->type) &&
- (buf->flags & V4L2_BUF_FLAG_REQUEST_FD)) {
+ (buf->flags & V4L2_BUF_FLAG_REQUEST_FD) &&
+ !vq->supports_ro_requests) {
dprintk("%s: requests cannot be used with capture buffers\n",
__func__);
return -EPERM;
@@ -575,6 +575,7 @@ struct vb2_queue {
unsigned int allow_zero_bytesused:1;
unsigned int quirk_poll_must_check_waiting_for_buffers:1;
unsigned int supports_requests:1;
+ unsigned int supports_ro_requests:1;
unsigned int requires_requests:1;
unsigned int uses_qbuf:1;
unsigned int uses_requests:1;
@@ -963,6 +963,7 @@ struct v4l2_requestbuffers {
#define V4L2_BUF_CAP_SUPPORTS_ORPHANED_BUFS (1 << 4)
#define V4L2_BUF_CAP_SUPPORTS_M2M_HOLD_CAPTURE_BUF (1 << 5)
#define V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS (1 << 6)
+#define V4L2_BUF_CAP_SUPPORTS_RO_REQUESTS (1 << 7)
/**
* struct v4l2_plane - plane info for multi-planar buffers
This patch adds support for the V4L2_BUF_CAP_SUPPORTS_RO_REQUESTS flag. This flag is used for Read-Only Requests. Based on a patch from Yunfei Dong <yunfei.dong@mediatek.com>. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> --- drivers/media/common/videobuf2/videobuf2-core.c | 3 +++ drivers/media/common/videobuf2/videobuf2-v4l2.c | 4 +++- drivers/media/v4l2-core/v4l2-mem2mem.c | 3 ++- include/media/videobuf2-core.h | 1 + include/uapi/linux/videodev2.h | 1 + 5 files changed, 10 insertions(+), 2 deletions(-)