2 * Driver for mt9d112 CMOS Image Sensor from Aptina(micron)
4 * Copyright (C) 2008, Guennadi Liakhovetski <kernel@pengutronix.de>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
11 #include <linux/videodev2.h>
12 #include <linux/slab.h>
13 #include <linux/i2c.h>
14 #include <linux/log2.h>
15 #include <linux/platform_device.h>
16 #include <linux/delay.h>
17 #include <linux/circ_buf.h>
18 #include <linux/miscdevice.h>
19 #include <media/v4l2-common.h>
20 #include <media/v4l2-chip-ident.h>
21 #include <media/soc_camera.h>
22 #include <plat/rk_camera.h>
26 module_param(debug, int, S_IRUGO|S_IWUSR);
28 #define dprintk(level, fmt, arg...) do { \
30 printk(KERN_WARNING fmt , ## arg); } while (0)
32 #define SENSOR_TR(format, ...) printk(KERN_ERR format, ## __VA_ARGS__)
33 #define SENSOR_DG(format, ...) dprintk(1, format, ## __VA_ARGS__)
35 #define _CONS(a,b) a##b
36 #define CONS(a,b) _CONS(a,b)
39 #define _STR(x) __STR(x)
40 #define STR(x) _STR(x)
42 #define MIN(x,y) ((x<y) ? x: y)
43 #define MAX(x,y) ((x>y) ? x: y)
45 /* Sensor Driver Configuration */
46 #define SENSOR_NAME RK29_CAM_SENSOR_MT9D112
47 #define SENSOR_V4L2_IDENT V4L2_IDENT_MT9D112
48 #define SENSOR_ID 0x1580
49 #define SENSOR_ID_REG 0x3000
50 #define SENSOR_RESET_REG SEQUENCE_END
51 #define SENSOR_RESET_VAL 0x00
52 #define SENSOR_MIN_WIDTH 320
53 #define SENSOR_MIN_HEIGHT 240
54 #define SENSOR_MAX_WIDTH 1600
55 #define SENSOR_MAX_HEIGHT 1200
56 #define SENSOR_INIT_WIDTH 640 /* Sensor pixel size for sensor_init_data array */
57 #define SENSOR_INIT_HEIGHT 480
58 #define SENSOR_INIT_WINSEQADR sensor_vga
59 #define SENSOR_INIT_PIXFMT V4L2_MBUS_FMT_UYVY8_2X8
61 #define CONFIG_SENSOR_WhiteBalance 1
62 #define CONFIG_SENSOR_Brightness 0
63 #define CONFIG_SENSOR_Contrast 0
64 #define CONFIG_SENSOR_Saturation 0
65 #define CONFIG_SENSOR_Effect 1
66 #define CONFIG_SENSOR_Scene 1
67 #define CONFIG_SENSOR_DigitalZoom 0
68 #define CONFIG_SENSOR_Exposure 0
69 #define CONFIG_SENSOR_Flash 1
70 #define CONFIG_SENSOR_Mirror 0
71 #define CONFIG_SENSOR_Flip 0
72 #define CONFIG_SENSOR_Focus 0
75 #define CONFIG_SENSOR_I2C_SPEED 250000 /* Hz */
76 /* Sensor write register continues by preempt_disable/preempt_enable for current process not be scheduled */
77 #define CONFIG_SENSOR_I2C_NOSCHED 0
78 #define CONFIG_SENSOR_I2C_RDWRCHK 0
81 #define SENSOR_BUS_PARAM (SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING |\
82 SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_HIGH |\
83 SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATAWIDTH_8 |SOCAM_MCLK_24MHZ)
85 #define COLOR_TEMPERATURE_CLOUDY_DN 6500
86 #define COLOR_TEMPERATURE_CLOUDY_UP 8000
87 #define COLOR_TEMPERATURE_CLEARDAY_DN 5000
88 #define COLOR_TEMPERATURE_CLEARDAY_UP 6500
89 #define COLOR_TEMPERATURE_OFFICE_DN 3500
90 #define COLOR_TEMPERATURE_OFFICE_UP 5000
91 #define COLOR_TEMPERATURE_HOME_DN 2500
92 #define COLOR_TEMPERATURE_HOME_UP 3500
94 #define SENSOR_NAME_STRING(a) STR(CONS(SENSOR_NAME, a))
95 #define SENSOR_NAME_VARFUN(a) CONS(SENSOR_NAME, a)
97 #define SENSOR_AF_IS_ERR (0x00<<0)
98 #define SENSOR_AF_IS_OK (0x01<<0)
99 #define SENSOR_INIT_IS_ERR (0x00<<28)
100 #define SENSOR_INIT_IS_OK (0x01<<28)
102 #if CONFIG_SENSOR_Focus
103 #define SENSOR_AF_MODE_INFINITY 0
104 #define SENSOR_AF_MODE_MACRO 1
105 #define SENSOR_AF_MODE_FIXED 2
106 #define SENSOR_AF_MODE_AUTO 3
107 #define SENSOR_AF_MODE_CONTINUOUS 4
108 #define SENSOR_AF_MODE_CLOSE 5
110 #define SENSOR_CCM_ONLY
112 //flash off in fixed time to prevent from too hot , zyc
114 struct soc_camera_device *icd;
115 struct hrtimer timer;
117 static enum hrtimer_restart flash_off_func(struct hrtimer *timer);
119 static struct flash_timer flash_off_timer;
120 //for user defined if user want to customize the series , zyc
121 #ifdef CONFIG_MT9D112_USER_DEFINED_SERIES
122 #include "mt9d112_user_series.c"
126 /* init 640X480 VGA */
127 static struct reginfo sensor_init_data[] =
129 {0x301A, 0x0ACC}, // RESET_REGISTER
130 {0x3202, 0x0008}, // STANDBY_CONTROL
131 {SEQUENCE_WAIT_MS, 10},
132 {0x341E, 0x8F09}, // PLL_CLK_IN_CONTROL
133 {0x341C, 0x0218}, // PLL_DIVIDERS1
134 {SEQUENCE_WAIT_MS, 1},
135 {0x341E, 0x8F09}, // PLL_CLK_IN_CONTROL
136 {0x341E, 0x8F08}, // PLL_CLK_IN_CONTROL
137 {0x3044, 0x0540}, // DARK_CONTROL
138 {0x3216, 0x02CF}, // INTERNAL_CLOCK_CONTROL
139 {0x321C, 0x0402}, // OF_CONTROL_STATUS
140 {0x3212, 0x0001}, // FACTORY_BYPASS
141 {0x341E, 0x8F09}, // PLL_CLK_IN_CONTROL
142 {0x341C, 0x0120}, // PLL_DIVIDERS1
143 {0x341E, 0x8F09}, // PLL_CLK_IN_CONTROL
144 {0x341E, 0x8F08}, // PLL_CLK_IN_CONTROL
145 {0x3044, 0x0540}, // DARK_CONTROL
146 {0x3216, 0x02CF}, // INTERNAL_CLOCK_CONTROL
147 {0x321C, 0x0402}, // OF_CONTROL_STATUS
148 {0x3212, 0x0001}, // FACTORY_BYPASS//¹©Æ·¸ÉÈųÌÐòÀûÓÃ֮ǰµÄ07005
149 #ifdef SENSOR_CCM_ONLY
168 {0x338C, 0x2703}, // MCU_ADDRESS
169 {0x3390, 0x0140}, // MCU_DATA_0
170 {0x338C, 0x2705}, // MCU_ADDRESS
171 {0x3390, 0x00F0}, // MCU_DATA_0
172 {0x338C, 0x2707}, // MCU_ADDRESS
173 {0x3390, 0x0640}, // MCU_DATA_0
174 {0x338C, 0x2709}, // MCU_ADDRESS
175 {0x3390, 0x04B0}, // MCU_DATA_0
176 {0x338C, 0x270D}, // MCU_ADDRESS
177 {0x3390, 0x0000}, // MCU_DATA_0
178 {0x338C, 0x270F}, // MCU_ADDRESS
179 {0x3390, 0x0000}, // MCU_DATA_0
180 {0x338C, 0x2711}, // MCU_ADDRESS
181 {0x3390, 0x04BD}, // MCU_DATA_0
182 {0x338C, 0x2713}, // MCU_ADDRESS
183 {0x3390, 0x064D}, // MCU_DATA_0
184 {0x338C, 0x2715}, // MCU_ADDRESS
185 {0x3390, 0x0022}, // MCU_DATA_0
187 {0x338C, 0x2717}, // MCU_ADDRESS
188 {0x3390, 0x2111}, // MCU_DATA_0
189 {0x338C, 0x2719}, // MCU_ADDRESS
190 {0x3390, 0x046C}, // MCU_DATA_0
191 {0x338C, 0x271B}, // MCU_ADDRESS
192 {0x3390, 0x024F}, // MCU_DATA_0
193 {0x338C, 0x271D}, // MCU_ADDRESS
194 {0x3390, 0x0102}, // MCU_DATA_0
195 {0x338C, 0x271F}, // MCU_ADDRESS
196 {0x3390, 0x0279}, // MCU_DATA_0
197 {0x338C, 0x2721}, // MCU_ADDRESS
198 {0x3390, 0x0155}, // MCU_DATA_0
199 {0x338C, 0x2723}, // MCU_ADDRESS
200 {0x3390, 0x0293}, // MCU_DATA_0
201 {0x338C, 0x2725}, // MCU_ADDRESS
202 {0x3390, 0x0824}, // MCU_DATA_0
203 {0x338C, 0x2727}, // MCU_ADDRESS
204 {0x3390, 0x2020}, // MCU_DATA_0
205 {0x338C, 0x2729}, // MCU_ADDRESS
206 {0x3390, 0x2020}, // MCU_DATA_0
207 {0x338C, 0x272B}, // MCU_ADDRESS
208 {0x3390, 0x1020}, // MCU_DATA_0
209 {0x338C, 0x272D}, // MCU_ADDRESS
210 {0x3390, 0x2007}, // MCU_DATA_0
211 {0x338C, 0x272F}, // MCU_ADDRESS
212 {0x3390, 0x0004}, // MCU_DATA_0
213 {0x338C, 0x2731}, // MCU_ADDRESS
214 {0x3390, 0x0004}, // MCU_DATA_0
215 {0x338C, 0x2733}, // MCU_ADDRESS
216 {0x3390, 0x04BB}, // MCU_DATA_0
217 {0x338C, 0x2735}, // MCU_ADDRESS
218 {0x3390, 0x064B}, // MCU_DATA_0
219 {0x338C, 0x2737}, // MCU_ADDRESS
220 {0x3390, 0x0000}, // MCU_DATA_0
221 {0x338C, 0x2739}, // MCU_ADDRESS
222 {0x3390, 0x2111}, // MCU_DATA_0
223 {0x338C, 0x273B}, // MCU_ADDRESS
224 {0x3390, 0x0024}, // MCU_DATA_0
225 {0x338C, 0x273D}, // MCU_ADDRESS
226 {0x3390, 0x0120}, // MCU_DATA_0
227 {0x338C, 0x273F}, // MCU_ADDRESS
228 {0x3390, 0x00A4}, // MCU_DATA_0
229 {0x338C, 0x2741}, // MCU_ADDRESS
230 {0x3390, 0x0169}, // MCU_DATA_0
231 {0x338C, 0x2743}, // MCU_ADDRESS
232 {0x3390, 0x00A4}, // MCU_DATA_0
233 {0x338C, 0x2745}, // MCU_ADDRESS
234 {0x3390, 0x04ED}, // MCU_DATA_0
235 {0x338C, 0x2747}, // MCU_ADDRESS
236 {0x3390, 0x0824}, // MCU_DATA_0
237 {0x338C, 0x2751}, // MCU_ADDRESS
238 {0x3390, 0x0000}, // MCU_DATA_0
239 {0x338C, 0x2753}, // MCU_ADDRESS
240 {0x3390, 0x0320}, // MCU_DATA_0
241 {0x338C, 0x2755}, // MCU_ADDRESS
242 {0x3390, 0x0000}, // MCU_DATA_0
243 {0x338C, 0x2757}, // MCU_ADDRESS
244 {0x3390, 0x0258}, // MCU_DATA_0
245 {0x338C, 0x275F}, // MCU_ADDRESS
246 {0x3390, 0x0000}, // MCU_DATA_0
247 {0x338C, 0x2761}, // MCU_ADDRESS
248 {0x3390, 0x0640}, // MCU_DATA_0
249 {0x338C, 0x2763}, // MCU_ADDRESS
250 {0x3390, 0x0000}, // MCU_DATA_0
251 {0x338C, 0x2765}, // MCU_ADDRESS
252 {0x3390, 0x04B0}, // MCU_DATA_0
253 {0x338C, 0x222E}, // MCU_ADDRESS
254 {0x3390, 0x0060}, // MCU_DATA_0
255 {0x338C, 0xA408}, // MCU_ADDRESS
256 {0x3390, 0x0017}, // MCU_DATA_0
257 {0x338C, 0xA409}, // MCU_ADDRESS
258 {0x3390, 0x001A}, // MCU_DATA_0
259 {0x338C, 0xA40A}, // MCU_ADDRESS
260 {0x3390, 0x001B}, // MCU_DATA_0
261 {0x338C, 0xA40B}, // MCU_ADDRESS
262 {0x3390, 0x001E}, // MCU_DATA_0
263 {0x338C, 0x2411}, // MCU_ADDRESS
264 {0x3390, 0x0060}, // MCU_DATA_0
265 {0x338C, 0x2413}, // MCU_ADDRESS
266 {0x3390, 0x0073}, // MCU_DATA_0
267 {0x338C, 0x2415}, // MCU_ADDRESS
268 {0x3390, 0x0060}, // MCU_DATA_0
269 {0x338C, 0x2417}, // MCU_ADDRESS
270 {0x3390, 0x0073}, // MCU_DATA_0
271 {0x338C, 0xA40D}, // MCU_ADDRESS
272 {0x3390, 0x0002}, // MCU_DATA_0
273 {0x338C, 0xA410}, // MCU_ADDRESS
274 {0x3390, 0x0001}, // MCU_DATA_0
275 {0x338C, 0xA103}, // MCU_ADDRESS
276 {0x3390, 0x0006}, // MCU_DATA_0
277 {0x338C, 0xA103}, // MCU_ADDRESS
278 {0x3390, 0x0005}, // MCU_DATA_0
279 {0x338C, 0x2703}, // MCU_ADDRESS
280 {0x3390, 0x0140}, // MCU_DATA_0
281 {0x338C, 0x2705}, // MCU_ADDRESS
282 {0x3390, 0x00F0}, // MCU_DATA_0
283 {0x338C, 0x2707}, // MCU_ADDRESS
284 {0x3390, 0x0640}, // MCU_DATA_0
285 {0x338C, 0x2709}, // MCU_ADDRESS
286 {0x3390, 0x04B0}, // MCU_DATA_0
287 {0x338C, 0x270D}, // MCU_ADDRESS
288 {0x3390, 0x0000}, // MCU_DATA_0
289 {0x338C, 0x270F}, // MCU_ADDRESS
290 {0x3390, 0x0000}, // MCU_DATA_0
291 {0x338C, 0x2711}, // MCU_ADDRESS
292 {0x3390, 0x04BD}, // MCU_DATA_0
293 {0x338C, 0x2713}, // MCU_ADDRESS
294 {0x3390, 0x064D}, // MCU_DATA_0
295 {0x338C, 0x2715}, // MCU_ADDRESS
296 {0x3390, 0x0022}, // MCU_DATA_0
297 {0x338C, 0x2717}, // MCU_ADDRESS
298 {0x3390, 0x2111}, // MCU_DATA_0
299 {0x338C, 0x2719}, // MCU_ADDRESS
300 {0x3390, 0x046C}, // MCU_DATA_0
301 {0x338C, 0x271B}, // MCU_ADDRESS
302 {0x3390, 0x024F}, // MCU_DATA_0
303 {0x338C, 0x271D}, // MCU_ADDRESS
304 {0x3390, 0x0102}, // MCU_DATA_0
305 {0x338C, 0x271F}, // MCU_ADDRESS
306 {0x3390, 0x0279}, // MCU_DATA_0
307 {0x338C, 0x2721}, // MCU_ADDRESS
308 {0x3390, 0x0155}, // MCU_DATA_0
309 {0x338C, 0x2723}, // MCU_ADDRESS
310 {0x3390, 0x0293}, // MCU_DATA_0
311 {0x338C, 0x2725}, // MCU_ADDRESS
312 {0x3390, 0x0824}, // MCU_DATA_0
313 {0x338C, 0x2727}, // MCU_ADDRESS
314 {0x3390, 0x2020}, // MCU_DATA_0
315 {0x338C, 0x2729}, // MCU_ADDRESS
316 {0x3390, 0x2020}, // MCU_DATA_0
317 {0x338C, 0x272B}, // MCU_ADDRESS
318 {0x3390, 0x1020}, // MCU_DATA_0
319 {0x338C, 0x272D}, // MCU_ADDRESS
320 {0x3390, 0x2007}, // MCU_DATA_0
321 {0x338C, 0x272F}, // MCU_ADDRESS
322 {0x3390, 0x0004}, // MCU_DATA_0
323 {0x338C, 0x2731}, // MCU_ADDRESS
324 {0x3390, 0x0004}, // MCU_DATA_0
325 {0x338C, 0x2733}, // MCU_ADDRESS
326 {0x3390, 0x04BB}, // MCU_DATA_0
327 {0x338C, 0x2735}, // MCU_ADDRESS
328 {0x3390, 0x064B}, // MCU_DATA_0
329 {0x338C, 0x2737}, // MCU_ADDRESS
330 {0x3390, 0x0000}, // MCU_DATA_0
331 {0x338C, 0x2739}, // MCU_ADDRESS
332 {0x3390, 0x2111}, // MCU_DATA_0
333 {0x338C, 0x273B}, // MCU_ADDRESS
334 {0x3390, 0x0024}, // MCU_DATA_0
335 {0x338C, 0x273D}, // MCU_ADDRESS
336 {0x3390, 0x0120}, // MCU_DATA_0
337 {0x338C, 0x273F}, // MCU_ADDRESS
338 {0x3390, 0x00A4}, // MCU_DATA_0
339 {0x338C, 0x2741}, // MCU_ADDRESS
340 {0x3390, 0x0169}, // MCU_DATA_0
341 {0x338C, 0x2743}, // MCU_ADDRESS
342 {0x3390, 0x00A4}, // MCU_DATA_0
343 {0x338C, 0x2745}, // MCU_ADDRESS
344 {0x3390, 0x04ED}, // MCU_DATA_0
345 {0x338C, 0x2747}, // MCU_ADDRESS
346 {0x3390, 0x0824}, // MCU_DATA_0
347 {0x338C, 0x2751}, // MCU_ADDRESS
348 {0x3390, 0x0000}, // MCU_DATA_0
349 {0x338C, 0x2753}, // MCU_ADDRESS
350 {0x3390, 0x0320}, // MCU_DATA_0
351 {0x338C, 0x2755}, // MCU_ADDRESS
352 {0x3390, 0x0000}, // MCU_DATA_0
353 {0x338C, 0x2757}, // MCU_ADDRESS
354 {0x3390, 0x0258}, // MCU_DATA_0
355 {0x338C, 0x275F}, // MCU_ADDRESS
356 {0x3390, 0x0000}, // MCU_DATA_0
357 {0x338C, 0x2761}, // MCU_ADDRESS
358 {0x3390, 0x0640}, // MCU_DATA_0
359 {0x338C, 0x2763}, // MCU_ADDRESS
360 {0x3390, 0x0000}, // MCU_DATA_0
361 {0x338C, 0x2765}, // MCU_ADDRESS
362 {0x3390, 0x04B0}, // MCU_DATA_0
363 {0x338C, 0x222E}, // MCU_ADDRESS
364 {0x3390, 0x0060}, // MCU_DATA_0
365 {0x338C, 0xA408}, // MCU_ADDRESS
366 {0x3390, 0x0017}, // MCU_DATA_0
367 {0x338C, 0xA409}, // MCU_ADDRESS
368 {0x3390, 0x001A}, // MCU_DATA_0
369 {0x338C, 0xA40A}, // MCU_ADDRESS
370 {0x3390, 0x001B}, // MCU_DATA_0
371 {0x338C, 0xA40B}, // MCU_ADDRESS
372 {0x3390, 0x001E}, // MCU_DATA_0
373 {0x338C, 0x2411}, // MCU_ADDRESS
374 {0x3390, 0x0060}, // MCU_DATA_0
375 {0x338C, 0x2413}, // MCU_ADDRESS
376 {0x3390, 0x0073}, // MCU_DATA_0
377 {0x338C, 0x2415}, // MCU_ADDRESS
378 {0x3390, 0x0060}, // MCU_DATA_0
379 {0x338C, 0x2417}, // MCU_ADDRESS
380 {0x3390, 0x0073}, // MCU_DATA_0
381 {0x338C, 0xA40D}, // MCU_ADDRESS
382 {0x3390, 0x0002}, // MCU_DATA_0
383 {0x338C, 0xA410}, // MCU_ADDRESS
384 {0x3390, 0x0001}, // MCU_DATA_0
385 {0x338C, 0xA103}, // MCU_ADDRESS
386 {0x3390, 0x0006}, // MCU_DATA_0
387 {SEQUENCE_WAIT_MS, 100},
388 {0x338C, 0xA103}, // MCU_ADDRESS
389 {0x3390, 0x0005}, // MCU_DATA_0
390 {SEQUENCE_WAIT_MS, 100},
393 //[Lens Correction 01/04/07 20:07:28]
394 {0x34CE, 0x01A0}, //LENS_CORRECTION_CONTROL
395 {0x34D0, 0x6532}, //ZONE_BOUNDS_X1_X2
396 {0x34D2, 0x3297}, //ZONE_BOUNDS_X0_X3
397 {0x34D4, 0x9664}, //ZONE_BOUNDS_X4_X5
398 {0x34D6, 0x4B25}, //ZONE_BOUNDS_Y1_Y2
399 {0x34D8, 0x2670}, //ZONE_BOUNDS_Y0_Y3
400 {0x34DA, 0x724C}, //ZONE_BOUNDS_Y4_Y5
401 {0x34DC, 0xFF01}, //CENTER_OFFSET
402 {0x34DE, 0x011F}, //FX_RED
403 {0x34E6, 0x00B3}, //FY_RED
404 {0x34EE, 0x0D8F}, //DF_DX_RED
405 {0x34F6, 0x0D6E}, //DF_DY_RED
406 {0x3500, 0xF51C}, //SECOND_DERIV_ZONE_0_RED
407 {0x3508, 0xFEF8}, //SECOND_DERIV_ZONE_1_RED
408 {0x3510, 0x212D}, //SECOND_DERIV_ZONE_2_RED
409 {0x3518, 0x212B}, //SECOND_DERIV_ZONE_3_RED
410 {0x3520, 0x1F2A}, //SECOND_DERIV_ZONE_4_RED
411 {0x3528, 0x2934}, //SECOND_DERIV_ZONE_5_RED
412 {0x3530, 0x17DB}, //SECOND_DERIV_ZONE_6_RED
413 {0x3538, 0xE7D6}, //SECOND_DERIV_ZONE_7_RED
414 {0x354C, 0x07C6}, //K_FACTOR_IN_K_FX_FY_R_TL
415 {0x3544, 0x07FF}, //K_FACTOR_IN_K_FX_FY_R_TR
416 {0x355C, 0x051C}, //K_FACTOR_IN_K_FX_FY_R_BL
417 {0x3554, 0x07FF}, //K_FACTOR_IN_K_FX_FY_R_BR
418 {0x34E0, 0x0137}, //FX_GREEN
419 {0x34E8, 0x00A8}, //FY_GREEN
420 {0x34F0, 0x0E3E}, //DF_DX_GREEN
421 {0x34F8, 0x0DCB}, //DF_DY_GREEN
422 {0x3502, 0xF20A}, //SECOND_DERIV_ZONE_0_GREEN
423 {0x350A, 0xFBE1}, //SECOND_DERIV_ZONE_1_GREEN
424 {0x3512, 0x1C26}, //SECOND_DERIV_ZONE_2_GREEN
425 {0x351A, 0x232B}, //SECOND_DERIV_ZONE_3_GREEN
426 {0x3522, 0x312E}, //SECOND_DERIV_ZONE_4_GREEN
427 {0x352A, 0x2121}, //SECOND_DERIV_ZONE_5_GREEN
428 {0x3532, 0xF106}, //SECOND_DERIV_ZONE_6_GREEN
429 {0x353A, 0x0C0D}, //SECOND_DERIV_ZONE_7_GREEN
430 {0x354E, 0x07FF}, //K_FACTOR_IN_K_FX_FY_G1_TL
431 {0x3546, 0x0638}, //K_FACTOR_IN_K_FX_FY_G1_TR
432 {0x355E, 0x07FF}, //K_FACTOR_IN_K_FX_FY_G1_BL
433 {0x3556, 0x0155}, //K_FACTOR_IN_K_FX_FY_G1_BR
434 {0x34E4, 0x0107}, //FX_BLUE
435 {0x34EC, 0x0079}, //FY_BLUE
436 {0x34F4, 0x0E19}, //DF_DX_BLUE
437 {0x34FC, 0x0D35}, //DF_DY_BLUE
438 {0x3506, 0x111C}, //SECOND_DERIV_ZONE_0_BLUE
439 {0x350E, 0x02E6}, //SECOND_DERIV_ZONE_1_BLUE
440 {0x3516, 0x2521}, //SECOND_DERIV_ZONE_2_BLUE
441 {0x351E, 0x2620}, //SECOND_DERIV_ZONE_3_BLUE
442 {0x3526, 0x1A25}, //SECOND_DERIV_ZONE_4_BLUE
443 {0x352E, 0x0B1D}, //SECOND_DERIV_ZONE_5_BLUE
444 {0x3536, 0xFD03}, //SECOND_DERIV_ZONE_6_BLUE
445 {0x353E, 0xB315}, //SECOND_DERIV_ZONE_7_BLUE
446 {0x3552, 0x06D0}, //K_FACTOR_IN_K_FX_FY_B_TL
447 {0x354A, 0x03FF}, //K_FACTOR_IN_K_FX_FY_B_TR
448 {0x3562, 0x07FF}, //K_FACTOR_IN_K_FX_FY_B_BL
449 {0x355A, 0x057B}, //K_FACTOR_IN_K_FX_FY_B_BR
450 {0x34E2, 0x011E}, //FX_GREEN2
451 {0x34EA, 0x008A}, //FY_GREEN2
452 {0x34F2, 0x0D6E}, //DF_DX_GREEN2
453 {0x34FA, 0x0D7F}, //DF_DY_GREEN2
454 {0x3504, 0xF822}, //SECOND_DERIV_ZONE_0_GREEN2
455 {0x350C, 0x0DFC}, //SECOND_DERIV_ZONE_1_GREEN2
456 {0x3514, 0x1F25}, //SECOND_DERIV_ZONE_2_GREEN2
457 {0x351C, 0x3032}, //SECOND_DERIV_ZONE_3_GREEN2
458 {0x3524, 0x2628}, //SECOND_DERIV_ZONE_4_GREEN2
459 {0x352C, 0x1523}, //SECOND_DERIV_ZONE_5_GREEN2
460 {0x3534, 0xFADF}, //SECOND_DERIV_ZONE_6_GREEN2
461 {0x353C, 0xDEF7}, //SECOND_DERIV_ZONE_7_GREEN2
462 {0x3550, 0x0109}, //K_FACTOR_IN_K_FX_FY_G2_TL
463 {0x3548, 0x0638}, //K_FACTOR_IN_K_FX_FY_G2_TR
464 {0x3560, 0x0638}, //K_FACTOR_IN_K_FX_FY_G2_BL
465 {0x3558, 0x07FF}, //K_FACTOR_IN_K_FX_FY_G2_BR
466 {0x3540, 0x0000}, //X2_FACTORS
467 {0x3542, 0x0000}, //GLOBAL_OFFSET_FXY_FUNCTION
468 {0x3210, 0x01FC}, // COLOR_PIPELINE_CONTROL
471 {0x338C, 0xA364}, // MCU_ADDRESS [AWB_KR_L]
472 {0x3390, 0x0080}, // MCU_DATA_0
473 {0x338C, 0xA364}, // MCU_ADDRESS [AWB_KR_L]
474 {0x3390, 0x0080}, // MCU_DATA_0
475 {0x338C, 0xA365}, // MCU_ADDRESS [AWB_KG_L]
476 {0x3390, 0x008C}, // MCU_DATA_0
477 {0x338C, 0xA365}, // MCU_ADDRESS [AWB_KG_L]
478 {0x3390, 0x008C}, // MCU_DATA_0
479 {0x338C, 0xA366}, // MCU_ADDRESS [AWB_KB_L]
480 {0x3390, 0x0082}, // MCU_DATA_0
481 {0x338C, 0xA366}, // MCU_ADDRESS [AWB_KB_L]
482 {0x3390, 0x0082}, // MCU_DATA_0
483 {0x338C, 0x2306}, // MCU_ADDRESS [AWB_CCM_L_0]
484 {0x3390, 0x0619}, // MCU_DATA_0
485 {0x338C, 0x2308}, // MCU_ADDRESS [AWB_CCM_L_1]
486 {0x3390, 0xFC80}, // MCU_DATA_0
487 {0x338C, 0x230A}, // MCU_ADDRESS [AWB_CCM_L_2]
488 {0x3390, 0xFEFB}, // MCU_DATA_0
489 {0x338C, 0x230C}, // MCU_ADDRESS [AWB_CCM_L_3]
490 {0x3390, 0xFEEE}, // MCU_DATA_0
491 {0x338C, 0x230E}, // MCU_ADDRESS [AWB_CCM_L_4]
492 {0x3390, 0x0571}, // MCU_DATA_0
493 {0x338C, 0x2310}, // MCU_ADDRESS [AWB_CCM_L_5]
494 {0x3390, 0xFE26}, // MCU_DATA_0
495 {0x338C, 0x2312}, // MCU_ADDRESS [AWB_CCM_L_6]
496 {0x3390, 0xFF0C}, // MCU_DATA_0
497 {0x338C, 0x2314}, // MCU_ADDRESS [AWB_CCM_L_7]
498 {0x3390, 0xFE48}, // MCU_DATA_0
499 {0x338C, 0x2316}, // MCU_ADDRESS [AWB_CCM_L_8]
500 {0x3390, 0x04A2}, // MCU_DATA_0
501 {0x338C, 0x2318}, // MCU_ADDRESS [AWB_CCM_L_9]
502 {0x3390, 0x0024}, // MCU_DATA_0
503 {0x338C, 0x231A}, // MCU_ADDRESS [AWB_CCM_L_10]
504 {0x3390, 0x003F}, // MCU_DATA_0
505 {0x338C, 0x231C}, // MCU_ADDRESS [AWB_CCM_RL_0]
506 {0x3390, 0xFDA7}, // MCU_DATA_0
507 {0x338C, 0x231E}, // MCU_ADDRESS [AWB_CCM_RL_1]
508 {0x3390, 0x0158}, // MCU_DATA_0
509 {0x338C, 0x2320}, // MCU_ADDRESS [AWB_CCM_RL_2]
510 {0x3390, 0x00EE}, // MCU_DATA_0
511 {0x338C, 0x2322}, // MCU_ADDRESS [AWB_CCM_RL_3]
512 {0x3390, 0x00D3}, // MCU_DATA_0
513 {0x338C, 0x2324}, // MCU_ADDRESS [AWB_CCM_RL_4]
514 {0x3390, 0xFC74}, // MCU_DATA_0
515 {0x338C, 0x2326}, // MCU_ADDRESS [AWB_CCM_RL_5]
516 {0x3390, 0x01A9}, // MCU_DATA_0
517 {0x338C, 0x2328}, // MCU_ADDRESS [AWB_CCM_RL_6]
518 {0x3390, 0x014B}, // MCU_DATA_0
519 {0x338C, 0x232A}, // MCU_ADDRESS [AWB_CCM_RL_7]
520 {0x3390, 0xFE9D}, // MCU_DATA_0
521 {0x338C, 0x232C}, // MCU_ADDRESS [AWB_CCM_RL_8]
522 {0x3390, 0xFF69}, // MCU_DATA_0
523 {0x338C, 0x232E}, // MCU_ADDRESS [AWB_CCM_RL_9]
524 {0x3390, 0x0018}, // MCU_DATA_0
525 {0x338C, 0x2330}, // MCU_ADDRESS [AWB_CCM_RL_10]
526 {0x3390, 0xFFEC}, // MCU_DATA_0
527 {0x338C, 0xA348}, // MCU_ADDRESS [AWB_GAIN_BUFFER_SPEED]
528 {0x3390, 0x0008}, // MCU_DATA_0
529 {0x338C, 0xA349}, // MCU_ADDRESS [AWB_JUMP_DIVISOR]
530 {0x3390, 0x0002}, // MCU_DATA_0
531 {0x338C, 0xA34A}, // MCU_ADDRESS [AWB_GAIN_MIN]
532 {0x3390, 0x0059}, // MCU_DATA_0
533 {0x338C, 0xA34B}, // MCU_ADDRESS [AWB_GAIN_MAX]
534 {0x3390, 0x00A6}, // MCU_DATA_0
535 {0x338C, 0xA34F}, // MCU_ADDRESS [AWB_CCM_POSITION_MIN]
536 {0x3390, 0x0000}, // MCU_DATA_0
537 {0x338C, 0xA350}, // MCU_ADDRESS [AWB_CCM_POSITION_MAX]
538 {0x3390, 0x007F}, // MCU_DATA_0
539 {0x338C, 0xA353}, // MCU_ADDRESS [AWB_MODE]
540 {0x3390, 0x0002}, // MCU_DATA_0
541 {0x338C, 0xA35B}, // MCU_ADDRESS [AWB_STEADY_BGAIN_OUT_MIN]
542 {0x3390, 0x0078}, // MCU_DATA_0
543 {0x338C, 0xA35C}, // MCU_ADDRESS [AWB_STEADY_BGAIN_OUT_MAX]
544 {0x3390, 0x0086}, // MCU_DATA_0
545 {0x338C, 0xA35D}, // MCU_ADDRESS [AWB_STEADY_BGAIN_IN_MIN]
546 {0x3390, 0x007E}, // MCU_DATA_0
547 {0x338C, 0xA35E}, // MCU_ADDRESS [AWB_STEADY_BGAIN_IN_MAX]
548 {0x3390, 0x0082}, // MCU_DATA_0
549 {0x338C, 0x235F}, // MCU_ADDRESS [AWB_CNT_PXL_TH]
550 {0x3390, 0x0040}, // MCU_DATA_0
551 {0x338C, 0xA361}, // MCU_ADDRESS [AWB_TG_MIN0]
552 {0x3390, 0x00C8}, // MCU_DATA_0
553 {0x338C, 0xA362}, // MCU_ADDRESS [AWB_TG_MAX0]
554 {0x3390, 0x00E1}, // MCU_DATA_0
555 {0x338C, 0xA302}, // MCU_ADDRESS [AWB_WINDOW_POS]
556 {0x3390, 0x0000}, // MCU_DATA_0
557 {0x338C, 0xA303}, // MCU_ADDRESS [AWB_WINDOW_SIZE]
558 {0x3390, 0x00EF}, // MCU_DATA_0
559 {0x338C, 0xA352}, // MCU_ADDRESS [AWB_SATURATION]
560 {0x3390, 0x001E}, // MCU_DATA_0
561 {0x338C, 0xA118}, // MCU_ADDRESS [SEQ_LLSAT1]
562 {0x3390, 0x001E}, // MCU_DATA_0
563 {0x338C, 0xA103}, // MCU_ADDRESS [SEQ_CMD]
564 {0x3390, 0x0005}, // MCU_DATA_0
566 {0x338C, 0xA76D}, // MCU_ADDRESS [MODE_GAM_CONT_A]
567 {0x3390, 0x0003}, // MCU_DATA_0
568 {0x338C, 0xA76F}, // MCU_ADDRESS [MODE_GAM_TABLE_A_0]
569 {0x3390, 0x0000}, // MCU_DATA_0
570 {0x338C, 0xA770}, // MCU_ADDRESS [MODE_GAM_TABLE_A_1]
571 {0x3390, 0x000B}, // MCU_DATA_0
572 {0x338C, 0xA771}, // MCU_ADDRESS [MODE_GAM_TABLE_A_2]
573 {0x3390, 0x0023}, // MCU_DATA_0
574 {0x338C, 0xA772}, // MCU_ADDRESS [MODE_GAM_TABLE_A_3]
575 {0x3390, 0x0043}, // MCU_DATA_0
576 {0x338C, 0xA773}, // MCU_ADDRESS [MODE_GAM_TABLE_A_4]
577 {0x3390, 0x006E}, // MCU_DATA_0
578 {0x338C, 0xA774}, // MCU_ADDRESS [MODE_GAM_TABLE_A_5]
579 {0x3390, 0x0090}, // MCU_DATA_0
580 {0x338C, 0xA775}, // MCU_ADDRESS [MODE_GAM_TABLE_A_6]
581 {0x3390, 0x00A8}, // MCU_DATA_0
582 {0x338C, 0xA776}, // MCU_ADDRESS [MODE_GAM_TABLE_A_7]
583 {0x3390, 0x00B9}, // MCU_DATA_0
584 {0x338C, 0xA777}, // MCU_ADDRESS [MODE_GAM_TABLE_A_8]
585 {0x3390, 0x00C6}, // MCU_DATA_0
586 {0x338C, 0xA778}, // MCU_ADDRESS [MODE_GAM_TABLE_A_9]
587 {0x3390, 0x00D0}, // MCU_DATA_0
588 {0x338C, 0xA779}, // MCU_ADDRESS [MODE_GAM_TABLE_A_10]
589 {0x3390, 0x00D9}, // MCU_DATA_0
590 {0x338C, 0xA77A}, // MCU_ADDRESS [MODE_GAM_TABLE_A_11]
591 {0x3390, 0x00E0}, // MCU_DATA_0
592 {0x338C, 0xA77B}, // MCU_ADDRESS [MODE_GAM_TABLE_A_12]
593 {0x3390, 0x00E6}, // MCU_DATA_0
594 {0x338C, 0xA77C}, // MCU_ADDRESS [MODE_GAM_TABLE_A_13]
595 {0x3390, 0x00EB}, // MCU_DATA_0
596 {0x338C, 0xA77D}, // MCU_ADDRESS [MODE_GAM_TABLE_A_14]
597 {0x3390, 0x00F0}, // MCU_DATA_0
598 {0x338C, 0xA77E}, // MCU_ADDRESS [MODE_GAM_TABLE_A_15]
599 {0x3390, 0x00F4}, // MCU_DATA_0
600 {0x338C, 0xA77F}, // MCU_ADDRESS [MODE_GAM_TABLE_A_16]
601 {0x3390, 0x00F8}, // MCU_DATA_0
602 {0x338C, 0xA780}, // MCU_ADDRESS [MODE_GAM_TABLE_A_17]
603 {0x3390, 0x00FC}, // MCU_DATA_0
604 {0x338C, 0xA781}, // MCU_ADDRESS [MODE_GAM_TABLE_A_18]
605 {0x3390, 0x00FF}, // MCU_DATA_0
607 {0x338C, 0xA102}, // MCU_ADDRESS
608 {0x3390, 0x002F}, // MCU_DATA_0
609 {0x338C, 0xA114}, // MCU_ADDRESS
610 {0x3390, 0x0005}, // MCU_DATA_0
611 {SEQUENCE_WAIT_MS, 20},
612 {0x338C, 0xA103}, // MCU_ADDRESS
613 {0x3390, 0x0005}, // MCU_DATA_0
615 {0x338C, 0xA206}, // MCU_ADDRESS [AE_TARGET]
616 {0x3390, 0x003C}, // MCU_DATA_0
620 /* 720p 15fps @ 1280x720 */
622 static struct reginfo sensor_720p[]=
627 /* 1080p, 0x15fps, 0xyuv @1920x1080 */
629 static struct reginfo sensor_1080p[]=
634 /* 2592X1944 QSXGA */
635 static struct reginfo sensor_qsxga[] =
640 static struct reginfo sensor_qxga[] =
646 static struct reginfo sensor_uxga[] =
648 {SEQUENCE_PROPERTY, SEQUENCE_CAPTURE},
666 static struct reginfo sensor_sxga[] =
668 {SEQUENCE_PROPERTY, SEQUENCE_CAPTURE},
686 static struct reginfo sensor_xga[] =
692 static struct reginfo sensor_svga[] =
698 static struct reginfo sensor_vga[] =
704 static struct reginfo sensor_cif[] =
710 static struct reginfo sensor_qvga[] =
716 static struct reginfo sensor_qcif[] =
724 static struct reginfo ov2655_qqvga[] =
768 static struct reginfo ov2655_Sharpness_auto[] =
773 static struct reginfo ov2655_Sharpness1[] =
779 static struct reginfo ov2655_Sharpness2[][3] =
786 static struct reginfo ov2655_Sharpness3[] =
792 static struct reginfo ov2655_Sharpness4[]=
799 static struct reginfo ov2655_Sharpness5[] =
807 static struct reginfo sensor_Preview2Capture[]=
809 {0x338C, 0xA120}, // MCU_ADDRESS [SEQ_CAP_MODE]
810 {0x3390, 0x0002}, // MCU_DATA_0
811 {0x338C, 0xA103}, // MCU_ADDRESS [SEQ_CMD]
812 {0x3390, 0x0002}, // MCU_DATA_0
813 {0x338C, 0xA102}, // MCU_ADDRESS [SEQ_CMD] cgz oppo 2008-09-26
818 static struct reginfo sensor_Capture2Preview[]=
820 {0x338C, 0xA120}, // MCU_ADDRESS [SEQ_CAP_MODE]
821 {0x3390, 0x0000}, // MCU_DATA_0
822 {0x338C, 0xA103}, // MCU_ADDRESS [SEQ_CMD]
823 {0x3390, 0x0001}, // MCU_DATA_0
827 static struct reginfo sensor_ClrFmt_YUYV[]=
832 static struct reginfo sensor_ClrFmt_UYVY[]=
838 #if CONFIG_SENSOR_WhiteBalance
839 static struct reginfo sensor_WhiteB_Auto[]=
842 {0x338C, 0xA34A}, // MCU_ADDRESS [AWB_GAIN_MIN]
843 {0x3390, 0x0059}, // MCU_DATA_0
844 {0x338C, 0xA34B}, // MCU_ADDRESS [AWB_GAIN_MAX]
845 {0x3390, 0x00A6}, // MCU_DATA_0
846 {0x338C, 0xA34F}, // MCU_ADDRESS [AWB_CCM_POSITION_MIN]
847 {0x3390, 0x0000}, // MCU_DATA_0
848 {0x338C, 0xA350}, // MCU_ADDRESS [AWB_CCM_POSITION_MAX]
849 {0x3390, 0x007F}, // MCU_DATA_0
852 /* Cloudy Colour Temperature : 6500K - 8000K */
853 static struct reginfo sensor_WhiteB_Cloudy[]=
856 {0x338C, 0xA34B}, // MCU_ADDRESS [AWB_GAIN_MAX]
857 {0x3390, 0x0080}, // MCU_DATA_0
858 {0x338C, 0xA34F}, // MCU_ADDRESS [AWB_CCM_POSITION_MIN]
859 {0x3390, 0x007F}, // MCU_DATA_0
860 {0x338C, 0xA350}, // MCU_ADDRESS [AWB_CCM_POSITION_MAX]
861 {0x3390, 0x007F}, // MCU_DATA_
864 /* ClearDay Colour Temperature : 5000K - 6500K */
865 static struct reginfo sensor_WhiteB_ClearDay[]=
868 {0x338C, 0xA34A}, // MCU_ADDRESS [AWB_GAIN_MIN]
869 {0x3390, 0x0080}, // MCU_DATA_0
870 {0x338C, 0xA34B}, // MCU_ADDRESS [AWB_GAIN_MAX]
871 {0x3390, 0x0080}, // MCU_DATA_0
872 {0x338C, 0xA34F}, // MCU_ADDRESS [AWB_CCM_POSITION_MIN]
873 {0x3390, 0x007E}, // MCU_DATA_0
874 {0x338C, 0xA350}, // MCU_ADDRESS [AWB_CCM_POSITION_MAX]
875 {0x3390, 0x007E}, // MCU_DATA_0
878 /* Office Colour Temperature : 3500K - 5000K */
879 static struct reginfo sensor_WhiteB_TungstenLamp1[]=
882 {0x338C, 0xA34A}, // MCU_ADDRESS [AWB_GAIN_MIN]
883 {0x3390, 0x0080}, // MCU_DATA_0
884 {0x338C, 0xA34B}, // MCU_ADDRESS [AWB_GAIN_MAX]
885 {0x3390, 0x0080}, // MCU_DATA_0
886 {0x338C, 0xA34F}, // MCU_ADDRESS [AWB_CCM_POSITION_MIN]
887 {0x3390, 0x0030}, // MCU_DATA_0
888 {0x338C, 0xA350}, // MCU_ADDRESS [AWB_CCM_POSITION_MAX]
889 {0x3390, 0x0030}, // MCU_DATA_0
892 /* Home Colour Temperature : 2500K - 3500K */
893 static struct reginfo sensor_WhiteB_TungstenLamp2[]=
896 {0x338C, 0xA34A}, // MCU_ADDRESS [AWB_GAIN_MIN]
897 {0x3390, 0x0080}, // MCU_DATA_0
898 {0x338C, 0xA34B}, // MCU_ADDRESS [AWB_GAIN_MAX]
899 {0x3390, 0x0080}, // MCU_DATA_0
900 {0x338C, 0xA34F}, // MCU_ADDRESS [AWB_CCM_POSITION_MIN]
901 {0x3390, 0x0032}, // MCU_DATA_0
902 {0x338C, 0xA350}, // MCU_ADDRESS [AWB_CCM_POSITION_MAX]
903 {0x3390, 0x0032}, // MCU_DATA_0
906 static struct reginfo *sensor_WhiteBalanceSeqe[] = {sensor_WhiteB_Auto, sensor_WhiteB_TungstenLamp1,sensor_WhiteB_TungstenLamp2,
907 sensor_WhiteB_ClearDay, sensor_WhiteB_Cloudy,NULL,
911 #if CONFIG_SENSOR_Brightness
912 static struct reginfo sensor_Brightness0[]=
917 static struct reginfo sensor_Brightness1[]=
922 static struct reginfo sensor_Brightness2[]=
927 static struct reginfo sensor_Brightness3[]=
932 static struct reginfo sensor_Brightness4[]=
937 static struct reginfo sensor_Brightness5[]=
941 static struct reginfo *sensor_BrightnessSeqe[] = {sensor_Brightness0, sensor_Brightness1, sensor_Brightness2, sensor_Brightness3,
942 sensor_Brightness4, sensor_Brightness5,NULL,
947 #if CONFIG_SENSOR_Effect
948 static struct reginfo sensor_Effect_Normal[] =
950 {0x338C, 0x2799}, // MCU_ADDRESS [MODE_SPEC_EFFECTS_A]
951 {0x3390, 0x6408}, // MCU_DATA_0
952 {0x338C, 0x279B}, // MCU_ADDRESS [MODE_SPEC_EFFECTS_B]
953 {0x3390, 0x6408}, // MCU_DATA_0
954 {0x338C, 0xA103}, // MCU_ADDRESS [SEQ_CMD]
955 {0x3390, 0x0005}, // MCU_DATA_0
959 static struct reginfo sensor_Effect_WandB[] =
961 {0x338C, 0x2799}, // MCU_ADDRESS [MODE_SPEC_EFFECTS_A]
962 {0x3390, 0x6409}, // MCU_DATA_0
963 {0x338C, 0x279B}, // MCU_ADDRESS [MODE_SPEC_EFFECTS_B]
964 {0x3390, 0x6409}, // MCU_DATA_0
965 {0x338C, 0xA103}, // MCU_ADDRESS [SEQ_CMD]
966 {0x3390, 0x0005}, // MCU_DATA_0
970 static struct reginfo sensor_Effect_Sepia[] =
972 {0x338C, 0x2799}, // MCU_ADDRESS [MODE_SPEC_EFFECTS_A]
973 {0x3390, 0x640A}, // MCU_DATA_0
974 {0x338C, 0x279B}, // MCU_ADDRESS [MODE_SPEC_EFFECTS_B]
975 {0x3390, 0x640A}, // MCU_DATA_0
976 {0x338C, 0xA103}, // MCU_ADDRESS [SEQ_CMD]
977 {0x3390, 0x0005}, // MCU_DATA_0
981 static struct reginfo sensor_Effect_Negative[] =
983 {0x338C, 0x2799}, // MCU_ADDRESS [MODE_SPEC_EFFECTS_A]
984 {0x3390, 0x640B}, // MCU_DATA_0
985 {0x338C, 0x279B}, // MCU_ADDRESS [MODE_SPEC_EFFECTS_B]
986 {0x3390, 0x640B}, // MCU_DATA_0
987 {0x338C, 0xA103}, // MCU_ADDRESS [SEQ_CMD]
988 {0x3390, 0x0005}, // MCU_DATA_0
991 static struct reginfo sensor_Effect_Bluish[] =
996 static struct reginfo sensor_Effect_Green[] =
1001 static struct reginfo sensor_Effect_Solarize[] =
1003 {SEQUENCE_END, 0x00}
1005 static struct reginfo *sensor_EffectSeqe[] = {sensor_Effect_Normal, sensor_Effect_WandB, sensor_Effect_Sepia,sensor_Effect_Negative,
1009 #if CONFIG_SENSOR_Exposure
1010 static struct reginfo sensor_Exposure0[]=
1012 {SEQUENCE_END, 0x00}
1015 static struct reginfo sensor_Exposure1[]=
1017 {SEQUENCE_END, 0x00}
1020 static struct reginfo sensor_Exposure2[]=
1022 {SEQUENCE_END, 0x00}
1025 static struct reginfo sensor_Exposure3[]=
1027 {SEQUENCE_END, 0x00}
1030 static struct reginfo sensor_Exposure4[]=
1032 {SEQUENCE_END, 0x00}
1035 static struct reginfo sensor_Exposure5[]=
1037 {SEQUENCE_END, 0x00}
1040 static struct reginfo sensor_Exposure6[]=
1042 {SEQUENCE_END, 0x00}
1045 static struct reginfo *sensor_ExposureSeqe[] = {sensor_Exposure0, sensor_Exposure1, sensor_Exposure2, sensor_Exposure3,
1046 sensor_Exposure4, sensor_Exposure5,sensor_Exposure6,NULL,
1049 #if CONFIG_SENSOR_Saturation
1050 static struct reginfo sensor_Saturation0[]=
1052 {SEQUENCE_END, 0x00}
1055 static struct reginfo sensor_Saturation1[]=
1057 {SEQUENCE_END, 0x00}
1060 static struct reginfo sensor_Saturation2[]=
1062 {SEQUENCE_END, 0x00}
1064 static struct reginfo *sensor_SaturationSeqe[] = {sensor_Saturation0, sensor_Saturation1, sensor_Saturation2, NULL,};
1067 #if CONFIG_SENSOR_Contrast
1068 static struct reginfo sensor_Contrast0[]=
1070 {SEQUENCE_END, 0x00}
1073 static struct reginfo sensor_Contrast1[]=
1075 {SEQUENCE_END, 0x00}
1078 static struct reginfo sensor_Contrast2[]=
1080 {SEQUENCE_END, 0x00}
1083 static struct reginfo sensor_Contrast3[]=
1085 {SEQUENCE_END, 0x00}
1088 static struct reginfo sensor_Contrast4[]=
1090 {SEQUENCE_END, 0x00}
1094 static struct reginfo sensor_Contrast5[]=
1096 {SEQUENCE_END, 0x00}
1099 static struct reginfo sensor_Contrast6[]=
1101 {SEQUENCE_END, 0x00}
1103 static struct reginfo *sensor_ContrastSeqe[] = {sensor_Contrast0, sensor_Contrast1, sensor_Contrast2, sensor_Contrast3,
1104 sensor_Contrast4, sensor_Contrast5, sensor_Contrast6, NULL,
1108 #if CONFIG_SENSOR_Mirror
1109 static struct reginfo sensor_MirrorOn[]=
1111 {SEQUENCE_END, 0x00}
1114 static struct reginfo sensor_MirrorOff[]=
1116 {SEQUENCE_END, 0x00}
1118 static struct reginfo *sensor_MirrorSeqe[] = {sensor_MirrorOff, sensor_MirrorOn,NULL,};
1120 #if CONFIG_SENSOR_Flip
1121 static struct reginfo sensor_FlipOn[]=
1123 {SEQUENCE_END, 0x00}
1126 static struct reginfo sensor_FlipOff[]=
1128 {SEQUENCE_END, 0x00}
1130 static struct reginfo *sensor_FlipSeqe[] = {sensor_FlipOff, sensor_FlipOn,NULL,};
1133 #if CONFIG_SENSOR_Scene
1134 static struct reginfo sensor_SceneAuto[] =
1136 {0x338C, 0xA102}, // MCU_ADDRESS
1137 {0x3390, 0x002F}, // MCU_DATA_0
1138 {0x338C, 0xA114}, // MCU_ADDRESS
1139 {0x3390, 0x0005}, // MCU_DATA_0
1140 {SEQUENCE_WAIT_MS, 20},
1141 {0x338C, 0xA103}, // MCU_ADDRESS
1142 {0x3390, 0x0005}, // MCU_DATA_0
1143 {SEQUENCE_END, 0x00}
1146 static struct reginfo sensor_SceneNight[] =
1148 {0x338C, 0xA102}, // MCU_ADDRESS
1149 {0x3390, 0x000F}, // MCU_DATA_0
1150 {SEQUENCE_WAIT_MS, 20},
1151 {0x338C, 0xA103}, // MCU_ADDRESS
1152 {0x3390, 0x0005}, // MCU_DATA_0
1153 {SEQUENCE_END, 0x00}
1155 static struct reginfo *sensor_SceneSeqe[] = {sensor_SceneAuto, sensor_SceneNight,NULL,};
1158 #if CONFIG_SENSOR_DigitalZoom
1159 static struct reginfo sensor_Zoom0[] =
1161 {SEQUENCE_END, 0x00}
1164 static struct reginfo sensor_Zoom1[] =
1166 {SEQUENCE_END, 0x00}
1169 static struct reginfo sensor_Zoom2[] =
1171 {SEQUENCE_END, 0x00}
1175 static struct reginfo sensor_Zoom3[] =
1177 {SEQUENCE_END, 0x00}
1179 static struct reginfo *sensor_ZoomSeqe[] = {sensor_Zoom0, sensor_Zoom1, sensor_Zoom2, sensor_Zoom3, NULL};
1181 static const struct v4l2_querymenu sensor_menus[] =
1183 #if CONFIG_SENSOR_WhiteBalance
1184 { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 0, .name = "auto", .reserved = 0, }, { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 1, .name = "incandescent", .reserved = 0,},
1185 { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 2, .name = "fluorescent", .reserved = 0,}, { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 3, .name = "daylight", .reserved = 0,},
1186 { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 4, .name = "cloudy-daylight", .reserved = 0,},
1189 #if CONFIG_SENSOR_Effect
1190 { .id = V4L2_CID_EFFECT, .index = 0, .name = "none", .reserved = 0, }, { .id = V4L2_CID_EFFECT, .index = 1, .name = "mono", .reserved = 0,},
1191 { .id = V4L2_CID_EFFECT, .index = 2, .name = "negative", .reserved = 0,}, { .id = V4L2_CID_EFFECT, .index = 3, .name = "sepia", .reserved = 0,},
1194 #if CONFIG_SENSOR_Scene
1195 { .id = V4L2_CID_SCENE, .index = 0, .name = "auto", .reserved = 0,} ,{ .id = V4L2_CID_SCENE, .index = 1, .name = "night", .reserved = 0,},
1198 #if CONFIG_SENSOR_Flash
1199 { .id = V4L2_CID_FLASH, .index = 0, .name = "off", .reserved = 0, }, { .id = V4L2_CID_FLASH, .index = 1, .name = "auto", .reserved = 0,},
1200 { .id = V4L2_CID_FLASH, .index = 2, .name = "on", .reserved = 0,}, { .id = V4L2_CID_FLASH, .index = 3, .name = "torch", .reserved = 0,},
1204 static struct v4l2_queryctrl sensor_controls[] =
1206 #if CONFIG_SENSOR_WhiteBalance
1208 .id = V4L2_CID_DO_WHITE_BALANCE,
1209 .type = V4L2_CTRL_TYPE_MENU,
1210 .name = "White Balance Control",
1218 #if CONFIG_SENSOR_Brightness
1220 .id = V4L2_CID_BRIGHTNESS,
1221 .type = V4L2_CTRL_TYPE_INTEGER,
1222 .name = "Brightness Control",
1230 #if CONFIG_SENSOR_Effect
1232 .id = V4L2_CID_EFFECT,
1233 .type = V4L2_CTRL_TYPE_MENU,
1234 .name = "Effect Control",
1242 #if CONFIG_SENSOR_Exposure
1244 .id = V4L2_CID_EXPOSURE,
1245 .type = V4L2_CTRL_TYPE_INTEGER,
1246 .name = "Exposure Control",
1254 #if CONFIG_SENSOR_Saturation
1256 .id = V4L2_CID_SATURATION,
1257 .type = V4L2_CTRL_TYPE_INTEGER,
1258 .name = "Saturation Control",
1266 #if CONFIG_SENSOR_Contrast
1268 .id = V4L2_CID_CONTRAST,
1269 .type = V4L2_CTRL_TYPE_INTEGER,
1270 .name = "Contrast Control",
1278 #if CONFIG_SENSOR_Mirror
1280 .id = V4L2_CID_HFLIP,
1281 .type = V4L2_CTRL_TYPE_BOOLEAN,
1282 .name = "Mirror Control",
1290 #if CONFIG_SENSOR_Flip
1292 .id = V4L2_CID_VFLIP,
1293 .type = V4L2_CTRL_TYPE_BOOLEAN,
1294 .name = "Flip Control",
1302 #if CONFIG_SENSOR_Scene
1304 .id = V4L2_CID_SCENE,
1305 .type = V4L2_CTRL_TYPE_MENU,
1306 .name = "Scene Control",
1314 #if CONFIG_SENSOR_DigitalZoom
1316 .id = V4L2_CID_ZOOM_RELATIVE,
1317 .type = V4L2_CTRL_TYPE_INTEGER,
1318 .name = "DigitalZoom Control",
1324 .id = V4L2_CID_ZOOM_ABSOLUTE,
1325 .type = V4L2_CTRL_TYPE_INTEGER,
1326 .name = "DigitalZoom Control",
1334 #if CONFIG_SENSOR_Focus
1336 .id = V4L2_CID_FOCUS_RELATIVE,
1337 .type = V4L2_CTRL_TYPE_INTEGER,
1338 .name = "Focus Control",
1344 .id = V4L2_CID_FOCUS_ABSOLUTE,
1345 .type = V4L2_CTRL_TYPE_INTEGER,
1346 .name = "Focus Control",
1350 .default_value = 125,
1353 .id = V4L2_CID_FOCUS_AUTO,
1354 .type = V4L2_CTRL_TYPE_BOOLEAN,
1355 .name = "Focus Control",
1361 .id = V4L2_CID_FOCUS_CONTINUOUS,
1362 .type = V4L2_CTRL_TYPE_BOOLEAN,
1363 .name = "Focus Control",
1371 #if CONFIG_SENSOR_Flash
1373 .id = V4L2_CID_FLASH,
1374 .type = V4L2_CTRL_TYPE_MENU,
1375 .name = "Flash Control",
1384 static int sensor_probe(struct i2c_client *client, const struct i2c_device_id *did);
1385 static int sensor_video_probe(struct soc_camera_device *icd, struct i2c_client *client);
1386 static int sensor_g_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl);
1387 static int sensor_s_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl);
1388 static int sensor_g_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl);
1389 static int sensor_s_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl);
1390 static int sensor_suspend(struct soc_camera_device *icd, pm_message_t pm_msg);
1391 static int sensor_resume(struct soc_camera_device *icd);
1392 static int sensor_set_bus_param(struct soc_camera_device *icd,unsigned long flags);
1393 static unsigned long sensor_query_bus_param(struct soc_camera_device *icd);
1394 #if CONFIG_SENSOR_Effect
1395 static int sensor_set_effect(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value);
1397 #if CONFIG_SENSOR_WhiteBalance
1398 static int sensor_set_whiteBalance(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value);
1400 static int sensor_deactivate(struct i2c_client *client);
1401 static struct soc_camera_ops sensor_ops =
1403 .suspend = sensor_suspend,
1404 .resume = sensor_resume,
1405 .set_bus_param = sensor_set_bus_param,
1406 .query_bus_param = sensor_query_bus_param,
1407 .controls = sensor_controls,
1408 .menus = sensor_menus,
1409 .num_controls = ARRAY_SIZE(sensor_controls),
1410 .num_menus = ARRAY_SIZE(sensor_menus),
1412 /* only one fixed colorspace per pixelcode */
1413 struct sensor_datafmt {
1414 enum v4l2_mbus_pixelcode code;
1415 enum v4l2_colorspace colorspace;
1418 /* Find a data format by a pixel code in an array */
1419 static const struct sensor_datafmt *sensor_find_datafmt(
1420 enum v4l2_mbus_pixelcode code, const struct sensor_datafmt *fmt,
1424 for (i = 0; i < n; i++)
1425 if (fmt[i].code == code)
1431 static const struct sensor_datafmt sensor_colour_fmts[] = {
1432 {V4L2_MBUS_FMT_UYVY8_2X8, V4L2_COLORSPACE_JPEG},
1433 {V4L2_MBUS_FMT_YUYV8_2X8, V4L2_COLORSPACE_JPEG}
1435 enum sensor_work_state
1437 sensor_work_ready = 0,
1442 struct i2c_client *client;
1443 struct delayed_work dwork;
1444 enum sensor_work_state state;
1447 typedef struct sensor_info_priv_s
1461 unsigned char mirror; /* HFLIP */
1462 unsigned char flip; /* VFLIP */
1469 struct reginfo *winseqe_cur_addr;
1470 struct sensor_datafmt fmt;
1471 unsigned int enable;
1472 unsigned int funmodule_state;
1473 } sensor_info_priv_t;
1477 struct sensor_parameter
1479 unsigned short int preview_maxlines;
1480 unsigned short int preview_exposure;
1481 unsigned short int preview_line_width;
1482 unsigned short int preview_gain;
1484 unsigned short int capture_framerate;
1485 unsigned short int preview_framerate;
1490 struct v4l2_subdev subdev;
1491 struct i2c_client *client;
1492 sensor_info_priv_t info_priv;
1493 struct sensor_parameter parameter;
1494 struct workqueue_struct *sensor_wq;
1495 struct sensor_work sensor_wk;
1496 struct mutex wq_lock;
1497 int model; /* V4L2_IDENT_OV* codes from v4l2-chip-ident.h */
1498 #if CONFIG_SENSOR_I2C_NOSCHED
1499 atomic_t tasklock_cnt;
1501 struct rk29camera_platform_data *sensor_io_request;
1502 struct rk29camera_gpio_res *sensor_gpio_res;
1505 static struct sensor* to_sensor(const struct i2c_client *client)
1507 return container_of(i2c_get_clientdata(client), struct sensor, subdev);
1510 static int sensor_task_lock(struct i2c_client *client, int lock)
1512 #if CONFIG_SENSOR_I2C_NOSCHED
1514 struct sensor *sensor = to_sensor(client);
1517 if (atomic_read(&sensor->tasklock_cnt) == 0) {
1518 while ((atomic_read(&client->adapter->bus_lock.count) < 1) && (cnt>0)) {
1519 SENSOR_TR("\n %s will obtain i2c in atomic, but i2c bus is locked! Wait...\n",SENSOR_NAME_STRING());
1523 if ((atomic_read(&client->adapter->bus_lock.count) < 1) && (cnt<=0)) {
1524 SENSOR_TR("\n %s obtain i2c fail in atomic!!\n",SENSOR_NAME_STRING());
1525 goto sensor_task_lock_err;
1530 atomic_add(1, &sensor->tasklock_cnt);
1532 if (atomic_read(&sensor->tasklock_cnt) > 0) {
1533 atomic_sub(1, &sensor->tasklock_cnt);
1535 if (atomic_read(&sensor->tasklock_cnt) == 0)
1540 sensor_task_lock_err:
1548 /* sensor register write */
1549 static int sensor_write(struct i2c_client *client, u16 reg, u16 val)
1553 struct i2c_msg msg[1];
1557 case SEQUENCE_WAIT_MS:
1563 case SEQUENCE_WAIT_US:
1569 case SEQUENCE_PROPERTY:
1576 buf[1] = reg & 0xFF;
1578 buf[3] = val & 0xFF;
1580 msg->addr = client->addr;
1581 msg->flags = client->flags;
1583 msg->len = sizeof(buf);
1584 msg->scl_rate = CONFIG_SENSOR_I2C_SPEED; /* ddl@rock-chips.com : 100kHz */
1585 msg->read_type = 0; /* fpga i2c:0==I2C_NORMAL : direct use number not enum for don't want include spi_fpga.h */
1590 while ((cnt-- > 0) && (err < 0)) { /* ddl@rock-chips.com : Transfer again if transent is failed */
1591 err = i2c_transfer(client->adapter, msg, 1);
1596 SENSOR_TR("\n %s write reg(0x%x, val:0x%x) failed, try to write again!\n",SENSOR_NAME_STRING(),reg, val);
1605 /* sensor register read */
1606 static int sensor_read(struct i2c_client *client, u16 reg, u16 *val)
1610 struct i2c_msg msg[2];
1613 buf[1] = reg & 0xFF;
1615 msg[0].addr = client->addr;
1616 msg[0].flags = client->flags;
1618 msg[0].len = sizeof(buf);
1619 msg[0].scl_rate = CONFIG_SENSOR_I2C_SPEED; /* ddl@rock-chips.com : 100kHz */
1620 msg[0].read_type = 2; /* fpga i2c:0==I2C_NO_STOP : direct use number not enum for don't want include spi_fpga.h */
1622 msg[1].addr = client->addr;
1623 msg[1].flags = client->flags|I2C_M_RD;
1626 msg[1].scl_rate = CONFIG_SENSOR_I2C_SPEED; /* ddl@rock-chips.com : 100kHz */
1627 msg[1].read_type = 2; /* fpga i2c:0==I2C_NO_STOP : direct use number not enum for don't want include spi_fpga.h */
1631 while ((cnt-- > 0) && (err < 0)) { /* ddl@rock-chips.com : Transfer again if transent is failed */
1632 err = i2c_transfer(client->adapter, msg, 2);
1638 SENSOR_TR("\n %s read reg(0x%x val:0x%x) failed, try to read again! \n",SENSOR_NAME_STRING(),reg, *val);
1646 /* write a array of registers */
1647 static int sensor_write_array(struct i2c_client *client, struct reginfo *regarray)
1651 #if CONFIG_SENSOR_I2C_RDWRCHK
1656 if (sensor_task_lock(client, 1) < 0)
1657 goto sensor_write_array_end;
1658 while (regarray[i].reg != SEQUENCE_END)
1661 err = sensor_write(client, regarray[i].reg, regarray[i].val);
1665 SENSOR_TR("%s..write failed current reg:0x%x, Write array again !\n", SENSOR_NAME_STRING(),regarray[i].reg);
1669 SENSOR_TR("%s..write array failed!!!\n", SENSOR_NAME_STRING());
1671 goto sensor_write_array_end;
1674 #if CONFIG_SENSOR_I2C_RDWRCHK
1675 sensor_read(client, regarray[i].reg, &valchk);
1676 if (valchk != regarray[i].val)
1677 SENSOR_TR("%s Reg:0x%x write(0x%x, 0x%x) fail\n",SENSOR_NAME_STRING(), regarray[i].reg, regarray[i].val, valchk);
1684 sensor_write_array_end:
1685 sensor_task_lock(client,0);
1688 #if CONFIG_SENSOR_I2C_RDWRCHK
1689 static int sensor_readchk_array(struct i2c_client *client, struct reginfo *regarray)
1697 while (regarray[i].reg != SEQUENCE_END)
1699 sensor_read(client, regarray[i].reg, &valchk);
1700 if (valchk != regarray[i].val)
1701 SENSOR_TR("%s Reg:0x%x read(0x%x, 0x%x) error\n",SENSOR_NAME_STRING(), regarray[i].reg, regarray[i].val, valchk);
1708 #if CONFIG_SENSOR_Focus
1710 static int sensor_af_single(struct i2c_client *client)
1715 sensor_af_single_end:
1719 static int sensor_af_const(struct i2c_client *client)
1723 sensor_af_const_end:
1727 static int sensor_af_zoneupdate(struct i2c_client *client)
1731 sensor_af_zoneupdate_end:
1735 static int sensor_af_init(struct i2c_client *client)
1743 static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd cmd, int on)
1745 struct soc_camera_link *icl = to_soc_camera_link(icd);
1748 SENSOR_DG("%s %s cmd(%d) on(%d)\n",SENSOR_NAME_STRING(),__FUNCTION__,cmd,on);
1751 case Sensor_PowerDown:
1753 if (icl->powerdown) {
1754 ret = icl->powerdown(icd->pdev, on);
1755 if (ret == RK29_CAM_IO_SUCCESS) {
1759 icl->reset(icd->pdev);
1761 } else if (ret == RK29_CAM_EIO_REQUESTFAIL) {
1763 goto sensor_power_end;
1770 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
1771 struct sensor *sensor = to_sensor(client);
1773 if (sensor->sensor_io_request && sensor->sensor_io_request->sensor_ioctrl) {
1774 sensor->sensor_io_request->sensor_ioctrl(icd->pdev,Cam_Flash, on);
1776 //flash off after 2 secs
1777 hrtimer_cancel(&(flash_off_timer.timer));
1778 hrtimer_start(&(flash_off_timer.timer),ktime_set(0, 800*1000*1000),HRTIMER_MODE_REL);
1785 SENSOR_TR("%s %s cmd(0x%x) is unknown!",SENSOR_NAME_STRING(),__FUNCTION__,cmd);
1794 static enum hrtimer_restart flash_off_func(struct hrtimer *timer){
1795 struct flash_timer *fps_timer = container_of(timer, struct flash_timer, timer);
1796 sensor_ioctrl(fps_timer->icd,Sensor_Flash,0);
1797 SENSOR_DG("%s %s !!!!!!",SENSOR_NAME_STRING(),__FUNCTION__);
1802 static int sensor_init(struct v4l2_subdev *sd, u32 val)
1804 struct i2c_client *client = v4l2_get_subdevdata(sd);
1805 struct soc_camera_device *icd = client->dev.platform_data;
1806 struct sensor *sensor = to_sensor(client);
1807 const struct v4l2_queryctrl *qctrl;
1808 const struct sensor_datafmt *fmt;
1810 #if (SENSOR_ID_REG != SEQUENCE_END)
1814 SENSOR_DG("\n%s..%s.. \n",SENSOR_NAME_STRING(),__FUNCTION__);
1816 if (sensor_ioctrl(icd, Sensor_PowerDown, 0) < 0) {
1818 goto sensor_INIT_ERR;
1822 if (sensor_task_lock(client,1)<0)
1823 goto sensor_INIT_ERR;
1825 #if (SENSOR_RESET_REG != SEQUENCE_END)
1826 ret = sensor_write(client, SENSOR_RESET_REG, SENSOR_RESET_VAL);
1828 SENSOR_TR("%s soft reset sensor failed\n",SENSOR_NAME_STRING());
1830 goto sensor_INIT_ERR;
1833 mdelay(5); //delay 5 microseconds
1836 /* check if it is an sensor sensor */
1837 #if (SENSOR_ID_REG != SEQUENCE_END)
1838 ret = sensor_read(client, SENSOR_ID_REG, &pid);
1840 SENSOR_TR("read chip id failed\n");
1842 goto sensor_INIT_ERR;
1845 SENSOR_DG("\n %s pid = 0x%x \n", SENSOR_NAME_STRING(), pid);
1849 if (pid == SENSOR_ID) {
1850 sensor->model = SENSOR_V4L2_IDENT;
1852 SENSOR_TR("error: %s mismatched pid = 0x%x\n", SENSOR_NAME_STRING(), pid);
1854 goto sensor_INIT_ERR;
1857 ret = sensor_write_array(client, sensor_init_data);
1860 SENSOR_TR("error: %s initial failed\n",SENSOR_NAME_STRING());
1861 goto sensor_INIT_ERR;
1863 sensor_task_lock(client,0);
1864 sensor->info_priv.preview_w = SENSOR_INIT_WIDTH;
1865 sensor->info_priv.preview_h = SENSOR_INIT_HEIGHT;
1866 sensor->info_priv.capture_w = SENSOR_MAX_WIDTH;
1867 sensor->info_priv.capture_h = SENSOR_MAX_HEIGHT;
1868 sensor->info_priv.winseqe_cur_addr = SENSOR_INIT_WINSEQADR;
1869 fmt = sensor_find_datafmt(SENSOR_INIT_PIXFMT,sensor_colour_fmts, ARRAY_SIZE(sensor_colour_fmts));
1871 SENSOR_TR("error: %s initial array colour fmts is not support!!",SENSOR_NAME_STRING());
1873 goto sensor_INIT_ERR;
1875 sensor->info_priv.fmt = *fmt;
1877 /* sensor sensor information for initialization */
1878 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE);
1880 sensor->info_priv.whiteBalance = qctrl->default_value;
1881 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_BRIGHTNESS);
1883 sensor->info_priv.brightness = qctrl->default_value;
1884 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT);
1886 sensor->info_priv.effect = qctrl->default_value;
1887 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EXPOSURE);
1889 sensor->info_priv.exposure = qctrl->default_value;
1891 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_SATURATION);
1893 sensor->info_priv.saturation = qctrl->default_value;
1894 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_CONTRAST);
1896 sensor->info_priv.contrast = qctrl->default_value;
1897 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_HFLIP);
1899 sensor->info_priv.mirror = qctrl->default_value;
1900 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_VFLIP);
1902 sensor->info_priv.flip = qctrl->default_value;
1903 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_SCENE);
1905 sensor->info_priv.scene = qctrl->default_value;
1906 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_ZOOM_ABSOLUTE);
1908 sensor->info_priv.digitalzoom = qctrl->default_value;
1910 /* ddl@rock-chips.com : if sensor support auto focus and flash, programer must run focus and flash code */
1911 #if CONFIG_SENSOR_Focus
1913 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FOCUS_ABSOLUTE);
1915 sensor->info_priv.focus = qctrl->default_value;
1918 #if CONFIG_SENSOR_Flash
1919 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH);
1921 sensor->info_priv.flash = qctrl->default_value;
1923 flash_off_timer.icd = icd;
1924 flash_off_timer.timer.function = flash_off_func;
1926 SENSOR_DG("\n%s..%s.. icd->width = %d.. icd->height %d\n",SENSOR_NAME_STRING(),((val == 0)?__FUNCTION__:"sensor_reinit"),icd->user_width,icd->user_height);
1930 sensor_task_lock(client,0);
1931 sensor_deactivate(client);
1934 static int sensor_deactivate(struct i2c_client *client)
1936 struct soc_camera_device *icd = client->dev.platform_data;
1938 SENSOR_DG("\n%s..%s.. Enter\n",SENSOR_NAME_STRING(),__FUNCTION__);
1940 /* ddl@rock-chips.com : all sensor output pin must change to input for other sensor */
1941 sensor_task_lock(client, 1);
1942 sensor_ioctrl(icd, Sensor_PowerDown, 1);
1944 /* ddl@rock-chips.com : sensor config init width , because next open sensor quickly(soc_camera_open -> Try to configure with default parameters) */
1945 icd->user_width = SENSOR_INIT_WIDTH;
1946 icd->user_height = SENSOR_INIT_HEIGHT;
1950 static struct reginfo sensor_power_down_sequence[]=
1954 static int sensor_suspend(struct soc_camera_device *icd, pm_message_t pm_msg)
1957 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
1959 if (pm_msg.event == PM_EVENT_SUSPEND) {
1960 SENSOR_DG("\n %s Enter Suspend.. \n", SENSOR_NAME_STRING());
1961 ret = sensor_write_array(client, sensor_power_down_sequence) ;
1963 SENSOR_TR("\n %s..%s WriteReg Fail.. \n", SENSOR_NAME_STRING(),__FUNCTION__);
1966 ret = sensor_ioctrl(icd, Sensor_PowerDown, 1);
1968 SENSOR_TR("\n %s suspend fail for turn on power!\n", SENSOR_NAME_STRING());
1973 SENSOR_TR("\n %s cann't suppout Suspend..\n",SENSOR_NAME_STRING());
1980 static int sensor_resume(struct soc_camera_device *icd)
1984 ret = sensor_ioctrl(icd, Sensor_PowerDown, 0);
1986 SENSOR_TR("\n %s resume fail for turn on power!\n", SENSOR_NAME_STRING());
1990 SENSOR_DG("\n %s Enter Resume.. \n", SENSOR_NAME_STRING());
1994 static int sensor_set_bus_param(struct soc_camera_device *icd,
1995 unsigned long flags)
2001 static unsigned long sensor_query_bus_param(struct soc_camera_device *icd)
2003 struct soc_camera_link *icl = to_soc_camera_link(icd);
2004 unsigned long flags = SENSOR_BUS_PARAM;
2006 return soc_camera_apply_sensor_flags(icl, flags);
2008 static int sensor_g_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
2010 struct i2c_client *client = v4l2_get_subdevdata(sd);
2011 struct soc_camera_device *icd = client->dev.platform_data;
2012 struct sensor *sensor = to_sensor(client);
2014 mf->width = icd->user_width;
2015 mf->height = icd->user_height;
2016 mf->code = sensor->info_priv.fmt.code;
2017 mf->colorspace = sensor->info_priv.fmt.colorspace;
2018 mf->field = V4L2_FIELD_NONE;
2022 static bool sensor_fmt_capturechk(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
2026 if ((mf->width == 1024) && (mf->height == 768)) {
2028 } else if ((mf->width == 1280) && (mf->height == 1024)) {
2030 } else if ((mf->width == 1600) && (mf->height == 1200)) {
2032 } else if ((mf->width == 2048) && (mf->height == 1536)) {
2034 } else if ((mf->width == 2592) && (mf->height == 1944)) {
2039 SENSOR_DG("%s %dx%d is capture format\n", __FUNCTION__, mf->width, mf->height);
2043 static bool sensor_fmt_videochk(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
2047 if ((mf->width == 1280) && (mf->height == 720)) {
2049 } else if ((mf->width == 1920) && (mf->height == 1080)) {
2054 SENSOR_DG("%s %dx%d is video format\n", __FUNCTION__, mf->width, mf->height);
2057 static int sensor_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
2059 struct i2c_client *client = v4l2_get_subdevdata(sd);
2060 struct sensor *sensor = to_sensor(client);
2061 const struct sensor_datafmt *fmt;
2062 struct reginfo *winseqe_set_addr=NULL;
2063 int ret = 0, set_w,set_h;
2065 fmt = sensor_find_datafmt(mf->code, sensor_colour_fmts,
2066 ARRAY_SIZE(sensor_colour_fmts));
2069 goto sensor_s_fmt_end;
2072 if (sensor->info_priv.fmt.code != mf->code) {
2075 case V4L2_MBUS_FMT_YUYV8_2X8:
2077 winseqe_set_addr = sensor_ClrFmt_YUYV;
2080 case V4L2_MBUS_FMT_UYVY8_2X8:
2082 winseqe_set_addr = sensor_ClrFmt_UYVY;
2088 if (winseqe_set_addr != NULL) {
2089 sensor_write_array(client, winseqe_set_addr);
2090 sensor->info_priv.fmt.code = mf->code;
2091 sensor->info_priv.fmt.colorspace= mf->colorspace;
2092 SENSOR_DG("%s v4l2_mbus_code:%d set success!\n", SENSOR_NAME_STRING(),mf->code);
2094 SENSOR_TR("%s v4l2_mbus_code:%d is invalidate!\n", SENSOR_NAME_STRING(),mf->code);
2100 if (((set_w <= 176) && (set_h <= 144)) && (sensor_qcif[0].reg!=SEQUENCE_END))
2102 winseqe_set_addr = sensor_qcif;
2106 else if (((set_w <= 320) && (set_h <= 240)) && (sensor_qvga[0].reg!=SEQUENCE_END))
2108 winseqe_set_addr = sensor_qvga;
2112 else if (((set_w <= 352) && (set_h<= 288)) && (sensor_cif[0].reg!=SEQUENCE_END))
2114 winseqe_set_addr = sensor_cif;
2118 else if (((set_w <= 640) && (set_h <= 480)) && (sensor_vga[0].reg!=SEQUENCE_END))
2120 winseqe_set_addr = sensor_vga;
2124 else if (((set_w <= 800) && (set_h <= 600)) && (sensor_svga[0].reg!=SEQUENCE_END))
2126 winseqe_set_addr = sensor_svga;
2130 else if (((set_w <= 1024) && (set_h <= 768)) && (sensor_xga[0].reg!=SEQUENCE_END))
2132 winseqe_set_addr = sensor_xga;
2136 else if (((set_w <= 1280) && (set_h <= 720)) && (sensor_720p[0].reg!=SEQUENCE_END))
2138 winseqe_set_addr = sensor_720p;
2142 else if (((set_w <= 1280) && (set_h <= 1024)) && (sensor_sxga[0].reg!=SEQUENCE_END))
2144 winseqe_set_addr = sensor_sxga;
2148 else if (((set_w <= 1600) && (set_h <= 1200)) && (sensor_uxga[0].reg!=SEQUENCE_END))
2150 winseqe_set_addr = sensor_uxga;
2154 else if (((set_w <= 1920) && (set_h <= 1080)) && (sensor_1080p[0].reg!=SEQUENCE_END))
2156 winseqe_set_addr = sensor_1080p;
2160 else if (((set_w <= 2048) && (set_h <= 1536)) && (sensor_qxga[0].reg!=SEQUENCE_END))
2162 winseqe_set_addr = sensor_qxga;
2166 else if (((set_w <= 2592) && (set_h <= 1944)) && (sensor_qsxga[0].reg!=SEQUENCE_END))
2168 winseqe_set_addr = sensor_qsxga;
2173 if ((winseqe_set_addr != sensor->info_priv.winseqe_cur_addr) && winseqe_set_addr) {
2174 ret |= sensor_write_array(client, winseqe_set_addr);
2176 SENSOR_TR("%s set format capability failed\n", SENSOR_NAME_STRING());
2177 goto sensor_s_fmt_end;
2179 sensor->info_priv.winseqe_cur_addr = winseqe_set_addr;
2180 if ((winseqe_set_addr[0].reg==SEQUENCE_PROPERTY) && (winseqe_set_addr[0].val==SEQUENCE_CAPTURE)) {
2181 SENSOR_DG("\n%s..%s..Capture icd->width = %d.. icd->height %d\n",SENSOR_NAME_STRING(),__FUNCTION__,set_w,set_h);
2183 SENSOR_DG("\n%s..%s..Video icd->width = %d.. icd->height %d\n",SENSOR_NAME_STRING(),__FUNCTION__,set_w,set_h);
2187 if (winseqe_set_addr && (winseqe_set_addr[0].reg==SEQUENCE_PROPERTY) && (winseqe_set_addr[0].val==SEQUENCE_CAPTURE)) {
2188 ret |= sensor_write_array(client, sensor_Preview2Capture);
2190 SENSOR_TR("%s Preview 2 Capture failed\n", SENSOR_NAME_STRING());
2191 goto sensor_s_fmt_end;
2193 sensor->info_priv.capture_w = set_w;
2194 sensor->info_priv.capture_h = set_h;
2195 sensor->info_priv.snap2preview = true;
2196 } else if (sensor->info_priv.snap2preview == true) {
2197 if (winseqe_set_addr || ((sensor->info_priv.preview_w == mf->width) && (sensor->info_priv.preview_h == mf->height))) {
2198 ret |= sensor_write_array(client, sensor_Capture2Preview);
2200 SENSOR_TR("%s Capture 2 Preview failed\n", SENSOR_NAME_STRING());
2201 goto sensor_s_fmt_end;
2203 sensor->info_priv.preview_w = mf->width;
2204 sensor->info_priv.preview_h = mf->height;
2205 sensor->info_priv.snap2preview = false;
2207 SENSOR_TR("\n %s..%s Format is Invalidate. pix->width = %d.. pix->height = %d\n",SENSOR_NAME_STRING(),__FUNCTION__,mf->width,mf->height);
2217 static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
2219 struct i2c_client *client = v4l2_get_subdevdata(sd);
2220 struct sensor *sensor = to_sensor(client);
2221 const struct sensor_datafmt *fmt;
2222 int ret = 0,set_w,set_h;
2224 fmt = sensor_find_datafmt(mf->code, sensor_colour_fmts,
2225 ARRAY_SIZE(sensor_colour_fmts));
2227 fmt = &sensor->info_priv.fmt;
2228 mf->code = fmt->code;
2231 if (mf->height > SENSOR_MAX_HEIGHT)
2232 mf->height = SENSOR_MAX_HEIGHT;
2233 else if (mf->height < SENSOR_MIN_HEIGHT)
2234 mf->height = SENSOR_MIN_HEIGHT;
2236 if (mf->width > SENSOR_MAX_WIDTH)
2237 mf->width = SENSOR_MAX_WIDTH;
2238 else if (mf->width < SENSOR_MIN_WIDTH)
2239 mf->width = SENSOR_MIN_WIDTH;
2243 if (((set_w <= 176) && (set_h <= 144)) && (sensor_qcif[0].reg!=SEQUENCE_END))
2248 else if (((set_w <= 320) && (set_h <= 240)) && (sensor_qvga[0].reg!=SEQUENCE_END))
2253 else if (((set_w <= 352) && (set_h<= 288)) && (sensor_cif[0].reg!=SEQUENCE_END))
2258 else if (((set_w <= 640) && (set_h <= 480)) && (sensor_vga[0].reg!=SEQUENCE_END))
2263 else if (((set_w <= 800) && (set_h <= 600)) && (sensor_svga[0].reg!=SEQUENCE_END))
2268 else if (((set_w <= 1024) && (set_h <= 768)) && (sensor_xga[0].reg!=SEQUENCE_END))
2273 else if (((set_w <= 1280) && (set_h <= 720)) && (sensor_720p[0].reg!=SEQUENCE_END))
2278 else if (((set_w <= 1280) && (set_h <= 1024)) && (sensor_sxga[0].reg!=SEQUENCE_END))
2283 else if (((set_w <= 1600) && (set_h <= 1200)) && (sensor_uxga[0].reg!=SEQUENCE_END))
2288 else if (((set_w <= 1920) && (set_h <= 1080)) && (sensor_1080p[0].reg!=SEQUENCE_END))
2293 else if (((set_w <= 2048) && (set_h <= 1536)) && (sensor_qxga[0].reg!=SEQUENCE_END))
2298 else if (((set_w <= 2592) && (set_h <= 1944)) && (sensor_qsxga[0].reg!=SEQUENCE_END))
2307 mf->colorspace = fmt->colorspace;
2312 static int sensor_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *id)
2314 struct i2c_client *client = v4l2_get_subdevdata(sd);
2316 if (id->match.type != V4L2_CHIP_MATCH_I2C_ADDR)
2319 if (id->match.addr != client->addr)
2322 id->ident = SENSOR_V4L2_IDENT; /* ddl@rock-chips.com : Return OV2655 identifier */
2327 #if CONFIG_SENSOR_Brightness
2328 static int sensor_set_brightness(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2330 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2332 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
2334 if (sensor_BrightnessSeqe[value - qctrl->minimum] != NULL)
2336 if (sensor_write_array(client, sensor_BrightnessSeqe[value - qctrl->minimum]) != 0)
2338 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2341 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2345 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2349 #if CONFIG_SENSOR_Effect
2350 static int sensor_set_effect(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2352 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2354 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
2356 if (sensor_EffectSeqe[value - qctrl->minimum] != NULL)
2358 if (sensor_write_array(client, sensor_EffectSeqe[value - qctrl->minimum]) != 0)
2360 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2363 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2367 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2371 #if CONFIG_SENSOR_Exposure
2372 static int sensor_set_exposure(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2374 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2376 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
2378 if (sensor_ExposureSeqe[value - qctrl->minimum] != NULL)
2380 if (sensor_write_array(client, sensor_ExposureSeqe[value - qctrl->minimum]) != 0)
2382 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2385 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2389 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2393 #if CONFIG_SENSOR_Saturation
2394 static int sensor_set_saturation(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2396 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2398 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
2400 if (sensor_SaturationSeqe[value - qctrl->minimum] != NULL)
2402 if (sensor_write_array(client, sensor_SaturationSeqe[value - qctrl->minimum]) != 0)
2404 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2407 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2411 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2415 #if CONFIG_SENSOR_Contrast
2416 static int sensor_set_contrast(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2418 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2420 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
2422 if (sensor_ContrastSeqe[value - qctrl->minimum] != NULL)
2424 if (sensor_write_array(client, sensor_ContrastSeqe[value - qctrl->minimum]) != 0)
2426 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2429 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2433 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2437 #if CONFIG_SENSOR_Mirror
2438 static int sensor_set_mirror(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2440 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2442 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
2444 if (sensor_MirrorSeqe[value - qctrl->minimum] != NULL)
2446 if (sensor_write_array(client, sensor_MirrorSeqe[value - qctrl->minimum]) != 0)
2448 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2451 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2455 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2459 #if CONFIG_SENSOR_Flip
2460 static int sensor_set_flip(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2462 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2464 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
2466 if (sensor_FlipSeqe[value - qctrl->minimum] != NULL)
2468 if (sensor_write_array(client, sensor_FlipSeqe[value - qctrl->minimum]) != 0)
2470 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2473 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2477 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2481 #if CONFIG_SENSOR_Scene
2482 static int sensor_set_scene(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2484 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2486 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
2488 if (sensor_SceneSeqe[value - qctrl->minimum] != NULL)
2490 if (sensor_write_array(client, sensor_SceneSeqe[value - qctrl->minimum]) != 0)
2492 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2495 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2499 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2503 #if CONFIG_SENSOR_WhiteBalance
2504 static int sensor_set_whiteBalance(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2506 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2508 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
2510 if (sensor_WhiteBalanceSeqe[value - qctrl->minimum] != NULL)
2512 if (sensor_write_array(client, sensor_WhiteBalanceSeqe[value - qctrl->minimum]) != 0)
2514 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2517 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2521 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2525 #if CONFIG_SENSOR_DigitalZoom
2526 static int sensor_set_digitalzoom(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int *value)
2528 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2529 struct sensor *sensor = to_sensor(client);
2530 const struct v4l2_queryctrl *qctrl_info;
2531 int digitalzoom_cur, digitalzoom_total;
2533 qctrl_info = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_ZOOM_ABSOLUTE);
2537 digitalzoom_cur = sensor->info_priv.digitalzoom;
2538 digitalzoom_total = qctrl_info->maximum;
2540 if ((*value > 0) && (digitalzoom_cur >= digitalzoom_total))
2542 SENSOR_TR("%s digitalzoom is maximum - %x\n", SENSOR_NAME_STRING(), digitalzoom_cur);
2546 if ((*value < 0) && (digitalzoom_cur <= qctrl_info->minimum))
2548 SENSOR_TR("%s digitalzoom is minimum - %x\n", SENSOR_NAME_STRING(), digitalzoom_cur);
2552 if ((*value > 0) && ((digitalzoom_cur + *value) > digitalzoom_total))
2554 *value = digitalzoom_total - digitalzoom_cur;
2557 if ((*value < 0) && ((digitalzoom_cur + *value) < 0))
2559 *value = 0 - digitalzoom_cur;
2562 digitalzoom_cur += *value;
2564 if (sensor_ZoomSeqe[digitalzoom_cur] != NULL)
2566 if (sensor_write_array(client, sensor_ZoomSeqe[digitalzoom_cur]) != 0)
2568 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
2571 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, *value);
2578 #if CONFIG_SENSOR_Flash
2579 static int sensor_set_flash(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2581 if ((value >= qctrl->minimum) && (value <= qctrl->maximum)) {
2582 if (value == 3) { /* ddl@rock-chips.com: torch */
2583 sensor_ioctrl(icd, Sensor_Flash, Flash_Torch); /* Flash On */
2585 sensor_ioctrl(icd, Sensor_Flash, Flash_Off);
2587 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
2591 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2595 #if CONFIG_SENSOR_Focus
2596 static int sensor_set_focus_absolute(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2598 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2599 struct sensor *sensor = to_sensor(client);
2600 const struct v4l2_queryctrl *qctrl_info;
2603 qctrl_info = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FOCUS_ABSOLUTE);
2607 if ((sensor->info_priv.funmodule_state & SENSOR_AF_IS_OK) && (sensor->info_priv.affm_reinit == 0)) {
2608 if ((value >= qctrl_info->minimum) && (value <= qctrl_info->maximum)) {
2610 SENSOR_DG("%s..%s : %d ret:0x%x\n",SENSOR_NAME_STRING(),__FUNCTION__, value,ret);
2613 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2617 SENSOR_TR("\n %s..%s AF module state(0x%x, 0x%x) is error!\n",SENSOR_NAME_STRING(),__FUNCTION__,
2618 sensor->info_priv.funmodule_state,sensor->info_priv.affm_reinit);
2621 sensor_set_focus_absolute_end:
2624 static int sensor_set_focus_relative(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2626 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2627 struct sensor *sensor = to_sensor(client);
2628 const struct v4l2_queryctrl *qctrl_info;
2631 qctrl_info = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FOCUS_RELATIVE);
2635 if ((sensor->info_priv.funmodule_state & SENSOR_AF_IS_OK) && (sensor->info_priv.affm_reinit == 0)) {
2636 if ((value >= qctrl_info->minimum) && (value <= qctrl_info->maximum)) {
2638 SENSOR_DG("%s..%s : %d ret:0x%x\n",SENSOR_NAME_STRING(),__FUNCTION__, value,ret);
2641 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2645 SENSOR_TR("\n %s..%s AF module state(0x%x, 0x%x) is error!\n",SENSOR_NAME_STRING(),__FUNCTION__,
2646 sensor->info_priv.funmodule_state,sensor->info_priv.affm_reinit);
2648 sensor_set_focus_relative_end:
2652 static int sensor_set_focus_mode(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
2654 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2655 struct sensor *sensor = to_sensor(client);
2658 if ((sensor->info_priv.funmodule_state & SENSOR_AF_IS_OK) && (sensor->info_priv.affm_reinit == 0)) {
2661 case SENSOR_AF_MODE_AUTO:
2663 ret = sensor_af_single(client);
2667 case SENSOR_AF_MODE_MACRO:
2669 ret = sensor_set_focus_absolute(icd, qctrl, 0xff);
2673 case SENSOR_AF_MODE_INFINITY:
2675 ret = sensor_set_focus_absolute(icd, qctrl, 0x00);
2679 case SENSOR_AF_MODE_CONTINUOUS:
2681 ret = sensor_af_const(client);
2685 SENSOR_TR("\n %s..%s AF value(0x%x) is error!\n",SENSOR_NAME_STRING(),__FUNCTION__,value);
2690 SENSOR_DG("%s..%s : %d ret:0x%x\n",SENSOR_NAME_STRING(),__FUNCTION__, value,ret);
2693 SENSOR_TR("\n %s..%s AF module state(0x%x, 0x%x) is error!\n",SENSOR_NAME_STRING(),__FUNCTION__,
2694 sensor->info_priv.funmodule_state,sensor->info_priv.affm_reinit);
2700 static int sensor_g_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
2702 struct i2c_client *client = v4l2_get_subdevdata(sd);
2703 struct sensor *sensor = to_sensor(client);
2704 const struct v4l2_queryctrl *qctrl;
2706 qctrl = soc_camera_find_qctrl(&sensor_ops, ctrl->id);
2710 SENSOR_TR("\n %s ioctrl id = %d is invalidate \n", SENSOR_NAME_STRING(), ctrl->id);
2716 case V4L2_CID_BRIGHTNESS:
2718 ctrl->value = sensor->info_priv.brightness;
2721 case V4L2_CID_SATURATION:
2723 ctrl->value = sensor->info_priv.saturation;
2726 case V4L2_CID_CONTRAST:
2728 ctrl->value = sensor->info_priv.contrast;
2731 case V4L2_CID_DO_WHITE_BALANCE:
2733 ctrl->value = sensor->info_priv.whiteBalance;
2736 case V4L2_CID_EXPOSURE:
2738 ctrl->value = sensor->info_priv.exposure;
2741 case V4L2_CID_HFLIP:
2743 ctrl->value = sensor->info_priv.mirror;
2746 case V4L2_CID_VFLIP:
2748 ctrl->value = sensor->info_priv.flip;
2759 static int sensor_s_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
2761 struct i2c_client *client = v4l2_get_subdevdata(sd);
2762 struct sensor *sensor = to_sensor(client);
2763 struct soc_camera_device *icd = client->dev.platform_data;
2764 const struct v4l2_queryctrl *qctrl;
2767 qctrl = soc_camera_find_qctrl(&sensor_ops, ctrl->id);
2771 SENSOR_TR("\n %s ioctrl id = %d is invalidate \n", SENSOR_NAME_STRING(), ctrl->id);
2777 #if CONFIG_SENSOR_Brightness
2778 case V4L2_CID_BRIGHTNESS:
2780 if (ctrl->value != sensor->info_priv.brightness)
2782 if (sensor_set_brightness(icd, qctrl,ctrl->value) != 0)
2786 sensor->info_priv.brightness = ctrl->value;
2791 #if CONFIG_SENSOR_Exposure
2792 case V4L2_CID_EXPOSURE:
2794 if (ctrl->value != sensor->info_priv.exposure)
2796 if (sensor_set_exposure(icd, qctrl,ctrl->value) != 0)
2800 sensor->info_priv.exposure = ctrl->value;
2805 #if CONFIG_SENSOR_Saturation
2806 case V4L2_CID_SATURATION:
2808 if (ctrl->value != sensor->info_priv.saturation)
2810 if (sensor_set_saturation(icd, qctrl,ctrl->value) != 0)
2814 sensor->info_priv.saturation = ctrl->value;
2819 #if CONFIG_SENSOR_Contrast
2820 case V4L2_CID_CONTRAST:
2822 if (ctrl->value != sensor->info_priv.contrast)
2824 if (sensor_set_contrast(icd, qctrl,ctrl->value) != 0)
2828 sensor->info_priv.contrast = ctrl->value;
2833 #if CONFIG_SENSOR_WhiteBalance
2834 case V4L2_CID_DO_WHITE_BALANCE:
2836 if (ctrl->value != sensor->info_priv.whiteBalance)
2838 if (sensor_set_whiteBalance(icd, qctrl,ctrl->value) != 0)
2842 sensor->info_priv.whiteBalance = ctrl->value;
2847 #if CONFIG_SENSOR_Mirror
2848 case V4L2_CID_HFLIP:
2850 if (ctrl->value != sensor->info_priv.mirror)
2852 if (sensor_set_mirror(icd, qctrl,ctrl->value) != 0)
2854 sensor->info_priv.mirror = ctrl->value;
2859 #if CONFIG_SENSOR_Flip
2860 case V4L2_CID_VFLIP:
2862 if (ctrl->value != sensor->info_priv.flip)
2864 if (sensor_set_flip(icd, qctrl,ctrl->value) != 0)
2866 sensor->info_priv.flip = ctrl->value;
2877 static int sensor_g_ext_control(struct soc_camera_device *icd , struct v4l2_ext_control *ext_ctrl)
2879 const struct v4l2_queryctrl *qctrl;
2880 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2881 struct sensor *sensor = to_sensor(client);
2883 qctrl = soc_camera_find_qctrl(&sensor_ops, ext_ctrl->id);
2887 SENSOR_TR("\n %s ioctrl id = %d is invalidate \n", SENSOR_NAME_STRING(), ext_ctrl->id);
2891 switch (ext_ctrl->id)
2893 case V4L2_CID_SCENE:
2895 ext_ctrl->value = sensor->info_priv.scene;
2898 case V4L2_CID_EFFECT:
2900 ext_ctrl->value = sensor->info_priv.effect;
2903 case V4L2_CID_ZOOM_ABSOLUTE:
2905 ext_ctrl->value = sensor->info_priv.digitalzoom;
2908 case V4L2_CID_ZOOM_RELATIVE:
2912 case V4L2_CID_FOCUS_ABSOLUTE:
2914 ext_ctrl->value = sensor->info_priv.focus;
2917 case V4L2_CID_FOCUS_RELATIVE:
2921 case V4L2_CID_FLASH:
2923 ext_ctrl->value = sensor->info_priv.flash;
2931 static int sensor_s_ext_control(struct soc_camera_device *icd, struct v4l2_ext_control *ext_ctrl)
2933 const struct v4l2_queryctrl *qctrl;
2934 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2935 struct sensor *sensor = to_sensor(client);
2938 qctrl = soc_camera_find_qctrl(&sensor_ops, ext_ctrl->id);
2942 SENSOR_TR("\n %s ioctrl id = %d is invalidate \n", SENSOR_NAME_STRING(), ext_ctrl->id);
2947 switch (ext_ctrl->id)
2949 #if CONFIG_SENSOR_Scene
2950 case V4L2_CID_SCENE:
2952 if (ext_ctrl->value != sensor->info_priv.scene)
2954 if (sensor_set_scene(icd, qctrl,ext_ctrl->value) != 0)
2956 sensor->info_priv.scene = ext_ctrl->value;
2961 #if CONFIG_SENSOR_Effect
2962 case V4L2_CID_EFFECT:
2964 if (ext_ctrl->value != sensor->info_priv.effect)
2966 if (sensor_set_effect(icd, qctrl,ext_ctrl->value) != 0)
2968 sensor->info_priv.effect= ext_ctrl->value;
2973 #if CONFIG_SENSOR_DigitalZoom
2974 case V4L2_CID_ZOOM_ABSOLUTE:
2976 if ((ext_ctrl->value < qctrl->minimum) || (ext_ctrl->value > qctrl->maximum))
2979 if (ext_ctrl->value != sensor->info_priv.digitalzoom)
2981 val_offset = ext_ctrl->value -sensor->info_priv.digitalzoom;
2983 if (sensor_set_digitalzoom(icd, qctrl,&val_offset) != 0)
2985 sensor->info_priv.digitalzoom += val_offset;
2987 SENSOR_DG("%s digitalzoom is %x\n",SENSOR_NAME_STRING(), sensor->info_priv.digitalzoom);
2992 case V4L2_CID_ZOOM_RELATIVE:
2994 if (ext_ctrl->value)
2996 if (sensor_set_digitalzoom(icd, qctrl,&ext_ctrl->value) != 0)
2998 sensor->info_priv.digitalzoom += ext_ctrl->value;
3000 SENSOR_DG("%s digitalzoom is %x\n", SENSOR_NAME_STRING(), sensor->info_priv.digitalzoom);
3005 #if CONFIG_SENSOR_Focus
3006 case V4L2_CID_FOCUS_ABSOLUTE:
3008 if ((ext_ctrl->value < qctrl->minimum) || (ext_ctrl->value > qctrl->maximum))
3011 if (sensor_set_focus_absolute(icd, qctrl,ext_ctrl->value) == 0) {
3012 if (ext_ctrl->value == qctrl->minimum) {
3013 sensor->info_priv.auto_focus = SENSOR_AF_MODE_INFINITY;
3014 } else if (ext_ctrl->value == qctrl->maximum) {
3015 sensor->info_priv.auto_focus = SENSOR_AF_MODE_MACRO;
3017 sensor->info_priv.auto_focus = SENSOR_AF_MODE_FIXED;
3023 case V4L2_CID_FOCUS_RELATIVE:
3025 if ((ext_ctrl->value < qctrl->minimum) || (ext_ctrl->value > qctrl->maximum))
3028 sensor_set_focus_relative(icd, qctrl,ext_ctrl->value);
3031 case V4L2_CID_FOCUS_AUTO:
3033 if (ext_ctrl->value == 1) {
3034 if (sensor_set_focus_mode(icd, qctrl,SENSOR_AF_MODE_AUTO) != 0)
3036 sensor->info_priv.auto_focus = SENSOR_AF_MODE_AUTO;
3037 } else if (SENSOR_AF_MODE_AUTO == sensor->info_priv.auto_focus){
3038 if (ext_ctrl->value == 0)
3039 sensor->info_priv.auto_focus = SENSOR_AF_MODE_CLOSE;
3043 case V4L2_CID_FOCUS_CONTINUOUS:
3045 if (SENSOR_AF_MODE_CONTINUOUS != sensor->info_priv.auto_focus) {
3046 if (ext_ctrl->value == 1) {
3047 if (sensor_set_focus_mode(icd, qctrl,SENSOR_AF_MODE_CONTINUOUS) != 0)
3049 sensor->info_priv.auto_focus = SENSOR_AF_MODE_CONTINUOUS;
3052 if (ext_ctrl->value == 0)
3053 sensor->info_priv.auto_focus = SENSOR_AF_MODE_CLOSE;
3058 #if CONFIG_SENSOR_Flash
3059 case V4L2_CID_FLASH:
3061 if (sensor_set_flash(icd, qctrl,ext_ctrl->value) != 0)
3063 sensor->info_priv.flash = ext_ctrl->value;
3065 SENSOR_DG("%s flash is %x\n",SENSOR_NAME_STRING(), sensor->info_priv.flash);
3076 static int sensor_g_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl)
3078 struct i2c_client *client = v4l2_get_subdevdata(sd);
3079 struct soc_camera_device *icd = client->dev.platform_data;
3080 int i, error_cnt=0, error_idx=-1;
3083 for (i=0; i<ext_ctrl->count; i++) {
3084 if (sensor_g_ext_control(icd, &ext_ctrl->controls[i]) != 0) {
3091 error_idx = ext_ctrl->count;
3093 if (error_idx != -1) {
3094 ext_ctrl->error_idx = error_idx;
3101 static int sensor_s_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl)
3103 struct i2c_client *client = v4l2_get_subdevdata(sd);
3104 struct soc_camera_device *icd = client->dev.platform_data;
3105 int i, error_cnt=0, error_idx=-1;
3107 for (i=0; i<ext_ctrl->count; i++) {
3108 if (sensor_s_ext_control(icd, &ext_ctrl->controls[i]) != 0) {
3115 error_idx = ext_ctrl->count;
3117 if (error_idx != -1) {
3118 ext_ctrl->error_idx = error_idx;
3125 static int sensor_s_stream(struct v4l2_subdev *sd, int enable)
3127 struct i2c_client *client = v4l2_get_subdevdata(sd);
3128 struct sensor *sensor = to_sensor(client);
3131 sensor->info_priv.enable = 1;
3132 } else if (enable == 0) {
3133 sensor->info_priv.enable = 0;
3139 /* Interface active, can use i2c. If it fails, it can indeed mean, that
3140 * this wasn't our capture interface, so, we wait for the right one */
3141 static int sensor_video_probe(struct soc_camera_device *icd,
3142 struct i2c_client *client)
3145 #if (SENSOR_ID_REG != SEQUENCE_END)
3149 struct sensor *sensor = to_sensor(client);
3151 /* We must have a parent by now. And it cannot be a wrong one.
3152 * So this entire test is completely redundant. */
3153 if (!icd->dev.parent ||
3154 to_soc_camera_host(icd->dev.parent)->nr != icd->iface)
3157 if (sensor_ioctrl(icd, Sensor_PowerDown, 0) < 0) {
3159 goto sensor_video_probe_err;
3163 #if (SENSOR_RESET_REG != SEQUENCE_END)
3164 ret = sensor_write(client, SENSOR_RESET_REG, SENSOR_RESET_VAL);
3166 SENSOR_TR("%s soft reset sensor failed\n",SENSOR_NAME_STRING());
3168 goto sensor_INIT_ERR;
3171 mdelay(5); //delay 5 microseconds
3174 /* check if it is an sensor sensor */
3175 #if (SENSOR_ID_REG != SEQUENCE_END)
3176 ret = sensor_read(client, SENSOR_ID_REG, &pid);
3178 SENSOR_TR("read chip id failed\n");
3180 goto sensor_video_probe_err;
3183 SENSOR_DG("\n %s pid = 0x%x \n", SENSOR_NAME_STRING(), pid);
3188 if (pid == SENSOR_ID) {
3189 sensor->model = SENSOR_V4L2_IDENT;
3191 SENSOR_TR("error: %s mismatched pid = 0x%x\n", SENSOR_NAME_STRING(), pid);
3193 goto sensor_video_probe_err;
3199 sensor_video_probe_err:
3202 static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
3204 struct i2c_client *client = v4l2_get_subdevdata(sd);
3205 struct soc_camera_device *icd = client->dev.platform_data;
3206 struct sensor *sensor = to_sensor(client);
3208 #if CONFIG_SENSOR_Flash
3212 SENSOR_DG("\n%s..%s..cmd:%x \n",SENSOR_NAME_STRING(),__FUNCTION__,cmd);
3215 case RK29_CAM_SUBDEV_DEACTIVATE:
3217 sensor_deactivate(client);
3220 case RK29_CAM_SUBDEV_IOREQUEST:
3222 sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
3223 if (sensor->sensor_io_request != NULL) {
3224 sensor->sensor_gpio_res = NULL;
3225 for (i=0; i<RK29_CAM_SUPPORT_NUMS;i++) {
3226 if (sensor->sensor_io_request->gpio_res[i].dev_name &&
3227 (strcmp(sensor->sensor_io_request->gpio_res[i].dev_name, dev_name(icd->pdev)) == 0)) {
3228 sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[i];
3231 if (sensor->sensor_gpio_res == NULL) {
3232 SENSOR_TR("%s %s obtain gpio resource failed when RK29_CAM_SUBDEV_IOREQUEST \n",SENSOR_NAME_STRING(),__FUNCTION__);
3234 goto sensor_ioctl_end;
3237 SENSOR_TR("%s %s RK29_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
3239 goto sensor_ioctl_end;
3241 /* ddl@rock-chips.com : if gpio_flash havn't been set in board-xxx.c, sensor driver must notify is not support flash control
3243 #if CONFIG_SENSOR_Flash
3244 if (sensor->sensor_gpio_res) {
3245 if (sensor->sensor_gpio_res->gpio_flash == INVALID_GPIO) {
3246 for (i = 0; i < icd->ops->num_controls; i++) {
3247 if (V4L2_CID_FLASH == icd->ops->controls[i].id) {
3248 //memset((char*)&icd->ops->controls[i],0x00,sizeof(struct v4l2_queryctrl));
3249 sensor_controls[i].id=0xffff;
3252 sensor->info_priv.flash = 0xff;
3253 SENSOR_DG("%s flash gpio is invalidate!\n",SENSOR_NAME_STRING());
3254 }else{ //two cameras are the same,need to deal diffrently ,zyc
3255 for (i = 0; i < icd->ops->num_controls; i++) {
3256 if(0xffff == icd->ops->controls[i].id){
3257 sensor_controls[i].id=V4L2_CID_FLASH;
3267 SENSOR_TR("%s %s cmd(0x%x) is unknown !\n",SENSOR_NAME_STRING(),__FUNCTION__,cmd);
3275 static int sensor_enum_fmt(struct v4l2_subdev *sd, unsigned int index,
3276 enum v4l2_mbus_pixelcode *code)
3278 if (index >= ARRAY_SIZE(sensor_colour_fmts))
3281 *code = sensor_colour_fmts[index].code;
3284 static struct v4l2_subdev_core_ops sensor_subdev_core_ops = {
3285 .init = sensor_init,
3286 .g_ctrl = sensor_g_control,
3287 .s_ctrl = sensor_s_control,
3288 .g_ext_ctrls = sensor_g_ext_controls,
3289 .s_ext_ctrls = sensor_s_ext_controls,
3290 .g_chip_ident = sensor_g_chip_ident,
3291 .ioctl = sensor_ioctl,
3294 static struct v4l2_subdev_video_ops sensor_subdev_video_ops = {
3295 .s_mbus_fmt = sensor_s_fmt,
3296 .g_mbus_fmt = sensor_g_fmt,
3297 .try_mbus_fmt = sensor_try_fmt,
3298 .enum_mbus_fmt = sensor_enum_fmt,
3301 static struct v4l2_subdev_ops sensor_subdev_ops = {
3302 .core = &sensor_subdev_core_ops,
3303 .video = &sensor_subdev_video_ops,
3306 static int sensor_probe(struct i2c_client *client,
3307 const struct i2c_device_id *did)
3309 struct sensor *sensor;
3310 struct soc_camera_device *icd = client->dev.platform_data;
3311 struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
3312 struct soc_camera_link *icl;
3315 SENSOR_DG("\n%s..%s..%d..\n",__FUNCTION__,__FILE__,__LINE__);
3317 dev_err(&client->dev, "%s: missing soc-camera data!\n",SENSOR_NAME_STRING());
3321 icl = to_soc_camera_link(icd);
3323 dev_err(&client->dev, "%s driver needs platform data\n", SENSOR_NAME_STRING());
3327 if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) {
3328 dev_warn(&adapter->dev,
3329 "I2C-Adapter doesn't support I2C_FUNC_I2C\n");
3333 sensor = kzalloc(sizeof(struct sensor), GFP_KERNEL);
3337 v4l2_i2c_subdev_init(&sensor->subdev, client, &sensor_subdev_ops);
3339 /* Second stage probe - when a capture adapter is there */
3340 icd->ops = &sensor_ops;
3341 sensor->info_priv.fmt = sensor_colour_fmts[0];
3342 #if CONFIG_SENSOR_I2C_NOSCHED
3343 atomic_set(&sensor->tasklock_cnt,0);
3346 ret = sensor_video_probe(icd, client);
3349 i2c_set_clientdata(client, NULL);
3353 hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL);
3354 SENSOR_DG("\n%s..%s..%d ret = %x \n",__FUNCTION__,__FILE__,__LINE__,ret);
3358 static int sensor_remove(struct i2c_client *client)
3360 struct sensor *sensor = to_sensor(client);
3361 struct soc_camera_device *icd = client->dev.platform_data;
3364 i2c_set_clientdata(client, NULL);
3365 client->driver = NULL;
3371 static const struct i2c_device_id sensor_id[] = {
3372 {SENSOR_NAME_STRING(), 0 },
3375 MODULE_DEVICE_TABLE(i2c, sensor_id);
3377 static struct i2c_driver sensor_i2c_driver = {
3379 .name = SENSOR_NAME_STRING(),
3381 .probe = sensor_probe,
3382 .remove = sensor_remove,
3383 .id_table = sensor_id,
3386 static int __init sensor_mod_init(void)
3388 SENSOR_DG("\n%s..%s.. \n",__FUNCTION__,SENSOR_NAME_STRING());
3389 return i2c_add_driver(&sensor_i2c_driver);
3392 static void __exit sensor_mod_exit(void)
3394 i2c_del_driver(&sensor_i2c_driver);
3397 device_initcall_sync(sensor_mod_init);
3398 module_exit(sensor_mod_exit);
3400 MODULE_DESCRIPTION(SENSOR_NAME_STRING(Camera sensor driver));
3401 MODULE_AUTHOR("ddl <kernel@rock-chips>");
3402 MODULE_LICENSE("GPL");