lkml.org 
[lkml]   [2021]   [Nov]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.10 291/575] media: v4l2-ioctl: S_CTRL output the right value
    Date
    From: Ricardo Ribalda <ribalda@chromium.org>

    [ Upstream commit c87ed93574e3cd8346c05bd934c617596c12541b ]

    If the driver does not implement s_ctrl, but it does implement
    s_ext_ctrls, we convert the call.

    When that happens we have also to convert back the response from
    s_ext_ctrls.

    Fixes v4l2_compliance:
    Control ioctls (Input 0):
    fail: v4l2-test-controls.cpp(411): returned control value out of range
    fail: v4l2-test-controls.cpp(507): invalid control 00980900
    test VIDIOC_G/S_CTRL: FAIL

    Fixes: 35ea11ff8471 ("V4L/DVB (8430): videodev: move some functions from v4l2-dev.h to v4l2-common.h or v4l2-ioctl.h")
    Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
    Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
    Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
    Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    drivers/media/v4l2-core/v4l2-ioctl.c | 9 ++++++---
    1 file changed, 6 insertions(+), 3 deletions(-)

    diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
    index 42958ce22de19..4ffa14e44efe4 100644
    --- a/drivers/media/v4l2-core/v4l2-ioctl.c
    +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
    @@ -2263,6 +2263,7 @@ static int v4l_s_ctrl(const struct v4l2_ioctl_ops *ops,
    test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags) ? fh : NULL;
    struct v4l2_ext_controls ctrls;
    struct v4l2_ext_control ctrl;
    + int ret;

    if (vfh && vfh->ctrl_handler)
    return v4l2_s_ctrl(vfh, vfh->ctrl_handler, p);
    @@ -2278,9 +2279,11 @@ static int v4l_s_ctrl(const struct v4l2_ioctl_ops *ops,
    ctrls.controls = &ctrl;
    ctrl.id = p->id;
    ctrl.value = p->value;
    - if (check_ext_ctrls(&ctrls, VIDIOC_S_CTRL))
    - return ops->vidioc_s_ext_ctrls(file, fh, &ctrls);
    - return -EINVAL;
    + if (!check_ext_ctrls(&ctrls, VIDIOC_S_CTRL))
    + return -EINVAL;
    + ret = ops->vidioc_s_ext_ctrls(file, fh, &ctrls);
    + p->value = ctrl.value;
    + return ret;
    }

    static int v4l_g_ext_ctrls(const struct v4l2_ioctl_ops *ops,
    --
    2.33.0


    \
     
     \ /
      Last update: 2021-11-15 21:23    [W:2.488 / U:0.292 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site