From: Nicolas Dufresne <nicolas.dufresne@collabora.com>
To: Paul Kocialkowski <paul.kocialkowski@bootlin.com>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Sakari Ailus <sakari.ailus@iki.fi>,
Hans Verkuil <hverkuil@xs4all.nl>
Subject: Re: [PATCH] media: v4l2-dev: Check that g/s_selection are valid before selecting crop
Date: Tue, 07 Nov 2023 15:33:17 -0500 [thread overview]
Message-ID: <be1d3bfbdd076bf7c5c25bab826dc8bde3d067d7.camel@collabora.com> (raw)
In-Reply-To: <20231107200509.485071-1-paul.kocialkowski@bootlin.com>
Le mardi 07 novembre 2023 à 21:05 +0100, Paul Kocialkowski a écrit :
> The cropcap and g/s_crop ioctls are automatically marked as valid whenever the
> g/s_selection ops are filled. The rationale is to auto-enable these legacy
> cropcap and g/s_crop ioctls that rely on g/s_selection.
>
> However it's possible that the ops are filled but explicitly disabled with
> calls to v4l2_disable_ioctl. In this situation the legacy ioctls should not
> be enabled.
>
> Add a check on the video device's valid ioctls field before auto-selecting
> them to honor the driver's choice. Note that the meaning of the bitfield
> stored in the video device is the opposite of what the name suggests as
> v4l2_disable_ioctl will set the bits. Their meaning will be reversed at
> the end of the function.
>
> Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
> ---
> drivers/media/v4l2-core/v4l2-dev.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
> index f81279492682..d13954bd31fd 100644
> --- a/drivers/media/v4l2-core/v4l2-dev.c
> +++ b/drivers/media/v4l2-core/v4l2-dev.c
> @@ -642,11 +642,13 @@ static void determine_valid_ioctls(struct video_device *vdev)
> SET_VALID_IOCTL(ops, VIDIOC_TRY_DECODER_CMD, vidioc_try_decoder_cmd);
> SET_VALID_IOCTL(ops, VIDIOC_ENUM_FRAMESIZES, vidioc_enum_framesizes);
> SET_VALID_IOCTL(ops, VIDIOC_ENUM_FRAMEINTERVALS, vidioc_enum_frameintervals);
> - if (ops->vidioc_g_selection) {
> + if (ops->vidioc_g_selection &&
> + !test_bit(_IOC_NR(VIDIOC_G_SELECTION), vdev->valid_ioctls)) {
> __set_bit(_IOC_NR(VIDIOC_G_CROP), valid_ioctls);
> __set_bit(_IOC_NR(VIDIOC_CROPCAP), valid_ioctls);
> }
> - if (ops->vidioc_s_selection)
> + if (ops->vidioc_s_selection &&
> + !test_bit(_IOC_NR(VIDIOC_S_SELECTION), vdev->valid_ioctls))
> __set_bit(_IOC_NR(VIDIOC_S_CROP), valid_ioctls);
> SET_VALID_IOCTL(ops, VIDIOC_G_SELECTION, vidioc_g_selection);
> SET_VALID_IOCTL(ops, VIDIOC_S_SELECTION, vidioc_s_selection);
prev parent reply other threads:[~2023-11-07 20:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-07 20:05 Paul Kocialkowski
2023-11-07 20:33 ` Nicolas Dufresne [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=be1d3bfbdd076bf7c5c25bab826dc8bde3d067d7.camel@collabora.com \
--to=nicolas.dufresne@collabora.com \
--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=paul.kocialkowski@bootlin.com \
--cc=sakari.ailus@iki.fi \
--cc=thomas.petazzoni@bootlin.com \
/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®