From: Hans Verkuil <hverkuil+cisco@kernel.org>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Michael Jordan <jordan.mymail@gmail.com>
Cc: Hans de Goede <hansg@kernel.org>,
Ricardo Ribalda <ribalda@chromium.org>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
Hans de Goede <johannes.goede@oss.qualcomm.com>
Subject: Re: [PATCH v4 1/4] media: uvcvideo: report AUTO_UPDATE controls as volatile
Date: Fri, 2 Oct 2026 10:14:46 +0200 [thread overview]
Message-ID: <60efdb3c-e669-403d-b2d5-fee993e16217@kernel.org> (raw)
In-Reply-To: <20260929123422.GA349401@killaraus.ideasonboard.com>
On 29/09/2026 14:34, Laurent Pinchart wrote:
> On Mon, Sep 28, 2026 at 05:50:18PM -0400, Michael Jordan wrote:
>> AUTO_UPDATE controls can change on their own, and the driver already
>> re-reads them from the device. Tell userspace by setting
>> V4L2_CTRL_FLAG_VOLATILE, plus EXECUTE_ON_WRITE for writable controls
>> so that writes are not ignored.
>
> Writes are not ignored by the driver regardless of whether or not
> V4L2_CTRL_FLAG_EXECUTE_ON_WRITE is reported to userspace.
>
>> Suggested-by: Ricardo Ribalda <ribalda@chromium.org>
>> Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
>> Reviewed-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
>> Assisted-by: LLM
>> Signed-off-by: Michael Jordan <jordan.mymail@gmail.com>
>> ---
>> 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 3ca108b83f1d..aceb263103e9 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;
>
> A blank line here would be nice.
>
>> + 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;
>> + }
>
> The V4L2 documentation also states
>
> Setting a new value for a volatile control will never trigger a
> V4L2_EVENT_CTRL_CH_VALUE event.
>
> This patch seems to break that as we unconditionally send
> V4L2_EVENT_CTRL_CH_VALUE events on control write for controls that don't
> have UVC_CTRL_FLAG_ASYNCHRONOUS set.
>
>>
>> if (mapping->master_id)
>> __uvc_find_control(ctrl->entity, mapping->master_id,
>
So this is not correct. The best place to see how this should be done in this
driver is the kernel doc comment for v4l2_ctrl_auto_cluster() in include/media/v4l2-ctrls.h.
A driver that uses the control framework can mark a set of controls as a cluster where
the first control switches between automatic and manual handling, and the other controls
are only active if manual handling is selected. If automatic handling is selected, then
the INACTIVE flag is automatically set. In addition, if the 'set_volatile' flag is true
when v4l2_ctrl_auto_cluster is called, then the VOLATILE flag is also set when automatic
handling is selected. That flag is cleared when you switch to manual mode.
So when in manual mode these are all normal, non-volatile controls. When in automatic mode,
and if set_volatile is true, then all but the first control are marked as inactive and
volatile, so reading one of those controls will call g_volatile_ctrl. Setting a volatile
control is just ignored as expected, since it is meaningless.
So don't set V4L2_CTRL_FLAG_EXECUTE_ON_WRITE, instead you have to modify the flags on
the fly whenever you switch between manual and automatic mode.
I hope this helps!
Regards,
Hans
next prev parent reply other threads:[~2026-10-02 8:14 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-28 21:50 [PATCH v4 0/4] media: uvcvideo: live pan/tilt/zoom readback on OBSBOT Tiny 2 and Tail 2 Michael Jordan
2026-09-28 21:50 ` [PATCH v4 1/4] media: uvcvideo: report AUTO_UPDATE controls as volatile Michael Jordan
2026-09-29 12:34 ` Laurent Pinchart
2026-09-29 13:54 ` Michael Jordan
2026-10-02 8:14 ` Hans Verkuil [this message]
2026-10-02 12:41 ` Michael Jordan
2026-09-28 21:50 ` [PATCH v4 2/4] media: uvcvideo: generalise the XU flags fixup to all controls Michael Jordan
2026-09-28 21:50 ` [PATCH v4 3/4] media: uvcvideo: fix up missing AUTO_UPDATE on the OBSBOT Tiny 2 Michael Jordan
2026-09-28 21:50 ` [PATCH v4 4/4] media: uvcvideo: fix up missing AUTO_UPDATE on the OBSBOT Tail 2 Michael Jordan
2026-09-29 15:51 ` [PATCH v4 0/4] media: uvcvideo: live pan/tilt/zoom readback on OBSBOT Tiny 2 and " Hans de Goede
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=60efdb3c-e669-403d-b2d5-fee993e16217@kernel.org \
--to=hverkuil+cisco@kernel.org \
--cc=hansg@kernel.org \
--cc=johannes.goede@oss.qualcomm.com \
--cc=jordan.mymail@gmail.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=ribalda@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®