xref: /OK3568_Linux_fs/kernel/drivers/media/i2c/imx319.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0
2*4882a593Smuzhiyun // Copyright (C) 2018 Intel Corporation
3*4882a593Smuzhiyun 
4*4882a593Smuzhiyun #include <asm/unaligned.h>
5*4882a593Smuzhiyun #include <linux/acpi.h>
6*4882a593Smuzhiyun #include <linux/i2c.h>
7*4882a593Smuzhiyun #include <linux/module.h>
8*4882a593Smuzhiyun #include <linux/pm_runtime.h>
9*4882a593Smuzhiyun #include <media/v4l2-ctrls.h>
10*4882a593Smuzhiyun #include <media/v4l2-device.h>
11*4882a593Smuzhiyun #include <media/v4l2-event.h>
12*4882a593Smuzhiyun #include <media/v4l2-fwnode.h>
13*4882a593Smuzhiyun 
14*4882a593Smuzhiyun #define IMX319_REG_MODE_SELECT		0x0100
15*4882a593Smuzhiyun #define IMX319_MODE_STANDBY		0x00
16*4882a593Smuzhiyun #define IMX319_MODE_STREAMING		0x01
17*4882a593Smuzhiyun 
18*4882a593Smuzhiyun /* Chip ID */
19*4882a593Smuzhiyun #define IMX319_REG_CHIP_ID		0x0016
20*4882a593Smuzhiyun #define IMX319_CHIP_ID			0x0319
21*4882a593Smuzhiyun 
22*4882a593Smuzhiyun /* V_TIMING internal */
23*4882a593Smuzhiyun #define IMX319_REG_FLL			0x0340
24*4882a593Smuzhiyun #define IMX319_FLL_MAX			0xffff
25*4882a593Smuzhiyun 
26*4882a593Smuzhiyun /* Exposure control */
27*4882a593Smuzhiyun #define IMX319_REG_EXPOSURE		0x0202
28*4882a593Smuzhiyun #define IMX319_EXPOSURE_MIN		1
29*4882a593Smuzhiyun #define IMX319_EXPOSURE_STEP		1
30*4882a593Smuzhiyun #define IMX319_EXPOSURE_DEFAULT		0x04f6
31*4882a593Smuzhiyun 
32*4882a593Smuzhiyun /*
33*4882a593Smuzhiyun  *  the digital control register for all color control looks like:
34*4882a593Smuzhiyun  *  +-----------------+------------------+
35*4882a593Smuzhiyun  *  |      [7:0]      |       [15:8]     |
36*4882a593Smuzhiyun  *  +-----------------+------------------+
37*4882a593Smuzhiyun  *  |	  0x020f      |       0x020e     |
38*4882a593Smuzhiyun  *  --------------------------------------
39*4882a593Smuzhiyun  *  it is used to calculate the digital gain times value(integral + fractional)
40*4882a593Smuzhiyun  *  the [15:8] bits is the fractional part and [7:0] bits is the integral
41*4882a593Smuzhiyun  *  calculation equation is:
42*4882a593Smuzhiyun  *      gain value (unit: times) = REG[15:8] + REG[7:0]/0x100
43*4882a593Smuzhiyun  *  Only value in 0x0100 ~ 0x0FFF range is allowed.
44*4882a593Smuzhiyun  *  Analog gain use 10 bits in the registers and allowed range is 0 ~ 960
45*4882a593Smuzhiyun  */
46*4882a593Smuzhiyun /* Analog gain control */
47*4882a593Smuzhiyun #define IMX319_REG_ANALOG_GAIN		0x0204
48*4882a593Smuzhiyun #define IMX319_ANA_GAIN_MIN		0
49*4882a593Smuzhiyun #define IMX319_ANA_GAIN_MAX		960
50*4882a593Smuzhiyun #define IMX319_ANA_GAIN_STEP		1
51*4882a593Smuzhiyun #define IMX319_ANA_GAIN_DEFAULT		0
52*4882a593Smuzhiyun 
53*4882a593Smuzhiyun /* Digital gain control */
54*4882a593Smuzhiyun #define IMX319_REG_DPGA_USE_GLOBAL_GAIN	0x3ff9
55*4882a593Smuzhiyun #define IMX319_REG_DIG_GAIN_GLOBAL	0x020e
56*4882a593Smuzhiyun #define IMX319_DGTL_GAIN_MIN		256
57*4882a593Smuzhiyun #define IMX319_DGTL_GAIN_MAX		4095
58*4882a593Smuzhiyun #define IMX319_DGTL_GAIN_STEP		1
59*4882a593Smuzhiyun #define IMX319_DGTL_GAIN_DEFAULT	256
60*4882a593Smuzhiyun 
61*4882a593Smuzhiyun /* Test Pattern Control */
62*4882a593Smuzhiyun #define IMX319_REG_TEST_PATTERN		0x0600
63*4882a593Smuzhiyun #define IMX319_TEST_PATTERN_DISABLED		0
64*4882a593Smuzhiyun #define IMX319_TEST_PATTERN_SOLID_COLOR		1
65*4882a593Smuzhiyun #define IMX319_TEST_PATTERN_COLOR_BARS		2
66*4882a593Smuzhiyun #define IMX319_TEST_PATTERN_GRAY_COLOR_BARS	3
67*4882a593Smuzhiyun #define IMX319_TEST_PATTERN_PN9			4
68*4882a593Smuzhiyun 
69*4882a593Smuzhiyun /* Flip Control */
70*4882a593Smuzhiyun #define IMX319_REG_ORIENTATION		0x0101
71*4882a593Smuzhiyun 
72*4882a593Smuzhiyun /* default link frequency and external clock */
73*4882a593Smuzhiyun #define IMX319_LINK_FREQ_DEFAULT	482400000
74*4882a593Smuzhiyun #define IMX319_EXT_CLK			19200000
75*4882a593Smuzhiyun #define IMX319_LINK_FREQ_INDEX		0
76*4882a593Smuzhiyun 
77*4882a593Smuzhiyun struct imx319_reg {
78*4882a593Smuzhiyun 	u16 address;
79*4882a593Smuzhiyun 	u8 val;
80*4882a593Smuzhiyun };
81*4882a593Smuzhiyun 
82*4882a593Smuzhiyun struct imx319_reg_list {
83*4882a593Smuzhiyun 	u32 num_of_regs;
84*4882a593Smuzhiyun 	const struct imx319_reg *regs;
85*4882a593Smuzhiyun };
86*4882a593Smuzhiyun 
87*4882a593Smuzhiyun /* Mode : resolution and related config&values */
88*4882a593Smuzhiyun struct imx319_mode {
89*4882a593Smuzhiyun 	/* Frame width */
90*4882a593Smuzhiyun 	u32 width;
91*4882a593Smuzhiyun 	/* Frame height */
92*4882a593Smuzhiyun 	u32 height;
93*4882a593Smuzhiyun 
94*4882a593Smuzhiyun 	/* V-timing */
95*4882a593Smuzhiyun 	u32 fll_def;
96*4882a593Smuzhiyun 	u32 fll_min;
97*4882a593Smuzhiyun 
98*4882a593Smuzhiyun 	/* H-timing */
99*4882a593Smuzhiyun 	u32 llp;
100*4882a593Smuzhiyun 
101*4882a593Smuzhiyun 	/* index of link frequency */
102*4882a593Smuzhiyun 	u32 link_freq_index;
103*4882a593Smuzhiyun 
104*4882a593Smuzhiyun 	/* Default register values */
105*4882a593Smuzhiyun 	struct imx319_reg_list reg_list;
106*4882a593Smuzhiyun };
107*4882a593Smuzhiyun 
108*4882a593Smuzhiyun struct imx319_hwcfg {
109*4882a593Smuzhiyun 	u32 ext_clk;			/* sensor external clk */
110*4882a593Smuzhiyun 	s64 *link_freqs;		/* CSI-2 link frequencies */
111*4882a593Smuzhiyun 	unsigned int nr_of_link_freqs;
112*4882a593Smuzhiyun };
113*4882a593Smuzhiyun 
114*4882a593Smuzhiyun struct imx319 {
115*4882a593Smuzhiyun 	struct v4l2_subdev sd;
116*4882a593Smuzhiyun 	struct media_pad pad;
117*4882a593Smuzhiyun 
118*4882a593Smuzhiyun 	struct v4l2_ctrl_handler ctrl_handler;
119*4882a593Smuzhiyun 	/* V4L2 Controls */
120*4882a593Smuzhiyun 	struct v4l2_ctrl *link_freq;
121*4882a593Smuzhiyun 	struct v4l2_ctrl *pixel_rate;
122*4882a593Smuzhiyun 	struct v4l2_ctrl *vblank;
123*4882a593Smuzhiyun 	struct v4l2_ctrl *hblank;
124*4882a593Smuzhiyun 	struct v4l2_ctrl *exposure;
125*4882a593Smuzhiyun 	struct v4l2_ctrl *vflip;
126*4882a593Smuzhiyun 	struct v4l2_ctrl *hflip;
127*4882a593Smuzhiyun 
128*4882a593Smuzhiyun 	/* Current mode */
129*4882a593Smuzhiyun 	const struct imx319_mode *cur_mode;
130*4882a593Smuzhiyun 
131*4882a593Smuzhiyun 	struct imx319_hwcfg *hwcfg;
132*4882a593Smuzhiyun 	s64 link_def_freq;	/* CSI-2 link default frequency */
133*4882a593Smuzhiyun 
134*4882a593Smuzhiyun 	/*
135*4882a593Smuzhiyun 	 * Mutex for serialized access:
136*4882a593Smuzhiyun 	 * Protect sensor set pad format and start/stop streaming safely.
137*4882a593Smuzhiyun 	 * Protect access to sensor v4l2 controls.
138*4882a593Smuzhiyun 	 */
139*4882a593Smuzhiyun 	struct mutex mutex;
140*4882a593Smuzhiyun 
141*4882a593Smuzhiyun 	/* Streaming on/off */
142*4882a593Smuzhiyun 	bool streaming;
143*4882a593Smuzhiyun };
144*4882a593Smuzhiyun 
145*4882a593Smuzhiyun static const struct imx319_reg imx319_global_regs[] = {
146*4882a593Smuzhiyun 	{ 0x0136, 0x13 },
147*4882a593Smuzhiyun 	{ 0x0137, 0x33 },
148*4882a593Smuzhiyun 	{ 0x3c7e, 0x05 },
149*4882a593Smuzhiyun 	{ 0x3c7f, 0x07 },
150*4882a593Smuzhiyun 	{ 0x4d39, 0x0b },
151*4882a593Smuzhiyun 	{ 0x4d41, 0x33 },
152*4882a593Smuzhiyun 	{ 0x4d43, 0x0c },
153*4882a593Smuzhiyun 	{ 0x4d49, 0x89 },
154*4882a593Smuzhiyun 	{ 0x4e05, 0x0b },
155*4882a593Smuzhiyun 	{ 0x4e0d, 0x33 },
156*4882a593Smuzhiyun 	{ 0x4e0f, 0x0c },
157*4882a593Smuzhiyun 	{ 0x4e15, 0x89 },
158*4882a593Smuzhiyun 	{ 0x4e49, 0x2a },
159*4882a593Smuzhiyun 	{ 0x4e51, 0x33 },
160*4882a593Smuzhiyun 	{ 0x4e53, 0x0c },
161*4882a593Smuzhiyun 	{ 0x4e59, 0x89 },
162*4882a593Smuzhiyun 	{ 0x5601, 0x4f },
163*4882a593Smuzhiyun 	{ 0x560b, 0x45 },
164*4882a593Smuzhiyun 	{ 0x562f, 0x0a },
165*4882a593Smuzhiyun 	{ 0x5643, 0x0a },
166*4882a593Smuzhiyun 	{ 0x5645, 0x0c },
167*4882a593Smuzhiyun 	{ 0x56ef, 0x51 },
168*4882a593Smuzhiyun 	{ 0x586f, 0x33 },
169*4882a593Smuzhiyun 	{ 0x5873, 0x89 },
170*4882a593Smuzhiyun 	{ 0x5905, 0x33 },
171*4882a593Smuzhiyun 	{ 0x5907, 0x89 },
172*4882a593Smuzhiyun 	{ 0x590d, 0x33 },
173*4882a593Smuzhiyun 	{ 0x590f, 0x89 },
174*4882a593Smuzhiyun 	{ 0x5915, 0x33 },
175*4882a593Smuzhiyun 	{ 0x5917, 0x89 },
176*4882a593Smuzhiyun 	{ 0x5969, 0x1c },
177*4882a593Smuzhiyun 	{ 0x596b, 0x72 },
178*4882a593Smuzhiyun 	{ 0x5971, 0x33 },
179*4882a593Smuzhiyun 	{ 0x5973, 0x89 },
180*4882a593Smuzhiyun 	{ 0x5975, 0x33 },
181*4882a593Smuzhiyun 	{ 0x5977, 0x89 },
182*4882a593Smuzhiyun 	{ 0x5979, 0x1c },
183*4882a593Smuzhiyun 	{ 0x597b, 0x72 },
184*4882a593Smuzhiyun 	{ 0x5985, 0x33 },
185*4882a593Smuzhiyun 	{ 0x5987, 0x89 },
186*4882a593Smuzhiyun 	{ 0x5999, 0x1c },
187*4882a593Smuzhiyun 	{ 0x599b, 0x72 },
188*4882a593Smuzhiyun 	{ 0x59a5, 0x33 },
189*4882a593Smuzhiyun 	{ 0x59a7, 0x89 },
190*4882a593Smuzhiyun 	{ 0x7485, 0x08 },
191*4882a593Smuzhiyun 	{ 0x7487, 0x0c },
192*4882a593Smuzhiyun 	{ 0x7489, 0xc7 },
193*4882a593Smuzhiyun 	{ 0x748b, 0x8b },
194*4882a593Smuzhiyun 	{ 0x9004, 0x09 },
195*4882a593Smuzhiyun 	{ 0x9200, 0x6a },
196*4882a593Smuzhiyun 	{ 0x9201, 0x22 },
197*4882a593Smuzhiyun 	{ 0x9202, 0x6a },
198*4882a593Smuzhiyun 	{ 0x9203, 0x23 },
199*4882a593Smuzhiyun 	{ 0x9204, 0x5f },
200*4882a593Smuzhiyun 	{ 0x9205, 0x23 },
201*4882a593Smuzhiyun 	{ 0x9206, 0x5f },
202*4882a593Smuzhiyun 	{ 0x9207, 0x24 },
203*4882a593Smuzhiyun 	{ 0x9208, 0x5f },
204*4882a593Smuzhiyun 	{ 0x9209, 0x26 },
205*4882a593Smuzhiyun 	{ 0x920a, 0x5f },
206*4882a593Smuzhiyun 	{ 0x920b, 0x27 },
207*4882a593Smuzhiyun 	{ 0x920c, 0x5f },
208*4882a593Smuzhiyun 	{ 0x920d, 0x29 },
209*4882a593Smuzhiyun 	{ 0x920e, 0x5f },
210*4882a593Smuzhiyun 	{ 0x920f, 0x2a },
211*4882a593Smuzhiyun 	{ 0x9210, 0x5f },
212*4882a593Smuzhiyun 	{ 0x9211, 0x2c },
213*4882a593Smuzhiyun 	{ 0xbc22, 0x1a },
214*4882a593Smuzhiyun 	{ 0xf01f, 0x04 },
215*4882a593Smuzhiyun 	{ 0xf021, 0x03 },
216*4882a593Smuzhiyun 	{ 0xf023, 0x02 },
217*4882a593Smuzhiyun 	{ 0xf03d, 0x05 },
218*4882a593Smuzhiyun 	{ 0xf03f, 0x03 },
219*4882a593Smuzhiyun 	{ 0xf041, 0x02 },
220*4882a593Smuzhiyun 	{ 0xf0af, 0x04 },
221*4882a593Smuzhiyun 	{ 0xf0b1, 0x03 },
222*4882a593Smuzhiyun 	{ 0xf0b3, 0x02 },
223*4882a593Smuzhiyun 	{ 0xf0cd, 0x05 },
224*4882a593Smuzhiyun 	{ 0xf0cf, 0x03 },
225*4882a593Smuzhiyun 	{ 0xf0d1, 0x02 },
226*4882a593Smuzhiyun 	{ 0xf13f, 0x04 },
227*4882a593Smuzhiyun 	{ 0xf141, 0x03 },
228*4882a593Smuzhiyun 	{ 0xf143, 0x02 },
229*4882a593Smuzhiyun 	{ 0xf15d, 0x05 },
230*4882a593Smuzhiyun 	{ 0xf15f, 0x03 },
231*4882a593Smuzhiyun 	{ 0xf161, 0x02 },
232*4882a593Smuzhiyun 	{ 0xf1cf, 0x04 },
233*4882a593Smuzhiyun 	{ 0xf1d1, 0x03 },
234*4882a593Smuzhiyun 	{ 0xf1d3, 0x02 },
235*4882a593Smuzhiyun 	{ 0xf1ed, 0x05 },
236*4882a593Smuzhiyun 	{ 0xf1ef, 0x03 },
237*4882a593Smuzhiyun 	{ 0xf1f1, 0x02 },
238*4882a593Smuzhiyun 	{ 0xf287, 0x04 },
239*4882a593Smuzhiyun 	{ 0xf289, 0x03 },
240*4882a593Smuzhiyun 	{ 0xf28b, 0x02 },
241*4882a593Smuzhiyun 	{ 0xf2a5, 0x05 },
242*4882a593Smuzhiyun 	{ 0xf2a7, 0x03 },
243*4882a593Smuzhiyun 	{ 0xf2a9, 0x02 },
244*4882a593Smuzhiyun 	{ 0xf2b7, 0x04 },
245*4882a593Smuzhiyun 	{ 0xf2b9, 0x03 },
246*4882a593Smuzhiyun 	{ 0xf2bb, 0x02 },
247*4882a593Smuzhiyun 	{ 0xf2d5, 0x05 },
248*4882a593Smuzhiyun 	{ 0xf2d7, 0x03 },
249*4882a593Smuzhiyun 	{ 0xf2d9, 0x02 },
250*4882a593Smuzhiyun };
251*4882a593Smuzhiyun 
252*4882a593Smuzhiyun static const struct imx319_reg_list imx319_global_setting = {
253*4882a593Smuzhiyun 	.num_of_regs = ARRAY_SIZE(imx319_global_regs),
254*4882a593Smuzhiyun 	.regs = imx319_global_regs,
255*4882a593Smuzhiyun };
256*4882a593Smuzhiyun 
257*4882a593Smuzhiyun static const struct imx319_reg mode_3264x2448_regs[] = {
258*4882a593Smuzhiyun 	{ 0x0112, 0x0a },
259*4882a593Smuzhiyun 	{ 0x0113, 0x0a },
260*4882a593Smuzhiyun 	{ 0x0114, 0x03 },
261*4882a593Smuzhiyun 	{ 0x0342, 0x0f },
262*4882a593Smuzhiyun 	{ 0x0343, 0x80 },
263*4882a593Smuzhiyun 	{ 0x0340, 0x0c },
264*4882a593Smuzhiyun 	{ 0x0341, 0xaa },
265*4882a593Smuzhiyun 	{ 0x0344, 0x00 },
266*4882a593Smuzhiyun 	{ 0x0345, 0x00 },
267*4882a593Smuzhiyun 	{ 0x0346, 0x00 },
268*4882a593Smuzhiyun 	{ 0x0347, 0x00 },
269*4882a593Smuzhiyun 	{ 0x0348, 0x0c },
270*4882a593Smuzhiyun 	{ 0x0349, 0xcf },
271*4882a593Smuzhiyun 	{ 0x034a, 0x09 },
272*4882a593Smuzhiyun 	{ 0x034b, 0x9f },
273*4882a593Smuzhiyun 	{ 0x0220, 0x00 },
274*4882a593Smuzhiyun 	{ 0x0221, 0x11 },
275*4882a593Smuzhiyun 	{ 0x0381, 0x01 },
276*4882a593Smuzhiyun 	{ 0x0383, 0x01 },
277*4882a593Smuzhiyun 	{ 0x0385, 0x01 },
278*4882a593Smuzhiyun 	{ 0x0387, 0x01 },
279*4882a593Smuzhiyun 	{ 0x0900, 0x00 },
280*4882a593Smuzhiyun 	{ 0x0901, 0x11 },
281*4882a593Smuzhiyun 	{ 0x0902, 0x0a },
282*4882a593Smuzhiyun 	{ 0x3140, 0x02 },
283*4882a593Smuzhiyun 	{ 0x3141, 0x00 },
284*4882a593Smuzhiyun 	{ 0x3f0d, 0x0a },
285*4882a593Smuzhiyun 	{ 0x3f14, 0x01 },
286*4882a593Smuzhiyun 	{ 0x3f3c, 0x01 },
287*4882a593Smuzhiyun 	{ 0x3f4d, 0x01 },
288*4882a593Smuzhiyun 	{ 0x3f4c, 0x01 },
289*4882a593Smuzhiyun 	{ 0x4254, 0x7f },
290*4882a593Smuzhiyun 	{ 0x0401, 0x00 },
291*4882a593Smuzhiyun 	{ 0x0404, 0x00 },
292*4882a593Smuzhiyun 	{ 0x0405, 0x10 },
293*4882a593Smuzhiyun 	{ 0x0408, 0x00 },
294*4882a593Smuzhiyun 	{ 0x0409, 0x08 },
295*4882a593Smuzhiyun 	{ 0x040a, 0x00 },
296*4882a593Smuzhiyun 	{ 0x040b, 0x08 },
297*4882a593Smuzhiyun 	{ 0x040c, 0x0c },
298*4882a593Smuzhiyun 	{ 0x040d, 0xc0 },
299*4882a593Smuzhiyun 	{ 0x040e, 0x09 },
300*4882a593Smuzhiyun 	{ 0x040f, 0x90 },
301*4882a593Smuzhiyun 	{ 0x034c, 0x0c },
302*4882a593Smuzhiyun 	{ 0x034d, 0xc0 },
303*4882a593Smuzhiyun 	{ 0x034e, 0x09 },
304*4882a593Smuzhiyun 	{ 0x034f, 0x90 },
305*4882a593Smuzhiyun 	{ 0x3261, 0x00 },
306*4882a593Smuzhiyun 	{ 0x3264, 0x00 },
307*4882a593Smuzhiyun 	{ 0x3265, 0x10 },
308*4882a593Smuzhiyun 	{ 0x0301, 0x05 },
309*4882a593Smuzhiyun 	{ 0x0303, 0x04 },
310*4882a593Smuzhiyun 	{ 0x0305, 0x04 },
311*4882a593Smuzhiyun 	{ 0x0306, 0x01 },
312*4882a593Smuzhiyun 	{ 0x0307, 0x92 },
313*4882a593Smuzhiyun 	{ 0x0309, 0x0a },
314*4882a593Smuzhiyun 	{ 0x030b, 0x02 },
315*4882a593Smuzhiyun 	{ 0x030d, 0x02 },
316*4882a593Smuzhiyun 	{ 0x030e, 0x00 },
317*4882a593Smuzhiyun 	{ 0x030f, 0xfa },
318*4882a593Smuzhiyun 	{ 0x0310, 0x00 },
319*4882a593Smuzhiyun 	{ 0x0820, 0x0f },
320*4882a593Smuzhiyun 	{ 0x0821, 0x13 },
321*4882a593Smuzhiyun 	{ 0x0822, 0x33 },
322*4882a593Smuzhiyun 	{ 0x0823, 0x33 },
323*4882a593Smuzhiyun 	{ 0x3e20, 0x01 },
324*4882a593Smuzhiyun 	{ 0x3e37, 0x00 },
325*4882a593Smuzhiyun 	{ 0x3e3b, 0x01 },
326*4882a593Smuzhiyun 	{ 0x38a3, 0x01 },
327*4882a593Smuzhiyun 	{ 0x38a8, 0x00 },
328*4882a593Smuzhiyun 	{ 0x38a9, 0x00 },
329*4882a593Smuzhiyun 	{ 0x38aa, 0x00 },
330*4882a593Smuzhiyun 	{ 0x38ab, 0x00 },
331*4882a593Smuzhiyun 	{ 0x3234, 0x00 },
332*4882a593Smuzhiyun 	{ 0x3fc1, 0x00 },
333*4882a593Smuzhiyun 	{ 0x3235, 0x00 },
334*4882a593Smuzhiyun 	{ 0x3802, 0x00 },
335*4882a593Smuzhiyun 	{ 0x3143, 0x04 },
336*4882a593Smuzhiyun 	{ 0x360a, 0x00 },
337*4882a593Smuzhiyun 	{ 0x0b00, 0x00 },
338*4882a593Smuzhiyun 	{ 0x0106, 0x00 },
339*4882a593Smuzhiyun 	{ 0x0b05, 0x01 },
340*4882a593Smuzhiyun 	{ 0x0b06, 0x01 },
341*4882a593Smuzhiyun 	{ 0x3230, 0x00 },
342*4882a593Smuzhiyun 	{ 0x3602, 0x01 },
343*4882a593Smuzhiyun 	{ 0x3607, 0x01 },
344*4882a593Smuzhiyun 	{ 0x3c00, 0x00 },
345*4882a593Smuzhiyun 	{ 0x3c01, 0x48 },
346*4882a593Smuzhiyun 	{ 0x3c02, 0xc8 },
347*4882a593Smuzhiyun 	{ 0x3c03, 0xaa },
348*4882a593Smuzhiyun 	{ 0x3c04, 0x91 },
349*4882a593Smuzhiyun 	{ 0x3c05, 0x54 },
350*4882a593Smuzhiyun 	{ 0x3c06, 0x26 },
351*4882a593Smuzhiyun 	{ 0x3c07, 0x20 },
352*4882a593Smuzhiyun 	{ 0x3c08, 0x51 },
353*4882a593Smuzhiyun 	{ 0x3d80, 0x00 },
354*4882a593Smuzhiyun 	{ 0x3f50, 0x00 },
355*4882a593Smuzhiyun 	{ 0x3f56, 0x00 },
356*4882a593Smuzhiyun 	{ 0x3f57, 0x30 },
357*4882a593Smuzhiyun 	{ 0x3f78, 0x01 },
358*4882a593Smuzhiyun 	{ 0x3f79, 0x18 },
359*4882a593Smuzhiyun 	{ 0x3f7c, 0x00 },
360*4882a593Smuzhiyun 	{ 0x3f7d, 0x00 },
361*4882a593Smuzhiyun 	{ 0x3fba, 0x00 },
362*4882a593Smuzhiyun 	{ 0x3fbb, 0x00 },
363*4882a593Smuzhiyun 	{ 0xa081, 0x00 },
364*4882a593Smuzhiyun 	{ 0xe014, 0x00 },
365*4882a593Smuzhiyun 	{ 0x0202, 0x0a },
366*4882a593Smuzhiyun 	{ 0x0203, 0x7a },
367*4882a593Smuzhiyun 	{ 0x0224, 0x01 },
368*4882a593Smuzhiyun 	{ 0x0225, 0xf4 },
369*4882a593Smuzhiyun 	{ 0x0204, 0x00 },
370*4882a593Smuzhiyun 	{ 0x0205, 0x00 },
371*4882a593Smuzhiyun 	{ 0x0216, 0x00 },
372*4882a593Smuzhiyun 	{ 0x0217, 0x00 },
373*4882a593Smuzhiyun 	{ 0x020e, 0x01 },
374*4882a593Smuzhiyun 	{ 0x020f, 0x00 },
375*4882a593Smuzhiyun 	{ 0x0210, 0x01 },
376*4882a593Smuzhiyun 	{ 0x0211, 0x00 },
377*4882a593Smuzhiyun 	{ 0x0212, 0x01 },
378*4882a593Smuzhiyun 	{ 0x0213, 0x00 },
379*4882a593Smuzhiyun 	{ 0x0214, 0x01 },
380*4882a593Smuzhiyun 	{ 0x0215, 0x00 },
381*4882a593Smuzhiyun 	{ 0x0218, 0x01 },
382*4882a593Smuzhiyun 	{ 0x0219, 0x00 },
383*4882a593Smuzhiyun 	{ 0x3614, 0x00 },
384*4882a593Smuzhiyun 	{ 0x3616, 0x0d },
385*4882a593Smuzhiyun 	{ 0x3617, 0x56 },
386*4882a593Smuzhiyun 	{ 0xb612, 0x20 },
387*4882a593Smuzhiyun 	{ 0xb613, 0x20 },
388*4882a593Smuzhiyun 	{ 0xb614, 0x20 },
389*4882a593Smuzhiyun 	{ 0xb615, 0x20 },
390*4882a593Smuzhiyun 	{ 0xb616, 0x0a },
391*4882a593Smuzhiyun 	{ 0xb617, 0x0a },
392*4882a593Smuzhiyun 	{ 0xb618, 0x20 },
393*4882a593Smuzhiyun 	{ 0xb619, 0x20 },
394*4882a593Smuzhiyun 	{ 0xb61a, 0x20 },
395*4882a593Smuzhiyun 	{ 0xb61b, 0x20 },
396*4882a593Smuzhiyun 	{ 0xb61c, 0x0a },
397*4882a593Smuzhiyun 	{ 0xb61d, 0x0a },
398*4882a593Smuzhiyun 	{ 0xb666, 0x30 },
399*4882a593Smuzhiyun 	{ 0xb667, 0x30 },
400*4882a593Smuzhiyun 	{ 0xb668, 0x30 },
401*4882a593Smuzhiyun 	{ 0xb669, 0x30 },
402*4882a593Smuzhiyun 	{ 0xb66a, 0x14 },
403*4882a593Smuzhiyun 	{ 0xb66b, 0x14 },
404*4882a593Smuzhiyun 	{ 0xb66c, 0x20 },
405*4882a593Smuzhiyun 	{ 0xb66d, 0x20 },
406*4882a593Smuzhiyun 	{ 0xb66e, 0x20 },
407*4882a593Smuzhiyun 	{ 0xb66f, 0x20 },
408*4882a593Smuzhiyun 	{ 0xb670, 0x10 },
409*4882a593Smuzhiyun 	{ 0xb671, 0x10 },
410*4882a593Smuzhiyun 	{ 0x3237, 0x00 },
411*4882a593Smuzhiyun 	{ 0x3900, 0x00 },
412*4882a593Smuzhiyun 	{ 0x3901, 0x00 },
413*4882a593Smuzhiyun 	{ 0x3902, 0x00 },
414*4882a593Smuzhiyun 	{ 0x3904, 0x00 },
415*4882a593Smuzhiyun 	{ 0x3905, 0x00 },
416*4882a593Smuzhiyun 	{ 0x3906, 0x00 },
417*4882a593Smuzhiyun 	{ 0x3907, 0x00 },
418*4882a593Smuzhiyun 	{ 0x3908, 0x00 },
419*4882a593Smuzhiyun 	{ 0x3909, 0x00 },
420*4882a593Smuzhiyun 	{ 0x3912, 0x00 },
421*4882a593Smuzhiyun 	{ 0x3930, 0x00 },
422*4882a593Smuzhiyun 	{ 0x3931, 0x00 },
423*4882a593Smuzhiyun 	{ 0x3933, 0x00 },
424*4882a593Smuzhiyun 	{ 0x3934, 0x00 },
425*4882a593Smuzhiyun 	{ 0x3935, 0x00 },
426*4882a593Smuzhiyun 	{ 0x3936, 0x00 },
427*4882a593Smuzhiyun 	{ 0x3937, 0x00 },
428*4882a593Smuzhiyun 	{ 0x30ac, 0x00 },
429*4882a593Smuzhiyun };
430*4882a593Smuzhiyun 
431*4882a593Smuzhiyun static const struct imx319_reg mode_3280x2464_regs[] = {
432*4882a593Smuzhiyun 	{ 0x0112, 0x0a },
433*4882a593Smuzhiyun 	{ 0x0113, 0x0a },
434*4882a593Smuzhiyun 	{ 0x0114, 0x03 },
435*4882a593Smuzhiyun 	{ 0x0342, 0x0f },
436*4882a593Smuzhiyun 	{ 0x0343, 0x80 },
437*4882a593Smuzhiyun 	{ 0x0340, 0x0c },
438*4882a593Smuzhiyun 	{ 0x0341, 0xaa },
439*4882a593Smuzhiyun 	{ 0x0344, 0x00 },
440*4882a593Smuzhiyun 	{ 0x0345, 0x00 },
441*4882a593Smuzhiyun 	{ 0x0346, 0x00 },
442*4882a593Smuzhiyun 	{ 0x0347, 0x00 },
443*4882a593Smuzhiyun 	{ 0x0348, 0x0c },
444*4882a593Smuzhiyun 	{ 0x0349, 0xcf },
445*4882a593Smuzhiyun 	{ 0x034a, 0x09 },
446*4882a593Smuzhiyun 	{ 0x034b, 0x9f },
447*4882a593Smuzhiyun 	{ 0x0220, 0x00 },
448*4882a593Smuzhiyun 	{ 0x0221, 0x11 },
449*4882a593Smuzhiyun 	{ 0x0381, 0x01 },
450*4882a593Smuzhiyun 	{ 0x0383, 0x01 },
451*4882a593Smuzhiyun 	{ 0x0385, 0x01 },
452*4882a593Smuzhiyun 	{ 0x0387, 0x01 },
453*4882a593Smuzhiyun 	{ 0x0900, 0x00 },
454*4882a593Smuzhiyun 	{ 0x0901, 0x11 },
455*4882a593Smuzhiyun 	{ 0x0902, 0x0a },
456*4882a593Smuzhiyun 	{ 0x3140, 0x02 },
457*4882a593Smuzhiyun 	{ 0x3141, 0x00 },
458*4882a593Smuzhiyun 	{ 0x3f0d, 0x0a },
459*4882a593Smuzhiyun 	{ 0x3f14, 0x01 },
460*4882a593Smuzhiyun 	{ 0x3f3c, 0x01 },
461*4882a593Smuzhiyun 	{ 0x3f4d, 0x01 },
462*4882a593Smuzhiyun 	{ 0x3f4c, 0x01 },
463*4882a593Smuzhiyun 	{ 0x4254, 0x7f },
464*4882a593Smuzhiyun 	{ 0x0401, 0x00 },
465*4882a593Smuzhiyun 	{ 0x0404, 0x00 },
466*4882a593Smuzhiyun 	{ 0x0405, 0x10 },
467*4882a593Smuzhiyun 	{ 0x0408, 0x00 },
468*4882a593Smuzhiyun 	{ 0x0409, 0x00 },
469*4882a593Smuzhiyun 	{ 0x040a, 0x00 },
470*4882a593Smuzhiyun 	{ 0x040b, 0x00 },
471*4882a593Smuzhiyun 	{ 0x040c, 0x0c },
472*4882a593Smuzhiyun 	{ 0x040d, 0xd0 },
473*4882a593Smuzhiyun 	{ 0x040e, 0x09 },
474*4882a593Smuzhiyun 	{ 0x040f, 0xa0 },
475*4882a593Smuzhiyun 	{ 0x034c, 0x0c },
476*4882a593Smuzhiyun 	{ 0x034d, 0xd0 },
477*4882a593Smuzhiyun 	{ 0x034e, 0x09 },
478*4882a593Smuzhiyun 	{ 0x034f, 0xa0 },
479*4882a593Smuzhiyun 	{ 0x3261, 0x00 },
480*4882a593Smuzhiyun 	{ 0x3264, 0x00 },
481*4882a593Smuzhiyun 	{ 0x3265, 0x10 },
482*4882a593Smuzhiyun 	{ 0x0301, 0x05 },
483*4882a593Smuzhiyun 	{ 0x0303, 0x04 },
484*4882a593Smuzhiyun 	{ 0x0305, 0x04 },
485*4882a593Smuzhiyun 	{ 0x0306, 0x01 },
486*4882a593Smuzhiyun 	{ 0x0307, 0x92 },
487*4882a593Smuzhiyun 	{ 0x0309, 0x0a },
488*4882a593Smuzhiyun 	{ 0x030b, 0x02 },
489*4882a593Smuzhiyun 	{ 0x030d, 0x02 },
490*4882a593Smuzhiyun 	{ 0x030e, 0x00 },
491*4882a593Smuzhiyun 	{ 0x030f, 0xfa },
492*4882a593Smuzhiyun 	{ 0x0310, 0x00 },
493*4882a593Smuzhiyun 	{ 0x0820, 0x0f },
494*4882a593Smuzhiyun 	{ 0x0821, 0x13 },
495*4882a593Smuzhiyun 	{ 0x0822, 0x33 },
496*4882a593Smuzhiyun 	{ 0x0823, 0x33 },
497*4882a593Smuzhiyun 	{ 0x3e20, 0x01 },
498*4882a593Smuzhiyun 	{ 0x3e37, 0x00 },
499*4882a593Smuzhiyun 	{ 0x3e3b, 0x01 },
500*4882a593Smuzhiyun 	{ 0x38a3, 0x01 },
501*4882a593Smuzhiyun 	{ 0x38a8, 0x00 },
502*4882a593Smuzhiyun 	{ 0x38a9, 0x00 },
503*4882a593Smuzhiyun 	{ 0x38aa, 0x00 },
504*4882a593Smuzhiyun 	{ 0x38ab, 0x00 },
505*4882a593Smuzhiyun 	{ 0x3234, 0x00 },
506*4882a593Smuzhiyun 	{ 0x3fc1, 0x00 },
507*4882a593Smuzhiyun 	{ 0x3235, 0x00 },
508*4882a593Smuzhiyun 	{ 0x3802, 0x00 },
509*4882a593Smuzhiyun 	{ 0x3143, 0x04 },
510*4882a593Smuzhiyun 	{ 0x360a, 0x00 },
511*4882a593Smuzhiyun 	{ 0x0b00, 0x00 },
512*4882a593Smuzhiyun 	{ 0x0106, 0x00 },
513*4882a593Smuzhiyun 	{ 0x0b05, 0x01 },
514*4882a593Smuzhiyun 	{ 0x0b06, 0x01 },
515*4882a593Smuzhiyun 	{ 0x3230, 0x00 },
516*4882a593Smuzhiyun 	{ 0x3602, 0x01 },
517*4882a593Smuzhiyun 	{ 0x3607, 0x01 },
518*4882a593Smuzhiyun 	{ 0x3c00, 0x00 },
519*4882a593Smuzhiyun 	{ 0x3c01, 0x48 },
520*4882a593Smuzhiyun 	{ 0x3c02, 0xc8 },
521*4882a593Smuzhiyun 	{ 0x3c03, 0xaa },
522*4882a593Smuzhiyun 	{ 0x3c04, 0x91 },
523*4882a593Smuzhiyun 	{ 0x3c05, 0x54 },
524*4882a593Smuzhiyun 	{ 0x3c06, 0x26 },
525*4882a593Smuzhiyun 	{ 0x3c07, 0x20 },
526*4882a593Smuzhiyun 	{ 0x3c08, 0x51 },
527*4882a593Smuzhiyun 	{ 0x3d80, 0x00 },
528*4882a593Smuzhiyun 	{ 0x3f50, 0x00 },
529*4882a593Smuzhiyun 	{ 0x3f56, 0x00 },
530*4882a593Smuzhiyun 	{ 0x3f57, 0x30 },
531*4882a593Smuzhiyun 	{ 0x3f78, 0x01 },
532*4882a593Smuzhiyun 	{ 0x3f79, 0x18 },
533*4882a593Smuzhiyun 	{ 0x3f7c, 0x00 },
534*4882a593Smuzhiyun 	{ 0x3f7d, 0x00 },
535*4882a593Smuzhiyun 	{ 0x3fba, 0x00 },
536*4882a593Smuzhiyun 	{ 0x3fbb, 0x00 },
537*4882a593Smuzhiyun 	{ 0xa081, 0x00 },
538*4882a593Smuzhiyun 	{ 0xe014, 0x00 },
539*4882a593Smuzhiyun 	{ 0x0202, 0x0a },
540*4882a593Smuzhiyun 	{ 0x0203, 0x7a },
541*4882a593Smuzhiyun 	{ 0x0224, 0x01 },
542*4882a593Smuzhiyun 	{ 0x0225, 0xf4 },
543*4882a593Smuzhiyun 	{ 0x0204, 0x00 },
544*4882a593Smuzhiyun 	{ 0x0205, 0x00 },
545*4882a593Smuzhiyun 	{ 0x0216, 0x00 },
546*4882a593Smuzhiyun 	{ 0x0217, 0x00 },
547*4882a593Smuzhiyun 	{ 0x020e, 0x01 },
548*4882a593Smuzhiyun 	{ 0x020f, 0x00 },
549*4882a593Smuzhiyun 	{ 0x0210, 0x01 },
550*4882a593Smuzhiyun 	{ 0x0211, 0x00 },
551*4882a593Smuzhiyun 	{ 0x0212, 0x01 },
552*4882a593Smuzhiyun 	{ 0x0213, 0x00 },
553*4882a593Smuzhiyun 	{ 0x0214, 0x01 },
554*4882a593Smuzhiyun 	{ 0x0215, 0x00 },
555*4882a593Smuzhiyun 	{ 0x0218, 0x01 },
556*4882a593Smuzhiyun 	{ 0x0219, 0x00 },
557*4882a593Smuzhiyun 	{ 0x3614, 0x00 },
558*4882a593Smuzhiyun 	{ 0x3616, 0x0d },
559*4882a593Smuzhiyun 	{ 0x3617, 0x56 },
560*4882a593Smuzhiyun 	{ 0xb612, 0x20 },
561*4882a593Smuzhiyun 	{ 0xb613, 0x20 },
562*4882a593Smuzhiyun 	{ 0xb614, 0x20 },
563*4882a593Smuzhiyun 	{ 0xb615, 0x20 },
564*4882a593Smuzhiyun 	{ 0xb616, 0x0a },
565*4882a593Smuzhiyun 	{ 0xb617, 0x0a },
566*4882a593Smuzhiyun 	{ 0xb618, 0x20 },
567*4882a593Smuzhiyun 	{ 0xb619, 0x20 },
568*4882a593Smuzhiyun 	{ 0xb61a, 0x20 },
569*4882a593Smuzhiyun 	{ 0xb61b, 0x20 },
570*4882a593Smuzhiyun 	{ 0xb61c, 0x0a },
571*4882a593Smuzhiyun 	{ 0xb61d, 0x0a },
572*4882a593Smuzhiyun 	{ 0xb666, 0x30 },
573*4882a593Smuzhiyun 	{ 0xb667, 0x30 },
574*4882a593Smuzhiyun 	{ 0xb668, 0x30 },
575*4882a593Smuzhiyun 	{ 0xb669, 0x30 },
576*4882a593Smuzhiyun 	{ 0xb66a, 0x14 },
577*4882a593Smuzhiyun 	{ 0xb66b, 0x14 },
578*4882a593Smuzhiyun 	{ 0xb66c, 0x20 },
579*4882a593Smuzhiyun 	{ 0xb66d, 0x20 },
580*4882a593Smuzhiyun 	{ 0xb66e, 0x20 },
581*4882a593Smuzhiyun 	{ 0xb66f, 0x20 },
582*4882a593Smuzhiyun 	{ 0xb670, 0x10 },
583*4882a593Smuzhiyun 	{ 0xb671, 0x10 },
584*4882a593Smuzhiyun 	{ 0x3237, 0x00 },
585*4882a593Smuzhiyun 	{ 0x3900, 0x00 },
586*4882a593Smuzhiyun 	{ 0x3901, 0x00 },
587*4882a593Smuzhiyun 	{ 0x3902, 0x00 },
588*4882a593Smuzhiyun 	{ 0x3904, 0x00 },
589*4882a593Smuzhiyun 	{ 0x3905, 0x00 },
590*4882a593Smuzhiyun 	{ 0x3906, 0x00 },
591*4882a593Smuzhiyun 	{ 0x3907, 0x00 },
592*4882a593Smuzhiyun 	{ 0x3908, 0x00 },
593*4882a593Smuzhiyun 	{ 0x3909, 0x00 },
594*4882a593Smuzhiyun 	{ 0x3912, 0x00 },
595*4882a593Smuzhiyun 	{ 0x3930, 0x00 },
596*4882a593Smuzhiyun 	{ 0x3931, 0x00 },
597*4882a593Smuzhiyun 	{ 0x3933, 0x00 },
598*4882a593Smuzhiyun 	{ 0x3934, 0x00 },
599*4882a593Smuzhiyun 	{ 0x3935, 0x00 },
600*4882a593Smuzhiyun 	{ 0x3936, 0x00 },
601*4882a593Smuzhiyun 	{ 0x3937, 0x00 },
602*4882a593Smuzhiyun 	{ 0x30ac, 0x00 },
603*4882a593Smuzhiyun };
604*4882a593Smuzhiyun 
605*4882a593Smuzhiyun static const struct imx319_reg mode_1936x1096_regs[] = {
606*4882a593Smuzhiyun 	{ 0x0112, 0x0a },
607*4882a593Smuzhiyun 	{ 0x0113, 0x0a },
608*4882a593Smuzhiyun 	{ 0x0114, 0x03 },
609*4882a593Smuzhiyun 	{ 0x0342, 0x0f },
610*4882a593Smuzhiyun 	{ 0x0343, 0x80 },
611*4882a593Smuzhiyun 	{ 0x0340, 0x0c },
612*4882a593Smuzhiyun 	{ 0x0341, 0xaa },
613*4882a593Smuzhiyun 	{ 0x0344, 0x00 },
614*4882a593Smuzhiyun 	{ 0x0345, 0x00 },
615*4882a593Smuzhiyun 	{ 0x0346, 0x02 },
616*4882a593Smuzhiyun 	{ 0x0347, 0xac },
617*4882a593Smuzhiyun 	{ 0x0348, 0x0c },
618*4882a593Smuzhiyun 	{ 0x0349, 0xcf },
619*4882a593Smuzhiyun 	{ 0x034a, 0x06 },
620*4882a593Smuzhiyun 	{ 0x034b, 0xf3 },
621*4882a593Smuzhiyun 	{ 0x0220, 0x00 },
622*4882a593Smuzhiyun 	{ 0x0221, 0x11 },
623*4882a593Smuzhiyun 	{ 0x0381, 0x01 },
624*4882a593Smuzhiyun 	{ 0x0383, 0x01 },
625*4882a593Smuzhiyun 	{ 0x0385, 0x01 },
626*4882a593Smuzhiyun 	{ 0x0387, 0x01 },
627*4882a593Smuzhiyun 	{ 0x0900, 0x00 },
628*4882a593Smuzhiyun 	{ 0x0901, 0x11 },
629*4882a593Smuzhiyun 	{ 0x0902, 0x0a },
630*4882a593Smuzhiyun 	{ 0x3140, 0x02 },
631*4882a593Smuzhiyun 	{ 0x3141, 0x00 },
632*4882a593Smuzhiyun 	{ 0x3f0d, 0x0a },
633*4882a593Smuzhiyun 	{ 0x3f14, 0x01 },
634*4882a593Smuzhiyun 	{ 0x3f3c, 0x01 },
635*4882a593Smuzhiyun 	{ 0x3f4d, 0x01 },
636*4882a593Smuzhiyun 	{ 0x3f4c, 0x01 },
637*4882a593Smuzhiyun 	{ 0x4254, 0x7f },
638*4882a593Smuzhiyun 	{ 0x0401, 0x00 },
639*4882a593Smuzhiyun 	{ 0x0404, 0x00 },
640*4882a593Smuzhiyun 	{ 0x0405, 0x10 },
641*4882a593Smuzhiyun 	{ 0x0408, 0x02 },
642*4882a593Smuzhiyun 	{ 0x0409, 0xa0 },
643*4882a593Smuzhiyun 	{ 0x040a, 0x00 },
644*4882a593Smuzhiyun 	{ 0x040b, 0x00 },
645*4882a593Smuzhiyun 	{ 0x040c, 0x07 },
646*4882a593Smuzhiyun 	{ 0x040d, 0x90 },
647*4882a593Smuzhiyun 	{ 0x040e, 0x04 },
648*4882a593Smuzhiyun 	{ 0x040f, 0x48 },
649*4882a593Smuzhiyun 	{ 0x034c, 0x07 },
650*4882a593Smuzhiyun 	{ 0x034d, 0x90 },
651*4882a593Smuzhiyun 	{ 0x034e, 0x04 },
652*4882a593Smuzhiyun 	{ 0x034f, 0x48 },
653*4882a593Smuzhiyun 	{ 0x3261, 0x00 },
654*4882a593Smuzhiyun 	{ 0x3264, 0x00 },
655*4882a593Smuzhiyun 	{ 0x3265, 0x10 },
656*4882a593Smuzhiyun 	{ 0x0301, 0x05 },
657*4882a593Smuzhiyun 	{ 0x0303, 0x04 },
658*4882a593Smuzhiyun 	{ 0x0305, 0x04 },
659*4882a593Smuzhiyun 	{ 0x0306, 0x01 },
660*4882a593Smuzhiyun 	{ 0x0307, 0x92 },
661*4882a593Smuzhiyun 	{ 0x0309, 0x0a },
662*4882a593Smuzhiyun 	{ 0x030b, 0x02 },
663*4882a593Smuzhiyun 	{ 0x030d, 0x02 },
664*4882a593Smuzhiyun 	{ 0x030e, 0x00 },
665*4882a593Smuzhiyun 	{ 0x030f, 0xfa },
666*4882a593Smuzhiyun 	{ 0x0310, 0x00 },
667*4882a593Smuzhiyun 	{ 0x0820, 0x0f },
668*4882a593Smuzhiyun 	{ 0x0821, 0x13 },
669*4882a593Smuzhiyun 	{ 0x0822, 0x33 },
670*4882a593Smuzhiyun 	{ 0x0823, 0x33 },
671*4882a593Smuzhiyun 	{ 0x3e20, 0x01 },
672*4882a593Smuzhiyun 	{ 0x3e37, 0x00 },
673*4882a593Smuzhiyun 	{ 0x3e3b, 0x01 },
674*4882a593Smuzhiyun 	{ 0x38a3, 0x01 },
675*4882a593Smuzhiyun 	{ 0x38a8, 0x00 },
676*4882a593Smuzhiyun 	{ 0x38a9, 0x00 },
677*4882a593Smuzhiyun 	{ 0x38aa, 0x00 },
678*4882a593Smuzhiyun 	{ 0x38ab, 0x00 },
679*4882a593Smuzhiyun 	{ 0x3234, 0x00 },
680*4882a593Smuzhiyun 	{ 0x3fc1, 0x00 },
681*4882a593Smuzhiyun 	{ 0x3235, 0x00 },
682*4882a593Smuzhiyun 	{ 0x3802, 0x00 },
683*4882a593Smuzhiyun 	{ 0x3143, 0x04 },
684*4882a593Smuzhiyun 	{ 0x360a, 0x00 },
685*4882a593Smuzhiyun 	{ 0x0b00, 0x00 },
686*4882a593Smuzhiyun 	{ 0x0106, 0x00 },
687*4882a593Smuzhiyun 	{ 0x0b05, 0x01 },
688*4882a593Smuzhiyun 	{ 0x0b06, 0x01 },
689*4882a593Smuzhiyun 	{ 0x3230, 0x00 },
690*4882a593Smuzhiyun 	{ 0x3602, 0x01 },
691*4882a593Smuzhiyun 	{ 0x3607, 0x01 },
692*4882a593Smuzhiyun 	{ 0x3c00, 0x00 },
693*4882a593Smuzhiyun 	{ 0x3c01, 0x48 },
694*4882a593Smuzhiyun 	{ 0x3c02, 0xc8 },
695*4882a593Smuzhiyun 	{ 0x3c03, 0xaa },
696*4882a593Smuzhiyun 	{ 0x3c04, 0x91 },
697*4882a593Smuzhiyun 	{ 0x3c05, 0x54 },
698*4882a593Smuzhiyun 	{ 0x3c06, 0x26 },
699*4882a593Smuzhiyun 	{ 0x3c07, 0x20 },
700*4882a593Smuzhiyun 	{ 0x3c08, 0x51 },
701*4882a593Smuzhiyun 	{ 0x3d80, 0x00 },
702*4882a593Smuzhiyun 	{ 0x3f50, 0x00 },
703*4882a593Smuzhiyun 	{ 0x3f56, 0x00 },
704*4882a593Smuzhiyun 	{ 0x3f57, 0x30 },
705*4882a593Smuzhiyun 	{ 0x3f78, 0x01 },
706*4882a593Smuzhiyun 	{ 0x3f79, 0x18 },
707*4882a593Smuzhiyun 	{ 0x3f7c, 0x00 },
708*4882a593Smuzhiyun 	{ 0x3f7d, 0x00 },
709*4882a593Smuzhiyun 	{ 0x3fba, 0x00 },
710*4882a593Smuzhiyun 	{ 0x3fbb, 0x00 },
711*4882a593Smuzhiyun 	{ 0xa081, 0x00 },
712*4882a593Smuzhiyun 	{ 0xe014, 0x00 },
713*4882a593Smuzhiyun 	{ 0x0202, 0x05 },
714*4882a593Smuzhiyun 	{ 0x0203, 0x34 },
715*4882a593Smuzhiyun 	{ 0x0224, 0x01 },
716*4882a593Smuzhiyun 	{ 0x0225, 0xf4 },
717*4882a593Smuzhiyun 	{ 0x0204, 0x00 },
718*4882a593Smuzhiyun 	{ 0x0205, 0x00 },
719*4882a593Smuzhiyun 	{ 0x0216, 0x00 },
720*4882a593Smuzhiyun 	{ 0x0217, 0x00 },
721*4882a593Smuzhiyun 	{ 0x020e, 0x01 },
722*4882a593Smuzhiyun 	{ 0x020f, 0x00 },
723*4882a593Smuzhiyun 	{ 0x0210, 0x01 },
724*4882a593Smuzhiyun 	{ 0x0211, 0x00 },
725*4882a593Smuzhiyun 	{ 0x0212, 0x01 },
726*4882a593Smuzhiyun 	{ 0x0213, 0x00 },
727*4882a593Smuzhiyun 	{ 0x0214, 0x01 },
728*4882a593Smuzhiyun 	{ 0x0215, 0x00 },
729*4882a593Smuzhiyun 	{ 0x0218, 0x01 },
730*4882a593Smuzhiyun 	{ 0x0219, 0x00 },
731*4882a593Smuzhiyun 	{ 0x3614, 0x00 },
732*4882a593Smuzhiyun 	{ 0x3616, 0x0d },
733*4882a593Smuzhiyun 	{ 0x3617, 0x56 },
734*4882a593Smuzhiyun 	{ 0xb612, 0x20 },
735*4882a593Smuzhiyun 	{ 0xb613, 0x20 },
736*4882a593Smuzhiyun 	{ 0xb614, 0x20 },
737*4882a593Smuzhiyun 	{ 0xb615, 0x20 },
738*4882a593Smuzhiyun 	{ 0xb616, 0x0a },
739*4882a593Smuzhiyun 	{ 0xb617, 0x0a },
740*4882a593Smuzhiyun 	{ 0xb618, 0x20 },
741*4882a593Smuzhiyun 	{ 0xb619, 0x20 },
742*4882a593Smuzhiyun 	{ 0xb61a, 0x20 },
743*4882a593Smuzhiyun 	{ 0xb61b, 0x20 },
744*4882a593Smuzhiyun 	{ 0xb61c, 0x0a },
745*4882a593Smuzhiyun 	{ 0xb61d, 0x0a },
746*4882a593Smuzhiyun 	{ 0xb666, 0x30 },
747*4882a593Smuzhiyun 	{ 0xb667, 0x30 },
748*4882a593Smuzhiyun 	{ 0xb668, 0x30 },
749*4882a593Smuzhiyun 	{ 0xb669, 0x30 },
750*4882a593Smuzhiyun 	{ 0xb66a, 0x14 },
751*4882a593Smuzhiyun 	{ 0xb66b, 0x14 },
752*4882a593Smuzhiyun 	{ 0xb66c, 0x20 },
753*4882a593Smuzhiyun 	{ 0xb66d, 0x20 },
754*4882a593Smuzhiyun 	{ 0xb66e, 0x20 },
755*4882a593Smuzhiyun 	{ 0xb66f, 0x20 },
756*4882a593Smuzhiyun 	{ 0xb670, 0x10 },
757*4882a593Smuzhiyun 	{ 0xb671, 0x10 },
758*4882a593Smuzhiyun 	{ 0x3237, 0x00 },
759*4882a593Smuzhiyun 	{ 0x3900, 0x00 },
760*4882a593Smuzhiyun 	{ 0x3901, 0x00 },
761*4882a593Smuzhiyun 	{ 0x3902, 0x00 },
762*4882a593Smuzhiyun 	{ 0x3904, 0x00 },
763*4882a593Smuzhiyun 	{ 0x3905, 0x00 },
764*4882a593Smuzhiyun 	{ 0x3906, 0x00 },
765*4882a593Smuzhiyun 	{ 0x3907, 0x00 },
766*4882a593Smuzhiyun 	{ 0x3908, 0x00 },
767*4882a593Smuzhiyun 	{ 0x3909, 0x00 },
768*4882a593Smuzhiyun 	{ 0x3912, 0x00 },
769*4882a593Smuzhiyun 	{ 0x3930, 0x00 },
770*4882a593Smuzhiyun 	{ 0x3931, 0x00 },
771*4882a593Smuzhiyun 	{ 0x3933, 0x00 },
772*4882a593Smuzhiyun 	{ 0x3934, 0x00 },
773*4882a593Smuzhiyun 	{ 0x3935, 0x00 },
774*4882a593Smuzhiyun 	{ 0x3936, 0x00 },
775*4882a593Smuzhiyun 	{ 0x3937, 0x00 },
776*4882a593Smuzhiyun 	{ 0x30ac, 0x00 },
777*4882a593Smuzhiyun };
778*4882a593Smuzhiyun 
779*4882a593Smuzhiyun static const struct imx319_reg mode_1920x1080_regs[] = {
780*4882a593Smuzhiyun 	{ 0x0112, 0x0a },
781*4882a593Smuzhiyun 	{ 0x0113, 0x0a },
782*4882a593Smuzhiyun 	{ 0x0114, 0x03 },
783*4882a593Smuzhiyun 	{ 0x0342, 0x0f },
784*4882a593Smuzhiyun 	{ 0x0343, 0x80 },
785*4882a593Smuzhiyun 	{ 0x0340, 0x0c },
786*4882a593Smuzhiyun 	{ 0x0341, 0xaa },
787*4882a593Smuzhiyun 	{ 0x0344, 0x00 },
788*4882a593Smuzhiyun 	{ 0x0345, 0x00 },
789*4882a593Smuzhiyun 	{ 0x0346, 0x02 },
790*4882a593Smuzhiyun 	{ 0x0347, 0xb4 },
791*4882a593Smuzhiyun 	{ 0x0348, 0x0c },
792*4882a593Smuzhiyun 	{ 0x0349, 0xcf },
793*4882a593Smuzhiyun 	{ 0x034a, 0x06 },
794*4882a593Smuzhiyun 	{ 0x034b, 0xeb },
795*4882a593Smuzhiyun 	{ 0x0220, 0x00 },
796*4882a593Smuzhiyun 	{ 0x0221, 0x11 },
797*4882a593Smuzhiyun 	{ 0x0381, 0x01 },
798*4882a593Smuzhiyun 	{ 0x0383, 0x01 },
799*4882a593Smuzhiyun 	{ 0x0385, 0x01 },
800*4882a593Smuzhiyun 	{ 0x0387, 0x01 },
801*4882a593Smuzhiyun 	{ 0x0900, 0x00 },
802*4882a593Smuzhiyun 	{ 0x0901, 0x11 },
803*4882a593Smuzhiyun 	{ 0x0902, 0x0a },
804*4882a593Smuzhiyun 	{ 0x3140, 0x02 },
805*4882a593Smuzhiyun 	{ 0x3141, 0x00 },
806*4882a593Smuzhiyun 	{ 0x3f0d, 0x0a },
807*4882a593Smuzhiyun 	{ 0x3f14, 0x01 },
808*4882a593Smuzhiyun 	{ 0x3f3c, 0x01 },
809*4882a593Smuzhiyun 	{ 0x3f4d, 0x01 },
810*4882a593Smuzhiyun 	{ 0x3f4c, 0x01 },
811*4882a593Smuzhiyun 	{ 0x4254, 0x7f },
812*4882a593Smuzhiyun 	{ 0x0401, 0x00 },
813*4882a593Smuzhiyun 	{ 0x0404, 0x00 },
814*4882a593Smuzhiyun 	{ 0x0405, 0x10 },
815*4882a593Smuzhiyun 	{ 0x0408, 0x02 },
816*4882a593Smuzhiyun 	{ 0x0409, 0xa8 },
817*4882a593Smuzhiyun 	{ 0x040a, 0x00 },
818*4882a593Smuzhiyun 	{ 0x040b, 0x00 },
819*4882a593Smuzhiyun 	{ 0x040c, 0x07 },
820*4882a593Smuzhiyun 	{ 0x040d, 0x80 },
821*4882a593Smuzhiyun 	{ 0x040e, 0x04 },
822*4882a593Smuzhiyun 	{ 0x040f, 0x38 },
823*4882a593Smuzhiyun 	{ 0x034c, 0x07 },
824*4882a593Smuzhiyun 	{ 0x034d, 0x80 },
825*4882a593Smuzhiyun 	{ 0x034e, 0x04 },
826*4882a593Smuzhiyun 	{ 0x034f, 0x38 },
827*4882a593Smuzhiyun 	{ 0x3261, 0x00 },
828*4882a593Smuzhiyun 	{ 0x3264, 0x00 },
829*4882a593Smuzhiyun 	{ 0x3265, 0x10 },
830*4882a593Smuzhiyun 	{ 0x0301, 0x05 },
831*4882a593Smuzhiyun 	{ 0x0303, 0x04 },
832*4882a593Smuzhiyun 	{ 0x0305, 0x04 },
833*4882a593Smuzhiyun 	{ 0x0306, 0x01 },
834*4882a593Smuzhiyun 	{ 0x0307, 0x92 },
835*4882a593Smuzhiyun 	{ 0x0309, 0x0a },
836*4882a593Smuzhiyun 	{ 0x030b, 0x02 },
837*4882a593Smuzhiyun 	{ 0x030d, 0x02 },
838*4882a593Smuzhiyun 	{ 0x030e, 0x00 },
839*4882a593Smuzhiyun 	{ 0x030f, 0xfa },
840*4882a593Smuzhiyun 	{ 0x0310, 0x00 },
841*4882a593Smuzhiyun 	{ 0x0820, 0x0f },
842*4882a593Smuzhiyun 	{ 0x0821, 0x13 },
843*4882a593Smuzhiyun 	{ 0x0822, 0x33 },
844*4882a593Smuzhiyun 	{ 0x0823, 0x33 },
845*4882a593Smuzhiyun 	{ 0x3e20, 0x01 },
846*4882a593Smuzhiyun 	{ 0x3e37, 0x00 },
847*4882a593Smuzhiyun 	{ 0x3e3b, 0x01 },
848*4882a593Smuzhiyun 	{ 0x38a3, 0x01 },
849*4882a593Smuzhiyun 	{ 0x38a8, 0x00 },
850*4882a593Smuzhiyun 	{ 0x38a9, 0x00 },
851*4882a593Smuzhiyun 	{ 0x38aa, 0x00 },
852*4882a593Smuzhiyun 	{ 0x38ab, 0x00 },
853*4882a593Smuzhiyun 	{ 0x3234, 0x00 },
854*4882a593Smuzhiyun 	{ 0x3fc1, 0x00 },
855*4882a593Smuzhiyun 	{ 0x3235, 0x00 },
856*4882a593Smuzhiyun 	{ 0x3802, 0x00 },
857*4882a593Smuzhiyun 	{ 0x3143, 0x04 },
858*4882a593Smuzhiyun 	{ 0x360a, 0x00 },
859*4882a593Smuzhiyun 	{ 0x0b00, 0x00 },
860*4882a593Smuzhiyun 	{ 0x0106, 0x00 },
861*4882a593Smuzhiyun 	{ 0x0b05, 0x01 },
862*4882a593Smuzhiyun 	{ 0x0b06, 0x01 },
863*4882a593Smuzhiyun 	{ 0x3230, 0x00 },
864*4882a593Smuzhiyun 	{ 0x3602, 0x01 },
865*4882a593Smuzhiyun 	{ 0x3607, 0x01 },
866*4882a593Smuzhiyun 	{ 0x3c00, 0x00 },
867*4882a593Smuzhiyun 	{ 0x3c01, 0x48 },
868*4882a593Smuzhiyun 	{ 0x3c02, 0xc8 },
869*4882a593Smuzhiyun 	{ 0x3c03, 0xaa },
870*4882a593Smuzhiyun 	{ 0x3c04, 0x91 },
871*4882a593Smuzhiyun 	{ 0x3c05, 0x54 },
872*4882a593Smuzhiyun 	{ 0x3c06, 0x26 },
873*4882a593Smuzhiyun 	{ 0x3c07, 0x20 },
874*4882a593Smuzhiyun 	{ 0x3c08, 0x51 },
875*4882a593Smuzhiyun 	{ 0x3d80, 0x00 },
876*4882a593Smuzhiyun 	{ 0x3f50, 0x00 },
877*4882a593Smuzhiyun 	{ 0x3f56, 0x00 },
878*4882a593Smuzhiyun 	{ 0x3f57, 0x30 },
879*4882a593Smuzhiyun 	{ 0x3f78, 0x01 },
880*4882a593Smuzhiyun 	{ 0x3f79, 0x18 },
881*4882a593Smuzhiyun 	{ 0x3f7c, 0x00 },
882*4882a593Smuzhiyun 	{ 0x3f7d, 0x00 },
883*4882a593Smuzhiyun 	{ 0x3fba, 0x00 },
884*4882a593Smuzhiyun 	{ 0x3fbb, 0x00 },
885*4882a593Smuzhiyun 	{ 0xa081, 0x00 },
886*4882a593Smuzhiyun 	{ 0xe014, 0x00 },
887*4882a593Smuzhiyun 	{ 0x0202, 0x05 },
888*4882a593Smuzhiyun 	{ 0x0203, 0x34 },
889*4882a593Smuzhiyun 	{ 0x0224, 0x01 },
890*4882a593Smuzhiyun 	{ 0x0225, 0xf4 },
891*4882a593Smuzhiyun 	{ 0x0204, 0x00 },
892*4882a593Smuzhiyun 	{ 0x0205, 0x00 },
893*4882a593Smuzhiyun 	{ 0x0216, 0x00 },
894*4882a593Smuzhiyun 	{ 0x0217, 0x00 },
895*4882a593Smuzhiyun 	{ 0x020e, 0x01 },
896*4882a593Smuzhiyun 	{ 0x020f, 0x00 },
897*4882a593Smuzhiyun 	{ 0x0210, 0x01 },
898*4882a593Smuzhiyun 	{ 0x0211, 0x00 },
899*4882a593Smuzhiyun 	{ 0x0212, 0x01 },
900*4882a593Smuzhiyun 	{ 0x0213, 0x00 },
901*4882a593Smuzhiyun 	{ 0x0214, 0x01 },
902*4882a593Smuzhiyun 	{ 0x0215, 0x00 },
903*4882a593Smuzhiyun 	{ 0x0218, 0x01 },
904*4882a593Smuzhiyun 	{ 0x0219, 0x00 },
905*4882a593Smuzhiyun 	{ 0x3614, 0x00 },
906*4882a593Smuzhiyun 	{ 0x3616, 0x0d },
907*4882a593Smuzhiyun 	{ 0x3617, 0x56 },
908*4882a593Smuzhiyun 	{ 0xb612, 0x20 },
909*4882a593Smuzhiyun 	{ 0xb613, 0x20 },
910*4882a593Smuzhiyun 	{ 0xb614, 0x20 },
911*4882a593Smuzhiyun 	{ 0xb615, 0x20 },
912*4882a593Smuzhiyun 	{ 0xb616, 0x0a },
913*4882a593Smuzhiyun 	{ 0xb617, 0x0a },
914*4882a593Smuzhiyun 	{ 0xb618, 0x20 },
915*4882a593Smuzhiyun 	{ 0xb619, 0x20 },
916*4882a593Smuzhiyun 	{ 0xb61a, 0x20 },
917*4882a593Smuzhiyun 	{ 0xb61b, 0x20 },
918*4882a593Smuzhiyun 	{ 0xb61c, 0x0a },
919*4882a593Smuzhiyun 	{ 0xb61d, 0x0a },
920*4882a593Smuzhiyun 	{ 0xb666, 0x30 },
921*4882a593Smuzhiyun 	{ 0xb667, 0x30 },
922*4882a593Smuzhiyun 	{ 0xb668, 0x30 },
923*4882a593Smuzhiyun 	{ 0xb669, 0x30 },
924*4882a593Smuzhiyun 	{ 0xb66a, 0x14 },
925*4882a593Smuzhiyun 	{ 0xb66b, 0x14 },
926*4882a593Smuzhiyun 	{ 0xb66c, 0x20 },
927*4882a593Smuzhiyun 	{ 0xb66d, 0x20 },
928*4882a593Smuzhiyun 	{ 0xb66e, 0x20 },
929*4882a593Smuzhiyun 	{ 0xb66f, 0x20 },
930*4882a593Smuzhiyun 	{ 0xb670, 0x10 },
931*4882a593Smuzhiyun 	{ 0xb671, 0x10 },
932*4882a593Smuzhiyun 	{ 0x3237, 0x00 },
933*4882a593Smuzhiyun 	{ 0x3900, 0x00 },
934*4882a593Smuzhiyun 	{ 0x3901, 0x00 },
935*4882a593Smuzhiyun 	{ 0x3902, 0x00 },
936*4882a593Smuzhiyun 	{ 0x3904, 0x00 },
937*4882a593Smuzhiyun 	{ 0x3905, 0x00 },
938*4882a593Smuzhiyun 	{ 0x3906, 0x00 },
939*4882a593Smuzhiyun 	{ 0x3907, 0x00 },
940*4882a593Smuzhiyun 	{ 0x3908, 0x00 },
941*4882a593Smuzhiyun 	{ 0x3909, 0x00 },
942*4882a593Smuzhiyun 	{ 0x3912, 0x00 },
943*4882a593Smuzhiyun 	{ 0x3930, 0x00 },
944*4882a593Smuzhiyun 	{ 0x3931, 0x00 },
945*4882a593Smuzhiyun 	{ 0x3933, 0x00 },
946*4882a593Smuzhiyun 	{ 0x3934, 0x00 },
947*4882a593Smuzhiyun 	{ 0x3935, 0x00 },
948*4882a593Smuzhiyun 	{ 0x3936, 0x00 },
949*4882a593Smuzhiyun 	{ 0x3937, 0x00 },
950*4882a593Smuzhiyun 	{ 0x30ac, 0x00 },
951*4882a593Smuzhiyun };
952*4882a593Smuzhiyun 
953*4882a593Smuzhiyun static const struct imx319_reg mode_1640x1232_regs[] = {
954*4882a593Smuzhiyun 	{ 0x0112, 0x0a },
955*4882a593Smuzhiyun 	{ 0x0113, 0x0a },
956*4882a593Smuzhiyun 	{ 0x0114, 0x03 },
957*4882a593Smuzhiyun 	{ 0x0342, 0x08 },
958*4882a593Smuzhiyun 	{ 0x0343, 0x20 },
959*4882a593Smuzhiyun 	{ 0x0340, 0x18 },
960*4882a593Smuzhiyun 	{ 0x0341, 0x2a },
961*4882a593Smuzhiyun 	{ 0x0344, 0x00 },
962*4882a593Smuzhiyun 	{ 0x0345, 0x00 },
963*4882a593Smuzhiyun 	{ 0x0346, 0x00 },
964*4882a593Smuzhiyun 	{ 0x0347, 0x00 },
965*4882a593Smuzhiyun 	{ 0x0348, 0x0c },
966*4882a593Smuzhiyun 	{ 0x0349, 0xcf },
967*4882a593Smuzhiyun 	{ 0x034a, 0x09 },
968*4882a593Smuzhiyun 	{ 0x034b, 0x9f },
969*4882a593Smuzhiyun 	{ 0x0220, 0x00 },
970*4882a593Smuzhiyun 	{ 0x0221, 0x11 },
971*4882a593Smuzhiyun 	{ 0x0381, 0x01 },
972*4882a593Smuzhiyun 	{ 0x0383, 0x01 },
973*4882a593Smuzhiyun 	{ 0x0385, 0x01 },
974*4882a593Smuzhiyun 	{ 0x0387, 0x01 },
975*4882a593Smuzhiyun 	{ 0x0900, 0x01 },
976*4882a593Smuzhiyun 	{ 0x0901, 0x22 },
977*4882a593Smuzhiyun 	{ 0x0902, 0x0a },
978*4882a593Smuzhiyun 	{ 0x3140, 0x02 },
979*4882a593Smuzhiyun 	{ 0x3141, 0x00 },
980*4882a593Smuzhiyun 	{ 0x3f0d, 0x0a },
981*4882a593Smuzhiyun 	{ 0x3f14, 0x01 },
982*4882a593Smuzhiyun 	{ 0x3f3c, 0x02 },
983*4882a593Smuzhiyun 	{ 0x3f4d, 0x01 },
984*4882a593Smuzhiyun 	{ 0x3f4c, 0x01 },
985*4882a593Smuzhiyun 	{ 0x4254, 0x7f },
986*4882a593Smuzhiyun 	{ 0x0401, 0x00 },
987*4882a593Smuzhiyun 	{ 0x0404, 0x00 },
988*4882a593Smuzhiyun 	{ 0x0405, 0x10 },
989*4882a593Smuzhiyun 	{ 0x0408, 0x00 },
990*4882a593Smuzhiyun 	{ 0x0409, 0x00 },
991*4882a593Smuzhiyun 	{ 0x040a, 0x00 },
992*4882a593Smuzhiyun 	{ 0x040b, 0x00 },
993*4882a593Smuzhiyun 	{ 0x040c, 0x06 },
994*4882a593Smuzhiyun 	{ 0x040d, 0x68 },
995*4882a593Smuzhiyun 	{ 0x040e, 0x04 },
996*4882a593Smuzhiyun 	{ 0x040f, 0xd0 },
997*4882a593Smuzhiyun 	{ 0x034c, 0x06 },
998*4882a593Smuzhiyun 	{ 0x034d, 0x68 },
999*4882a593Smuzhiyun 	{ 0x034e, 0x04 },
1000*4882a593Smuzhiyun 	{ 0x034f, 0xd0 },
1001*4882a593Smuzhiyun 	{ 0x3261, 0x00 },
1002*4882a593Smuzhiyun 	{ 0x3264, 0x00 },
1003*4882a593Smuzhiyun 	{ 0x3265, 0x10 },
1004*4882a593Smuzhiyun 	{ 0x0301, 0x05 },
1005*4882a593Smuzhiyun 	{ 0x0303, 0x04 },
1006*4882a593Smuzhiyun 	{ 0x0305, 0x04 },
1007*4882a593Smuzhiyun 	{ 0x0306, 0x01 },
1008*4882a593Smuzhiyun 	{ 0x0307, 0x92 },
1009*4882a593Smuzhiyun 	{ 0x0309, 0x0a },
1010*4882a593Smuzhiyun 	{ 0x030b, 0x02 },
1011*4882a593Smuzhiyun 	{ 0x030d, 0x02 },
1012*4882a593Smuzhiyun 	{ 0x030e, 0x00 },
1013*4882a593Smuzhiyun 	{ 0x030f, 0xfa },
1014*4882a593Smuzhiyun 	{ 0x0310, 0x00 },
1015*4882a593Smuzhiyun 	{ 0x0820, 0x0f },
1016*4882a593Smuzhiyun 	{ 0x0821, 0x13 },
1017*4882a593Smuzhiyun 	{ 0x0822, 0x33 },
1018*4882a593Smuzhiyun 	{ 0x0823, 0x33 },
1019*4882a593Smuzhiyun 	{ 0x3e20, 0x01 },
1020*4882a593Smuzhiyun 	{ 0x3e37, 0x00 },
1021*4882a593Smuzhiyun 	{ 0x3e3b, 0x01 },
1022*4882a593Smuzhiyun 	{ 0x38a3, 0x01 },
1023*4882a593Smuzhiyun 	{ 0x38a8, 0x00 },
1024*4882a593Smuzhiyun 	{ 0x38a9, 0x00 },
1025*4882a593Smuzhiyun 	{ 0x38aa, 0x00 },
1026*4882a593Smuzhiyun 	{ 0x38ab, 0x00 },
1027*4882a593Smuzhiyun 	{ 0x3234, 0x00 },
1028*4882a593Smuzhiyun 	{ 0x3fc1, 0x00 },
1029*4882a593Smuzhiyun 	{ 0x3235, 0x00 },
1030*4882a593Smuzhiyun 	{ 0x3802, 0x00 },
1031*4882a593Smuzhiyun 	{ 0x3143, 0x04 },
1032*4882a593Smuzhiyun 	{ 0x360a, 0x00 },
1033*4882a593Smuzhiyun 	{ 0x0b00, 0x00 },
1034*4882a593Smuzhiyun 	{ 0x0106, 0x00 },
1035*4882a593Smuzhiyun 	{ 0x0b05, 0x01 },
1036*4882a593Smuzhiyun 	{ 0x0b06, 0x01 },
1037*4882a593Smuzhiyun 	{ 0x3230, 0x00 },
1038*4882a593Smuzhiyun 	{ 0x3602, 0x01 },
1039*4882a593Smuzhiyun 	{ 0x3607, 0x01 },
1040*4882a593Smuzhiyun 	{ 0x3c00, 0x00 },
1041*4882a593Smuzhiyun 	{ 0x3c01, 0xba },
1042*4882a593Smuzhiyun 	{ 0x3c02, 0xc8 },
1043*4882a593Smuzhiyun 	{ 0x3c03, 0xaa },
1044*4882a593Smuzhiyun 	{ 0x3c04, 0x91 },
1045*4882a593Smuzhiyun 	{ 0x3c05, 0x54 },
1046*4882a593Smuzhiyun 	{ 0x3c06, 0x26 },
1047*4882a593Smuzhiyun 	{ 0x3c07, 0x20 },
1048*4882a593Smuzhiyun 	{ 0x3c08, 0x51 },
1049*4882a593Smuzhiyun 	{ 0x3d80, 0x00 },
1050*4882a593Smuzhiyun 	{ 0x3f50, 0x00 },
1051*4882a593Smuzhiyun 	{ 0x3f56, 0x00 },
1052*4882a593Smuzhiyun 	{ 0x3f57, 0x30 },
1053*4882a593Smuzhiyun 	{ 0x3f78, 0x00 },
1054*4882a593Smuzhiyun 	{ 0x3f79, 0x34 },
1055*4882a593Smuzhiyun 	{ 0x3f7c, 0x00 },
1056*4882a593Smuzhiyun 	{ 0x3f7d, 0x00 },
1057*4882a593Smuzhiyun 	{ 0x3fba, 0x00 },
1058*4882a593Smuzhiyun 	{ 0x3fbb, 0x00 },
1059*4882a593Smuzhiyun 	{ 0xa081, 0x04 },
1060*4882a593Smuzhiyun 	{ 0xe014, 0x00 },
1061*4882a593Smuzhiyun 	{ 0x0202, 0x04 },
1062*4882a593Smuzhiyun 	{ 0x0203, 0xf6 },
1063*4882a593Smuzhiyun 	{ 0x0224, 0x01 },
1064*4882a593Smuzhiyun 	{ 0x0225, 0xf4 },
1065*4882a593Smuzhiyun 	{ 0x0204, 0x00 },
1066*4882a593Smuzhiyun 	{ 0x0205, 0x00 },
1067*4882a593Smuzhiyun 	{ 0x0216, 0x00 },
1068*4882a593Smuzhiyun 	{ 0x0217, 0x00 },
1069*4882a593Smuzhiyun 	{ 0x020e, 0x01 },
1070*4882a593Smuzhiyun 	{ 0x020f, 0x00 },
1071*4882a593Smuzhiyun 	{ 0x0210, 0x01 },
1072*4882a593Smuzhiyun 	{ 0x0211, 0x00 },
1073*4882a593Smuzhiyun 	{ 0x0212, 0x01 },
1074*4882a593Smuzhiyun 	{ 0x0213, 0x00 },
1075*4882a593Smuzhiyun 	{ 0x0214, 0x01 },
1076*4882a593Smuzhiyun 	{ 0x0215, 0x00 },
1077*4882a593Smuzhiyun 	{ 0x0218, 0x01 },
1078*4882a593Smuzhiyun 	{ 0x0219, 0x00 },
1079*4882a593Smuzhiyun 	{ 0x3614, 0x00 },
1080*4882a593Smuzhiyun 	{ 0x3616, 0x0d },
1081*4882a593Smuzhiyun 	{ 0x3617, 0x56 },
1082*4882a593Smuzhiyun 	{ 0xb612, 0x20 },
1083*4882a593Smuzhiyun 	{ 0xb613, 0x20 },
1084*4882a593Smuzhiyun 	{ 0xb614, 0x20 },
1085*4882a593Smuzhiyun 	{ 0xb615, 0x20 },
1086*4882a593Smuzhiyun 	{ 0xb616, 0x0a },
1087*4882a593Smuzhiyun 	{ 0xb617, 0x0a },
1088*4882a593Smuzhiyun 	{ 0xb618, 0x20 },
1089*4882a593Smuzhiyun 	{ 0xb619, 0x20 },
1090*4882a593Smuzhiyun 	{ 0xb61a, 0x20 },
1091*4882a593Smuzhiyun 	{ 0xb61b, 0x20 },
1092*4882a593Smuzhiyun 	{ 0xb61c, 0x0a },
1093*4882a593Smuzhiyun 	{ 0xb61d, 0x0a },
1094*4882a593Smuzhiyun 	{ 0xb666, 0x30 },
1095*4882a593Smuzhiyun 	{ 0xb667, 0x30 },
1096*4882a593Smuzhiyun 	{ 0xb668, 0x30 },
1097*4882a593Smuzhiyun 	{ 0xb669, 0x30 },
1098*4882a593Smuzhiyun 	{ 0xb66a, 0x14 },
1099*4882a593Smuzhiyun 	{ 0xb66b, 0x14 },
1100*4882a593Smuzhiyun 	{ 0xb66c, 0x20 },
1101*4882a593Smuzhiyun 	{ 0xb66d, 0x20 },
1102*4882a593Smuzhiyun 	{ 0xb66e, 0x20 },
1103*4882a593Smuzhiyun 	{ 0xb66f, 0x20 },
1104*4882a593Smuzhiyun 	{ 0xb670, 0x10 },
1105*4882a593Smuzhiyun 	{ 0xb671, 0x10 },
1106*4882a593Smuzhiyun 	{ 0x3237, 0x00 },
1107*4882a593Smuzhiyun 	{ 0x3900, 0x00 },
1108*4882a593Smuzhiyun 	{ 0x3901, 0x00 },
1109*4882a593Smuzhiyun 	{ 0x3902, 0x00 },
1110*4882a593Smuzhiyun 	{ 0x3904, 0x00 },
1111*4882a593Smuzhiyun 	{ 0x3905, 0x00 },
1112*4882a593Smuzhiyun 	{ 0x3906, 0x00 },
1113*4882a593Smuzhiyun 	{ 0x3907, 0x00 },
1114*4882a593Smuzhiyun 	{ 0x3908, 0x00 },
1115*4882a593Smuzhiyun 	{ 0x3909, 0x00 },
1116*4882a593Smuzhiyun 	{ 0x3912, 0x00 },
1117*4882a593Smuzhiyun 	{ 0x3930, 0x00 },
1118*4882a593Smuzhiyun 	{ 0x3931, 0x00 },
1119*4882a593Smuzhiyun 	{ 0x3933, 0x00 },
1120*4882a593Smuzhiyun 	{ 0x3934, 0x00 },
1121*4882a593Smuzhiyun 	{ 0x3935, 0x00 },
1122*4882a593Smuzhiyun 	{ 0x3936, 0x00 },
1123*4882a593Smuzhiyun 	{ 0x3937, 0x00 },
1124*4882a593Smuzhiyun 	{ 0x30ac, 0x00 },
1125*4882a593Smuzhiyun };
1126*4882a593Smuzhiyun 
1127*4882a593Smuzhiyun static const struct imx319_reg mode_1640x922_regs[] = {
1128*4882a593Smuzhiyun 	{ 0x0112, 0x0a },
1129*4882a593Smuzhiyun 	{ 0x0113, 0x0a },
1130*4882a593Smuzhiyun 	{ 0x0114, 0x03 },
1131*4882a593Smuzhiyun 	{ 0x0342, 0x08 },
1132*4882a593Smuzhiyun 	{ 0x0343, 0x20 },
1133*4882a593Smuzhiyun 	{ 0x0340, 0x18 },
1134*4882a593Smuzhiyun 	{ 0x0341, 0x2a },
1135*4882a593Smuzhiyun 	{ 0x0344, 0x00 },
1136*4882a593Smuzhiyun 	{ 0x0345, 0x00 },
1137*4882a593Smuzhiyun 	{ 0x0346, 0x01 },
1138*4882a593Smuzhiyun 	{ 0x0347, 0x30 },
1139*4882a593Smuzhiyun 	{ 0x0348, 0x0c },
1140*4882a593Smuzhiyun 	{ 0x0349, 0xcf },
1141*4882a593Smuzhiyun 	{ 0x034a, 0x08 },
1142*4882a593Smuzhiyun 	{ 0x034b, 0x6f },
1143*4882a593Smuzhiyun 	{ 0x0220, 0x00 },
1144*4882a593Smuzhiyun 	{ 0x0221, 0x11 },
1145*4882a593Smuzhiyun 	{ 0x0381, 0x01 },
1146*4882a593Smuzhiyun 	{ 0x0383, 0x01 },
1147*4882a593Smuzhiyun 	{ 0x0385, 0x01 },
1148*4882a593Smuzhiyun 	{ 0x0387, 0x01 },
1149*4882a593Smuzhiyun 	{ 0x0900, 0x01 },
1150*4882a593Smuzhiyun 	{ 0x0901, 0x22 },
1151*4882a593Smuzhiyun 	{ 0x0902, 0x0a },
1152*4882a593Smuzhiyun 	{ 0x3140, 0x02 },
1153*4882a593Smuzhiyun 	{ 0x3141, 0x00 },
1154*4882a593Smuzhiyun 	{ 0x3f0d, 0x0a },
1155*4882a593Smuzhiyun 	{ 0x3f14, 0x01 },
1156*4882a593Smuzhiyun 	{ 0x3f3c, 0x02 },
1157*4882a593Smuzhiyun 	{ 0x3f4d, 0x01 },
1158*4882a593Smuzhiyun 	{ 0x3f4c, 0x01 },
1159*4882a593Smuzhiyun 	{ 0x4254, 0x7f },
1160*4882a593Smuzhiyun 	{ 0x0401, 0x00 },
1161*4882a593Smuzhiyun 	{ 0x0404, 0x00 },
1162*4882a593Smuzhiyun 	{ 0x0405, 0x10 },
1163*4882a593Smuzhiyun 	{ 0x0408, 0x00 },
1164*4882a593Smuzhiyun 	{ 0x0409, 0x00 },
1165*4882a593Smuzhiyun 	{ 0x040a, 0x00 },
1166*4882a593Smuzhiyun 	{ 0x040b, 0x02 },
1167*4882a593Smuzhiyun 	{ 0x040c, 0x06 },
1168*4882a593Smuzhiyun 	{ 0x040d, 0x68 },
1169*4882a593Smuzhiyun 	{ 0x040e, 0x03 },
1170*4882a593Smuzhiyun 	{ 0x040f, 0x9a },
1171*4882a593Smuzhiyun 	{ 0x034c, 0x06 },
1172*4882a593Smuzhiyun 	{ 0x034d, 0x68 },
1173*4882a593Smuzhiyun 	{ 0x034e, 0x03 },
1174*4882a593Smuzhiyun 	{ 0x034f, 0x9a },
1175*4882a593Smuzhiyun 	{ 0x3261, 0x00 },
1176*4882a593Smuzhiyun 	{ 0x3264, 0x00 },
1177*4882a593Smuzhiyun 	{ 0x3265, 0x10 },
1178*4882a593Smuzhiyun 	{ 0x0301, 0x05 },
1179*4882a593Smuzhiyun 	{ 0x0303, 0x04 },
1180*4882a593Smuzhiyun 	{ 0x0305, 0x04 },
1181*4882a593Smuzhiyun 	{ 0x0306, 0x01 },
1182*4882a593Smuzhiyun 	{ 0x0307, 0x92 },
1183*4882a593Smuzhiyun 	{ 0x0309, 0x0a },
1184*4882a593Smuzhiyun 	{ 0x030b, 0x02 },
1185*4882a593Smuzhiyun 	{ 0x030d, 0x02 },
1186*4882a593Smuzhiyun 	{ 0x030e, 0x00 },
1187*4882a593Smuzhiyun 	{ 0x030f, 0xfa },
1188*4882a593Smuzhiyun 	{ 0x0310, 0x00 },
1189*4882a593Smuzhiyun 	{ 0x0820, 0x0f },
1190*4882a593Smuzhiyun 	{ 0x0821, 0x13 },
1191*4882a593Smuzhiyun 	{ 0x0822, 0x33 },
1192*4882a593Smuzhiyun 	{ 0x0823, 0x33 },
1193*4882a593Smuzhiyun 	{ 0x3e20, 0x01 },
1194*4882a593Smuzhiyun 	{ 0x3e37, 0x00 },
1195*4882a593Smuzhiyun 	{ 0x3e3b, 0x01 },
1196*4882a593Smuzhiyun 	{ 0x38a3, 0x01 },
1197*4882a593Smuzhiyun 	{ 0x38a8, 0x00 },
1198*4882a593Smuzhiyun 	{ 0x38a9, 0x00 },
1199*4882a593Smuzhiyun 	{ 0x38aa, 0x00 },
1200*4882a593Smuzhiyun 	{ 0x38ab, 0x00 },
1201*4882a593Smuzhiyun 	{ 0x3234, 0x00 },
1202*4882a593Smuzhiyun 	{ 0x3fc1, 0x00 },
1203*4882a593Smuzhiyun 	{ 0x3235, 0x00 },
1204*4882a593Smuzhiyun 	{ 0x3802, 0x00 },
1205*4882a593Smuzhiyun 	{ 0x3143, 0x04 },
1206*4882a593Smuzhiyun 	{ 0x360a, 0x00 },
1207*4882a593Smuzhiyun 	{ 0x0b00, 0x00 },
1208*4882a593Smuzhiyun 	{ 0x0106, 0x00 },
1209*4882a593Smuzhiyun 	{ 0x0b05, 0x01 },
1210*4882a593Smuzhiyun 	{ 0x0b06, 0x01 },
1211*4882a593Smuzhiyun 	{ 0x3230, 0x00 },
1212*4882a593Smuzhiyun 	{ 0x3602, 0x01 },
1213*4882a593Smuzhiyun 	{ 0x3607, 0x01 },
1214*4882a593Smuzhiyun 	{ 0x3c00, 0x00 },
1215*4882a593Smuzhiyun 	{ 0x3c01, 0xba },
1216*4882a593Smuzhiyun 	{ 0x3c02, 0xc8 },
1217*4882a593Smuzhiyun 	{ 0x3c03, 0xaa },
1218*4882a593Smuzhiyun 	{ 0x3c04, 0x91 },
1219*4882a593Smuzhiyun 	{ 0x3c05, 0x54 },
1220*4882a593Smuzhiyun 	{ 0x3c06, 0x26 },
1221*4882a593Smuzhiyun 	{ 0x3c07, 0x20 },
1222*4882a593Smuzhiyun 	{ 0x3c08, 0x51 },
1223*4882a593Smuzhiyun 	{ 0x3d80, 0x00 },
1224*4882a593Smuzhiyun 	{ 0x3f50, 0x00 },
1225*4882a593Smuzhiyun 	{ 0x3f56, 0x00 },
1226*4882a593Smuzhiyun 	{ 0x3f57, 0x30 },
1227*4882a593Smuzhiyun 	{ 0x3f78, 0x00 },
1228*4882a593Smuzhiyun 	{ 0x3f79, 0x34 },
1229*4882a593Smuzhiyun 	{ 0x3f7c, 0x00 },
1230*4882a593Smuzhiyun 	{ 0x3f7d, 0x00 },
1231*4882a593Smuzhiyun 	{ 0x3fba, 0x00 },
1232*4882a593Smuzhiyun 	{ 0x3fbb, 0x00 },
1233*4882a593Smuzhiyun 	{ 0xa081, 0x04 },
1234*4882a593Smuzhiyun 	{ 0xe014, 0x00 },
1235*4882a593Smuzhiyun 	{ 0x0202, 0x04 },
1236*4882a593Smuzhiyun 	{ 0x0203, 0xf6 },
1237*4882a593Smuzhiyun 	{ 0x0224, 0x01 },
1238*4882a593Smuzhiyun 	{ 0x0225, 0xf4 },
1239*4882a593Smuzhiyun 	{ 0x0204, 0x00 },
1240*4882a593Smuzhiyun 	{ 0x0205, 0x00 },
1241*4882a593Smuzhiyun 	{ 0x0216, 0x00 },
1242*4882a593Smuzhiyun 	{ 0x0217, 0x00 },
1243*4882a593Smuzhiyun 	{ 0x020e, 0x01 },
1244*4882a593Smuzhiyun 	{ 0x020f, 0x00 },
1245*4882a593Smuzhiyun 	{ 0x0210, 0x01 },
1246*4882a593Smuzhiyun 	{ 0x0211, 0x00 },
1247*4882a593Smuzhiyun 	{ 0x0212, 0x01 },
1248*4882a593Smuzhiyun 	{ 0x0213, 0x00 },
1249*4882a593Smuzhiyun 	{ 0x0214, 0x01 },
1250*4882a593Smuzhiyun 	{ 0x0215, 0x00 },
1251*4882a593Smuzhiyun 	{ 0x0218, 0x01 },
1252*4882a593Smuzhiyun 	{ 0x0219, 0x00 },
1253*4882a593Smuzhiyun 	{ 0x3614, 0x00 },
1254*4882a593Smuzhiyun 	{ 0x3616, 0x0d },
1255*4882a593Smuzhiyun 	{ 0x3617, 0x56 },
1256*4882a593Smuzhiyun 	{ 0xb612, 0x20 },
1257*4882a593Smuzhiyun 	{ 0xb613, 0x20 },
1258*4882a593Smuzhiyun 	{ 0xb614, 0x20 },
1259*4882a593Smuzhiyun 	{ 0xb615, 0x20 },
1260*4882a593Smuzhiyun 	{ 0xb616, 0x0a },
1261*4882a593Smuzhiyun 	{ 0xb617, 0x0a },
1262*4882a593Smuzhiyun 	{ 0xb618, 0x20 },
1263*4882a593Smuzhiyun 	{ 0xb619, 0x20 },
1264*4882a593Smuzhiyun 	{ 0xb61a, 0x20 },
1265*4882a593Smuzhiyun 	{ 0xb61b, 0x20 },
1266*4882a593Smuzhiyun 	{ 0xb61c, 0x0a },
1267*4882a593Smuzhiyun 	{ 0xb61d, 0x0a },
1268*4882a593Smuzhiyun 	{ 0xb666, 0x30 },
1269*4882a593Smuzhiyun 	{ 0xb667, 0x30 },
1270*4882a593Smuzhiyun 	{ 0xb668, 0x30 },
1271*4882a593Smuzhiyun 	{ 0xb669, 0x30 },
1272*4882a593Smuzhiyun 	{ 0xb66a, 0x14 },
1273*4882a593Smuzhiyun 	{ 0xb66b, 0x14 },
1274*4882a593Smuzhiyun 	{ 0xb66c, 0x20 },
1275*4882a593Smuzhiyun 	{ 0xb66d, 0x20 },
1276*4882a593Smuzhiyun 	{ 0xb66e, 0x20 },
1277*4882a593Smuzhiyun 	{ 0xb66f, 0x20 },
1278*4882a593Smuzhiyun 	{ 0xb670, 0x10 },
1279*4882a593Smuzhiyun 	{ 0xb671, 0x10 },
1280*4882a593Smuzhiyun 	{ 0x3237, 0x00 },
1281*4882a593Smuzhiyun 	{ 0x3900, 0x00 },
1282*4882a593Smuzhiyun 	{ 0x3901, 0x00 },
1283*4882a593Smuzhiyun 	{ 0x3902, 0x00 },
1284*4882a593Smuzhiyun 	{ 0x3904, 0x00 },
1285*4882a593Smuzhiyun 	{ 0x3905, 0x00 },
1286*4882a593Smuzhiyun 	{ 0x3906, 0x00 },
1287*4882a593Smuzhiyun 	{ 0x3907, 0x00 },
1288*4882a593Smuzhiyun 	{ 0x3908, 0x00 },
1289*4882a593Smuzhiyun 	{ 0x3909, 0x00 },
1290*4882a593Smuzhiyun 	{ 0x3912, 0x00 },
1291*4882a593Smuzhiyun 	{ 0x3930, 0x00 },
1292*4882a593Smuzhiyun 	{ 0x3931, 0x00 },
1293*4882a593Smuzhiyun 	{ 0x3933, 0x00 },
1294*4882a593Smuzhiyun 	{ 0x3934, 0x00 },
1295*4882a593Smuzhiyun 	{ 0x3935, 0x00 },
1296*4882a593Smuzhiyun 	{ 0x3936, 0x00 },
1297*4882a593Smuzhiyun 	{ 0x3937, 0x00 },
1298*4882a593Smuzhiyun 	{ 0x30ac, 0x00 },
1299*4882a593Smuzhiyun };
1300*4882a593Smuzhiyun 
1301*4882a593Smuzhiyun static const struct imx319_reg mode_1296x736_regs[] = {
1302*4882a593Smuzhiyun 	{ 0x0112, 0x0a },
1303*4882a593Smuzhiyun 	{ 0x0113, 0x0a },
1304*4882a593Smuzhiyun 	{ 0x0114, 0x03 },
1305*4882a593Smuzhiyun 	{ 0x0342, 0x08 },
1306*4882a593Smuzhiyun 	{ 0x0343, 0x20 },
1307*4882a593Smuzhiyun 	{ 0x0340, 0x18 },
1308*4882a593Smuzhiyun 	{ 0x0341, 0x2a },
1309*4882a593Smuzhiyun 	{ 0x0344, 0x00 },
1310*4882a593Smuzhiyun 	{ 0x0345, 0x00 },
1311*4882a593Smuzhiyun 	{ 0x0346, 0x01 },
1312*4882a593Smuzhiyun 	{ 0x0347, 0xf0 },
1313*4882a593Smuzhiyun 	{ 0x0348, 0x0c },
1314*4882a593Smuzhiyun 	{ 0x0349, 0xcf },
1315*4882a593Smuzhiyun 	{ 0x034a, 0x07 },
1316*4882a593Smuzhiyun 	{ 0x034b, 0xaf },
1317*4882a593Smuzhiyun 	{ 0x0220, 0x00 },
1318*4882a593Smuzhiyun 	{ 0x0221, 0x11 },
1319*4882a593Smuzhiyun 	{ 0x0381, 0x01 },
1320*4882a593Smuzhiyun 	{ 0x0383, 0x01 },
1321*4882a593Smuzhiyun 	{ 0x0385, 0x01 },
1322*4882a593Smuzhiyun 	{ 0x0387, 0x01 },
1323*4882a593Smuzhiyun 	{ 0x0900, 0x01 },
1324*4882a593Smuzhiyun 	{ 0x0901, 0x22 },
1325*4882a593Smuzhiyun 	{ 0x0902, 0x0a },
1326*4882a593Smuzhiyun 	{ 0x3140, 0x02 },
1327*4882a593Smuzhiyun 	{ 0x3141, 0x00 },
1328*4882a593Smuzhiyun 	{ 0x3f0d, 0x0a },
1329*4882a593Smuzhiyun 	{ 0x3f14, 0x01 },
1330*4882a593Smuzhiyun 	{ 0x3f3c, 0x02 },
1331*4882a593Smuzhiyun 	{ 0x3f4d, 0x01 },
1332*4882a593Smuzhiyun 	{ 0x3f4c, 0x01 },
1333*4882a593Smuzhiyun 	{ 0x4254, 0x7f },
1334*4882a593Smuzhiyun 	{ 0x0401, 0x00 },
1335*4882a593Smuzhiyun 	{ 0x0404, 0x00 },
1336*4882a593Smuzhiyun 	{ 0x0405, 0x10 },
1337*4882a593Smuzhiyun 	{ 0x0408, 0x00 },
1338*4882a593Smuzhiyun 	{ 0x0409, 0xac },
1339*4882a593Smuzhiyun 	{ 0x040a, 0x00 },
1340*4882a593Smuzhiyun 	{ 0x040b, 0x00 },
1341*4882a593Smuzhiyun 	{ 0x040c, 0x05 },
1342*4882a593Smuzhiyun 	{ 0x040d, 0x10 },
1343*4882a593Smuzhiyun 	{ 0x040e, 0x02 },
1344*4882a593Smuzhiyun 	{ 0x040f, 0xe0 },
1345*4882a593Smuzhiyun 	{ 0x034c, 0x05 },
1346*4882a593Smuzhiyun 	{ 0x034d, 0x10 },
1347*4882a593Smuzhiyun 	{ 0x034e, 0x02 },
1348*4882a593Smuzhiyun 	{ 0x034f, 0xe0 },
1349*4882a593Smuzhiyun 	{ 0x3261, 0x00 },
1350*4882a593Smuzhiyun 	{ 0x3264, 0x00 },
1351*4882a593Smuzhiyun 	{ 0x3265, 0x10 },
1352*4882a593Smuzhiyun 	{ 0x0301, 0x05 },
1353*4882a593Smuzhiyun 	{ 0x0303, 0x04 },
1354*4882a593Smuzhiyun 	{ 0x0305, 0x04 },
1355*4882a593Smuzhiyun 	{ 0x0306, 0x01 },
1356*4882a593Smuzhiyun 	{ 0x0307, 0x92 },
1357*4882a593Smuzhiyun 	{ 0x0309, 0x0a },
1358*4882a593Smuzhiyun 	{ 0x030b, 0x02 },
1359*4882a593Smuzhiyun 	{ 0x030d, 0x02 },
1360*4882a593Smuzhiyun 	{ 0x030e, 0x00 },
1361*4882a593Smuzhiyun 	{ 0x030f, 0xfa },
1362*4882a593Smuzhiyun 	{ 0x0310, 0x00 },
1363*4882a593Smuzhiyun 	{ 0x0820, 0x0f },
1364*4882a593Smuzhiyun 	{ 0x0821, 0x13 },
1365*4882a593Smuzhiyun 	{ 0x0822, 0x33 },
1366*4882a593Smuzhiyun 	{ 0x0823, 0x33 },
1367*4882a593Smuzhiyun 	{ 0x3e20, 0x01 },
1368*4882a593Smuzhiyun 	{ 0x3e37, 0x00 },
1369*4882a593Smuzhiyun 	{ 0x3e3b, 0x01 },
1370*4882a593Smuzhiyun 	{ 0x38a3, 0x01 },
1371*4882a593Smuzhiyun 	{ 0x38a8, 0x00 },
1372*4882a593Smuzhiyun 	{ 0x38a9, 0x00 },
1373*4882a593Smuzhiyun 	{ 0x38aa, 0x00 },
1374*4882a593Smuzhiyun 	{ 0x38ab, 0x00 },
1375*4882a593Smuzhiyun 	{ 0x3234, 0x00 },
1376*4882a593Smuzhiyun 	{ 0x3fc1, 0x00 },
1377*4882a593Smuzhiyun 	{ 0x3235, 0x00 },
1378*4882a593Smuzhiyun 	{ 0x3802, 0x00 },
1379*4882a593Smuzhiyun 	{ 0x3143, 0x04 },
1380*4882a593Smuzhiyun 	{ 0x360a, 0x00 },
1381*4882a593Smuzhiyun 	{ 0x0b00, 0x00 },
1382*4882a593Smuzhiyun 	{ 0x0106, 0x00 },
1383*4882a593Smuzhiyun 	{ 0x0b05, 0x01 },
1384*4882a593Smuzhiyun 	{ 0x0b06, 0x01 },
1385*4882a593Smuzhiyun 	{ 0x3230, 0x00 },
1386*4882a593Smuzhiyun 	{ 0x3602, 0x01 },
1387*4882a593Smuzhiyun 	{ 0x3607, 0x01 },
1388*4882a593Smuzhiyun 	{ 0x3c00, 0x00 },
1389*4882a593Smuzhiyun 	{ 0x3c01, 0xba },
1390*4882a593Smuzhiyun 	{ 0x3c02, 0xc8 },
1391*4882a593Smuzhiyun 	{ 0x3c03, 0xaa },
1392*4882a593Smuzhiyun 	{ 0x3c04, 0x91 },
1393*4882a593Smuzhiyun 	{ 0x3c05, 0x54 },
1394*4882a593Smuzhiyun 	{ 0x3c06, 0x26 },
1395*4882a593Smuzhiyun 	{ 0x3c07, 0x20 },
1396*4882a593Smuzhiyun 	{ 0x3c08, 0x51 },
1397*4882a593Smuzhiyun 	{ 0x3d80, 0x00 },
1398*4882a593Smuzhiyun 	{ 0x3f50, 0x00 },
1399*4882a593Smuzhiyun 	{ 0x3f56, 0x00 },
1400*4882a593Smuzhiyun 	{ 0x3f57, 0x30 },
1401*4882a593Smuzhiyun 	{ 0x3f78, 0x00 },
1402*4882a593Smuzhiyun 	{ 0x3f79, 0x34 },
1403*4882a593Smuzhiyun 	{ 0x3f7c, 0x00 },
1404*4882a593Smuzhiyun 	{ 0x3f7d, 0x00 },
1405*4882a593Smuzhiyun 	{ 0x3fba, 0x00 },
1406*4882a593Smuzhiyun 	{ 0x3fbb, 0x00 },
1407*4882a593Smuzhiyun 	{ 0xa081, 0x04 },
1408*4882a593Smuzhiyun 	{ 0xe014, 0x00 },
1409*4882a593Smuzhiyun 	{ 0x0202, 0x04 },
1410*4882a593Smuzhiyun 	{ 0x0203, 0xf6 },
1411*4882a593Smuzhiyun 	{ 0x0224, 0x01 },
1412*4882a593Smuzhiyun 	{ 0x0225, 0xf4 },
1413*4882a593Smuzhiyun 	{ 0x0204, 0x00 },
1414*4882a593Smuzhiyun 	{ 0x0205, 0x00 },
1415*4882a593Smuzhiyun 	{ 0x0216, 0x00 },
1416*4882a593Smuzhiyun 	{ 0x0217, 0x00 },
1417*4882a593Smuzhiyun 	{ 0x020e, 0x01 },
1418*4882a593Smuzhiyun 	{ 0x020f, 0x00 },
1419*4882a593Smuzhiyun 	{ 0x0210, 0x01 },
1420*4882a593Smuzhiyun 	{ 0x0211, 0x00 },
1421*4882a593Smuzhiyun 	{ 0x0212, 0x01 },
1422*4882a593Smuzhiyun 	{ 0x0213, 0x00 },
1423*4882a593Smuzhiyun 	{ 0x0214, 0x01 },
1424*4882a593Smuzhiyun 	{ 0x0215, 0x00 },
1425*4882a593Smuzhiyun 	{ 0x0218, 0x01 },
1426*4882a593Smuzhiyun 	{ 0x0219, 0x00 },
1427*4882a593Smuzhiyun 	{ 0x3614, 0x00 },
1428*4882a593Smuzhiyun 	{ 0x3616, 0x0d },
1429*4882a593Smuzhiyun 	{ 0x3617, 0x56 },
1430*4882a593Smuzhiyun 	{ 0xb612, 0x20 },
1431*4882a593Smuzhiyun 	{ 0xb613, 0x20 },
1432*4882a593Smuzhiyun 	{ 0xb614, 0x20 },
1433*4882a593Smuzhiyun 	{ 0xb615, 0x20 },
1434*4882a593Smuzhiyun 	{ 0xb616, 0x0a },
1435*4882a593Smuzhiyun 	{ 0xb617, 0x0a },
1436*4882a593Smuzhiyun 	{ 0xb618, 0x20 },
1437*4882a593Smuzhiyun 	{ 0xb619, 0x20 },
1438*4882a593Smuzhiyun 	{ 0xb61a, 0x20 },
1439*4882a593Smuzhiyun 	{ 0xb61b, 0x20 },
1440*4882a593Smuzhiyun 	{ 0xb61c, 0x0a },
1441*4882a593Smuzhiyun 	{ 0xb61d, 0x0a },
1442*4882a593Smuzhiyun 	{ 0xb666, 0x30 },
1443*4882a593Smuzhiyun 	{ 0xb667, 0x30 },
1444*4882a593Smuzhiyun 	{ 0xb668, 0x30 },
1445*4882a593Smuzhiyun 	{ 0xb669, 0x30 },
1446*4882a593Smuzhiyun 	{ 0xb66a, 0x14 },
1447*4882a593Smuzhiyun 	{ 0xb66b, 0x14 },
1448*4882a593Smuzhiyun 	{ 0xb66c, 0x20 },
1449*4882a593Smuzhiyun 	{ 0xb66d, 0x20 },
1450*4882a593Smuzhiyun 	{ 0xb66e, 0x20 },
1451*4882a593Smuzhiyun 	{ 0xb66f, 0x20 },
1452*4882a593Smuzhiyun 	{ 0xb670, 0x10 },
1453*4882a593Smuzhiyun 	{ 0xb671, 0x10 },
1454*4882a593Smuzhiyun 	{ 0x3237, 0x00 },
1455*4882a593Smuzhiyun 	{ 0x3900, 0x00 },
1456*4882a593Smuzhiyun 	{ 0x3901, 0x00 },
1457*4882a593Smuzhiyun 	{ 0x3902, 0x00 },
1458*4882a593Smuzhiyun 	{ 0x3904, 0x00 },
1459*4882a593Smuzhiyun 	{ 0x3905, 0x00 },
1460*4882a593Smuzhiyun 	{ 0x3906, 0x00 },
1461*4882a593Smuzhiyun 	{ 0x3907, 0x00 },
1462*4882a593Smuzhiyun 	{ 0x3908, 0x00 },
1463*4882a593Smuzhiyun 	{ 0x3909, 0x00 },
1464*4882a593Smuzhiyun 	{ 0x3912, 0x00 },
1465*4882a593Smuzhiyun 	{ 0x3930, 0x00 },
1466*4882a593Smuzhiyun 	{ 0x3931, 0x00 },
1467*4882a593Smuzhiyun 	{ 0x3933, 0x00 },
1468*4882a593Smuzhiyun 	{ 0x3934, 0x00 },
1469*4882a593Smuzhiyun 	{ 0x3935, 0x00 },
1470*4882a593Smuzhiyun 	{ 0x3936, 0x00 },
1471*4882a593Smuzhiyun 	{ 0x3937, 0x00 },
1472*4882a593Smuzhiyun 	{ 0x30ac, 0x00 },
1473*4882a593Smuzhiyun };
1474*4882a593Smuzhiyun 
1475*4882a593Smuzhiyun static const struct imx319_reg mode_1280x720_regs[] = {
1476*4882a593Smuzhiyun 	{ 0x0112, 0x0a },
1477*4882a593Smuzhiyun 	{ 0x0113, 0x0a },
1478*4882a593Smuzhiyun 	{ 0x0114, 0x03 },
1479*4882a593Smuzhiyun 	{ 0x0342, 0x08 },
1480*4882a593Smuzhiyun 	{ 0x0343, 0x20 },
1481*4882a593Smuzhiyun 	{ 0x0340, 0x18 },
1482*4882a593Smuzhiyun 	{ 0x0341, 0x2a },
1483*4882a593Smuzhiyun 	{ 0x0344, 0x00 },
1484*4882a593Smuzhiyun 	{ 0x0345, 0x00 },
1485*4882a593Smuzhiyun 	{ 0x0346, 0x02 },
1486*4882a593Smuzhiyun 	{ 0x0347, 0x00 },
1487*4882a593Smuzhiyun 	{ 0x0348, 0x0c },
1488*4882a593Smuzhiyun 	{ 0x0349, 0xcf },
1489*4882a593Smuzhiyun 	{ 0x034a, 0x07 },
1490*4882a593Smuzhiyun 	{ 0x034b, 0x9f },
1491*4882a593Smuzhiyun 	{ 0x0220, 0x00 },
1492*4882a593Smuzhiyun 	{ 0x0221, 0x11 },
1493*4882a593Smuzhiyun 	{ 0x0381, 0x01 },
1494*4882a593Smuzhiyun 	{ 0x0383, 0x01 },
1495*4882a593Smuzhiyun 	{ 0x0385, 0x01 },
1496*4882a593Smuzhiyun 	{ 0x0387, 0x01 },
1497*4882a593Smuzhiyun 	{ 0x0900, 0x01 },
1498*4882a593Smuzhiyun 	{ 0x0901, 0x22 },
1499*4882a593Smuzhiyun 	{ 0x0902, 0x0a },
1500*4882a593Smuzhiyun 	{ 0x3140, 0x02 },
1501*4882a593Smuzhiyun 	{ 0x3141, 0x00 },
1502*4882a593Smuzhiyun 	{ 0x3f0d, 0x0a },
1503*4882a593Smuzhiyun 	{ 0x3f14, 0x01 },
1504*4882a593Smuzhiyun 	{ 0x3f3c, 0x02 },
1505*4882a593Smuzhiyun 	{ 0x3f4d, 0x01 },
1506*4882a593Smuzhiyun 	{ 0x3f4c, 0x01 },
1507*4882a593Smuzhiyun 	{ 0x4254, 0x7f },
1508*4882a593Smuzhiyun 	{ 0x0401, 0x00 },
1509*4882a593Smuzhiyun 	{ 0x0404, 0x00 },
1510*4882a593Smuzhiyun 	{ 0x0405, 0x10 },
1511*4882a593Smuzhiyun 	{ 0x0408, 0x00 },
1512*4882a593Smuzhiyun 	{ 0x0409, 0xb4 },
1513*4882a593Smuzhiyun 	{ 0x040a, 0x00 },
1514*4882a593Smuzhiyun 	{ 0x040b, 0x00 },
1515*4882a593Smuzhiyun 	{ 0x040c, 0x05 },
1516*4882a593Smuzhiyun 	{ 0x040d, 0x00 },
1517*4882a593Smuzhiyun 	{ 0x040e, 0x02 },
1518*4882a593Smuzhiyun 	{ 0x040f, 0xd0 },
1519*4882a593Smuzhiyun 	{ 0x034c, 0x05 },
1520*4882a593Smuzhiyun 	{ 0x034d, 0x00 },
1521*4882a593Smuzhiyun 	{ 0x034e, 0x02 },
1522*4882a593Smuzhiyun 	{ 0x034f, 0xd0 },
1523*4882a593Smuzhiyun 	{ 0x3261, 0x00 },
1524*4882a593Smuzhiyun 	{ 0x3264, 0x00 },
1525*4882a593Smuzhiyun 	{ 0x3265, 0x10 },
1526*4882a593Smuzhiyun 	{ 0x0301, 0x05 },
1527*4882a593Smuzhiyun 	{ 0x0303, 0x04 },
1528*4882a593Smuzhiyun 	{ 0x0305, 0x04 },
1529*4882a593Smuzhiyun 	{ 0x0306, 0x01 },
1530*4882a593Smuzhiyun 	{ 0x0307, 0x92 },
1531*4882a593Smuzhiyun 	{ 0x0309, 0x0a },
1532*4882a593Smuzhiyun 	{ 0x030b, 0x02 },
1533*4882a593Smuzhiyun 	{ 0x030d, 0x02 },
1534*4882a593Smuzhiyun 	{ 0x030e, 0x00 },
1535*4882a593Smuzhiyun 	{ 0x030f, 0xfa },
1536*4882a593Smuzhiyun 	{ 0x0310, 0x00 },
1537*4882a593Smuzhiyun 	{ 0x0820, 0x0f },
1538*4882a593Smuzhiyun 	{ 0x0821, 0x13 },
1539*4882a593Smuzhiyun 	{ 0x0822, 0x33 },
1540*4882a593Smuzhiyun 	{ 0x0823, 0x33 },
1541*4882a593Smuzhiyun 	{ 0x3e20, 0x01 },
1542*4882a593Smuzhiyun 	{ 0x3e37, 0x00 },
1543*4882a593Smuzhiyun 	{ 0x3e3b, 0x01 },
1544*4882a593Smuzhiyun 	{ 0x38a3, 0x01 },
1545*4882a593Smuzhiyun 	{ 0x38a8, 0x00 },
1546*4882a593Smuzhiyun 	{ 0x38a9, 0x00 },
1547*4882a593Smuzhiyun 	{ 0x38aa, 0x00 },
1548*4882a593Smuzhiyun 	{ 0x38ab, 0x00 },
1549*4882a593Smuzhiyun 	{ 0x3234, 0x00 },
1550*4882a593Smuzhiyun 	{ 0x3fc1, 0x00 },
1551*4882a593Smuzhiyun 	{ 0x3235, 0x00 },
1552*4882a593Smuzhiyun 	{ 0x3802, 0x00 },
1553*4882a593Smuzhiyun 	{ 0x3143, 0x04 },
1554*4882a593Smuzhiyun 	{ 0x360a, 0x00 },
1555*4882a593Smuzhiyun 	{ 0x0b00, 0x00 },
1556*4882a593Smuzhiyun 	{ 0x0106, 0x00 },
1557*4882a593Smuzhiyun 	{ 0x0b05, 0x01 },
1558*4882a593Smuzhiyun 	{ 0x0b06, 0x01 },
1559*4882a593Smuzhiyun 	{ 0x3230, 0x00 },
1560*4882a593Smuzhiyun 	{ 0x3602, 0x01 },
1561*4882a593Smuzhiyun 	{ 0x3607, 0x01 },
1562*4882a593Smuzhiyun 	{ 0x3c00, 0x00 },
1563*4882a593Smuzhiyun 	{ 0x3c01, 0xba },
1564*4882a593Smuzhiyun 	{ 0x3c02, 0xc8 },
1565*4882a593Smuzhiyun 	{ 0x3c03, 0xaa },
1566*4882a593Smuzhiyun 	{ 0x3c04, 0x91 },
1567*4882a593Smuzhiyun 	{ 0x3c05, 0x54 },
1568*4882a593Smuzhiyun 	{ 0x3c06, 0x26 },
1569*4882a593Smuzhiyun 	{ 0x3c07, 0x20 },
1570*4882a593Smuzhiyun 	{ 0x3c08, 0x51 },
1571*4882a593Smuzhiyun 	{ 0x3d80, 0x00 },
1572*4882a593Smuzhiyun 	{ 0x3f50, 0x00 },
1573*4882a593Smuzhiyun 	{ 0x3f56, 0x00 },
1574*4882a593Smuzhiyun 	{ 0x3f57, 0x30 },
1575*4882a593Smuzhiyun 	{ 0x3f78, 0x00 },
1576*4882a593Smuzhiyun 	{ 0x3f79, 0x34 },
1577*4882a593Smuzhiyun 	{ 0x3f7c, 0x00 },
1578*4882a593Smuzhiyun 	{ 0x3f7d, 0x00 },
1579*4882a593Smuzhiyun 	{ 0x3fba, 0x00 },
1580*4882a593Smuzhiyun 	{ 0x3fbb, 0x00 },
1581*4882a593Smuzhiyun 	{ 0xa081, 0x04 },
1582*4882a593Smuzhiyun 	{ 0xe014, 0x00 },
1583*4882a593Smuzhiyun 	{ 0x0202, 0x04 },
1584*4882a593Smuzhiyun 	{ 0x0203, 0xf6 },
1585*4882a593Smuzhiyun 	{ 0x0224, 0x01 },
1586*4882a593Smuzhiyun 	{ 0x0225, 0xf4 },
1587*4882a593Smuzhiyun 	{ 0x0204, 0x00 },
1588*4882a593Smuzhiyun 	{ 0x0205, 0x00 },
1589*4882a593Smuzhiyun 	{ 0x0216, 0x00 },
1590*4882a593Smuzhiyun 	{ 0x0217, 0x00 },
1591*4882a593Smuzhiyun 	{ 0x020e, 0x01 },
1592*4882a593Smuzhiyun 	{ 0x020f, 0x00 },
1593*4882a593Smuzhiyun 	{ 0x0210, 0x01 },
1594*4882a593Smuzhiyun 	{ 0x0211, 0x00 },
1595*4882a593Smuzhiyun 	{ 0x0212, 0x01 },
1596*4882a593Smuzhiyun 	{ 0x0213, 0x00 },
1597*4882a593Smuzhiyun 	{ 0x0214, 0x01 },
1598*4882a593Smuzhiyun 	{ 0x0215, 0x00 },
1599*4882a593Smuzhiyun 	{ 0x0218, 0x01 },
1600*4882a593Smuzhiyun 	{ 0x0219, 0x00 },
1601*4882a593Smuzhiyun 	{ 0x3614, 0x00 },
1602*4882a593Smuzhiyun 	{ 0x3616, 0x0d },
1603*4882a593Smuzhiyun 	{ 0x3617, 0x56 },
1604*4882a593Smuzhiyun 	{ 0xb612, 0x20 },
1605*4882a593Smuzhiyun 	{ 0xb613, 0x20 },
1606*4882a593Smuzhiyun 	{ 0xb614, 0x20 },
1607*4882a593Smuzhiyun 	{ 0xb615, 0x20 },
1608*4882a593Smuzhiyun 	{ 0xb616, 0x0a },
1609*4882a593Smuzhiyun 	{ 0xb617, 0x0a },
1610*4882a593Smuzhiyun 	{ 0xb618, 0x20 },
1611*4882a593Smuzhiyun 	{ 0xb619, 0x20 },
1612*4882a593Smuzhiyun 	{ 0xb61a, 0x20 },
1613*4882a593Smuzhiyun 	{ 0xb61b, 0x20 },
1614*4882a593Smuzhiyun 	{ 0xb61c, 0x0a },
1615*4882a593Smuzhiyun 	{ 0xb61d, 0x0a },
1616*4882a593Smuzhiyun 	{ 0xb666, 0x30 },
1617*4882a593Smuzhiyun 	{ 0xb667, 0x30 },
1618*4882a593Smuzhiyun 	{ 0xb668, 0x30 },
1619*4882a593Smuzhiyun 	{ 0xb669, 0x30 },
1620*4882a593Smuzhiyun 	{ 0xb66a, 0x14 },
1621*4882a593Smuzhiyun 	{ 0xb66b, 0x14 },
1622*4882a593Smuzhiyun 	{ 0xb66c, 0x20 },
1623*4882a593Smuzhiyun 	{ 0xb66d, 0x20 },
1624*4882a593Smuzhiyun 	{ 0xb66e, 0x20 },
1625*4882a593Smuzhiyun 	{ 0xb66f, 0x20 },
1626*4882a593Smuzhiyun 	{ 0xb670, 0x10 },
1627*4882a593Smuzhiyun 	{ 0xb671, 0x10 },
1628*4882a593Smuzhiyun 	{ 0x3237, 0x00 },
1629*4882a593Smuzhiyun 	{ 0x3900, 0x00 },
1630*4882a593Smuzhiyun 	{ 0x3901, 0x00 },
1631*4882a593Smuzhiyun 	{ 0x3902, 0x00 },
1632*4882a593Smuzhiyun 	{ 0x3904, 0x00 },
1633*4882a593Smuzhiyun 	{ 0x3905, 0x00 },
1634*4882a593Smuzhiyun 	{ 0x3906, 0x00 },
1635*4882a593Smuzhiyun 	{ 0x3907, 0x00 },
1636*4882a593Smuzhiyun 	{ 0x3908, 0x00 },
1637*4882a593Smuzhiyun 	{ 0x3909, 0x00 },
1638*4882a593Smuzhiyun 	{ 0x3912, 0x00 },
1639*4882a593Smuzhiyun 	{ 0x3930, 0x00 },
1640*4882a593Smuzhiyun 	{ 0x3931, 0x00 },
1641*4882a593Smuzhiyun 	{ 0x3933, 0x00 },
1642*4882a593Smuzhiyun 	{ 0x3934, 0x00 },
1643*4882a593Smuzhiyun 	{ 0x3935, 0x00 },
1644*4882a593Smuzhiyun 	{ 0x3936, 0x00 },
1645*4882a593Smuzhiyun 	{ 0x3937, 0x00 },
1646*4882a593Smuzhiyun 	{ 0x30ac, 0x00 },
1647*4882a593Smuzhiyun };
1648*4882a593Smuzhiyun 
1649*4882a593Smuzhiyun static const char * const imx319_test_pattern_menu[] = {
1650*4882a593Smuzhiyun 	"Disabled",
1651*4882a593Smuzhiyun 	"Solid Colour",
1652*4882a593Smuzhiyun 	"Eight Vertical Colour Bars",
1653*4882a593Smuzhiyun 	"Colour Bars With Fade to Grey",
1654*4882a593Smuzhiyun 	"Pseudorandom Sequence (PN9)",
1655*4882a593Smuzhiyun };
1656*4882a593Smuzhiyun 
1657*4882a593Smuzhiyun /* supported link frequencies */
1658*4882a593Smuzhiyun static const s64 link_freq_menu_items[] = {
1659*4882a593Smuzhiyun 	IMX319_LINK_FREQ_DEFAULT,
1660*4882a593Smuzhiyun };
1661*4882a593Smuzhiyun 
1662*4882a593Smuzhiyun /* Mode configs */
1663*4882a593Smuzhiyun static const struct imx319_mode supported_modes[] = {
1664*4882a593Smuzhiyun 	{
1665*4882a593Smuzhiyun 		.width = 3280,
1666*4882a593Smuzhiyun 		.height = 2464,
1667*4882a593Smuzhiyun 		.fll_def = 3242,
1668*4882a593Smuzhiyun 		.fll_min = 3242,
1669*4882a593Smuzhiyun 		.llp = 3968,
1670*4882a593Smuzhiyun 		.link_freq_index = IMX319_LINK_FREQ_INDEX,
1671*4882a593Smuzhiyun 		.reg_list = {
1672*4882a593Smuzhiyun 			.num_of_regs = ARRAY_SIZE(mode_3280x2464_regs),
1673*4882a593Smuzhiyun 			.regs = mode_3280x2464_regs,
1674*4882a593Smuzhiyun 		},
1675*4882a593Smuzhiyun 	},
1676*4882a593Smuzhiyun 	{
1677*4882a593Smuzhiyun 		.width = 3264,
1678*4882a593Smuzhiyun 		.height = 2448,
1679*4882a593Smuzhiyun 		.fll_def = 3242,
1680*4882a593Smuzhiyun 		.fll_min = 3242,
1681*4882a593Smuzhiyun 		.llp = 3968,
1682*4882a593Smuzhiyun 		.link_freq_index = IMX319_LINK_FREQ_INDEX,
1683*4882a593Smuzhiyun 		.reg_list = {
1684*4882a593Smuzhiyun 			.num_of_regs = ARRAY_SIZE(mode_3264x2448_regs),
1685*4882a593Smuzhiyun 			.regs = mode_3264x2448_regs,
1686*4882a593Smuzhiyun 		},
1687*4882a593Smuzhiyun 	},
1688*4882a593Smuzhiyun 	{
1689*4882a593Smuzhiyun 		.width = 1936,
1690*4882a593Smuzhiyun 		.height = 1096,
1691*4882a593Smuzhiyun 		.fll_def = 3242,
1692*4882a593Smuzhiyun 		.fll_min = 3242,
1693*4882a593Smuzhiyun 		.llp = 3968,
1694*4882a593Smuzhiyun 		.link_freq_index = IMX319_LINK_FREQ_INDEX,
1695*4882a593Smuzhiyun 		.reg_list = {
1696*4882a593Smuzhiyun 			.num_of_regs = ARRAY_SIZE(mode_1936x1096_regs),
1697*4882a593Smuzhiyun 			.regs = mode_1936x1096_regs,
1698*4882a593Smuzhiyun 		},
1699*4882a593Smuzhiyun 	},
1700*4882a593Smuzhiyun 	{
1701*4882a593Smuzhiyun 		.width = 1920,
1702*4882a593Smuzhiyun 		.height = 1080,
1703*4882a593Smuzhiyun 		.fll_def = 3242,
1704*4882a593Smuzhiyun 		.fll_min = 3242,
1705*4882a593Smuzhiyun 		.llp = 3968,
1706*4882a593Smuzhiyun 		.link_freq_index = IMX319_LINK_FREQ_INDEX,
1707*4882a593Smuzhiyun 		.reg_list = {
1708*4882a593Smuzhiyun 			.num_of_regs = ARRAY_SIZE(mode_1920x1080_regs),
1709*4882a593Smuzhiyun 			.regs = mode_1920x1080_regs,
1710*4882a593Smuzhiyun 		},
1711*4882a593Smuzhiyun 	},
1712*4882a593Smuzhiyun 	{
1713*4882a593Smuzhiyun 		.width = 1640,
1714*4882a593Smuzhiyun 		.height = 1232,
1715*4882a593Smuzhiyun 		.fll_def = 5146,
1716*4882a593Smuzhiyun 		.fll_min = 5146,
1717*4882a593Smuzhiyun 		.llp = 2500,
1718*4882a593Smuzhiyun 		.link_freq_index = IMX319_LINK_FREQ_INDEX,
1719*4882a593Smuzhiyun 		.reg_list = {
1720*4882a593Smuzhiyun 			.num_of_regs = ARRAY_SIZE(mode_1640x1232_regs),
1721*4882a593Smuzhiyun 			.regs = mode_1640x1232_regs,
1722*4882a593Smuzhiyun 		},
1723*4882a593Smuzhiyun 	},
1724*4882a593Smuzhiyun 	{
1725*4882a593Smuzhiyun 		.width = 1640,
1726*4882a593Smuzhiyun 		.height = 922,
1727*4882a593Smuzhiyun 		.fll_def = 5146,
1728*4882a593Smuzhiyun 		.fll_min = 5146,
1729*4882a593Smuzhiyun 		.llp = 2500,
1730*4882a593Smuzhiyun 		.link_freq_index = IMX319_LINK_FREQ_INDEX,
1731*4882a593Smuzhiyun 		.reg_list = {
1732*4882a593Smuzhiyun 			.num_of_regs = ARRAY_SIZE(mode_1640x922_regs),
1733*4882a593Smuzhiyun 			.regs = mode_1640x922_regs,
1734*4882a593Smuzhiyun 		},
1735*4882a593Smuzhiyun 	},
1736*4882a593Smuzhiyun 	{
1737*4882a593Smuzhiyun 		.width = 1296,
1738*4882a593Smuzhiyun 		.height = 736,
1739*4882a593Smuzhiyun 		.fll_def = 5146,
1740*4882a593Smuzhiyun 		.fll_min = 5146,
1741*4882a593Smuzhiyun 		.llp = 2500,
1742*4882a593Smuzhiyun 		.link_freq_index = IMX319_LINK_FREQ_INDEX,
1743*4882a593Smuzhiyun 		.reg_list = {
1744*4882a593Smuzhiyun 			.num_of_regs = ARRAY_SIZE(mode_1296x736_regs),
1745*4882a593Smuzhiyun 			.regs = mode_1296x736_regs,
1746*4882a593Smuzhiyun 		},
1747*4882a593Smuzhiyun 	},
1748*4882a593Smuzhiyun 	{
1749*4882a593Smuzhiyun 		.width = 1280,
1750*4882a593Smuzhiyun 		.height = 720,
1751*4882a593Smuzhiyun 		.fll_def = 5146,
1752*4882a593Smuzhiyun 		.fll_min = 5146,
1753*4882a593Smuzhiyun 		.llp = 2500,
1754*4882a593Smuzhiyun 		.link_freq_index = IMX319_LINK_FREQ_INDEX,
1755*4882a593Smuzhiyun 		.reg_list = {
1756*4882a593Smuzhiyun 			.num_of_regs = ARRAY_SIZE(mode_1280x720_regs),
1757*4882a593Smuzhiyun 			.regs = mode_1280x720_regs,
1758*4882a593Smuzhiyun 		},
1759*4882a593Smuzhiyun 	},
1760*4882a593Smuzhiyun };
1761*4882a593Smuzhiyun 
to_imx319(struct v4l2_subdev * _sd)1762*4882a593Smuzhiyun static inline struct imx319 *to_imx319(struct v4l2_subdev *_sd)
1763*4882a593Smuzhiyun {
1764*4882a593Smuzhiyun 	return container_of(_sd, struct imx319, sd);
1765*4882a593Smuzhiyun }
1766*4882a593Smuzhiyun 
1767*4882a593Smuzhiyun /* Get bayer order based on flip setting. */
imx319_get_format_code(struct imx319 * imx319)1768*4882a593Smuzhiyun static u32 imx319_get_format_code(struct imx319 *imx319)
1769*4882a593Smuzhiyun {
1770*4882a593Smuzhiyun 	/*
1771*4882a593Smuzhiyun 	 * Only one bayer order is supported.
1772*4882a593Smuzhiyun 	 * It depends on the flip settings.
1773*4882a593Smuzhiyun 	 */
1774*4882a593Smuzhiyun 	u32 code;
1775*4882a593Smuzhiyun 	static const u32 codes[2][2] = {
1776*4882a593Smuzhiyun 		{ MEDIA_BUS_FMT_SRGGB10_1X10, MEDIA_BUS_FMT_SGRBG10_1X10, },
1777*4882a593Smuzhiyun 		{ MEDIA_BUS_FMT_SGBRG10_1X10, MEDIA_BUS_FMT_SBGGR10_1X10, },
1778*4882a593Smuzhiyun 	};
1779*4882a593Smuzhiyun 
1780*4882a593Smuzhiyun 	lockdep_assert_held(&imx319->mutex);
1781*4882a593Smuzhiyun 	code = codes[imx319->vflip->val][imx319->hflip->val];
1782*4882a593Smuzhiyun 
1783*4882a593Smuzhiyun 	return code;
1784*4882a593Smuzhiyun }
1785*4882a593Smuzhiyun 
1786*4882a593Smuzhiyun /* Read registers up to 4 at a time */
imx319_read_reg(struct imx319 * imx319,u16 reg,u32 len,u32 * val)1787*4882a593Smuzhiyun static int imx319_read_reg(struct imx319 *imx319, u16 reg, u32 len, u32 *val)
1788*4882a593Smuzhiyun {
1789*4882a593Smuzhiyun 	struct i2c_client *client = v4l2_get_subdevdata(&imx319->sd);
1790*4882a593Smuzhiyun 	struct i2c_msg msgs[2];
1791*4882a593Smuzhiyun 	u8 addr_buf[2];
1792*4882a593Smuzhiyun 	u8 data_buf[4] = { 0 };
1793*4882a593Smuzhiyun 	int ret;
1794*4882a593Smuzhiyun 
1795*4882a593Smuzhiyun 	if (len > 4)
1796*4882a593Smuzhiyun 		return -EINVAL;
1797*4882a593Smuzhiyun 
1798*4882a593Smuzhiyun 	put_unaligned_be16(reg, addr_buf);
1799*4882a593Smuzhiyun 	/* Write register address */
1800*4882a593Smuzhiyun 	msgs[0].addr = client->addr;
1801*4882a593Smuzhiyun 	msgs[0].flags = 0;
1802*4882a593Smuzhiyun 	msgs[0].len = ARRAY_SIZE(addr_buf);
1803*4882a593Smuzhiyun 	msgs[0].buf = addr_buf;
1804*4882a593Smuzhiyun 
1805*4882a593Smuzhiyun 	/* Read data from register */
1806*4882a593Smuzhiyun 	msgs[1].addr = client->addr;
1807*4882a593Smuzhiyun 	msgs[1].flags = I2C_M_RD;
1808*4882a593Smuzhiyun 	msgs[1].len = len;
1809*4882a593Smuzhiyun 	msgs[1].buf = &data_buf[4 - len];
1810*4882a593Smuzhiyun 
1811*4882a593Smuzhiyun 	ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));
1812*4882a593Smuzhiyun 	if (ret != ARRAY_SIZE(msgs))
1813*4882a593Smuzhiyun 		return -EIO;
1814*4882a593Smuzhiyun 
1815*4882a593Smuzhiyun 	*val = get_unaligned_be32(data_buf);
1816*4882a593Smuzhiyun 
1817*4882a593Smuzhiyun 	return 0;
1818*4882a593Smuzhiyun }
1819*4882a593Smuzhiyun 
1820*4882a593Smuzhiyun /* Write registers up to 4 at a time */
imx319_write_reg(struct imx319 * imx319,u16 reg,u32 len,u32 val)1821*4882a593Smuzhiyun static int imx319_write_reg(struct imx319 *imx319, u16 reg, u32 len, u32 val)
1822*4882a593Smuzhiyun {
1823*4882a593Smuzhiyun 	struct i2c_client *client = v4l2_get_subdevdata(&imx319->sd);
1824*4882a593Smuzhiyun 	u8 buf[6];
1825*4882a593Smuzhiyun 
1826*4882a593Smuzhiyun 	if (len > 4)
1827*4882a593Smuzhiyun 		return -EINVAL;
1828*4882a593Smuzhiyun 
1829*4882a593Smuzhiyun 	put_unaligned_be16(reg, buf);
1830*4882a593Smuzhiyun 	put_unaligned_be32(val << (8 * (4 - len)), buf + 2);
1831*4882a593Smuzhiyun 	if (i2c_master_send(client, buf, len + 2) != len + 2)
1832*4882a593Smuzhiyun 		return -EIO;
1833*4882a593Smuzhiyun 
1834*4882a593Smuzhiyun 	return 0;
1835*4882a593Smuzhiyun }
1836*4882a593Smuzhiyun 
1837*4882a593Smuzhiyun /* Write a list of registers */
imx319_write_regs(struct imx319 * imx319,const struct imx319_reg * regs,u32 len)1838*4882a593Smuzhiyun static int imx319_write_regs(struct imx319 *imx319,
1839*4882a593Smuzhiyun 			     const struct imx319_reg *regs, u32 len)
1840*4882a593Smuzhiyun {
1841*4882a593Smuzhiyun 	struct i2c_client *client = v4l2_get_subdevdata(&imx319->sd);
1842*4882a593Smuzhiyun 	int ret;
1843*4882a593Smuzhiyun 	u32 i;
1844*4882a593Smuzhiyun 
1845*4882a593Smuzhiyun 	for (i = 0; i < len; i++) {
1846*4882a593Smuzhiyun 		ret = imx319_write_reg(imx319, regs[i].address, 1, regs[i].val);
1847*4882a593Smuzhiyun 		if (ret) {
1848*4882a593Smuzhiyun 			dev_err_ratelimited(&client->dev,
1849*4882a593Smuzhiyun 					    "write reg 0x%4.4x return err %d",
1850*4882a593Smuzhiyun 					    regs[i].address, ret);
1851*4882a593Smuzhiyun 			return ret;
1852*4882a593Smuzhiyun 		}
1853*4882a593Smuzhiyun 	}
1854*4882a593Smuzhiyun 
1855*4882a593Smuzhiyun 	return 0;
1856*4882a593Smuzhiyun }
1857*4882a593Smuzhiyun 
1858*4882a593Smuzhiyun /* Open sub-device */
imx319_open(struct v4l2_subdev * sd,struct v4l2_subdev_fh * fh)1859*4882a593Smuzhiyun static int imx319_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
1860*4882a593Smuzhiyun {
1861*4882a593Smuzhiyun 	struct imx319 *imx319 = to_imx319(sd);
1862*4882a593Smuzhiyun 	struct v4l2_mbus_framefmt *try_fmt =
1863*4882a593Smuzhiyun 		v4l2_subdev_get_try_format(sd, fh->pad, 0);
1864*4882a593Smuzhiyun 
1865*4882a593Smuzhiyun 	mutex_lock(&imx319->mutex);
1866*4882a593Smuzhiyun 
1867*4882a593Smuzhiyun 	/* Initialize try_fmt */
1868*4882a593Smuzhiyun 	try_fmt->width = imx319->cur_mode->width;
1869*4882a593Smuzhiyun 	try_fmt->height = imx319->cur_mode->height;
1870*4882a593Smuzhiyun 	try_fmt->code = imx319_get_format_code(imx319);
1871*4882a593Smuzhiyun 	try_fmt->field = V4L2_FIELD_NONE;
1872*4882a593Smuzhiyun 
1873*4882a593Smuzhiyun 	mutex_unlock(&imx319->mutex);
1874*4882a593Smuzhiyun 
1875*4882a593Smuzhiyun 	return 0;
1876*4882a593Smuzhiyun }
1877*4882a593Smuzhiyun 
imx319_set_ctrl(struct v4l2_ctrl * ctrl)1878*4882a593Smuzhiyun static int imx319_set_ctrl(struct v4l2_ctrl *ctrl)
1879*4882a593Smuzhiyun {
1880*4882a593Smuzhiyun 	struct imx319 *imx319 = container_of(ctrl->handler,
1881*4882a593Smuzhiyun 					     struct imx319, ctrl_handler);
1882*4882a593Smuzhiyun 	struct i2c_client *client = v4l2_get_subdevdata(&imx319->sd);
1883*4882a593Smuzhiyun 	s64 max;
1884*4882a593Smuzhiyun 	int ret;
1885*4882a593Smuzhiyun 
1886*4882a593Smuzhiyun 	/* Propagate change of current control to all related controls */
1887*4882a593Smuzhiyun 	switch (ctrl->id) {
1888*4882a593Smuzhiyun 	case V4L2_CID_VBLANK:
1889*4882a593Smuzhiyun 		/* Update max exposure while meeting expected vblanking */
1890*4882a593Smuzhiyun 		max = imx319->cur_mode->height + ctrl->val - 18;
1891*4882a593Smuzhiyun 		__v4l2_ctrl_modify_range(imx319->exposure,
1892*4882a593Smuzhiyun 					 imx319->exposure->minimum,
1893*4882a593Smuzhiyun 					 max, imx319->exposure->step, max);
1894*4882a593Smuzhiyun 		break;
1895*4882a593Smuzhiyun 	}
1896*4882a593Smuzhiyun 
1897*4882a593Smuzhiyun 	/*
1898*4882a593Smuzhiyun 	 * Applying V4L2 control value only happens
1899*4882a593Smuzhiyun 	 * when power is up for streaming
1900*4882a593Smuzhiyun 	 */
1901*4882a593Smuzhiyun 	if (!pm_runtime_get_if_in_use(&client->dev))
1902*4882a593Smuzhiyun 		return 0;
1903*4882a593Smuzhiyun 
1904*4882a593Smuzhiyun 	switch (ctrl->id) {
1905*4882a593Smuzhiyun 	case V4L2_CID_ANALOGUE_GAIN:
1906*4882a593Smuzhiyun 		/* Analog gain = 1024/(1024 - ctrl->val) times */
1907*4882a593Smuzhiyun 		ret = imx319_write_reg(imx319, IMX319_REG_ANALOG_GAIN, 2,
1908*4882a593Smuzhiyun 				       ctrl->val);
1909*4882a593Smuzhiyun 		break;
1910*4882a593Smuzhiyun 	case V4L2_CID_DIGITAL_GAIN:
1911*4882a593Smuzhiyun 		ret = imx319_write_reg(imx319, IMX319_REG_DIG_GAIN_GLOBAL, 2,
1912*4882a593Smuzhiyun 				       ctrl->val);
1913*4882a593Smuzhiyun 		break;
1914*4882a593Smuzhiyun 	case V4L2_CID_EXPOSURE:
1915*4882a593Smuzhiyun 		ret = imx319_write_reg(imx319, IMX319_REG_EXPOSURE, 2,
1916*4882a593Smuzhiyun 				       ctrl->val);
1917*4882a593Smuzhiyun 		break;
1918*4882a593Smuzhiyun 	case V4L2_CID_VBLANK:
1919*4882a593Smuzhiyun 		/* Update FLL that meets expected vertical blanking */
1920*4882a593Smuzhiyun 		ret = imx319_write_reg(imx319, IMX319_REG_FLL, 2,
1921*4882a593Smuzhiyun 				       imx319->cur_mode->height + ctrl->val);
1922*4882a593Smuzhiyun 		break;
1923*4882a593Smuzhiyun 	case V4L2_CID_TEST_PATTERN:
1924*4882a593Smuzhiyun 		ret = imx319_write_reg(imx319, IMX319_REG_TEST_PATTERN,
1925*4882a593Smuzhiyun 				       2, ctrl->val);
1926*4882a593Smuzhiyun 		break;
1927*4882a593Smuzhiyun 	case V4L2_CID_HFLIP:
1928*4882a593Smuzhiyun 	case V4L2_CID_VFLIP:
1929*4882a593Smuzhiyun 		ret = imx319_write_reg(imx319, IMX319_REG_ORIENTATION, 1,
1930*4882a593Smuzhiyun 				       imx319->hflip->val |
1931*4882a593Smuzhiyun 				       imx319->vflip->val << 1);
1932*4882a593Smuzhiyun 		break;
1933*4882a593Smuzhiyun 	default:
1934*4882a593Smuzhiyun 		ret = -EINVAL;
1935*4882a593Smuzhiyun 		dev_info(&client->dev, "ctrl(id:0x%x,val:0x%x) is not handled",
1936*4882a593Smuzhiyun 			 ctrl->id, ctrl->val);
1937*4882a593Smuzhiyun 		break;
1938*4882a593Smuzhiyun 	}
1939*4882a593Smuzhiyun 
1940*4882a593Smuzhiyun 	pm_runtime_put(&client->dev);
1941*4882a593Smuzhiyun 
1942*4882a593Smuzhiyun 	return ret;
1943*4882a593Smuzhiyun }
1944*4882a593Smuzhiyun 
1945*4882a593Smuzhiyun static const struct v4l2_ctrl_ops imx319_ctrl_ops = {
1946*4882a593Smuzhiyun 	.s_ctrl = imx319_set_ctrl,
1947*4882a593Smuzhiyun };
1948*4882a593Smuzhiyun 
imx319_enum_mbus_code(struct v4l2_subdev * sd,struct v4l2_subdev_pad_config * cfg,struct v4l2_subdev_mbus_code_enum * code)1949*4882a593Smuzhiyun static int imx319_enum_mbus_code(struct v4l2_subdev *sd,
1950*4882a593Smuzhiyun 				 struct v4l2_subdev_pad_config *cfg,
1951*4882a593Smuzhiyun 				 struct v4l2_subdev_mbus_code_enum *code)
1952*4882a593Smuzhiyun {
1953*4882a593Smuzhiyun 	struct imx319 *imx319 = to_imx319(sd);
1954*4882a593Smuzhiyun 
1955*4882a593Smuzhiyun 	if (code->index > 0)
1956*4882a593Smuzhiyun 		return -EINVAL;
1957*4882a593Smuzhiyun 
1958*4882a593Smuzhiyun 	mutex_lock(&imx319->mutex);
1959*4882a593Smuzhiyun 	code->code = imx319_get_format_code(imx319);
1960*4882a593Smuzhiyun 	mutex_unlock(&imx319->mutex);
1961*4882a593Smuzhiyun 
1962*4882a593Smuzhiyun 	return 0;
1963*4882a593Smuzhiyun }
1964*4882a593Smuzhiyun 
imx319_enum_frame_size(struct v4l2_subdev * sd,struct v4l2_subdev_pad_config * cfg,struct v4l2_subdev_frame_size_enum * fse)1965*4882a593Smuzhiyun static int imx319_enum_frame_size(struct v4l2_subdev *sd,
1966*4882a593Smuzhiyun 				  struct v4l2_subdev_pad_config *cfg,
1967*4882a593Smuzhiyun 				  struct v4l2_subdev_frame_size_enum *fse)
1968*4882a593Smuzhiyun {
1969*4882a593Smuzhiyun 	struct imx319 *imx319 = to_imx319(sd);
1970*4882a593Smuzhiyun 
1971*4882a593Smuzhiyun 	if (fse->index >= ARRAY_SIZE(supported_modes))
1972*4882a593Smuzhiyun 		return -EINVAL;
1973*4882a593Smuzhiyun 
1974*4882a593Smuzhiyun 	mutex_lock(&imx319->mutex);
1975*4882a593Smuzhiyun 	if (fse->code != imx319_get_format_code(imx319)) {
1976*4882a593Smuzhiyun 		mutex_unlock(&imx319->mutex);
1977*4882a593Smuzhiyun 		return -EINVAL;
1978*4882a593Smuzhiyun 	}
1979*4882a593Smuzhiyun 	mutex_unlock(&imx319->mutex);
1980*4882a593Smuzhiyun 
1981*4882a593Smuzhiyun 	fse->min_width = supported_modes[fse->index].width;
1982*4882a593Smuzhiyun 	fse->max_width = fse->min_width;
1983*4882a593Smuzhiyun 	fse->min_height = supported_modes[fse->index].height;
1984*4882a593Smuzhiyun 	fse->max_height = fse->min_height;
1985*4882a593Smuzhiyun 
1986*4882a593Smuzhiyun 	return 0;
1987*4882a593Smuzhiyun }
1988*4882a593Smuzhiyun 
imx319_update_pad_format(struct imx319 * imx319,const struct imx319_mode * mode,struct v4l2_subdev_format * fmt)1989*4882a593Smuzhiyun static void imx319_update_pad_format(struct imx319 *imx319,
1990*4882a593Smuzhiyun 				     const struct imx319_mode *mode,
1991*4882a593Smuzhiyun 				     struct v4l2_subdev_format *fmt)
1992*4882a593Smuzhiyun {
1993*4882a593Smuzhiyun 	fmt->format.width = mode->width;
1994*4882a593Smuzhiyun 	fmt->format.height = mode->height;
1995*4882a593Smuzhiyun 	fmt->format.code = imx319_get_format_code(imx319);
1996*4882a593Smuzhiyun 	fmt->format.field = V4L2_FIELD_NONE;
1997*4882a593Smuzhiyun }
1998*4882a593Smuzhiyun 
imx319_do_get_pad_format(struct imx319 * imx319,struct v4l2_subdev_pad_config * cfg,struct v4l2_subdev_format * fmt)1999*4882a593Smuzhiyun static int imx319_do_get_pad_format(struct imx319 *imx319,
2000*4882a593Smuzhiyun 				    struct v4l2_subdev_pad_config *cfg,
2001*4882a593Smuzhiyun 				    struct v4l2_subdev_format *fmt)
2002*4882a593Smuzhiyun {
2003*4882a593Smuzhiyun 	struct v4l2_mbus_framefmt *framefmt;
2004*4882a593Smuzhiyun 	struct v4l2_subdev *sd = &imx319->sd;
2005*4882a593Smuzhiyun 
2006*4882a593Smuzhiyun 	if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
2007*4882a593Smuzhiyun 		framefmt = v4l2_subdev_get_try_format(sd, cfg, fmt->pad);
2008*4882a593Smuzhiyun 		fmt->format = *framefmt;
2009*4882a593Smuzhiyun 	} else {
2010*4882a593Smuzhiyun 		imx319_update_pad_format(imx319, imx319->cur_mode, fmt);
2011*4882a593Smuzhiyun 	}
2012*4882a593Smuzhiyun 
2013*4882a593Smuzhiyun 	return 0;
2014*4882a593Smuzhiyun }
2015*4882a593Smuzhiyun 
imx319_get_pad_format(struct v4l2_subdev * sd,struct v4l2_subdev_pad_config * cfg,struct v4l2_subdev_format * fmt)2016*4882a593Smuzhiyun static int imx319_get_pad_format(struct v4l2_subdev *sd,
2017*4882a593Smuzhiyun 				 struct v4l2_subdev_pad_config *cfg,
2018*4882a593Smuzhiyun 				 struct v4l2_subdev_format *fmt)
2019*4882a593Smuzhiyun {
2020*4882a593Smuzhiyun 	struct imx319 *imx319 = to_imx319(sd);
2021*4882a593Smuzhiyun 	int ret;
2022*4882a593Smuzhiyun 
2023*4882a593Smuzhiyun 	mutex_lock(&imx319->mutex);
2024*4882a593Smuzhiyun 	ret = imx319_do_get_pad_format(imx319, cfg, fmt);
2025*4882a593Smuzhiyun 	mutex_unlock(&imx319->mutex);
2026*4882a593Smuzhiyun 
2027*4882a593Smuzhiyun 	return ret;
2028*4882a593Smuzhiyun }
2029*4882a593Smuzhiyun 
2030*4882a593Smuzhiyun static int
imx319_set_pad_format(struct v4l2_subdev * sd,struct v4l2_subdev_pad_config * cfg,struct v4l2_subdev_format * fmt)2031*4882a593Smuzhiyun imx319_set_pad_format(struct v4l2_subdev *sd,
2032*4882a593Smuzhiyun 		      struct v4l2_subdev_pad_config *cfg,
2033*4882a593Smuzhiyun 		      struct v4l2_subdev_format *fmt)
2034*4882a593Smuzhiyun {
2035*4882a593Smuzhiyun 	struct imx319 *imx319 = to_imx319(sd);
2036*4882a593Smuzhiyun 	const struct imx319_mode *mode;
2037*4882a593Smuzhiyun 	struct v4l2_mbus_framefmt *framefmt;
2038*4882a593Smuzhiyun 	s32 vblank_def;
2039*4882a593Smuzhiyun 	s32 vblank_min;
2040*4882a593Smuzhiyun 	s64 h_blank;
2041*4882a593Smuzhiyun 	u64 pixel_rate;
2042*4882a593Smuzhiyun 	u32 height;
2043*4882a593Smuzhiyun 
2044*4882a593Smuzhiyun 	mutex_lock(&imx319->mutex);
2045*4882a593Smuzhiyun 
2046*4882a593Smuzhiyun 	/*
2047*4882a593Smuzhiyun 	 * Only one bayer order is supported.
2048*4882a593Smuzhiyun 	 * It depends on the flip settings.
2049*4882a593Smuzhiyun 	 */
2050*4882a593Smuzhiyun 	fmt->format.code = imx319_get_format_code(imx319);
2051*4882a593Smuzhiyun 
2052*4882a593Smuzhiyun 	mode = v4l2_find_nearest_size(supported_modes,
2053*4882a593Smuzhiyun 				      ARRAY_SIZE(supported_modes),
2054*4882a593Smuzhiyun 				      width, height,
2055*4882a593Smuzhiyun 				      fmt->format.width, fmt->format.height);
2056*4882a593Smuzhiyun 	imx319_update_pad_format(imx319, mode, fmt);
2057*4882a593Smuzhiyun 	if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
2058*4882a593Smuzhiyun 		framefmt = v4l2_subdev_get_try_format(sd, cfg, fmt->pad);
2059*4882a593Smuzhiyun 		*framefmt = fmt->format;
2060*4882a593Smuzhiyun 	} else {
2061*4882a593Smuzhiyun 		imx319->cur_mode = mode;
2062*4882a593Smuzhiyun 		pixel_rate = imx319->link_def_freq * 2 * 4;
2063*4882a593Smuzhiyun 		do_div(pixel_rate, 10);
2064*4882a593Smuzhiyun 		__v4l2_ctrl_s_ctrl_int64(imx319->pixel_rate, pixel_rate);
2065*4882a593Smuzhiyun 		/* Update limits and set FPS to default */
2066*4882a593Smuzhiyun 		height = imx319->cur_mode->height;
2067*4882a593Smuzhiyun 		vblank_def = imx319->cur_mode->fll_def - height;
2068*4882a593Smuzhiyun 		vblank_min = imx319->cur_mode->fll_min - height;
2069*4882a593Smuzhiyun 		height = IMX319_FLL_MAX - height;
2070*4882a593Smuzhiyun 		__v4l2_ctrl_modify_range(imx319->vblank, vblank_min, height, 1,
2071*4882a593Smuzhiyun 					 vblank_def);
2072*4882a593Smuzhiyun 		__v4l2_ctrl_s_ctrl(imx319->vblank, vblank_def);
2073*4882a593Smuzhiyun 		h_blank = mode->llp - imx319->cur_mode->width;
2074*4882a593Smuzhiyun 		/*
2075*4882a593Smuzhiyun 		 * Currently hblank is not changeable.
2076*4882a593Smuzhiyun 		 * So FPS control is done only by vblank.
2077*4882a593Smuzhiyun 		 */
2078*4882a593Smuzhiyun 		__v4l2_ctrl_modify_range(imx319->hblank, h_blank,
2079*4882a593Smuzhiyun 					 h_blank, 1, h_blank);
2080*4882a593Smuzhiyun 	}
2081*4882a593Smuzhiyun 
2082*4882a593Smuzhiyun 	mutex_unlock(&imx319->mutex);
2083*4882a593Smuzhiyun 
2084*4882a593Smuzhiyun 	return 0;
2085*4882a593Smuzhiyun }
2086*4882a593Smuzhiyun 
2087*4882a593Smuzhiyun /* Start streaming */
imx319_start_streaming(struct imx319 * imx319)2088*4882a593Smuzhiyun static int imx319_start_streaming(struct imx319 *imx319)
2089*4882a593Smuzhiyun {
2090*4882a593Smuzhiyun 	struct i2c_client *client = v4l2_get_subdevdata(&imx319->sd);
2091*4882a593Smuzhiyun 	const struct imx319_reg_list *reg_list;
2092*4882a593Smuzhiyun 	int ret;
2093*4882a593Smuzhiyun 
2094*4882a593Smuzhiyun 	/* Global Setting */
2095*4882a593Smuzhiyun 	reg_list = &imx319_global_setting;
2096*4882a593Smuzhiyun 	ret = imx319_write_regs(imx319, reg_list->regs, reg_list->num_of_regs);
2097*4882a593Smuzhiyun 	if (ret) {
2098*4882a593Smuzhiyun 		dev_err(&client->dev, "failed to set global settings");
2099*4882a593Smuzhiyun 		return ret;
2100*4882a593Smuzhiyun 	}
2101*4882a593Smuzhiyun 
2102*4882a593Smuzhiyun 	/* Apply default values of current mode */
2103*4882a593Smuzhiyun 	reg_list = &imx319->cur_mode->reg_list;
2104*4882a593Smuzhiyun 	ret = imx319_write_regs(imx319, reg_list->regs, reg_list->num_of_regs);
2105*4882a593Smuzhiyun 	if (ret) {
2106*4882a593Smuzhiyun 		dev_err(&client->dev, "failed to set mode");
2107*4882a593Smuzhiyun 		return ret;
2108*4882a593Smuzhiyun 	}
2109*4882a593Smuzhiyun 
2110*4882a593Smuzhiyun 	/* set digital gain control to all color mode */
2111*4882a593Smuzhiyun 	ret = imx319_write_reg(imx319, IMX319_REG_DPGA_USE_GLOBAL_GAIN, 1, 1);
2112*4882a593Smuzhiyun 	if (ret)
2113*4882a593Smuzhiyun 		return ret;
2114*4882a593Smuzhiyun 
2115*4882a593Smuzhiyun 	/* Apply customized values from user */
2116*4882a593Smuzhiyun 	ret =  __v4l2_ctrl_handler_setup(imx319->sd.ctrl_handler);
2117*4882a593Smuzhiyun 	if (ret)
2118*4882a593Smuzhiyun 		return ret;
2119*4882a593Smuzhiyun 
2120*4882a593Smuzhiyun 	return imx319_write_reg(imx319, IMX319_REG_MODE_SELECT,
2121*4882a593Smuzhiyun 				1, IMX319_MODE_STREAMING);
2122*4882a593Smuzhiyun }
2123*4882a593Smuzhiyun 
2124*4882a593Smuzhiyun /* Stop streaming */
imx319_stop_streaming(struct imx319 * imx319)2125*4882a593Smuzhiyun static int imx319_stop_streaming(struct imx319 *imx319)
2126*4882a593Smuzhiyun {
2127*4882a593Smuzhiyun 	return imx319_write_reg(imx319, IMX319_REG_MODE_SELECT,
2128*4882a593Smuzhiyun 				1, IMX319_MODE_STANDBY);
2129*4882a593Smuzhiyun }
2130*4882a593Smuzhiyun 
imx319_set_stream(struct v4l2_subdev * sd,int enable)2131*4882a593Smuzhiyun static int imx319_set_stream(struct v4l2_subdev *sd, int enable)
2132*4882a593Smuzhiyun {
2133*4882a593Smuzhiyun 	struct imx319 *imx319 = to_imx319(sd);
2134*4882a593Smuzhiyun 	struct i2c_client *client = v4l2_get_subdevdata(sd);
2135*4882a593Smuzhiyun 	int ret = 0;
2136*4882a593Smuzhiyun 
2137*4882a593Smuzhiyun 	mutex_lock(&imx319->mutex);
2138*4882a593Smuzhiyun 	if (imx319->streaming == enable) {
2139*4882a593Smuzhiyun 		mutex_unlock(&imx319->mutex);
2140*4882a593Smuzhiyun 		return 0;
2141*4882a593Smuzhiyun 	}
2142*4882a593Smuzhiyun 
2143*4882a593Smuzhiyun 	if (enable) {
2144*4882a593Smuzhiyun 		ret = pm_runtime_get_sync(&client->dev);
2145*4882a593Smuzhiyun 		if (ret < 0) {
2146*4882a593Smuzhiyun 			pm_runtime_put_noidle(&client->dev);
2147*4882a593Smuzhiyun 			goto err_unlock;
2148*4882a593Smuzhiyun 		}
2149*4882a593Smuzhiyun 
2150*4882a593Smuzhiyun 		/*
2151*4882a593Smuzhiyun 		 * Apply default & customized values
2152*4882a593Smuzhiyun 		 * and then start streaming.
2153*4882a593Smuzhiyun 		 */
2154*4882a593Smuzhiyun 		ret = imx319_start_streaming(imx319);
2155*4882a593Smuzhiyun 		if (ret)
2156*4882a593Smuzhiyun 			goto err_rpm_put;
2157*4882a593Smuzhiyun 	} else {
2158*4882a593Smuzhiyun 		imx319_stop_streaming(imx319);
2159*4882a593Smuzhiyun 		pm_runtime_put(&client->dev);
2160*4882a593Smuzhiyun 	}
2161*4882a593Smuzhiyun 
2162*4882a593Smuzhiyun 	imx319->streaming = enable;
2163*4882a593Smuzhiyun 
2164*4882a593Smuzhiyun 	/* vflip and hflip cannot change during streaming */
2165*4882a593Smuzhiyun 	__v4l2_ctrl_grab(imx319->vflip, enable);
2166*4882a593Smuzhiyun 	__v4l2_ctrl_grab(imx319->hflip, enable);
2167*4882a593Smuzhiyun 
2168*4882a593Smuzhiyun 	mutex_unlock(&imx319->mutex);
2169*4882a593Smuzhiyun 
2170*4882a593Smuzhiyun 	return ret;
2171*4882a593Smuzhiyun 
2172*4882a593Smuzhiyun err_rpm_put:
2173*4882a593Smuzhiyun 	pm_runtime_put(&client->dev);
2174*4882a593Smuzhiyun err_unlock:
2175*4882a593Smuzhiyun 	mutex_unlock(&imx319->mutex);
2176*4882a593Smuzhiyun 
2177*4882a593Smuzhiyun 	return ret;
2178*4882a593Smuzhiyun }
2179*4882a593Smuzhiyun 
imx319_suspend(struct device * dev)2180*4882a593Smuzhiyun static int __maybe_unused imx319_suspend(struct device *dev)
2181*4882a593Smuzhiyun {
2182*4882a593Smuzhiyun 	struct i2c_client *client = to_i2c_client(dev);
2183*4882a593Smuzhiyun 	struct v4l2_subdev *sd = i2c_get_clientdata(client);
2184*4882a593Smuzhiyun 	struct imx319 *imx319 = to_imx319(sd);
2185*4882a593Smuzhiyun 
2186*4882a593Smuzhiyun 	if (imx319->streaming)
2187*4882a593Smuzhiyun 		imx319_stop_streaming(imx319);
2188*4882a593Smuzhiyun 
2189*4882a593Smuzhiyun 	return 0;
2190*4882a593Smuzhiyun }
2191*4882a593Smuzhiyun 
imx319_resume(struct device * dev)2192*4882a593Smuzhiyun static int __maybe_unused imx319_resume(struct device *dev)
2193*4882a593Smuzhiyun {
2194*4882a593Smuzhiyun 	struct i2c_client *client = to_i2c_client(dev);
2195*4882a593Smuzhiyun 	struct v4l2_subdev *sd = i2c_get_clientdata(client);
2196*4882a593Smuzhiyun 	struct imx319 *imx319 = to_imx319(sd);
2197*4882a593Smuzhiyun 	int ret;
2198*4882a593Smuzhiyun 
2199*4882a593Smuzhiyun 	if (imx319->streaming) {
2200*4882a593Smuzhiyun 		ret = imx319_start_streaming(imx319);
2201*4882a593Smuzhiyun 		if (ret)
2202*4882a593Smuzhiyun 			goto error;
2203*4882a593Smuzhiyun 	}
2204*4882a593Smuzhiyun 
2205*4882a593Smuzhiyun 	return 0;
2206*4882a593Smuzhiyun 
2207*4882a593Smuzhiyun error:
2208*4882a593Smuzhiyun 	imx319_stop_streaming(imx319);
2209*4882a593Smuzhiyun 	imx319->streaming = 0;
2210*4882a593Smuzhiyun 	return ret;
2211*4882a593Smuzhiyun }
2212*4882a593Smuzhiyun 
2213*4882a593Smuzhiyun /* Verify chip ID */
imx319_identify_module(struct imx319 * imx319)2214*4882a593Smuzhiyun static int imx319_identify_module(struct imx319 *imx319)
2215*4882a593Smuzhiyun {
2216*4882a593Smuzhiyun 	struct i2c_client *client = v4l2_get_subdevdata(&imx319->sd);
2217*4882a593Smuzhiyun 	int ret;
2218*4882a593Smuzhiyun 	u32 val;
2219*4882a593Smuzhiyun 
2220*4882a593Smuzhiyun 	ret = imx319_read_reg(imx319, IMX319_REG_CHIP_ID, 2, &val);
2221*4882a593Smuzhiyun 	if (ret)
2222*4882a593Smuzhiyun 		return ret;
2223*4882a593Smuzhiyun 
2224*4882a593Smuzhiyun 	if (val != IMX319_CHIP_ID) {
2225*4882a593Smuzhiyun 		dev_err(&client->dev, "chip id mismatch: %x!=%x",
2226*4882a593Smuzhiyun 			IMX319_CHIP_ID, val);
2227*4882a593Smuzhiyun 		return -EIO;
2228*4882a593Smuzhiyun 	}
2229*4882a593Smuzhiyun 
2230*4882a593Smuzhiyun 	return 0;
2231*4882a593Smuzhiyun }
2232*4882a593Smuzhiyun 
2233*4882a593Smuzhiyun static const struct v4l2_subdev_core_ops imx319_subdev_core_ops = {
2234*4882a593Smuzhiyun 	.subscribe_event = v4l2_ctrl_subdev_subscribe_event,
2235*4882a593Smuzhiyun 	.unsubscribe_event = v4l2_event_subdev_unsubscribe,
2236*4882a593Smuzhiyun };
2237*4882a593Smuzhiyun 
2238*4882a593Smuzhiyun static const struct v4l2_subdev_video_ops imx319_video_ops = {
2239*4882a593Smuzhiyun 	.s_stream = imx319_set_stream,
2240*4882a593Smuzhiyun };
2241*4882a593Smuzhiyun 
2242*4882a593Smuzhiyun static const struct v4l2_subdev_pad_ops imx319_pad_ops = {
2243*4882a593Smuzhiyun 	.enum_mbus_code = imx319_enum_mbus_code,
2244*4882a593Smuzhiyun 	.get_fmt = imx319_get_pad_format,
2245*4882a593Smuzhiyun 	.set_fmt = imx319_set_pad_format,
2246*4882a593Smuzhiyun 	.enum_frame_size = imx319_enum_frame_size,
2247*4882a593Smuzhiyun };
2248*4882a593Smuzhiyun 
2249*4882a593Smuzhiyun static const struct v4l2_subdev_ops imx319_subdev_ops = {
2250*4882a593Smuzhiyun 	.core = &imx319_subdev_core_ops,
2251*4882a593Smuzhiyun 	.video = &imx319_video_ops,
2252*4882a593Smuzhiyun 	.pad = &imx319_pad_ops,
2253*4882a593Smuzhiyun };
2254*4882a593Smuzhiyun 
2255*4882a593Smuzhiyun static const struct media_entity_operations imx319_subdev_entity_ops = {
2256*4882a593Smuzhiyun 	.link_validate = v4l2_subdev_link_validate,
2257*4882a593Smuzhiyun };
2258*4882a593Smuzhiyun 
2259*4882a593Smuzhiyun static const struct v4l2_subdev_internal_ops imx319_internal_ops = {
2260*4882a593Smuzhiyun 	.open = imx319_open,
2261*4882a593Smuzhiyun };
2262*4882a593Smuzhiyun 
2263*4882a593Smuzhiyun /* Initialize control handlers */
imx319_init_controls(struct imx319 * imx319)2264*4882a593Smuzhiyun static int imx319_init_controls(struct imx319 *imx319)
2265*4882a593Smuzhiyun {
2266*4882a593Smuzhiyun 	struct i2c_client *client = v4l2_get_subdevdata(&imx319->sd);
2267*4882a593Smuzhiyun 	struct v4l2_ctrl_handler *ctrl_hdlr;
2268*4882a593Smuzhiyun 	s64 exposure_max;
2269*4882a593Smuzhiyun 	s64 vblank_def;
2270*4882a593Smuzhiyun 	s64 vblank_min;
2271*4882a593Smuzhiyun 	s64 hblank;
2272*4882a593Smuzhiyun 	u64 pixel_rate;
2273*4882a593Smuzhiyun 	const struct imx319_mode *mode;
2274*4882a593Smuzhiyun 	u32 max;
2275*4882a593Smuzhiyun 	int ret;
2276*4882a593Smuzhiyun 
2277*4882a593Smuzhiyun 	ctrl_hdlr = &imx319->ctrl_handler;
2278*4882a593Smuzhiyun 	ret = v4l2_ctrl_handler_init(ctrl_hdlr, 10);
2279*4882a593Smuzhiyun 	if (ret)
2280*4882a593Smuzhiyun 		return ret;
2281*4882a593Smuzhiyun 
2282*4882a593Smuzhiyun 	ctrl_hdlr->lock = &imx319->mutex;
2283*4882a593Smuzhiyun 	max = ARRAY_SIZE(link_freq_menu_items) - 1;
2284*4882a593Smuzhiyun 	imx319->link_freq = v4l2_ctrl_new_int_menu(ctrl_hdlr, &imx319_ctrl_ops,
2285*4882a593Smuzhiyun 						   V4L2_CID_LINK_FREQ, max, 0,
2286*4882a593Smuzhiyun 						   link_freq_menu_items);
2287*4882a593Smuzhiyun 	if (imx319->link_freq)
2288*4882a593Smuzhiyun 		imx319->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;
2289*4882a593Smuzhiyun 
2290*4882a593Smuzhiyun 	/* pixel_rate = link_freq * 2 * nr_of_lanes / bits_per_sample */
2291*4882a593Smuzhiyun 	pixel_rate = imx319->link_def_freq * 2 * 4;
2292*4882a593Smuzhiyun 	do_div(pixel_rate, 10);
2293*4882a593Smuzhiyun 	/* By default, PIXEL_RATE is read only */
2294*4882a593Smuzhiyun 	imx319->pixel_rate = v4l2_ctrl_new_std(ctrl_hdlr, &imx319_ctrl_ops,
2295*4882a593Smuzhiyun 					       V4L2_CID_PIXEL_RATE, pixel_rate,
2296*4882a593Smuzhiyun 					       pixel_rate, 1, pixel_rate);
2297*4882a593Smuzhiyun 
2298*4882a593Smuzhiyun 	/* Initial vblank/hblank/exposure parameters based on current mode */
2299*4882a593Smuzhiyun 	mode = imx319->cur_mode;
2300*4882a593Smuzhiyun 	vblank_def = mode->fll_def - mode->height;
2301*4882a593Smuzhiyun 	vblank_min = mode->fll_min - mode->height;
2302*4882a593Smuzhiyun 	imx319->vblank = v4l2_ctrl_new_std(ctrl_hdlr, &imx319_ctrl_ops,
2303*4882a593Smuzhiyun 					   V4L2_CID_VBLANK, vblank_min,
2304*4882a593Smuzhiyun 					   IMX319_FLL_MAX - mode->height,
2305*4882a593Smuzhiyun 					   1, vblank_def);
2306*4882a593Smuzhiyun 
2307*4882a593Smuzhiyun 	hblank = mode->llp - mode->width;
2308*4882a593Smuzhiyun 	imx319->hblank = v4l2_ctrl_new_std(ctrl_hdlr, &imx319_ctrl_ops,
2309*4882a593Smuzhiyun 					   V4L2_CID_HBLANK, hblank, hblank,
2310*4882a593Smuzhiyun 					   1, hblank);
2311*4882a593Smuzhiyun 	if (imx319->hblank)
2312*4882a593Smuzhiyun 		imx319->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY;
2313*4882a593Smuzhiyun 
2314*4882a593Smuzhiyun 	/* fll >= exposure time + adjust parameter (default value is 18) */
2315*4882a593Smuzhiyun 	exposure_max = mode->fll_def - 18;
2316*4882a593Smuzhiyun 	imx319->exposure = v4l2_ctrl_new_std(ctrl_hdlr, &imx319_ctrl_ops,
2317*4882a593Smuzhiyun 					     V4L2_CID_EXPOSURE,
2318*4882a593Smuzhiyun 					     IMX319_EXPOSURE_MIN, exposure_max,
2319*4882a593Smuzhiyun 					     IMX319_EXPOSURE_STEP,
2320*4882a593Smuzhiyun 					     IMX319_EXPOSURE_DEFAULT);
2321*4882a593Smuzhiyun 
2322*4882a593Smuzhiyun 	imx319->hflip = v4l2_ctrl_new_std(ctrl_hdlr, &imx319_ctrl_ops,
2323*4882a593Smuzhiyun 					  V4L2_CID_HFLIP, 0, 1, 1, 0);
2324*4882a593Smuzhiyun 	imx319->vflip = v4l2_ctrl_new_std(ctrl_hdlr, &imx319_ctrl_ops,
2325*4882a593Smuzhiyun 					  V4L2_CID_VFLIP, 0, 1, 1, 0);
2326*4882a593Smuzhiyun 
2327*4882a593Smuzhiyun 	v4l2_ctrl_new_std(ctrl_hdlr, &imx319_ctrl_ops, V4L2_CID_ANALOGUE_GAIN,
2328*4882a593Smuzhiyun 			  IMX319_ANA_GAIN_MIN, IMX319_ANA_GAIN_MAX,
2329*4882a593Smuzhiyun 			  IMX319_ANA_GAIN_STEP, IMX319_ANA_GAIN_DEFAULT);
2330*4882a593Smuzhiyun 
2331*4882a593Smuzhiyun 	/* Digital gain */
2332*4882a593Smuzhiyun 	v4l2_ctrl_new_std(ctrl_hdlr, &imx319_ctrl_ops, V4L2_CID_DIGITAL_GAIN,
2333*4882a593Smuzhiyun 			  IMX319_DGTL_GAIN_MIN, IMX319_DGTL_GAIN_MAX,
2334*4882a593Smuzhiyun 			  IMX319_DGTL_GAIN_STEP, IMX319_DGTL_GAIN_DEFAULT);
2335*4882a593Smuzhiyun 
2336*4882a593Smuzhiyun 	v4l2_ctrl_new_std_menu_items(ctrl_hdlr, &imx319_ctrl_ops,
2337*4882a593Smuzhiyun 				     V4L2_CID_TEST_PATTERN,
2338*4882a593Smuzhiyun 				     ARRAY_SIZE(imx319_test_pattern_menu) - 1,
2339*4882a593Smuzhiyun 				     0, 0, imx319_test_pattern_menu);
2340*4882a593Smuzhiyun 	if (ctrl_hdlr->error) {
2341*4882a593Smuzhiyun 		ret = ctrl_hdlr->error;
2342*4882a593Smuzhiyun 		dev_err(&client->dev, "control init failed: %d", ret);
2343*4882a593Smuzhiyun 		goto error;
2344*4882a593Smuzhiyun 	}
2345*4882a593Smuzhiyun 
2346*4882a593Smuzhiyun 	imx319->sd.ctrl_handler = ctrl_hdlr;
2347*4882a593Smuzhiyun 
2348*4882a593Smuzhiyun 	return 0;
2349*4882a593Smuzhiyun 
2350*4882a593Smuzhiyun error:
2351*4882a593Smuzhiyun 	v4l2_ctrl_handler_free(ctrl_hdlr);
2352*4882a593Smuzhiyun 
2353*4882a593Smuzhiyun 	return ret;
2354*4882a593Smuzhiyun }
2355*4882a593Smuzhiyun 
imx319_get_hwcfg(struct device * dev)2356*4882a593Smuzhiyun static struct imx319_hwcfg *imx319_get_hwcfg(struct device *dev)
2357*4882a593Smuzhiyun {
2358*4882a593Smuzhiyun 	struct imx319_hwcfg *cfg;
2359*4882a593Smuzhiyun 	struct v4l2_fwnode_endpoint bus_cfg = {
2360*4882a593Smuzhiyun 		.bus_type = V4L2_MBUS_CSI2_DPHY
2361*4882a593Smuzhiyun 	};
2362*4882a593Smuzhiyun 	struct fwnode_handle *ep;
2363*4882a593Smuzhiyun 	struct fwnode_handle *fwnode = dev_fwnode(dev);
2364*4882a593Smuzhiyun 	unsigned int i;
2365*4882a593Smuzhiyun 	int ret;
2366*4882a593Smuzhiyun 
2367*4882a593Smuzhiyun 	if (!fwnode)
2368*4882a593Smuzhiyun 		return NULL;
2369*4882a593Smuzhiyun 
2370*4882a593Smuzhiyun 	ep = fwnode_graph_get_next_endpoint(fwnode, NULL);
2371*4882a593Smuzhiyun 	if (!ep)
2372*4882a593Smuzhiyun 		return NULL;
2373*4882a593Smuzhiyun 
2374*4882a593Smuzhiyun 	ret = v4l2_fwnode_endpoint_alloc_parse(ep, &bus_cfg);
2375*4882a593Smuzhiyun 	if (ret)
2376*4882a593Smuzhiyun 		goto out_err;
2377*4882a593Smuzhiyun 
2378*4882a593Smuzhiyun 	cfg = devm_kzalloc(dev, sizeof(*cfg), GFP_KERNEL);
2379*4882a593Smuzhiyun 	if (!cfg)
2380*4882a593Smuzhiyun 		goto out_err;
2381*4882a593Smuzhiyun 
2382*4882a593Smuzhiyun 	ret = fwnode_property_read_u32(dev_fwnode(dev), "clock-frequency",
2383*4882a593Smuzhiyun 				       &cfg->ext_clk);
2384*4882a593Smuzhiyun 	if (ret) {
2385*4882a593Smuzhiyun 		dev_err(dev, "can't get clock frequency");
2386*4882a593Smuzhiyun 		goto out_err;
2387*4882a593Smuzhiyun 	}
2388*4882a593Smuzhiyun 
2389*4882a593Smuzhiyun 	dev_dbg(dev, "ext clk: %d", cfg->ext_clk);
2390*4882a593Smuzhiyun 	if (cfg->ext_clk != IMX319_EXT_CLK) {
2391*4882a593Smuzhiyun 		dev_err(dev, "external clock %d is not supported",
2392*4882a593Smuzhiyun 			cfg->ext_clk);
2393*4882a593Smuzhiyun 		goto out_err;
2394*4882a593Smuzhiyun 	}
2395*4882a593Smuzhiyun 
2396*4882a593Smuzhiyun 	dev_dbg(dev, "num of link freqs: %d", bus_cfg.nr_of_link_frequencies);
2397*4882a593Smuzhiyun 	if (!bus_cfg.nr_of_link_frequencies) {
2398*4882a593Smuzhiyun 		dev_warn(dev, "no link frequencies defined");
2399*4882a593Smuzhiyun 		goto out_err;
2400*4882a593Smuzhiyun 	}
2401*4882a593Smuzhiyun 
2402*4882a593Smuzhiyun 	cfg->nr_of_link_freqs = bus_cfg.nr_of_link_frequencies;
2403*4882a593Smuzhiyun 	cfg->link_freqs = devm_kcalloc(dev,
2404*4882a593Smuzhiyun 				       bus_cfg.nr_of_link_frequencies + 1,
2405*4882a593Smuzhiyun 				       sizeof(*cfg->link_freqs), GFP_KERNEL);
2406*4882a593Smuzhiyun 	if (!cfg->link_freqs)
2407*4882a593Smuzhiyun 		goto out_err;
2408*4882a593Smuzhiyun 
2409*4882a593Smuzhiyun 	for (i = 0; i < bus_cfg.nr_of_link_frequencies; i++) {
2410*4882a593Smuzhiyun 		cfg->link_freqs[i] = bus_cfg.link_frequencies[i];
2411*4882a593Smuzhiyun 		dev_dbg(dev, "link_freq[%d] = %lld", i, cfg->link_freqs[i]);
2412*4882a593Smuzhiyun 	}
2413*4882a593Smuzhiyun 
2414*4882a593Smuzhiyun 	v4l2_fwnode_endpoint_free(&bus_cfg);
2415*4882a593Smuzhiyun 	fwnode_handle_put(ep);
2416*4882a593Smuzhiyun 	return cfg;
2417*4882a593Smuzhiyun 
2418*4882a593Smuzhiyun out_err:
2419*4882a593Smuzhiyun 	v4l2_fwnode_endpoint_free(&bus_cfg);
2420*4882a593Smuzhiyun 	fwnode_handle_put(ep);
2421*4882a593Smuzhiyun 	return NULL;
2422*4882a593Smuzhiyun }
2423*4882a593Smuzhiyun 
imx319_probe(struct i2c_client * client)2424*4882a593Smuzhiyun static int imx319_probe(struct i2c_client *client)
2425*4882a593Smuzhiyun {
2426*4882a593Smuzhiyun 	struct imx319 *imx319;
2427*4882a593Smuzhiyun 	int ret;
2428*4882a593Smuzhiyun 	u32 i;
2429*4882a593Smuzhiyun 
2430*4882a593Smuzhiyun 	imx319 = devm_kzalloc(&client->dev, sizeof(*imx319), GFP_KERNEL);
2431*4882a593Smuzhiyun 	if (!imx319)
2432*4882a593Smuzhiyun 		return -ENOMEM;
2433*4882a593Smuzhiyun 
2434*4882a593Smuzhiyun 	mutex_init(&imx319->mutex);
2435*4882a593Smuzhiyun 
2436*4882a593Smuzhiyun 	/* Initialize subdev */
2437*4882a593Smuzhiyun 	v4l2_i2c_subdev_init(&imx319->sd, client, &imx319_subdev_ops);
2438*4882a593Smuzhiyun 
2439*4882a593Smuzhiyun 	/* Check module identity */
2440*4882a593Smuzhiyun 	ret = imx319_identify_module(imx319);
2441*4882a593Smuzhiyun 	if (ret) {
2442*4882a593Smuzhiyun 		dev_err(&client->dev, "failed to find sensor: %d", ret);
2443*4882a593Smuzhiyun 		goto error_probe;
2444*4882a593Smuzhiyun 	}
2445*4882a593Smuzhiyun 
2446*4882a593Smuzhiyun 	imx319->hwcfg = imx319_get_hwcfg(&client->dev);
2447*4882a593Smuzhiyun 	if (!imx319->hwcfg) {
2448*4882a593Smuzhiyun 		dev_err(&client->dev, "failed to get hwcfg");
2449*4882a593Smuzhiyun 		ret = -ENODEV;
2450*4882a593Smuzhiyun 		goto error_probe;
2451*4882a593Smuzhiyun 	}
2452*4882a593Smuzhiyun 
2453*4882a593Smuzhiyun 	imx319->link_def_freq = link_freq_menu_items[IMX319_LINK_FREQ_INDEX];
2454*4882a593Smuzhiyun 	for (i = 0; i < imx319->hwcfg->nr_of_link_freqs; i++) {
2455*4882a593Smuzhiyun 		if (imx319->hwcfg->link_freqs[i] == imx319->link_def_freq) {
2456*4882a593Smuzhiyun 			dev_dbg(&client->dev, "link freq index %d matched", i);
2457*4882a593Smuzhiyun 			break;
2458*4882a593Smuzhiyun 		}
2459*4882a593Smuzhiyun 	}
2460*4882a593Smuzhiyun 
2461*4882a593Smuzhiyun 	if (i == imx319->hwcfg->nr_of_link_freqs) {
2462*4882a593Smuzhiyun 		dev_err(&client->dev, "no link frequency supported");
2463*4882a593Smuzhiyun 		ret = -EINVAL;
2464*4882a593Smuzhiyun 		goto error_probe;
2465*4882a593Smuzhiyun 	}
2466*4882a593Smuzhiyun 
2467*4882a593Smuzhiyun 	/* Set default mode to max resolution */
2468*4882a593Smuzhiyun 	imx319->cur_mode = &supported_modes[0];
2469*4882a593Smuzhiyun 
2470*4882a593Smuzhiyun 	ret = imx319_init_controls(imx319);
2471*4882a593Smuzhiyun 	if (ret) {
2472*4882a593Smuzhiyun 		dev_err(&client->dev, "failed to init controls: %d", ret);
2473*4882a593Smuzhiyun 		goto error_probe;
2474*4882a593Smuzhiyun 	}
2475*4882a593Smuzhiyun 
2476*4882a593Smuzhiyun 	/* Initialize subdev */
2477*4882a593Smuzhiyun 	imx319->sd.internal_ops = &imx319_internal_ops;
2478*4882a593Smuzhiyun 	imx319->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE |
2479*4882a593Smuzhiyun 		V4L2_SUBDEV_FL_HAS_EVENTS;
2480*4882a593Smuzhiyun 	imx319->sd.entity.ops = &imx319_subdev_entity_ops;
2481*4882a593Smuzhiyun 	imx319->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
2482*4882a593Smuzhiyun 
2483*4882a593Smuzhiyun 	/* Initialize source pad */
2484*4882a593Smuzhiyun 	imx319->pad.flags = MEDIA_PAD_FL_SOURCE;
2485*4882a593Smuzhiyun 	ret = media_entity_pads_init(&imx319->sd.entity, 1, &imx319->pad);
2486*4882a593Smuzhiyun 	if (ret) {
2487*4882a593Smuzhiyun 		dev_err(&client->dev, "failed to init entity pads: %d", ret);
2488*4882a593Smuzhiyun 		goto error_handler_free;
2489*4882a593Smuzhiyun 	}
2490*4882a593Smuzhiyun 
2491*4882a593Smuzhiyun 	ret = v4l2_async_register_subdev_sensor_common(&imx319->sd);
2492*4882a593Smuzhiyun 	if (ret < 0)
2493*4882a593Smuzhiyun 		goto error_media_entity;
2494*4882a593Smuzhiyun 
2495*4882a593Smuzhiyun 	/*
2496*4882a593Smuzhiyun 	 * Device is already turned on by i2c-core with ACPI domain PM.
2497*4882a593Smuzhiyun 	 * Enable runtime PM and turn off the device.
2498*4882a593Smuzhiyun 	 */
2499*4882a593Smuzhiyun 	pm_runtime_set_active(&client->dev);
2500*4882a593Smuzhiyun 	pm_runtime_enable(&client->dev);
2501*4882a593Smuzhiyun 	pm_runtime_idle(&client->dev);
2502*4882a593Smuzhiyun 
2503*4882a593Smuzhiyun 	return 0;
2504*4882a593Smuzhiyun 
2505*4882a593Smuzhiyun error_media_entity:
2506*4882a593Smuzhiyun 	media_entity_cleanup(&imx319->sd.entity);
2507*4882a593Smuzhiyun 
2508*4882a593Smuzhiyun error_handler_free:
2509*4882a593Smuzhiyun 	v4l2_ctrl_handler_free(imx319->sd.ctrl_handler);
2510*4882a593Smuzhiyun 
2511*4882a593Smuzhiyun error_probe:
2512*4882a593Smuzhiyun 	mutex_destroy(&imx319->mutex);
2513*4882a593Smuzhiyun 
2514*4882a593Smuzhiyun 	return ret;
2515*4882a593Smuzhiyun }
2516*4882a593Smuzhiyun 
imx319_remove(struct i2c_client * client)2517*4882a593Smuzhiyun static int imx319_remove(struct i2c_client *client)
2518*4882a593Smuzhiyun {
2519*4882a593Smuzhiyun 	struct v4l2_subdev *sd = i2c_get_clientdata(client);
2520*4882a593Smuzhiyun 	struct imx319 *imx319 = to_imx319(sd);
2521*4882a593Smuzhiyun 
2522*4882a593Smuzhiyun 	v4l2_async_unregister_subdev(sd);
2523*4882a593Smuzhiyun 	media_entity_cleanup(&sd->entity);
2524*4882a593Smuzhiyun 	v4l2_ctrl_handler_free(sd->ctrl_handler);
2525*4882a593Smuzhiyun 
2526*4882a593Smuzhiyun 	pm_runtime_disable(&client->dev);
2527*4882a593Smuzhiyun 	pm_runtime_set_suspended(&client->dev);
2528*4882a593Smuzhiyun 
2529*4882a593Smuzhiyun 	mutex_destroy(&imx319->mutex);
2530*4882a593Smuzhiyun 
2531*4882a593Smuzhiyun 	return 0;
2532*4882a593Smuzhiyun }
2533*4882a593Smuzhiyun 
2534*4882a593Smuzhiyun static const struct dev_pm_ops imx319_pm_ops = {
2535*4882a593Smuzhiyun 	SET_SYSTEM_SLEEP_PM_OPS(imx319_suspend, imx319_resume)
2536*4882a593Smuzhiyun };
2537*4882a593Smuzhiyun 
2538*4882a593Smuzhiyun static const struct acpi_device_id imx319_acpi_ids[] = {
2539*4882a593Smuzhiyun 	{ "SONY319A" },
2540*4882a593Smuzhiyun 	{ /* sentinel */ }
2541*4882a593Smuzhiyun };
2542*4882a593Smuzhiyun MODULE_DEVICE_TABLE(acpi, imx319_acpi_ids);
2543*4882a593Smuzhiyun 
2544*4882a593Smuzhiyun static struct i2c_driver imx319_i2c_driver = {
2545*4882a593Smuzhiyun 	.driver = {
2546*4882a593Smuzhiyun 		.name = "imx319",
2547*4882a593Smuzhiyun 		.pm = &imx319_pm_ops,
2548*4882a593Smuzhiyun 		.acpi_match_table = ACPI_PTR(imx319_acpi_ids),
2549*4882a593Smuzhiyun 	},
2550*4882a593Smuzhiyun 	.probe_new = imx319_probe,
2551*4882a593Smuzhiyun 	.remove = imx319_remove,
2552*4882a593Smuzhiyun };
2553*4882a593Smuzhiyun module_i2c_driver(imx319_i2c_driver);
2554*4882a593Smuzhiyun 
2555*4882a593Smuzhiyun MODULE_AUTHOR("Qiu, Tianshu <tian.shu.qiu@intel.com>");
2556*4882a593Smuzhiyun MODULE_AUTHOR("Rapolu, Chiranjeevi <chiranjeevi.rapolu@intel.com>");
2557*4882a593Smuzhiyun MODULE_AUTHOR("Bingbu Cao <bingbu.cao@intel.com>");
2558*4882a593Smuzhiyun MODULE_AUTHOR("Yang, Hyungwoo <hyungwoo.yang@intel.com>");
2559*4882a593Smuzhiyun MODULE_DESCRIPTION("Sony imx319 sensor driver");
2560*4882a593Smuzhiyun MODULE_LICENSE("GPL v2");
2561