From nobody Thu Oct 2 09:17:06 2025 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 933902F83BA; Fri, 19 Sep 2025 09:57:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758275866; cv=none; b=mZ2ZKLwXpW27ZmuR4dU3fZy7bQwToCxSAUhdVtZANBaBfJ2+1oJtfpuZ7Ol1t8Scgi7jsw2W2HqFWKrI2e+dbMzYfpdLRm66LhcQ+bUfH6UOt8Y3Fo5B0pZO1t+Duj3skdn2rqSJRKZefWbZQUddK35zVrVNLO4IlUzURjQXE/M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758275866; c=relaxed/simple; bh=XNnJ6n8emPTeuOsinNTjhgf/eEcs0/njtyMq0631uec=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=GhmEdT9SPcCtzTIALWCf4kF5b/CGcFrr2C0Qzz9qCIskmvIGDISdqC/MqjUFtVLjKQTj6BmE92JHcBnU5pPuJgMrHKYrY8II1/kDbBHPFjQCT3h3uOnLAoJN5QgzicSKBpYQnfNOaKLTuzs1NHS6f/cHjv8Kq3+Z5WLXLOGxbNo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=fCn2SfwH; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="fCn2SfwH" Received: from mail.ideasonboard.com (unknown [IPv6:2401:4900:1c30:4816:952:3054:81b6:1a3a]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id CB4C6D3E; Fri, 19 Sep 2025 11:56:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1758275782; bh=XNnJ6n8emPTeuOsinNTjhgf/eEcs0/njtyMq0631uec=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=fCn2SfwH3pbehC5d6BM5q6QCWLF+LLW5iGQGSe+Lqyrsg75wVZUexcsTukx7BZPr+ WAaKU9z8DRFW6VKaCOwjum4Nnszb1mfYYA4SKlh474OaAYizRlPKzI3uQrL00y8txT WcFbM8Pn/vZmn1pSKImztVpi3H/W0m3ZdeqZdu+4= From: Jai Luthra Date: Fri, 19 Sep 2025 15:25:59 +0530 Subject: [PATCH v2 07/10] media: v4l2-ioctl: Pass device state for G/S/TRY_FMT ioctls Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250919-vdev-state-v2-7-b2c42426965c@ideasonboard.com> References: <20250919-vdev-state-v2-0-b2c42426965c@ideasonboard.com> In-Reply-To: <20250919-vdev-state-v2-0-b2c42426965c@ideasonboard.com> To: Hans Verkuil , Mauro Carvalho Chehab , Sakari Ailus , Laurent Pinchart , Tomi Valkeinen , Jacopo Mondi , linux-media@vger.kernel.org Cc: Jai Luthra , Laurent Pinchart , Ricardo Ribalda , Hans de Goede , linux-kernel@vger.kernel.org X-Mailer: b4 0.14.2 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 -- Cc: Mauro Carvalho Chehab Cc: Hans Verkuil Cc: Laurent Pinchart Cc: Ricardo Ribalda Cc: Hans de Goede Cc: Jai Luthra 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(-) diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core= /v4l2-ioctl.c index 644f06521673ff7ce5b194335d50f0e375ca7f51..500fc20627c97ce70016f452430= 1835142b7bebd 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 i= nt cmd) } EXPORT_SYMBOL(v4l_printk_ioctl); =20 +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 =3D vfd->ioctl_ops; bool write_only =3D false; + struct video_device_state *state =3D NULL; struct v4l2_ioctl_info default_info; const struct v4l2_ioctl_info *info; struct v4l2_fh *vfh =3D file_to_v4l2_fh(file); @@ -3090,6 +3106,9 @@ static long __video_do_ioctl(struct file *file, return ret; } =20 + if (test_bit(V4L2_FL_USES_STATE, &vfd->flags)) + state =3D 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, =20 write_only =3D _IOC_DIR(cmd) =3D=3D _IOC_WRITE; if (info !=3D &default_info) { - ret =3D info->func(ops, file, NULL, arg); + ret =3D info->func(ops, file, state, arg); } else if (!ops->vidioc_default) { ret =3D -ENOTTY; } else { - ret =3D ops->vidioc_default(file, NULL, + ret =3D ops->vidioc_default(file, state, v4l2_prio_check(vfd->prio, vfh->prio) >=3D 0, cmd, arg); } --=20 2.51.0