Call v4l2_ctrl_request_add_handler() from req_validate() to add the control handler request object if needed. Without this the returned request object would not have a copy of the controls used for the captured frame. Signed-off-by: Hans Verkuil <hverkuil-cisco@xxxxxxxxx> --- drivers/media/test-drivers/vivid/vivid-core.c | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/drivers/media/test-drivers/vivid/vivid-core.c b/drivers/media/test-drivers/vivid/vivid-core.c index f7ee37e9508d..c21bc27bbfeb 100644 --- a/drivers/media/test-drivers/vivid/vivid-core.c +++ b/drivers/media/test-drivers/vivid/vivid-core.c @@ -783,6 +783,48 @@ static void vivid_dev_release(struct v4l2_device *v4l2_dev) static int vivid_req_validate(struct media_request *req) { struct vivid_dev *dev = container_of(req->mdev, struct vivid_dev, mdev); + struct vb2_buffer *vb = vb2_request_buffer_first(req); + struct v4l2_ctrl_handler *hdl = NULL; + bool ro_req; + int ret; + + if (!vb) + return -ENOENT; + + switch (vb->vb2_queue->type) { + case V4L2_BUF_TYPE_VIDEO_CAPTURE: + case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: + if (vb->vb2_queue == &dev->vb_touch_cap_q) + hdl = &dev->ctrl_hdl_touch_cap; + else + hdl = &dev->ctrl_hdl_vid_cap; + break; + case V4L2_BUF_TYPE_VIDEO_OUTPUT: + case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: + hdl = &dev->ctrl_hdl_vid_out; + break; + case V4L2_BUF_TYPE_VBI_CAPTURE: + case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: + hdl = &dev->ctrl_hdl_vbi_cap; + break; + case V4L2_BUF_TYPE_VBI_OUTPUT: + case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: + hdl = &dev->ctrl_hdl_vbi_out; + break; + case V4L2_BUF_TYPE_META_CAPTURE: + hdl = &dev->ctrl_hdl_meta_cap; + break; + case V4L2_BUF_TYPE_META_OUTPUT: + hdl = &dev->ctrl_hdl_meta_out; + break; + case V4L2_BUF_TYPE_SDR_CAPTURE: + hdl = &dev->ctrl_hdl_sdr_cap; + break; + } + ro_req = vb->vb2_queue->supports_ro_requests; + ret = v4l2_ctrl_request_add_handler(req, hdl, ro_req); + if (ret) + return ret; if (dev->req_validate_error) { dev->req_validate_error = false; -- 2.27.0