* [PATCH] media: uvcvideo: Return -EINVAL for ctrl_get errors on disabled controls
@ 2026-11-25 13:35 Ricardo Ribalda
0 siblings, 0 replies; only message in thread
From: Ricardo Ribalda @ 2026-11-25 13:35 UTC (permalink / raw)
To: Laurent Pinchart, Hans de Goede, Mauro Carvalho Chehab, Hans Verkuil
Cc: linux-media, linux-kernel, Nezul Tairus, Ricardo Ribalda
Some non-compliant cameras fail boundary queries (e.g. GET_MIN), so
uvcvideo marks those controls as disabled during enumeration. Due to
legacy uAPI constraints, GET_CUR requests are still sent to the hardware
for disabled controls.
However, userspace (e.g. PipeWire) expects -EINVAL for disabled controls
and treats -EIO as a fatal error, which can cause it to disable the
camera completely.
Match the V4L2 control framework behaviour in uvc_ctrl_get() for
VIDIOC_G_EXT_CTRLS returning -EINVAL directly for boundary queries
(V4L2_CTRL_WHICH_{DEF,MIN,MAX}_VAL) on disabled controls, and converting
-EIO from GET_CUR into -EINVAL. If GET_CUR succeeds, the value is still
returned to the user.
Reported-by: Nezul Tairus <radwolf.83@gmail.com>
Closes: https://lore.kernel.org/linux-media/CAFDWN6LPcz6CBOZzBVN-VbCce3g2wOrPZ8V45_=8xv16VCqzsg@mail.gmail.com/T/#u
Fixes: 649c033711d7 ("media: uvcvideo: Set V4L2_CTRL_FLAG_DISABLED during queryctrl errors")
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
drivers/media/usb/uvc/uvc_ctrl.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c
index d2f722bc3459..9390cb642d30 100644
--- a/drivers/media/usb/uvc/uvc_ctrl.c
+++ b/drivers/media/usb/uvc/uvc_ctrl.c
@@ -2645,6 +2645,7 @@ int uvc_ctrl_get(struct uvc_video_chain *chain, u32 which,
{
struct uvc_control *ctrl;
struct uvc_control_mapping *mapping;
+ int ret;
if (__uvc_query_v4l2_class(chain, xctrl->id, 0) >= 0)
return -EACCES;
@@ -2653,7 +2654,14 @@ int uvc_ctrl_get(struct uvc_video_chain *chain, u32 which,
if (!ctrl)
return -EINVAL;
- return uvc_mapping_get_xctrl(chain, ctrl, mapping, which, xctrl);
+ if (mapping->disabled && which != V4L2_CTRL_WHICH_CUR_VAL)
+ return -EINVAL;
+
+ ret = uvc_mapping_get_xctrl(chain, ctrl, mapping, which, xctrl);
+ if (ret == -EIO && mapping->disabled)
+ return -EINVAL;
+
+ return ret;
}
static int uvc_ctrl_clamp(struct uvc_video_chain *chain,
---
base-commit: b7ac871daee981f1963f632586ff9b9d898ce5dd
change-id: 20261125-uvc-invalid-einval-603b8f0bda56
Best regards,
--
Ricardo Ribalda <ribalda@chromium.org>
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-25 13:35 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-25 13:35 [PATCH] media: uvcvideo: Return -EINVAL for ctrl_get errors on disabled controls Ricardo Ribalda
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®