From: Hans de Goede <hansg@kernel.org>
To: Ricardo Ribalda <ribalda@chromium.org>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Hans Verkuil <hverkuil@xs4all.nl>
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
Hans Verkuil <hans@jjverkuil.nl>
Subject: Re: [PATCH v2 7/9] media: uvcvideo: uvc_v4l2_unlocked_ioctl: Invert PM logic
Date: Mon, 16 Jun 2025 16:14:15 +0200 [thread overview]
Message-ID: <ba461646-c639-4e66-9f6d-c34f59d39f82@kernel.org> (raw)
In-Reply-To: <20250602-uvc-grannular-invert-v2-7-c871934ad880@chromium.org>
Hi,
On 2-Jun-25 15:06, 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.
>
> Suggested-by: Hans Verkuil <hans@jjverkuil.nl>
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> ---
> drivers/media/usb/uvc/uvc_v4l2.c | 61 ++++++++++++++++++++++++----------------
> 1 file changed, 36 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
> index 020def11b60e00ca2875dd96f23ef9591fed11d9..13388879091c46ff74582226146521b5b5eb3d10 100644
> --- a/drivers/media/usb/uvc/uvc_v4l2.c
> +++ b/drivers/media/usb/uvc/uvc_v4l2.c
> @@ -1219,43 +1219,54 @@ static long uvc_v4l2_compat_ioctl32(struct file *file,
> }
> #endif
>
> -static long uvc_v4l2_unlocked_ioctl(struct file *file,
> - unsigned int cmd, unsigned long arg)
> +static long uvc_v4l2_pm_ioctl(struct file *file,
> + unsigned int cmd, unsigned long arg)
> {
> struct uvc_fh *handle = file->private_data;
> int ret;
>
> - /* The following IOCTLs do not need to turn on the camera. */
s/do need/need/
otherwise this looks good to me:
Reviewed-by: Hans de Goede <hansg@kernel.org>
Regards,
Hans
> - 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)
> return ret;
> -
> ret = video_ioctl2(file, cmd, arg);
> -
> uvc_pm_put(handle->stream->dev);
> +
> return ret;
> }
>
> +static long uvc_v4l2_unlocked_ioctl(struct file *file,
> + unsigned int cmd, unsigned long arg)
> +{
> + /*
> + * For now, we do not support granular power saving for compat
> + * syscalls.
> + */
> + if (in_compat_syscall())
> + return uvc_v4l2_pm_ioctl(file, cmd, arg);
> +
> + /* The following IOCTLs do need to turn on the camera. */
> + switch (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:
> + return uvc_v4l2_pm_ioctl(file, cmd, arg);
> + }
> +
> + /* The other IOCTLs can run with the camera off. */
> + return video_ioctl2(file, cmd, arg);
> +}
> +
> const struct v4l2_ioctl_ops uvc_ioctl_ops = {
> .vidioc_g_fmt_vid_cap = uvc_ioctl_g_fmt,
> .vidioc_g_fmt_vid_out = uvc_ioctl_g_fmt,
>
next prev parent reply other threads:[~2025-06-16 14:14 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-02 13:06 [PATCH v2 0/9] media: uvcvideo: Invert granular PM logic + PM fix Ricardo Ribalda
2025-06-02 13:06 ` [PATCH v2 1/9] media: uvcvideo: Refactor uvc_queue_streamon Ricardo Ribalda
2025-06-02 13:06 ` [PATCH v2 2/9] media: uvcvideo: Refactor uvc_v4l2_compat_ioctl32 Ricardo Ribalda
2025-06-02 13:06 ` [PATCH v2 3/9] media: uvcvideo: Use vb2 ioctl and fop helpers Ricardo Ribalda
2025-06-02 13:06 ` [PATCH v2 4/9] media: uvcvideo: Remove stream->is_streaming field Ricardo Ribalda
2025-06-02 13:06 ` [PATCH v2 5/9] media: uvcvideo: Turn on the camera if V4L2_EVENT_SUB_FL_SEND_INITIAL Ricardo Ribalda
2025-06-02 13:06 ` [PATCH v2 6/9] media: uvcvideo: Do not enable camera during UVCIOC_CTRL_MAP* Ricardo Ribalda
2025-06-02 13:06 ` [PATCH v2 7/9] media: uvcvideo: uvc_v4l2_unlocked_ioctl: Invert PM logic Ricardo Ribalda
2025-06-16 14:14 ` Hans de Goede [this message]
2025-06-30 13:21 ` Hans de Goede
2025-06-30 13:35 ` Hans Verkuil
2025-06-02 13:06 ` [PATCH v2 8/9] media: core: export v4l2_compat_translate_cmd() Ricardo Ribalda
2025-06-16 14:14 ` Hans de Goede
2025-06-30 13:06 ` Hans de Goede
2025-06-30 13:38 ` hans
2025-06-02 13:06 ` [PATCH v2 9/9] media: uvcvideo: Support granular power saving for compat syscalls Ricardo Ribalda
2025-06-16 14:15 ` Hans de Goede
2025-06-30 13:39 ` hans
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=ba461646-c639-4e66-9f6d-c34f59d39f82@kernel.org \
--to=hansg@kernel.org \
--cc=hans@jjverkuil.nl \
--cc=hverkuil@xs4all.nl \
--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®