512cd6ae54dc2254af9816d79f9d25039ff546a9
[openwrt/staging/chunkeey.git] / target / linux / bcm27xx / patches-5.10 / 950-0490-media-i2c-imx477-Replace-existing-1012x760-mode.patch
1 From f90f60490c5f5f944077a42b2394c0b51c393ce1 Mon Sep 17 00:00:00 2001
2 From: Naushir Patuck <naush@raspberrypi.com>
3 Date: Thu, 18 Feb 2021 15:23:11 +0000
4 Subject: [PATCH] media: i2c: imx477: Replace existing 1012x760 mode
5
6 The existing 1012x760 120 fps mode has significant IQ problem using
7 the internal sensor scaler. Replace this mode with a 1332x990 120 fps
8 mode instead. This new mode has a smaller field of view, but does not
9 suffer from the bad IQ of the original mode.
10
11 Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
12 ---
13 drivers/media/i2c/imx477.c | 97 ++++++++++++++++++++------------------
14 1 file changed, 50 insertions(+), 47 deletions(-)
15
16 --- a/drivers/media/i2c/imx477.c
17 +++ b/drivers/media/i2c/imx477.c
18 @@ -770,7 +770,7 @@ static const struct imx477_reg mode_2028
19 };
20
21 /* 4x4 binned. 120fps */
22 -static const struct imx477_reg mode_1012x760_regs[] = {
23 +static const struct imx477_reg mode_1332x990_regs[] = {
24 {0x420b, 0x01},
25 {0x990c, 0x00},
26 {0x990d, 0x08},
27 @@ -786,28 +786,31 @@ static const struct imx477_reg mode_1012
28 {0x0112, 0x0a},
29 {0x0113, 0x0a},
30 {0x0114, 0x01},
31 - {0x0342, 0x14},
32 - {0x0343, 0x60},
33 + {0x0342, 0x1a},
34 + {0x0343, 0x08},
35 + {0x0340, 0x04},
36 + {0x0341, 0x1a},
37 {0x0344, 0x00},
38 {0x0345, 0x00},
39 - {0x0346, 0x00},
40 - {0x0347, 0x00},
41 + {0x0346, 0x02},
42 + {0x0347, 0x10},
43 {0x0348, 0x0f},
44 - {0x0349, 0xd3},
45 - {0x034a, 0x0b},
46 - {0x034b, 0xdf},
47 + {0x0349, 0xd7},
48 + {0x034a, 0x09},
49 + {0x034b, 0xcf},
50 {0x00e3, 0x00},
51 {0x00e4, 0x00},
52 {0x00fc, 0x0a},
53 {0x00fd, 0x0a},
54 {0x00fe, 0x0a},
55 {0x00ff, 0x0a},
56 + {0xe013, 0x00},
57 {0x0220, 0x00},
58 {0x0221, 0x11},
59 {0x0381, 0x01},
60 {0x0383, 0x01},
61 {0x0385, 0x01},
62 - {0x0387, 0x03},
63 + {0x0387, 0x01},
64 {0x0900, 0x01},
65 {0x0901, 0x22},
66 {0x0902, 0x02},
67 @@ -831,29 +834,29 @@ static const struct imx477_reg mode_1012
68 {0x936d, 0x5f},
69 {0x9304, 0x03},
70 {0x9305, 0x80},
71 - {0x9e9a, 0x3f},
72 - {0x9e9b, 0x3f},
73 - {0x9e9c, 0x3f},
74 - {0x9e9d, 0x27},
75 - {0x9e9e, 0x27},
76 - {0x9e9f, 0x27},
77 + {0x9e9a, 0x2f},
78 + {0x9e9b, 0x2f},
79 + {0x9e9c, 0x2f},
80 + {0x9e9d, 0x00},
81 + {0x9e9e, 0x00},
82 + {0x9e9f, 0x00},
83 {0xa2a9, 0x27},
84 {0xa2b7, 0x03},
85 - {0x0401, 0x01},
86 + {0x0401, 0x00},
87 {0x0404, 0x00},
88 - {0x0405, 0x20},
89 - {0x0408, 0x00},
90 - {0x0409, 0x00},
91 + {0x0405, 0x10},
92 + {0x0408, 0x01},
93 + {0x0409, 0x5c},
94 {0x040a, 0x00},
95 {0x040b, 0x00},
96 - {0x040c, 0x07},
97 - {0x040d, 0xea},
98 - {0x040e, 0x02},
99 - {0x040f, 0xf8},
100 - {0x034c, 0x03},
101 - {0x034d, 0xf4},
102 - {0x034e, 0x02},
103 - {0x034f, 0xf8},
104 + {0x040c, 0x05},
105 + {0x040d, 0x34},
106 + {0x040e, 0x03},
107 + {0x040f, 0xde},
108 + {0x034c, 0x05},
109 + {0x034d, 0x34},
110 + {0x034e, 0x03},
111 + {0x034f, 0xde},
112 {0x0301, 0x05},
113 {0x0303, 0x02},
114 {0x0305, 0x02},
115 @@ -870,21 +873,21 @@ static const struct imx477_reg mode_1012
116 {0x0822, 0x00},
117 {0x0823, 0x00},
118 {0x080a, 0x00},
119 - {0x080b, 0x6f},
120 + {0x080b, 0x7f},
121 {0x080c, 0x00},
122 - {0x080d, 0x3f},
123 + {0x080d, 0x4f},
124 {0x080e, 0x00},
125 - {0x080f, 0xff},
126 + {0x080f, 0x77},
127 {0x0810, 0x00},
128 - {0x0811, 0x4f},
129 + {0x0811, 0x5f},
130 {0x0812, 0x00},
131 - {0x0813, 0x47},
132 + {0x0813, 0x57},
133 {0x0814, 0x00},
134 - {0x0815, 0x37},
135 - {0x0816, 0x00},
136 - {0x0817, 0xe7},
137 + {0x0815, 0x4f},
138 + {0x0816, 0x01},
139 + {0x0817, 0x27},
140 {0x0818, 0x00},
141 - {0x0819, 0x2f},
142 + {0x0819, 0x3f},
143 {0xe04c, 0x00},
144 {0xe04d, 0x5f},
145 {0xe04e, 0x00},
146 @@ -893,7 +896,7 @@ static const struct imx477_reg mode_1012
147 {0x3e37, 0x00},
148 {0x3f50, 0x00},
149 {0x3f56, 0x00},
150 - {0x3f57, 0x96},
151 + {0x3f57, 0xbf},
152 };
153
154 /* Mode configs */
155 @@ -974,9 +977,9 @@ static const struct imx477_mode supporte
156
157 static const struct imx477_mode supported_modes_10bit[] = {
158 {
159 - /* 720P 120fps. 4x4 binned */
160 - .width = 1012,
161 - .height = 760,
162 + /* 120fps. 2x2 binned and cropped */
163 + .width = 1332,
164 + .height = 990,
165 .line_length_pix = 0x1460,
166 .crop = {
167 /*
168 @@ -987,10 +990,10 @@ static const struct imx477_mode supporte
169 * rectangle once the driver is expanded to represent
170 * its processing blocks with multiple subdevs.
171 */
172 - .left = IMX477_PIXEL_ARRAY_LEFT + 4,
173 - .top = IMX477_PIXEL_ARRAY_TOP,
174 - .width = 4052,
175 - .height = 3040,
176 + .left = IMX477_PIXEL_ARRAY_LEFT + 696,
177 + .top = IMX477_PIXEL_ARRAY_TOP + 528,
178 + .width = 2664,
179 + .height = 1980,
180 },
181 .timeperframe_min = {
182 .numerator = 100,
183 @@ -998,11 +1001,11 @@ static const struct imx477_mode supporte
184 },
185 .timeperframe_default = {
186 .numerator = 100,
187 - .denominator = 60000
188 + .denominator = 12000
189 },
190 .reg_list = {
191 - .num_of_regs = ARRAY_SIZE(mode_1012x760_regs),
192 - .regs = mode_1012x760_regs,
193 + .num_of_regs = ARRAY_SIZE(mode_1332x990_regs),
194 + .regs = mode_1332x990_regs,
195 }
196 }
197 };