From: Daniel Schaefer <dhs@frame.work>
To: linux-media@vger.kernel.org
Cc: Daniel Schaefer <dhs@frame.work>,
Edgar Thier <info@edgarthier.net>,
Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Kieran Levin <ktl@frame.work>
Subject: [PATCH] media: uvcvideo: Override default flags
Date: Sun, 2 Jun 2024 14:50:53 +0800 [thread overview]
Message-ID: <20240602065053.36850-1-dhs@frame.work> (raw)
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 859086ae3636 ("media:
uvcvideo: Apply flags from device to actual properties"). But changed to
|= in commit 0dc68cabdb62 ("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
```
Cc: Edgar Thier <info@edgarthier.net>
Cc: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Kieran Levin <ktl@frame.work>
Signed-off-by: Daniel Schaefer <dhs@frame.work>
---
drivers/media/usb/uvc/uvc_ctrl.c | 26 +++++++++++++++++---------
1 file changed, 17 insertions(+), 9 deletions(-)
diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c
index 4b685f883e4d..f50542e26542 100644
--- a/drivers/media/usb/uvc/uvc_ctrl.c
+++ b/drivers/media/usb/uvc/uvc_ctrl.c
@@ -2031,15 +2031,23 @@ static int uvc_ctrl_get_flags(struct uvc_device *dev,
else
ret = uvc_query_ctrl(dev, UVC_GET_INFO, ctrl->entity->id,
dev->intfnum, info->selector, data, 1);
- if (!ret)
- info->flags |= (data[0] & UVC_CONTROL_CAP_GET ?
- UVC_CTRL_FLAG_GET_CUR : 0)
- | (data[0] & UVC_CONTROL_CAP_SET ?
- UVC_CTRL_FLAG_SET_CUR : 0)
- | (data[0] & UVC_CONTROL_CAP_AUTOUPDATE ?
- UVC_CTRL_FLAG_AUTO_UPDATE : 0)
- | (data[0] & UVC_CONTROL_CAP_ASYNCHRONOUS ?
- UVC_CTRL_FLAG_ASYNCHRONOUS : 0);
+ if (!ret) {
+ info->flags = (data[0] & UVC_CONTROL_CAP_GET)
+ ? (info->flags | UVC_CTRL_FLAG_GET_CUR)
+ : (info->flags & ~UVC_CTRL_FLAG_GET_CUR);
+
+ info->flags = (data[0] & UVC_CONTROL_CAP_SET)
+ ? (info->flags | UVC_CTRL_FLAG_SET_CUR)
+ : (info->flags & ~UVC_CTRL_FLAG_SET_CUR);
+
+ info->flags = (data[0] & UVC_CONTROL_CAP_AUTOUPDATE)
+ ? (info->flags | UVC_CTRL_FLAG_AUTO_UPDATE)
+ : (info->flags & ~UVC_CTRL_FLAG_AUTO_UPDATE);
+
+ info->flags = (data[0] & UVC_CONTROL_CAP_ASYNCHRONOUS)
+ ? (info->flags | UVC_CTRL_FLAG_ASYNCHRONOUS)
+ : (info->flags & ~UVC_CTRL_FLAG_ASYNCHRONOUS);
+ }
kfree(data);
return ret;
--
2.43.0
next reply other threads:[~2024-06-02 6:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-02 6:50 Daniel Schaefer [this message]
2024-06-03 11:49 ` [PATCH] media: uvcvideo: Override default flags Ricardo Ribalda
2024-06-05 7:12 ` Daniel Schaefer
2024-06-16 23:20 ` Laurent Pinchart
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=20240602065053.36850-1-dhs@frame.work \
--to=dhs@frame.work \
--cc=info@edgarthier.net \
--cc=kieran.bingham+renesas@ideasonboard.com \
--cc=ktl@frame.work \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.