[PATCH 1/3] media: uvcvideo: report AUTO_UPDATE controls as volatile
From: Michael Jordan
Date: Fri Aug 28 2026 - 11:26:11 EST
A control with UVC_CTRL_FLAG_AUTO_UPDATE is one whose value the device
changes on its own: the driver never trusts its cached value for it,
re-reading the device on every VIDIOC_G_EXT_CTRLS (the rollback at the
end of the ioctl runs uvc_ctrl_commit_entity(), which clears ctrl->loaded
for these controls) and re-reading it after each write. That is exactly
what V4L2_CTRL_FLAG_VOLATILE describes to userspace, but the driver never
reported it, so applications had no way to know that the value they read
can change under them and that a fresh read is worth issuing.
Report V4L2_CTRL_FLAG_VOLATILE for AUTO_UPDATE controls. The uAPI
documents writes to a volatile control as ignored unless
V4L2_CTRL_FLAG_EXECUTE_ON_WRITE is also set, and this driver sends every
write of a writable control to the device, so report EXECUTE_ON_WRITE
alongside it whenever the control is settable.
Suggested-by: Ricardo Ribalda <ribalda@xxxxxxxxxxxx>
Signed-off-by: Michael Jordan <jordan.mymail@xxxxxxxxx>
---
drivers/media/usb/uvc/uvc_ctrl.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c
index 3ca108b83..aceb26310 100644
--- a/drivers/media/usb/uvc/uvc_ctrl.c
+++ b/drivers/media/usb/uvc/uvc_ctrl.c
@@ -1840,6 +1840,17 @@ static int __uvc_query_v4l2_ctrl(struct uvc_video_chain *chain,
if ((ctrl->info.flags & UVC_CTRL_FLAG_GET_MAX) &&
(ctrl->info.flags & UVC_CTRL_FLAG_GET_MIN))
v4l2_ctrl->flags |= V4L2_CTRL_FLAG_HAS_WHICH_MIN_MAX;
+ if (ctrl->info.flags & UVC_CTRL_FLAG_AUTO_UPDATE) {
+ v4l2_ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE;
+ /*
+ * Writes to a volatile control are documented to be ignored
+ * unless EXECUTE_ON_WRITE is also reported. The driver sends
+ * every write of a writable control to the device, so report
+ * the flag accordingly.
+ */
+ if (ctrl->info.flags & UVC_CTRL_FLAG_SET_CUR)
+ v4l2_ctrl->flags |= V4L2_CTRL_FLAG_EXECUTE_ON_WRITE;
+ }
if (mapping->master_id)
__uvc_find_control(ctrl->entity, mapping->master_id,
--
2.43.0