mirror of
https://github.com/torvalds/linux.git
synced 2026-06-03 03:53:37 +02:00
media: uvcvideo: Fix support for V4L2_CTRL_FLAG_HAS_WHICH_MIN_MAX
The VIDIOC_G_EXT_CTRLS with which V4L2_CTRL_WHICH_(MIN|MAX)_VAL can only
work for controls that have previously announced support for it.
This patch fixes the following v4l2-compliance error:
info: checking extended control 'User Controls' (0x00980001)
fail: v4l2-test-controls.cpp(980): ret != EINVAL (got 13)
test VIDIOC_G/S/TRY_EXT_CTRLS: FAIL
Fixes: 39d2c891c9 ("media: uvcvideo: support V4L2_CTRL_WHICH_MIN/MAX_VAL")
Cc: stable@vger.kernel.org
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Reviewed-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
This commit is contained in:
parent
85883141d3
commit
4238bd6dc6
|
|
@ -1432,7 +1432,7 @@ static bool uvc_ctrl_is_readable(u32 which, struct uvc_control *ctrl,
|
|||
* auto_exposure=1, exposure_time_absolute=251.
|
||||
*/
|
||||
int uvc_ctrl_is_accessible(struct uvc_video_chain *chain, u32 v4l2_id,
|
||||
const struct v4l2_ext_controls *ctrls,
|
||||
const struct v4l2_ext_controls *ctrls, u32 which,
|
||||
unsigned long ioctl)
|
||||
{
|
||||
struct uvc_control_mapping *master_map = NULL;
|
||||
|
|
@ -1442,14 +1442,24 @@ int uvc_ctrl_is_accessible(struct uvc_video_chain *chain, u32 v4l2_id,
|
|||
s32 val;
|
||||
int ret;
|
||||
int i;
|
||||
/*
|
||||
* There is no need to check the ioctl, all the ioctls except
|
||||
* VIDIOC_G_EXT_CTRLS use which=V4L2_CTRL_WHICH_CUR_VAL.
|
||||
*/
|
||||
bool is_which_min_max = which == V4L2_CTRL_WHICH_MIN_VAL ||
|
||||
which == V4L2_CTRL_WHICH_MAX_VAL;
|
||||
|
||||
if (__uvc_query_v4l2_class(chain, v4l2_id, 0) >= 0)
|
||||
return -EACCES;
|
||||
return is_which_min_max ? -EINVAL : -EACCES;
|
||||
|
||||
ctrl = uvc_find_control(chain, v4l2_id, &mapping);
|
||||
if (!ctrl)
|
||||
return -EINVAL;
|
||||
|
||||
if ((!(ctrl->info.flags & UVC_CTRL_FLAG_GET_MIN) ||
|
||||
!(ctrl->info.flags & UVC_CTRL_FLAG_GET_MAX)) && is_which_min_max)
|
||||
return -EINVAL;
|
||||
|
||||
if (ioctl == VIDIOC_G_EXT_CTRLS)
|
||||
return uvc_ctrl_is_readable(ctrls->which, ctrl, mapping);
|
||||
|
||||
|
|
|
|||
|
|
@ -765,14 +765,15 @@ static int uvc_ioctl_query_ext_ctrl(struct file *file, void *priv,
|
|||
|
||||
static int uvc_ctrl_check_access(struct uvc_video_chain *chain,
|
||||
struct v4l2_ext_controls *ctrls,
|
||||
unsigned long ioctl)
|
||||
u32 which, unsigned long ioctl)
|
||||
{
|
||||
struct v4l2_ext_control *ctrl = ctrls->controls;
|
||||
unsigned int i;
|
||||
int ret = 0;
|
||||
|
||||
for (i = 0; i < ctrls->count; ++ctrl, ++i) {
|
||||
ret = uvc_ctrl_is_accessible(chain, ctrl->id, ctrls, ioctl);
|
||||
ret = uvc_ctrl_is_accessible(chain, ctrl->id, ctrls, which,
|
||||
ioctl);
|
||||
if (ret)
|
||||
break;
|
||||
}
|
||||
|
|
@ -806,7 +807,7 @@ static int uvc_ioctl_g_ext_ctrls(struct file *file, void *priv,
|
|||
which = V4L2_CTRL_WHICH_CUR_VAL;
|
||||
}
|
||||
|
||||
ret = uvc_ctrl_check_access(chain, ctrls, VIDIOC_G_EXT_CTRLS);
|
||||
ret = uvc_ctrl_check_access(chain, ctrls, which, VIDIOC_G_EXT_CTRLS);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
|
|
@ -840,7 +841,8 @@ static int uvc_ioctl_s_try_ext_ctrls(struct uvc_fh *handle,
|
|||
if (!ctrls->count)
|
||||
return 0;
|
||||
|
||||
ret = uvc_ctrl_check_access(chain, ctrls, ioctl);
|
||||
ret = uvc_ctrl_check_access(chain, ctrls, V4L2_CTRL_WHICH_CUR_VAL,
|
||||
ioctl);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
|
|
|
|||
|
|
@ -786,7 +786,7 @@ int uvc_ctrl_get(struct uvc_video_chain *chain, u32 which,
|
|||
struct v4l2_ext_control *xctrl);
|
||||
int uvc_ctrl_set(struct uvc_fh *handle, struct v4l2_ext_control *xctrl);
|
||||
int uvc_ctrl_is_accessible(struct uvc_video_chain *chain, u32 v4l2_id,
|
||||
const struct v4l2_ext_controls *ctrls,
|
||||
const struct v4l2_ext_controls *ctrls, u32 which,
|
||||
unsigned long ioctl);
|
||||
|
||||
int uvc_xu_ctrl_query(struct uvc_video_chain *chain,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user