From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Ricardo Ribalda <ribalda@chromium.org>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
Hans Verkuil <hverkuil@xs4all.nl>,
Hans de Goede <hansg@kernel.org>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
Hans Verkuil <hans@jjverkuil.nl>
Subject: Re: [PATCH v3 8/8] media: uvcvideo: uvc_v4l2_unlocked_ioctl: Invert PM logic
Date: Tue, 1 Jul 2025 01:25:46 +0300 [thread overview]
Message-ID: <20250630222546.GC15184@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20250630-uvc-grannular-invert-v3-8-abd5cb5c45b7@chromium.org>
Hi Ricardo,
On Mon, Jun 30, 2025 at 02:20:33PM +0000, Ricardo Ribalda wrote:
> Instead of listing the IOCTLs that do not need to turn on the camera,
> list the IOCTLs that need to turn it on. This makes the code more
> maintainable.
>
> This patch changes the behaviour for unsupported IOCTLs. Those IOCTLs
> will not turn on the camera.
The idea is good, but you'll have to add UVCIOC_CTRL_MAP back (see 6/8).
> Suggested-by: Hans Verkuil <hans@jjverkuil.nl>
> Reviewed-by: Hans de Goede <hansg@kernel.org>
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> ---
> drivers/media/usb/uvc/uvc_v4l2.c | 52 +++++++++++++++++++---------------------
> 1 file changed, 25 insertions(+), 27 deletions(-)
>
> diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
> index 350cd2cc88f872d2e8bd19e2b8fb067894916364..94dc97448446d36a85a1b36d16c29f22af89c640 100644
> --- a/drivers/media/usb/uvc/uvc_v4l2.c
> +++ b/drivers/media/usb/uvc/uvc_v4l2.c
> @@ -1222,37 +1222,35 @@ static long uvc_v4l2_unlocked_ioctl(struct file *file,
> unsigned int cmd, unsigned long arg)
> {
> struct uvc_fh *handle = file->private_data;
> + unsigned int converted_cmd = v4l2_translate_cmd(cmd);
> int ret;
>
> - /* The following IOCTLs do not need to turn on the camera. */
> - switch (cmd) {
> - case UVCIOC_CTRL_MAP:
> - case VIDIOC_CREATE_BUFS:
> - case VIDIOC_DQBUF:
> - case VIDIOC_ENUM_FMT:
> - case VIDIOC_ENUM_FRAMEINTERVALS:
> - case VIDIOC_ENUM_FRAMESIZES:
> - case VIDIOC_ENUMINPUT:
> - case VIDIOC_EXPBUF:
> - case VIDIOC_G_FMT:
> - case VIDIOC_G_PARM:
> - case VIDIOC_G_SELECTION:
> - case VIDIOC_QBUF:
> - case VIDIOC_QUERYCAP:
> - case VIDIOC_REQBUFS:
> - case VIDIOC_SUBSCRIBE_EVENT:
> - case VIDIOC_UNSUBSCRIBE_EVENT:
> - return video_ioctl2(file, cmd, arg);
> - }
> -
> - ret = uvc_pm_get(handle->stream->dev);
> - if (ret)
> + /* The following IOCTLs need to turn on the camera. */
> + switch (converted_cmd) {
> + case UVCIOC_CTRL_QUERY:
> + case VIDIOC_G_CTRL:
> + case VIDIOC_G_EXT_CTRLS:
> + case VIDIOC_G_INPUT:
> + case VIDIOC_QUERYCTRL:
> + case VIDIOC_QUERYMENU:
> + case VIDIOC_QUERY_EXT_CTRL:
> + case VIDIOC_S_CTRL:
> + case VIDIOC_S_EXT_CTRLS:
> + case VIDIOC_S_FMT:
> + case VIDIOC_S_INPUT:
> + case VIDIOC_S_PARM:
> + case VIDIOC_TRY_EXT_CTRLS:
> + case VIDIOC_TRY_FMT:
> + ret = uvc_pm_get(handle->stream->dev);
> + if (ret)
> + return ret;
> + ret = video_ioctl2(file, cmd, arg);
> + uvc_pm_put(handle->stream->dev);
> return ret;
> + }
>
> - ret = video_ioctl2(file, cmd, arg);
> -
> - uvc_pm_put(handle->stream->dev);
> - return ret;
> + /* The other IOCTLs can run with the camera off. */
> + return video_ioctl2(file, cmd, arg);
> }
>
> const struct v4l2_ioctl_ops uvc_ioctl_ops = {
--
Regards,
Laurent Pinchart
prev parent reply other threads:[~2025-06-30 22:26 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-30 14:20 [PATCH v3 0/8] media: uvcvideo: Invert granular PM logic + PM fix Ricardo Ribalda
2025-06-30 14:20 ` [PATCH v3 1/8] media: uvcvideo: Use vb2 ioctl and fop helpers Ricardo Ribalda
2025-06-30 14:20 ` [PATCH v3 2/8] media: uvcvideo: Handle locks in uvc_queue_return_buffers Ricardo Ribalda
2025-06-30 14:20 ` [PATCH v3 3/8] media: uvcvideo: Split uvc_stop_streaming() Ricardo Ribalda
2025-06-30 14:20 ` [PATCH v3 4/8] media: uvcvideo: Remove stream->is_streaming field Ricardo Ribalda
2025-06-30 14:20 ` [PATCH v3 5/8] media: uvcvideo: Turn on the camera if V4L2_EVENT_SUB_FL_SEND_INITIAL Ricardo Ribalda
2025-06-30 22:09 ` Laurent Pinchart
2025-06-30 14:20 ` [PATCH v3 6/8] media: uvcvideo: Do not enable camera during UVCIOC_CTRL_MAP* Ricardo Ribalda
2025-06-30 22:14 ` Laurent Pinchart
2025-07-01 4:40 ` Ricardo Ribalda
2025-06-30 14:20 ` [PATCH v3 7/8] media: core: export v4l2_translate_cmd Ricardo Ribalda
2025-06-30 14:42 ` hans
2025-06-30 14:20 ` [PATCH v3 8/8] media: uvcvideo: uvc_v4l2_unlocked_ioctl: Invert PM logic Ricardo Ribalda
2025-06-30 14:43 ` Hans Verkuil
2025-06-30 22:25 ` Laurent Pinchart [this message]
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=20250630222546.GC15184@pendragon.ideasonboard.com \
--to=laurent.pinchart@ideasonboard.com \
--cc=hans@jjverkuil.nl \
--cc=hansg@kernel.org \
--cc=hverkuil@xs4all.nl \
--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®