@@ -2331,6 +2331,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);
@@ -712,7 +712,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
}
@@ -753,7 +753,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;
@@ -578,6 +578,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;
@@ -964,6 +964,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(-)