Skip to content

Commit 8641968

Browse files
JohnAZoidbergpinchartl
authored andcommitted
media: uvcvideo: Override default flags
When the UVC device has a control that is readonly it doesn't set the SET_CUR flag. For example the privacy control has SET_CUR flag set in the defaults in the `uvc_ctrls` variable. Even if the device does not have it set, it's not cleared by uvc_ctrl_get_flags(). Originally written with assignment in commit 859086a ("media: uvcvideo: Apply flags from device to actual properties"). But changed to |= in commit 0dc68ca ("media: uvcvideo: Prevent setting unavailable flags"). It would not clear the default flags. With this patch applied the correct flags are reported to user space. Tested with: ``` > v4l2-ctl --list-ctrls | grep privacy privacy 0x009a0910 (bool) : default=0 value=0 flags=read-only ``` Signed-off-by: Daniel Schaefer <dhs@frame.work> Fixes: 0dc68ca ("media: uvcvideo: Prevent setting unavailable flags") Reviewed-by: Ricardo Ribalda <ribalda@chromium.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Link: https://lore.kernel.org/r/20240602065053.36850-1-dhs@frame.work Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
1 parent c8931ef commit 8641968

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

drivers/media/usb/uvc/uvc_ctrl.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2031,7 +2031,13 @@ static int uvc_ctrl_get_flags(struct uvc_device *dev,
20312031
else
20322032
ret = uvc_query_ctrl(dev, UVC_GET_INFO, ctrl->entity->id,
20332033
dev->intfnum, info->selector, data, 1);
2034-
if (!ret)
2034+
2035+
if (!ret) {
2036+
info->flags &= ~(UVC_CTRL_FLAG_GET_CUR |
2037+
UVC_CTRL_FLAG_SET_CUR |
2038+
UVC_CTRL_FLAG_AUTO_UPDATE |
2039+
UVC_CTRL_FLAG_ASYNCHRONOUS);
2040+
20352041
info->flags |= (data[0] & UVC_CONTROL_CAP_GET ?
20362042
UVC_CTRL_FLAG_GET_CUR : 0)
20372043
| (data[0] & UVC_CONTROL_CAP_SET ?
@@ -2040,6 +2046,7 @@ static int uvc_ctrl_get_flags(struct uvc_device *dev,
20402046
UVC_CTRL_FLAG_AUTO_UPDATE : 0)
20412047
| (data[0] & UVC_CONTROL_CAP_ASYNCHRONOUS ?
20422048
UVC_CTRL_FLAG_ASYNCHRONOUS : 0);
2049+
}
20432050

20442051
kfree(data);
20452052
return ret;

0 commit comments

Comments
 (0)