public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: Hans Verkuil <hverkuil+cisco@kernel.org>
Cc: linux-media@vger.kernel.org, laurent.pinchart@ideasonboard.com
Subject: Re: [PATCH 07/14] media: omap3isp: rework isp_video_try/set_format
Date: Wed, 22 Oct 2025 11:04:19 +0300	[thread overview]
Message-ID: <aPiQAwEa4_fN-LIt@kekkonen.localdomain> (raw)
In-Reply-To: <679d80346bef43fab642342ab9de407c132b62ed.1760707611.git.hverkuil+cisco@kernel.org>

Hi Hans,

On Fri, Oct 17, 2025 at 03:26:44PM +0200, Hans Verkuil wrote:
> isp_video_set_format now calls isp_video_try_format first, ensuring
> consistent behavior and removing duplicate code in both functions.
> 
> This fixes an v4l2-compliance error:
> 
> 	fail: v4l2-test-formats.cpp(519): !pix.sizeimage
> test VIDIOC_S_FMT: FAIL
> 
> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
> ---
>  drivers/media/platform/ti/omap3isp/ispvideo.c | 60 +++++++++----------
>  1 file changed, 30 insertions(+), 30 deletions(-)
> 
> diff --git a/drivers/media/platform/ti/omap3isp/ispvideo.c b/drivers/media/platform/ti/omap3isp/ispvideo.c
> index d3fe28506fb0..69d17e4dcd36 100644
> --- a/drivers/media/platform/ti/omap3isp/ispvideo.c
> +++ b/drivers/media/platform/ti/omap3isp/ispvideo.c
> @@ -701,11 +701,15 @@ isp_video_get_format(struct file *file, void *fh, struct v4l2_format *format)
>  }
>  
>  static int
> -isp_video_set_format(struct file *file, void *fh, struct v4l2_format *format)
> +isp_video_try_format(struct file *file, void *fh, struct v4l2_format *format)
>  {
> -	struct isp_video_fh *vfh = file_to_isp_video_fh(file);
>  	struct isp_video *video = video_drvdata(file);
> -	struct v4l2_mbus_framefmt fmt;
> +	struct v4l2_subdev_format fmt = {
> +		.which = V4L2_SUBDEV_FORMAT_ACTIVE,
> +	};
> +	struct v4l2_subdev *subdev;
> +	u32 pad;
> +	int ret;
>  
>  	if (format->type != video->type)
>  		return -EINVAL;
> @@ -745,32 +749,11 @@ isp_video_set_format(struct file *file, void *fh, struct v4l2_format *format)
>  		break;
>  	}
>  
> -	/* Fill the bytesperline and sizeimage fields by converting to media bus
> -	 * format and back to pixel format.
> -	 */
> -	isp_video_pix_to_mbus(&format->fmt.pix, &fmt);
> -	isp_video_mbus_to_pix(video, &fmt, &format->fmt.pix);
> -
> -	mutex_lock(&video->mutex);
> -	vfh->format = *format;
> -	mutex_unlock(&video->mutex);
> -
> -	return 0;
> -}
> -
> -static int
> -isp_video_try_format(struct file *file, void *fh, struct v4l2_format *format)
> -{
> -	struct isp_video *video = video_drvdata(file);
> -	struct v4l2_subdev_format fmt = {
> -		.which = V4L2_SUBDEV_FORMAT_ACTIVE,
> -	};
> -	struct v4l2_subdev *subdev;
> -	u32 pad;
> -	int ret;
> -
> -	if (format->type != video->type)
> -		return -EINVAL;
> +	if (video->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) {
> +		isp_video_pix_to_mbus(&format->fmt.pix, &fmt.format);
> +		isp_video_mbus_to_pix(video, &fmt.format, &format->fmt.pix);
> +		return 0;
> +	}
>  
>  	subdev = isp_video_remote_subdev(video, &pad);
>  	if (subdev == NULL)
> @@ -781,12 +764,29 @@ isp_video_try_format(struct file *file, void *fh, struct v4l2_format *format)
>  	fmt.pad = pad;
>  	ret = v4l2_subdev_call(subdev, pad, get_fmt, NULL, &fmt);
>  	if (ret)
> -		return ret == -ENOIOCTLCMD ? -ENOTTY : ret;
> +		return ret == -ENOIOCTLCMD ? -EINVAL : ret;

I believe -ENOTTY was right. Yet this should not happen (albeit I haven't
checked) as all omap3isp sub-device drivers with connected video devices
presumably implement get_fmt.

>  
>  	isp_video_mbus_to_pix(video, &fmt.format, &format->fmt.pix);
>  	return 0;
>  }
>  
> +static int
> +isp_video_set_format(struct file *file, void *fh, struct v4l2_format *format)
> +{
> +	struct isp_video_fh *vfh = file_to_isp_video_fh(file);
> +	struct isp_video *video = video_drvdata(file);
> +	int ret = isp_video_try_format(file, fh, format);

I'd do this assignment separately: initialising variables in declaration
that requires error handling isn't very nice.

> +
> +	if (ret)
> +		return ret;
> +
> +	mutex_lock(&video->mutex);
> +	vfh->format = *format;
> +	mutex_unlock(&video->mutex);
> +
> +	return 0;
> +}
> +
>  static int
>  isp_video_get_selection(struct file *file, void *fh, struct v4l2_selection *sel)
>  {

-- 
Kind regards,

Sakari Ailus

  reply	other threads:[~2025-10-22  8:04 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-17 13:26 [PATCH 00/14] media: omap3isp: v4l2-compliance fixes Hans Verkuil
2025-10-17 13:26 ` [PATCH 01/14] media: omap3isp: configure entity functions Hans Verkuil
2025-10-17 13:26 ` [PATCH 02/14] media: omap3isp: add V4L2_CAP_IO_MC and don't set bus_info Hans Verkuil
2025-10-17 13:26 ` [PATCH 03/14] media: omap3isp: isp_video_mbus_to_pix/pix_to_mbus fixes Hans Verkuil
2025-10-22  7:48   ` Sakari Ailus
2025-12-01  8:27     ` Hans Verkuil
2025-12-01 10:22       ` Sakari Ailus
2025-12-01 12:56         ` Sakari Ailus
2025-12-01 15:35           ` Hans Verkuil
2025-12-01 16:43             ` Sakari Ailus
2025-12-02  7:18               ` Hans Verkuil
2025-10-17 13:26 ` [PATCH 04/14] media: omap3isp: implement enum_fmt_vid_cap/out Hans Verkuil
2025-10-22  7:56   ` Sakari Ailus
2025-12-01  8:40     ` Hans Verkuil
2025-12-01 11:35       ` Sakari Ailus
2025-12-01 13:44         ` Hans Verkuil
2025-12-01 15:27           ` Sakari Ailus
2025-10-17 13:26 ` [PATCH 05/14] media: omap3isp: use V4L2_COLORSPACE_SRGB instead of _JPEG Hans Verkuil
2025-10-17 13:26 ` [PATCH 06/14] media: omap3isp: set initial format Hans Verkuil
2025-10-17 13:26 ` [PATCH 07/14] media: omap3isp: rework isp_video_try/set_format Hans Verkuil
2025-10-22  8:04   ` Sakari Ailus [this message]
2025-12-01  8:48     ` Hans Verkuil
2025-12-01 12:42       ` Sakari Ailus
2025-10-17 13:26 ` [PATCH 08/14] media: omap3isp: implement create/prepare_bufs Hans Verkuil
2025-10-22  8:06   ` Sakari Ailus
2025-12-01  8:54     ` Hans Verkuil
2025-12-01 12:42       ` Sakari Ailus
2025-10-17 13:26 ` [PATCH 09/14] media: omap3isp: better VIDIOC_G/S_PARM handling Hans Verkuil
2025-10-22  8:09   ` Sakari Ailus
2025-12-01 10:28     ` Hans Verkuil
2025-12-01 13:40       ` Hans Verkuil
2025-12-01 15:10         ` Sakari Ailus
2025-10-17 13:26 ` [PATCH 10/14] media: omap3isp: support ctrl events for isppreview Hans Verkuil
2025-10-17 13:26 ` [PATCH 11/14] media: omap3isp: ispccp2: always clamp in ccp2_try_format() Hans Verkuil
2025-10-17 13:26 ` [PATCH 12/14] media: omap3isp: isppreview: always clamp in preview_try_format() Hans Verkuil
2025-10-17 13:26 ` [PATCH 13/14] DO NOT MERGE: media: omap3isp: change default resolution to 864x648 Hans Verkuil
2025-10-17 13:26 ` [PATCH 14/14] DO NOT MERGE: omap3-beagle-xm.dts: add Leopard Imaging li5m03 support Hans Verkuil

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=aPiQAwEa4_fN-LIt@kekkonen.localdomain \
    --to=sakari.ailus@linux.intel.com \
    --cc=hverkuil+cisco@kernel.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.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