public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil+cisco@kernel.org>
To: Jai Luthra <jai.luthra@ideasonboard.com>,
	Hans Verkuil <hverkuil@kernel.org>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>,
	Jacopo Mondi <jacopo.mondi@ideasonboard.com>,
	linux-media@vger.kernel.org
Cc: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>,
	Ricardo Ribalda <ribalda@chromium.org>,
	Hans de Goede <hansg@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 07/10] media: v4l2-ioctl: Pass device state for G/S/TRY_FMT ioctls
Date: Mon, 22 Sep 2025 10:11:04 +0200	[thread overview]
Message-ID: <097124ea-cf9b-425c-bb5f-a305224328f6@kernel.org> (raw)
In-Reply-To: <20250919-vdev-state-v2-7-b2c42426965c@ideasonboard.com>

On 19/09/2025 11:55, Jai Luthra wrote:
> Now that video device state is accepted as an argument in ioctl
> implementations across all video device drivers, populate that argument
> with the actual state data.
> 
> Pass the active state for G_FMT and S_FMT ioctls, and the try state for
> TRY_FMT ioctl to drivers that have opted to use device state for format
> storage.
> 
> Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com>
> --
> Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
> Cc: Hans Verkuil <hverkuil@kernel.org>
> Cc: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> Cc: Ricardo Ribalda <ribalda@chromium.org>
> Cc: Hans de Goede <hansg@kernel.org>
> Cc: Jai Luthra <jai.luthra@ideasonboard.com>
> Cc: linux-media@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> ---
>  drivers/media/v4l2-core/v4l2-ioctl.c | 23 +++++++++++++++++++++--
>  1 file changed, 21 insertions(+), 2 deletions(-)

There is one more occurrence of this in v4l2_compat_ioctl32.c in function
ctrl_is_pointer() where vidioc_query_ext_ctrl is called.

Regards,

	Hans

