]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - drivers/staging/media/atomisp/i2c/gc2235.h
Merge tag 'char-misc-4.13-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregk...
[karo-tx-linux.git] / drivers / staging / media / atomisp / i2c / gc2235.h
1 /*
2  * Support for GalaxyCore GC2235 2M camera sensor.
3  *
4  * Copyright (c) 2014 Intel Corporation. All Rights Reserved.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License version
8  * 2 as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.
17  *
18  */
19
20 #ifndef __GC2235_H__
21 #define __GC2235_H__
22 #include <linux/kernel.h>
23 #include <linux/types.h>
24 #include <linux/i2c.h>
25 #include <linux/delay.h>
26 #include <linux/videodev2.h>
27 #include <linux/spinlock.h>
28 #include <media/v4l2-subdev.h>
29 #include <media/v4l2-device.h>
30 #include <media/v4l2-ctrls.h>
31 #include <linux/v4l2-mediabus.h>
32 #include <media/media-entity.h>
33
34 #include "../include/linux/atomisp_platform.h"
35
36 #define GC2235_NAME             "gc2235"
37
38 /* Defines for register writes and register array processing */
39 #define I2C_MSG_LENGTH          0x2
40 #define I2C_RETRY_COUNT         5
41
42 #define GC2235_FOCAL_LENGTH_NUM 278     /*2.78mm*/
43 #define GC2235_FOCAL_LENGTH_DEM 100
44 #define GC2235_F_NUMBER_DEFAULT_NUM     26
45 #define GC2235_F_NUMBER_DEM     10
46
47 #define MAX_FMTS                1
48
49 /*
50  * focal length bits definition:
51  * bits 31-16: numerator, bits 15-0: denominator
52  */
53 #define GC2235_FOCAL_LENGTH_DEFAULT 0x1160064
54
55 /*
56  * current f-number bits definition:
57  * bits 31-16: numerator, bits 15-0: denominator
58  */
59 #define GC2235_F_NUMBER_DEFAULT 0x1a000a
60
61 /*
62  * f-number range bits definition:
63  * bits 31-24: max f-number numerator
64  * bits 23-16: max f-number denominator
65  * bits 15-8: min f-number numerator
66  * bits 7-0: min f-number denominator
67  */
68 #define GC2235_F_NUMBER_RANGE 0x1a0a1a0a
69 #define GC2235_ID       0x2235
70
71 #define GC2235_FINE_INTG_TIME_MIN 0
72 #define GC2235_FINE_INTG_TIME_MAX_MARGIN 0
73 #define GC2235_COARSE_INTG_TIME_MIN 1
74 #define GC2235_COARSE_INTG_TIME_MAX_MARGIN 6
75
76 /*
77  * GC2235 System control registers
78  */
79 /*
80  * GC2235 System control registers
81  */
82 #define GC2235_SENSOR_ID_H              0xF0
83 #define GC2235_SENSOR_ID_L              0xF1
84 #define GC2235_RESET_RELATED            0xFE
85 #define GC2235_SW_RESET                 0x8
86 #define GC2235_MIPI_RESET               0x3
87 #define GC2235_RESET_BIT                0x4
88 #define GC2235_REGISTER_PAGE_0          0x0
89 #define GC2235_REGISTER_PAGE_3          0x3
90
91 #define GC2235_V_CROP_START_H           0x91
92 #define GC2235_V_CROP_START_L           0x92
93 #define GC2235_H_CROP_START_H           0x93
94 #define GC2235_H_CROP_START_L           0x94
95 #define GC2235_V_OUTSIZE_H              0x95
96 #define GC2235_V_OUTSIZE_L              0x96
97 #define GC2235_H_OUTSIZE_H              0x97
98 #define GC2235_H_OUTSIZE_L              0x98
99
100 #define GC2235_HB_H                     0x5
101 #define GC2235_HB_L                     0x6
102 #define GC2235_VB_H                     0x7
103 #define GC2235_VB_L                     0x8
104 #define GC2235_SH_DELAY_H               0x11
105 #define GC2235_SH_DELAY_L               0x12
106
107 #define GC2235_CSI2_MODE                0x10
108
109 #define GC2235_EXPOSURE_H               0x3
110 #define GC2235_EXPOSURE_L               0x4
111 #define GC2235_GLOBAL_GAIN              0xB0
112 #define GC2235_PRE_GAIN                 0xB1
113 #define GC2235_AWB_R_GAIN               0xB3
114 #define GC2235_AWB_G_GAIN               0xB4
115 #define GC2235_AWB_B_GAIN               0xB5
116
117 #define GC2235_START_STREAMING          0x91
118 #define GC2235_STOP_STREAMING           0x0
119
120 struct regval_list {
121         u16 reg_num;
122         u8 value;
123 };
124
125 struct gc2235_resolution {
126         u8 *desc;
127         const struct gc2235_reg *regs;
128         int res;
129         int width;
130         int height;
131         int fps;
132         int pix_clk_freq;
133         u32 skip_frames;
134         u16 pixels_per_line;
135         u16 lines_per_frame;
136         u8 bin_factor_x;
137         u8 bin_factor_y;
138         u8 bin_mode;
139         bool used;
140 };
141
142 struct gc2235_format {
143         u8 *desc;
144         u32 pixelformat;
145         struct gc2235_reg *regs;
146 };
147
148 /*
149  * gc2235 device structure.
150  */
151 struct gc2235_device {
152         struct v4l2_subdev sd;
153         struct media_pad pad;
154         struct v4l2_mbus_framefmt format;
155         struct mutex input_lock;
156         struct v4l2_ctrl_handler ctrl_handler;
157
158         struct camera_sensor_platform_data *platform_data;
159         int vt_pix_clk_freq_mhz;
160         int fmt_idx;
161         int run_mode;
162         u8 res;
163         u8 type;
164 };
165
166 enum gc2235_tok_type {
167         GC2235_8BIT  = 0x0001,
168         GC2235_16BIT = 0x0002,
169         GC2235_32BIT = 0x0004,
170         GC2235_TOK_TERM   = 0xf000,     /* terminating token for reg list */
171         GC2235_TOK_DELAY  = 0xfe00,     /* delay token for reg list */
172         GC2235_TOK_MASK = 0xfff0
173 };
174
175 /**
176  * struct gc2235_reg - MI sensor  register format
177  * @type: type of the register
178  * @reg: 8-bit offset to register
179  * @val: 8/16/32-bit register value
180  *
181  * Define a structure for sensor register initialization values
182  */
183 struct gc2235_reg {
184         enum gc2235_tok_type type;
185         u8 reg;
186         u32 val;        /* @set value for read/mod/write, @mask */
187 };
188
189 #define to_gc2235_sensor(x) container_of(x, struct gc2235_device, sd)
190
191 #define GC2235_MAX_WRITE_BUF_SIZE       30
192
193 struct gc2235_write_buffer {
194         u8 addr;
195         u8 data[GC2235_MAX_WRITE_BUF_SIZE];
196 };
197
198 struct gc2235_write_ctrl {
199         int index;
200         struct gc2235_write_buffer buffer;
201 };
202
203 static const struct i2c_device_id gc2235_id[] = {
204         {GC2235_NAME, 0},
205         {}
206 };
207
208 static struct gc2235_reg const gc2235_stream_on[] = {
209         { GC2235_8BIT, 0xfe, 0x03}, /* switch to P3 */
210         { GC2235_8BIT, 0x10, 0x91}, /* start mipi */
211         { GC2235_8BIT, 0xfe, 0x00}, /* switch to P0 */
212         { GC2235_TOK_TERM, 0, 0 }
213 };
214
215 static struct gc2235_reg const gc2235_stream_off[] = {
216         { GC2235_8BIT, 0xfe, 0x03}, /* switch to P3 */
217         { GC2235_8BIT, 0x10, 0x01}, /* stop mipi */
218         { GC2235_8BIT, 0xfe, 0x00}, /* switch to P0 */
219         { GC2235_TOK_TERM, 0, 0 }
220 };
221
222 static struct gc2235_reg const gc2235_init_settings[] = {
223         /* Sysytem */
224         { GC2235_8BIT, 0xfe, 0x80 },
225         { GC2235_8BIT, 0xfe, 0x80 },
226         { GC2235_8BIT, 0xfe, 0x80 },
227         { GC2235_8BIT, 0xf2, 0x00 },
228         { GC2235_8BIT, 0xf6, 0x00 },
229         { GC2235_8BIT, 0xfc, 0x06 },
230         { GC2235_8BIT, 0xf7, 0x15 },
231         { GC2235_8BIT, 0xf8, 0x84 },
232         { GC2235_8BIT, 0xf9, 0xfe },
233         { GC2235_8BIT, 0xfa, 0x00 },
234         { GC2235_8BIT, 0xfe, 0x00 },
235         /* Analog & cisctl */
236         { GC2235_8BIT, 0x03, 0x04 },
237         { GC2235_8BIT, 0x04, 0x9E },
238         { GC2235_8BIT, 0x05, 0x00 },
239         { GC2235_8BIT, 0x06, 0xfd },
240         { GC2235_8BIT, 0x07, 0x00 },
241         { GC2235_8BIT, 0x08, 0x14 },
242         { GC2235_8BIT, 0x0a, 0x02 }, /* row start */
243         { GC2235_8BIT, 0x0c, 0x00 }, /* col start */
244         { GC2235_8BIT, 0x0d, 0x04 }, /* win height 1232 */
245         { GC2235_8BIT, 0x0e, 0xd0 },
246         { GC2235_8BIT, 0x0f, 0x06 }, /* win width: 1616 */
247         { GC2235_8BIT, 0x10, 0x60 },
248         { GC2235_8BIT, 0x17, 0x15 }, /* mirror flip */
249         { GC2235_8BIT, 0x18, 0x1a },
250         { GC2235_8BIT, 0x19, 0x06 },
251         { GC2235_8BIT, 0x1a, 0x01 },
252         { GC2235_8BIT, 0x1b, 0x4d },
253         { GC2235_8BIT, 0x1e, 0x88 },
254         { GC2235_8BIT, 0x1f, 0x48 },
255         { GC2235_8BIT, 0x20, 0x03 },
256         { GC2235_8BIT, 0x21, 0x7f },
257         { GC2235_8BIT, 0x22, 0x83 },
258         { GC2235_8BIT, 0x23, 0x42 },
259         { GC2235_8BIT, 0x24, 0x16 },
260         { GC2235_8BIT, 0x26, 0x01 }, /*analog gain*/
261         { GC2235_8BIT, 0x27, 0x30 },
262         { GC2235_8BIT, 0x3f, 0x00 }, /* PRC */
263         /* blk */
264         { GC2235_8BIT, 0x40, 0xa3 },
265         { GC2235_8BIT, 0x41, 0x82 },
266         { GC2235_8BIT, 0x43, 0x20 },
267         { GC2235_8BIT, 0x5e, 0x18 },
268         { GC2235_8BIT, 0x5f, 0x18 },
269         { GC2235_8BIT, 0x60, 0x18 },
270         { GC2235_8BIT, 0x61, 0x18 },
271         { GC2235_8BIT, 0x62, 0x18 },
272         { GC2235_8BIT, 0x63, 0x18 },
273         { GC2235_8BIT, 0x64, 0x18 },
274         { GC2235_8BIT, 0x65, 0x18 },
275         { GC2235_8BIT, 0x66, 0x20 },
276         { GC2235_8BIT, 0x67, 0x20 },
277         { GC2235_8BIT, 0x68, 0x20 },
278         { GC2235_8BIT, 0x69, 0x20 },
279         /* Gain */
280         { GC2235_8BIT, 0xb2, 0x00 },
281         { GC2235_8BIT, 0xb3, 0x40 },
282         { GC2235_8BIT, 0xb4, 0x40 },
283         { GC2235_8BIT, 0xb5, 0x40 },
284         /* Dark sun */
285         { GC2235_8BIT, 0xbc, 0x00 },
286
287         { GC2235_8BIT, 0xfe, 0x03 },
288         { GC2235_8BIT, 0x10, 0x01 }, /* disable mipi */
289         { GC2235_8BIT, 0xfe, 0x00 }, /* switch to P0 */
290         { GC2235_TOK_TERM, 0, 0 }
291 };
292 /*
293  * Register settings for various resolution
294  */
295 static struct gc2235_reg const gc2235_1296_736_30fps[] = {
296         { GC2235_8BIT, 0x8b, 0xa0 },
297         { GC2235_8BIT, 0x8c, 0x02 },
298
299         { GC2235_8BIT, 0x07, 0x01 }, /* VBI */
300         { GC2235_8BIT, 0x08, 0x44 },
301         { GC2235_8BIT, 0x09, 0x00 }, /* row start */
302         { GC2235_8BIT, 0x0a, 0xf0 },
303         { GC2235_8BIT, 0x0b, 0x00 }, /* col start */
304         { GC2235_8BIT, 0x0c, 0xa0 },
305         { GC2235_8BIT, 0x0d, 0x02 }, /* win height 736 */
306         { GC2235_8BIT, 0x0e, 0xf0 },
307         { GC2235_8BIT, 0x0f, 0x05 }, /* win width: 1296 */
308         { GC2235_8BIT, 0x10, 0x20 },
309
310         { GC2235_8BIT, 0x90, 0x01 },
311         { GC2235_8BIT, 0x92, 0x08 },
312         { GC2235_8BIT, 0x94, 0x08 },
313         { GC2235_8BIT, 0x95, 0x02 }, /* crop win height 736 */
314         { GC2235_8BIT, 0x96, 0xe0 },
315         { GC2235_8BIT, 0x97, 0x05 }, /* crop win width 1296 */
316         { GC2235_8BIT, 0x98, 0x10 },
317         /* mimi init */
318         { GC2235_8BIT, 0xfe, 0x03 }, /* switch to P3 */
319         { GC2235_8BIT, 0x01, 0x07 },
320         { GC2235_8BIT, 0x02, 0x11 },
321         { GC2235_8BIT, 0x03, 0x11 },
322         { GC2235_8BIT, 0x06, 0x80 },
323         { GC2235_8BIT, 0x11, 0x2b },
324         /* set mipi buffer */
325         { GC2235_8BIT, 0x12, 0x54 }, /* val_low = (width * 10 / 8) & 0xFF */
326         { GC2235_8BIT, 0x13, 0x06 }, /* val_high = (width * 10 / 8) >> 8 */
327
328         { GC2235_8BIT, 0x15, 0x12 }, /* DPHY mode*/
329         { GC2235_8BIT, 0x04, 0x10 },
330         { GC2235_8BIT, 0x05, 0x00 },
331         { GC2235_8BIT, 0x17, 0x01 },
332
333         { GC2235_8BIT, 0x22, 0x01 },
334         { GC2235_8BIT, 0x23, 0x05 },
335         { GC2235_8BIT, 0x24, 0x10 },
336         { GC2235_8BIT, 0x25, 0x10 },
337         { GC2235_8BIT, 0x26, 0x02 },
338         { GC2235_8BIT, 0x21, 0x10 },
339         { GC2235_8BIT, 0x29, 0x01 },
340         { GC2235_8BIT, 0x2a, 0x02 },
341         { GC2235_8BIT, 0x2b, 0x02 },
342
343         { GC2235_8BIT, 0x10, 0x01 }, /* disable mipi */
344         { GC2235_8BIT, 0xfe, 0x00 }, /* switch to P0 */
345         { GC2235_TOK_TERM, 0, 0 }
346 };
347
348 static struct gc2235_reg const gc2235_960_640_30fps[] = {
349         { GC2235_8BIT, 0x8b, 0xa0 },
350         { GC2235_8BIT, 0x8c, 0x02 },
351
352         { GC2235_8BIT, 0x07, 0x02 }, /* VBI */
353         { GC2235_8BIT, 0x08, 0xA4 },
354         { GC2235_8BIT, 0x09, 0x01 }, /* row start */
355         { GC2235_8BIT, 0x0a, 0x18 },
356         { GC2235_8BIT, 0x0b, 0x01 }, /* col start */
357         { GC2235_8BIT, 0x0c, 0x40 },
358         { GC2235_8BIT, 0x0d, 0x02 }, /* win height 656 */
359         { GC2235_8BIT, 0x0e, 0x90 },
360         { GC2235_8BIT, 0x0f, 0x03 }, /* win width: 976 */
361         { GC2235_8BIT, 0x10, 0xd0 },
362
363         { GC2235_8BIT, 0x90, 0x01 },
364         { GC2235_8BIT, 0x92, 0x02 },
365         { GC2235_8BIT, 0x94, 0x06 },
366         { GC2235_8BIT, 0x95, 0x02 }, /* crop win height 640 */
367         { GC2235_8BIT, 0x96, 0x80 },
368         { GC2235_8BIT, 0x97, 0x03 }, /* crop win width 960 */
369         { GC2235_8BIT, 0x98, 0xc0 },
370         /* mimp init */
371         { GC2235_8BIT, 0xfe, 0x03 }, /* switch to P3 */
372         { GC2235_8BIT, 0x01, 0x07 },
373         { GC2235_8BIT, 0x02, 0x11 },
374         { GC2235_8BIT, 0x03, 0x11 },
375         { GC2235_8BIT, 0x06, 0x80 },
376         { GC2235_8BIT, 0x11, 0x2b },
377         /* set mipi buffer */
378         { GC2235_8BIT, 0x12, 0xb0 }, /* val_low = (width * 10 / 8) & 0xFF */
379         { GC2235_8BIT, 0x13, 0x04 }, /* val_high = (width * 10 / 8) >> 8 */
380
381         { GC2235_8BIT, 0x15, 0x12 }, /* DPHY mode*/
382         { GC2235_8BIT, 0x04, 0x10 },
383         { GC2235_8BIT, 0x05, 0x00 },
384         { GC2235_8BIT, 0x17, 0x01 },
385         { GC2235_8BIT, 0x22, 0x01 },
386         { GC2235_8BIT, 0x23, 0x05 },
387         { GC2235_8BIT, 0x24, 0x10 },
388         { GC2235_8BIT, 0x25, 0x10 },
389         { GC2235_8BIT, 0x26, 0x02 },
390         { GC2235_8BIT, 0x21, 0x10 },
391         { GC2235_8BIT, 0x29, 0x01 },
392         { GC2235_8BIT, 0x2a, 0x02 },
393         { GC2235_8BIT, 0x2b, 0x02 },
394         { GC2235_8BIT, 0x10, 0x01 }, /* disable mipi */
395         { GC2235_8BIT, 0xfe, 0x00 }, /* switch to P0 */
396         { GC2235_TOK_TERM, 0, 0 }
397 };
398
399 static struct gc2235_reg const gc2235_1600_900_30fps[] = {
400         { GC2235_8BIT, 0x8b, 0xa0 },
401         { GC2235_8BIT, 0x8c, 0x02 },
402
403         { GC2235_8BIT, 0x0d, 0x03 }, /* win height 932 */
404         { GC2235_8BIT, 0x0e, 0xa4 },
405         { GC2235_8BIT, 0x0f, 0x06 }, /* win width: 1632 */
406         { GC2235_8BIT, 0x10, 0x50 },
407
408         { GC2235_8BIT, 0x90, 0x01 },
409         { GC2235_8BIT, 0x92, 0x02 },
410         { GC2235_8BIT, 0x94, 0x06 },
411         { GC2235_8BIT, 0x95, 0x03 }, /* crop win height 900 */
412         { GC2235_8BIT, 0x96, 0x84 },
413         { GC2235_8BIT, 0x97, 0x06 }, /* crop win width 1600 */
414         { GC2235_8BIT, 0x98, 0x40 },
415         /* mimi init */
416         { GC2235_8BIT, 0xfe, 0x03 }, /* switch to P3 */
417         { GC2235_8BIT, 0x01, 0x07 },
418         { GC2235_8BIT, 0x02, 0x11 },
419         { GC2235_8BIT, 0x03, 0x11 },
420         { GC2235_8BIT, 0x06, 0x80 },
421         { GC2235_8BIT, 0x11, 0x2b },
422         /* set mipi buffer */
423         { GC2235_8BIT, 0x12, 0xd0 }, /* val_low = (width * 10 / 8) & 0xFF */
424         { GC2235_8BIT, 0x13, 0x07 }, /* val_high = (width * 10 / 8) >> 8 */
425
426         { GC2235_8BIT, 0x15, 0x12 }, /* DPHY mode*/
427         { GC2235_8BIT, 0x04, 0x10 },
428         { GC2235_8BIT, 0x05, 0x00 },
429         { GC2235_8BIT, 0x17, 0x01 },
430         { GC2235_8BIT, 0x22, 0x01 },
431         { GC2235_8BIT, 0x23, 0x05 },
432         { GC2235_8BIT, 0x24, 0x10 },
433         { GC2235_8BIT, 0x25, 0x10 },
434         { GC2235_8BIT, 0x26, 0x02 },
435         { GC2235_8BIT, 0x21, 0x10 },
436         { GC2235_8BIT, 0x29, 0x01 },
437         { GC2235_8BIT, 0x2a, 0x02 },
438         { GC2235_8BIT, 0x2b, 0x02 },
439         { GC2235_8BIT, 0x10, 0x01 }, /* disable mipi */
440         { GC2235_8BIT, 0xfe, 0x00 }, /* switch to P0 */
441         { GC2235_TOK_TERM, 0, 0 }
442 };
443
444 static struct gc2235_reg const gc2235_1616_1082_30fps[] = {
445         { GC2235_8BIT, 0x8b, 0xa0 },
446         { GC2235_8BIT, 0x8c, 0x02 },
447
448         { GC2235_8BIT, 0x0d, 0x04 }, /* win height 1232 */
449         { GC2235_8BIT, 0x0e, 0xd0 },
450         { GC2235_8BIT, 0x0f, 0x06 }, /* win width: 1616 */
451         { GC2235_8BIT, 0x10, 0x50 },
452
453         { GC2235_8BIT, 0x90, 0x01 },
454         { GC2235_8BIT, 0x92, 0x4a },
455         { GC2235_8BIT, 0x94, 0x00 },
456         { GC2235_8BIT, 0x95, 0x04 }, /* crop win height 1082 */
457         { GC2235_8BIT, 0x96, 0x3a },
458         { GC2235_8BIT, 0x97, 0x06 }, /* crop win width 1616 */
459         { GC2235_8BIT, 0x98, 0x50 },
460         /* mimp init */
461         { GC2235_8BIT, 0xfe, 0x03 }, /* switch to P3 */
462         { GC2235_8BIT, 0x01, 0x07 },
463         { GC2235_8BIT, 0x02, 0x11 },
464         { GC2235_8BIT, 0x03, 0x11 },
465         { GC2235_8BIT, 0x06, 0x80 },
466         { GC2235_8BIT, 0x11, 0x2b },
467         /* set mipi buffer */
468         { GC2235_8BIT, 0x12, 0xe4 }, /* val_low = (width * 10 / 8) & 0xFF */
469         { GC2235_8BIT, 0x13, 0x07 }, /* val_high = (width * 10 / 8) >> 8 */
470
471         { GC2235_8BIT, 0x15, 0x12 }, /* DPHY mode*/
472         { GC2235_8BIT, 0x04, 0x10 },
473         { GC2235_8BIT, 0x05, 0x00 },
474         { GC2235_8BIT, 0x17, 0x01 },
475         { GC2235_8BIT, 0x22, 0x01 },
476         { GC2235_8BIT, 0x23, 0x05 },
477         { GC2235_8BIT, 0x24, 0x10 },
478         { GC2235_8BIT, 0x25, 0x10 },
479         { GC2235_8BIT, 0x26, 0x02 },
480         { GC2235_8BIT, 0x21, 0x10 },
481         { GC2235_8BIT, 0x29, 0x01 },
482         { GC2235_8BIT, 0x2a, 0x02 },
483         { GC2235_8BIT, 0x2b, 0x02 },
484         { GC2235_8BIT, 0x10, 0x01 }, /* disable mipi */
485         { GC2235_8BIT, 0xfe, 0x00 }, /* switch to P0 */
486         { GC2235_TOK_TERM, 0, 0 }
487 };
488
489 static struct gc2235_reg const gc2235_1616_1216_30fps[] = {
490         { GC2235_8BIT, 0x8b, 0xa0 },
491         { GC2235_8BIT, 0x8c, 0x02 },
492
493         { GC2235_8BIT, 0x0d, 0x04 }, /* win height 1232 */
494         { GC2235_8BIT, 0x0e, 0xd0 },
495         { GC2235_8BIT, 0x0f, 0x06 }, /* win width: 1616 */
496         { GC2235_8BIT, 0x10, 0x50 },
497
498         { GC2235_8BIT, 0x90, 0x01 },
499         { GC2235_8BIT, 0x92, 0x02 },
500         { GC2235_8BIT, 0x94, 0x00 },
501         { GC2235_8BIT, 0x95, 0x04 }, /* crop win height 1216 */
502         { GC2235_8BIT, 0x96, 0xc0 },
503         { GC2235_8BIT, 0x97, 0x06 }, /* crop win width 1616 */
504         { GC2235_8BIT, 0x98, 0x50 },
505         /* mimi init */
506         { GC2235_8BIT, 0xfe, 0x03 }, /* switch to P3 */
507         { GC2235_8BIT, 0x01, 0x07 },
508         { GC2235_8BIT, 0x02, 0x11 },
509         { GC2235_8BIT, 0x03, 0x11 },
510         { GC2235_8BIT, 0x06, 0x80 },
511         { GC2235_8BIT, 0x11, 0x2b },
512         /* set mipi buffer */
513         { GC2235_8BIT, 0x12, 0xe4 }, /* val_low = (width * 10 / 8) & 0xFF */
514         { GC2235_8BIT, 0x13, 0x07 }, /* val_high = (width * 10 / 8) >> 8 */
515         { GC2235_8BIT, 0x15, 0x12 }, /* DPHY mode*/
516         { GC2235_8BIT, 0x04, 0x10 },
517         { GC2235_8BIT, 0x05, 0x00 },
518         { GC2235_8BIT, 0x17, 0x01 },
519         { GC2235_8BIT, 0x22, 0x01 },
520         { GC2235_8BIT, 0x23, 0x05 },
521         { GC2235_8BIT, 0x24, 0x10 },
522         { GC2235_8BIT, 0x25, 0x10 },
523         { GC2235_8BIT, 0x26, 0x02 },
524         { GC2235_8BIT, 0x21, 0x10 },
525         { GC2235_8BIT, 0x29, 0x01 },
526         { GC2235_8BIT, 0x2a, 0x02 },
527         { GC2235_8BIT, 0x2b, 0x02 },
528         { GC2235_8BIT, 0x10, 0x01 }, /* disable mipi */
529         { GC2235_8BIT, 0xfe, 0x00 }, /* switch to P0 */
530         { GC2235_TOK_TERM, 0, 0 }
531 };
532
533 struct gc2235_resolution gc2235_res_preview[] = {
534
535         {
536                 .desc = "gc2235_1600_900_30fps",
537                 .width = 1600,
538                 .height = 900,
539                 .pix_clk_freq = 30,
540                 .fps = 30,
541                 .used = 0,
542                 .pixels_per_line = 2132,
543                 .lines_per_frame = 1068,
544                 .bin_factor_x = 0,
545                 .bin_factor_y = 0,
546                 .bin_mode = 0,
547                 .skip_frames = 3,
548                 .regs = gc2235_1600_900_30fps,
549         },
550
551         {
552                 .desc = "gc2235_1600_1066_30fps",
553                 .width = 1616,
554                 .height = 1082,
555                 .pix_clk_freq = 30,
556                 .fps = 30,
557                 .used = 0,
558                 .pixels_per_line = 2132,
559                 .lines_per_frame = 1368,
560                 .bin_factor_x = 0,
561                 .bin_factor_y = 0,
562                 .bin_mode = 0,
563                 .skip_frames = 3,
564                 .regs = gc2235_1616_1082_30fps,
565         },
566         {
567                 .desc = "gc2235_1600_1200_30fps",
568                 .width = 1616,
569                 .height = 1216,
570                 .pix_clk_freq = 30,
571                 .fps = 30,
572                 .used = 0,
573                 .pixels_per_line = 2132,
574                 .lines_per_frame = 1368,
575                 .bin_factor_x = 0,
576                 .bin_factor_y = 0,
577                 .bin_mode = 0,
578                 .skip_frames = 3,
579                 .regs = gc2235_1616_1216_30fps,
580         },
581
582 };
583 #define N_RES_PREVIEW (ARRAY_SIZE(gc2235_res_preview))
584
585 struct gc2235_resolution gc2235_res_still[] = {
586         {
587                 .desc = "gc2235_1600_900_30fps",
588                 .width = 1600,
589                 .height = 900,
590                 .pix_clk_freq = 30,
591                 .fps = 30,
592                 .used = 0,
593                 .pixels_per_line = 2132,
594                 .lines_per_frame = 1068,
595                 .bin_factor_x = 0,
596                 .bin_factor_y = 0,
597                 .bin_mode = 0,
598                 .skip_frames = 3,
599                 .regs = gc2235_1600_900_30fps,
600         },
601         {
602                 .desc = "gc2235_1600_1066_30fps",
603                 .width = 1616,
604                 .height = 1082,
605                 .pix_clk_freq = 30,
606                 .fps = 30,
607                 .used = 0,
608                 .pixels_per_line = 2132,
609                 .lines_per_frame = 1368,
610                 .bin_factor_x = 0,
611                 .bin_factor_y = 0,
612                 .bin_mode = 0,
613                 .skip_frames = 3,
614                 .regs = gc2235_1616_1082_30fps,
615         },
616         {
617                 .desc = "gc2235_1600_1200_30fps",
618                 .width = 1616,
619                 .height = 1216,
620                 .pix_clk_freq = 30,
621                 .fps = 30,
622                 .used = 0,
623                 .pixels_per_line = 2132,
624                 .lines_per_frame = 1368,
625                 .bin_factor_x = 0,
626                 .bin_factor_y = 0,
627                 .bin_mode = 0,
628                 .skip_frames = 3,
629                 .regs = gc2235_1616_1216_30fps,
630         },
631
632 };
633 #define N_RES_STILL (ARRAY_SIZE(gc2235_res_still))
634
635 struct gc2235_resolution gc2235_res_video[] = {
636         {
637                 .desc = "gc2235_1296_736_30fps",
638                 .width = 1296,
639                 .height = 736,
640                 .pix_clk_freq = 30,
641                 .fps = 30,
642                 .used = 0,
643                 .pixels_per_line = 1828,
644                 .lines_per_frame = 888,
645                 .bin_factor_x = 0,
646                 .bin_factor_y = 0,
647                 .bin_mode = 0,
648                 .skip_frames = 3,
649                 .regs = gc2235_1296_736_30fps,
650         },
651         {
652                 .desc = "gc2235_960_640_30fps",
653                 .width = 960,
654                 .height = 640,
655                 .pix_clk_freq = 30,
656                 .fps = 30,
657                 .used = 0,
658                 .pixels_per_line = 1492,
659                 .lines_per_frame = 792,
660                 .bin_factor_x = 0,
661                 .bin_factor_y = 0,
662                 .bin_mode = 0,
663                 .skip_frames = 3,
664                 .regs = gc2235_960_640_30fps,
665         },
666
667 };
668 #define N_RES_VIDEO (ARRAY_SIZE(gc2235_res_video))
669
670 static struct gc2235_resolution *gc2235_res = gc2235_res_preview;
671 static unsigned long N_RES = N_RES_PREVIEW;
672 #endif