]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: omap3isp: rework isp_video_try/set_format
authorHans Verkuil <hverkuil+cisco@kernel.org>
Wed, 30 Apr 2025 07:29:21 +0000 (09:29 +0200)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Tue, 6 Jan 2026 07:22:46 +0000 (08:22 +0100)
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>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
drivers/media/platform/ti/omap3isp/ispvideo.c

index c52312b395985228db117c61b84b8dd02fedd30b..adea39b6d930268a0f3774613acf2d17903d1b0c 100644 (file)
@@ -700,11 +700,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;
@@ -744,32 +748,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)
@@ -786,6 +769,24 @@ isp_video_try_format(struct file *file, void *fh, struct v4l2_format *format)
        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;
+
+       ret = isp_video_try_format(file, fh, format);
+       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)
 {