diff mbox series

[PATCHv2,13/19] media: common: saa7146: fall back to V4L2_PIX_FMT_BGR24

Message ID 20230323155343.2399473-14-hverkuil-cisco@xs4all.nl
State New
Headers show
Series saa7146: convert to vb2 | expand

Commit Message

Hans Verkuil March 23, 2023, 3:53 p.m. UTC
If the requested pixelformat is not supported, then fall
back to V4L2_PIX_FMT_BGR24 for improved V4L2 compliance.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
---
 drivers/media/common/saa7146/saa7146_video.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/media/common/saa7146/saa7146_video.c b/drivers/media/common/saa7146/saa7146_video.c
index e698b4470db3..d706aa3b5967 100644
--- a/drivers/media/common/saa7146/saa7146_video.c
+++ b/drivers/media/common/saa7146/saa7146_video.c
@@ -367,8 +367,10 @@  static int vidioc_try_fmt_vid_cap(struct file *file, void *fh, struct v4l2_forma
 	DEB_EE("V4L2_BUF_TYPE_VIDEO_CAPTURE: dev:%p, fh:%p\n", dev, fh);
 
 	fmt = saa7146_format_by_fourcc(dev, f->fmt.pix.pixelformat);
-	if (NULL == fmt)
-		return -EINVAL;
+	if (!fmt) {
+		f->fmt.pix.pixelformat = V4L2_PIX_FMT_BGR24;
+		fmt = saa7146_format_by_fourcc(dev, f->fmt.pix.pixelformat);
+	}
 
 	field = f->fmt.pix.field;
 	maxw  = vv->standard->h_max_out;