bcm27xx: import latest patches from the RPi foundation
[openwrt/openwrt.git] / target / linux / bcm27xx / patches-5.4 / 950-1023-media-i2c-imx219-Selection-compliance-fixes.patch
1 From de47ea073936726d9a5ad843908fd3074c1fb8f0 Mon Sep 17 00:00:00 2001
2 From: Hans Verkuil <hverkuil@xs4all.nl>
3 Date: Wed, 5 Aug 2020 12:57:21 +0200
4 Subject: [PATCH] media: i2c: imx219: Selection compliance fixes
5
6 To comply with the intended usage of the V4L2 selection target when
7 used to retrieve a sensor image properties, adjust the rectangles
8 returned by the imx219 driver.
9
10 The top/left crop coordinates of the TGT_CROP rectangle were set to
11 (0, 0) instead of (8, 8) which is the offset from the larger physical
12 pixel array rectangle. This was also a mismatch with the default values
13 crop rectangle value, so this is corrected. Found with v4l2-compliance.
14
15 While at it, add V4L2_SEL_TGT_CROP_BOUNDS support: CROP_DEFAULT and
16 CROP_BOUNDS have the same size as the non-active pixels are not readable
17 using the selection API. Found with v4l2-compliance.
18
19 Fixes: e6d4ef7d58aa7 ("media: i2c: imx219: Implement get_selection")
20 Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
21 [reword commit message, use macros for pixel offsets]
22 Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
23 ---
24 drivers/media/i2c/imx219.c | 17 +++++++++--------
25 1 file changed, 9 insertions(+), 8 deletions(-)
26
27 --- a/drivers/media/i2c/imx219.c
28 +++ b/drivers/media/i2c/imx219.c
29 @@ -485,8 +485,8 @@ static const struct imx219_mode supporte
30 .width = 3280,
31 .height = 2464,
32 .crop = {
33 - .left = 0,
34 - .top = 0,
35 + .left = IMX219_PIXEL_ARRAY_LEFT,
36 + .top = IMX219_PIXEL_ARRAY_TOP,
37 .width = 3280,
38 .height = 2464
39 },
40 @@ -501,8 +501,8 @@ static const struct imx219_mode supporte
41 .width = 1920,
42 .height = 1080,
43 .crop = {
44 - .left = 680,
45 - .top = 692,
46 + .left = 688,
47 + .top = 700,
48 .width = 1920,
49 .height = 1080
50 },
51 @@ -517,8 +517,8 @@ static const struct imx219_mode supporte
52 .width = 1640,
53 .height = 1232,
54 .crop = {
55 - .left = 0,
56 - .top = 0,
57 + .left = IMX219_PIXEL_ARRAY_LEFT,
58 + .top = IMX219_PIXEL_ARRAY_TOP,
59 .width = 3280,
60 .height = 2464
61 },
62 @@ -533,8 +533,8 @@ static const struct imx219_mode supporte
63 .width = 640,
64 .height = 480,
65 .crop = {
66 - .left = 1000,
67 - .top = 752,
68 + .left = 1008,
69 + .top = 760,
70 .width = 1280,
71 .height = 960
72 },
73 @@ -1093,6 +1093,7 @@ static int imx219_get_selection(struct v
74 return 0;
75
76 case V4L2_SEL_TGT_CROP_DEFAULT:
77 + case V4L2_SEL_TGT_CROP_BOUNDS:
78 sel->r.top = IMX219_PIXEL_ARRAY_TOP;
79 sel->r.left = IMX219_PIXEL_ARRAY_LEFT;
80 sel->r.width = IMX219_PIXEL_ARRAY_WIDTH;