1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Support for OmniVision OV5693 5M camera sensor.
4  *
5  * Copyright (c) 2013 Intel Corporation. All Rights Reserved.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License version
9  * 2 as published by the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  *
17  */
18 
19 #ifndef __OV5693_H__
20 #define __OV5693_H__
21 #include <linux/kernel.h>
22 #include <linux/types.h>
23 #include <linux/i2c.h>
24 #include <linux/delay.h>
25 #include <linux/videodev2.h>
26 #include <linux/spinlock.h>
27 #include <media/v4l2-subdev.h>
28 #include <media/v4l2-device.h>
29 #include <media/v4l2-ctrls.h>
30 #include <linux/v4l2-mediabus.h>
31 #include <media/media-entity.h>
32 
33 #include "../../include/linux/atomisp_platform.h"
34 
35 /*
36  * FIXME: non-preview resolutions are currently broken
37  */
38 #define ENABLE_NON_PREVIEW	0
39 
40 #define OV5693_POWER_UP_RETRY_NUM 5
41 
42 /* Defines for register writes and register array processing */
43 #define I2C_MSG_LENGTH		0x2
44 #define I2C_RETRY_COUNT		5
45 
46 #define OV5693_FOCAL_LENGTH_NUM	334	/*3.34mm*/
47 #define OV5693_FOCAL_LENGTH_DEM	100
48 #define OV5693_F_NUMBER_DEFAULT_NUM	24
49 #define OV5693_F_NUMBER_DEM	10
50 
51 #define MAX_FMTS		1
52 
53 /* sensor_mode_data read_mode adaptation */
54 #define OV5693_READ_MODE_BINNING_ON	0x0400
55 #define OV5693_READ_MODE_BINNING_OFF	0x00
56 #define OV5693_INTEGRATION_TIME_MARGIN	8
57 
58 #define OV5693_MAX_EXPOSURE_VALUE	0xFFF1
59 #define OV5693_MAX_GAIN_VALUE		0xFF
60 
61 /*
62  * focal length bits definition:
63  * bits 31-16: numerator, bits 15-0: denominator
64  */
65 #define OV5693_FOCAL_LENGTH_DEFAULT 0x1B70064
66 
67 /*
68  * current f-number bits definition:
69  * bits 31-16: numerator, bits 15-0: denominator
70  */
71 #define OV5693_F_NUMBER_DEFAULT 0x18000a
72 
73 /*
74  * f-number range bits definition:
75  * bits 31-24: max f-number numerator
76  * bits 23-16: max f-number denominator
77  * bits 15-8: min f-number numerator
78  * bits 7-0: min f-number denominator
79  */
80 #define OV5693_F_NUMBER_RANGE 0x180a180a
81 #define OV5693_ID	0x5690
82 
83 #define OV5693_FINE_INTG_TIME_MIN 0
84 #define OV5693_FINE_INTG_TIME_MAX_MARGIN 0
85 #define OV5693_COARSE_INTG_TIME_MIN 1
86 #define OV5693_COARSE_INTG_TIME_MAX_MARGIN 6
87 
88 #define OV5693_BIN_FACTOR_MAX 4
89 /*
90  * OV5693 System control registers
91  */
92 #define OV5693_SW_SLEEP				0x0100
93 #define OV5693_SW_RESET				0x0103
94 #define OV5693_SW_STREAM			0x0100
95 
96 #define OV5693_SC_CMMN_CHIP_ID_H		0x300A
97 #define OV5693_SC_CMMN_CHIP_ID_L		0x300B
98 #define OV5693_SC_CMMN_SCCB_ID			0x300C
99 #define OV5693_SC_CMMN_SUB_ID			0x302A /* process, version*/
100 /*Bit[7:4] Group control, Bit[3:0] Group ID*/
101 #define OV5693_GROUP_ACCESS			0x3208
102 /*
103 *Bit[3:0] Bit[19:16] of exposure,
104 *remaining 16 bits lies in Reg0x3501&Reg0x3502
105 */
106 #define OV5693_EXPOSURE_H			0x3500
107 #define OV5693_EXPOSURE_M			0x3501
108 #define OV5693_EXPOSURE_L			0x3502
109 /*Bit[1:0] means Bit[9:8] of gain*/
110 #define OV5693_AGC_H				0x350A
111 #define OV5693_AGC_L				0x350B /*Bit[7:0] of gain*/
112 
113 #define OV5693_HORIZONTAL_START_H		0x3800 /*Bit[11:8]*/
114 #define OV5693_HORIZONTAL_START_L		0x3801 /*Bit[7:0]*/
115 #define OV5693_VERTICAL_START_H			0x3802 /*Bit[11:8]*/
116 #define OV5693_VERTICAL_START_L			0x3803 /*Bit[7:0]*/
117 #define OV5693_HORIZONTAL_END_H			0x3804 /*Bit[11:8]*/
118 #define OV5693_HORIZONTAL_END_L			0x3805 /*Bit[7:0]*/
119 #define OV5693_VERTICAL_END_H			0x3806 /*Bit[11:8]*/
120 #define OV5693_VERTICAL_END_L			0x3807 /*Bit[7:0]*/
121 #define OV5693_HORIZONTAL_OUTPUT_SIZE_H		0x3808 /*Bit[3:0]*/
122 #define OV5693_HORIZONTAL_OUTPUT_SIZE_L		0x3809 /*Bit[7:0]*/
123 #define OV5693_VERTICAL_OUTPUT_SIZE_H		0x380a /*Bit[3:0]*/
124 #define OV5693_VERTICAL_OUTPUT_SIZE_L		0x380b /*Bit[7:0]*/
125 /*High 8-bit, and low 8-bit HTS address is 0x380d*/
126 #define OV5693_TIMING_HTS_H			0x380C
127 /*High 8-bit, and low 8-bit HTS address is 0x380d*/
128 #define OV5693_TIMING_HTS_L			0x380D
129 /*High 8-bit, and low 8-bit HTS address is 0x380f*/
130 #define OV5693_TIMING_VTS_H			0x380e
131 /*High 8-bit, and low 8-bit HTS address is 0x380f*/
132 #define OV5693_TIMING_VTS_L			0x380f
133 
134 #define OV5693_MWB_RED_GAIN_H			0x3400
135 #define OV5693_MWB_GREEN_GAIN_H			0x3402
136 #define OV5693_MWB_BLUE_GAIN_H			0x3404
137 #define OV5693_MWB_GAIN_MAX			0x0fff
138 
139 #define OV5693_START_STREAMING			0x01
140 #define OV5693_STOP_STREAMING			0x00
141 
142 #define VCM_ADDR           0x0c
143 #define VCM_CODE_MSB       0x04
144 
145 #define OV5693_INVALID_CONFIG	0xffffffff
146 
147 #define OV5693_VCM_SLEW_STEP			0x30F0
148 #define OV5693_VCM_SLEW_STEP_MAX		0x7
149 #define OV5693_VCM_SLEW_STEP_MASK		0x7
150 #define OV5693_VCM_CODE				0x30F2
151 #define OV5693_VCM_SLEW_TIME			0x30F4
152 #define OV5693_VCM_SLEW_TIME_MAX		0xffff
153 #define OV5693_VCM_ENABLE			0x8000
154 
155 #define OV5693_VCM_MAX_FOCUS_NEG       -1023
156 #define OV5693_VCM_MAX_FOCUS_POS       1023
157 
158 #define DLC_ENABLE 1
159 #define DLC_DISABLE 0
160 #define VCM_PROTECTION_OFF     0xeca3
161 #define VCM_PROTECTION_ON      0xdc51
162 #define VCM_DEFAULT_S 0x0
163 #define vcm_step_s(a) (u8)(a & 0xf)
164 #define vcm_step_mclk(a) (u8)((a >> 4) & 0x3)
165 #define vcm_dlc_mclk(dlc, mclk) (u16)((dlc << 3) | mclk | 0xa104)
166 #define vcm_tsrc(tsrc) (u16)(tsrc << 3 | 0xf200)
167 #define vcm_val(data, s) (u16)(data << 4 | s)
168 #define DIRECT_VCM vcm_dlc_mclk(0, 0)
169 
170 /* Defines for OTP Data Registers */
171 #define OV5693_FRAME_OFF_NUM		0x4202
172 #define OV5693_OTP_BYTE_MAX		32	//change to 32 as needed by otpdata
173 #define OV5693_OTP_SHORT_MAX		16
174 #define OV5693_OTP_START_ADDR		0x3D00
175 #define OV5693_OTP_END_ADDR		0x3D0F
176 #define OV5693_OTP_DATA_SIZE		320
177 #define OV5693_OTP_PROGRAM_REG		0x3D80
178 #define OV5693_OTP_READ_REG		0x3D81	// 1:Enable 0:disable
179 #define OV5693_OTP_BANK_REG		0x3D84	//otp bank and mode
180 #define OV5693_OTP_READY_REG_DONE	1
181 #define OV5693_OTP_BANK_MAX		28
182 #define OV5693_OTP_BANK_SIZE		16	//16 bytes per bank
183 #define OV5693_OTP_READ_ONETIME		16
184 #define OV5693_OTP_MODE_READ		1
185 
186 struct regval_list {
187 	u16 reg_num;
188 	u8 value;
189 };
190 
191 struct ov5693_resolution {
192 	u8 *desc;
193 	const struct ov5693_reg *regs;
194 	int res;
195 	int width;
196 	int height;
197 	int fps;
198 	int pix_clk_freq;
199 	u16 pixels_per_line;
200 	u16 lines_per_frame;
201 	bool used;
202 };
203 
204 struct ov5693_format {
205 	u8 *desc;
206 	u32 pixelformat;
207 	struct ov5693_reg *regs;
208 };
209 
210 enum vcm_type {
211 	VCM_UNKNOWN,
212 	VCM_AD5823,
213 	VCM_DW9714,
214 };
215 
216 /*
217  * ov5693 device structure.
218  */
219 struct ov5693_device {
220 	struct v4l2_subdev sd;
221 	struct media_pad pad;
222 	struct v4l2_mbus_framefmt format;
223 	struct mutex input_lock;
224 	struct v4l2_ctrl_handler ctrl_handler;
225 
226 	struct camera_sensor_platform_data *platform_data;
227 	ktime_t timestamp_t_focus_abs;
228 	int fmt_idx;
229 	int run_mode;
230 	int otp_size;
231 	u8 *otp_data;
232 	u32 focus;
233 	s16 number_of_steps;
234 	u8 res;
235 	u8 type;
236 	bool vcm_update;
237 	enum vcm_type vcm;
238 };
239 
240 enum ov5693_tok_type {
241 	OV5693_8BIT  = 0x0001,
242 	OV5693_16BIT = 0x0002,
243 	OV5693_32BIT = 0x0004,
244 	OV5693_TOK_TERM   = 0xf000,	/* terminating token for reg list */
245 	OV5693_TOK_DELAY  = 0xfe00,	/* delay token for reg list */
246 	OV5693_TOK_MASK = 0xfff0
247 };
248 
249 /**
250  * struct ov5693_reg - MI sensor  register format
251  * @type: type of the register
252  * @reg: 16-bit offset to register
253  * @val: 8/16/32-bit register value
254  *
255  * Define a structure for sensor register initialization values
256  */
257 struct ov5693_reg {
258 	enum ov5693_tok_type type;
259 	u16 reg;
260 	u32 val;	/* @set value for read/mod/write, @mask */
261 };
262 
263 #define to_ov5693_sensor(x) container_of(x, struct ov5693_device, sd)
264 
265 #define OV5693_MAX_WRITE_BUF_SIZE	30
266 
267 struct ov5693_write_buffer {
268 	u16 addr;
269 	u8 data[OV5693_MAX_WRITE_BUF_SIZE];
270 };
271 
272 struct ov5693_write_ctrl {
273 	int index;
274 	struct ov5693_write_buffer buffer;
275 };
276 
277 static struct ov5693_reg const ov5693_global_setting[] = {
278 	{OV5693_8BIT, 0x0103, 0x01},
279 	{OV5693_8BIT, 0x3001, 0x0a},
280 	{OV5693_8BIT, 0x3002, 0x80},
281 	{OV5693_8BIT, 0x3006, 0x00},
282 	{OV5693_8BIT, 0x3011, 0x21},
283 	{OV5693_8BIT, 0x3012, 0x09},
284 	{OV5693_8BIT, 0x3013, 0x10},
285 	{OV5693_8BIT, 0x3014, 0x00},
286 	{OV5693_8BIT, 0x3015, 0x08},
287 	{OV5693_8BIT, 0x3016, 0xf0},
288 	{OV5693_8BIT, 0x3017, 0xf0},
289 	{OV5693_8BIT, 0x3018, 0xf0},
290 	{OV5693_8BIT, 0x301b, 0xb4},
291 	{OV5693_8BIT, 0x301d, 0x02},
292 	{OV5693_8BIT, 0x3021, 0x00},
293 	{OV5693_8BIT, 0x3022, 0x01},
294 	{OV5693_8BIT, 0x3028, 0x44},
295 	{OV5693_8BIT, 0x3098, 0x02},
296 	{OV5693_8BIT, 0x3099, 0x19},
297 	{OV5693_8BIT, 0x309a, 0x02},
298 	{OV5693_8BIT, 0x309b, 0x01},
299 	{OV5693_8BIT, 0x309c, 0x00},
300 	{OV5693_8BIT, 0x30a0, 0xd2},
301 	{OV5693_8BIT, 0x30a2, 0x01},
302 	{OV5693_8BIT, 0x30b2, 0x00},
303 	{OV5693_8BIT, 0x30b3, 0x7d},
304 	{OV5693_8BIT, 0x30b4, 0x03},
305 	{OV5693_8BIT, 0x30b5, 0x04},
306 	{OV5693_8BIT, 0x30b6, 0x01},
307 	{OV5693_8BIT, 0x3104, 0x21},
308 	{OV5693_8BIT, 0x3106, 0x00},
309 	{OV5693_8BIT, 0x3400, 0x04},
310 	{OV5693_8BIT, 0x3401, 0x00},
311 	{OV5693_8BIT, 0x3402, 0x04},
312 	{OV5693_8BIT, 0x3403, 0x00},
313 	{OV5693_8BIT, 0x3404, 0x04},
314 	{OV5693_8BIT, 0x3405, 0x00},
315 	{OV5693_8BIT, 0x3406, 0x01},
316 	{OV5693_8BIT, 0x3500, 0x00},
317 	{OV5693_8BIT, 0x3503, 0x07},
318 	{OV5693_8BIT, 0x3504, 0x00},
319 	{OV5693_8BIT, 0x3505, 0x00},
320 	{OV5693_8BIT, 0x3506, 0x00},
321 	{OV5693_8BIT, 0x3507, 0x02},
322 	{OV5693_8BIT, 0x3508, 0x00},
323 	{OV5693_8BIT, 0x3509, 0x10},
324 	{OV5693_8BIT, 0x350a, 0x00},
325 	{OV5693_8BIT, 0x350b, 0x40},
326 	{OV5693_8BIT, 0x3601, 0x0a},
327 	{OV5693_8BIT, 0x3602, 0x38},
328 	{OV5693_8BIT, 0x3612, 0x80},
329 	{OV5693_8BIT, 0x3620, 0x54},
330 	{OV5693_8BIT, 0x3621, 0xc7},
331 	{OV5693_8BIT, 0x3622, 0x0f},
332 	{OV5693_8BIT, 0x3625, 0x10},
333 	{OV5693_8BIT, 0x3630, 0x55},
334 	{OV5693_8BIT, 0x3631, 0xf4},
335 	{OV5693_8BIT, 0x3632, 0x00},
336 	{OV5693_8BIT, 0x3633, 0x34},
337 	{OV5693_8BIT, 0x3634, 0x02},
338 	{OV5693_8BIT, 0x364d, 0x0d},
339 	{OV5693_8BIT, 0x364f, 0xdd},
340 	{OV5693_8BIT, 0x3660, 0x04},
341 	{OV5693_8BIT, 0x3662, 0x10},
342 	{OV5693_8BIT, 0x3663, 0xf1},
343 	{OV5693_8BIT, 0x3665, 0x00},
344 	{OV5693_8BIT, 0x3666, 0x20},
345 	{OV5693_8BIT, 0x3667, 0x00},
346 	{OV5693_8BIT, 0x366a, 0x80},
347 	{OV5693_8BIT, 0x3680, 0xe0},
348 	{OV5693_8BIT, 0x3681, 0x00},
349 	{OV5693_8BIT, 0x3700, 0x42},
350 	{OV5693_8BIT, 0x3701, 0x14},
351 	{OV5693_8BIT, 0x3702, 0xa0},
352 	{OV5693_8BIT, 0x3703, 0xd8},
353 	{OV5693_8BIT, 0x3704, 0x78},
354 	{OV5693_8BIT, 0x3705, 0x02},
355 	{OV5693_8BIT, 0x370a, 0x00},
356 	{OV5693_8BIT, 0x370b, 0x20},
357 	{OV5693_8BIT, 0x370c, 0x0c},
358 	{OV5693_8BIT, 0x370d, 0x11},
359 	{OV5693_8BIT, 0x370e, 0x00},
360 	{OV5693_8BIT, 0x370f, 0x40},
361 	{OV5693_8BIT, 0x3710, 0x00},
362 	{OV5693_8BIT, 0x371a, 0x1c},
363 	{OV5693_8BIT, 0x371b, 0x05},
364 	{OV5693_8BIT, 0x371c, 0x01},
365 	{OV5693_8BIT, 0x371e, 0xa1},
366 	{OV5693_8BIT, 0x371f, 0x0c},
367 	{OV5693_8BIT, 0x3721, 0x00},
368 	{OV5693_8BIT, 0x3724, 0x10},
369 	{OV5693_8BIT, 0x3726, 0x00},
370 	{OV5693_8BIT, 0x372a, 0x01},
371 	{OV5693_8BIT, 0x3730, 0x10},
372 	{OV5693_8BIT, 0x3738, 0x22},
373 	{OV5693_8BIT, 0x3739, 0xe5},
374 	{OV5693_8BIT, 0x373a, 0x50},
375 	{OV5693_8BIT, 0x373b, 0x02},
376 	{OV5693_8BIT, 0x373c, 0x41},
377 	{OV5693_8BIT, 0x373f, 0x02},
378 	{OV5693_8BIT, 0x3740, 0x42},
379 	{OV5693_8BIT, 0x3741, 0x02},
380 	{OV5693_8BIT, 0x3742, 0x18},
381 	{OV5693_8BIT, 0x3743, 0x01},
382 	{OV5693_8BIT, 0x3744, 0x02},
383 	{OV5693_8BIT, 0x3747, 0x10},
384 	{OV5693_8BIT, 0x374c, 0x04},
385 	{OV5693_8BIT, 0x3751, 0xf0},
386 	{OV5693_8BIT, 0x3752, 0x00},
387 	{OV5693_8BIT, 0x3753, 0x00},
388 	{OV5693_8BIT, 0x3754, 0xc0},
389 	{OV5693_8BIT, 0x3755, 0x00},
390 	{OV5693_8BIT, 0x3756, 0x1a},
391 	{OV5693_8BIT, 0x3758, 0x00},
392 	{OV5693_8BIT, 0x3759, 0x0f},
393 	{OV5693_8BIT, 0x376b, 0x44},
394 	{OV5693_8BIT, 0x375c, 0x04},
395 	{OV5693_8BIT, 0x3774, 0x10},
396 	{OV5693_8BIT, 0x3776, 0x00},
397 	{OV5693_8BIT, 0x377f, 0x08},
398 	{OV5693_8BIT, 0x3780, 0x22},
399 	{OV5693_8BIT, 0x3781, 0x0c},
400 	{OV5693_8BIT, 0x3784, 0x2c},
401 	{OV5693_8BIT, 0x3785, 0x1e},
402 	{OV5693_8BIT, 0x378f, 0xf5},
403 	{OV5693_8BIT, 0x3791, 0xb0},
404 	{OV5693_8BIT, 0x3795, 0x00},
405 	{OV5693_8BIT, 0x3796, 0x64},
406 	{OV5693_8BIT, 0x3797, 0x11},
407 	{OV5693_8BIT, 0x3798, 0x30},
408 	{OV5693_8BIT, 0x3799, 0x41},
409 	{OV5693_8BIT, 0x379a, 0x07},
410 	{OV5693_8BIT, 0x379b, 0xb0},
411 	{OV5693_8BIT, 0x379c, 0x0c},
412 	{OV5693_8BIT, 0x37c5, 0x00},
413 	{OV5693_8BIT, 0x37c6, 0x00},
414 	{OV5693_8BIT, 0x37c7, 0x00},
415 	{OV5693_8BIT, 0x37c9, 0x00},
416 	{OV5693_8BIT, 0x37ca, 0x00},
417 	{OV5693_8BIT, 0x37cb, 0x00},
418 	{OV5693_8BIT, 0x37de, 0x00},
419 	{OV5693_8BIT, 0x37df, 0x00},
420 	{OV5693_8BIT, 0x3800, 0x00},
421 	{OV5693_8BIT, 0x3801, 0x00},
422 	{OV5693_8BIT, 0x3802, 0x00},
423 	{OV5693_8BIT, 0x3804, 0x0a},
424 	{OV5693_8BIT, 0x3805, 0x3f},
425 	{OV5693_8BIT, 0x3810, 0x00},
426 	{OV5693_8BIT, 0x3812, 0x00},
427 	{OV5693_8BIT, 0x3823, 0x00},
428 	{OV5693_8BIT, 0x3824, 0x00},
429 	{OV5693_8BIT, 0x3825, 0x00},
430 	{OV5693_8BIT, 0x3826, 0x00},
431 	{OV5693_8BIT, 0x3827, 0x00},
432 	{OV5693_8BIT, 0x382a, 0x04},
433 	{OV5693_8BIT, 0x3a04, 0x06},
434 	{OV5693_8BIT, 0x3a05, 0x14},
435 	{OV5693_8BIT, 0x3a06, 0x00},
436 	{OV5693_8BIT, 0x3a07, 0xfe},
437 	{OV5693_8BIT, 0x3b00, 0x00},
438 	{OV5693_8BIT, 0x3b02, 0x00},
439 	{OV5693_8BIT, 0x3b03, 0x00},
440 	{OV5693_8BIT, 0x3b04, 0x00},
441 	{OV5693_8BIT, 0x3b05, 0x00},
442 	{OV5693_8BIT, 0x3e07, 0x20},
443 	{OV5693_8BIT, 0x4000, 0x08},
444 	{OV5693_8BIT, 0x4001, 0x04},
445 	{OV5693_8BIT, 0x4002, 0x45},
446 	{OV5693_8BIT, 0x4004, 0x08},
447 	{OV5693_8BIT, 0x4005, 0x18},
448 	{OV5693_8BIT, 0x4006, 0x20},
449 	{OV5693_8BIT, 0x4008, 0x24},
450 	{OV5693_8BIT, 0x4009, 0x10},
451 	{OV5693_8BIT, 0x400c, 0x00},
452 	{OV5693_8BIT, 0x400d, 0x00},
453 	{OV5693_8BIT, 0x4058, 0x00},
454 	{OV5693_8BIT, 0x404e, 0x37},
455 	{OV5693_8BIT, 0x404f, 0x8f},
456 	{OV5693_8BIT, 0x4058, 0x00},
457 	{OV5693_8BIT, 0x4101, 0xb2},
458 	{OV5693_8BIT, 0x4303, 0x00},
459 	{OV5693_8BIT, 0x4304, 0x08},
460 	{OV5693_8BIT, 0x4307, 0x31},
461 	{OV5693_8BIT, 0x4311, 0x04},
462 	{OV5693_8BIT, 0x4315, 0x01},
463 	{OV5693_8BIT, 0x4511, 0x05},
464 	{OV5693_8BIT, 0x4512, 0x01},
465 	{OV5693_8BIT, 0x4806, 0x00},
466 	{OV5693_8BIT, 0x4816, 0x52},
467 	{OV5693_8BIT, 0x481f, 0x30},
468 	{OV5693_8BIT, 0x4826, 0x2c},
469 	{OV5693_8BIT, 0x4831, 0x64},
470 	{OV5693_8BIT, 0x4d00, 0x04},
471 	{OV5693_8BIT, 0x4d01, 0x71},
472 	{OV5693_8BIT, 0x4d02, 0xfd},
473 	{OV5693_8BIT, 0x4d03, 0xf5},
474 	{OV5693_8BIT, 0x4d04, 0x0c},
475 	{OV5693_8BIT, 0x4d05, 0xcc},
476 	{OV5693_8BIT, 0x4837, 0x0a},
477 	{OV5693_8BIT, 0x5000, 0x06},
478 	{OV5693_8BIT, 0x5001, 0x01},
479 	{OV5693_8BIT, 0x5003, 0x20},
480 	{OV5693_8BIT, 0x5046, 0x0a},
481 	{OV5693_8BIT, 0x5013, 0x00},
482 	{OV5693_8BIT, 0x5046, 0x0a},
483 	{OV5693_8BIT, 0x5780, 0x1c},
484 	{OV5693_8BIT, 0x5786, 0x20},
485 	{OV5693_8BIT, 0x5787, 0x10},
486 	{OV5693_8BIT, 0x5788, 0x18},
487 	{OV5693_8BIT, 0x578a, 0x04},
488 	{OV5693_8BIT, 0x578b, 0x02},
489 	{OV5693_8BIT, 0x578c, 0x02},
490 	{OV5693_8BIT, 0x578e, 0x06},
491 	{OV5693_8BIT, 0x578f, 0x02},
492 	{OV5693_8BIT, 0x5790, 0x02},
493 	{OV5693_8BIT, 0x5791, 0xff},
494 	{OV5693_8BIT, 0x5842, 0x01},
495 	{OV5693_8BIT, 0x5843, 0x2b},
496 	{OV5693_8BIT, 0x5844, 0x01},
497 	{OV5693_8BIT, 0x5845, 0x92},
498 	{OV5693_8BIT, 0x5846, 0x01},
499 	{OV5693_8BIT, 0x5847, 0x8f},
500 	{OV5693_8BIT, 0x5848, 0x01},
501 	{OV5693_8BIT, 0x5849, 0x0c},
502 	{OV5693_8BIT, 0x5e00, 0x00},
503 	{OV5693_8BIT, 0x5e10, 0x0c},
504 	{OV5693_8BIT, 0x0100, 0x00},
505 	{OV5693_TOK_TERM, 0, 0}
506 };
507 
508 #if ENABLE_NON_PREVIEW
509 /*
510  * 654x496 30fps 17ms VBlanking 2lane 10Bit (Scaling)
511  */
512 static struct ov5693_reg const ov5693_654x496[] = {
513 	{OV5693_8BIT, 0x3501, 0x3d},
514 	{OV5693_8BIT, 0x3502, 0x00},
515 	{OV5693_8BIT, 0x3708, 0xe6},
516 	{OV5693_8BIT, 0x3709, 0xc7},
517 	{OV5693_8BIT, 0x3803, 0x00},
518 	{OV5693_8BIT, 0x3806, 0x07},
519 	{OV5693_8BIT, 0x3807, 0xa3},
520 	{OV5693_8BIT, 0x3808, 0x02},
521 	{OV5693_8BIT, 0x3809, 0x90},
522 	{OV5693_8BIT, 0x380a, 0x01},
523 	{OV5693_8BIT, 0x380b, 0xf0},
524 	{OV5693_8BIT, 0x380c, 0x0a},
525 	{OV5693_8BIT, 0x380d, 0x80},
526 	{OV5693_8BIT, 0x380e, 0x07},
527 	{OV5693_8BIT, 0x380f, 0xc0},
528 	{OV5693_8BIT, 0x3811, 0x08},
529 	{OV5693_8BIT, 0x3813, 0x02},
530 	{OV5693_8BIT, 0x3814, 0x31},
531 	{OV5693_8BIT, 0x3815, 0x31},
532 	{OV5693_8BIT, 0x3820, 0x04},
533 	{OV5693_8BIT, 0x3821, 0x1f},
534 	{OV5693_8BIT, 0x5002, 0x80},
535 	{OV5693_8BIT, 0x0100, 0x01},
536 	{OV5693_TOK_TERM, 0, 0}
537 };
538 
539 /*
540  * 1296x976 30fps 17ms VBlanking 2lane 10Bit (Scaling)
541 *DS from 2592x1952
542 */
543 static struct ov5693_reg const ov5693_1296x976[] = {
544 	{OV5693_8BIT, 0x3501, 0x7b},
545 	{OV5693_8BIT, 0x3502, 0x00},
546 	{OV5693_8BIT, 0x3708, 0xe2},
547 	{OV5693_8BIT, 0x3709, 0xc3},
548 
549 	{OV5693_8BIT, 0x3800, 0x00},
550 	{OV5693_8BIT, 0x3801, 0x00},
551 	{OV5693_8BIT, 0x3802, 0x00},
552 	{OV5693_8BIT, 0x3803, 0x00},
553 
554 	{OV5693_8BIT, 0x3804, 0x0a},
555 	{OV5693_8BIT, 0x3805, 0x3f},
556 	{OV5693_8BIT, 0x3806, 0x07},
557 	{OV5693_8BIT, 0x3807, 0xA3},
558 
559 	{OV5693_8BIT, 0x3808, 0x05},
560 	{OV5693_8BIT, 0x3809, 0x10},
561 	{OV5693_8BIT, 0x380a, 0x03},
562 	{OV5693_8BIT, 0x380b, 0xD0},
563 
564 	{OV5693_8BIT, 0x380c, 0x0a},
565 	{OV5693_8BIT, 0x380d, 0x80},
566 	{OV5693_8BIT, 0x380e, 0x07},
567 	{OV5693_8BIT, 0x380f, 0xc0},
568 
569 	{OV5693_8BIT, 0x3810, 0x00},
570 	{OV5693_8BIT, 0x3811, 0x10},
571 	{OV5693_8BIT, 0x3812, 0x00},
572 	{OV5693_8BIT, 0x3813, 0x02},
573 
574 	{OV5693_8BIT, 0x3814, 0x11},	/*X subsample control*/
575 	{OV5693_8BIT, 0x3815, 0x11},	/*Y subsample control*/
576 	{OV5693_8BIT, 0x3820, 0x00},
577 	{OV5693_8BIT, 0x3821, 0x1e},
578 	{OV5693_8BIT, 0x5002, 0x00},
579 	{OV5693_8BIT, 0x5041, 0x84}, /* scale is auto enabled */
580 	{OV5693_8BIT, 0x0100, 0x01},
581 	{OV5693_TOK_TERM, 0, 0}
582 
583 };
584 
585 /*
586  * 336x256 30fps 17ms VBlanking 2lane 10Bit (Scaling)
587  DS from 2564x1956
588  */
589 static struct ov5693_reg const ov5693_336x256[] = {
590 	{OV5693_8BIT, 0x3501, 0x3d},
591 	{OV5693_8BIT, 0x3502, 0x00},
592 	{OV5693_8BIT, 0x3708, 0xe6},
593 	{OV5693_8BIT, 0x3709, 0xc7},
594 	{OV5693_8BIT, 0x3806, 0x07},
595 	{OV5693_8BIT, 0x3807, 0xa3},
596 	{OV5693_8BIT, 0x3808, 0x01},
597 	{OV5693_8BIT, 0x3809, 0x50},
598 	{OV5693_8BIT, 0x380a, 0x01},
599 	{OV5693_8BIT, 0x380b, 0x00},
600 	{OV5693_8BIT, 0x380c, 0x0a},
601 	{OV5693_8BIT, 0x380d, 0x80},
602 	{OV5693_8BIT, 0x380e, 0x07},
603 	{OV5693_8BIT, 0x380f, 0xc0},
604 	{OV5693_8BIT, 0x3811, 0x1E},
605 	{OV5693_8BIT, 0x3814, 0x31},
606 	{OV5693_8BIT, 0x3815, 0x31},
607 	{OV5693_8BIT, 0x3820, 0x04},
608 	{OV5693_8BIT, 0x3821, 0x1f},
609 	{OV5693_8BIT, 0x5002, 0x80},
610 	{OV5693_8BIT, 0x0100, 0x01},
611 	{OV5693_TOK_TERM, 0, 0}
612 };
613 
614 /*
615  * 336x256 30fps 17ms VBlanking 2lane 10Bit (Scaling)
616  DS from 2368x1956
617  */
618 static struct ov5693_reg const ov5693_368x304[] = {
619 	{OV5693_8BIT, 0x3501, 0x3d},
620 	{OV5693_8BIT, 0x3502, 0x00},
621 	{OV5693_8BIT, 0x3708, 0xe6},
622 	{OV5693_8BIT, 0x3709, 0xc7},
623 	{OV5693_8BIT, 0x3808, 0x01},
624 	{OV5693_8BIT, 0x3809, 0x70},
625 	{OV5693_8BIT, 0x380a, 0x01},
626 	{OV5693_8BIT, 0x380b, 0x30},
627 	{OV5693_8BIT, 0x380c, 0x0a},
628 	{OV5693_8BIT, 0x380d, 0x80},
629 	{OV5693_8BIT, 0x380e, 0x07},
630 	{OV5693_8BIT, 0x380f, 0xc0},
631 	{OV5693_8BIT, 0x3811, 0x80},
632 	{OV5693_8BIT, 0x3814, 0x31},
633 	{OV5693_8BIT, 0x3815, 0x31},
634 	{OV5693_8BIT, 0x3820, 0x04},
635 	{OV5693_8BIT, 0x3821, 0x1f},
636 	{OV5693_8BIT, 0x5002, 0x80},
637 	{OV5693_8BIT, 0x0100, 0x01},
638 	{OV5693_TOK_TERM, 0, 0}
639 };
640 
641 /*
642  * ov5693_192x160 30fps 17ms VBlanking 2lane 10Bit (Scaling)
643  DS from 2460x1956
644  */
645 static struct ov5693_reg const ov5693_192x160[] = {
646 	{OV5693_8BIT, 0x3501, 0x7b},
647 	{OV5693_8BIT, 0x3502, 0x80},
648 	{OV5693_8BIT, 0x3708, 0xe2},
649 	{OV5693_8BIT, 0x3709, 0xc3},
650 	{OV5693_8BIT, 0x3804, 0x0a},
651 	{OV5693_8BIT, 0x3805, 0x3f},
652 	{OV5693_8BIT, 0x3806, 0x07},
653 	{OV5693_8BIT, 0x3807, 0xA3},
654 	{OV5693_8BIT, 0x3808, 0x00},
655 	{OV5693_8BIT, 0x3809, 0xC0},
656 	{OV5693_8BIT, 0x380a, 0x00},
657 	{OV5693_8BIT, 0x380b, 0xA0},
658 	{OV5693_8BIT, 0x380c, 0x0a},
659 	{OV5693_8BIT, 0x380d, 0x80},
660 	{OV5693_8BIT, 0x380e, 0x07},
661 	{OV5693_8BIT, 0x380f, 0xc0},
662 	{OV5693_8BIT, 0x3811, 0x40},
663 	{OV5693_8BIT, 0x3813, 0x00},
664 	{OV5693_8BIT, 0x3814, 0x31},
665 	{OV5693_8BIT, 0x3815, 0x31},
666 	{OV5693_8BIT, 0x3820, 0x04},
667 	{OV5693_8BIT, 0x3821, 0x1f},
668 	{OV5693_8BIT, 0x5002, 0x80},
669 	{OV5693_8BIT, 0x0100, 0x01},
670 	{OV5693_TOK_TERM, 0, 0}
671 };
672 
673 static struct ov5693_reg const ov5693_736x496[] = {
674 	{OV5693_8BIT, 0x3501, 0x3d},
675 	{OV5693_8BIT, 0x3502, 0x00},
676 	{OV5693_8BIT, 0x3708, 0xe6},
677 	{OV5693_8BIT, 0x3709, 0xc7},
678 	{OV5693_8BIT, 0x3803, 0x68},
679 	{OV5693_8BIT, 0x3806, 0x07},
680 	{OV5693_8BIT, 0x3807, 0x3b},
681 	{OV5693_8BIT, 0x3808, 0x02},
682 	{OV5693_8BIT, 0x3809, 0xe0},
683 	{OV5693_8BIT, 0x380a, 0x01},
684 	{OV5693_8BIT, 0x380b, 0xf0},
685 	{OV5693_8BIT, 0x380c, 0x0a}, /*hts*/
686 	{OV5693_8BIT, 0x380d, 0x80},
687 	{OV5693_8BIT, 0x380e, 0x07}, /*vts*/
688 	{OV5693_8BIT, 0x380f, 0xc0},
689 	{OV5693_8BIT, 0x3811, 0x08},
690 	{OV5693_8BIT, 0x3813, 0x02},
691 	{OV5693_8BIT, 0x3814, 0x31},
692 	{OV5693_8BIT, 0x3815, 0x31},
693 	{OV5693_8BIT, 0x3820, 0x04},
694 	{OV5693_8BIT, 0x3821, 0x1f},
695 	{OV5693_8BIT, 0x5002, 0x80},
696 	{OV5693_8BIT, 0x0100, 0x01},
697 	{OV5693_TOK_TERM, 0, 0}
698 };
699 #endif
700 
701 /*
702 static struct ov5693_reg const ov5693_736x496[] = {
703 	{OV5693_8BIT, 0x3501, 0x7b},
704 	{OV5693_8BIT, 0x3502, 0x00},
705 	{OV5693_8BIT, 0x3708, 0xe6},
706 	{OV5693_8BIT, 0x3709, 0xc3},
707 	{OV5693_8BIT, 0x3803, 0x00},
708 	{OV5693_8BIT, 0x3806, 0x07},
709 	{OV5693_8BIT, 0x3807, 0xa3},
710 	{OV5693_8BIT, 0x3808, 0x02},
711 	{OV5693_8BIT, 0x3809, 0xe0},
712 	{OV5693_8BIT, 0x380a, 0x01},
713 	{OV5693_8BIT, 0x380b, 0xf0},
714 	{OV5693_8BIT, 0x380c, 0x0d},
715 	{OV5693_8BIT, 0x380d, 0xb0},
716 	{OV5693_8BIT, 0x380e, 0x05},
717 	{OV5693_8BIT, 0x380f, 0xf2},
718 	{OV5693_8BIT, 0x3811, 0x08},
719 	{OV5693_8BIT, 0x3813, 0x02},
720 	{OV5693_8BIT, 0x3814, 0x31},
721 	{OV5693_8BIT, 0x3815, 0x31},
722 	{OV5693_8BIT, 0x3820, 0x01},
723 	{OV5693_8BIT, 0x3821, 0x1f},
724 	{OV5693_8BIT, 0x5002, 0x00},
725 	{OV5693_8BIT, 0x0100, 0x01},
726 	{OV5693_TOK_TERM, 0, 0}
727 };
728 */
729 /*
730  * 976x556 30fps 8.8ms VBlanking 2lane 10Bit (Scaling)
731  */
732 #if ENABLE_NON_PREVIEW
733 static struct ov5693_reg const ov5693_976x556[] = {
734 	{OV5693_8BIT, 0x3501, 0x7b},
735 	{OV5693_8BIT, 0x3502, 0x00},
736 	{OV5693_8BIT, 0x3708, 0xe2},
737 	{OV5693_8BIT, 0x3709, 0xc3},
738 	{OV5693_8BIT, 0x3803, 0xf0},
739 	{OV5693_8BIT, 0x3806, 0x06},
740 	{OV5693_8BIT, 0x3807, 0xa7},
741 	{OV5693_8BIT, 0x3808, 0x03},
742 	{OV5693_8BIT, 0x3809, 0xd0},
743 	{OV5693_8BIT, 0x380a, 0x02},
744 	{OV5693_8BIT, 0x380b, 0x2C},
745 	{OV5693_8BIT, 0x380c, 0x0a},
746 	{OV5693_8BIT, 0x380d, 0x80},
747 	{OV5693_8BIT, 0x380e, 0x07},
748 	{OV5693_8BIT, 0x380f, 0xc0},
749 	{OV5693_8BIT, 0x3811, 0x10},
750 	{OV5693_8BIT, 0x3813, 0x02},
751 	{OV5693_8BIT, 0x3814, 0x11},
752 	{OV5693_8BIT, 0x3815, 0x11},
753 	{OV5693_8BIT, 0x3820, 0x00},
754 	{OV5693_8BIT, 0x3821, 0x1e},
755 	{OV5693_8BIT, 0x5002, 0x80},
756 	{OV5693_8BIT, 0x0100, 0x01},
757 	{OV5693_TOK_TERM, 0, 0}
758 };
759 
760 /*DS from 2624x1492*/
761 static struct ov5693_reg const ov5693_1296x736[] = {
762 	{OV5693_8BIT, 0x3501, 0x7b},
763 	{OV5693_8BIT, 0x3502, 0x00},
764 	{OV5693_8BIT, 0x3708, 0xe2},
765 	{OV5693_8BIT, 0x3709, 0xc3},
766 
767 	{OV5693_8BIT, 0x3800, 0x00},
768 	{OV5693_8BIT, 0x3801, 0x00},
769 	{OV5693_8BIT, 0x3802, 0x00},
770 	{OV5693_8BIT, 0x3803, 0x00},
771 
772 	{OV5693_8BIT, 0x3804, 0x0a},
773 	{OV5693_8BIT, 0x3805, 0x3f},
774 	{OV5693_8BIT, 0x3806, 0x07},
775 	{OV5693_8BIT, 0x3807, 0xA3},
776 
777 	{OV5693_8BIT, 0x3808, 0x05},
778 	{OV5693_8BIT, 0x3809, 0x10},
779 	{OV5693_8BIT, 0x380a, 0x02},
780 	{OV5693_8BIT, 0x380b, 0xe0},
781 
782 	{OV5693_8BIT, 0x380c, 0x0a},
783 	{OV5693_8BIT, 0x380d, 0x80},
784 	{OV5693_8BIT, 0x380e, 0x07},
785 	{OV5693_8BIT, 0x380f, 0xc0},
786 
787 	{OV5693_8BIT, 0x3813, 0xE8},
788 
789 	{OV5693_8BIT, 0x3814, 0x11},	/*X subsample control*/
790 	{OV5693_8BIT, 0x3815, 0x11},	/*Y subsample control*/
791 	{OV5693_8BIT, 0x3820, 0x00},
792 	{OV5693_8BIT, 0x3821, 0x1e},
793 	{OV5693_8BIT, 0x5002, 0x00},
794 	{OV5693_8BIT, 0x5041, 0x84}, /* scale is auto enabled */
795 	{OV5693_8BIT, 0x0100, 0x01},
796 	{OV5693_TOK_TERM, 0, 0}
797 };
798 
799 static struct ov5693_reg const ov5693_1636p_30fps[] = {
800 	{OV5693_8BIT, 0x3501, 0x7b},
801 	{OV5693_8BIT, 0x3502, 0x00},
802 	{OV5693_8BIT, 0x3708, 0xe2},
803 	{OV5693_8BIT, 0x3709, 0xc3},
804 	{OV5693_8BIT, 0x3803, 0xf0},
805 	{OV5693_8BIT, 0x3806, 0x06},
806 	{OV5693_8BIT, 0x3807, 0xa7},
807 	{OV5693_8BIT, 0x3808, 0x06},
808 	{OV5693_8BIT, 0x3809, 0x64},
809 	{OV5693_8BIT, 0x380a, 0x04},
810 	{OV5693_8BIT, 0x380b, 0x48},
811 	{OV5693_8BIT, 0x380c, 0x0a}, /*hts*/
812 	{OV5693_8BIT, 0x380d, 0x80},
813 	{OV5693_8BIT, 0x380e, 0x07}, /*vts*/
814 	{OV5693_8BIT, 0x380f, 0xc0},
815 	{OV5693_8BIT, 0x3811, 0x02},
816 	{OV5693_8BIT, 0x3813, 0x02},
817 	{OV5693_8BIT, 0x3814, 0x11},
818 	{OV5693_8BIT, 0x3815, 0x11},
819 	{OV5693_8BIT, 0x3820, 0x00},
820 	{OV5693_8BIT, 0x3821, 0x1e},
821 	{OV5693_8BIT, 0x5002, 0x80},
822 	{OV5693_8BIT, 0x0100, 0x01},
823 	{OV5693_TOK_TERM, 0, 0}
824 };
825 #endif
826 
827 static struct ov5693_reg const ov5693_1616x1216_30fps[] = {
828 	{OV5693_8BIT, 0x3501, 0x7b},
829 	{OV5693_8BIT, 0x3502, 0x80},
830 	{OV5693_8BIT, 0x3708, 0xe2},
831 	{OV5693_8BIT, 0x3709, 0xc3},
832 	{OV5693_8BIT, 0x3800, 0x00},	/*{3800,3801} Array X start*/
833 	{OV5693_8BIT, 0x3801, 0x08},	/* 04 //{3800,3801} Array X start*/
834 	{OV5693_8BIT, 0x3802, 0x00},	/*{3802,3803} Array Y start*/
835 	{OV5693_8BIT, 0x3803, 0x04},	/* 00  //{3802,3803} Array Y start*/
836 	{OV5693_8BIT, 0x3804, 0x0a},	/*{3804,3805} Array X end*/
837 	{OV5693_8BIT, 0x3805, 0x37},	/* 3b  //{3804,3805} Array X end*/
838 	{OV5693_8BIT, 0x3806, 0x07},	/*{3806,3807} Array Y end*/
839 	{OV5693_8BIT, 0x3807, 0x9f},	/* a3  //{3806,3807} Array Y end*/
840 	{OV5693_8BIT, 0x3808, 0x06},	/*{3808,3809} Final output H size*/
841 	{OV5693_8BIT, 0x3809, 0x50},	/*{3808,3809} Final output H size*/
842 	{OV5693_8BIT, 0x380a, 0x04},	/*{380a,380b} Final output V size*/
843 	{OV5693_8BIT, 0x380b, 0xc0},	/*{380a,380b} Final output V size*/
844 	{OV5693_8BIT, 0x380c, 0x0a},	/*{380c,380d} HTS*/
845 	{OV5693_8BIT, 0x380d, 0x80},	/*{380c,380d} HTS*/
846 	{OV5693_8BIT, 0x380e, 0x07},	/*{380e,380f} VTS*/
847 	{OV5693_8BIT, 0x380f, 0xc0},	/* bc	//{380e,380f} VTS*/
848 	{OV5693_8BIT, 0x3810, 0x00},	/*{3810,3811} windowing X offset*/
849 	{OV5693_8BIT, 0x3811, 0x10},	/*{3810,3811} windowing X offset*/
850 	{OV5693_8BIT, 0x3812, 0x00},	/*{3812,3813} windowing Y offset*/
851 	{OV5693_8BIT, 0x3813, 0x06},	/*{3812,3813} windowing Y offset*/
852 	{OV5693_8BIT, 0x3814, 0x11},	/*X subsample control*/
853 	{OV5693_8BIT, 0x3815, 0x11},	/*Y subsample control*/
854 	{OV5693_8BIT, 0x3820, 0x00},	/*FLIP/Binning control*/
855 	{OV5693_8BIT, 0x3821, 0x1e},	/*MIRROR control*/
856 	{OV5693_8BIT, 0x5002, 0x00},
857 	{OV5693_8BIT, 0x5041, 0x84},
858 	{OV5693_8BIT, 0x0100, 0x01},
859 	{OV5693_TOK_TERM, 0, 0}
860 };
861 
862 /*
863  * 1940x1096 30fps 8.8ms VBlanking 2lane 10bit (Scaling)
864  */
865 #if ENABLE_NON_PREVIEW
866 static struct ov5693_reg const ov5693_1940x1096[] = {
867 	{OV5693_8BIT, 0x3501, 0x7b},
868 	{OV5693_8BIT, 0x3502, 0x00},
869 	{OV5693_8BIT, 0x3708, 0xe2},
870 	{OV5693_8BIT, 0x3709, 0xc3},
871 	{OV5693_8BIT, 0x3803, 0xf0},
872 	{OV5693_8BIT, 0x3806, 0x06},
873 	{OV5693_8BIT, 0x3807, 0xa7},
874 	{OV5693_8BIT, 0x3808, 0x07},
875 	{OV5693_8BIT, 0x3809, 0x94},
876 	{OV5693_8BIT, 0x380a, 0x04},
877 	{OV5693_8BIT, 0x380b, 0x48},
878 	{OV5693_8BIT, 0x380c, 0x0a},
879 	{OV5693_8BIT, 0x380d, 0x80},
880 	{OV5693_8BIT, 0x380e, 0x07},
881 	{OV5693_8BIT, 0x380f, 0xc0},
882 	{OV5693_8BIT, 0x3811, 0x02},
883 	{OV5693_8BIT, 0x3813, 0x02},
884 	{OV5693_8BIT, 0x3814, 0x11},
885 	{OV5693_8BIT, 0x3815, 0x11},
886 	{OV5693_8BIT, 0x3820, 0x00},
887 	{OV5693_8BIT, 0x3821, 0x1e},
888 	{OV5693_8BIT, 0x5002, 0x80},
889 	{OV5693_8BIT, 0x0100, 0x01},
890 	{OV5693_TOK_TERM, 0, 0}
891 };
892 
893 static struct ov5693_reg const ov5693_2592x1456_30fps[] = {
894 	{OV5693_8BIT, 0x3501, 0x7b},
895 	{OV5693_8BIT, 0x3502, 0x00},
896 	{OV5693_8BIT, 0x3708, 0xe2},
897 	{OV5693_8BIT, 0x3709, 0xc3},
898 	{OV5693_8BIT, 0x3800, 0x00},
899 	{OV5693_8BIT, 0x3801, 0x00},
900 	{OV5693_8BIT, 0x3802, 0x00},
901 	{OV5693_8BIT, 0x3803, 0xf0},
902 	{OV5693_8BIT, 0x3804, 0x0a},
903 	{OV5693_8BIT, 0x3805, 0x3f},
904 	{OV5693_8BIT, 0x3806, 0x06},
905 	{OV5693_8BIT, 0x3807, 0xa4},
906 	{OV5693_8BIT, 0x3808, 0x0a},
907 	{OV5693_8BIT, 0x3809, 0x20},
908 	{OV5693_8BIT, 0x380a, 0x05},
909 	{OV5693_8BIT, 0x380b, 0xb0},
910 	{OV5693_8BIT, 0x380c, 0x0a},
911 	{OV5693_8BIT, 0x380d, 0x80},
912 	{OV5693_8BIT, 0x380e, 0x07},
913 	{OV5693_8BIT, 0x380f, 0xc0},
914 	{OV5693_8BIT, 0x3811, 0x10},
915 	{OV5693_8BIT, 0x3813, 0x00},
916 	{OV5693_8BIT, 0x3814, 0x11},
917 	{OV5693_8BIT, 0x3815, 0x11},
918 	{OV5693_8BIT, 0x3820, 0x00},
919 	{OV5693_8BIT, 0x3821, 0x1e},
920 	{OV5693_8BIT, 0x5002, 0x00},
921 	{OV5693_TOK_TERM, 0, 0}
922 };
923 #endif
924 
925 static struct ov5693_reg const ov5693_2576x1456_30fps[] = {
926 	{OV5693_8BIT, 0x3501, 0x7b},
927 	{OV5693_8BIT, 0x3502, 0x00},
928 	{OV5693_8BIT, 0x3708, 0xe2},
929 	{OV5693_8BIT, 0x3709, 0xc3},
930 	{OV5693_8BIT, 0x3800, 0x00},
931 	{OV5693_8BIT, 0x3801, 0x00},
932 	{OV5693_8BIT, 0x3802, 0x00},
933 	{OV5693_8BIT, 0x3803, 0xf0},
934 	{OV5693_8BIT, 0x3804, 0x0a},
935 	{OV5693_8BIT, 0x3805, 0x3f},
936 	{OV5693_8BIT, 0x3806, 0x06},
937 	{OV5693_8BIT, 0x3807, 0xa4},
938 	{OV5693_8BIT, 0x3808, 0x0a},
939 	{OV5693_8BIT, 0x3809, 0x10},
940 	{OV5693_8BIT, 0x380a, 0x05},
941 	{OV5693_8BIT, 0x380b, 0xb0},
942 	{OV5693_8BIT, 0x380c, 0x0a},
943 	{OV5693_8BIT, 0x380d, 0x80},
944 	{OV5693_8BIT, 0x380e, 0x07},
945 	{OV5693_8BIT, 0x380f, 0xc0},
946 	{OV5693_8BIT, 0x3811, 0x18},
947 	{OV5693_8BIT, 0x3813, 0x00},
948 	{OV5693_8BIT, 0x3814, 0x11},
949 	{OV5693_8BIT, 0x3815, 0x11},
950 	{OV5693_8BIT, 0x3820, 0x00},
951 	{OV5693_8BIT, 0x3821, 0x1e},
952 	{OV5693_8BIT, 0x5002, 0x00},
953 	{OV5693_TOK_TERM, 0, 0}
954 };
955 
956 /*
957  * 2592x1944 30fps 0.6ms VBlanking 2lane 10Bit
958  */
959 #if ENABLE_NON_PREVIEW
960 static struct ov5693_reg const ov5693_2592x1944_30fps[] = {
961 	{OV5693_8BIT, 0x3501, 0x7b},
962 	{OV5693_8BIT, 0x3502, 0x00},
963 	{OV5693_8BIT, 0x3708, 0xe2},
964 	{OV5693_8BIT, 0x3709, 0xc3},
965 	{OV5693_8BIT, 0x3803, 0x00},
966 	{OV5693_8BIT, 0x3806, 0x07},
967 	{OV5693_8BIT, 0x3807, 0xa3},
968 	{OV5693_8BIT, 0x3808, 0x0a},
969 	{OV5693_8BIT, 0x3809, 0x20},
970 	{OV5693_8BIT, 0x380a, 0x07},
971 	{OV5693_8BIT, 0x380b, 0x98},
972 	{OV5693_8BIT, 0x380c, 0x0a},
973 	{OV5693_8BIT, 0x380d, 0x80},
974 	{OV5693_8BIT, 0x380e, 0x07},
975 	{OV5693_8BIT, 0x380f, 0xc0},
976 	{OV5693_8BIT, 0x3811, 0x10},
977 	{OV5693_8BIT, 0x3813, 0x00},
978 	{OV5693_8BIT, 0x3814, 0x11},
979 	{OV5693_8BIT, 0x3815, 0x11},
980 	{OV5693_8BIT, 0x3820, 0x00},
981 	{OV5693_8BIT, 0x3821, 0x1e},
982 	{OV5693_8BIT, 0x5002, 0x00},
983 	{OV5693_8BIT, 0x0100, 0x01},
984 	{OV5693_TOK_TERM, 0, 0}
985 };
986 #endif
987 
988 /*
989  * 11:9 Full FOV Output, expected FOV Res: 2346x1920
990  * ISP Effect Res: 1408x1152
991  * Sensor out: 1424x1168, DS From: 2380x1952
992  *
993  * WA: Left Offset: 8, Hor scal: 64
994  */
995 #if ENABLE_NON_PREVIEW
996 static struct ov5693_reg const ov5693_1424x1168_30fps[] = {
997 	{OV5693_8BIT, 0x3501, 0x3b}, /* long exposure[15:8] */
998 	{OV5693_8BIT, 0x3502, 0x80}, /* long exposure[7:0] */
999 	{OV5693_8BIT, 0x3708, 0xe2},
1000 	{OV5693_8BIT, 0x3709, 0xc3},
1001 	{OV5693_8BIT, 0x3800, 0x00}, /* TIMING_X_ADDR_START */
1002 	{OV5693_8BIT, 0x3801, 0x50}, /* 80 */
1003 	{OV5693_8BIT, 0x3802, 0x00}, /* TIMING_Y_ADDR_START */
1004 	{OV5693_8BIT, 0x3803, 0x02}, /* 2 */
1005 	{OV5693_8BIT, 0x3804, 0x09}, /* TIMING_X_ADDR_END */
1006 	{OV5693_8BIT, 0x3805, 0xdd}, /* 2525 */
1007 	{OV5693_8BIT, 0x3806, 0x07}, /* TIMING_Y_ADDR_END */
1008 	{OV5693_8BIT, 0x3807, 0xa1}, /* 1953 */
1009 	{OV5693_8BIT, 0x3808, 0x05}, /* TIMING_X_OUTPUT_SIZE */
1010 	{OV5693_8BIT, 0x3809, 0x90}, /* 1424 */
1011 	{OV5693_8BIT, 0x380a, 0x04}, /* TIMING_Y_OUTPUT_SIZE */
1012 	{OV5693_8BIT, 0x380b, 0x90}, /* 1168 */
1013 	{OV5693_8BIT, 0x380c, 0x0a}, /* TIMING_HTS */
1014 	{OV5693_8BIT, 0x380d, 0x80},
1015 	{OV5693_8BIT, 0x380e, 0x07}, /* TIMING_VTS */
1016 	{OV5693_8BIT, 0x380f, 0xc0},
1017 	{OV5693_8BIT, 0x3810, 0x00}, /* TIMING_ISP_X_WIN */
1018 	{OV5693_8BIT, 0x3811, 0x02}, /* 2 */
1019 	{OV5693_8BIT, 0x3812, 0x00}, /* TIMING_ISP_Y_WIN */
1020 	{OV5693_8BIT, 0x3813, 0x00}, /* 0 */
1021 	{OV5693_8BIT, 0x3814, 0x11}, /* TIME_X_INC */
1022 	{OV5693_8BIT, 0x3815, 0x11}, /* TIME_Y_INC */
1023 	{OV5693_8BIT, 0x3820, 0x00},
1024 	{OV5693_8BIT, 0x3821, 0x1e},
1025 	{OV5693_8BIT, 0x5002, 0x00},
1026 	{OV5693_8BIT, 0x5041, 0x84}, /* scale is auto enabled */
1027 	{OV5693_8BIT, 0x0100, 0x01},
1028 	{OV5693_TOK_TERM, 0, 0}
1029 };
1030 #endif
1031 
1032 /*
1033  * 3:2 Full FOV Output, expected FOV Res: 2560x1706
1034  * ISP Effect Res: 720x480
1035  * Sensor out: 736x496, DS From 2616x1764
1036  */
1037 static struct ov5693_reg const ov5693_736x496_30fps[] = {
1038 	{OV5693_8BIT, 0x3501, 0x3b}, /* long exposure[15:8] */
1039 	{OV5693_8BIT, 0x3502, 0x80}, /* long exposure[7:0] */
1040 	{OV5693_8BIT, 0x3708, 0xe2},
1041 	{OV5693_8BIT, 0x3709, 0xc3},
1042 	{OV5693_8BIT, 0x3800, 0x00}, /* TIMING_X_ADDR_START */
1043 	{OV5693_8BIT, 0x3801, 0x02}, /* 2 */
1044 	{OV5693_8BIT, 0x3802, 0x00}, /* TIMING_Y_ADDR_START */
1045 	{OV5693_8BIT, 0x3803, 0x62}, /* 98 */
1046 	{OV5693_8BIT, 0x3804, 0x0a}, /* TIMING_X_ADDR_END */
1047 	{OV5693_8BIT, 0x3805, 0x3b}, /* 2619 */
1048 	{OV5693_8BIT, 0x3806, 0x07}, /* TIMING_Y_ADDR_END */
1049 	{OV5693_8BIT, 0x3807, 0x43}, /* 1859 */
1050 	{OV5693_8BIT, 0x3808, 0x02}, /* TIMING_X_OUTPUT_SIZE */
1051 	{OV5693_8BIT, 0x3809, 0xe0}, /* 736 */
1052 	{OV5693_8BIT, 0x380a, 0x01}, /* TIMING_Y_OUTPUT_SIZE */
1053 	{OV5693_8BIT, 0x380b, 0xf0}, /* 496 */
1054 	{OV5693_8BIT, 0x380c, 0x0a}, /* TIMING_HTS */
1055 	{OV5693_8BIT, 0x380d, 0x80},
1056 	{OV5693_8BIT, 0x380e, 0x07}, /* TIMING_VTS */
1057 	{OV5693_8BIT, 0x380f, 0xc0},
1058 	{OV5693_8BIT, 0x3810, 0x00}, /* TIMING_ISP_X_WIN */
1059 	{OV5693_8BIT, 0x3811, 0x02}, /* 2 */
1060 	{OV5693_8BIT, 0x3812, 0x00}, /* TIMING_ISP_Y_WIN */
1061 	{OV5693_8BIT, 0x3813, 0x00}, /* 0 */
1062 	{OV5693_8BIT, 0x3814, 0x11}, /* TIME_X_INC */
1063 	{OV5693_8BIT, 0x3815, 0x11}, /* TIME_Y_INC */
1064 	{OV5693_8BIT, 0x3820, 0x00},
1065 	{OV5693_8BIT, 0x3821, 0x1e},
1066 	{OV5693_8BIT, 0x5002, 0x00},
1067 	{OV5693_8BIT, 0x5041, 0x84}, /* scale is auto enabled */
1068 	{OV5693_8BIT, 0x0100, 0x01},
1069 	{OV5693_TOK_TERM, 0, 0}
1070 };
1071 
1072 static struct ov5693_reg const ov5693_2576x1936_30fps[] = {
1073 	{OV5693_8BIT, 0x3501, 0x7b},
1074 	{OV5693_8BIT, 0x3502, 0x00},
1075 	{OV5693_8BIT, 0x3708, 0xe2},
1076 	{OV5693_8BIT, 0x3709, 0xc3},
1077 	{OV5693_8BIT, 0x3803, 0x00},
1078 	{OV5693_8BIT, 0x3806, 0x07},
1079 	{OV5693_8BIT, 0x3807, 0xa3},
1080 	{OV5693_8BIT, 0x3808, 0x0a},
1081 	{OV5693_8BIT, 0x3809, 0x10},
1082 	{OV5693_8BIT, 0x380a, 0x07},
1083 	{OV5693_8BIT, 0x380b, 0x90},
1084 	{OV5693_8BIT, 0x380c, 0x0a},
1085 	{OV5693_8BIT, 0x380d, 0x80},
1086 	{OV5693_8BIT, 0x380e, 0x07},
1087 	{OV5693_8BIT, 0x380f, 0xc0},
1088 	{OV5693_8BIT, 0x3811, 0x18},
1089 	{OV5693_8BIT, 0x3813, 0x00},
1090 	{OV5693_8BIT, 0x3814, 0x11},
1091 	{OV5693_8BIT, 0x3815, 0x11},
1092 	{OV5693_8BIT, 0x3820, 0x00},
1093 	{OV5693_8BIT, 0x3821, 0x1e},
1094 	{OV5693_8BIT, 0x5002, 0x00},
1095 	{OV5693_8BIT, 0x0100, 0x01},
1096 	{OV5693_TOK_TERM, 0, 0}
1097 };
1098 
1099 static struct ov5693_resolution ov5693_res_preview[] = {
1100 	{
1101 		.desc = "ov5693_736x496_30fps",
1102 		.width = 736,
1103 		.height = 496,
1104 		.pix_clk_freq = 160,
1105 		.fps = 30,
1106 		.used = 0,
1107 		.pixels_per_line = 2688,
1108 		.lines_per_frame = 1984,
1109 		.regs = ov5693_736x496_30fps,
1110 	},
1111 	{
1112 		.desc = "ov5693_1616x1216_30fps",
1113 		.width = 1616,
1114 		.height = 1216,
1115 		.pix_clk_freq = 160,
1116 		.fps = 30,
1117 		.used = 0,
1118 		.pixels_per_line = 2688,
1119 		.lines_per_frame = 1984,
1120 		.regs = ov5693_1616x1216_30fps,
1121 	},
1122 	{
1123 		.desc = "ov5693_5M_30fps",
1124 		.width = 2576,
1125 		.height = 1456,
1126 		.pix_clk_freq = 160,
1127 		.fps = 30,
1128 		.used = 0,
1129 		.pixels_per_line = 2688,
1130 		.lines_per_frame = 1984,
1131 		.regs = ov5693_2576x1456_30fps,
1132 	},
1133 	{
1134 		.desc = "ov5693_5M_30fps",
1135 		.width = 2576,
1136 		.height = 1936,
1137 		.pix_clk_freq = 160,
1138 		.fps = 30,
1139 		.used = 0,
1140 		.pixels_per_line = 2688,
1141 		.lines_per_frame = 1984,
1142 		.regs = ov5693_2576x1936_30fps,
1143 	},
1144 };
1145 
1146 #define N_RES_PREVIEW (ARRAY_SIZE(ov5693_res_preview))
1147 
1148 /*
1149  * Disable non-preview configurations until the configuration selection is
1150  * improved.
1151  */
1152 #if ENABLE_NON_PREVIEW
1153 struct ov5693_resolution ov5693_res_still[] = {
1154 	{
1155 		.desc = "ov5693_736x496_30fps",
1156 		.width = 736,
1157 		.height = 496,
1158 		.pix_clk_freq = 160,
1159 		.fps = 30,
1160 		.used = 0,
1161 		.pixels_per_line = 2688,
1162 		.lines_per_frame = 1984,
1163 		.regs = ov5693_736x496_30fps,
1164 	},
1165 	{
1166 		.desc = "ov5693_1424x1168_30fps",
1167 		.width = 1424,
1168 		.height = 1168,
1169 		.pix_clk_freq = 160,
1170 		.fps = 30,
1171 		.used = 0,
1172 		.pixels_per_line = 2688,
1173 		.lines_per_frame = 1984,
1174 		.regs = ov5693_1424x1168_30fps,
1175 	},
1176 	{
1177 		.desc = "ov5693_1616x1216_30fps",
1178 		.width = 1616,
1179 		.height = 1216,
1180 		.pix_clk_freq = 160,
1181 		.fps = 30,
1182 		.used = 0,
1183 		.pixels_per_line = 2688,
1184 		.lines_per_frame = 1984,
1185 		.regs = ov5693_1616x1216_30fps,
1186 	},
1187 	{
1188 		.desc = "ov5693_5M_30fps",
1189 		.width = 2592,
1190 		.height = 1456,
1191 		.pix_clk_freq = 160,
1192 		.fps = 30,
1193 		.used = 0,
1194 		.pixels_per_line = 2688,
1195 		.lines_per_frame = 1984,
1196 		.regs = ov5693_2592x1456_30fps,
1197 	},
1198 	{
1199 		.desc = "ov5693_5M_30fps",
1200 		.width = 2592,
1201 		.height = 1944,
1202 		.pix_clk_freq = 160,
1203 		.fps = 30,
1204 		.used = 0,
1205 		.pixels_per_line = 2688,
1206 		.lines_per_frame = 1984,
1207 		.regs = ov5693_2592x1944_30fps,
1208 	},
1209 };
1210 
1211 #define N_RES_STILL (ARRAY_SIZE(ov5693_res_still))
1212 
1213 struct ov5693_resolution ov5693_res_video[] = {
1214 	{
1215 		.desc = "ov5693_736x496_30fps",
1216 		.width = 736,
1217 		.height = 496,
1218 		.fps = 30,
1219 		.pix_clk_freq = 160,
1220 		.used = 0,
1221 		.pixels_per_line = 2688,
1222 		.lines_per_frame = 1984,
1223 		.regs = ov5693_736x496,
1224 	},
1225 	{
1226 		.desc = "ov5693_336x256_30fps",
1227 		.width = 336,
1228 		.height = 256,
1229 		.fps = 30,
1230 		.pix_clk_freq = 160,
1231 		.used = 0,
1232 		.pixels_per_line = 2688,
1233 		.lines_per_frame = 1984,
1234 		.regs = ov5693_336x256,
1235 	},
1236 	{
1237 		.desc = "ov5693_368x304_30fps",
1238 		.width = 368,
1239 		.height = 304,
1240 		.fps = 30,
1241 		.pix_clk_freq = 160,
1242 		.used = 0,
1243 		.pixels_per_line = 2688,
1244 		.lines_per_frame = 1984,
1245 		.regs = ov5693_368x304,
1246 	},
1247 	{
1248 		.desc = "ov5693_192x160_30fps",
1249 		.width = 192,
1250 		.height = 160,
1251 		.fps = 30,
1252 		.pix_clk_freq = 160,
1253 		.used = 0,
1254 		.pixels_per_line = 2688,
1255 		.lines_per_frame = 1984,
1256 		.regs = ov5693_192x160,
1257 	},
1258 	{
1259 		.desc = "ov5693_1296x736_30fps",
1260 		.width = 1296,
1261 		.height = 736,
1262 		.fps = 30,
1263 		.pix_clk_freq = 160,
1264 		.used = 0,
1265 		.pixels_per_line = 2688,
1266 		.lines_per_frame = 1984,
1267 		.regs = ov5693_1296x736,
1268 	},
1269 	{
1270 		.desc = "ov5693_1296x976_30fps",
1271 		.width = 1296,
1272 		.height = 976,
1273 		.fps = 30,
1274 		.pix_clk_freq = 160,
1275 		.used = 0,
1276 		.pixels_per_line = 2688,
1277 		.lines_per_frame = 1984,
1278 		.regs = ov5693_1296x976,
1279 	},
1280 	{
1281 		.desc = "ov5693_1636P_30fps",
1282 		.width = 1636,
1283 		.height = 1096,
1284 		.fps = 30,
1285 		.pix_clk_freq = 160,
1286 		.used = 0,
1287 		.pixels_per_line = 2688,
1288 		.lines_per_frame = 1984,
1289 		.regs = ov5693_1636p_30fps,
1290 	},
1291 	{
1292 		.desc = "ov5693_1080P_30fps",
1293 		.width = 1940,
1294 		.height = 1096,
1295 		.fps = 30,
1296 		.pix_clk_freq = 160,
1297 		.used = 0,
1298 		.pixels_per_line = 2688,
1299 		.lines_per_frame = 1984,
1300 		.regs = ov5693_1940x1096,
1301 	},
1302 	{
1303 		.desc = "ov5693_5M_30fps",
1304 		.width = 2592,
1305 		.height = 1456,
1306 		.pix_clk_freq = 160,
1307 		.fps = 30,
1308 		.used = 0,
1309 		.pixels_per_line = 2688,
1310 		.lines_per_frame = 1984,
1311 		.regs = ov5693_2592x1456_30fps,
1312 	},
1313 	{
1314 		.desc = "ov5693_5M_30fps",
1315 		.width = 2592,
1316 		.height = 1944,
1317 		.pix_clk_freq = 160,
1318 		.fps = 30,
1319 		.used = 0,
1320 		.pixels_per_line = 2688,
1321 		.lines_per_frame = 1984,
1322 		.regs = ov5693_2592x1944_30fps,
1323 	},
1324 };
1325 
1326 #define N_RES_VIDEO (ARRAY_SIZE(ov5693_res_video))
1327 #endif
1328 
1329 static struct ov5693_resolution *ov5693_res = ov5693_res_preview;
1330 static unsigned long N_RES = N_RES_PREVIEW;
1331 #endif
1332