Skip to content

Commit

Permalink
[media] usb/uvc: Support for V4L2_CTRL_WHICH_DEF_VAL
Browse files Browse the repository at this point in the history
This driver does not use the control infrastructure.
Add support for the new field which on structure
 v4l2_ext_controls

Signed-off-by: Ricardo Ribalda Delgado <[email protected]>
Acked-by: Laurent Pinchart <[email protected]>
Signed-off-by: Hans Verkuil <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  • Loading branch information
ribalda authored and mchehab committed Nov 17, 2015
1 parent 953eae5 commit 9173983
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions drivers/media/usb/uvc/uvc_v4l2.c
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,22 @@ static int uvc_ioctl_g_ext_ctrls(struct file *file, void *fh,
unsigned int i;
int ret;

if (ctrls->which == V4L2_CTRL_WHICH_DEF_VAL) {
for (i = 0; i < ctrls->count; ++ctrl, ++i) {
struct v4l2_queryctrl qc = { .id = ctrl->id };

ret = uvc_query_v4l2_ctrl(chain, &qc);
if (ret < 0) {
ctrls->error_idx = i;
return ret;
}

ctrl->value = qc.default_value;
}

return 0;
}

ret = uvc_ctrl_begin(chain);
if (ret < 0)
return ret;
Expand Down Expand Up @@ -1010,6 +1026,10 @@ static int uvc_ioctl_s_try_ext_ctrls(struct uvc_fh *handle,
unsigned int i;
int ret;

/* Default value cannot be changed */
if (ctrls->which == V4L2_CTRL_WHICH_DEF_VAL)
return -EINVAL;

ret = uvc_ctrl_begin(chain);
if (ret < 0)
return ret;
Expand Down

0 comments on commit 9173983

Please sign in to comment.