[RFCv2 14/17] v4l2-ctrls: support requests in EXT_CTRLS ioctls
From: Alexandre Courbot
Date: Wed Jan 31 2018 - 05:28:00 EST
Read and use the request_fd field of struct v4l2_ext_controls to apply
VIDIOC_G_EXT_CTRLS or VIDIOC_S_EXT_CTRLS to a request when asked by
userspace.
Signed-off-by: Alexandre Courbot <acourbot@xxxxxxxxxxxx>
---
drivers/media/v4l2-core/v4l2-ioctl.c | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index 3b44f1fe4f23..0b4c9024c96b 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -30,6 +30,7 @@
#include <media/videobuf2-v4l2.h>
#include <media/v4l2-mc.h>
#include <media/media-request.h>
+#include <media/v4l2-request.h>
#include <trace/events/v4l2.h>
@@ -2182,6 +2183,24 @@ static int v4l_g_ext_ctrls(const struct v4l2_ioctl_ops *ops,
test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags) ? fh : NULL;
p->error_idx = p->count;
+
+ if (p->request_fd > 0) {
+ struct media_request *req = NULL;
+ struct media_request_entity_data *_data;
+ struct media_request_v4l2_entity_data *data;
+ int ret;
+
+ req = check_request(p->request_fd, file, fh, &_data);
+ if (IS_ERR(req))
+ return PTR_ERR(req);
+ data = to_v4l2_entity_data(_data);
+
+ ret = v4l2_g_ext_ctrls(&data->ctrls, p);
+
+ media_request_put(req);
+ return ret;
+ }
+
if (vfh && vfh->ctrl_handler)
return v4l2_g_ext_ctrls(vfh->ctrl_handler, p);
if (vfd->ctrl_handler)
@@ -2201,6 +2220,23 @@ static int v4l_s_ext_ctrls(const struct v4l2_ioctl_ops *ops,
test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags) ? fh : NULL;
p->error_idx = p->count;
+ if (p->request_fd > 0) {
+ struct media_request *req = NULL;
+ struct media_request_entity_data *_data;
+ struct media_request_v4l2_entity_data *data;
+ int ret;
+
+ req = check_request(p->request_fd, file, fh, &_data);
+ if (IS_ERR(req))
+ return PTR_ERR(req);
+ data = to_v4l2_entity_data(_data);
+
+ ret = v4l2_s_ext_ctrls(vfh, &data->ctrls, p);
+
+ media_request_put(req);
+ return ret;
+ }
+
if (vfh && vfh->ctrl_handler)
return v4l2_s_ext_ctrls(vfh, vfh->ctrl_handler, p);
if (vfd->ctrl_handler)
--
2.16.0.rc1.238.g530d649a79-goog