rk312x : delay some time when sensor resolution is changed for gc2035.
[firefly-linux-kernel-4.4.55.git] / drivers / media / video / gc2035.c
1 \r
2 #include "generic_sensor.h"\r
3 \r
4 /*
5 *      Driver Version Note\r
6 *v0.0.1: this driver is compatible with generic_sensor\r
7 *v0.0.3:\r
8 *        add sensor_focus_af_const_pause_usr_cb;\r
9 */\r
10 static int version = KERNEL_VERSION(0,0,3);\r
11 module_param(version, int, S_IRUGO);\r
12 \r
13 \r
14 static int debug;\r
15 module_param(debug, int, S_IRUGO|S_IWUSR);\r
16 \r
17 #define dprintk(level, fmt, arg...) do {                        \\r
18         if (debug >= level)                                     \\r
19         printk(KERN_WARNING fmt , ## arg); } while (0)\r
20 \r
21 /* Sensor Driver Configuration Begin */\r
22 #define SENSOR_NAME RK29_CAM_SENSOR_GC2035\r
23 #define SENSOR_V4L2_IDENT V4L2_IDENT_GC2035\r
24 #define SENSOR_ID 0x2035\r
25 #define SENSOR_BUS_PARAM                     (V4L2_MBUS_MASTER |\\r
26                                                                                                                  V4L2_MBUS_PCLK_SAMPLE_RISING|V4L2_MBUS_HSYNC_ACTIVE_HIGH| V4L2_MBUS_VSYNC_ACTIVE_HIGH|\\r
27                                                                                                                  V4L2_MBUS_DATA_ACTIVE_HIGH | SOCAM_DATAWIDTH_8  |SOCAM_MCLK_24MHZ)\r
28 #define SENSOR_PREVIEW_W                                         800\r
29 #define SENSOR_PREVIEW_H                                         600\r
30 #define SENSOR_PREVIEW_FPS                                       15000     // 15fps \r
31 #define SENSOR_FULLRES_L_FPS                             7500      // 7.5fps\r
32 #define SENSOR_FULLRES_H_FPS                             7500      // 7.5fps\r
33 #define SENSOR_720P_FPS                                          0\r
34 #define SENSOR_1080P_FPS                                         0\r
35 \r
36 #define SENSOR_REGISTER_LEN                              1                 // sensor register address bytes\r
37 #define SENSOR_VALUE_LEN                                         1                 // sensor register value bytes\r
38 static unsigned int SensorConfiguration = (CFG_WhiteBalance|CFG_Effect|CFG_Scene);\r
39 static unsigned int SensorChipID[] = {SENSOR_ID};\r
40 /* Sensor Driver Configuration End */\r
41 \r
42 \r
43 #define SENSOR_NAME_STRING(a) STR(CONS(SENSOR_NAME, a))\r
44 #define SENSOR_NAME_VARFUN(a) CONS(SENSOR_NAME, a)\r
45 \r
46 #define SensorRegVal(a,b) CONS4(SensorReg,SENSOR_REGISTER_LEN,Val,SENSOR_VALUE_LEN)(a,b)\r
47 #define sensor_write(client,reg,v) CONS4(sensor_write_reg,SENSOR_REGISTER_LEN,val,SENSOR_VALUE_LEN)(client,(reg),(v))\r
48 #define sensor_read(client,reg,v) CONS4(sensor_read_reg,SENSOR_REGISTER_LEN,val,SENSOR_VALUE_LEN)(client,(reg),(v))\r
49 #define sensor_write_array generic_sensor_write_array\r
50 \r
51 struct sensor_parameter\r
52 {\r
53         unsigned int PreviewDummyPixels;\r
54         unsigned int CaptureDummyPixels;\r
55         unsigned int preview_exposure;\r
56         unsigned short int preview_line_width;\r
57         unsigned short int preview_gain;\r
58 \r
59         unsigned short int PreviewPclk;\r
60         unsigned short int CapturePclk;\r
61         char awb[6];\r
62 };\r
63 \r
64 struct specific_sensor{\r
65         struct generic_sensor common_sensor;\r
66         //define user data below\r
67         struct sensor_parameter parameter;\r
68         u16 shutter;\r
69 \r
70 };\r
71 \r
72 /*\r
73 *  The follow setting need been filled.\r
74 *  \r
75 *  Must Filled:\r
76 *  sensor_init_data :                           Sensor initial setting;\r
77 *  sensor_fullres_lowfps_data :         Sensor full resolution setting with best auality, recommand for video;\r
78 *  sensor_preview_data :                        Sensor preview resolution setting, recommand it is vga or svga;\r
79 *  sensor_softreset_data :                      Sensor software reset register;\r
80 *  sensor_check_id_data :                       Sensir chip id register;\r
81 *\r
82 *  Optional filled:\r
83 *  sensor_fullres_highfps_data:         Sensor full resolution setting with high framerate, recommand for video;\r
84 *  sensor_720p:                                         Sensor 720p setting, it is for video;\r
85 *  sensor_1080p:                                        Sensor 1080p setting, it is for video;\r
86 *\r
87 *  :::::WARNING:::::\r
88 *  The SensorEnd which is the setting end flag must be filled int the last of each setting;\r
89 */\r
90 \r
91 /* Sensor initial setting */\r
92 static struct rk_sensor_reg sensor_init_data[] =\r
93 {\r
94         {0xfe , 0x80},\r
95         {0xfe , 0x80},\r
96         {0xfe , 0x80},  \r
97         {0xfc , 0x06},\r
98         {0xf2 , 0x00},\r
99         {0xf3 , 0x00},\r
100         {0xf4 , 0x00},\r
101         {0xf5 , 0x00},\r
102         {0xf9 , 0xfe}, //[0] pll enable\r
103         {0xfa , 0x00},\r
104         {0xf6 , 0x00},\r
105         {0xf7 , 0x15}, //pll enable\r
106 \r
107         {0xf8 , 0x85},\r
108         {0xfe , 0x00},\r
109         {0x82 , 0x00},\r
110         {0xb3 , 0x60},\r
111         {0xb4 , 0x40},\r
112         {0xb5 , 0x60},\r
113 \r
114         {0x03 , 0x02},\r
115         {0x04 , 0x80},\r
116 \r
117         //////////measure window  ///////////\r
118         {0xfe , 0x00},\r
119         {0xec , 0x06},//04 \r
120         {0xed , 0x06},//04 \r
121         {0xee , 0x62},//60 \r
122         {0xef , 0x92},//90 \r
123 \r
124         ///////////analog/////////////\r
125         {0x0a , 0x00}, //row start\r
126         {0x0c , 0x00}, //col start\r
127         {0x0d , 0x04},\r
128         {0x0e , 0xc0},\r
129         {0x0f , 0x06}, //Window setting\r
130         {0x10 , 0x58}, \r
131         {0x17 , 0x14}, //[0]mirror [1]flip\r
132 \r
133 \r
134         {0x18 , 0x0e}, //sdark 4 row in even frame??\r
135         {0x19 , 0x0c}, //AD pipe number\r
136 \r
137         /*\r
138         ///  Ã«´Ì ÏÖÏó\r
139         {0x18 , 0x0a}, //sdark 4 row in even frame??\r
140         {0x19 , 0x0a}, //AD pipe number\r
141         */\r
142         \r
143         {0x1a , 0x01}, //CISCTL mode4\r
144         {0x1b , 0x8b},\r
145         {0x1e , 0x88}, //analog mode1 [7] tx-high en [5:3]COL_bias\r
146         {0x1f , 0x08}, //[3] tx-low en//\r
147         {0x20 , 0x05}, //[0]adclk mode , 0x[1]rowclk_MODE [2]rsthigh_en\r
148         {0x21 , 0x0f}, //[6:4]rsg\r
149         {0x22 , 0xf0}, //[3:0]vref\r
150         {0x23 , 0xc3}, //f3//ADC_r\r
151         {0x24 , 0x17}, //pad drive  16\r
152 \r
153         //AEC\r
154         {0xfe , 0x01},\r
155         {0x11 , 0x20},//AEC_out_slope , 0x\r
156         {0x1f , 0xc0},//max_post_gain\r
157         {0x20 , 0x60},//max_pre_gain\r
158         {0x47 , 0x30},//AEC_outdoor_th\r
159         {0x0b , 0x10},//\r
160         {0x13 , 0x75},//y_target\r
161         {0xfe , 0x00},\r
162 \r
163 \r
164         {0x05 , 0x01},//hb\r
165         {0x06 , 0x11},\r
166         {0x07 , 0x00},//vb\r
167         {0x08 , 0x50},\r
168         {0xfe , 0x01},\r
169         {0x27 , 0x00},//step\r
170         {0x28 , 0xa0},\r
171         {0x29 , 0x05},//level1\r
172         {0x2a , 0x00},\r
173         {0x2b , 0x05},//level2\r
174         {0x2c , 0x00},\r
175         {0x2d , 0x06},//6e8//level3\r
176         {0x2e , 0xe0},\r
177         {0x2f , 0x0a},//level4\r
178         {0x30 , 0x00},\r
179         {0x3e , 0x40},\r
180         {0xfe , 0x00},\r
181         {0xfe , 0x00},  //0x , 0x , 0x , 0x , 0x \r
182         {0xb6 , 0x03}, //AEC enable\r
183         {0xfe , 0x00},\r
184 \r
185         /////////BLK//////\r
186         {0x3f , 0x00}, //prc close\r
187         {0x40 , 0x77},//\r
188         {0x42 , 0x7f},\r
189         {0x43 , 0x30},\r
190         {0x5c , 0x08},\r
191         {0x5e , 0x20},\r
192         {0x5f , 0x20},\r
193         {0x60 , 0x20},\r
194         {0x61 , 0x20},\r
195         {0x62 , 0x20},\r
196         {0x63 , 0x20},\r
197         {0x64 , 0x20},\r
198         {0x65 , 0x20},\r
199 \r
200         ///block////////////\r
201         {0x80 , 0xff},\r
202         {0x81 , 0x26},//38 , 0x//skin_Y 8c_debug\r
203         {0x87 , 0x90}, //[7]middle gamma \r
204         {0x84 , 0x00}, //output put foramat\r
205         {0x86 , 0x07}, //02 //sync plority \r
206         {0x8b , 0xbc},\r
207         {0xb0 , 0x80}, //globle gain\r
208         {0xc0 , 0x40},//Yuv bypass\r
209 \r
210         //////lsc/////////////\r
211         {0xfe , 0x01},\r
212         {0xc2 , 0x38},\r
213         {0xc3 , 0x25},\r
214         {0xc4 , 0x21},\r
215         {0xc8 , 0x19},\r
216         {0xc9 , 0x12},\r
217         {0xca , 0x0e},\r
218         {0xbc , 0x43},\r
219         {0xbd , 0x18},\r
220         {0xbe , 0x1b},\r
221         {0xb6 , 0x40},\r
222         {0xb7 , 0x2e},\r
223         {0xb8 , 0x26},\r
224         {0xc5 , 0x05},\r
225         {0xc6 , 0x03},\r
226         {0xc7 , 0x04},\r
227         {0xcb , 0x00},\r
228         {0xcc , 0x00},\r
229         {0xcd , 0x00},\r
230         {0xbf , 0x14},\r
231         {0xc0 , 0x22},\r
232         {0xc1 , 0x1b},\r
233         {0xb9 , 0x00},\r
234         {0xba , 0x05},\r
235         {0xbb , 0x05},\r
236         {0xaa , 0x35},\r
237         {0xab , 0x33},\r
238         {0xac , 0x33},\r
239         {0xad , 0x25},\r
240         {0xae , 0x22},\r
241         {0xaf , 0x27},\r
242         {0xb0 , 0x1d},\r
243         {0xb1 , 0x20},\r
244         {0xb2 , 0x22},\r
245         {0xb3 , 0x14},\r
246         {0xb4 , 0x15},\r
247         {0xb5 , 0x16},\r
248         {0xd0 , 0x00},\r
249         {0xd2 , 0x07},\r
250         {0xd3 , 0x08},\r
251         {0xd8 , 0x00},\r
252         {0xda , 0x13},\r
253         {0xdb , 0x17},\r
254         {0xdc , 0x00},\r
255         {0xde , 0x0a},\r
256         {0xdf , 0x08},\r
257         {0xd4 , 0x00},\r
258         {0xd6 , 0x00},\r
259         {0xd7 , 0x0c},\r
260         {0xa4 , 0x00},\r
261         {0xa5 , 0x00},\r
262         {0xa6 , 0x00},\r
263         {0xa7 , 0x00},\r
264         {0xa8 , 0x00},\r
265         {0xa9 , 0x00},\r
266         {0xa1 , 0x80},\r
267         {0xa2 , 0x80},\r
268 \r
269         //////////cc//////////////\r
270         {0xfe , 0x02},\r
271         {0xc0 , 0x01},\r
272         {0xc1 , 0x40}, //Green_cc for d\r
273         {0xc2 , 0xfc},\r
274         {0xc3 , 0x05},\r
275         {0xc4 , 0xec},\r
276         {0xc5 , 0x42},\r
277         {0xc6 , 0xf8},\r
278         {0xc7 , 0x40},//for cwf \r
279         {0xc8 , 0xf8},\r
280         {0xc9 , 0x06},\r
281         {0xca , 0xfd},\r
282         {0xcb , 0x3e},\r
283         {0xcc , 0xf3},\r
284         {0xcd , 0x36},//for A\r
285         {0xce , 0xf6},\r
286         {0xcf , 0x04},\r
287         {0xe3 , 0x0c},\r
288         {0xe4 , 0x44},\r
289         {0xe5 , 0xe5},\r
290         {0xfe , 0x00},\r
291 \r
292         ///////awb start ////////////////\r
293         //AWB clear\r
294         {0xfe , 0x01},\r
295         {0x4f , 0x00},\r
296         {0x4d , 0x00},\r
297         {0x4e , 0x00},\r
298         {0x4e , 0x00},\r
299         {0x4e , 0x00},\r
300         {0x4e , 0x00},\r
301         {0x4e , 0x00},\r
302         {0x4e , 0x00},\r
303         {0x4e , 0x00},\r
304         {0x4e , 0x00},\r
305         {0x4e , 0x00},\r
306         {0x4e , 0x00},\r
307         {0x4e , 0x00},\r
308         {0x4e , 0x00},\r
309         {0x4e , 0x00},\r
310         {0x4e , 0x00},\r
311         {0x4e , 0x00},\r
312         {0x4e , 0x00},\r
313         {0x4d , 0x10}, // 10\r
314         {0x4e , 0x00},\r
315         {0x4e , 0x00},\r
316         {0x4e , 0x00},\r
317         {0x4e , 0x00},\r
318         {0x4e , 0x00},\r
319         {0x4e , 0x00},\r
320         {0x4e , 0x00},\r
321         {0x4e , 0x00},\r
322         {0x4e , 0x00},\r
323         {0x4e , 0x00},\r
324         {0x4e , 0x00},\r
325         {0x4e , 0x00},\r
326         {0x4e , 0x00},\r
327         {0x4e , 0x00},\r
328         {0x4e , 0x00},\r
329         {0x4e , 0x00},\r
330         {0x4d , 0x20}, // 20\r
331         {0x4e , 0x00},\r
332         {0x4e , 0x00},\r
333         {0x4e , 0x00},\r
334         {0x4e , 0x00},\r
335         {0x4e , 0x00},\r
336         {0x4e , 0x00},\r
337         {0x4e , 0x00},\r
338         {0x4e , 0x00},\r
339         {0x4e , 0x00},\r
340         {0x4e , 0x00},\r
341         {0x4e , 0x00},\r
342         {0x4e , 0x00},\r
343         {0x4e , 0x00},\r
344         {0x4e , 0x00},\r
345         {0x4e , 0x00},\r
346         {0x4e , 0x00},\r
347         {0x4d , 0x30},\r
348         {0x4e , 0x00},\r
349         {0x4e , 0x00},\r
350         {0x4e , 0x00},\r
351         {0x4e , 0x00}, // 30\r
352         {0x4e , 0x00},\r
353         {0x4e , 0x00},\r
354         {0x4e , 0x00},\r
355         {0x4e , 0x00},\r
356         {0x4e , 0x00},\r
357         {0x4e , 0x00},\r
358         {0x4e , 0x00},\r
359         {0x4e , 0x00},\r
360         {0x4e , 0x00},\r
361         {0x4e , 0x00},\r
362         {0x4e , 0x00},\r
363         {0x4e , 0x00},\r
364         {0x4d , 0x40}, // 40\r
365         {0x4e , 0x00},\r
366         {0x4e , 0x00},\r
367         {0x4e , 0x00},\r
368         {0x4e , 0x00},\r
369         {0x4e , 0x00},\r
370         {0x4e , 0x00},\r
371         {0x4e , 0x00},\r
372         {0x4e , 0x00},\r
373         {0x4e , 0x00},\r
374         {0x4e , 0x00},\r
375         {0x4e , 0x00},\r
376         {0x4e , 0x00},\r
377         {0x4e , 0x00},\r
378         {0x4e , 0x00},\r
379         {0x4e , 0x00},\r
380         {0x4e , 0x00},\r
381         {0x4d , 0x50}, // 50\r
382         {0x4e , 0x00},\r
383         {0x4e , 0x00},\r
384         {0x4e , 0x00},\r
385         {0x4e , 0x00},\r
386         {0x4e , 0x00},\r
387         {0x4e , 0x00},\r
388         {0x4e , 0x00},\r
389         {0x4e , 0x00},\r
390         {0x4e , 0x00},\r
391         {0x4e , 0x00},\r
392         {0x4e , 0x00},\r
393         {0x4e , 0x00},\r
394         {0x4e , 0x00},\r
395         {0x4e , 0x00},\r
396         {0x4e , 0x00},\r
397         {0x4e , 0x00},\r
398         {0x4d , 0x60}, // 60\r
399         {0x4e , 0x00},\r
400         {0x4e , 0x00},\r
401         {0x4e , 0x00},\r
402         {0x4e , 0x00},\r
403         {0x4e , 0x00},\r
404         {0x4e , 0x00},\r
405         {0x4e , 0x00},\r
406         {0x4e , 0x00},\r
407         {0x4e , 0x00},\r
408         {0x4e , 0x00},\r
409         {0x4e , 0x00},\r
410         {0x4e , 0x00},\r
411         {0x4e , 0x00},\r
412         {0x4e , 0x00},\r
413         {0x4e , 0x00},\r
414         {0x4e , 0x00},\r
415         {0x4d , 0x70}, // 70\r
416         {0x4e , 0x00},\r
417         {0x4e , 0x00},\r
418         {0x4e , 0x00},\r
419         {0x4e , 0x00},\r
420         {0x4e , 0x00},\r
421         {0x4e , 0x00},\r
422         {0x4e , 0x00},\r
423         {0x4e , 0x00},\r
424         {0x4e , 0x00},\r
425         {0x4e , 0x00},\r
426         {0x4e , 0x00},\r
427         {0x4e , 0x00},\r
428         {0x4e , 0x00},\r
429         {0x4e , 0x00},\r
430         {0x4e , 0x00},\r
431         {0x4e , 0x00},\r
432         {0x4d , 0x80}, // 80\r
433         {0x4e , 0x00},\r
434         {0x4e , 0x00},\r
435         {0x4e , 0x00},\r
436         {0x4e , 0x00},\r
437         {0x4e , 0x00},\r
438         {0x4e , 0x00},\r
439         {0x4e , 0x00},\r
440         {0x4e , 0x00},\r
441         {0x4e , 0x00},\r
442         {0x4e , 0x00},\r
443         {0x4e , 0x00},\r
444         {0x4e , 0x00},\r
445         {0x4e , 0x00},\r
446         {0x4e , 0x00},\r
447         {0x4e , 0x00},\r
448         {0x4e , 0x00},\r
449         {0x4d , 0x90}, // 90\r
450         {0x4e , 0x00},\r
451         {0x4e , 0x00},\r
452         {0x4e , 0x00},\r
453         {0x4e , 0x00},\r
454         {0x4e , 0x00},\r
455         {0x4e , 0x00},\r
456         {0x4e , 0x00},\r
457         {0x4e , 0x00},\r
458         {0x4e , 0x00},\r
459         {0x4e , 0x00},\r
460         {0x4e , 0x00},\r
461         {0x4e , 0x00},\r
462         {0x4e , 0x00},\r
463         {0x4e , 0x00},\r
464         {0x4e , 0x00},\r
465         {0x4e , 0x00},\r
466         {0x4d , 0xa0}, // a0\r
467         {0x4e , 0x00},\r
468         {0x4e , 0x00},\r
469         {0x4e , 0x00},\r
470         {0x4e , 0x00},\r
471         {0x4e , 0x00},\r
472         {0x4e , 0x00},\r
473         {0x4e , 0x00},\r
474         {0x4e , 0x00},\r
475         {0x4e , 0x00},\r
476         {0x4e , 0x00},\r
477         {0x4e , 0x00},\r
478         {0x4e , 0x00},\r
479         {0x4e , 0x00},\r
480         {0x4e , 0x00},\r
481         {0x4e , 0x00},\r
482         {0x4e , 0x00},\r
483         {0x4d , 0xb0}, // b0\r
484         {0x4e , 0x00},\r
485         {0x4e , 0x00},\r
486         {0x4e , 0x00},\r
487         {0x4e , 0x00},\r
488         {0x4e , 0x00},\r
489         {0x4e , 0x00},\r
490         {0x4e , 0x00},\r
491         {0x4e , 0x00},\r
492         {0x4e , 0x00},\r
493         {0x4e , 0x00},\r
494         {0x4e , 0x00},\r
495         {0x4e , 0x00},\r
496         {0x4e , 0x00},\r
497         {0x4e , 0x00},\r
498         {0x4e , 0x00},\r
499         {0x4e , 0x00},\r
500         {0x4d , 0xc0}, // c0\r
501         {0x4e , 0x00},\r
502         {0x4e , 0x00},\r
503         {0x4e , 0x00},\r
504         {0x4e , 0x00},\r
505         {0x4e , 0x00},\r
506         {0x4e , 0x00},\r
507         {0x4e , 0x00},\r
508         {0x4e , 0x00},\r
509         {0x4e , 0x00},\r
510         {0x4e , 0x00},\r
511         {0x4e , 0x00},\r
512         {0x4e , 0x00},\r
513         {0x4e , 0x00},\r
514         {0x4e , 0x00},\r
515         {0x4e , 0x00},\r
516         {0x4e , 0x00},\r
517         {0x4d , 0xd0}, // d0\r
518         {0x4e , 0x00},\r
519         {0x4e , 0x00},\r
520         {0x4e , 0x00},\r
521         {0x4e , 0x00},\r
522         {0x4e , 0x00},\r
523         {0x4e , 0x00},\r
524         {0x4e , 0x00},\r
525         {0x4e , 0x00},\r
526         {0x4e , 0x00},\r
527         {0x4e , 0x00},\r
528         {0x4e , 0x00},\r
529         {0x4e , 0x00},\r
530         {0x4e , 0x00},\r
531         {0x4e , 0x00},\r
532         {0x4e , 0x00},\r
533         {0x4e , 0x00},\r
534         {0x4f , 0x01},\r
535         /////// awb value////////\r
536         {0xfe , 0x01},\r
537         {0x4f , 0x00},\r
538         {0x4d , 0x30},\r
539         {0x4e , 0x00},\r
540         {0x4e , 0x80},\r
541         {0x4e , 0x80},\r
542         {0x4e , 0x02},\r
543         {0x4e , 0x02},\r
544         {0x4d , 0x40},\r
545         {0x4e , 0x00},\r
546         {0x4e , 0x80},\r
547         {0x4e , 0x80},\r
548         {0x4e , 0x02},\r
549         {0x4e , 0x02},\r
550         {0x4e , 0x02},\r
551         {0x4d , 0x53},\r
552         {0x4e , 0x08},\r
553         {0x4e , 0x04},\r
554         {0x4d , 0x62},\r
555         {0x4e , 0x10},\r
556         {0x4d , 0x72},\r
557         {0x4e , 0x20},\r
558         {0x4f , 0x01},\r
559 \r
560         /////awb////\r
561         {0xfe , 0x01},\r
562         {0x50 , 0x88},//c0//[6]green mode\r
563         {0x52 , 0x40},\r
564         {0x54 , 0x60},\r
565         {0x56 , 0x06},\r
566         {0x57 , 0x20}, //pre adjust\r
567         {0x58 , 0x01}, \r
568         {0x5b , 0x02}, //AWB_gain_delta\r
569         {0x61 , 0xaa},//R/G stand\r
570         {0x62 , 0xaa},//R/G stand\r
571         {0x71 , 0x00},\r
572         {0x74 , 0x10},  //0x//AWB_C_max\r
573         {0x77 , 0x08}, // 0x//AWB_p2_x\r
574         {0x78 , 0xfd}, //AWB_p2_y\r
575         {0x86 , 0x30},\r
576         {0x87 , 0x00},\r
577         {0x88 , 0x04},//06 , 0x//[1]dark mode\r
578         {0x8a , 0xc0},//awb move mode\r
579         {0x89 , 0x75},\r
580         {0x84 , 0x08},  //0x//auto_window\r
581         {0x8b , 0x00}, // 0x//awb compare luma\r
582         {0x8d , 0x70}, //awb gain limit R \r
583         {0x8e , 0x70},//G\r
584         {0x8f , 0xf4},//B\r
585         {0xfe , 0x00},\r
586         {0x82 , 0x02},//awb_en\r
587        /////////awb end /////////////\r
588        \r
589         ///==========asde\r
590         {0xfe , 0x01},\r
591         {0x21 , 0xbf},\r
592         {0xfe , 0x02},\r
593         {0xa4 , 0x00},//\r
594         {0xa5 , 0x40}, //lsc_th\r
595         {0xa2 , 0xa0}, //lsc_dec_slope\r
596         {0xa6 , 0x80}, //dd_th\r
597         {0xa7 , 0x80}, //ot_th\r
598         {0xab , 0x31}, //\r
599         {0xa9 , 0x6f}, //\r
600         {0xb0 , 0x99}, //0x//edge effect slope low\r
601         {0xb1 , 0x34},//edge effect slope low\r
602         {0xb3 , 0x80}, //saturation dec slope\r
603         {0xde , 0xb6},  //\r
604         {0x38 , 0x0f}, // \r
605         {0x39 , 0x60}, //\r
606         {0xfe , 0x00},\r
607         {0x81 , 0x26},\r
608         {0xfe , 0x02},\r
609         {0x83 , 0x00},//\r
610         {0x84 , 0x45},//\r
611         ////////////YCP//////////\r
612         {0xd1 , 0x38},//saturation_cb\r
613         {0xd2 , 0x38},//saturation_Cr\r
614         {0xd3 , 0x40},//contrast ?\r
615         {0xd4 , 0x80},//contrast center \r
616         {0xd5 , 0x00},//luma_offset \r
617         {0xdc , 0x30},\r
618         {0xdd , 0xb8},//edge_sa_g,b\r
619         {0xfe , 0x00},\r
620         ///////dndd///////////\r
621         {0xfe , 0x02},\r
622         {0x88 , 0x15},//dn_b_base\r
623         {0x8c , 0xf6}, //[2]b_in_dark_inc\r
624         {0x89 , 0x03}, //dn_c_weight\r
625         ////////EE ///////////\r
626         {0xfe , 0x02},\r
627         {0x90 , 0x6c},// EEINTP mode1\r
628         {0x97 , 0x45},// edge effect\r
629         ////==============RGB Gamma \r
630         {0xfe , 0x02},\r
631         {0x15 , 0x0a},\r
632         {0x16 , 0x12},\r
633         {0x17 , 0x19},\r
634         {0x18 , 0x1f},\r
635         {0x19 , 0x2c},\r
636         {0x1a , 0x38},\r
637         {0x1b , 0x42},\r
638         {0x1c , 0x4e},\r
639         {0x1d , 0x63},\r
640         {0x1e , 0x76},\r
641         {0x1f , 0x87},\r
642         {0x20 , 0x96},\r
643         {0x21 , 0xa2},\r
644         {0x22 , 0xb8},\r
645         {0x23 , 0xca},\r
646         {0x24 , 0xd8},\r
647         {0x25 , 0xe3},\r
648         {0x26 , 0xf0},\r
649         {0x27 , 0xf8},\r
650         {0x28 , 0xfd},\r
651         {0x29 , 0xff},\r
652 \r
653         ///=================y gamma\r
654         {0xfe , 0x02},\r
655         {0x2b , 0x00},\r
656         {0x2c , 0x04},\r
657         {0x2d , 0x09},\r
658         {0x2e , 0x18},\r
659         {0x2f , 0x27},\r
660         {0x30 , 0x37},\r
661         {0x31 , 0x49},\r
662         {0x32 , 0x5c},\r
663         {0x33 , 0x7e},\r
664         {0x34 , 0xa0},\r
665         {0x35 , 0xc0},\r
666         {0x36 , 0xe0},\r
667         {0x37 , 0xff},\r
668         /////1600x1200size// \r
669         {0xfe , 0x00},//\r
670         {0x90 , 0x01}, //0x//crop enable\r
671         {0x95 , 0x04},  //0x//1600x1200\r
672         {0x96 , 0xb0},\r
673         {0x97 , 0x06},\r
674         {0x98 , 0x40},\r
675 \r
676         {0xfe , 0x03},\r
677         {0x42 , 0x40}, \r
678         {0x43 , 0x06}, //output buf width\r
679         {0x41 , 0x02}, // Pclk_polarity\r
680         {0x40 , 0x40},  //00  \r
681         {0x17 , 0x00}, //widv \r
682         {0xfe , 0x00},\r
683         ////output DVP/////\r
684         {0xfe , 0x00},\r
685         {0xb6 , 0x03},\r
686         {0xf7 , 0x15},\r
687 \r
688         {0xc8 , 0x00},//close scaler\r
689         {0x99 , 0x22},// 1/2 subsample\r
690         {0x9a , 0x06},\r
691         {0x9b , 0x00},\r
692         {0x9c , 0x00},\r
693         {0x9d , 0x00},\r
694         {0x9e , 0x00},\r
695         {0x9f , 0x00},\r
696         {0xa0 , 0x00},  \r
697         {0xa1 , 0x00},\r
698         {0xa2  ,0x00},\r
699         \r
700         {0x90 , 0x01},  //crop enable\r
701         {0x94 , 0x02},\r
702         {0x95 , 0x02},\r
703         {0x96 , 0x58},\r
704         {0x97 , 0x03},\r
705         {0x98 , 0x20},\r
706         {0xfe , 0x00},\r
707         {0x82 , 0xfe},  // fe\r
708         {0xf2 , 0x70}, \r
709         {0xf3 , 0xff},\r
710         {0xf4 , 0x00},\r
711         {0xf5 , 0x30},\r
712         \r
713           #if 0   \r
714         /////////  re zao///\r
715         {0xfe,0x00},\r
716         {0x22,0xd0},\r
717         {0xfe,0x01},\r
718         {0x21,0xff},\r
719         {0xfe,0x02},  \r
720         {0x8a,0x33},\r
721         {0x8c,0x76},\r
722         {0x8d,0x85},\r
723         {0xa6,0xf0},    \r
724         {0xae,0x9f},\r
725         {0xa2,0x90},\r
726         {0xa5,0x40},  \r
727         {0xa7,0x30},\r
728         {0xb0,0x88},\r
729         {0x38,0x0b},\r
730         {0x39,0x30},\r
731         {0xfe,0x00},  \r
732         {0x87,0xb0},\r
733 \r
734        //// small  RGB gamma////\r
735         {0xfe , 0x02},\r
736         {0x15 , 0x0b},\r
737         {0x16 , 0x0e},\r
738         {0x17 , 0x10},\r
739         {0x18 , 0x12},\r
740         {0x19 , 0x19},\r
741         {0x1a , 0x21},\r
742         {0x1b , 0x29},\r
743         {0x1c , 0x31},\r
744         {0x1d , 0x41},\r
745         {0x1e , 0x50},\r
746         {0x1f , 0x5f},\r
747         {0x20 , 0x6d},\r
748         {0x21 , 0x79},\r
749         {0x22 , 0x91},\r
750         {0x23 , 0xa5},\r
751         {0x24 , 0xb9},\r
752         {0x25 , 0xc9},\r
753         {0x26 , 0xe1},\r
754         {0x27 , 0xee},\r
755         {0x28 , 0xf7},\r
756         {0x29 , 0xff},\r
757         \r
758         ////dark sun/////\r
759         {0xfe , 0x02},\r
760         {0x40 , 0x06},\r
761         {0x41 , 0x23},\r
762         {0x42 , 0x3f},\r
763         {0x43 , 0x06},\r
764         {0x44 , 0x00},\r
765         {0x45 , 0x00},\r
766         {0x46 , 0x14},\r
767         {0x47 , 0x09},\r
768  \r
769   #endif\r
770         SensorEnd\r
771 };\r
772 /* Senor full resolution setting: recommand for capture */\r
773 static struct rk_sensor_reg sensor_fullres_lowfps_data[] ={\r
774  \r
775  \r
776         {0xfe , 0x00},\r
777         {0xc8 , 0x00},\r
778         {0xf7 , 0x17},\r
779 \r
780         {0x99 , 0x11}, // disable sambsample\r
781         {0x9a , 0x06},\r
782         {0x9b , 0x00},\r
783         {0x9c , 0x00},\r
784         {0x9d , 0x00},\r
785         {0x9e , 0x00},\r
786         {0x9f , 0x00},\r
787         {0xa0 , 0x00},  \r
788         {0xa1 , 0x00},\r
789         {0xa2 , 0x00},\r
790                 \r
791         {0x90 , 0x01},\r
792         {0x95 , 0x04},\r
793         {0x96 , 0xb0},  \r
794         {0x97 , 0x06},\r
795         {0x98 , 0x40},\r
796                 \r
797         SensorEnd \r
798 \r
799 \r
800 };\r
801 \r
802 /* Senor full resolution setting: recommand for video */\r
803 static struct rk_sensor_reg sensor_fullres_highfps_data[] ={\r
804         SensorEnd\r
805 };\r
806 /* Preview resolution setting*/\r
807 static struct rk_sensor_reg sensor_preview_data[] =\r
808 {\r
809         {0xfe , 0x00},\r
810         {0xb6 , 0x03},\r
811         {0xf7 , 0x15},\r
812 \r
813         {0xc8 , 0x00},//close scaler\r
814         {0x99 , 0x22},// 1/2 subsample\r
815         {0x9a , 0x06},\r
816         {0x9b , 0x00},\r
817         {0x9c , 0x00},\r
818         {0x9d , 0x00},\r
819         {0x9e , 0x00},\r
820         {0x9f , 0x00},\r
821         {0xa0 , 0x00},  \r
822         {0xa1 , 0x00},\r
823         {0xa2 , 0x00},\r
824         \r
825         {0x90 , 0x01},  //crop enable\r
826         {0x94 , 0x02},\r
827         {0x95 , 0x02},\r
828         {0x96 , 0x58},\r
829         {0x97 , 0x03},\r
830         {0x98 , 0x20},\r
831         SensorEnd\r
832 };\r
833 /* 1280x720 */\r
834 static struct rk_sensor_reg sensor_720p[]={\r
835         SensorEnd\r
836 };\r
837 \r
838 /* 1920x1080 */\r
839 static struct rk_sensor_reg sensor_1080p[]={\r
840         SensorEnd\r
841 };\r
842 \r
843 \r
844 static struct rk_sensor_reg sensor_softreset_data[]={\r
845     SensorRegVal(0xfe,80),\r
846     SensorWaitMs(5),\r
847         SensorEnd\r
848 };\r
849 \r
850 static struct rk_sensor_reg sensor_check_id_data[]={\r
851         SensorRegVal(0xf0,0),\r
852         SensorRegVal(0xf1,0),\r
853         SensorEnd\r
854 };\r
855 /*\r
856 *  The following setting must been filled, if the function is turn on by CONFIG_SENSOR_xxxx\r
857 */\r
858 static struct rk_sensor_reg sensor_WhiteB_Auto[]=\r
859 {\r
860         {0xb3, 0x61},\r
861         {0xb4, 0x40},\r
862         {0xb5, 0x61},\r
863         {0x82, 0xfe},\r
864         SensorEnd\r
865 };\r
866 /* Cloudy Colour Temperature : 6500K - 8000K  */\r
867 static  struct rk_sensor_reg sensor_WhiteB_Cloudy[]=\r
868 {\r
869         {0x82, 0xfc},\r
870         {0xb3, 0x58},\r
871         {0xb4, 0x40},\r
872         {0xb5, 0x50},   \r
873         SensorEnd\r
874 };\r
875 /* ClearDay Colour Temperature : 5000K - 6500K  */\r
876 static  struct rk_sensor_reg sensor_WhiteB_ClearDay[]=\r
877 {\r
878         //Sunny\r
879                         {0x82, 0xfc},\r
880                         {0xb3, 0x58},\r
881                         {0xb4, 0x40},\r
882                         {0xb5, 0x50},\r
883         SensorEnd\r
884 };\r
885 /* Office Colour Temperature : 3500K - 5000K  */\r
886 static  struct rk_sensor_reg sensor_WhiteB_TungstenLamp1[]=\r
887 {\r
888         //Office\r
889                         {0x82, 0xfc},\r
890                         {0xb3, 0x50},\r
891                         {0xb4, 0x40},\r
892                         {0xb5, 0xa8},\r
893         SensorEnd\r
894 \r
895 };\r
896 /* Home Colour Temperature : 2500K - 3500K      */\r
897 static  struct rk_sensor_reg sensor_WhiteB_TungstenLamp2[]=\r
898 {\r
899         //Home\r
900                         {0x82, 0xfc},\r
901                         {0xb3, 0xa0},\r
902                         {0xb4, 0x45},\r
903                         {0xb5, 0x40},\r
904         SensorEnd\r
905 };\r
906 static struct rk_sensor_reg *sensor_WhiteBalanceSeqe[] = {sensor_WhiteB_Auto, sensor_WhiteB_TungstenLamp1,sensor_WhiteB_TungstenLamp2,\r
907         sensor_WhiteB_ClearDay, sensor_WhiteB_Cloudy,NULL,\r
908 };\r
909 \r
910 static  struct rk_sensor_reg sensor_Brightness0[]=\r
911 {\r
912         // Brightness -2\r
913         \r
914         {0xfe, 0x01},\r
915         {0x13, 0x40},\r
916         {0xfe, 0x02},\r
917         {0xd5, 0xe0},\r
918         SensorEnd\r
919 };\r
920 \r
921 static  struct rk_sensor_reg sensor_Brightness1[]=\r
922 {\r
923         // Brightness -1\r
924         \r
925         {0xfe, 0x01},\r
926         {0x13, 0x48},\r
927         {0xfe, 0x02},\r
928         {0xd5, 0xf0},\r
929         \r
930         SensorEnd\r
931 };\r
932 \r
933 static  struct rk_sensor_reg sensor_Brightness2[]=\r
934 {\r
935         //      Brightness 0\r
936         \r
937         {0xfe, 0x01},\r
938         {0x13, 0x58},\r
939         {0xfe, 0x02},\r
940         {0xd5, 0x00},\r
941         \r
942         SensorEnd\r
943 };\r
944 \r
945 static  struct rk_sensor_reg sensor_Brightness3[]=\r
946 {\r
947         // Brightness +1\r
948         {0xfe, 0x01},\r
949         {0x13, 0x60},\r
950         {0xfe, 0x02},\r
951         {0xd5, 0x10},\r
952         \r
953         SensorEnd\r
954 };\r
955 \r
956 static  struct rk_sensor_reg sensor_Brightness4[]=\r
957 {\r
958         //      Brightness +2\r
959         {0xfe, 0x01},\r
960         {0x13, 0x68},\r
961         {0xfe, 0x02},\r
962         {0xd5, 0x20},\r
963 \r
964         SensorEnd\r
965 };\r
966 \r
967 static  struct rk_sensor_reg sensor_Brightness5[]=\r
968 {\r
969         //      Brightness +3\r
970         {0xfe, 0x01},\r
971         {0x13, 0x78},\r
972         {0xfe, 0x02},\r
973         {0xd5, 0x30},\r
974 \r
975         SensorEnd\r
976 };\r
977 static struct rk_sensor_reg *sensor_BrightnessSeqe[] = {sensor_Brightness0, sensor_Brightness1, sensor_Brightness2, sensor_Brightness3,\r
978         sensor_Brightness4, sensor_Brightness5,NULL,\r
979 };\r
980 \r
981 static  struct rk_sensor_reg sensor_Effect_Normal[] =\r
982 {\r
983         {0xfe, 0x00},\r
984         {0x83, 0xe0},\r
985         SensorEnd\r
986 };\r
987 \r
988 static  struct rk_sensor_reg sensor_Effect_WandB[] =\r
989 {\r
990         {0xfe, 0x00},\r
991         {0x83, 0x12},                   \r
992         SensorEnd\r
993 };\r
994 \r
995 static  struct rk_sensor_reg sensor_Effect_Sepia[] =\r
996 {\r
997         {0xfe, 0x00},\r
998         {0x83, 0x82},\r
999         SensorEnd\r
1000 };\r
1001 \r
1002 static  struct rk_sensor_reg sensor_Effect_Negative[] =\r
1003 {\r
1004         //Negative\r
1005         {0xfe, 0x00},\r
1006         {0x83, 0x01},\r
1007         SensorEnd\r
1008 };\r
1009 static  struct rk_sensor_reg sensor_Effect_Bluish[] =\r
1010 {\r
1011         // Bluish\r
1012         {0xfe, 0x00},\r
1013         {0x83, 0x62},\r
1014         SensorEnd\r
1015 };\r
1016 \r
1017 static  struct rk_sensor_reg sensor_Effect_Green[] =\r
1018 {\r
1019         //      Greenish\r
1020         {0xfe, 0x00},\r
1021         {0x83, 0x52},\r
1022         SensorEnd\r
1023 };\r
1024 static struct rk_sensor_reg *sensor_EffectSeqe[] = {sensor_Effect_Normal, sensor_Effect_WandB, sensor_Effect_Negative,sensor_Effect_Sepia,\r
1025         sensor_Effect_Bluish, sensor_Effect_Green,NULL,\r
1026 };\r
1027 \r
1028 static  struct rk_sensor_reg sensor_Exposure0[]=\r
1029 {\r
1030 \r
1031         SensorEnd\r
1032 };\r
1033 \r
1034 static  struct rk_sensor_reg sensor_Exposure1[]=\r
1035 {\r
1036         SensorEnd\r
1037 };\r
1038 \r
1039 static  struct rk_sensor_reg sensor_Exposure2[]=\r
1040 {\r
1041         SensorEnd\r
1042 };\r
1043 \r
1044 static  struct rk_sensor_reg sensor_Exposure3[]=\r
1045 {\r
1046         SensorEnd\r
1047 };\r
1048 \r
1049 static  struct rk_sensor_reg sensor_Exposure4[]=\r
1050 {\r
1051         SensorEnd\r
1052 };\r
1053 \r
1054 static  struct rk_sensor_reg sensor_Exposure5[]=\r
1055 {\r
1056 \r
1057         SensorEnd\r
1058 };\r
1059 \r
1060 static  struct rk_sensor_reg sensor_Exposure6[]=\r
1061 {\r
1062         SensorEnd\r
1063 };\r
1064 \r
1065 static struct rk_sensor_reg *sensor_ExposureSeqe[] = {sensor_Exposure0, sensor_Exposure1, sensor_Exposure2, sensor_Exposure3,\r
1066         sensor_Exposure4, sensor_Exposure5,sensor_Exposure6,NULL,\r
1067 };\r
1068 \r
1069 static  struct rk_sensor_reg sensor_Saturation0[]=\r
1070 {\r
1071         SensorEnd\r
1072 };\r
1073 \r
1074 static  struct rk_sensor_reg sensor_Saturation1[]=\r
1075 {\r
1076         SensorEnd\r
1077 };\r
1078 \r
1079 static  struct rk_sensor_reg sensor_Saturation2[]=\r
1080 {\r
1081         SensorEnd\r
1082 };\r
1083 static struct rk_sensor_reg *sensor_SaturationSeqe[] = {sensor_Saturation0, sensor_Saturation1, sensor_Saturation2, NULL,};\r
1084 \r
1085 static  struct rk_sensor_reg sensor_Contrast0[]=\r
1086 {\r
1087         //Contrast -3\r
1088 \r
1089         SensorEnd\r
1090 };\r
1091 \r
1092 static  struct rk_sensor_reg sensor_Contrast1[]=\r
1093 {\r
1094         //Contrast -2\r
1095 \r
1096         SensorEnd\r
1097 };\r
1098 \r
1099 static  struct rk_sensor_reg sensor_Contrast2[]=\r
1100 {\r
1101         // Contrast -1\r
1102 \r
1103         SensorEnd\r
1104 };\r
1105 \r
1106 static  struct rk_sensor_reg sensor_Contrast3[]=\r
1107 {\r
1108         //Contrast 0\r
1109 \r
1110         SensorEnd\r
1111 };\r
1112 \r
1113 static  struct rk_sensor_reg sensor_Contrast4[]=\r
1114 {\r
1115         //Contrast +1\r
1116 \r
1117         SensorEnd\r
1118 };\r
1119 \r
1120 \r
1121 static  struct rk_sensor_reg sensor_Contrast5[]=\r
1122 {\r
1123         //Contrast +2\r
1124 \r
1125         SensorEnd\r
1126 };\r
1127 \r
1128 static  struct rk_sensor_reg sensor_Contrast6[]=\r
1129 {\r
1130         //Contrast +3\r
1131 \r
1132         SensorEnd\r
1133 };\r
1134 static struct rk_sensor_reg *sensor_ContrastSeqe[] = {sensor_Contrast0, sensor_Contrast1, sensor_Contrast2, sensor_Contrast3,\r
1135         sensor_Contrast4, sensor_Contrast5, sensor_Contrast6, NULL,\r
1136 };\r
1137 static  struct rk_sensor_reg sensor_SceneAuto[] =\r
1138 {\r
1139         {0xfe,0x01},\r
1140         \r
1141         {0x3e,0x40},    \r
1142         {0xfe,0x00},\r
1143         SensorEnd\r
1144 };\r
1145 \r
1146 static  struct rk_sensor_reg sensor_SceneNight[] =\r
1147 {\r
1148         {0xfe,0x01},\r
1149         \r
1150         {0x3e,0x60},    \r
1151         {0xfe,0x00},\r
1152         SensorEnd\r
1153 };\r
1154 static struct rk_sensor_reg *sensor_SceneSeqe[] = {sensor_SceneAuto, sensor_SceneNight,NULL,};\r
1155 \r
1156 static struct rk_sensor_reg sensor_Zoom0[] =\r
1157 {\r
1158         SensorEnd\r
1159 };\r
1160 \r
1161 static struct rk_sensor_reg sensor_Zoom1[] =\r
1162 {\r
1163         SensorEnd\r
1164 };\r
1165 \r
1166 static struct rk_sensor_reg sensor_Zoom2[] =\r
1167 {\r
1168         SensorEnd\r
1169 };\r
1170 \r
1171 \r
1172 static struct rk_sensor_reg sensor_Zoom3[] =\r
1173 {\r
1174         SensorEnd\r
1175 };\r
1176 static struct rk_sensor_reg *sensor_ZoomSeqe[] = {sensor_Zoom0, sensor_Zoom1, sensor_Zoom2, sensor_Zoom3, NULL,};\r
1177 \r
1178 /*\r
1179 * User could be add v4l2_querymenu in sensor_controls by new_usr_v4l2menu\r
1180 */\r
1181 static struct v4l2_querymenu sensor_menus[] =\r
1182 {\r
1183 };\r
1184 /*\r
1185 * User could be add v4l2_queryctrl in sensor_controls by new_user_v4l2ctrl\r
1186 */\r
1187 static struct sensor_v4l2ctrl_usr_s sensor_controls[] =\r
1188 {\r
1189 };\r
1190 \r
1191 //MUST define the current used format as the first item   \r
1192 static struct rk_sensor_datafmt sensor_colour_fmts[] = {\r
1193         {V4L2_MBUS_FMT_UYVY8_2X8, V4L2_COLORSPACE_JPEG} \r
1194 };\r
1195 /*static struct soc_camera_ops sensor_ops;*/\r
1196 \r
1197 \r
1198 /*\r
1199 **********************************************************\r
1200 * Following is local code:\r
1201\r
1202 * Please codeing your program here \r
1203 **********************************************************\r
1204 */\r
1205 /*\r
1206 **********************************************************\r
1207 * Following is callback\r
1208 * If necessary, you could coding these callback\r
1209 **********************************************************\r
1210 */\r
1211 /*\r
1212 * the function is called in open sensor  \r
1213 */\r
1214 static int sensor_activate_cb(struct i2c_client *client)\r
1215 {\r
1216         \r
1217         return 0;\r
1218 }\r
1219 /*\r
1220 * the function is called in close sensor\r
1221 */\r
1222 static int sensor_deactivate_cb(struct i2c_client *client)\r
1223 {\r
1224         \r
1225         return 0;\r
1226 }\r
1227 /*\r
1228 * the function is called before sensor register setting in VIDIOC_S_FMT  \r
1229 */\r
1230 static int sensor_s_fmt_cb_th(struct i2c_client *client,struct v4l2_mbus_framefmt *mf, bool capture)\r
1231 {\r
1232         char value;\r
1233         unsigned   int pid=0,shutter,temp_reg;\r
1234         if(mf->width == 1600 && mf->height == 1200){\r
1235                  sensor_write(client, 0xfe, 0x00);\r
1236                  sensor_write(client, 0xb6, 0x02);\r
1237                 \r
1238                 \r
1239                  sensor_read(client, 0x03, &value);\r
1240                  pid |= (value << 8);\r
1241                 sensor_read(client, 0x04, &value);\r
1242                  pid |= (value & 0xff);\r
1243                  shutter=pid;\r
1244                 \r
1245                 \r
1246                  temp_reg= shutter /2;   // 2\r
1247                 \r
1248                  if(temp_reg < 1) temp_reg = 1;\r
1249                 \r
1250                 \r
1251                  sensor_write(client, 0x03, ((temp_reg>>8)&0xff));\r
1252                  sensor_write(client, 0x04, (temp_reg&0xff));\r
1253         }\r
1254 \r
1255         return 0;\r
1256 }\r
1257 /*\r
1258 * the function is called after sensor register setting finished in VIDIOC_S_FMT  \r
1259 */\r
1260 static int sensor_s_fmt_cb_bh (struct i2c_client *client,struct v4l2_mbus_framefmt *mf, bool capture)\r
1261 {\r
1262         /* add delay for rk312x*/
1263         msleep(300); 
1264         return 0;\r
1265 }\r
1266 static int sensor_softrest_usr_cb(struct i2c_client *client,struct rk_sensor_reg *series)\r
1267 {\r
1268         \r
1269         return 0;\r
1270 }\r
1271 static int sensor_check_id_usr_cb(struct i2c_client *client,struct rk_sensor_reg *series)\r
1272 {\r
1273         return 0;\r
1274 }\r
1275 static int sensor_try_fmt_cb_th(struct i2c_client *client,struct v4l2_mbus_framefmt *mf)\r
1276 {\r
1277         return 0;\r
1278 }\r
1279 static int sensor_suspend(struct soc_camera_device *icd, pm_message_t pm_msg)\r
1280 {\r
1281         //struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));\r
1282                 \r
1283         if (pm_msg.event == PM_EVENT_SUSPEND) {\r
1284                 SENSOR_DG("Suspend");\r
1285                 \r
1286         } else {\r
1287                 SENSOR_TR("pm_msg.event(0x%x) != PM_EVENT_SUSPEND\n",pm_msg.event);\r
1288                 return -EINVAL;\r
1289         }\r
1290         return 0;\r
1291 }\r
1292 \r
1293 static int sensor_resume(struct soc_camera_device *icd)\r
1294 {\r
1295 \r
1296         SENSOR_DG("Resume");\r
1297 \r
1298         return 0;\r
1299 \r
1300 }\r
1301 static int sensor_mirror_cb (struct i2c_client *client, int mirror)\r
1302 {\r
1303         char val;\r
1304         int err = 0;\r
1305         \r
1306         SENSOR_DG("mirror: %d",mirror);\r
1307         if (mirror) {\r
1308                 sensor_write(client, 0xfe, 0);\r
1309                 err = sensor_read(client, 0x17, &val);\r
1310                 val-=4;\r
1311                 if (err == 0) {\r
1312                         if((val & 0x1) == 0){\r
1313                                 err = sensor_write(client, 0x17, ((val |0x1)+4));\r
1314                                 }\r
1315                         else \r
1316                                 err = sensor_write(client, 0x17, ((val & 0xfe)+4));\r
1317                 }\r
1318         } else {\r
1319                 //do nothing\r
1320         }\r
1321         return err;    \r
1322 }\r
1323 /*\r
1324 * the function is v4l2 control V4L2_CID_HFLIP callback  \r
1325 */\r
1326 static int sensor_v4l2ctrl_mirror_cb(struct soc_camera_device *icd, struct sensor_v4l2ctrl_info_s *ctrl_info, \r
1327                                                                                                          struct v4l2_ext_control *ext_ctrl)\r
1328 {\r
1329         struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));\r
1330 \r
1331         if (sensor_mirror_cb(client,ext_ctrl->value) != 0)\r
1332                 SENSOR_TR("sensor_mirror failed, value:0x%x",ext_ctrl->value);\r
1333         \r
1334         SENSOR_DG("sensor_mirror success, value:0x%x",ext_ctrl->value);\r
1335         return 0;\r
1336 }\r
1337 \r
1338 static int sensor_flip_cb(struct i2c_client *client, int flip)\r
1339 {\r
1340         char val;\r
1341         int err = 0;    \r
1342 \r
1343         SENSOR_DG("flip: %d",flip);\r
1344         if (flip) {\r
1345                 \r
1346                 sensor_write(client, 0xfe, 0);\r
1347                 err = sensor_read(client, 0x17, &val);\r
1348                 val-=4;\r
1349                 if (err == 0) {\r
1350                         if((val & 0x2) == 0){\r
1351                                 err = sensor_write(client, 0x17, ((val |0x2)+4));\r
1352                                 }\r
1353                         else {\r
1354                                 err = sensor_write(client, 0x17, ((val & 0xfc)+4));\r
1355                                 }\r
1356                 }\r
1357         } else {\r
1358                 //do nothing\r
1359         }\r
1360 \r
1361         return err;    \r
1362 }\r
1363 /*\r
1364 * the function is v4l2 control V4L2_CID_VFLIP callback  \r
1365 */\r
1366 static int sensor_v4l2ctrl_flip_cb(struct soc_camera_device *icd, struct sensor_v4l2ctrl_info_s *ctrl_info, \r
1367                                                                                                          struct v4l2_ext_control *ext_ctrl)\r
1368 {\r
1369         struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));\r
1370 \r
1371         if (sensor_flip_cb(client,ext_ctrl->value) != 0)\r
1372                 SENSOR_TR("sensor_flip failed, value:0x%x",ext_ctrl->value);\r
1373         \r
1374         SENSOR_DG("sensor_flip success, value:0x%x",ext_ctrl->value);\r
1375         return 0;\r
1376 }\r
1377 /*\r
1378 * the functions are focus callbacks\r
1379 */\r
1380 static int sensor_focus_init_usr_cb(struct i2c_client *client){\r
1381         return 0;\r
1382 }\r
1383 \r
1384 static int sensor_focus_af_single_usr_cb(struct i2c_client *client){\r
1385         return 0;\r
1386 }\r
1387 \r
1388 static int sensor_focus_af_near_usr_cb(struct i2c_client *client){\r
1389         return 0;\r
1390 }\r
1391 \r
1392 static int sensor_focus_af_far_usr_cb(struct i2c_client *client){\r
1393         return 0;\r
1394 }\r
1395 \r
1396 static int sensor_focus_af_specialpos_usr_cb(struct i2c_client *client,int pos){\r
1397         return 0;\r
1398 }\r
1399 \r
1400 static int sensor_focus_af_const_usr_cb(struct i2c_client *client){\r
1401         return 0;\r
1402 }\r
1403 static int sensor_focus_af_const_pause_usr_cb(struct i2c_client *client)
1404 {
1405     return 0;
1406 }\r
1407 static int sensor_focus_af_close_usr_cb(struct i2c_client *client){\r
1408         return 0;\r
1409 }\r
1410 \r
1411 static int sensor_focus_af_zoneupdate_usr_cb(struct i2c_client *client, int *zone_tm_pos)\r
1412 {\r
1413     return 0;\r
1414 }\r
1415 \r
1416 /*\r
1417 face defect call back\r
1418 */\r
1419 static int      sensor_face_detect_usr_cb(struct i2c_client *client,int on){\r
1420         return 0;\r
1421 }\r
1422 \r
1423 /*\r
1424 *       The function can been run in sensor_init_parametres which run in sensor_probe, so user can do some\r
1425 * initialization in the function. \r
1426 */\r
1427 static void sensor_init_parameters_user(struct specific_sensor* spsensor,struct soc_camera_device *icd)\r
1428 {\r
1429         return;\r
1430 }\r
1431 \r
1432 /*\r
1433 * :::::WARNING:::::\r
1434 * It is not allowed to modify the following code\r
1435 */\r
1436 \r
1437 sensor_init_parameters_default_code();\r
1438 \r
1439 sensor_v4l2_struct_initialization();\r
1440 \r
1441 sensor_probe_default_code();\r
1442 \r
1443 sensor_remove_default_code();\r
1444 \r
1445 sensor_driver_default_module_code();\r
1446 \r
1447 \r
1448 \r
1449 \r
1450 \r