On Wed Apr 30 09:29:21 2025 +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 <[email protected]>
> Acked-by: Sakari Ailus <[email protected]>
Patch committed.
Thanks,
Hans Verkuil
drivers/media/platform/ti/omap3isp/ispvideo.c | 59 ++++++++++++++-------------
1 file changed, 30 insertions(+), 29 deletions(-)
---
diff --git a/drivers/media/platform/ti/omap3isp/ispvideo.c
b/drivers/media/platform/ti/omap3isp/ispvideo.c
index c52312b39598..adea39b6d930 100644
--- a/drivers/media/platform/ti/omap3isp/ispvideo.c
+++ b/drivers/media/platform/ti/omap3isp/ispvideo.c
@@ -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)
{
_______________________________________________
linuxtv-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]