> 
> diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
> index 644f06521673ff7ce5b194335d50f0e375ca7f51..500fc20627c97ce70016f4524301835142b7bebd 100644
> --- a/drivers/media/v4l2-core/v4l2-ioctl.c
> +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
> @@ -3070,6 +3070,21 @@ void v4l_printk_ioctl(const char *prefix, unsigned int cmd)
>  }
>  EXPORT_SYMBOL(v4l_printk_ioctl);
>  
> +static struct video_device_state *
> +video_device_get_state(struct video_device *vfd, struct v4l2_fh *vfh,
> +		       unsigned int cmd)
> +{
> +	switch (cmd) {
> +	default:
> +		return NULL;
> +	case VIDIOC_G_FMT:
> +	case VIDIOC_S_FMT:
> +		return vfd->state;
> +	case VIDIOC_TRY_FMT:
> +		return vfh->state;
> +	}
> +}
> +
>  static long __video_do_ioctl(struct file *file,
>  		unsigned int cmd, void *arg)
>  {
> @@ -3078,6 +3093,7 @@ static long __video_do_ioctl(struct file *file,
>  	struct mutex *lock; /* ioctl serialization mutex */
>  	const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
>  	bool write_only = false;
> +	struct video_device_state *state = NULL;
>  	struct v4l2_ioctl_info default_info;
>  	const struct v4l2_ioctl_info *info;
>  	struct v4l2_fh *vfh = file_to_v4l2_fh(file);
> @@ -3090,6 +3106,9 @@ static long __video_do_ioctl(struct file *file,
>  		return ret;
>  	}
>  
> +	if (test_bit(V4L2_FL_USES_STATE, &vfd->flags))
> +		state = video_device_get_state(vfd, vfh, cmd);
> +
>  	/*
>  	 * We need to serialize streamon/off with queueing new requests.
>  	 * These ioctls may trigger the cancellation of a streaming
> @@ -3138,11 +3157,11 @@ static long __video_do_ioctl(struct file *file,
>  
>  	write_only = _IOC_DIR(cmd) == _IOC_WRITE;
>  	if (info != &default_info) {
> -		ret = info->func(ops, file, NULL, arg);
> +		ret = info->func(ops, file, state, arg);
>  	} else if (!ops->vidioc_default) {
>  		ret = -ENOTTY;
>  	} else {
> -		ret = ops->vidioc_default(file, NULL,
> +		ret = ops->vidioc_default(file, state,
>  			v4l2_prio_check(vfd->prio, vfh->prio) >= 0,
>  			cmd, arg);
>  	}
> 


  reply	other threads:[~2025-09-22  8:11 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-19  9:55 [PATCH v2 00/10] media: Introduce video device state management Jai Luthra
2025-09-19  9:55 ` [PATCH v2 01/10] media: v4l2-core: Introduce state management for video devices Jai Luthra
2025-09-22  7:44   ` Hans Verkuil
2025-09-22  8:00     ` Hans Verkuil
2025-09-29 15:30       ` Jai Luthra
2025-09-29 20:02         ` Michael Riesch
2025-09-30  7:26           ` Jacopo Mondi
2025-09-30  7:15         ` Jacopo Mondi
2025-09-30  7:24         ` Hans Verkuil
2025-09-24  7:06     ` Hans Verkuil
2025-09-24 10:15   ` Mauro Carvalho Chehab
2025-09-29 16:50     ` Jai Luthra
2025-09-19  9:55 ` [PATCH v2 02/10] media: v4l2-dev: Add support for try state Jai Luthra
2025-09-22  7:52   ` Hans Verkuil
2025-09-22  7:58     ` Hans Verkuil
2025-09-29 16:15       ` Jai Luthra
2025-09-30  7:30         ` Hans Verkuil
2025-09-30  9:35           ` Jacopo Mondi
2025-09-30 10:07             ` Hans Verkuil
2025-09-19  9:55 ` [PATCH v2 03/10] media: v4l2-dev: Add callback for initializing video device state Jai Luthra
2025-09-19  9:55 ` [PATCH v2 04/10] media: v4l2-dev: Add helpers to get current format from the state Jai Luthra
2025-09-22  8:06   ` Hans Verkuil
2025-09-29 16:16     ` Jai Luthra
2025-09-19  9:55 ` [PATCH v2 05/10] media: v4l2-ioctl: Add video_device_state argument to v4l2 ioctl wrappers Jai Luthra
2025-09-22  8:09   ` Hans Verkuil
2025-09-22  8:10     ` Hans Verkuil
2025-09-19  9:55 ` [PATCH v2 06/10] media: Replace void * with video_device_state * in all driver ioctl implementations Jai Luthra
2026-03-07 19:49   ` David Dull
2026-03-08 10:37     ` Laurent Pinchart
2026-03-07 20:06   ` David Dull
2025-09-19  9:55 ` [PATCH v2 07/10] media: v4l2-ioctl: Pass device state for G/S/TRY_FMT ioctls Jai Luthra
2025-09-22  8:11   ` Hans Verkuil [this message]
2025-09-19  9:56 ` [PATCH v2 08/10] media: ti: j721e-csi2rx: Use video_device_state Jai Luthra
2025-09-22  8:16   ` Hans Verkuil
2025-09-29 16:21     ` Jai Luthra
2025-09-19  9:56 ` [PATCH v2 09/10] media: rkisp1: " Jai Luthra
2025-09-19  9:56 ` [PATCH v2 10/10] media: rkisp1: Calculate format information on demand Jai Luthra
2025-09-20 10:48 ` [PATCH v2 00/10] media: Introduce video device state management Andy Shevchenko

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=097124ea-cf9b-425c-bb5f-a305224328f6@kernel.org \
    --to=hverkuil+cisco@kernel.org \
    --cc=hansg@kernel.org \
    --cc=hverkuil@kernel.org \
    --cc=jacopo.mondi@ideasonboard.com \
    --cc=jai.luthra@ideasonboard.com \
    --cc=laurent.pinchart+renesas@ideasonboard.com \
    --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 \
    --cc=sakari.ailus@linux.intel.com \
    --cc=tomi.valkeinen@ideasonboard.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