• Ricardo Ribalda's avatar
    media: v4l2-ioctl: Fix check_ext_ctrls · 861f92cb
    Ricardo Ribalda authored
    Drivers that do not use the ctrl-framework use this function instead.
    
    Fix the following issues:
    
    - Do not check for multiple classes when getting the DEF_VAL.
    - Return -EINVAL for request_api calls
    - Default value cannot be changed, return EINVAL as soon as possible.
    - Return the right error_idx
    [If an error is found when validating the list of controls passed with
    VIDIOC_G_EXT_CTRLS, then error_idx shall be set to ctrls->count to
    indicate to userspace that no actual hardware was touched.
    It would have been much nicer of course if error_idx could point to the
    control index that failed the validation, but sadly that's not how the
    API was designed.]
    
    Fixes v4l2-compliance:
    Control ioctls (Input 0):
            warn: v4l2-test-controls.cpp(834): error_idx should be equal to count
            warn: v4l2-test-controls.cpp(855): error_idx should be equal to count
    		fail: v4l2-test-controls.cpp(813): doioctl(node, VIDIOC_G_EXT_CTRLS, &ctrls)
    	test VIDIOC_G/S/TRY_EXT_CTRLS: FAIL
    Buffer ioctls (Input 0):
    		fail: v4l2-test-buffers.cpp(1994): ret != EINVAL && ret != EBADR && ret != ENOTTY
    	test Requests: FAIL
    
    Cc: stable@vger.kernel.org
    Fixes: 6fa6f831 ("media: v4l2-ctrls: add core request support")
    Suggested-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
    Reviewed-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
    Signed-off-by: default avatarRicardo Ribalda <ribalda@chromium.org>
    Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
    Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
    861f92cb
v4l2-ioctl.c 107 KB