]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.9.180/media-ov2659-make-s_fmt-succeed-even-if-requested-fo.patch
Linux 4.9.180
[thirdparty/kernel/stable-queue.git] / releases / 4.9.180 / media-ov2659-make-s_fmt-succeed-even-if-requested-fo.patch
CommitLineData
2f47b8fc
SL
1From 9448837cbe97f249ec327849b4f7df78e4e322a7 Mon Sep 17 00:00:00 2001
2From: Akinobu Mita <akinobu.mita@gmail.com>
3Date: Sat, 30 Mar 2019 10:01:31 -0400
4Subject: media: ov2659: make S_FMT succeed even if requested format doesn't
5 match
6
7[ Upstream commit bccb89cf9cd07a0690d519696a00c00a973b3fe4 ]
8
9This driver returns an error if unsupported media bus pixel code is
10requested by VIDIOC_SUBDEV_S_FMT.
11
12But according to Documentation/media/uapi/v4l/vidioc-subdev-g-fmt.rst,
13
14Drivers must not return an error solely because the requested format
15doesn't match the device capabilities. They must instead modify the
16format to match what the hardware can provide.
17
18So select default format code and return success in that case.
19
20This is detected by v4l2-compliance.
21
22Cc: "Lad, Prabhakar" <prabhakar.csengg@gmail.com>
23Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
24Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
25Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
26Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
27Signed-off-by: Sasha Levin <sashal@kernel.org>
28---
29 drivers/media/i2c/ov2659.c | 6 ++++--
30 1 file changed, 4 insertions(+), 2 deletions(-)
31
32diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c
33index 1f999e9c0118e..3554eea77e04c 100644
34--- a/drivers/media/i2c/ov2659.c
35+++ b/drivers/media/i2c/ov2659.c
36@@ -1117,8 +1117,10 @@ static int ov2659_set_fmt(struct v4l2_subdev *sd,
37 if (ov2659_formats[index].code == mf->code)
38 break;
39
40- if (index < 0)
41- return -EINVAL;
42+ if (index < 0) {
43+ index = 0;
44+ mf->code = ov2659_formats[index].code;
45+ }
46
47 mf->colorspace = V4L2_COLORSPACE_SRGB;
48 mf->code = ov2659_formats[index].code;
49--
502.20.1
51