@@ -145,23 +145,61 @@ struct imx219_mode {
145145 struct imx219_reg_list reg_list ;
146146};
147147
148- /*
149- * Register sets lifted off the i2C interface from the Raspberry Pi firmware
150- * driver.
151- * 3280x2464 = mode 2, 1920x1080 = mode 1, 1640x1232 = mode 4, 640x480 = mode 7.
152- */
153- static const struct imx219_reg mode_3280x2464_regs [] = {
154- {0x0100 , 0x00 },
148+ static const struct imx219_reg imx219_common_regs [] = {
149+ {0x0100 , 0x00 }, /* Mode Select */
150+
151+ /* To Access Addresses 3000-5fff, send the following commands */
155152 {0x30eb , 0x0c },
156153 {0x30eb , 0x05 },
157154 {0x300a , 0xff },
158155 {0x300b , 0xff },
159156 {0x30eb , 0x05 },
160157 {0x30eb , 0x09 },
161- {0x0114 , 0x01 },
162- {0x0128 , 0x00 },
163- {0x012a , 0x18 },
158+
159+ /* PLL Clock Table */
160+ {0x0301 , 0x05 }, /* VTPXCK_DIV */
161+ {0x0303 , 0x01 }, /* VTSYSCK_DIV */
162+ {0x0304 , 0x03 }, /* PREPLLCK_VT_DIV 0x03 = AUTO set */
163+ {0x0305 , 0x03 }, /* PREPLLCK_OP_DIV 0x03 = AUTO set */
164+ {0x0306 , 0x00 }, /* PLL_VT_MPY */
165+ {0x0307 , 0x39 },
166+ {0x030b , 0x01 }, /* OP_SYS_CLK_DIV */
167+ {0x030c , 0x00 }, /* PLL_OP_MPY */
168+ {0x030d , 0x72 },
169+
170+ /* Undocumented registers */
171+ {0x455e , 0x00 },
172+ {0x471e , 0x4b },
173+ {0x4767 , 0x0f },
174+ {0x4750 , 0x14 },
175+ {0x4540 , 0x00 },
176+ {0x47b4 , 0x14 },
177+ {0x4713 , 0x30 },
178+ {0x478b , 0x10 },
179+ {0x478f , 0x10 },
180+ {0x4793 , 0x10 },
181+ {0x4797 , 0x0e },
182+ {0x479b , 0x0e },
183+
184+ /* Frame Bank Register Group "A" */
185+ {0x0162 , 0x0d }, /* Line_Length_A */
186+ {0x0163 , 0x78 },
187+ {0x0170 , 0x01 }, /* X_ODD_INC_A */
188+ {0x0171 , 0x01 }, /* Y_ODD_INC_A */
189+
190+ /* Output setup registers */
191+ {0x0114 , 0x01 }, /* CSI 2-Lane Mode */
192+ {0x0128 , 0x00 }, /* DPHY Auto Mode */
193+ {0x012a , 0x18 }, /* EXCK_Freq */
164194 {0x012b , 0x00 },
195+ };
196+
197+ /*
198+ * Register sets lifted off the i2C interface from the Raspberry Pi firmware
199+ * driver.
200+ * 3280x2464 = mode 2, 1920x1080 = mode 1, 1640x1232 = mode 4, 640x480 = mode 7.
201+ */
202+ static const struct imx219_reg mode_3280x2464_regs [] = {
165203 {0x0164 , 0x00 },
166204 {0x0165 , 0x00 },
167205 {0x0166 , 0x0c },
@@ -174,53 +212,15 @@ static const struct imx219_reg mode_3280x2464_regs[] = {
174212 {0x016d , 0xd0 },
175213 {0x016e , 0x09 },
176214 {0x016f , 0xa0 },
177- {0x0170 , 0x01 },
178- {0x0171 , 0x01 },
179- {0x0174 , 0x00 },
215+ {0x0174 , 0x00 }, /* No-Binning */
180216 {0x0175 , 0x00 },
181- {0x0301 , 0x05 },
182- {0x0303 , 0x01 },
183- {0x0304 , 0x03 },
184- {0x0305 , 0x03 },
185- {0x0306 , 0x00 },
186- {0x0307 , 0x39 },
187- {0x030b , 0x01 },
188- {0x030c , 0x00 },
189- {0x030d , 0x72 },
190217 {0x0624 , 0x0c },
191218 {0x0625 , 0xd0 },
192219 {0x0626 , 0x09 },
193220 {0x0627 , 0xa0 },
194- {0x455e , 0x00 },
195- {0x471e , 0x4b },
196- {0x4767 , 0x0f },
197- {0x4750 , 0x14 },
198- {0x4540 , 0x00 },
199- {0x47b4 , 0x14 },
200- {0x4713 , 0x30 },
201- {0x478b , 0x10 },
202- {0x478f , 0x10 },
203- {0x4793 , 0x10 },
204- {0x4797 , 0x0e },
205- {0x479b , 0x0e },
206- {0x0162 , 0x0d },
207- {0x0163 , 0x78 },
208221};
209222
210223static const struct imx219_reg mode_1920_1080_regs [] = {
211- {0x0100 , 0x00 },
212- {0x30eb , 0x05 },
213- {0x30eb , 0x0c },
214- {0x300a , 0xff },
215- {0x300b , 0xff },
216- {0x30eb , 0x05 },
217- {0x30eb , 0x09 },
218- {0x0114 , 0x01 },
219- {0x0128 , 0x00 },
220- {0x012a , 0x18 },
221- {0x012b , 0x00 },
222- {0x0162 , 0x0d },
223- {0x0163 , 0x78 },
224224 {0x0164 , 0x02 },
225225 {0x0165 , 0xa8 },
226226 {0x0166 , 0x0a },
@@ -233,49 +233,15 @@ static const struct imx219_reg mode_1920_1080_regs[] = {
233233 {0x016d , 0x80 },
234234 {0x016e , 0x04 },
235235 {0x016f , 0x38 },
236- {0x0170 , 0x01 },
237- {0x0171 , 0x01 },
238- {0x0174 , 0x00 },
236+ {0x0174 , 0x00 }, /* No-Binning */
239237 {0x0175 , 0x00 },
240- {0x0301 , 0x05 },
241- {0x0303 , 0x01 },
242- {0x0304 , 0x03 },
243- {0x0305 , 0x03 },
244- {0x0306 , 0x00 },
245- {0x0307 , 0x39 },
246- {0x030b , 0x01 },
247- {0x030c , 0x00 },
248- {0x030d , 0x72 },
249238 {0x0624 , 0x07 },
250239 {0x0625 , 0x80 },
251240 {0x0626 , 0x04 },
252241 {0x0627 , 0x38 },
253- {0x455e , 0x00 },
254- {0x471e , 0x4b },
255- {0x4767 , 0x0f },
256- {0x4750 , 0x14 },
257- {0x4540 , 0x00 },
258- {0x47b4 , 0x14 },
259- {0x4713 , 0x30 },
260- {0x478b , 0x10 },
261- {0x478f , 0x10 },
262- {0x4793 , 0x10 },
263- {0x4797 , 0x0e },
264- {0x479b , 0x0e },
265242};
266243
267244static const struct imx219_reg mode_1640_1232_regs [] = {
268- {0x0100 , 0x00 },
269- {0x30eb , 0x0c },
270- {0x30eb , 0x05 },
271- {0x300a , 0xff },
272- {0x300b , 0xff },
273- {0x30eb , 0x05 },
274- {0x30eb , 0x09 },
275- {0x0114 , 0x01 },
276- {0x0128 , 0x00 },
277- {0x012a , 0x18 },
278- {0x012b , 0x00 },
279245 {0x0164 , 0x00 },
280246 {0x0165 , 0x00 },
281247 {0x0166 , 0x0c },
@@ -288,53 +254,15 @@ static const struct imx219_reg mode_1640_1232_regs[] = {
288254 {0x016d , 0x68 },
289255 {0x016e , 0x04 },
290256 {0x016f , 0xd0 },
291- {0x0170 , 0x01 },
292- {0x0171 , 0x01 },
293- {0x0174 , 0x01 },
257+ {0x0174 , 0x01 }, /* x2-Binning */
294258 {0x0175 , 0x01 },
295- {0x0301 , 0x05 },
296- {0x0303 , 0x01 },
297- {0x0304 , 0x03 },
298- {0x0305 , 0x03 },
299- {0x0306 , 0x00 },
300- {0x0307 , 0x39 },
301- {0x030b , 0x01 },
302- {0x030c , 0x00 },
303- {0x030d , 0x72 },
304259 {0x0624 , 0x06 },
305260 {0x0625 , 0x68 },
306261 {0x0626 , 0x04 },
307262 {0x0627 , 0xd0 },
308- {0x455e , 0x00 },
309- {0x471e , 0x4b },
310- {0x4767 , 0x0f },
311- {0x4750 , 0x14 },
312- {0x4540 , 0x00 },
313- {0x47b4 , 0x14 },
314- {0x4713 , 0x30 },
315- {0x478b , 0x10 },
316- {0x478f , 0x10 },
317- {0x4793 , 0x10 },
318- {0x4797 , 0x0e },
319- {0x479b , 0x0e },
320- {0x0162 , 0x0d },
321- {0x0163 , 0x78 },
322263};
323264
324265static const struct imx219_reg mode_640_480_regs [] = {
325- {0x0100 , 0x00 },
326- {0x30eb , 0x05 },
327- {0x30eb , 0x0c },
328- {0x300a , 0xff },
329- {0x300b , 0xff },
330- {0x30eb , 0x05 },
331- {0x30eb , 0x09 },
332- {0x0114 , 0x01 },
333- {0x0128 , 0x00 },
334- {0x012a , 0x18 },
335- {0x012b , 0x00 },
336- {0x0162 , 0x0d },
337- {0x0163 , 0x78 },
338266 {0x0164 , 0x03 },
339267 {0x0165 , 0xe8 },
340268 {0x0166 , 0x08 },
@@ -347,35 +275,12 @@ static const struct imx219_reg mode_640_480_regs[] = {
347275 {0x016d , 0x80 },
348276 {0x016e , 0x01 },
349277 {0x016f , 0xe0 },
350- {0x0170 , 0x01 },
351- {0x0171 , 0x01 },
352- {0x0174 , 0x03 },
278+ {0x0174 , 0x03 }, /* x2-analog binning */
353279 {0x0175 , 0x03 },
354- {0x0301 , 0x05 },
355- {0x0303 , 0x01 },
356- {0x0304 , 0x03 },
357- {0x0305 , 0x03 },
358- {0x0306 , 0x00 },
359- {0x0307 , 0x39 },
360- {0x030b , 0x01 },
361- {0x030c , 0x00 },
362- {0x030d , 0x72 },
363280 {0x0624 , 0x06 },
364281 {0x0625 , 0x68 },
365282 {0x0626 , 0x04 },
366283 {0x0627 , 0xd0 },
367- {0x455e , 0x00 },
368- {0x471e , 0x4b },
369- {0x4767 , 0x0f },
370- {0x4750 , 0x14 },
371- {0x4540 , 0x00 },
372- {0x47b4 , 0x14 },
373- {0x4713 , 0x30 },
374- {0x478b , 0x10 },
375- {0x478f , 0x10 },
376- {0x4793 , 0x10 },
377- {0x4797 , 0x0e },
378- {0x479b , 0x0e },
379284};
380285
381286static const struct imx219_reg raw8_framefmt_regs [] = {
@@ -1041,6 +946,13 @@ static int imx219_start_streaming(struct imx219 *imx219)
1041946 if (ret < 0 )
1042947 return ret ;
1043948
949+ /* Send all registers that are common to all modes */
950+ ret = imx219_write_regs (imx219 , imx219_common_regs , ARRAY_SIZE (imx219_common_regs ));
951+ if (ret ) {
952+ dev_err (& client -> dev , "%s failed to send mfg header\n" , __func__ );
953+ goto err_rpm_put ;
954+ }
955+
1044956 /* Apply default values of current mode */
1045957 reg_list = & imx219 -> mode -> reg_list ;
1046958 ret = imx219_write_regs (imx219 , reg_list -> regs , reg_list -> num_of_regs );
0 commit comments