2 * Driver for OV5642 CMOS Image Sensor from OmniVision
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/hardirq.h>
19 #include <linux/miscdevice.h>
22 #include <media/v4l2-common.h>
23 #include <media/v4l2-chip-ident.h>
24 #include <media/soc_camera.h>
25 #include <plat/rk_camera.h>
29 module_param(debug, int, S_IRUGO|S_IWUSR);
31 #define dprintk(level, fmt, arg...) do { \
33 printk(KERN_WARNING fmt , ## arg); } while (0)
35 #define SENSOR_TR(format, ...) printk(KERN_ERR format, ## __VA_ARGS__)
36 #define SENSOR_DG(format, ...) dprintk(1, format, ## __VA_ARGS__)
38 #define _CONS(a,b) a##b
39 #define CONS(a,b) _CONS(a,b)
42 #define _STR(x) __STR(x)
43 #define STR(x) _STR(x)
45 #define MIN(x,y) ((x<y) ? x: y)
46 #define MAX(x,y) ((x>y) ? x: y)
48 /* Sensor Driver Configuration */
49 #define SENSOR_NAME RK29_CAM_SENSOR_MT9P111
50 #define SENSOR_V4L2_IDENT V4L2_IDENT_MT9P111
51 #define SENSOR_ID SEQUENCE_END
52 #define SENSOR_ID_REG SEQUENCE_END
53 #define SENSOR_RESET_REG 0x0010
54 #define SENSOR_RESET_VAL 0x0115
55 #define SENSOR_RESET_REG_LEN WORD_LEN
56 #define SENSOR_MIN_WIDTH 176
57 #define SENSOR_MIN_HEIGHT 144
58 #define SENSOR_MAX_WIDTH 2592
59 #define SENSOR_MAX_HEIGHT 1944
60 #define SENSOR_INIT_WIDTH 640 /* Sensor pixel size for sensor_init_data array */
61 #define SENSOR_INIT_HEIGHT 480
62 #define SENSOR_INIT_WINSEQADR sensor_vga
63 #define SENSOR_INIT_PIXFMT V4L2_MBUS_FMT_UYVY8_2X8
64 #define YUV420_BUFFER_MAX_SIZE 7558272 /* 2592*1944*1.5*/
66 #define CONFIG_SENSOR_WhiteBalance 1
67 #define CONFIG_SENSOR_Brightness 0
68 #define CONFIG_SENSOR_Contrast 0
69 #define CONFIG_SENSOR_Saturation 0
70 #define CONFIG_SENSOR_Effect 1
71 #define CONFIG_SENSOR_Scene 1
72 #define CONFIG_SENSOR_DigitalZoom 0
73 #define CONFIG_SENSOR_Exposure 0
74 #define CONFIG_SENSOR_Flash 1
75 #define CONFIG_SENSOR_Mirror 0
76 #define CONFIG_SENSOR_Flip 1
77 #define CONFIG_SENSOR_Focus 1
80 #define CONFIG_SENSOR_I2C_SPEED 100000 /* Hz */
81 //#define CONFIG_SENSOR_I2C_SPEED 350000 /* Hz */
83 /* Sensor write register continues by preempt_disable/preempt_enable for current process not be scheduled */
84 #define CONFIG_SENSOR_I2C_NOSCHED 0
85 #define CONFIG_SENSOR_I2C_RDWRCHK 0
88 #define SENSOR_BUS_PARAM (SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING|\
89 SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_HIGH|\
90 SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATAWIDTH_8 |SOCAM_MCLK_24MHZ)
92 #define COLOR_TEMPERATURE_CLOUDY_DN 6500
93 #define COLOR_TEMPERATURE_CLOUDY_UP 8000
94 #define COLOR_TEMPERATURE_CLEARDAY_DN 5000
95 #define COLOR_TEMPERATURE_CLEARDAY_UP 6500
96 #define COLOR_TEMPERATURE_OFFICE_DN 3500
97 #define COLOR_TEMPERATURE_OFFICE_UP 5000
98 #define COLOR_TEMPERATURE_HOME_DN 2500
99 #define COLOR_TEMPERATURE_HOME_UP 3500
101 #define SENSOR_NAME_STRING(a) STR(CONS(SENSOR_NAME, a))
102 #define SENSOR_NAME_VARFUN(a) CONS(SENSOR_NAME, a)
104 #define SENSOR_AF_IS_ERR (0x00<<0)
105 #define SENSOR_AF_IS_OK (0x01<<0)
106 #define SENSOR_INIT_IS_ERR (0x00<<28)
107 #define SENSOR_INIT_IS_OK (0x01<<28)
111 #if CONFIG_SENSOR_Focus
112 #define SENSOR_AF_MODE_INFINITY 0
113 #define SENSOR_AF_MODE_MACRO 1
114 #define SENSOR_AF_MODE_FIXED 2
115 #define SENSOR_AF_MODE_AUTO 3
116 #define SENSOR_AF_MODE_CONTINUOUS 4
117 #define SENSOR_AF_MODE_CLOSE 5
120 //flash off in fixed time to prevent from too hot , zyc
122 struct soc_camera_device *icd;
123 struct hrtimer timer;
125 static enum hrtimer_restart flash_off_func(struct hrtimer *timer);
127 static struct flash_timer flash_off_timer;
128 //for user defined if user want to customize the series , zyc
129 #if CONFIG_MT9P111_USER_DEFINED_SERIES
130 #include "mt9p111_user_series.c"
133 /* init 640X480 VGA */
134 static struct reginfo sensor_init_data[] =
137 //for 24MHz input, VCO=MAX=768mhz
138 { 0x0010, 0x0340, WORD_LEN, 0},
139 /*sovle problem that lack of pclk during one href*/
140 #if ADJUST_PCLK_FRE_FALG
141 { 0x0012, 0x0080, WORD_LEN, 0}, //PCLK=85MHz
143 { 0x0012, 0x0090, WORD_LEN, 0}, //PCLK=76MHz
145 { 0x0014, 0x2025, WORD_LEN, 0},
146 { 0x001E, 0x0565, WORD_LEN, 0}, // PAD_SLEW_PAD_CONFIG
147 { 0x0022, 0x0030, WORD_LEN, 0}, //0x01E0// VDD_DIS_COUNTER
148 #if ADJUST_PCLK_FRE_FALG
149 { 0x002A, 0x7FFF, WORD_LEN, 0},
151 { 0x002A, 0x7F7E, WORD_LEN, 0}, //0x7F7F// PLL_P4_P5_P6_DIVIDERS By Hwang 20101104
153 { 0x002C, 0x0000, WORD_LEN, 0}, // PLL_P7_DIVIDER
154 { 0x002E, 0x0000, WORD_LEN, 0}, // SENSOR_CLOCK_DIVIDER
155 { 0x0018, 0x4008, WORD_LEN, 0}, // STANDBY_CONTROL_AND_STATUS
156 //////{ SEQUENCE_WAIT_MS,100,WORD_LEN, 0},
157 { SEQUENCE_WAIT_MS,20,WORD_LEN, 0},
159 { 0x0010, 0x0340, WORD_LEN, 0}, // PLL_DIVIDERS
160 { 0x098E, 0x483A, WORD_LEN, 0}, // LOGICAL_ADDRESS_ACCESS [CAM_CORE_A_Y_ADDR_START]
161 { 0xC83A, 0x000C, WORD_LEN, 0}, // CAM_CORE_A_Y_ADDR_START
162 { 0xC83C, 0x0018, WORD_LEN, 0}, // CAM_CORE_A_X_ADDR_START
163 { 0xC83E, 0x07B1, WORD_LEN, 0}, // CAM_CORE_A_Y_ADDR_END
164 { 0xC840, 0x0A45, WORD_LEN, 0}, // CAM_CORE_A_X_ADDR_END
165 { 0xC842, 0x0001, WORD_LEN, 0}, // CAM_CORE_A_ROW_SPEED
166 { 0xC844, 0x0103, WORD_LEN, 0}, // CAM_CORE_A_SKIP_X_CORE
167 { 0xC846, 0x0103, WORD_LEN, 0}, // CAM_CORE_A_SKIP_Y_CORE
168 { 0xC848, 0x0103, WORD_LEN, 0}, // CAM_CORE_A_SKIP_X_PIPE
169 { 0xC84A, 0x0103, WORD_LEN, 0}, // CAM_CORE_A_SKIP_Y_PIPE
170 { 0xC84C, 0x00F6, WORD_LEN, 0}, // CAM_CORE_A_POWER_MODE
171 { 0xC84E, 0x0001, WORD_LEN, 0}, // CAM_CORE_A_BIN_MODE
172 /*lzg@rock-chips.com, FIH:preview image to be mirrored and flipped */
173 #if CONFIG_SENSOR_NONE_FLIP_MIRROR
174 { 0xC850, 0x00, BYTE_LEN, 0}, // CAM_CORE_A_ORIENTATION
175 #elif CONFIG_SENSOR_MIRROR
176 { 0xC850, 0x01, BYTE_LEN, 0}, // CAM_CORE_A_ORIENTATION
177 #elif CONFIG_SENSOR_FLIPE
178 { 0xC850, 0x02, BYTE_LEN, 0}, // CAM_CORE_A_ORIENTATION
179 #elif CONFIG_SENSOR_MIRROR_AND_FLIPE
180 { 0xC850, 0x03, BYTE_LEN, 0}, // CAM_CORE_A_ORIENTATION
182 { 0xC851, 0x00, BYTE_LEN, 0}, // CAM_CORE_A_PIXEL_ORDER
183 { 0xC852, 0x019C, WORD_LEN, 0}, // CAM_CORE_A_FINE_CORRECTION
184 { 0xC854, 0x0732, WORD_LEN, 0}, // CAM_CORE_A_FINE_ITMIN
185 { 0xC858, 0x0000, WORD_LEN, 0}, // CAM_CORE_A_COARSE_ITMIN
186 { 0xC85A, 0x0001, WORD_LEN, 0}, // CAM_CORE_A_COARSE_ITMAX_MARGIN
187 { 0xC85C, 0x0423, WORD_LEN, 0}, // CAM_CORE_A_MIN_FRAME_LENGTH_LINES
188 { 0xC85E, 0xFFFF, WORD_LEN, 0}, // CAM_CORE_A_MAX_FRAME_LENGTH_LINS
189 { 0xC860, 0x0423, WORD_LEN, 0}, // CAM_CORE_A_BASE_FRAME_LENGTH_LINES
190 { 0xC862, 0x1194, WORD_LEN, 0}, // CAM_CORE_A_MIN_LINE_LENGTH_PCLK
191 { 0xC864, 0xFFFE, WORD_LEN, 0}, // CAM_CORE_A_MAX_LINE_LENGTH_PCLK
192 { 0xC866, 0x7F7F, WORD_LEN, 0}, // CAM_CORE_A_P4_5_6_DIVIDER
193 { 0xC868, 0x0423, WORD_LEN, 0}, // CAM_CORE_A_FRAME_LENGTH_LINES
194 { 0xC86A, 0x1194, WORD_LEN, 0}, // CAM_CORE_A_LINE_LENGTH_PCK
195 { 0xC86C, 0x0518, WORD_LEN, 0}, // CAM_CORE_A_OUTPUT_SIZE_WIDTH
196 { 0xC86E, 0x03D4, WORD_LEN, 0}, // CAM_CORE_A_OUTPUT_SIZE_HEIGHT
197 { 0xC870, 0x0014, WORD_LEN, 0}, // CAM_CORE_A_RX_FIFO_TRIGGER_MARK
198 { 0xC858, 0x0003, WORD_LEN, 0}, // CAM_CORE_A_COARSE_ITMIN
199 { 0xC8B8, 0x0004, WORD_LEN, 0}, // CAM_OUTPUT_0_JPEG_CONTROL
200 { 0xC8AE, 0x0001, WORD_LEN, 0}, // CAM_OUTPUT_0_OUTPUT_FORMAT
201 { 0xC8AA, 0x0280, WORD_LEN, 0}, // CAM_OUTPUT_0_IMAGE_WIDTH
202 { 0xC8AC, 0x01E0, WORD_LEN, 0}, // CAM_OUTPUT_0_IMAGE_HEIGHT
203 { 0xC872, 0x0010, WORD_LEN, 0}, // CAM_CORE_B_Y_ADDR_START
204 { 0xC874, 0x001C, WORD_LEN, 0}, // CAM_CORE_B_X_ADDR_START
205 { 0xC876, 0x07AF, WORD_LEN, 0}, // CAM_CORE_B_Y_ADDR_END
206 { 0xC878, 0x0A43, WORD_LEN, 0}, // CAM_CORE_B_X_ADDR_END
207 { 0xC87A, 0x0001, WORD_LEN, 0}, // CAM_CORE_B_ROW_SPEED
208 { 0xC87C, 0x0101, WORD_LEN, 0}, // CAM_CORE_B_SKIP_X_CORE
209 { 0xC87E, 0x0101, WORD_LEN, 0}, // CAM_CORE_B_SKIP_Y_CORE
210 { 0xC880, 0x0101, WORD_LEN, 0}, // CAM_CORE_B_SKIP_X_PIPE
211 { 0xC882, 0x0101, WORD_LEN, 0}, // CAM_CORE_B_SKIP_Y_PIPE
212 { 0xC884, 0x00F2, WORD_LEN, 0}, // CAM_CORE_B_POWER_MODE
213 { 0xC886, 0x0000, WORD_LEN, 0}, // CAM_CORE_B_BIN_MODE
214 /*lzg@rock-chips.com, FIH:capture image to be mirrored and flipped */
215 #if CONFIG_SENSOR_NONE_FLIP_MIRROR
216 { 0xC888, 0x00, BYTE_LEN, 0}, // CAM_CORE_A_ORIENTATION
217 #elif CONFIG_SENSOR_MIRROR
218 { 0xC888, 0x01, BYTE_LEN, 0}, // CAM_CORE_A_ORIENTATION
219 #elif CONFIG_SENSOR_FLIPE
220 { 0xC888, 0x02, BYTE_LEN, 0}, // CAM_CORE_A_ORIENTATION
221 #elif CONFIG_SENSOR_MIRROR_AND_FLIPE
222 { 0xC888, 0x03, BYTE_LEN, 0}, // CAM_CORE_A_ORIENTATION
224 { 0xC889, 0x00, BYTE_LEN, 0}, // CAM_CORE_B_PIXEL_ORDER
225 { 0xC88A, 0x009C, WORD_LEN, 0}, // CAM_CORE_B_FINE_CORRECTION
226 { 0xC88C, 0x034A, WORD_LEN, 0}, // CAM_CORE_B_FINE_ITMIN
227 { 0xC890, 0x0000, WORD_LEN, 0}, // CAM_CORE_B_COARSE_ITMIN
228 { 0xC892, 0x0001, WORD_LEN, 0}, // CAM_CORE_B_COARSE_ITMAX_MARGIN
229 { 0xC894, 0x07EF, WORD_LEN, 0}, // CAM_CORE_B_MIN_FRAME_LENGTH_LINES
230 { 0xC896, 0xFFFF, WORD_LEN, 0}, // CAM_CORE_B_MAX_FRAME_LENGTH_LINES
231 { 0xC898, 0x082F, WORD_LEN, 0}, // CAM_CORE_B_BASE_FRAME_LENGTH_LINES
232 { 0xC89A, 0x1964, WORD_LEN, 0}, // CAM_CORE_B_MIN_LINE_LENGTH_PCLK
233 { 0xC89C, 0xFFFE, WORD_LEN, 0}, // CAM_CORE_B_MAX_LINE_LENGTH_PCLK
234 { 0xC89E, 0x7F7F, WORD_LEN, 0}, // CAM_CORE_B_P4_5_6_DIVIDER
235 { 0xC8A0, 0x07EF, WORD_LEN, 0}, // CAM_CORE_B_FRAME_LENGTH_LINES
236 { 0xC8A2, 0x1964, WORD_LEN, 0}, // CAM_CORE_B_LINE_LENGTH_PCK
237 { 0xC8A4, 0x0A28, WORD_LEN, 0}, // CAM_CORE_B_OUTPUT_SIZE_WIDTH
238 { 0xC8A6, 0x07A0, WORD_LEN, 0}, // CAM_CORE_B_OUTPUT_SIZE_HEIGHT
239 { 0xC8A8, 0x0124, WORD_LEN, 0}, // CAM_CORE_B_RX_FIFO_TRIGGER_MARK
240 { 0xC890, 0x0003, WORD_LEN, 0}, // CAM_CORE_B_COARSE_ITMIN
241 { 0xC8C0, 0x0A20, WORD_LEN, 0}, // CAM_OUTPUT_1_IMAGE_WIDTH
242 { 0xC8C2, 0x0798, WORD_LEN, 0}, // CAM_OUTPUT_1_IMAGE_HEIGHT
243 { 0xC89A, 0x1964, WORD_LEN, 0}, // CAM_CORE_B_MIN_LINE_LENGTH_PCLK
244 { 0xC8A2, 0x1964, WORD_LEN, 0}, // CAM_CORE_B_LINE_LENGTH_PCK
245 { 0xC8C4, 0x0001, WORD_LEN, 0}, // CAM_OUTPUT_1_OUTPUT_FORMAT
246 { 0xC8C6, 0x0000, WORD_LEN, 0}, // CAM_OUTPUT_1_OUTPUT_FORMAT_ORDER
247 { 0xC8CE, 0x0014, WORD_LEN, 0}, // CAM_OUTPUT_1_JPEG_CONTROL
248 { 0xD822, 0x4610, WORD_LEN, 0}, // JPEG_JPSS_CTRL_VAR
249 { 0x3330, 0x0000, WORD_LEN, 0}, // OUTPUT_FORMAT_TEST
250 { 0x098E, 0xA00E, WORD_LEN, 0}, // LOGICAL_ADDRESS_ACCESS
251 { 0xA00E, 0x32, BYTE_LEN, 0}, // FD_MAX_NUM_AUTOCOR_FUNC_VALUES_TO_CHECK
252 { 0xA010, 0x00CC, WORD_LEN, 0}, // FD_MIN_EXPECTED50HZ_FLICKER_PERIOD
253 { 0xA012, 0x00E0, WORD_LEN, 0}, // FD_MAX_EXPECTED50HZ_FLICKER_PERIOD
254 { 0xA014, 0x00A8, WORD_LEN, 0}, // FD_MIN_EXPECTED60HZ_FLICKER_PERIOD
255 { 0xA016, 0x00BC, WORD_LEN, 0}, // FD_MAX_EXPECTED60HZ_FLICKER_PERIOD
256 { 0xA018, 0x00D6, WORD_LEN, 0}, // FD_EXPECTED50HZ_FLICKER_PERIOD_IN_CONTEXT_A
257 { 0xA01A, 0x0075, WORD_LEN, 0}, // FD_EXPECTED50HZ_FLICKER_PERIOD_IN_CONTEXT_B
258 { 0xA01C, 0x00B2, WORD_LEN, 0}, // FD_EXPECTED60HZ_FLICKER_PERIOD_IN_CONTEXT_A
259 { 0xA01E, 0x0062, WORD_LEN, 0}, // FD_EXPECTED60HZ_FLICKER_PERIOD_IN_CONTEXT_B
260 { 0xA000, 0x10, BYTE_LEN, 0}, // FD_STATUS
261 { 0x8417, 0x02, BYTE_LEN, 0}, // SEQ_STATE_CFG_1_FD
262 { 0x8404, 0x06, BYTE_LEN, 0}, // SEQ_CMD
263 //////{ SEQUENCE_WAIT_MS,300, BYTE_LEN, 0},
264 { SEQUENCE_WAIT_MS,100, BYTE_LEN, 0},
265 //[Step3-Recommended]
266 //[k28a_rev3_FW_patch7]
267 // k28a_rev03_patch07_CR30221_MCNEX_AWB_AFNOISE_YOFFSET_APGA_REV1
268 { 0x0982, 0x0000, WORD_LEN, 0}, // ACCESS_CTL_STAT
269 { 0x098A, 0x0000, WORD_LEN, 0}, // PHYSICAL_ADDRESS_ACCESS
270 { 0x886C, 0xC0F1, WORD_LEN, 0},
271 { 0x886E, 0xC5E1, WORD_LEN, 0},
272 { 0x8870, 0x246A, WORD_LEN, 0},
273 { 0x8872, 0x1280, WORD_LEN, 0},
274 { 0x8874, 0xC4E1, WORD_LEN, 0},
275 { 0x8876, 0xD20F, WORD_LEN, 0},
276 { 0x8878, 0x2069, WORD_LEN, 0},
277 { 0x887A, 0x0000, WORD_LEN, 0},
278 { 0x887C, 0x6A62, WORD_LEN, 0},
279 { 0x887E, 0x1303, WORD_LEN, 0},
280 { 0x8880, 0x0084, WORD_LEN, 0},
281 { 0x8882, 0x1734, WORD_LEN, 0},
282 { 0x8884, 0x7005, WORD_LEN, 0},
283 { 0x8886, 0xD801, WORD_LEN, 0},
284 { 0x8888, 0x8A41, WORD_LEN, 0},
285 { 0x888A, 0xD900, WORD_LEN, 0},
286 { 0x888C, 0x0D5A, WORD_LEN, 0},
287 { 0x888E, 0x0664, WORD_LEN, 0},
288 { 0x8890, 0x8B61, WORD_LEN, 0},
289 { 0x8892, 0xE80B, WORD_LEN, 0},
290 { 0x8894, 0x000D, WORD_LEN, 0},
291 { 0x8896, 0x0020, WORD_LEN, 0},
292 { 0x8898, 0xD508, WORD_LEN, 0},
293 { 0x889A, 0x1504, WORD_LEN, 0},
294 { 0x889C, 0x1400, WORD_LEN, 0},
295 { 0x889E, 0x7840, WORD_LEN, 0},
296 { 0x88A0, 0xD007, WORD_LEN, 0},
297 { 0x88A2, 0x0DFB, WORD_LEN, 0},
298 { 0x88A4, 0x9004, WORD_LEN, 0},
299 { 0x88A6, 0xC4C1, WORD_LEN, 0},
300 { 0x88A8, 0x2029, WORD_LEN, 0},
301 { 0x88AA, 0x0300, WORD_LEN, 0},
302 { 0x88AC, 0x0219, WORD_LEN, 0},
303 { 0x88AE, 0x06C4, WORD_LEN, 0},
304 { 0x88B0, 0xFF80, WORD_LEN, 0},
305 { 0x88B2, 0x08C8, WORD_LEN, 0},
306 { 0x88B4, 0xFF80, WORD_LEN, 0},
307 { 0x88B6, 0x086C, WORD_LEN, 0},
308 { 0x88B8, 0xFF80, WORD_LEN, 0},
309 { 0x88BA, 0x08C0, WORD_LEN, 0},
310 { 0x88BC, 0xFF80, WORD_LEN, 0},
311 { 0x88BE, 0x08C8, WORD_LEN, 0},
312 { 0x88C0, 0xFF80, WORD_LEN, 0},
313 { 0x88C2, 0x08D0, WORD_LEN, 0},
314 { 0x88C4, 0xFF80, WORD_LEN, 0},
315 { 0x88C6, 0x0978, WORD_LEN, 0},
316 { 0x88C8, 0x0007, WORD_LEN, 0},
317 { 0x88CA, 0x0001, WORD_LEN, 0},
318 { 0x88CC, 0x0000, WORD_LEN, 0},
319 { 0x88CE, 0x0000, WORD_LEN, 0},
320 { 0x88D0, 0xC0F1, WORD_LEN, 0},
321 { 0x88D2, 0x097E, WORD_LEN, 0},
322 { 0x88D4, 0x06E4, WORD_LEN, 0},
323 { 0x88D6, 0xDA14, WORD_LEN, 0},
324 { 0x88D8, 0xD0C8, WORD_LEN, 0},
325 { 0x88DA, 0xDE00, WORD_LEN, 0},
326 { 0x88DC, 0xD1C8, WORD_LEN, 0},
327 { 0x88DE, 0x2E41, WORD_LEN, 0},
328 { 0x88E0, 0x120C, WORD_LEN, 0},
329 { 0x88E2, 0xA895, WORD_LEN, 0},
330 { 0x88E4, 0xD5C7, WORD_LEN, 0},
331 { 0x88E6, 0xA8D4, WORD_LEN, 0},
332 { 0x88E8, 0xA8D6, WORD_LEN, 0},
333 { 0x88EA, 0x0F0A, WORD_LEN, 0},
334 { 0x88EC, 0x06A4, WORD_LEN, 0},
335 { 0x88EE, 0x2555, WORD_LEN, 0},
336 { 0x88F0, 0x1440, WORD_LEN, 0},
337 { 0x88F2, 0xD0C5, WORD_LEN, 0},
338 { 0x88F4, 0x2555, WORD_LEN, 0},
339 { 0x88F6, 0x1441, WORD_LEN, 0},
340 { 0x88F8, 0x77A9, WORD_LEN, 0},
341 { 0x88FA, 0xA515, WORD_LEN, 0},
342 { 0x88FC, 0xD0C3, WORD_LEN, 0},
343 { 0x88FE, 0xA020, WORD_LEN, 0},
344 { 0x8900, 0xD1C3, WORD_LEN, 0},
345 { 0x8902, 0x70E9, WORD_LEN, 0},
346 { 0x8904, 0x0EEE, WORD_LEN, 0},
347 { 0x8906, 0x06A4, WORD_LEN, 0},
348 { 0x8908, 0xDA44, WORD_LEN, 0},
349 { 0x890A, 0xD0C2, WORD_LEN, 0},
350 { 0x890C, 0xD1C2, WORD_LEN, 0},
351 { 0x890E, 0xA502, WORD_LEN, 0},
352 { 0x8910, 0xD0C2, WORD_LEN, 0},
353 { 0x8912, 0xA0E0, WORD_LEN, 0},
354 { 0x8914, 0xD0C2, WORD_LEN, 0},
355 { 0x8916, 0xB0CB, WORD_LEN, 0},
356 { 0x8918, 0x8900, WORD_LEN, 0},
357 { 0x891A, 0xDB08, WORD_LEN, 0},
358 { 0x891C, 0xDAF0, WORD_LEN, 0},
359 { 0x891E, 0x19B0, WORD_LEN, 0},
360 { 0x8920, 0x00C2, WORD_LEN, 0},
361 { 0x8922, 0xB8A6, WORD_LEN, 0},
362 { 0x8924, 0xA900, WORD_LEN, 0},
363 { 0x8926, 0xD851, WORD_LEN, 0},
364 { 0x8928, 0x19B2, WORD_LEN, 0},
365 { 0x892A, 0x0002, WORD_LEN, 0},
366 { 0x892C, 0xD852, WORD_LEN, 0},
367 { 0x892E, 0x19B3, WORD_LEN, 0},
368 { 0x8930, 0x0002, WORD_LEN, 0},
369 { 0x8932, 0xD855, WORD_LEN, 0},
370 { 0x8934, 0x19B6, WORD_LEN, 0},
371 { 0x8936, 0x0002, WORD_LEN, 0},
372 { 0x8938, 0xD856, WORD_LEN, 0},
373 { 0x893A, 0x19B7, WORD_LEN, 0},
374 { 0x893C, 0x0002, WORD_LEN, 0},
375 { 0x893E, 0xD896, WORD_LEN, 0},
376 { 0x8940, 0x19B8, WORD_LEN, 0},
377 { 0x8942, 0x0004, WORD_LEN, 0},
378 { 0x8944, 0xD814, WORD_LEN, 0},
379 { 0x8946, 0x19BA, WORD_LEN, 0},
380 { 0x8948, 0x0004, WORD_LEN, 0},
381 { 0x894A, 0xD805, WORD_LEN, 0},
382 { 0x894C, 0xB111, WORD_LEN, 0},
383 { 0x894E, 0x19B1, WORD_LEN, 0},
384 { 0x8950, 0x0082, WORD_LEN, 0},
385 { 0x8952, 0x19B4, WORD_LEN, 0},
386 { 0x8954, 0x00C2, WORD_LEN, 0},
387 { 0x8956, 0x19B5, WORD_LEN, 0},
388 { 0x8958, 0x0082, WORD_LEN, 0},
389 { 0x895A, 0xD1B2, WORD_LEN, 0},
390 { 0x895C, 0x2556, WORD_LEN, 0},
391 { 0x895E, 0x12C0, WORD_LEN, 0},
392 { 0x8960, 0x0E92, WORD_LEN, 0},
393 { 0x8962, 0x06A4, WORD_LEN, 0},
394 { 0x8964, 0xDA2C, WORD_LEN, 0},
395 { 0x8966, 0xD0B0, WORD_LEN, 0},
396 { 0x8968, 0x2556, WORD_LEN, 0},
397 { 0x896A, 0x12C1, WORD_LEN, 0},
398 { 0x896C, 0xA519, WORD_LEN, 0},
399 { 0x896E, 0xD0AF, WORD_LEN, 0},
400 { 0x8970, 0x0145, WORD_LEN, 0},
401 { 0x8972, 0x06E4, WORD_LEN, 0},
402 { 0x8974, 0xA020, WORD_LEN, 0},
403 { 0x8976, 0x78E0, WORD_LEN, 0},
404 { 0x8978, 0xC0F1, WORD_LEN, 0},
405 { 0x897A, 0xD0AD, WORD_LEN, 0},
406 { 0x897C, 0xD1AD, WORD_LEN, 0},
407 { 0x897E, 0xD2AE, WORD_LEN, 0},
408 { 0x8980, 0xA020, WORD_LEN, 0},
409 { 0x8982, 0x8A09, WORD_LEN, 0},
410 { 0x8984, 0x8A6A, WORD_LEN, 0},
411 { 0x8986, 0xB808, WORD_LEN, 0},
412 { 0x8988, 0x7865, WORD_LEN, 0},
413 { 0x898A, 0xB880, WORD_LEN, 0},
414 { 0x898C, 0x2841, WORD_LEN, 0},
415 { 0x898E, 0x020C, WORD_LEN, 0},
416 { 0x8990, 0xAA89, WORD_LEN, 0},
417 { 0x8992, 0xAA0A, WORD_LEN, 0},
418 { 0x8994, 0xD2A9, WORD_LEN, 0},
419 { 0x8996, 0x8A00, WORD_LEN, 0},
420 { 0x8998, 0x0809, WORD_LEN, 0},
421 { 0x899A, 0x01DE, WORD_LEN, 0},
422 { 0x899C, 0xB8A7, WORD_LEN, 0},
423 { 0x899E, 0xAA00, WORD_LEN, 0},
424 { 0x89A0, 0xDBFF, WORD_LEN, 0},
425 { 0x89A2, 0x2B41, WORD_LEN, 0},
426 { 0x89A4, 0x0200, WORD_LEN, 0},
427 { 0x89A6, 0xAA0C, WORD_LEN, 0},
428 { 0x89A8, 0x1228, WORD_LEN, 0},
429 { 0x89AA, 0x0080, WORD_LEN, 0},
430 { 0x89AC, 0xAA6D, WORD_LEN, 0},
431 { 0x89AE, 0x0815, WORD_LEN, 0},
432 { 0x89B0, 0x01DE, WORD_LEN, 0},
433 { 0x89B2, 0xB8A7, WORD_LEN, 0},
434 { 0x89B4, 0x1A28, WORD_LEN, 0},
435 { 0x89B6, 0x0002, WORD_LEN, 0},
436 { 0x89B8, 0x8123, WORD_LEN, 0},
437 { 0x89BA, 0x7960, WORD_LEN, 0},
438 { 0x89BC, 0x1228, WORD_LEN, 0},
439 { 0x89BE, 0x0080, WORD_LEN, 0},
440 { 0x89C0, 0xC0D1, WORD_LEN, 0},
441 { 0x89C2, 0x7EE0, WORD_LEN, 0},
442 { 0x89C4, 0xC0F1, WORD_LEN, 0},
443 { 0x89C6, 0x088E, WORD_LEN, 0},
444 { 0x89C8, 0x06E4, WORD_LEN, 0},
445 { 0x89CA, 0xDB03, WORD_LEN, 0},
446 { 0x89CC, 0xD29B, WORD_LEN, 0},
447 { 0x89CE, 0x8A2E, WORD_LEN, 0},
448 { 0x89D0, 0x8ACF, WORD_LEN, 0},
449 { 0x89D2, 0xB908, WORD_LEN, 0},
450 { 0x89D4, 0x79C5, WORD_LEN, 0},
451 { 0x89D6, 0xDD65, WORD_LEN, 0},
452 { 0x89D8, 0x094F, WORD_LEN, 0},
453 { 0x89DA, 0x00D1, WORD_LEN, 0},
454 { 0x89DC, 0xD90A, WORD_LEN, 0},
455 { 0x89DE, 0x1A24, WORD_LEN, 0},
456 { 0x89E0, 0x0042, WORD_LEN, 0},
457 { 0x89E2, 0x8A24, WORD_LEN, 0},
458 { 0x89E4, 0xE1E5, WORD_LEN, 0},
459 { 0x89E6, 0xF6C9, WORD_LEN, 0},
460 { 0x89E8, 0xD902, WORD_LEN, 0},
461 { 0x89EA, 0x2941, WORD_LEN, 0},
462 { 0x89EC, 0x0200, WORD_LEN, 0},
463 { 0x89EE, 0xAA0E, WORD_LEN, 0},
464 { 0x89F0, 0xAA2F, WORD_LEN, 0},
465 { 0x89F2, 0x70A9, WORD_LEN, 0},
466 { 0x89F4, 0xF014, WORD_LEN, 0},
467 { 0x89F6, 0xE1C8, WORD_LEN, 0},
468 { 0x89F8, 0x0036, WORD_LEN, 0},
469 { 0x89FA, 0x000B, WORD_LEN, 0},
470 { 0x89FC, 0xE0C8, WORD_LEN, 0},
471 { 0x89FE, 0x003A, WORD_LEN, 0},
472 { 0x8A00, 0x000A, WORD_LEN, 0},
473 { 0x8A02, 0xD901, WORD_LEN, 0},
474 { 0x8A04, 0x2941, WORD_LEN, 0},
475 { 0x8A06, 0x0200, WORD_LEN, 0},
476 { 0x8A08, 0xAA0E, WORD_LEN, 0},
477 { 0x8A0A, 0xAA2F, WORD_LEN, 0},
478 { 0x8A0C, 0xD848, WORD_LEN, 0},
479 { 0x8A0E, 0xF008, WORD_LEN, 0},
480 { 0x8A10, 0xD900, WORD_LEN, 0},
481 { 0x8A12, 0x2941, WORD_LEN, 0},
482 { 0x8A14, 0x0200, WORD_LEN, 0},
483 { 0x8A16, 0xAA0E, WORD_LEN, 0},
484 { 0x8A18, 0xAA2F, WORD_LEN, 0},
485 { 0x8A1A, 0xD820, WORD_LEN, 0},
486 { 0x8A1C, 0xD288, WORD_LEN, 0},
487 { 0x8A1E, 0x8A26, WORD_LEN, 0},
488 { 0x8A20, 0xB961, WORD_LEN, 0},
489 { 0x8A22, 0xAA26, WORD_LEN, 0},
490 { 0x8A24, 0xF00D, WORD_LEN, 0},
491 { 0x8A26, 0x091F, WORD_LEN, 0},
492 { 0x8A28, 0x0091, WORD_LEN, 0},
493 { 0x8A2A, 0x8A24, WORD_LEN, 0},
494 { 0x8A2C, 0xF1E5, WORD_LEN, 0},
495 { 0x8A2E, 0x0913, WORD_LEN, 0},
496 { 0x8A30, 0x0812, WORD_LEN, 0},
497 { 0x8A32, 0x08E1, WORD_LEN, 0},
498 { 0x8A34, 0x8812, WORD_LEN, 0},
499 { 0x8A36, 0x2B41, WORD_LEN, 0},
500 { 0x8A38, 0x0201, WORD_LEN, 0},
501 { 0x8A3A, 0xAA2E, WORD_LEN, 0},
502 { 0x8A3C, 0xAA6F, WORD_LEN, 0},
503 { 0x8A3E, 0x0081, WORD_LEN, 0},
504 { 0x8A40, 0x06C4, WORD_LEN, 0},
505 { 0x8A42, 0x09F7, WORD_LEN, 0},
506 { 0x8A44, 0x8051, WORD_LEN, 0},
507 { 0x8A46, 0x8A24, WORD_LEN, 0},
508 { 0x8A48, 0xF1F3, WORD_LEN, 0},
509 { 0x8A4A, 0x78E0, WORD_LEN, 0},
510 { 0x8A4C, 0xC0F1, WORD_LEN, 0},
511 { 0x8A4E, 0x0FFA, WORD_LEN, 0},
512 { 0x8A50, 0x0684, WORD_LEN, 0},
513 { 0x8A52, 0xD67A, WORD_LEN, 0},
514 { 0x8A54, 0x7508, WORD_LEN, 0},
515 { 0x8A56, 0x8E01, WORD_LEN, 0},
516 { 0x8A58, 0xD179, WORD_LEN, 0},
517 { 0x8A5A, 0x2046, WORD_LEN, 0},
518 { 0x8A5C, 0x00C0, WORD_LEN, 0},
519 { 0x8A5E, 0xAE01, WORD_LEN, 0},
520 { 0x8A60, 0x1145, WORD_LEN, 0},
521 { 0x8A62, 0x0080, WORD_LEN, 0},
522 { 0x8A64, 0x1146, WORD_LEN, 0},
523 { 0x8A66, 0x0082, WORD_LEN, 0},
524 { 0x8A68, 0xB808, WORD_LEN, 0},
525 { 0x8A6A, 0x7845, WORD_LEN, 0},
526 { 0x8A6C, 0x0817, WORD_LEN, 0},
527 { 0x8A6E, 0x001E, WORD_LEN, 0},
528 { 0x8A70, 0x8900, WORD_LEN, 0},
529 { 0x8A72, 0x8941, WORD_LEN, 0},
530 { 0x8A74, 0xB808, WORD_LEN, 0},
531 { 0x8A76, 0x7845, WORD_LEN, 0},
532 { 0x8A78, 0x080B, WORD_LEN, 0},
533 { 0x8A7A, 0x00DE, WORD_LEN, 0},
534 { 0x8A7C, 0x70A9, WORD_LEN, 0},
535 { 0x8A7E, 0xFFD2, WORD_LEN, 0},
536 { 0x8A80, 0x7508, WORD_LEN, 0},
537 { 0x8A82, 0x1604, WORD_LEN, 0},
538 { 0x8A84, 0x1090, WORD_LEN, 0},
539 { 0x8A86, 0x0D93, WORD_LEN, 0},
540 { 0x8A88, 0x1400, WORD_LEN, 0},
541 { 0x8A8A, 0x8EEA, WORD_LEN, 0},
542 { 0x8A8C, 0x8E0B, WORD_LEN, 0},
543 { 0x8A8E, 0x214A, WORD_LEN, 0},
544 { 0x8A90, 0x2040, WORD_LEN, 0},
545 { 0x8A92, 0x8E2D, WORD_LEN, 0},
546 { 0x8A94, 0xBF08, WORD_LEN, 0},
547 { 0x8A96, 0x7F05, WORD_LEN, 0},
548 { 0x8A98, 0x8E0C, WORD_LEN, 0},
549 { 0x8A9A, 0xB808, WORD_LEN, 0},
550 { 0x8A9C, 0x7825, WORD_LEN, 0},
551 { 0x8A9E, 0x7710, WORD_LEN, 0},
552 { 0x8AA0, 0x21C2, WORD_LEN, 0},
553 { 0x8AA2, 0x244C, WORD_LEN, 0},
554 { 0x8AA4, 0x081D, WORD_LEN, 0},
555 { 0x8AA6, 0x03E3, WORD_LEN, 0},
556 { 0x8AA8, 0xD9FF, WORD_LEN, 0},
557 { 0x8AAA, 0x2702, WORD_LEN, 0},
558 { 0x8AAC, 0x1002, WORD_LEN, 0},
559 { 0x8AAE, 0x2A05, WORD_LEN, 0},
560 { 0x8AB0, 0x037E, WORD_LEN, 0},
561 { 0x8AB2, 0x0876, WORD_LEN, 0},
562 { 0x8AB4, 0x06E4, WORD_LEN, 0},
563 { 0x8AB6, 0x702F, WORD_LEN, 0},
564 { 0x8AB8, 0x7810, WORD_LEN, 0},
565 { 0x8ABA, 0x7F02, WORD_LEN, 0},
566 { 0x8ABC, 0x7FF0, WORD_LEN, 0},
567 { 0x8ABE, 0xF00B, WORD_LEN, 0},
568 { 0x8AC0, 0x78E2, WORD_LEN, 0},
569 { 0x8AC2, 0x2805, WORD_LEN, 0},
570 { 0x8AC4, 0x037E, WORD_LEN, 0},
571 { 0x8AC6, 0x0862, WORD_LEN, 0},
572 { 0x8AC8, 0x06E4, WORD_LEN, 0},
573 { 0x8ACA, 0x702F, WORD_LEN, 0},
574 { 0x8ACC, 0x7810, WORD_LEN, 0},
575 { 0x8ACE, 0x671F, WORD_LEN, 0},
576 { 0x8AD0, 0x7FF0, WORD_LEN, 0},
577 { 0x8AD2, 0x7FEF, WORD_LEN, 0},
578 { 0x8AD4, 0x8E08, WORD_LEN, 0},
579 { 0x8AD6, 0xBF06, WORD_LEN, 0},
580 { 0x8AD8, 0xD15A, WORD_LEN, 0},
581 { 0x8ADA, 0xB8C3, WORD_LEN, 0},
582 { 0x8ADC, 0x78E5, WORD_LEN, 0},
583 { 0x8ADE, 0xB88F, WORD_LEN, 0},
584 { 0x8AE0, 0x1908, WORD_LEN, 0},
585 { 0x8AE2, 0x0024, WORD_LEN, 0},
586 { 0x8AE4, 0x2841, WORD_LEN, 0},
587 { 0x8AE6, 0x0201, WORD_LEN, 0},
588 { 0x8AE8, 0x1E26, WORD_LEN, 0},
589 { 0x8AEA, 0x1042, WORD_LEN, 0},
590 { 0x8AEC, 0x0D15, WORD_LEN, 0},
591 { 0x8AEE, 0x1423, WORD_LEN, 0},
592 { 0x8AF0, 0x1E27, WORD_LEN, 0},
593 { 0x8AF2, 0x1002, WORD_LEN, 0},
594 { 0x8AF4, 0x214C, WORD_LEN, 0},
595 { 0x8AF6, 0xA000, WORD_LEN, 0},
596 { 0x8AF8, 0x214A, WORD_LEN, 0},
597 { 0x8AFA, 0x2040, WORD_LEN, 0},
598 { 0x8AFC, 0x21C2, WORD_LEN, 0},
599 { 0x8AFE, 0x2442, WORD_LEN, 0},
600 { 0x8B00, 0x8E21, WORD_LEN, 0},
601 { 0x8B02, 0x214F, WORD_LEN, 0},
602 { 0x8B04, 0x0040, WORD_LEN, 0},
603 { 0x8B06, 0x090F, WORD_LEN, 0},
604 { 0x8B08, 0x2010, WORD_LEN, 0},
605 { 0x8B0A, 0x2145, WORD_LEN, 0},
606 { 0x8B0C, 0x0181, WORD_LEN, 0},
607 { 0x8B0E, 0xAE21, WORD_LEN, 0},
608 { 0x8B10, 0xF003, WORD_LEN, 0},
609 { 0x8B12, 0xB8A2, WORD_LEN, 0},
610 { 0x8B14, 0xAE01, WORD_LEN, 0},
611 { 0x8B16, 0x0BFA, WORD_LEN, 0},
612 { 0x8B18, 0xFFE3, WORD_LEN, 0},
613 { 0x8B1A, 0x70A9, WORD_LEN, 0},
614 { 0x8B1C, 0x0789, WORD_LEN, 0},
615 { 0x8B1E, 0x0684, WORD_LEN, 0},
616 { 0x8B20, 0xD149, WORD_LEN, 0},
617 { 0x8B22, 0xD24A, WORD_LEN, 0},
618 { 0x8B24, 0x11B2, WORD_LEN, 0},
619 { 0x8B26, 0x8903, WORD_LEN, 0},
620 { 0x8B28, 0x1252, WORD_LEN, 0},
621 { 0x8B2A, 0x0100, WORD_LEN, 0},
622 { 0x8B2C, 0x7B6F, WORD_LEN, 0},
623 { 0x8B2E, 0xB808, WORD_LEN, 0},
624 { 0x8B30, 0x2004, WORD_LEN, 0},
625 { 0x8B32, 0x0F80, WORD_LEN, 0},
626 { 0x8B34, 0x0000, WORD_LEN, 0},
627 { 0x8B36, 0xFF00, WORD_LEN, 0},
628 { 0x8B38, 0x7865, WORD_LEN, 0},
629 { 0x8B3A, 0x19B2, WORD_LEN, 0},
630 { 0x8B3C, 0x8024, WORD_LEN, 0},
631 { 0x8B3E, 0xD044, WORD_LEN, 0},
632 { 0x8B40, 0x8801, WORD_LEN, 0},
633 { 0x8B42, 0xB8E1, WORD_LEN, 0},
634 { 0x8B44, 0xD800, WORD_LEN, 0},
635 { 0x8B46, 0xF404, WORD_LEN, 0},
636 { 0x8B48, 0x1234, WORD_LEN, 0},
637 { 0x8B4A, 0x0080, WORD_LEN, 0},
638 { 0x8B4C, 0x1955, WORD_LEN, 0},
639 { 0x8B4E, 0x803C, WORD_LEN, 0},
640 { 0x8B50, 0x1233, WORD_LEN, 0},
641 { 0x8B52, 0x0080, WORD_LEN, 0},
642 { 0x8B54, 0xB802, WORD_LEN, 0},
643 { 0x8B56, 0x1957, WORD_LEN, 0},
644 { 0x8B58, 0x803C, WORD_LEN, 0},
645 { 0x8B5A, 0x1958, WORD_LEN, 0},
646 { 0x8B5C, 0x803C, WORD_LEN, 0},
647 { 0x8B5E, 0x1959, WORD_LEN, 0},
648 { 0x8B60, 0x803C, WORD_LEN, 0},
649 { 0x8B62, 0x195A, WORD_LEN, 0},
650 { 0x8B64, 0x803C, WORD_LEN, 0},
651 { 0x8B66, 0x7EE0, WORD_LEN, 0},
652 { 0x8B68, 0xC0F1, WORD_LEN, 0},
653 { 0x8B6A, 0x0EE6, WORD_LEN, 0},
654 { 0x8B6C, 0x0684, WORD_LEN, 0},
655 { 0x8B6E, 0xD523, WORD_LEN, 0},
656 { 0x8B70, 0x8D2C, WORD_LEN, 0},
657 { 0x8B72, 0x0983, WORD_LEN, 0},
658 { 0x8B74, 0x0010, WORD_LEN, 0},
659 { 0x8B76, 0xD236, WORD_LEN, 0},
660 { 0x8B78, 0x123A, WORD_LEN, 0},
661 { 0x8B7A, 0x0083, WORD_LEN, 0},
662 { 0x8B7C, 0x123B, WORD_LEN, 0},
663 { 0x8B7E, 0x008F, WORD_LEN, 0},
664 { 0x8B80, 0x8D55, WORD_LEN, 0},
665 { 0x8B82, 0xBB08, WORD_LEN, 0},
666 { 0x8B84, 0x7BE5, WORD_LEN, 0},
667 { 0x8B86, 0x8DF6, WORD_LEN, 0},
668 { 0x8B88, 0xBA08, WORD_LEN, 0},
669 { 0x8B8A, 0x7AE5, WORD_LEN, 0},
670 { 0x8B8C, 0x0B0D, WORD_LEN, 0},
671 { 0x8B8E, 0x00A3, WORD_LEN, 0},
672 { 0x8B90, 0x8DC5, WORD_LEN, 0},
673 { 0x8B92, 0x8D54, WORD_LEN, 0},
674 { 0x8B94, 0xAD45, WORD_LEN, 0},
675 { 0x8B96, 0xF026, WORD_LEN, 0},
676 { 0x8B98, 0x65DB, WORD_LEN, 0},
677 { 0x8B9A, 0x8B6D, WORD_LEN, 0},
678 { 0x8B9C, 0x0815, WORD_LEN, 0},
679 { 0x8B9E, 0x00E2, WORD_LEN, 0},
680 { 0x8BA0, 0x65DA, WORD_LEN, 0},
681 { 0x8BA2, 0x8A51, WORD_LEN, 0},
682 { 0x8BA4, 0x0A0D, WORD_LEN, 0},
683 { 0x8BA6, 0x0002, WORD_LEN, 0},
684 { 0x8BA8, 0xE683, WORD_LEN, 0},
685 { 0x8BAA, 0x22CA, WORD_LEN, 0},
686 { 0x8BAC, 0x038B, WORD_LEN, 0},
687 { 0x8BAE, 0xF69A, WORD_LEN, 0},
688 { 0x8BB0, 0xDA00, WORD_LEN, 0},
689 { 0x8BB2, 0xAD45, WORD_LEN, 0},
690 { 0x8BB4, 0x2540, WORD_LEN, 0},
691 { 0x8BB6, 0x1343, WORD_LEN, 0},
692 { 0x8BB8, 0xE180, WORD_LEN, 0},
693 { 0x8BBA, 0x2540, WORD_LEN, 0},
694 { 0x8BBC, 0x144F, WORD_LEN, 0},
695 { 0x8BBE, 0xF6D2, WORD_LEN, 0},
696 { 0x8BC0, 0x719F, WORD_LEN, 0},
697 { 0x8BC2, 0x78E0, WORD_LEN, 0},
698 { 0x8BC4, 0x20A8, WORD_LEN, 0},
699 { 0x8BC6, 0x0280, WORD_LEN, 0},
700 { 0x8BC8, 0x8B20, WORD_LEN, 0},
701 { 0x8BCA, 0x0813, WORD_LEN, 0},
702 { 0x8BCC, 0x0043, WORD_LEN, 0},
703 { 0x8BCE, 0xE201, WORD_LEN, 0},
704 { 0x8BD0, 0x7A4F, WORD_LEN, 0},
705 { 0x8BD2, 0xAD45, WORD_LEN, 0},
706 { 0x8BD4, 0xE301, WORD_LEN, 0},
707 { 0x8BD6, 0xE701, WORD_LEN, 0},
708 { 0x8BD8, 0xF004, WORD_LEN, 0},
709 { 0x8BDA, 0x8F20, WORD_LEN, 0},
710 { 0x8BDC, 0x09F3, WORD_LEN, 0},
711 { 0x8BDE, 0x8002, WORD_LEN, 0},
712 { 0x8BE0, 0xD01C, WORD_LEN, 0},
713 { 0x8BE2, 0x8800, WORD_LEN, 0},
714 { 0x8BE4, 0xE803, WORD_LEN, 0},
715 { 0x8BE6, 0x0E0F, WORD_LEN, 0},
716 { 0x8BE8, 0x1080, WORD_LEN, 0},
717 { 0x8BEA, 0xD008, WORD_LEN, 0},
718 { 0x8BEC, 0x8000, WORD_LEN, 0},
719 { 0x8BEE, 0x8002, WORD_LEN, 0},
720 { 0x8BF0, 0x7840, WORD_LEN, 0},
721 { 0x8BF2, 0x06C5, WORD_LEN, 0},
722 { 0x8BF4, 0x0684, WORD_LEN, 0},
723 { 0x8BF6, 0x78E0, WORD_LEN, 0},
724 { 0x8BF8, 0xFF80, WORD_LEN, 0},
725 { 0x8BFA, 0x0644, WORD_LEN, 0},
726 { 0x8BFC, 0x0000, WORD_LEN, 0},
727 { 0x8BFE, 0xF978, WORD_LEN, 0},
728 { 0x8C00, 0xFF80, WORD_LEN, 0},
729 { 0x8C02, 0x0E00, WORD_LEN, 0},
730 { 0x8C04, 0xFF80, WORD_LEN, 0},
731 { 0x8C06, 0x0B68, WORD_LEN, 0},
732 { 0x8C08, 0x8000, WORD_LEN, 0},
733 { 0x8C0A, 0x0164, WORD_LEN, 0},
734 { 0x8C0C, 0x0000, WORD_LEN, 0},
735 { 0x8C0E, 0xF9AC, WORD_LEN, 0},
736 { 0x8C10, 0xFF80, WORD_LEN, 0},
737 { 0x8C12, 0x0B20, WORD_LEN, 0},
738 { 0x8C14, 0xFF80, WORD_LEN, 0},
739 { 0x8C16, 0x0314, WORD_LEN, 0},
740 { 0x8C18, 0x8000, WORD_LEN, 0},
741 { 0x8C1A, 0x016C, WORD_LEN, 0},
742 { 0x8C1C, 0xFF80, WORD_LEN, 0},
743 { 0x8C1E, 0x0694, WORD_LEN, 0},
744 { 0x8C20, 0x0000, WORD_LEN, 0},
745 { 0x8C22, 0xF444, WORD_LEN, 0},
746 { 0x8C24, 0xFF80, WORD_LEN, 0},
747 { 0x8C26, 0x0C54, WORD_LEN, 0},
748 { 0x8C28, 0x8000, WORD_LEN, 0},
749 { 0x8C2A, 0x009C, WORD_LEN, 0},
750 { 0x8C2C, 0x8000, WORD_LEN, 0},
751 { 0x8C2E, 0x0008, WORD_LEN, 0},
752 { 0x8C30, 0xFF80, WORD_LEN, 0},
753 { 0x8C32, 0x0DF0, WORD_LEN, 0},
754 { 0x8C34, 0xFF80, WORD_LEN, 0},
755 { 0x8C36, 0x02CC, WORD_LEN, 0},
756 { 0x8C38, 0xFF80, WORD_LEN, 0},
757 { 0x8C3A, 0x0158, WORD_LEN, 0},
758 { 0x8C3C, 0xFF80, WORD_LEN, 0},
759 { 0x8C3E, 0x0290, WORD_LEN, 0},
760 { 0x8C40, 0xFF00, WORD_LEN, 0},
761 { 0x8C42, 0x0618, WORD_LEN, 0},
762 { 0x8C44, 0xFF00, WORD_LEN, 0},
763 { 0x8C46, 0x33CC, WORD_LEN, 0},
764 { 0x8C48, 0xFF80, WORD_LEN, 0},
765 { 0x8C4A, 0x0658, WORD_LEN, 0},
766 { 0x8C4C, 0xFF80, WORD_LEN, 0},
767 { 0x8C4E, 0x0250, WORD_LEN, 0},
768 { 0x8C50, 0x8000, WORD_LEN, 0},
769 { 0x8C52, 0x0168, WORD_LEN, 0},
770 { 0x8C54, 0xC0F1, WORD_LEN, 0},
771 { 0x8C56, 0x0DFE, WORD_LEN, 0},
772 { 0x8C58, 0x0684, WORD_LEN, 0},
773 { 0x8C5A, 0x17BC, WORD_LEN, 0},
774 { 0x8C5C, 0xF00E, WORD_LEN, 0},
775 { 0x8C5E, 0x8E01, WORD_LEN, 0},
776 { 0x8C60, 0xB8A4, WORD_LEN, 0},
777 { 0x8C62, 0xAE01, WORD_LEN, 0},
778 { 0x8C64, 0x8E09, WORD_LEN, 0},
779 { 0x8C66, 0xB8E0, WORD_LEN, 0},
780 { 0x8C68, 0xF29B, WORD_LEN, 0},
781 { 0x8C6A, 0x17E4, WORD_LEN, 0},
782 { 0x8C6C, 0xF00D, WORD_LEN, 0},
783 { 0x8C6E, 0x153A, WORD_LEN, 0},
784 { 0x8C70, 0x1080, WORD_LEN, 0},
785 { 0x8C72, 0x153B, WORD_LEN, 0},
786 { 0x8C74, 0x1081, WORD_LEN, 0},
787 { 0x8C76, 0xB808, WORD_LEN, 0},
788 { 0x8C78, 0x7825, WORD_LEN, 0},
789 { 0x8C7A, 0x16B8, WORD_LEN, 0},
790 { 0x8C7C, 0x1101, WORD_LEN, 0},
791 { 0x8C7E, 0x092D, WORD_LEN, 0},
792 { 0x8C80, 0x0003, WORD_LEN, 0},
793 { 0x8C82, 0x16B0, WORD_LEN, 0},
794 { 0x8C84, 0x1082, WORD_LEN, 0},
795 { 0x8C86, 0x1E3C, WORD_LEN, 0},
796 { 0x8C88, 0x1082, WORD_LEN, 0},
797 { 0x8C8A, 0x16B1, WORD_LEN, 0},
798 { 0x8C8C, 0x1082, WORD_LEN, 0},
799 { 0x8C8E, 0x1E3D, WORD_LEN, 0},
800 { 0x8C90, 0x1082, WORD_LEN, 0},
801 { 0x8C92, 0x16B4, WORD_LEN, 0},
802 { 0x8C94, 0x1082, WORD_LEN, 0},
803 { 0x8C96, 0x1E3E, WORD_LEN, 0},
804 { 0x8C98, 0x1082, WORD_LEN, 0},
805 { 0x8C9A, 0x16B5, WORD_LEN, 0},
806 { 0x8C9C, 0x1082, WORD_LEN, 0},
807 { 0x8C9E, 0x1E3F, WORD_LEN, 0},
808 { 0x8CA0, 0x1082, WORD_LEN, 0},
809 { 0x8CA2, 0x8E40, WORD_LEN, 0},
810 { 0x8CA4, 0xBAA6, WORD_LEN, 0},
811 { 0x8CA6, 0xAE40, WORD_LEN, 0},
812 { 0x8CA8, 0x098F, WORD_LEN, 0},
813 { 0x8CAA, 0x0022, WORD_LEN, 0},
814 { 0x8CAC, 0x16BA, WORD_LEN, 0},
815 { 0x8CAE, 0x1102, WORD_LEN, 0},
816 { 0x8CB0, 0x0A87, WORD_LEN, 0},
817 { 0x8CB2, 0x0003, WORD_LEN, 0},
818 { 0x8CB4, 0x16B2, WORD_LEN, 0},
819 { 0x8CB6, 0x1084, WORD_LEN, 0},
820 { 0x8CB8, 0x0F2E, WORD_LEN, 0},
821 { 0x8CBA, 0x0664, WORD_LEN, 0},
822 { 0x8CBC, 0x16B0, WORD_LEN, 0},
823 { 0x8CBE, 0x1083, WORD_LEN, 0},
824 { 0x8CC0, 0x1E3C, WORD_LEN, 0},
825 { 0x8CC2, 0x1002, WORD_LEN, 0},
826 { 0x8CC4, 0x153A, WORD_LEN, 0},
827 { 0x8CC6, 0x1080, WORD_LEN, 0},
828 { 0x8CC8, 0x153B, WORD_LEN, 0},
829 { 0x8CCA, 0x1081, WORD_LEN, 0},
830 { 0x8CCC, 0x16B3, WORD_LEN, 0},
831 { 0x8CCE, 0x1084, WORD_LEN, 0},
832 { 0x8CD0, 0xB808, WORD_LEN, 0},
833 { 0x8CD2, 0x7825, WORD_LEN, 0},
834 { 0x8CD4, 0x16B8, WORD_LEN, 0},
835 { 0x8CD6, 0x1101, WORD_LEN, 0},
836 { 0x8CD8, 0x16BA, WORD_LEN, 0},
837 { 0x8CDA, 0x1102, WORD_LEN, 0},
838 { 0x8CDC, 0x0F0A, WORD_LEN, 0},
839 { 0x8CDE, 0x0664, WORD_LEN, 0},
840 { 0x8CE0, 0x16B1, WORD_LEN, 0},
841 { 0x8CE2, 0x1083, WORD_LEN, 0},
842 { 0x8CE4, 0x1E3D, WORD_LEN, 0},
843 { 0x8CE6, 0x1002, WORD_LEN, 0},
844 { 0x8CE8, 0x153A, WORD_LEN, 0},
845 { 0x8CEA, 0x1080, WORD_LEN, 0},
846 { 0x8CEC, 0x153B, WORD_LEN, 0},
847 { 0x8CEE, 0x1081, WORD_LEN, 0},
848 { 0x8CF0, 0x16B6, WORD_LEN, 0},
849 { 0x8CF2, 0x1084, WORD_LEN, 0},
850 { 0x8CF4, 0xB808, WORD_LEN, 0},
851 { 0x8CF6, 0x7825, WORD_LEN, 0},
852 { 0x8CF8, 0x16B8, WORD_LEN, 0},
853 { 0x8CFA, 0x1101, WORD_LEN, 0},
854 { 0x8CFC, 0x16BA, WORD_LEN, 0},
855 { 0x8CFE, 0x1102, WORD_LEN, 0},
856 { 0x8D00, 0x0EE6, WORD_LEN, 0},
857 { 0x8D02, 0x0664, WORD_LEN, 0},
858 { 0x8D04, 0x16B4, WORD_LEN, 0},
859 { 0x8D06, 0x1083, WORD_LEN, 0},
860 { 0x8D08, 0x1E3E, WORD_LEN, 0},
861 { 0x8D0A, 0x1002, WORD_LEN, 0},
862 { 0x8D0C, 0x153A, WORD_LEN, 0},
863 { 0x8D0E, 0x1080, WORD_LEN, 0},
864 { 0x8D10, 0x153B, WORD_LEN, 0},
865 { 0x8D12, 0x1081, WORD_LEN, 0},
866 { 0x8D14, 0x16B7, WORD_LEN, 0},
867 { 0x8D16, 0x1084, WORD_LEN, 0},
868 { 0x8D18, 0xB808, WORD_LEN, 0},
869 { 0x8D1A, 0x7825, WORD_LEN, 0},
870 { 0x8D1C, 0x16B8, WORD_LEN, 0},
871 { 0x8D1E, 0x1101, WORD_LEN, 0},
872 { 0x8D20, 0x16BA, WORD_LEN, 0},
873 { 0x8D22, 0x1102, WORD_LEN, 0},
874 { 0x8D24, 0x0EC2, WORD_LEN, 0},
875 { 0x8D26, 0x0664, WORD_LEN, 0},
876 { 0x8D28, 0x16B5, WORD_LEN, 0},
877 { 0x8D2A, 0x1083, WORD_LEN, 0},
878 { 0x8D2C, 0x1E3F, WORD_LEN, 0},
879 { 0x8D2E, 0x1002, WORD_LEN, 0},
880 { 0x8D30, 0x8E00, WORD_LEN, 0},
881 { 0x8D32, 0xB8A6, WORD_LEN, 0},
882 { 0x8D34, 0xAE00, WORD_LEN, 0},
883 { 0x8D36, 0x153A, WORD_LEN, 0},
884 { 0x8D38, 0x1081, WORD_LEN, 0},
885 { 0x8D3A, 0x153B, WORD_LEN, 0},
886 { 0x8D3C, 0x1080, WORD_LEN, 0},
887 { 0x8D3E, 0xB908, WORD_LEN, 0},
888 { 0x8D40, 0x7905, WORD_LEN, 0},
889 { 0x8D42, 0x16BA, WORD_LEN, 0},
890 { 0x8D44, 0x1100, WORD_LEN, 0},
891 { 0x8D46, 0x085B, WORD_LEN, 0},
892 { 0x8D48, 0x0042, WORD_LEN, 0},
893 { 0x8D4A, 0xD018, WORD_LEN, 0},
894 { 0x8D4C, 0x9E31, WORD_LEN, 0},
895 { 0x8D4E, 0x904D, WORD_LEN, 0},
896 { 0x8D50, 0x0A2B, WORD_LEN, 0},
897 { 0x8D52, 0x0063, WORD_LEN, 0},
898 { 0x8D54, 0x8E00, WORD_LEN, 0},
899 { 0x8D56, 0x16B0, WORD_LEN, 0},
900 { 0x8D58, 0x1081, WORD_LEN, 0},
901 { 0x8D5A, 0x1E3C, WORD_LEN, 0},
902 { 0x8D5C, 0x1042, WORD_LEN, 0},
903 { 0x8D5E, 0x16B1, WORD_LEN, 0},
904 { 0x8D60, 0x1081, WORD_LEN, 0},
905 { 0x8D62, 0x1E3D, WORD_LEN, 0},
906 { 0x8D64, 0x1042, WORD_LEN, 0},
907 { 0x8D66, 0x16B4, WORD_LEN, 0},
908 { 0x8D68, 0x1081, WORD_LEN, 0},
909 { 0x8D6A, 0x1E3E, WORD_LEN, 0},
910 { 0x8D6C, 0x1042, WORD_LEN, 0},
911 { 0x8D6E, 0x16B5, WORD_LEN, 0},
912 { 0x8D70, 0x1081, WORD_LEN, 0},
913 { 0x8D72, 0x1E3F, WORD_LEN, 0},
914 { 0x8D74, 0x1042, WORD_LEN, 0},
915 { 0x8D76, 0xB886, WORD_LEN, 0},
916 { 0x8D78, 0xF012, WORD_LEN, 0},
917 { 0x8D7A, 0x16B2, WORD_LEN, 0},
918 { 0x8D7C, 0x1081, WORD_LEN, 0},
919 { 0x8D7E, 0xB8A6, WORD_LEN, 0},
920 { 0x8D80, 0x1E3C, WORD_LEN, 0},
921 { 0x8D82, 0x1042, WORD_LEN, 0},
922 { 0x8D84, 0x16B3, WORD_LEN, 0},
923 { 0x8D86, 0x1081, WORD_LEN, 0},
924 { 0x8D88, 0x1E3D, WORD_LEN, 0},
925 { 0x8D8A, 0x1042, WORD_LEN, 0},
926 { 0x8D8C, 0x16B6, WORD_LEN, 0},
927 { 0x8D8E, 0x1081, WORD_LEN, 0},
928 { 0x8D90, 0x1E3E, WORD_LEN, 0},
929 { 0x8D92, 0x1042, WORD_LEN, 0},
930 { 0x8D94, 0x16B7, WORD_LEN, 0},
931 { 0x8D96, 0x1081, WORD_LEN, 0},
932 { 0x8D98, 0x1E3F, WORD_LEN, 0},
933 { 0x8D9A, 0x1042, WORD_LEN, 0},
934 { 0x8D9C, 0xAE00, WORD_LEN, 0},
935 { 0x8D9E, 0x0D92, WORD_LEN, 0},
936 { 0x8DA0, 0x0184, WORD_LEN, 0},
937 { 0x8DA2, 0x051D, WORD_LEN, 0},
938 { 0x8DA4, 0x0684, WORD_LEN, 0},
939 { 0x8DA6, 0x78E0, WORD_LEN, 0},
940 { 0x8DA8, 0xFF80, WORD_LEN, 0},
941 { 0x8DAA, 0x050C, WORD_LEN, 0},
942 { 0x8DAC, 0xE280, WORD_LEN, 0},
943 { 0x8DAE, 0x24CA, WORD_LEN, 0},
944 { 0x8DB0, 0x7082, WORD_LEN, 0},
945 { 0x8DB2, 0x78E0, WORD_LEN, 0},
946 { 0x8DB4, 0x20E8, WORD_LEN, 0},
947 { 0x8DB6, 0x01A2, WORD_LEN, 0},
948 { 0x8DB8, 0x1002, WORD_LEN, 0},
949 { 0x8DBA, 0x0D02, WORD_LEN, 0},
950 { 0x8DBC, 0x1902, WORD_LEN, 0},
951 { 0x8DBE, 0x0094, WORD_LEN, 0},
952 { 0x8DC0, 0x7FE0, WORD_LEN, 0},
953 { 0x8DC2, 0x7028, WORD_LEN, 0},
954 { 0x8DC4, 0x7308, WORD_LEN, 0},
955 { 0x8DC6, 0x1000, WORD_LEN, 0},
956 { 0x8DC8, 0x0900, WORD_LEN, 0},
957 { 0x8DCA, 0x7904, WORD_LEN, 0},
958 { 0x8DCC, 0x7947, WORD_LEN, 0},
959 { 0x8DCE, 0x1B00, WORD_LEN, 0},
960 { 0x8DD0, 0x0064, WORD_LEN, 0},
961 { 0x8DD2, 0x7EE0, WORD_LEN, 0},
962 { 0x8DD4, 0xE280, WORD_LEN, 0},
963 { 0x8DD6, 0x24CA, WORD_LEN, 0},
964 { 0x8DD8, 0x7082, WORD_LEN, 0},
965 { 0x8DDA, 0x78E0, WORD_LEN, 0},
966 { 0x8DDC, 0x20E8, WORD_LEN, 0},
967 { 0x8DDE, 0x01A2, WORD_LEN, 0},
968 { 0x8DE0, 0x1102, WORD_LEN, 0},
969 { 0x8DE2, 0x0502, WORD_LEN, 0},
970 { 0x8DE4, 0x1802, WORD_LEN, 0},
971 { 0x8DE6, 0x00B4, WORD_LEN, 0},
972 { 0x8DE8, 0x7FE0, WORD_LEN, 0},
973 { 0x8DEA, 0x7028, WORD_LEN, 0},
974 { 0x8DEC, 0x0000, WORD_LEN, 0},
975 { 0x8DEE, 0x0000, WORD_LEN, 0},
976 { 0x8DF0, 0xFF80, WORD_LEN, 0},
977 { 0x8DF2, 0x0978, WORD_LEN, 0},
978 { 0x8DF4, 0xFF80, WORD_LEN, 0},
979 { 0x8DF6, 0x0A4C, WORD_LEN, 0},
980 { 0x8DF8, 0x0000, WORD_LEN, 0},
981 { 0x8DFA, 0x08DC, WORD_LEN, 0},
982 { 0x8DFC, 0x0000, WORD_LEN, 0},
983 { 0x8DFE, 0x0998, WORD_LEN, 0},
984 { 0x098E, 0x0016, WORD_LEN, 0}, // LOGICAL_ADDRESS_ACCESS
985 { 0x8016, 0x086C, WORD_LEN, 0}, // MON_ADDRESS_LO
986 { 0x8002, 0x0001, WORD_LEN, 0}, // MON_CMD
987 //POLL_{0x800A,0x00,!=0x07,DELAY=10,TIMEOUT=100 //Wait for the core ready
988 ////{ SEQUENCE_WAIT_MS,300, BYTE_LEN, 0},
989 { SEQUENCE_WAIT_MS,100, BYTE_LEN, 0},
991 { 0x30D4, 0x9080, WORD_LEN, 0}, // COLUMN_CORRECTION
992 { 0x316E, 0xC400, WORD_LEN, 0}, // DAC_ECL
993 { 0x305E, 0x10A0, WORD_LEN, 0}, // GLOBAL_GAIN
994 { 0x3E00, 0x0010, WORD_LEN, 0}, // SAMP_CONTROL
995 { 0x3E02, 0xED02, WORD_LEN, 0}, // SAMP_ADDR_EN
996 { 0x3E04, 0xC88C, WORD_LEN, 0}, // SAMP_RD1_SIG
997 { 0x3E06, 0xC88C, WORD_LEN, 0}, // SAMP_RD1_SIG_BOOST
998 { 0x3E08, 0x700A, WORD_LEN, 0}, // SAMP_RD1_RST
999 { 0x3E0A, 0x701E, WORD_LEN, 0}, // SAMP_RD1_RST_BOOST
1000 { 0x3E0C, 0x00FF, WORD_LEN, 0}, // SAMP_RST1_EN
1001 { 0x3E0E, 0x00FF, WORD_LEN, 0}, // SAMP_RST1_BOOST
1002 { 0x3E10, 0x00FF, WORD_LEN, 0}, // SAMP_RST1_CLOOP_SH
1003 { 0x3E12, 0x0000, WORD_LEN, 0}, // SAMP_RST_BOOST_SEQ
1004 { 0x3E14, 0xC78C, WORD_LEN, 0}, // SAMP_SAMP1_SIG
1005 { 0x3E16, 0x6E06, WORD_LEN, 0}, // SAMP_SAMP1_RST
1006 { 0x3E18, 0xA58C, WORD_LEN, 0}, // SAMP_TX_EN
1007 { 0x3E1A, 0xA58E, WORD_LEN, 0}, // SAMP_TX_BOOST
1008 { 0x3E1C, 0xA58E, WORD_LEN, 0}, // SAMP_TX_CLOOP_SH
1009 { 0x3E1E, 0xC0D0, WORD_LEN, 0}, // SAMP_TX_BOOST_SEQ
1010 { 0x3E20, 0xEB00, WORD_LEN, 0}, // SAMP_VLN_EN
1011 { 0x3E22, 0x00FF, WORD_LEN, 0}, // SAMP_VLN_HOLD
1012 { 0x3E24, 0xEB02, WORD_LEN, 0}, // SAMP_VCL_EN
1013 { 0x3E26, 0xEA02, WORD_LEN, 0}, // SAMP_COLCLAMP
1014 { 0x3E28, 0xEB0A, WORD_LEN, 0}, // SAMP_SH_VCL
1015 { 0x3E2A, 0xEC01, WORD_LEN, 0}, // SAMP_SH_VREF
1016 { 0x3E2C, 0xEB01, WORD_LEN, 0}, // SAMP_SH_VBST
1017 { 0x3E2E, 0x00FF, WORD_LEN, 0}, // SAMP_SPARE
1018 { 0x3E30, 0x00F3, WORD_LEN, 0}, // SAMP_READOUT
1019 { 0x3E32, 0x3DFA, WORD_LEN, 0}, // SAMP_RESET_DONE
1020 { 0x3E34, 0x00FF, WORD_LEN, 0}, // SAMP_VLN_CLAMP
1021 { 0x3E36, 0x00F3, WORD_LEN, 0}, // SAMP_ASC_INT
1022 { 0x3E38, 0x0000, WORD_LEN, 0}, // SAMP_RS_CLOOP_SH_R
1023 { 0x3E3A, 0xF802, WORD_LEN, 0}, // SAMP_RS_CLOOP_SH
1024 { 0x3E3C, 0x0FFF, WORD_LEN, 0}, // SAMP_RS_BOOST_SEQ
1025 { 0x3E3E, 0xEA10, WORD_LEN, 0}, // SAMP_TXLO_GND
1026 { 0x3E40, 0xEB05, WORD_LEN, 0}, // SAMP_VLN_PER_COL
1027 { 0x3E42, 0xE5C8, WORD_LEN, 0}, // SAMP_RD2_SIG
1028 { 0x3E44, 0xE5C8, WORD_LEN, 0}, // SAMP_RD2_SIG_BOOST
1029 { 0x3E46, 0x8C70, WORD_LEN, 0}, // SAMP_RD2_RST
1030 { 0x3E48, 0x8C71, WORD_LEN, 0}, // SAMP_RD2_RST_BOOST
1031 { 0x3E4A, 0x00FF, WORD_LEN, 0}, // SAMP_RST2_EN
1032 { 0x3E4C, 0x00FF, WORD_LEN, 0}, // SAMP_RST2_BOOST
1033 { 0x3E4E, 0x00FF, WORD_LEN, 0}, // SAMP_RST2_CLOOP_SH
1034 { 0x3E50, 0xE38D, WORD_LEN, 0}, // SAMP_SAMP2_SIG
1035 { 0x3E52, 0x8B0A, WORD_LEN, 0}, // SAMP_SAMP2_RST
1036 { 0x3E58, 0xEB0A, WORD_LEN, 0}, // SAMP_PIX_CLAMP_EN
1037 { 0x3E5C, 0x0A00, WORD_LEN, 0}, // SAMP_PIX_PULLUP_EN
1038 { 0x3E5E, 0x00FF, WORD_LEN, 0}, // SAMP_PIX_PULLDOWN_EN_R
1039 { 0x3E60, 0x00FF, WORD_LEN, 0}, // SAMP_PIX_PULLDOWN_EN_S
1040 { 0x3E90, 0x3C01, WORD_LEN, 0}, // RST_ADDR_EN
1041 { 0x3E92, 0x00FF, WORD_LEN, 0}, // RST_RST_EN
1042 { 0x3E94, 0x00FF, WORD_LEN, 0}, // RST_RST_BOOST
1043 { 0x3E96, 0x3C00, WORD_LEN, 0}, // RST_TX_EN
1044 { 0x3E98, 0x3C00, WORD_LEN, 0}, // RST_TX_BOOST
1045 { 0x3E9A, 0x3C00, WORD_LEN, 0}, // RST_TX_CLOOP_SH
1046 { 0x3E9C, 0xC0E0, WORD_LEN, 0}, // RST_TX_BOOST_SEQ
1047 { 0x3E9E, 0x00FF, WORD_LEN, 0}, // RST_RST_CLOOP_SH
1048 { 0x3EA0, 0x0000, WORD_LEN, 0}, // RST_RST_BOOST_SEQ
1049 { 0x3EA6, 0x3C00, WORD_LEN, 0}, // RST_PIX_PULLUP_EN
1050 { 0x3ED8, 0x3057, WORD_LEN, 0}, // DAC_LD_12_13
1051 { 0x316C, 0xB44F, WORD_LEN, 0}, // DAC_TXLO
1052 { 0x316E, 0xC6FF, WORD_LEN, 0}, // DAC_ECL
1053 { 0x3ED2, 0xEA0A, WORD_LEN, 0}, // DAC_LD_6_7
1054 { 0x3ED4, 0x00A3, WORD_LEN, 0}, // DAC_LD_8_9
1055 { 0x3EDC, 0x6020, WORD_LEN, 0}, // DAC_LD_16_17
1056 { 0x3EE6, 0xA541, WORD_LEN, 0}, // DAC_LD_26_27
1057 { 0x31E0, 0x0001, WORD_LEN, 0}, // PIX_DEF_ID
1058 { 0x3ED0, 0x2409, WORD_LEN, 0}, // DAC_LD_4_5
1059 //{ 0x3EDA, 0x6000 // DAC_LD_14_15 //
1060 { 0x3EDE, 0x0A49, WORD_LEN, 0}, // DAC_LD_18_19
1061 { 0x3EE0, 0x4910, WORD_LEN, 0}, // DAC_LD_20_21
1062 { 0x3EE2, 0x09D2, WORD_LEN, 0}, // DAC_LD_22_23
1063 { 0x30B6, 0x0008, WORD_LEN, 0}, // AUTOLR_CONTROL
1064 { 0x337C, 0x0006, WORD_LEN, 0}, // YUV_YCBCR_CONTROL
1065 { 0x3E1A, 0xA582, WORD_LEN, 0}, // SAMP_TX_BOOST
1066 { 0x3E2E, 0xEC05, WORD_LEN, 0}, // SAMP_SPARE
1067 { 0x3EE6, 0xA5C0, WORD_LEN, 0}, // DAC_LD_26_27
1068 { 0x316C, 0xB43F, WORD_LEN, 0}, // DAC_TXLO
1069 { 0x316E, 0xC6FF, WORD_LEN, 0}, // DAC_ECL
1070 //LOAD = Lens Correction 90% 04/29/10 12:58:28
1071 { 0x381C, 0x0000, WORD_LEN, 0},
1072 { 0xE02A, 0x0001, WORD_LEN, 0}, // IO_NV_MEM_COMMAND
1073 // POLL IO_NV_MEM_STATUS::IO_NVMEM_STAT_OTPM_AVAIL => 0x00
1074 { SEQUENCE_WAIT_MS,100, BYTE_LEN, 0},
1075 { 0x3812, 0x2124, WORD_LEN, 0},
1076 //POLL_FIELD= IO_NV_MEM_STATUS, IO_NV_MEM_STATUS!=0xC1,DELAY=100,TIMEOUT=50 //5 sec
1077 { SEQUENCE_WAIT_MS,100, BYTE_LEN, 0},
1078 { 0xD004, 0x04, BYTE_LEN, 0}, // PGA_SOLUTION
1079 { 0xD006, 0x0008, WORD_LEN, 0}, // PGA_ZONE_ADDR_0
1080 { 0xD005, 0x00, BYTE_LEN, 0}, // PGA_CURRENT_ZONE
1081 { 0xD002, 0x8002, WORD_LEN, 0}, // PGA_ALGO
1082 { 0x3210, 0x49B8, WORD_LEN, 0}, // COLOR_PIPELINE_CONTROL
1085 { 0xAC02, 0x00FF , WORD_LEN, 0 }, // AWB_ALGO
1086 { 0xAC01, 0x7F, BYTE_LEN, 0 }, // AWB_MODE
1088 { 0xAC3C, 0x39, BYTE_LEN, 0 }, //42 // AWB_MIN_ACCEPTED_PRE_AWB_R2G_RATIO
1089 { 0xAC3D, 0x6E, BYTE_LEN, 0 }, //50 // AWB_MAX_ACCEPTED_PRE_AWB_R2G_RATIO
1090 { 0xAC3E, 0x28, BYTE_LEN, 0 }, //13 // AWB_MIN_ACCEPTED_PRE_AWB_B2G_RATIO
1091 { 0xAC3F, 0x6B, BYTE_LEN, 0 }, //5B // AWB_MAX_ACCEPTED_PRE_AWB_B2G_RATIO
1092 { 0xAC40, 0x64, BYTE_LEN, 0 }, //52 // AWB_MIN_ACCEPTED_POST_AWB_R2G_RATIO
1093 { 0xAC41, 0x66, BYTE_LEN, 0 }, //56 // AWB_MAX_ACCEPTED_POST_AWB_R2G_RATIO
1094 { 0xAC42, 0x64, BYTE_LEN, 0 }, // AWB_MIN_ACCEPTED_POST_AWB_B2G_RATIO
1095 { 0xAC43, 0x66, BYTE_LEN, 0 }, // AWB_MAX_ACCEPTED_POST_AWB_B2G_RATIO
1097 { 0xACB0, 0x31, BYTE_LEN, 0 }, // AWB_RG_MIN
1098 { 0xACB1, 0x5B, BYTE_LEN, 0 }, //50 // AWB_RG_MAX
1099 { 0xACB4, 0x2A, BYTE_LEN, 0 }, //13 // AWB_BG_MIN
1100 { 0xACB5, 0x5B, BYTE_LEN, 0 }, // AWB_BG_MAX
1101 { 0xACB2, 0x42, BYTE_LEN, 0 }, // AWB_RG_MIN_BRIGHT
1102 { 0xACB3, 0x4B, BYTE_LEN, 0 }, // AWB_RG_MAX_BRIGHT
1103 { 0xACB6, 0x36, BYTE_LEN, 0 }, // AWB_BG_MIN_BRIGHT
1104 { 0xACB7, 0x42, BYTE_LEN, 0 }, // AWB_BG_MAX_BRIGHT
1105 { 0xACB8, 0x00D0, WORD_LEN, 0}, // 0x0100 // AWB_START_NUM_INT_LINES
1106 { 0xACBA, 0x0090, WORD_LEN, 0}, // B0 // AWB_END_NUM_INT_LINES
1108 { 0x098E, 0xAC09, WORD_LEN, 0}, // LOGICAL_ADDRESS_ACCESS
1109 { 0xAC09, 0x01, BYTE_LEN, 0}, // AWB_MODE_EX
1110 { 0xAC22, 0x0000, WORD_LEN, 0}, // AWB_SHARPNESS_TH
1111 //soc5140_ccm_settings
1112 { 0x098E, 0x2C46, WORD_LEN, 0}, // LOGICAL_ADDRESS_ACCESS [AWB_LEFT_CCM_0]
1113 { 0xAC46, 0x010F, WORD_LEN, 0}, //0x015F // AWB_LEFT_CCM_0
1114 { 0xAC48, 0xFFAE, WORD_LEN, 0}, //0xFFC2 // AWB_LEFT_CCM_1
1115 { 0xAC4A, 0x0043, WORD_LEN, 0}, //0xFFDF // AWB_LEFT_CCM_2
1116 { 0xAC4C, 0xFF7E, WORD_LEN, 0}, //0xFF7F // AWB_LEFT_CCM_3
1117 { 0xAC4E, 0x01BD, WORD_LEN, 0}, //0x01BB // AWB_LEFT_CCM_4
1118 { 0xAC50, 0xFFC5, WORD_LEN, 0}, //0xFFC6 // AWB_LEFT_CCM_5
1119 { 0xAC52, 0xFFE1, WORD_LEN, 0}, //0xFFC7 // AWB_LEFT_CCM_6
1120 { 0xAC54, 0xFF34, WORD_LEN, 0}, //0xFEFA // AWB_LEFT_CCM_7
1121 { 0xAC56, 0x01EB, WORD_LEN, 0}, //0x023F // AWB_LEFT_CCM_8
1122 { 0xAC58, 0x00A8, WORD_LEN, 0}, // AWB_LEFT_CCM_R2BRATIO
1123 { 0xAC5C, 0x0233, WORD_LEN, 0}, // AWB_RIGHT_CCM_0
1124 { 0xAC5E, 0xFF23, WORD_LEN, 0}, // AWB_RIGHT_CCM_1
1125 { 0xAC60, 0xFFAA, WORD_LEN, 0}, // AWB_RIGHT_CCM_2
1126 { 0xAC62, 0xFF91, WORD_LEN, 0}, // AWB_RIGHT_CCM_3
1127 { 0xAC64, 0x01AF, WORD_LEN, 0}, // AWB_RIGHT_CCM_4
1128 { 0xAC66, 0xFFBF, WORD_LEN, 0}, // AWB_RIGHT_CCM_5
1129 { 0xAC68, 0xFFE7, WORD_LEN, 0}, // AWB_RIGHT_CCM_6
1130 { 0xAC6A, 0xFF4C, WORD_LEN, 0}, // AWB_RIGHT_CCM_7
1131 { 0xAC6C, 0x01CE, WORD_LEN, 0}, // AWB_RIGHT_CCM_8
1132 { 0xAC6E, 0x005A, WORD_LEN, 0}, // AWB_RIGHT_CCM_R2BRATIO
1133 { 0xAC72, 0x004D, WORD_LEN, 0}, // AWB_LL_CCM_0
1134 { 0xAC74, 0x0096, WORD_LEN, 0}, // AWB_LL_CCM_1
1135 { 0xAC76, 0x001D, WORD_LEN, 0}, // AWB_LL_CCM_2
1136 { 0xAC78, 0x004D, WORD_LEN, 0}, // AWB_LL_CCM_3
1137 { 0xAC7A, 0x0096, WORD_LEN, 0}, // AWB_LL_CCM_4
1138 { 0xAC7C, 0x001D, WORD_LEN, 0}, // AWB_LL_CCM_5
1139 { 0xAC7E, 0x004D, WORD_LEN, 0}, // AWB_LL_CCM_6
1140 { 0xAC80, 0x0096, WORD_LEN, 0}, // AWB_LL_CCM_7
1141 { 0xAC82, 0x001D, WORD_LEN, 0}, // AWB_LL_CCM_8
1142 { 0xAC97, 0x80, BYTE_LEN, 0}, // AWB_LEFT_TINT_COEF_FOR_CCM_ROW_0
1143 { 0xAC98, 0x80, BYTE_LEN, 0}, // AWB_LEFT_TINT_COEF_FOR_CCM_ROW_1
1144 { 0xAC99, 0x74, BYTE_LEN, 0}, //0x64 // AWB_LEFT_TINT_COEF_FOR_CCM_ROW_2
1145 { 0xAC9A, 0x7D, BYTE_LEN, 0}, //0x76 // AWB_RIGHT_TINT_COEF_FOR_CCM_ROW_0
1146 { 0xAC9B, 0x80, BYTE_LEN, 0}, // AWB_RIGHT_TINT_COEF_FOR_CCM_ROW_1
1147 { 0xAC9C, 0x7D, BYTE_LEN, 0}, //0x78 // AWB_RIGHT_TINT_COEF_FOR_CCM_ROW_2
1148 { 0xB83E, 0x10, BYTE_LEN, 0}, // STAT_AWB_WINDOW_POS_X
1149 { 0xB83F, 0x10, BYTE_LEN, 0}, // STAT_AWB_WINDOW_POS_Y
1150 { 0xB840, 0xDF, BYTE_LEN, 0}, // STAT_AWB_WINDOW_SIZE_X
1151 { 0xB841, 0xCF, BYTE_LEN, 0}, // STAT_AWB_WINDOW_SIZE_Y
1152 //soc5140_weighted2D_awb_settings
1153 { 0xB842, 0x0034, WORD_LEN, 0}, //0x0032 // STAT_AWB_GRAY_CHECKER_OFFSET_X
1154 { 0xB844, 0x003C, WORD_LEN, 0}, //0x0038 // STAT_AWB_GRAY_CHECKER_OFFSET_Y
1155 { 0x3240, 0x0024, WORD_LEN, 0}, // AWB_XY_SCALE
1156 { 0x3242, 0x0000, WORD_LEN, 0}, // AWB_WEIGHT_R0
1157 { 0x3244, 0x0000, WORD_LEN, 0}, // AWB_WEIGHT_R1
1158 { 0x3246, 0x0000, WORD_LEN, 0}, // AWB_WEIGHT_R2
1159 { 0x3248, 0x7070, WORD_LEN, 0}, // AWB_WEIGHT_R3
1160 { 0x324A, 0x38E0, WORD_LEN, 0}, // AWB_WEIGHT_R4
1161 { 0x324C, 0x70E0, WORD_LEN, 0}, // AWB_WEIGHT_R5
1162 { 0x324E, 0x01B8, WORD_LEN, 0}, // AWB_WEIGHT_R6
1163 { 0x3250, 0x00AB, WORD_LEN, 0}, // AWB_WEIGHT_R7
1164 { 0xD80F, 0x04, BYTE_LEN, 0}, // JPEG_QSCALE_0
1165 { 0xD810, 0x08, BYTE_LEN, 0}, // JPEG_QSCALE_1
1166 { 0xC8D2, 0x04, BYTE_LEN, 0}, // CAM_OUTPUT_1_JPEG_QSCALE_0
1167 { 0xC8D3, 0x08, BYTE_LEN, 0}, // CAM_OUTPUT_1_JPEG_QSCALE_1
1168 { 0xC8BC, 0x04, BYTE_LEN, 0}, // CAM_OUTPUT_0_JPEG_QSCALE_0
1169 { 0xC8BD, 0x08, BYTE_LEN, 0}, // CAM_OUTPUT_0_JPEG_QSCALE_1
1171 { 0x301A, 0x10F4, WORD_LEN, 0}, // RESET_REGISTER
1172 { 0x301E, 0x0083, WORD_LEN, 0}, // DATA_PEDESTAL
1173 { 0x301A, 0x10FC, WORD_LEN, 0}, // RESET_REGISTER
1174 { 0xDC33, 0x20, BYTE_LEN, 0}, // SYS_FIRST_BLACK_LEVEL
1175 { 0xDC35, 0x04, BYTE_LEN, 0}, // SYS_UV_COLOR_BOOST
1176 { 0x326E, 0x0006, WORD_LEN, 0}, // LOW_PASS_YUV_FILTER
1177 { 0xDC37, 0x62, BYTE_LEN, 0}, // SYS_BRIGHT_COLORKILL
1178 { 0x35A4, 0x0596, WORD_LEN, 0}, // BRIGHT_COLOR_KILL_CONTROLS
1179 { 0x35A2, 0x009C, WORD_LEN, 0}, // DARK_COLOR_KILL_CONTROLS
1180 { 0x098E, 0x5C02, WORD_LEN, 0}, // MCU_ADDR
1181 { 0xDC02, 0x003E, WORD_LEN, 0}, // SYS_ALGO
1182 { 0xDC36, 0x34, BYTE_LEN, 0}, // SYS_DARK_COLOR_KILL
1183 // Refresh Mode - skip
1184 { 0xBC18, 0x00, BYTE_LEN, 0}, // LL_GAMMA_CONTRAST_CURVE_0
1185 { 0xBC19, 0x11, BYTE_LEN, 0}, // LL_GAMMA_CONTRAST_CURVE_1
1186 { 0xBC1A, 0x23, BYTE_LEN, 0}, // LL_GAMMA_CONTRAST_CURVE_2
1187 { 0xBC1B, 0x3F, BYTE_LEN, 0}, // LL_GAMMA_CONTRAST_CURVE_3
1188 { 0xBC1C, 0x67, BYTE_LEN, 0}, // LL_GAMMA_CONTRAST_CURVE_4
1189 { 0xBC1D, 0x85, BYTE_LEN, 0}, // LL_GAMMA_CONTRAST_CURVE_5
1190 { 0xBC1E, 0x9B, BYTE_LEN, 0}, // LL_GAMMA_CONTRAST_CURVE_6
1191 { 0xBC1F, 0xAD, BYTE_LEN, 0}, // LL_GAMMA_CONTRAST_CURVE_7
1192 { 0xBC20, 0xBB, BYTE_LEN, 0}, // LL_GAMMA_CONTRAST_CURVE_8
1193 { 0xBC21, 0xC7, BYTE_LEN, 0}, // LL_GAMMA_CONTRAST_CURVE_9
1194 { 0xBC22, 0xD1, BYTE_LEN, 0}, // LL_GAMMA_CONTRAST_CURVE_10
1195 { 0xBC23, 0xDA, BYTE_LEN, 0}, // LL_GAMMA_CONTRAST_CURVE_11
1196 { 0xBC24, 0xE1, BYTE_LEN, 0}, // LL_GAMMA_CONTRAST_CURVE_12
1197 { 0xBC25, 0xE8, BYTE_LEN, 0}, // LL_GAMMA_CONTRAST_CURVE_13
1198 { 0xBC26, 0xEE, BYTE_LEN, 0}, // LL_GAMMA_CONTRAST_CURVE_14
1199 { 0xBC27, 0xF3, BYTE_LEN, 0}, // LL_GAMMA_CONTRAST_CURVE_15
1200 { 0xBC28, 0xF7, BYTE_LEN, 0}, // LL_GAMMA_CONTRAST_CURVE_16
1201 { 0xBC29, 0xFB, BYTE_LEN, 0}, // LL_GAMMA_CONTRAST_CURVE_17
1202 { 0xBC2A, 0xFF, BYTE_LEN, 0}, // LL_GAMMA_CONTRAST_CURVE_18
1203 { 0xBC2B, 0x00, BYTE_LEN, 0}, // LL_GAMMA_NEUTRAL_CURVE_0
1204 { 0xBC2C, 0x0A, BYTE_LEN, 0}, // LL_GAMMA_NEUTRAL_CURVE_1
1205 { 0xBC2D, 0x1C, BYTE_LEN, 0}, // LL_GAMMA_NEUTRAL_CURVE_2
1206 { 0xBC2E, 0x36, BYTE_LEN, 0}, // LL_GAMMA_NEUTRAL_CURVE_3
1207 { 0xBC2F, 0x53, BYTE_LEN, 0}, // LL_GAMMA_NEUTRAL_CURVE_4
1208 { 0xBC30, 0x6F, BYTE_LEN, 0}, // LL_GAMMA_NEUTRAL_CURVE_5
1209 { 0xBC31, 0x86, BYTE_LEN, 0}, // LL_GAMMA_NEUTRAL_CURVE_6
1210 { 0xBC32, 0x99, BYTE_LEN, 0}, // LL_GAMMA_NEUTRAL_CURVE_7
1211 { 0xBC33, 0xAB, BYTE_LEN, 0}, // LL_GAMMA_NEUTRAL_CURVE_8
1212 { 0xBC34, 0xBB, BYTE_LEN, 0}, // LL_GAMMA_NEUTRAL_CURVE_9
1213 { 0xBC35, 0xC6, BYTE_LEN, 0}, // LL_GAMMA_NEUTRAL_CURVE_10
1214 { 0xBC36, 0xD0, BYTE_LEN, 0}, // LL_GAMMA_NEUTRAL_CURVE_11
1215 { 0xBC37, 0xD9, BYTE_LEN, 0}, // LL_GAMMA_NEUTRAL_CURVE_12
1216 { 0xBC38, 0xE2, BYTE_LEN, 0}, // LL_GAMMA_NEUTRAL_CURVE_13
1217 { 0xBC39, 0xE9, BYTE_LEN, 0}, // LL_GAMMA_NEUTRAL_CURVE_14
1218 { 0xBC3A, 0xEF, BYTE_LEN, 0}, // LL_GAMMA_NEUTRAL_CURVE_15
1219 { 0xBC3B, 0xF5, BYTE_LEN, 0}, // LL_GAMMA_NEUTRAL_CURVE_16
1220 { 0xBC3C, 0xFA, BYTE_LEN, 0}, // LL_GAMMA_NEUTRAL_CURVE_17
1221 { 0xBC3D, 0xFF, BYTE_LEN, 0}, // LL_GAMMA_NEUTRAL_CURVE_18
1222 { 0xBC3E, 0x00, BYTE_LEN, 0}, // LL_GAMMA_NR_CURVE_0
1223 { 0xBC3F, 0x18, BYTE_LEN, 0}, // LL_GAMMA_NR_CURVE_1
1224 { 0xBC40, 0x25, BYTE_LEN, 0}, // LL_GAMMA_NR_CURVE_2
1225 { 0xBC41, 0x3A, BYTE_LEN, 0}, // LL_GAMMA_NR_CURVE_3
1226 { 0xBC42, 0x59, BYTE_LEN, 0}, // LL_GAMMA_NR_CURVE_4
1227 { 0xBC43, 0x70, BYTE_LEN, 0}, // LL_GAMMA_NR_CURVE_5
1228 { 0xBC44, 0x81, BYTE_LEN, 0}, // LL_GAMMA_NR_CURVE_6
1229 { 0xBC45, 0x90, BYTE_LEN, 0}, // LL_GAMMA_NR_CURVE_7
1230 { 0xBC46, 0x9E, BYTE_LEN, 0}, // LL_GAMMA_NR_CURVE_8
1231 { 0xBC47, 0xAB, BYTE_LEN, 0}, // LL_GAMMA_NR_CURVE_9
1232 { 0xBC48, 0xB6, BYTE_LEN, 0}, // LL_GAMMA_NR_CURVE_10
1233 { 0xBC49, 0xC1, BYTE_LEN, 0}, // LL_GAMMA_NR_CURVE_11
1234 { 0xBC4A, 0xCB, BYTE_LEN, 0}, // LL_GAMMA_NR_CURVE_12
1235 { 0xBC4B, 0xD5, BYTE_LEN, 0}, // LL_GAMMA_NR_CURVE_13
1236 { 0xBC4C, 0xDE, BYTE_LEN, 0}, // LL_GAMMA_NR_CURVE_14
1237 { 0xBC4D, 0xE7, BYTE_LEN, 0}, // LL_GAMMA_NR_CURVE_15
1238 { 0xBC4E, 0xEF, BYTE_LEN, 0}, // LL_GAMMA_NR_CURVE_16
1239 { 0xBC4F, 0xF7, BYTE_LEN, 0}, // LL_GAMMA_NR_CURVE_17
1240 { 0xBC50, 0xFF, BYTE_LEN, 0}, // LL_GAMMA_NR_CURVE_18
1241 { 0xBC51, 0x04, BYTE_LEN, 0}, // LL_GAMMA_CURVE_SELECTOR
1243 { 0xB801, 0xE0, BYTE_LEN, 0}, // STAT_MODE
1244 { 0xB862, 0x04, BYTE_LEN, 0}, // STAT_BMTRACKING_SPEED
1246 { 0xB829, 0x02, BYTE_LEN, 0}, // STAT_LL_BRIGHTNESS_METRIC_DIVISOR
1247 { 0xB863, 0x02, BYTE_LEN, 0}, // STAT_BM_MUL
1248 { 0xB827, 0x0F, BYTE_LEN, 0}, // STAT_AE_EV_SHIFT
1249 { 0xA409, 0x4A, BYTE_LEN, 0}, // AE_RULE_BASE_TARGET
1250 { 0xA805, 0x06, BYTE_LEN, 0}, // AE_TRACK_GATE
1251 { 0xA80D, 0x08, BYTE_LEN, 0},
1252 { 0xA816, 0x0002, WORD_LEN, 0}, // AE_TRACK_MIN_INT_TIME_ROWS
1253 { 0xA401, 0x00, BYTE_LEN, 0}, // AE_RULE_MODE
1254 { 0xA80E, 0x06, BYTE_LEN, 0}, // AE_TRACK_MAX_BLACK_LEVEL
1256 { 0xC8E6, 0x014C, WORD_LEN, 0}, // RESERVED_CAM_E6
1257 { 0xC8E8, 0x0040, WORD_LEN, 0}, // RESERVED_CAM_E8
1258 { 0xBC52, 0x00C8, WORD_LEN, 0}, // LL_START_BRIGHTNESS_METRIC
1259 { 0xBC54, 0x0A28, WORD_LEN, 0}, // LL_END_BRIGHTNESS_METRIC
1260 { 0xBC58, 0x0100, WORD_LEN, 0}, //0x0000 // LL_START_GAIN_METRIC
1261 { 0xBC5A, 0x0480, WORD_LEN, 0}, //0x1000 // LL_END_GAIN_METRIC
1262 { 0xBC5E, 0x0227, WORD_LEN, 0}, // LL_START_APERTURE_GAIN_BM
1263 { 0xBC60, 0x0540, WORD_LEN, 0}, // LL_END_APERTURE_GAIN_BM
1264 { 0xBC66, 0x0154, WORD_LEN, 0}, // LL_START_APERTURE_GM
1265 { 0xBC68, 0x07D0, WORD_LEN, 0}, // LL_END_APERTURE_GM
1266 { 0xBC86, 0x00C8, WORD_LEN, 0}, // LL_START_FFNR_GM
1267 { 0xBC88, 0x0420, WORD_LEN, 0}, // LL_END_FFNR_GM
1268 { 0xBCBC, 0x0040, WORD_LEN, 0}, // LL_SFFB_START_GAIN
1269 { 0xBCBE, 0x01FC, WORD_LEN, 0}, // LL_SFFB_END_GAIN
1270 { 0xBCCC, 0x00C8, WORD_LEN, 0}, // LL_SFFB_START_MAX_GM
1271 { 0xBCCE, 0x0640, WORD_LEN, 0}, // LL_SFFB_END_MAX_GM
1272 { 0xBC90, 0x00C8, WORD_LEN, 0}, // LL_START_GRB_GM
1273 { 0xBC92, 0x0640, WORD_LEN, 0}, // LL_END_GRB_GM
1274 { 0xBC0E, 0x0032, WORD_LEN, 0}, // LL_GAMMA_CURVE_ADJ_START_POS
1275 { 0xBC10, 0x0064, WORD_LEN, 0}, // LL_GAMMA_CURVE_ADJ_MID_POS
1276 { 0xBC12, 0x0FA0, WORD_LEN, 0}, // LL_GAMMA_CURVE_ADJ_END_POS
1277 { 0xBCAA, 0x03E8, WORD_LEN, 0}, // LL_CDC_THR_ADJ_START_POS
1278 { 0xBCAC, 0x012C, WORD_LEN, 0}, // LL_CDC_THR_ADJ_MID_POS
1279 { 0xBCAE, 0x0009, WORD_LEN, 0}, // LL_CDC_THR_ADJ_END_POS
1280 { 0xBCD8, 0x00C8, WORD_LEN, 0}, // LL_PCR_START_BM
1281 { 0xBCDA, 0x0A28, WORD_LEN, 0}, // LL_PCR_END_BM
1284 { 0x3380, 0x0504, WORD_LEN, 0}, // KERNEL_CONFIG
1285 { 0x3380, 0x0505, WORD_LEN, 0}, // KERNEL_CONFIG
1286 { 0x3380, 0x0584, WORD_LEN, 0}, // KERNEL_CONFIG
1287 { 0x3380, 0x0586, WORD_LEN, 0}, // KERNEL_CONFIG
1288 { 0x3380, 0x0587, WORD_LEN, 0}, // KERNEL_CONFIG
1291 { 0xBC94, 0x06, BYTE_LEN, 0}, // LL_GB_START_THRESHOLD_0
1292 { 0xBC95, 0x05, BYTE_LEN, 0}, // LL_GB_START_THRESHOLD_1
1293 { 0xBC9C, 0x09, BYTE_LEN, 0}, // RESERVED_LL_9C
1294 { 0xBC9D, 0x05, BYTE_LEN, 0}, // RESERVED_LL_9D
1297 { 0x33B0, 0x2A16, WORD_LEN, 0}, // FFNR_ALPHA_BETA
1298 { 0xBC8A, 0x0E, BYTE_LEN, 0}, //0x00 // LL_START_FF_MIX_THRESH_Y
1299 { 0xBC8B, 0x4C, BYTE_LEN, 0}, // LL_END_FF_MIX_THRESH_Y
1300 { 0xBC8C, 0x00, BYTE_LEN, 0}, // LL_START_FF_MIX_THRESH_YGAIN
1301 { 0xBC8D, 0x24, BYTE_LEN, 0}, // LL_END_FF_MIX_THRESH_YGAIN
1302 { 0xBC8E, 0xFF, BYTE_LEN, 0}, // LL_START_FF_MIX_THRESH_GAIN
1303 { 0xBC8F, 0x00, BYTE_LEN, 0}, // LL_END_FF_MIX_THRESH_GAIN
1304 { 0xBCB2, 0x20, BYTE_LEN, 0}, // LL_CDC_DARK_CLUS_SLOPE
1305 { 0xBCB3, 0x3A, BYTE_LEN, 0}, // LL_CDC_DARK_CLUS_SATUR
1306 { 0xBCB4, 0x39, BYTE_LEN, 0}, // RESERVED_LL_B4
1307 { 0xBCB7, 0x39, BYTE_LEN, 0}, // RESERVED_LL_B7
1308 { 0xBCB5, 0x20, BYTE_LEN, 0}, // RESERVED_LL_B5
1309 { 0xBCB8, 0x3A, BYTE_LEN, 0}, // RESERVED_LL_B8
1310 { 0xBCB6, 0x80, BYTE_LEN, 0}, // RESERVED_LL_B6
1311 { 0xBCB9, 0x24, BYTE_LEN, 0}, // RESERVED_LL_B9
1313 //SFFB_rev3_noisemodel
1314 { 0xBCC0, 0x1F, BYTE_LEN, 0}, // LL_SFFB_RAMP_START
1315 { 0xBCC1, 0x03, BYTE_LEN, 0}, // LL_SFFB_RAMP_STOP
1316 { 0xBCC2, 0x3C, BYTE_LEN, 0}, // LL_SFFB_SLOPE_START
1317 { 0xBCC3, 0x10, BYTE_LEN, 0}, // LL_SFFB_SLOPE_STOP
1318 { 0xBCC4, 0x07, BYTE_LEN, 0}, // LL_SFFB_THSTART
1319 { 0xBCC5, 0x0B, BYTE_LEN, 0}, // LL_SFFB_THSTOP
1320 { 0xBCBA, 0x0009, WORD_LEN, 0}, // LL_SFFB_CONFIG
1322 //[Step7-CPIPE_Preference]
1324 { 0xBC14, 0xFFFE, WORD_LEN, 0}, // LL_GAMMA_FADE_TO_BLACK_START_POS
1325 { 0xBC16, 0xFFFF, WORD_LEN, 0}, // LL_GAMMA_FADE_TO_BLACK_END_POS
1327 //aperture_preference
1328 { 0xBC6A, 0x06, BYTE_LEN, 0}, // LL_START_APERTURE_INTEGER_GAIN
1329 { 0xBC6B, 0x00, BYTE_LEN, 0}, // LL_END_APERTURE_INTEGER_GAIN
1330 { 0xBC6C, 0x00, BYTE_LEN, 0}, // LL_START_APERTURE_EXP_GAIN
1331 { 0xBC6D, 0x00, BYTE_LEN, 0}, // LL_END_APERTURE_EXP_GAIN
1332 { 0xBCE2, 0x0A, BYTE_LEN, 0}, // LL_START_POS_KNEE
1333 { 0xBCE3, 0x2B, BYTE_LEN, 0}, // LL_END_POS_KNEE
1334 { 0xBCE4, 0x0A, BYTE_LEN, 0}, // LL_START_NEG_KNEE
1335 { 0xBCE5, 0x2B, BYTE_LEN, 0}, // LL_END_NEG_KNEE
1336 { 0x33BA, 0x0084, WORD_LEN, 0}, // APEDGE_CONTROL
1337 { 0x33BE, 0x0000, WORD_LEN, 0}, // UA_KNEE_L
1338 { 0x33C2, 0x5600, WORD_LEN, 0}, // UA_WEIGHTS
1339 { 0xBC62, 0x10, BYTE_LEN, 0}, // LL_START_APERTURE_KPGAIN
1340 { 0xBC63, 0x1F, BYTE_LEN, 0}, // LL_END_APERTURE_KPGAIN
1341 { 0xBC64, 0x10, BYTE_LEN, 0}, // LL_START_APERTURE_KNGAIN
1342 { 0xBC65, 0x1F, BYTE_LEN, 0}, // LL_END_APERTURE_KNGAIN
1343 { 0xA81C, 0x0043, WORD_LEN, 0}, // AE_TRACK_MIN_AGAIN
1344 { 0xA81E, 0x0102, WORD_LEN, 0}, // AE_TRACK_TARGET_AGAIN
1345 { 0xA820, 0x0102, WORD_LEN, 0}, // AE_TRACK_MAX_AGAIN
1346 { 0xA822, 0x0080, WORD_LEN, 0}, // AE_TRACK_MIN_DGAIN
1347 { 0xA824, 0x0080, WORD_LEN, 0}, // AE_TRACK_MAX_DGAIN
1350 { 0xA818, 0x07D0, WORD_LEN, 0}, // AE_TRACK_TARGET_INT_TIME_ROWS
1351 { 0xA81A, 0x0A00, WORD_LEN, 0}, //0x0810(10.9Fps) //0x0FF4(5Fps) // AE_TRACK_MAX_INT_TIME_ROWS
1354 { 0xBC56, 0x80, BYTE_LEN, 0}, //0xA8 // LL_START_CCM_SATURATION
1355 { 0xBC57, 0x10, BYTE_LEN, 0}, // LL_END_CCM_SATURATION
1358 { 0xBCDE, 0x03, BYTE_LEN, 0}, // LL_START_SYS_THRESHOLD
1359 { 0xBCDF, 0x50, BYTE_LEN, 0}, // LL_STOP_SYS_THRESHOLD
1360 { 0xBCE0, 0x08, BYTE_LEN, 0}, // LL_START_SYS_GAIN
1361 { 0xBCE1, 0x03, BYTE_LEN, 0}, // LL_STOP_SYS_GAIN
1364 { 0xBCD0, 0x000A, WORD_LEN, 0}, // LL_SFFB_SOBEL_FLAT_START
1365 { 0xBCD2, 0x00FE, WORD_LEN, 0}, // LL_SFFB_SOBEL_FLAT_STOP
1366 { 0xBCD4, 0x001E, WORD_LEN, 0}, // LL_SFFB_SOBEL_SHARP_START
1367 { 0xBCD6, 0x00FF, WORD_LEN, 0}, // LL_SFFB_SOBEL_SHARP_STOP
1368 { 0xBCC6, 0x00, BYTE_LEN, 0}, // LL_SFFB_SHARPENING_START
1369 { 0xBCC7, 0x00, BYTE_LEN, 0}, // LL_SFFB_SHARPENING_STOP
1370 { 0xBCC8, 0x20, BYTE_LEN, 0}, // LL_SFFB_FLATNESS_START
1371 { 0xBCC9, 0x40, BYTE_LEN, 0}, // LL_SFFB_FLATNESS_STOP
1372 { 0xBCCA, 0x04, BYTE_LEN, 0}, // LL_SFFB_TRANSITION_START
1373 { 0xBCCB, 0x00, BYTE_LEN, 0}, // LL_SFFB_TRANSITION_STOP
1374 //SFFB_slope_zero_enable
1375 { 0xBCE6, 0x03 , BYTE_LEN, 0 }, // LL_SFFB_ZERO_ENABLE
1377 { 0x8417, 0x02, BYTE_LEN, 0 }, // SEQ_STATE_CFG_1_FD
1379 { 0xC8ED, 0x02, BYTE_LEN, 0 }, // CAM_TX_ENABLE_MODE Context A,B time
1381 { 0x8404, 0x06, BYTE_LEN, 0 }, // SEQ_CMD
1382 ///{ SEQUENCE_WAIT_MS,300, WORD_LEN, 0},
1383 { SEQUENCE_WAIT_MS,100, WORD_LEN, 0},
1384 { SEQUENCE_END, 0x00, 0, 0}
1387 /* 720p 15fps @ 1280x720 */
1388 static struct reginfo sensor_720p[]=
1390 //{SEQUENCE_END, 0x00},
1391 {0x098E, 0x843C, WORD_LEN, 0}, // LOGICAL_ADDRESS_ACCESS [CAM_CORE_A_Y_ADDR_START]
1392 {0x843C, 0x01, BYTE_LEN, 0 }, // SEQ_STATE_CFG_5_MAX_FRAME_CNT
1393 {0x8404, 0x01, BYTE_LEN, 0 }, // SEQ_CMD
1394 {0x0016, 0x0447, WORD_LEN, 0}, // CLOCKS_CONTROL
1395 {0xC83A, 0x0106, WORD_LEN, 0}, // CAM_CORE_A_Y_ADDR_START
1396 {0xC83C, 0x0018, WORD_LEN, 0}, // CAM_CORE_A_X_ADDR_START
1397 {0xC83E, 0x06B7, WORD_LEN, 0}, // CAM_CORE_A_Y_ADDR_END
1398 {0xC840, 0x0A45, WORD_LEN, 0}, // CAM_CORE_A_X_ADDR_END
1399 {0xC86C, 0x0518, WORD_LEN, 0}, // CAM_CORE_A_OUTPUT_SIZE_WIDTH
1400 {0xC86E, 0x02D8, WORD_LEN, 0}, // CAM_CORE_A_OUTPUT_SIZE_HEIGHT
1401 {0xC870, 0x0014, WORD_LEN, 0}, // CAM_CORE_A_RX_FIFO_TRIGGER_MARK
1402 {0xC858, 0x0003, WORD_LEN, 0}, // CAM_CORE_A_COARSE_ITMIN
1403 {0xC8B8, 0x0004, WORD_LEN, 0}, // CAM_OUTPUT_0_JPEG_CONTROL
1404 /****bug:part pixsels data not to be aquired *****/
1405 #if ADJUST_FOR_720P_FALG
1406 {0xC8AA, 0x0500, WORD_LEN, 0}, // CAM_OUTPUT_0_IMAGE_WIDTH
1407 {0xC8AC, 0x02D1, WORD_LEN, 0}, // CAM_OUTPUT_0_IMAGE_HEIGHT
1409 {0xC8AA, 0x0500, WORD_LEN, 0}, // CAM_OUTPUT_0_IMAGE_WIDTH
1410 {0xC8AC, 0x02D0, WORD_LEN, 0}, // CAM_OUTPUT_0_IMAGE_HEIGHT
1412 {0xC8AE, 0x0001, WORD_LEN, 0}, // CAM_OUTPUT_0_OUTPUT_FORMAT
1413 {0x8404, 0x06, BYTE_LEN, 0 }, // SEQ_CMD
1415 {SEQUENCE_WAIT_MS,100, WORD_LEN, 0},
1416 { SEQUENCE_END, 0x00, 0, 0}
1419 /* 1080p, 0x15fps, 0xyuv @1920x1080 */
1420 static struct reginfo sensor_1080p[]=
1422 { SEQUENCE_END, 0x00, 0, 0}
1425 /* 2592X1944 QSXGA */
1426 #if ADJUST_FOR_CAPTURE_FALG
1427 static struct reginfo sensor_qsxga[] =
1429 {0x098E, 0x48C0,WORD_LEN,0}, // LOGICAL_ADDRESS_ACCESS [CAM_OUTPUT_1_IMAGE_WIDTH]
1430 {0xC8C0, 0x0A20,WORD_LEN,0}, // CAM_OUTPUT_1_IMAGE_WIDTH
1431 {0xC8C2, 0x0798,WORD_LEN,0}, // CAM_OUTPUT_1_IMAGE_HEIGHT
1432 {0x8404, 0x06 ,BYTE_LEN,0}, // SEQ_CMD
1433 {SEQUENCE_WAIT_MS,100,WORD_LEN,0},
1434 {SEQUENCE_END, 0x00, 0, 0}
1437 static struct reginfo sensor_qsxga[] =
1439 {SEQUENCE_PROPERTY,SEQUENCE_CAPTURE},
1440 { SEQUENCE_END, 0x00, 0, 0}
1444 /* 2048*1536 QXGA */
1445 #if ADJUST_FOR_CAPTURE_FALG
1446 // send extra two lines to forbid to be captured error
1447 static struct reginfo sensor_qxga[] =
1449 {0x098E, 0x48C0,WORD_LEN,0}, // LOGICAL_ADDRESS_ACCESS [CAM_OUTPUT_1_IMAGE_WIDTH]
1450 {0xC8C0, 0x0800,WORD_LEN,0}, // CAM_OUTPUT_1_IMAGE_WIDTH
1451 {0xC8C2, 0x0602,WORD_LEN,0}, // CAM_OUTPUT_1_IMAGE_HEIGHT
1452 {0x8404, 0x06 ,BYTE_LEN,0}, // SEQ_CMD
1453 {SEQUENCE_WAIT_MS,100,WORD_LEN,0},
1454 {SEQUENCE_END, 0x00, 0, 0}
1457 static struct reginfo sensor_qxga[] =
1459 { SEQUENCE_END, 0x00, 0, 0}
1463 /* 1600X1200 UXGA */
1464 #if ADJUST_FOR_CAPTURE_FALG
1465 static struct reginfo sensor_uxga[] =
1467 {0x098E, 0x48C0,WORD_LEN,0}, // LOGICAL_ADDRESS_ACCESS [CAM_OUTPUT_1_IMAGE_WIDTH]
1468 {0xC8C0, 0x0640,WORD_LEN,0}, // CAM_OUTPUT_1_IMAGE_WIDTH
1469 {0xC8C2, 0x04b2,WORD_LEN,0}, // CAM_OUTPUT_1_IMAGE_HEIGHT
1470 {0x8404, 0x06 ,BYTE_LEN,0}, // SEQ_CMD
1471 {SEQUENCE_WAIT_MS,100,WORD_LEN,0},
1472 {SEQUENCE_END, 0x00, 0, 0}
1475 static struct reginfo sensor_uxga[] =
1477 { SEQUENCE_END, 0x00, 0, 0}
1481 /* 1280X1024 SXGA */
1482 static struct reginfo sensor_sxga[] =
1484 {SEQUENCE_END, 0x00}
1488 #if ADJUST_FOR_CAPTURE_FALG
1489 static struct reginfo sensor_xga[] =
1491 {0x098E, 0x48C0,WORD_LEN,0}, // LOGICAL_ADDRESS_ACCESS [CAM_OUTPUT_1_IMAGE_WIDTH]
1492 {0xC8C0, 0x0403,WORD_LEN,0}, // CAM_OUTPUT_1_IMAGE_WIDTH
1493 {0xC8C2, 0x0302,WORD_LEN,0}, // CAM_OUTPUT_1_IMAGE_HEIGHT
1494 {0x8404, 0x06 ,BYTE_LEN,0}, // SEQ_CMD
1495 {SEQUENCE_WAIT_MS,100,WORD_LEN,0},
1496 {SEQUENCE_END, 0x00, 0, 0}
1499 static struct reginfo sensor_xga[] =
1501 {SEQUENCE_END, 0x00, 0, 0}
1507 static struct reginfo sensor_svga[] =
1509 { SEQUENCE_END, 0x00, 0, 0}
1513 static struct reginfo sensor_vga[] =
1516 {0xC83A, 0x000C, WORD_LEN, 0}, // CAM_CORE_A_Y_ADDR_START
1517 {0xC83C, 0x0018, WORD_LEN, 0}, // CAM_CORE_A_X_ADDR_START
1518 {0xC83E, 0x07B1, WORD_LEN, 0 }, // CAM_CORE_A_Y_ADDR_END
1519 {0xC840, 0x0A45, WORD_LEN, 0}, // CAM_CORE_A_X_ADDR_END
1520 {0xC868, 0x0423, WORD_LEN, 0}, // CAM_CORE_A_FRAME_LENGTH_LINES
1521 {0xC86A, 0x1194, WORD_LEN, 0}, // CAM_CORE_A_LINE_LENGTH_PCK
1522 {0xC86C, 0x0518, WORD_LEN, 0}, // CAM_CORE_A_OUTPUT_SIZE_WIDTH
1523 {0xC86E, 0x03D4, WORD_LEN, 0}, // CAM_CORE_A_OUTPUT_SIZE_HEIGHT
1524 {0xC870, 0x0014, WORD_LEN, 0}, // CAM_CORE_A_RX_FIFO_TRIGGER_MARK
1525 {0xC858, 0x0003, WORD_LEN, 0}, // CAM_CORE_A_COARSE_ITMIN
1526 {0xC8A4, 0x0A28, WORD_LEN, 0}, // CAM_CORE_B_OUTPUT_SIZE_WIDTH
1527 {0xC8A6, 0x07A0, WORD_LEN, 0 }, // CAM_CORE_B_OUTPUT_SIZE_HEIGHT
1528 {0xC8AA, 0x0280, WORD_LEN, 0 }, // CAM_OUTPUT_0_IMAGE_WIDTH
1529 {0xC8AC, 0x01E0, WORD_LEN, 0 }, // CAM_OUTPUT_0_IMAGE_HEIGHT
1530 {0xC8AE, 0x0001, WORD_LEN, 0 }, // CAM_OUTPUT_0_OUTPUT_FORMAT
1531 {0x8404, 0x06, BYTE_LEN, 0 }, // SEQ_CMD
1532 {SEQUENCE_WAIT_MS,100, WORD_LEN, 0},
1533 {SEQUENCE_END, 0x00, 0, 0}
1538 static struct reginfo sensor_cif[] =
1540 {SEQUENCE_END, 0x00}
1544 static struct reginfo sensor_qvga[] =
1546 {SEQUENCE_END, 0x00}
1550 static struct reginfo sensor_qcif[] =
1552 {SEQUENCE_END, 0x00}
1555 static struct reginfo sensor_Preview2Capture[]=
1558 {0x098E, 0x843C, WORD_LEN, 0}, // LOGICAL_ADDRESS_ACCESS [SEQ_STATE_CFG_5_MAX_FRAME_CNT]
1559 {0x843C, 0xFF, BYTE_LEN, 0 }, // SEQ_STATE_CFG_5_MAX_FRAME_CNT
1560 {0x8404, 0x02, BYTE_LEN, 0 }, // SEQ_CMD
1561 {SEQUENCE_END, 0x00, 0, 0}
1565 static struct reginfo sensor_Capture2Preview[]=
1568 {0x098E, 0x843C, WORD_LEN, 0}, // LOGICAL_ADDRESS_ACCESS [SEQ_STATE_CFG_5_MAX_FRAME_CNT]
1569 {0x843C, 0x01, BYTE_LEN, 0 }, // SEQ_STATE_CFG_5_MAX_FRAME_CNT
1570 {0x8404, 0x01, BYTE_LEN, 0 }, // SEQ_CMD
1571 {0x0016, 0x0447, WORD_LEN, 0}, // CLOCKS_CONTRO
1572 {SEQUENCE_END, 0x00, 0, 0}
1575 static struct reginfo sensor_ClrFmt_YUYV[]=
1577 {SEQUENCE_END, 0x00}
1580 static struct reginfo sensor_ClrFmt_UYVY[]=
1582 {SEQUENCE_END, 0x00}
1586 #if CONFIG_SENSOR_WhiteBalance
1587 static struct reginfo sensor_WhiteB_Auto[]=
1590 {0x098E, 0xACB0, WORD_LEN, 0}, // LOGICAL_ADDRESS_ACCESS [AWB_MIN_ACCEPTED_PRE_AWB_R2G_RATIO]
1591 {0xACB0, 0x31, BYTE_LEN, 0 }, // AWB_RG_MIN
1592 {0xACB1, 0x5B, BYTE_LEN, 0 }, // AWB_RG_MAX
1593 {0xACB4, 0x2A, BYTE_LEN, 0 }, // AWB_BG_MIN
1594 {0xACB5, 0x5B, BYTE_LEN, 0 }, // AWB_BG_MAX
1595 {0xACB2, 0x40, BYTE_LEN, 0 }, // AWB_RG_MIN_BRIGHT
1596 {0xACB3, 0x48, BYTE_LEN, 0 }, // AWB_RG_MAX_BRIGHT
1597 {0xACB6, 0x3f, BYTE_LEN, 0 }, // AWB_BG_MIN_BRIGHT
1598 {0xACB7, 0x48, BYTE_LEN, 0 }, // AWB_BG_MAX_BRIGHT
1599 {0xAC44, 0x00, BYTE_LEN, 0 }, // AWB_LEFT_CCM_POS_RANGE_LIMIT
1600 {0xAC45, 0x7F, BYTE_LEN, 0 }, // AWB_RIGHT_CCM_POS_RANGE_LIMIT
1601 {SEQUENCE_END, 0x00, 0, 0}
1604 /* Cloudy Colour Temperature : 6500K - 8000K */
1605 static struct reginfo sensor_WhiteB_Cloudy[]=
1608 { 0x098E, 0xACB0, WORD_LEN, 0}, // LOGICAL_ADDRESS_ACCESS [AWB_MIN_ACCEPTED_PRE_AWB_R2G_RATIO]
1609 {0xACB0, 0x38, BYTE_LEN, 0 }, // AWB_RG_MIN
1610 {0xACB1, 0x42, BYTE_LEN, 0 }, // AWB_RG_MAX
1611 {0xACB4, 0x44, BYTE_LEN, 0 }, // AWB_BG_MIN
1612 {0xACB5, 0x4C, BYTE_LEN, 0 }, // AWB_BG_MAX
1613 {0xACB2, 0x38, BYTE_LEN, 0 }, // AWB_RG_MIN_BRIGHT
1614 {0xACB3, 0x42, BYTE_LEN, 0 }, // AWB_RG_MAX_BRIGHT
1615 {0xACB6, 0x44, BYTE_LEN, 0 }, // AWB_BG_MIN_BRIGHT
1616 {0xACB7, 0x4C, BYTE_LEN, 0 }, // AWB_BG_MAX_BRIGHT
1617 {0xAC44, 0x7C, BYTE_LEN, 0 }, // AWB_LEFT_CCM_POS_RANGE_LIMIT
1618 {0xAC45, 0x7F, BYTE_LEN, 0 }, // AWB_RIGHT_CCM_POS_RANGE_LIMIT
1619 {0xAC04, 0x3E, BYTE_LEN, 0 }, // AWB_PRE_AWB_R2G_RATIO
1620 {0xAC05, 0x48, BYTE_LEN, 0 }, // AWB_PRE_AWB_B2G_RATIO
1621 {0xAC08, 0x7F, BYTE_LEN, 0 }, // AWB_CUR_CCM_POS
1622 {SEQUENCE_END, 0x00, 0, 0}
1625 /* ClearDay Colour Temperature : 5000K - 6500K */
1626 static struct reginfo sensor_WhiteB_ClearDay[]=
1629 { 0x098E, 0xACB0, WORD_LEN, 0}, // LOGICAL_ADDRESS_ACCESS [AWB_MIN_ACCEPTED_PRE_AWB_R2G_RATIO]
1630 {0xACB0, 0x3A, BYTE_LEN, 0 }, // AWB_RG_MIN
1631 {0xACB1, 0x44, BYTE_LEN, 0 }, // AWB_RG_MAX
1632 {0xACB4, 0x40, BYTE_LEN, 0 }, // AWB_BG_MIN
1633 {0xACB5, 0x4A, BYTE_LEN, 0 }, // AWB_BG_MAX
1634 {0xACB2, 0x3A, BYTE_LEN, 0 }, // AWB_RG_MIN_BRIGHT
1635 {0xACB3, 0x44, BYTE_LEN, 0 }, // AWB_RG_MAX_BRIGHT
1636 {0xACB6, 0x40, BYTE_LEN, 0 }, // AWB_BG_MIN_BRIGHT
1637 {0xACB7, 0x4A, BYTE_LEN, 0 }, // AWB_BG_MAX_BRIGHT
1638 {0xAC44, 0x7C, BYTE_LEN, 0 }, // AWB_LEFT_CCM_POS_RANGE_LIMIT
1639 {0xAC45, 0x7F, BYTE_LEN, 0 }, // AWB_RIGHT_CCM_POS_RANGE_LIMIT
1640 {0xAC04, 0x40, BYTE_LEN, 0 }, // AWB_PRE_AWB_R2G_RATIO
1641 {0xAC05, 0x48, BYTE_LEN, 0 }, // AWB_PRE_AWB_B2G_RATIO
1642 {0xAC08, 0x7F, BYTE_LEN, 0 }, // AWB_CUR_CCM_POS
1643 {SEQUENCE_END, 0x00, 0, 0}
1646 /* Office Colour Temperature : 3500K - 5000K */
1647 static struct reginfo sensor_WhiteB_TungstenLamp1[]=
1650 { 0x098E, 0xACB0, WORD_LEN, 0}, // LOGICAL_ADDRESS_ACCESS [AWB_MIN_ACCEPTED_PRE_AWB_R2G_RATIO]
1651 {0xACB0, 0x44, BYTE_LEN, 0 }, // AWB_RG_MIN
1652 {0xACB1, 0x4B, BYTE_LEN, 0 }, // AWB_RG_MAX
1653 {0xACB4, 0x2C, BYTE_LEN, 0 }, // AWB_BG_MIN
1654 {0xACB5, 0x34, BYTE_LEN, 0 }, // AWB_BG_MAX
1655 {0xACB2, 0x44, BYTE_LEN, 0 }, // AWB_RG_MIN_BRIGHT
1656 {0xACB3, 0x4B, BYTE_LEN, 0 }, // AWB_RG_MAX_BRIGHT
1657 {0xACB6, 0x2C, BYTE_LEN, 0 }, // AWB_BG_MIN_BRIGHT
1658 {0xACB7, 0x34, BYTE_LEN, 0 }, // AWB_BG_MAX_BRIGHT
1659 {0xAC44, 0x40, BYTE_LEN, 0 }, // AWB_LEFT_CCM_POS_RANGE_LIMIT
1660 {0xAC45, 0x4A, BYTE_LEN, 0 }, // AWB_RIGHT_CCM_POS_RANGE_LIMIT
1661 {0xAC04, 0x47, BYTE_LEN, 0 }, // AWB_PRE_AWB_R2G_RATIO
1662 {0xAC05, 0x30, BYTE_LEN, 0 }, // AWB_PRE_AWB_B2G_RATIO
1663 {0xAC08, 0x45, BYTE_LEN, 0 }, // AWB_CUR_CCM_POS
1664 {SEQUENCE_END, 0x00, 0, 0}
1666 /* Home Colour Temperature : 2500K - 3500K */
1667 static struct reginfo sensor_WhiteB_TungstenLamp2[]=
1669 //[II. Incandescent]
1670 { 0x098E, 0xACB0, WORD_LEN, 0}, // LOGICAL_ADDRESS_ACCESS [AWB_MIN_ACCEPTED_PRE_AWB_R2G_RATIO]
1671 {0xACB0, 0x57, BYTE_LEN, 0 }, // AWB_RG_MIN
1672 {0xACB1, 0x5F, BYTE_LEN, 0 }, // AWB_RG_MAX
1673 {0xACB4, 0x26, BYTE_LEN, 0 }, // AWB_BG_MIN
1674 {0xACB5, 0x2E, BYTE_LEN, 0 }, // AWB_BG_MAX
1675 {0xACB2, 0x57, BYTE_LEN, 0 }, // AWB_RG_MIN_BRIGHT
1676 {0xACB3, 0x5F, BYTE_LEN, 0 }, // AWB_RG_MAX_BRIGHT
1677 {0xACB6, 0x26, BYTE_LEN, 0 }, // AWB_BG_MIN_BRIGHT
1678 {0xACB7, 0x2E, BYTE_LEN, 0 }, // AWB_BG_MAX_BRIGHT
1679 {0xAC44, 0x00, BYTE_LEN, 0 }, // AWB_LEFT_CCM_POS_RANGE_LIMIT
1680 {0xAC45, 0x08, BYTE_LEN, 0 }, // AWB_RIGHT_CCM_POS_RANGE_LIMIT
1681 {0xAC04, 0x5B, BYTE_LEN, 0 }, // AWB_PRE_AWB_R2G_RATIO
1682 {0xAC05, 0x2A, BYTE_LEN, 0 }, // AWB_PRE_AWB_B2G_RATIO
1683 {0xAC08, 0x00, BYTE_LEN, 0 }, // AWB_CUR_CCM_POS
1684 {SEQUENCE_END, 0x00, 0, 0}
1686 static struct reginfo *sensor_WhiteBalanceSeqe[] = {sensor_WhiteB_Auto, sensor_WhiteB_TungstenLamp1,sensor_WhiteB_TungstenLamp2,
1687 sensor_WhiteB_ClearDay, sensor_WhiteB_Cloudy,NULL,
1691 #if CONFIG_SENSOR_Brightness
1692 static struct reginfo sensor_Brightness0[]=
1694 {SEQUENCE_END, 0x00}
1697 static struct reginfo sensor_Brightness1[]=
1699 {SEQUENCE_END, 0x00}
1702 static struct reginfo sensor_Brightness2[]=
1704 {SEQUENCE_END, 0x00}
1707 static struct reginfo sensor_Brightness3[]=
1709 {SEQUENCE_END, 0x00}
1712 static struct reginfo sensor_Brightness4[]=
1714 {SEQUENCE_END, 0x00}
1717 static struct reginfo sensor_Brightness5[]=
1719 {SEQUENCE_END, 0x00}
1721 static struct reginfo *sensor_BrightnessSeqe[] = {sensor_Brightness0, sensor_Brightness1, sensor_Brightness2, sensor_Brightness3,
1722 sensor_Brightness4, sensor_Brightness5,NULL,
1727 #if CONFIG_SENSOR_Effect
1728 static struct reginfo sensor_Effect_Normal[] =
1730 {0x098e,0xdc38, WORD_LEN, 0},
1731 {0xdc38,0x00, BYTE_LEN, 0 },
1732 {0x8404,0x06, BYTE_LEN, 0 },
1733 {SEQUENCE_END, 0x00, 0, 0}
1736 static struct reginfo sensor_Effect_WandB[] =
1738 {SEQUENCE_END, 0x00, 0, 0}
1741 static struct reginfo sensor_Effect_Sepia[] =
1743 {0x098e,0xdc38, WORD_LEN, 0},
1744 {0xdc38,0x02, BYTE_LEN, 0 },
1745 {0xdc3a,0x10, BYTE_LEN, 0 },
1746 {0xdc3b,0xe0, BYTE_LEN, 0 },
1747 {0x8404,0x06, BYTE_LEN, 0 },
1748 {SEQUENCE_END, 0x00, 0, 0}
1751 static struct reginfo sensor_Effect_Negative[] =
1753 {0x098e,0xdc38, WORD_LEN, 0},
1754 {0xdc38,0x03, BYTE_LEN, 0 },
1755 {0x8404,0x06, BYTE_LEN, 0 },
1756 {SEQUENCE_END, 0x00, 0, 0}
1759 static struct reginfo sensor_Effect_Bluish[] =
1761 {SEQUENCE_END, 0x00, 0, 0}
1764 static struct reginfo sensor_Effect_Green[] =
1766 {SEQUENCE_END, 0x00, 0, 0}
1769 static struct reginfo sensor_Effect_Solarize[] =
1771 {0x098e,0xdc38, WORD_LEN, 0},
1772 {0xdc38,0x05, BYTE_LEN, 0 },
1773 {0xdc39,0x20, BYTE_LEN, 0 },
1774 {0x8404,0x06, BYTE_LEN, 0 },
1775 {SEQUENCE_END, 0x00, 0, 0}
1777 static struct reginfo *sensor_EffectSeqe[] = {sensor_Effect_Normal, sensor_Effect_Negative,sensor_Effect_Sepia,
1778 sensor_Effect_Solarize,NULL,
1781 #if CONFIG_SENSOR_Exposure
1782 static struct reginfo sensor_Exposure0[]=
1784 {SEQUENCE_END, 0x00}
1787 static struct reginfo sensor_Exposure1[]=
1789 {SEQUENCE_END, 0x00}
1792 static struct reginfo sensor_Exposure2[]=
1794 {SEQUENCE_END, 0x00}
1797 static struct reginfo sensor_Exposure3[]=
1799 {SEQUENCE_END, 0x00}
1802 static struct reginfo sensor_Exposure4[]=
1804 {SEQUENCE_END, 0x00}
1807 static struct reginfo sensor_Exposure5[]=
1809 {SEQUENCE_END, 0x00}
1812 static struct reginfo sensor_Exposure6[]=
1814 {SEQUENCE_END, 0x00}
1817 static struct reginfo *sensor_ExposureSeqe[] = {sensor_Exposure0, sensor_Exposure1, sensor_Exposure2, sensor_Exposure3,
1818 sensor_Exposure4, sensor_Exposure5,sensor_Exposure6,NULL,
1821 #if CONFIG_SENSOR_Saturation
1822 static struct reginfo sensor_Saturation0[]=
1824 {SEQUENCE_END, 0x00}
1827 static struct reginfo sensor_Saturation1[]=
1829 {SEQUENCE_END, 0x00}
1832 static struct reginfo sensor_Saturation2[]=
1834 {SEQUENCE_END, 0x00}
1836 static struct reginfo *sensor_SaturationSeqe[] = {sensor_Saturation0, sensor_Saturation1, sensor_Saturation2, NULL,};
1839 #if CONFIG_SENSOR_Contrast
1840 static struct reginfo sensor_Contrast0[]=
1842 {SEQUENCE_END, 0x00}
1845 static struct reginfo sensor_Contrast1[]=
1847 {SEQUENCE_END, 0x00}
1850 static struct reginfo sensor_Contrast2[]=
1852 {SEQUENCE_END, 0x00}
1855 static struct reginfo sensor_Contrast3[]=
1857 {SEQUENCE_END, 0x00}
1860 static struct reginfo sensor_Contrast4[]=
1862 {SEQUENCE_END, 0x00}
1866 static struct reginfo sensor_Contrast5[]=
1868 {SEQUENCE_END, 0x00}
1871 static struct reginfo sensor_Contrast6[]=
1873 {SEQUENCE_END, 0x00}
1875 static struct reginfo *sensor_ContrastSeqe[] = {sensor_Contrast0, sensor_Contrast1, sensor_Contrast2, sensor_Contrast3,
1876 sensor_Contrast4, sensor_Contrast5, sensor_Contrast6, NULL,
1880 #if CONFIG_SENSOR_Mirror
1881 static struct reginfo sensor_MirrorOn[]=
1883 {SEQUENCE_END, 0x00, 0, 0}
1886 static struct reginfo sensor_MirrorOff[]=
1888 {SEQUENCE_END, 0x00, 0, 0}
1890 static struct reginfo *sensor_MirrorSeqe[] = {sensor_MirrorOff, sensor_MirrorOn,NULL,};
1892 #if CONFIG_SENSOR_Flip
1893 static struct reginfo sensor_FlipOn[]=
1895 {SEQUENCE_END, 0x00, 0, 0}
1898 static struct reginfo sensor_FlipOff[]=
1900 {SEQUENCE_END, 0x00, 0, 0}
1902 static struct reginfo *sensor_FlipSeqe[] = {sensor_FlipOff, sensor_FlipOn,NULL,};
1906 #if CONFIG_SENSOR_Scene
1907 static struct reginfo sensor_SceneAuto[] =
1909 {SEQUENCE_END, 0x00, 0, 0}
1912 static struct reginfo sensor_SceneNight[] =
1914 {SEQUENCE_END, 0x00, 0, 0}
1916 static struct reginfo *sensor_SceneSeqe[] = {sensor_SceneAuto, sensor_SceneNight,NULL,};
1920 #if CONFIG_SENSOR_DigitalZoom
1921 static struct reginfo sensor_Zoom0[] =
1923 {SEQUENCE_END, 0x00, 0, 0}
1926 static struct reginfo sensor_Zoom1[] =
1928 {SEQUENCE_END, 0x00, 0, 0}
1931 static struct reginfo sensor_Zoom2[] =
1933 {SEQUENCE_END, 0x00, 0, 0}
1937 static struct reginfo sensor_Zoom3[] =
1939 {SEQUENCE_END, 0x00, 0, 0}
1941 static struct reginfo *sensor_ZoomSeqe[] = {sensor_Zoom0, sensor_Zoom1, sensor_Zoom2, sensor_Zoom3, NULL};
1943 static const struct v4l2_querymenu sensor_menus[] =
1945 #if CONFIG_SENSOR_WhiteBalance
1946 { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 0, .name = "auto", .reserved = 0, }, { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 1, .name = "incandescent", .reserved = 0,},
1947 { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 2, .name = "fluorescent", .reserved = 0,}, { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 3, .name = "daylight", .reserved = 0,},
1948 { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 4, .name = "cloudy-daylight", .reserved = 0,},
1951 #if CONFIG_SENSOR_Effect
1952 { .id = V4L2_CID_EFFECT, .index = 0, .name = "none", .reserved = 0, }, { .id = V4L2_CID_EFFECT, .index = 1, .name = "negative", .reserved = 0,},
1953 { .id = V4L2_CID_EFFECT, .index = 2, .name = "sepia", .reserved = 0,}, { .id = V4L2_CID_EFFECT, .index = 3, .name = "solarize", .reserved = 0,},
1956 #if CONFIG_SENSOR_Scene
1957 { .id = V4L2_CID_SCENE, .index = 0, .name = "auto", .reserved = 0,} ,{ .id = V4L2_CID_SCENE, .index = 1, .name = "night", .reserved = 0,},
1960 #if CONFIG_SENSOR_Flash
1961 { .id = V4L2_CID_FLASH, .index = 0, .name = "off", .reserved = 0, }, { .id = V4L2_CID_FLASH, .index = 1, .name = "auto", .reserved = 0,},
1962 { .id = V4L2_CID_FLASH, .index = 2, .name = "on", .reserved = 0,}, { .id = V4L2_CID_FLASH, .index = 3, .name = "torch", .reserved = 0,},
1966 static struct v4l2_queryctrl sensor_controls[] =
1968 #if CONFIG_SENSOR_WhiteBalance
1970 .id = V4L2_CID_DO_WHITE_BALANCE,
1971 .type = V4L2_CTRL_TYPE_MENU,
1972 .name = "White Balance Control",
1980 #if CONFIG_SENSOR_Brightness
1982 .id = V4L2_CID_BRIGHTNESS,
1983 .type = V4L2_CTRL_TYPE_INTEGER,
1984 .name = "Brightness Control",
1992 #if CONFIG_SENSOR_Effect
1994 .id = V4L2_CID_EFFECT,
1995 .type = V4L2_CTRL_TYPE_MENU,
1996 .name = "Effect Control",
2004 #if CONFIG_SENSOR_Exposure
2006 .id = V4L2_CID_EXPOSURE,
2007 .type = V4L2_CTRL_TYPE_INTEGER,
2008 .name = "Exposure Control",
2016 #if CONFIG_SENSOR_Saturation
2018 .id = V4L2_CID_SATURATION,
2019 .type = V4L2_CTRL_TYPE_INTEGER,
2020 .name = "Saturation Control",
2028 #if CONFIG_SENSOR_Contrast
2030 .id = V4L2_CID_CONTRAST,
2031 .type = V4L2_CTRL_TYPE_INTEGER,
2032 .name = "Contrast Control",
2040 #if CONFIG_SENSOR_Mirror
2042 .id = V4L2_CID_HFLIP,
2043 .type = V4L2_CTRL_TYPE_BOOLEAN,
2044 .name = "Mirror Control",
2052 #if CONFIG_SENSOR_Flip
2054 .id = V4L2_CID_VFLIP,
2055 .type = V4L2_CTRL_TYPE_BOOLEAN,
2056 .name = "Flip Control",
2064 #if CONFIG_SENSOR_Scene
2066 .id = V4L2_CID_SCENE,
2067 .type = V4L2_CTRL_TYPE_MENU,
2068 .name = "Scene Control",
2076 #if CONFIG_SENSOR_DigitalZoom
2078 .id = V4L2_CID_ZOOM_RELATIVE,
2079 .type = V4L2_CTRL_TYPE_INTEGER,
2080 .name = "DigitalZoom Control",
2086 .id = V4L2_CID_ZOOM_ABSOLUTE,
2087 .type = V4L2_CTRL_TYPE_INTEGER,
2088 .name = "DigitalZoom Control",
2096 #if CONFIG_SENSOR_Focus
2098 .id = V4L2_CID_FOCUS_RELATIVE,
2099 .type = V4L2_CTRL_TYPE_INTEGER,
2100 .name = "Focus Control",
2106 .id = V4L2_CID_FOCUS_ABSOLUTE,
2107 .type = V4L2_CTRL_TYPE_INTEGER,
2108 .name = "Focus Control",
2112 .default_value = 125,
2115 .id = V4L2_CID_FOCUS_AUTO,
2116 .type = V4L2_CTRL_TYPE_BOOLEAN,
2117 .name = "Focus Control",
2123 .id = V4L2_CID_FOCUS_CONTINUOUS,
2124 .type = V4L2_CTRL_TYPE_BOOLEAN,
2125 .name = "Focus Control",
2133 #if CONFIG_SENSOR_Flash
2135 .id = V4L2_CID_FLASH,
2136 .type = V4L2_CTRL_TYPE_MENU,
2137 .name = "Flash Control",
2147 static int sensor_probe(struct i2c_client *client, const struct i2c_device_id *did);
2148 static int sensor_video_probe(struct soc_camera_device *icd, struct i2c_client *client);
2149 static int sensor_g_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl);
2150 static int sensor_s_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl);
2151 static int sensor_g_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl);
2152 static int sensor_s_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl);
2153 static int sensor_suspend(struct soc_camera_device *icd, pm_message_t pm_msg);
2154 static int sensor_resume(struct soc_camera_device *icd);
2155 static int sensor_set_bus_param(struct soc_camera_device *icd,unsigned long flags);
2156 static unsigned long sensor_query_bus_param(struct soc_camera_device *icd);
2157 static int sensor_set_effect(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value);
2158 static int sensor_set_whiteBalance(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value);
2159 static int sensor_deactivate(struct i2c_client *client);
2161 static struct soc_camera_ops sensor_ops =
2163 .suspend = sensor_suspend,
2164 .resume = sensor_resume,
2165 .set_bus_param = sensor_set_bus_param,
2166 .query_bus_param = sensor_query_bus_param,
2167 .controls = sensor_controls,
2168 .menus = sensor_menus,
2169 .num_controls = ARRAY_SIZE(sensor_controls),
2170 .num_menus = ARRAY_SIZE(sensor_menus),
2173 /* only one fixed colorspace per pixelcode */
2174 struct sensor_datafmt {
2175 enum v4l2_mbus_pixelcode code;
2176 enum v4l2_colorspace colorspace;
2179 /* Find a data format by a pixel code in an array */
2180 static const struct sensor_datafmt *sensor_find_datafmt(
2181 enum v4l2_mbus_pixelcode code, const struct sensor_datafmt *fmt,
2185 for (i = 0; i < n; i++)
2186 if (fmt[i].code == code)
2192 static const struct sensor_datafmt sensor_colour_fmts[] = {
2193 {V4L2_MBUS_FMT_UYVY8_2X8, V4L2_COLORSPACE_JPEG},
2194 {V4L2_MBUS_FMT_YUYV8_2X8, V4L2_COLORSPACE_JPEG}
2196 enum sensor_work_state
2198 sensor_work_ready = 0,
2203 struct i2c_client *client;
2204 struct delayed_work dwork;
2205 enum sensor_work_state state;
2208 typedef struct sensor_info_priv_s
2222 unsigned char mirror; /* HFLIP */
2223 unsigned char flip; /* VFLIP */
2230 struct reginfo *winseqe_cur_addr;
2231 struct sensor_datafmt fmt;
2232 unsigned int enable;
2233 unsigned int funmodule_state;
2234 } sensor_info_priv_t;
2238 struct sensor_parameter
2240 unsigned short int preview_maxlines;
2241 unsigned short int preview_exposure;
2242 unsigned short int preview_line_width;
2243 unsigned short int preview_gain;
2245 unsigned short int capture_framerate;
2246 unsigned short int preview_framerate;
2251 struct v4l2_subdev subdev;
2252 struct i2c_client *client;
2253 sensor_info_priv_t info_priv;
2254 struct sensor_parameter parameter;
2255 struct workqueue_struct *sensor_wq;
2256 struct sensor_work sensor_wk;
2257 struct mutex wq_lock;
2258 int model; /* V4L2_IDENT_OV* codes from v4l2-chip-ident.h */
2259 #if CONFIG_SENSOR_I2C_NOSCHED
2260 atomic_t tasklock_cnt;
2262 struct rk29camera_platform_data *sensor_io_request;
2263 struct rk29camera_gpio_res *sensor_gpio_res;
2266 static struct sensor* to_sensor(const struct i2c_client *client)
2268 return container_of(i2c_get_clientdata(client), struct sensor, subdev);
2271 static int sensor_task_lock(struct i2c_client *client, int lock)
2273 #if CONFIG_SENSOR_I2C_NOSCHED
2275 struct sensor *sensor = to_sensor(client);
2278 if (atomic_read(&sensor->tasklock_cnt) == 0) {
2279 while ((atomic_read(&client->adapter->bus_lock.count) < 1) && (cnt>0)) {
2280 SENSOR_TR("\n %s will obtain i2c in atomic, but i2c bus is locked! Wait...\n",SENSOR_NAME_STRING());
2284 if ((atomic_read(&client->adapter->bus_lock.count) < 1) && (cnt<=0)) {
2285 SENSOR_TR("\n %s obtain i2c fail in atomic!!\n",SENSOR_NAME_STRING());
2286 goto sensor_task_lock_err;
2291 atomic_add(1, &sensor->tasklock_cnt);
2293 if (atomic_read(&sensor->tasklock_cnt) > 0) {
2294 atomic_sub(1, &sensor->tasklock_cnt);
2296 if (atomic_read(&sensor->tasklock_cnt) == 0)
2301 sensor_task_lock_err:
2307 /*sensor register write */
2308 static int sensor_write(struct i2c_client *client, struct reginfo *reg_info)
2312 struct i2c_msg msg[1];
2314 switch (reg_info->reg)
2316 case SEQUENCE_WAIT_MS:
2319 mdelay(reg_info->val);
2321 msleep(reg_info->val);
2325 case SEQUENCE_WAIT_US:
2327 udelay(reg_info->val);
2330 case SEQUENCE_PROPERTY:
2336 buf[0] = reg_info->reg >> 8;
2337 buf[1] = reg_info->reg & 0xFF;
2338 if (reg_info->reg_len == WORD_LEN) {
2339 buf[2] = reg_info->val >> 8;
2340 buf[3] = reg_info->val & 0xFF;
2342 } else if (reg_info->reg_len == BYTE_LEN) {
2343 buf[2] = reg_info->val;
2346 msg->addr = client->addr;
2347 msg->flags = client->flags;
2349 msg->scl_rate = CONFIG_SENSOR_I2C_SPEED; /* ddl@rock-chips.com : 100kHz */
2350 msg->read_type = 0; /* fpga i2c:0==I2C_NORMAL : direct use number not enum for don't want include spi_fpga.h */
2353 while ((cnt-- > 0) && (err < 0)) { /* ddl@rock-chips.com : Transfer again if transent is failed */
2354 err = i2c_transfer(client->adapter, msg, 1);
2359 SENSOR_TR("\n %s write reg(0x%x, val:0x%x) failed, try to write again!\n",SENSOR_NAME_STRING(),reg_info->reg, reg_info->val);
2369 *sensor_write_Multiple_data - sensor register write with Multiple data
2371 * @reg_info: the first register address
2372 * @count: data number
2374 * Returns negative errno, else the number of messages executed.
2378 static int sensor_write_Multiple_data(struct i2c_client *client, struct reginfo *reg_info, int count)
2383 struct reginfo *tmpval = NULL;
2385 struct i2c_msg msg[1];
2388 if(count < 1 || tmpval==NULL||tmpval->reg==0x0000)
2391 memset((char*)&msg[0],0,sizeof(struct i2c_msg));
2392 buf = kmalloc((count*2+10)*sizeof(u8),GFP_KERNEL);
2394 SENSOR_TR("%s %s fail,because kmalloc failed",SENSOR_NAME_STRING(),__FUNCTION__);
2396 goto sensor_write_Multiple_data_end;
2398 memset(buf,0,sizeof(buf));
2400 switch (reg_info->reg)
2402 case SEQUENCE_WAIT_MS:
2405 mdelay(reg_info->val);
2407 msleep(reg_info->val);
2411 case SEQUENCE_WAIT_US:
2413 udelay(reg_info->val);
2417 case SEQUENCE_PROPERTY:
2424 buf[0] = tmpval->reg >> 8;
2425 buf[1] = tmpval->reg & 0xFF;
2427 if (tmpval->reg_len == WORD_LEN)
2432 buf[i] = tmpval->val >> 8;
2433 buf[i+1] = tmpval->val & 0xFF;
2438 } else if (tmpval->reg_len == BYTE_LEN) {
2442 buf[i] = tmpval->val;
2448 msg->addr = client->addr;
2449 msg->flags = client->flags;
2451 msg->scl_rate = CONFIG_SENSOR_I2C_SPEED; /* ddl@rock-chips.com : 100kHz */
2452 msg->read_type = 0; /* fpga i2c:0==I2C_NORMAL : direct use number not enum for don't want include spi_fpga.h */
2455 while ((cnt-- > 0) && (err < 0)) { /* ddl@rock-chips.com : Transfer again if transent is failed */
2456 err = i2c_transfer(client->adapter, msg, 1);
2460 SENSOR_TR("\n %s write reg(0x%x, val:0x%x) failed, try to write again!\n",SENSOR_NAME_STRING(),reg_info->reg, reg_info->val);
2466 sensor_write_Multiple_data_end:
2474 /* sensor register read */
2475 static int sensor_read(struct i2c_client *client, u16 reg, u16 *val)
2479 struct i2c_msg msg[2];
2482 buf[1] = reg & 0xFF;
2484 msg[0].addr = client->addr;
2485 msg[0].flags = client->flags;
2487 msg[0].len = sizeof(buf);
2488 msg[0].scl_rate = CONFIG_SENSOR_I2C_SPEED; /* ddl@rock-chips.com : 100kHz */
2489 msg[0].read_type = 2; /* fpga i2c:0==I2C_NO_STOP : direct use number not enum for don't want include spi_fpga.h */
2491 msg[1].addr = client->addr;
2492 msg[1].flags = client->flags|I2C_M_RD;
2495 msg[1].scl_rate = CONFIG_SENSOR_I2C_SPEED; /* ddl@rock-chips.com : 100kHz */
2496 msg[1].read_type = 2; /* fpga i2c:0==I2C_NO_STOP : direct use number not enum for don't want include spi_fpga.h */
2500 while ((cnt-- > 0) && (err < 0)) { /* ddl@rock-chips.com : Transfer again if transent is failed */
2501 err = i2c_transfer(client->adapter, msg, 2);
2507 SENSOR_TR("\n %s read reg(0x%x val:0x%x) failed, try to read again! \n",SENSOR_NAME_STRING(),reg, *val);
2515 /* write a array of registers */
2516 static int sensor_write_array(struct i2c_client *client, struct reginfo *regarray)
2523 #if CONFIG_SENSOR_I2C_RDWRCHK
2528 if (sensor_task_lock(client, 1) < 0)
2529 goto sensor_write_array_end;
2531 // SENSOR_TR("%s ..%s..\n",SENSOR_NAME_STRING(),__FUNCTION__);
2533 while (regarray[i].reg != SEQUENCE_END) {
2536 while((regarray[j].reg_len ==regarray[i].reg_len)&®array[j].reg != SEQUENCE_END)
2538 temp = regarray[j].reg - regarray[j-1].reg;
2539 if((regarray[j].reg_len==WORD_LEN && temp!=0x0002)||(regarray[j].reg_len==BYTE_LEN && temp!=0x0001))
2544 err = sensor_write_Multiple_data(client, ®array[i], num) ;
2548 SENSOR_TR("%s..write failed current reg:0x%x, Write array again !\n", SENSOR_NAME_STRING(),regarray[i].reg);
2552 SENSOR_TR("%s..write array failed!!!\n", SENSOR_NAME_STRING());
2554 goto sensor_write_array_end;
2557 #if CONFIG_SENSOR_I2C_RDWRCHK
2558 sensor_read(client, regarray[i].reg, &valchk);
2559 if (valchk != regarray[i].val)
2560 SENSOR_TR("%s Reg:0x%x write(0x%x, 0x%x) fail\n",SENSOR_NAME_STRING(), regarray[i].reg, regarray[i].val, valchk);
2566 sensor_write_array_end:
2567 sensor_task_lock(client,0);
2571 /* write sensor initial data */
2572 static int sensor_write_init_data(struct i2c_client *client, struct reginfo *regarray)
2577 #if CONFIG_SENSOR_I2C_RDWRCHK
2581 int table[167] = { /*written data numbers every time*/
2582 3,1,1,3,1,1,1,1,11,2,2,13,1,1,1,2,11,2,2,13,
2583 1,2,1,1,2,1,1,1,1,1,8,1,1,1,1,1,1,714,1,1,
2584 1,1,1,1,1,42,1,3,9,1,1,2,2,1,1,1,1,3,1,1,
2585 1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,8,2,2,2,
2586 2,2,1,1,1,1,10,10,9,6,4,2,9,2,2,2,1,1,1,1,
2587 1,1,1,1,1,1,1,1,58,1,1,1,1,1,1,1,1,1,1,1,
2588 2,2,2,2,2,2,2,2,2,3,3,2,1,1,1,1,1, 2,2,1,
2589 6,3,1,1,1,1,1,6,1,2,4,4,1,1,1,4,5,2,2,4,
2594 if (sensor_task_lock(client, 1) < 0)
2595 goto sensor_write_array_end;
2597 while (regarray[i].reg != SEQUENCE_END) {
2603 err = sensor_write_Multiple_data(client, ®array[i], num) ;
2607 SENSOR_TR("%s..write failed current reg:0x%x, Write array again !\n", SENSOR_NAME_STRING(),regarray[i].reg);
2611 SENSOR_TR("%s..write array failed!!!\n", SENSOR_NAME_STRING());
2613 goto sensor_write_array_end;
2616 #if CONFIG_SENSOR_I2C_RDWRCHK
2617 sensor_read(client, regarray[i].reg, &valchk);
2618 if (valchk != regarray[i].val)
2619 SENSOR_TR("%s Reg:0x%x write(0x%x, 0x%x) fail\n",SENSOR_NAME_STRING(), regarray[i].reg, regarray[i].val, valchk);
2624 sensor_write_array_end:
2625 sensor_task_lock(client,0);
2630 /* write a array of registers */
2631 static int sensor_write_array(struct i2c_client *client, struct reginfo *regarray)
2635 #if CONFIG_SENSOR_I2C_RDWRCHK
2639 if (sensor_task_lock(client, 1) < 0)
2640 goto sensor_write_array_end;
2642 while (regarray[i].reg != SEQUENCE_END) {
2644 err = sensor_write(client, ®array[i]);
2649 SENSOR_TR("%s..write failed current reg:0x%x, Write array again !\n", SENSOR_NAME_STRING(),regarray[i].reg);
2653 SENSOR_TR("%s..write array failed!!!\n", SENSOR_NAME_STRING());
2655 goto sensor_write_array_end;
2658 #if CONFIG_SENSOR_I2C_RDWRCHK
2659 sensor_read(client, regarray[i].reg, &valchk);
2660 if (valchk != regarray[i].val)
2661 SENSOR_TR("%s Reg:0x%x write(0x%x, 0x%x) fail\n",SENSOR_NAME_STRING(), regarray[i].reg, regarray[i].val, valchk);
2666 sensor_write_array_end:
2667 sensor_task_lock(client,0);
2671 #if CONFIG_SENSOR_I2C_RDWRCHK
2672 static int sensor_readchk_array(struct i2c_client *client, struct reginfo *regarray)
2680 while (regarray[i].reg != SEQUENCE_END)
2682 sensor_read(client, regarray[i].reg, &valchk);
2683 if (valchk != regarray[i].val)
2684 SENSOR_TR("%s Reg:0x%x read(0x%x, 0x%x) error\n",SENSOR_NAME_STRING(), regarray[i].reg, regarray[i].val, valchk);
2692 #if CONFIG_SENSOR_Focus
2693 static struct reginfo sensor_af_init0[] =
2695 { 0xC400, 0x88, BYTE_LEN, 0 }, // AFM_ALGO
2696 { 0x8419, 0x05, BYTE_LEN, 0 }, // SEQ_STATE_CFG_1_AF
2697 { 0xC400, 0x08, BYTE_LEN, 0 }, // AFM_ALGO
2699 { 0xB002, 0x0305, WORD_LEN, 0}, // AF_MODE
2700 { 0xB004, 0x0002, WORD_LEN, 0}, // AF_ALGO
2702 { 0xB008, 0x0003, WORD_LEN, 0}, // AF_ZONE_WEIGHTS_HI
2703 { 0xB00A, 0xFFFF, WORD_LEN, 0}, // AF_ZONE_WEIGHTS_HI
2704 { 0xB00C, 0xFFFF, WORD_LEN, 0}, // AF_ZONE_WEIGHTS_LO
2705 { 0xB00E, 0xFFFF, WORD_LEN, 0}, // AF_ZONE_WEIGHTS_LO
2706 {SEQUENCE_END, 0x00, 0, 0}
2708 static struct reginfo sensor_af_init1[] =
2711 { 0xC40A, 0x0028, WORD_LEN, 0 }, // AFM_POS_MIN
2712 { 0xC40C, 0x00BE, WORD_LEN, 0 }, // AFM_POS_MAX
2713 //AF_postition_settings
2714 { 0xB018, 0x00, BYTE_LEN, 0}, // AF_FS_POS_0
2715 { 0xB019, 0x20, BYTE_LEN, 0}, // AF_FS_POS_1
2716 { 0xB01A, 0x40, BYTE_LEN, 0}, // AF_FS_POS_2
2717 { 0xB01B, 0x60, BYTE_LEN, 0}, // AF_FS_POS_3
2718 { 0xB01C, 0x80, BYTE_LEN, 0}, // AF_FS_POS_4
2719 { 0xB01D, 0xA0, BYTE_LEN, 0}, // AF_FS_POS_5
2720 { 0xB01E, 0xC0, BYTE_LEN, 0}, // AF_FS_POS_6
2721 { 0xB01A, 0x38, BYTE_LEN, 0}, // AF_FS_POS_2
2722 { 0xB01B, 0x50, BYTE_LEN, 0}, // AF_FS_POS_3
2723 { 0xB01C, 0x68, BYTE_LEN, 0}, // AF_FS_POS_4
2724 { 0xB01D, 0x80, BYTE_LEN, 0}, // AF_FS_POS_5
2725 { 0xB01E, 0x98, BYTE_LEN, 0}, // AF_FS_POS_6
2726 { 0xB01F, 0xB0, BYTE_LEN, 0}, // AF_FS_POS_7
2727 { 0xB020, 0xC0, BYTE_LEN, 0}, // AF_FS_POS_8
2728 { 0xB012, 0x09, BYTE_LEN, 0}, // AF_FS_NUM_STEPS
2730 { 0xB013, 0x55, BYTE_LEN, 0}, // AF_FS_NUM_STEPS2
2731 { 0xB014, 0x06, BYTE_LEN, 0}, // AF_FS_STEP_SIZE
2732 { 0x8404, 0x05, BYTE_LEN, 0}, // SEQ_CMD
2733 //{ SEQUENCE_WAIT_MS,300, WORD_LEN, 0},
2734 { SEQUENCE_WAIT_MS,100, WORD_LEN, 0},
2735 //{ 0x3EDA, 0x6060 // DAC_LD_14_15
2736 { 0x0018, 0x2008, WORD_LEN, 0}, // STANDBY_CONTROL_AND_STATUS
2737 //{ SEQUENCE_WAIT_MS,100, WORD_LEN, 0},
2738 { SEQUENCE_WAIT_MS,30, WORD_LEN, 0},
2739 { 0x3EDA, 0x6060, WORD_LEN, 0 }, // DAC_LD_14_15
2740 {SEQUENCE_END, 0x00, 0, 0}
2744 static struct reginfo sensor_af_trigger[] =
2746 {0x098e,0xb006, WORD_LEN, 0 },
2747 {0xb006,0x01, BYTE_LEN, 0 },
2748 {SEQUENCE_END, 0x00, 0, 0}
2750 static int sensor_af_single(struct i2c_client *client)
2754 ret = sensor_write_array(client, sensor_af_trigger);
2756 SENSOR_TR("%s sensor auto focus trigger fail!!\n",SENSOR_NAME_STRING());
2758 SENSOR_DG("%s sensor auto focus trigger success!\n",SENSOR_NAME_STRING());
2759 sensor_af_single_end:
2763 static int sensor_af_const(struct i2c_client *client)
2767 sensor_af_const_end:
2771 static int sensor_af_zoneupdate(struct i2c_client *client)
2774 struct i2c_msg msg[2];
2777 {0xb0,0x08,0x00,0x03,0xff,0xff},
2778 {0xb0,0x0c,0xff,0xff,0xff,0xff},
2781 msg[0].addr = client->addr;
2782 msg[0].flags = client->flags;
2783 msg[0].buf = buf[0];
2784 msg[0].len = sizeof(buf);
2785 msg[0].scl_rate = CONFIG_SENSOR_I2C_SPEED; /* ddl@rock-chips.com : 100kHz */
2786 msg[0].read_type = 0; /* fpga i2c:0==I2C_NORMAL : direct use number not enum for don't want include spi_fpga.h */
2788 msg[1].addr = client->addr;
2789 msg[1].flags = client->flags;
2790 msg[1].buf = buf[1];
2791 msg[1].len = sizeof(buf);
2792 msg[1].scl_rate = CONFIG_SENSOR_I2C_SPEED; /* ddl@rock-chips.com : 100kHz */
2793 msg[1].read_type = 0; /* fpga i2c:0==I2C_NORMAL : direct use number not enum for don't want include spi_fpga.h */
2795 ret = i2c_transfer(client->adapter, &msg[0], 1);
2796 ret |= i2c_transfer(client->adapter, &msg[1], 1);
2800 SENSOR_TR("\n %s sensor auto focus zone set fail!!\n",SENSOR_NAME_STRING());
2803 sensor_af_zoneupdate_end:
2807 static int sensor_af_init(struct i2c_client *client)
2811 ret = sensor_write_array(client, sensor_af_init0);
2813 SENSOR_DG("%s sensor auto focus init_0 fail!!",SENSOR_NAME_STRING());
2815 SENSOR_DG("%s sensor auto focus init_0 sucess!!",SENSOR_NAME_STRING());
2816 if (sensor_af_zoneupdate(client) == 0) {
2817 ret = sensor_write_array(client, sensor_af_init1);
2819 SENSOR_DG("%s sensor auto focus init_1 fail!!",SENSOR_NAME_STRING());
2821 SENSOR_DG("%s sensor auto focus init_1 success!!",SENSOR_NAME_STRING());
2830 static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd cmd, int on)
2832 struct soc_camera_link *icl = to_soc_camera_link(icd);
2835 SENSOR_DG("%s %s cmd(%d) on(%d)\n",SENSOR_NAME_STRING(),__FUNCTION__,cmd,on);
2838 case Sensor_PowerDown:
2840 if (icl->powerdown) {
2841 ret = icl->powerdown(icd->pdev, on);
2842 if (ret == RK29_CAM_IO_SUCCESS) {
2846 icl->reset(icd->pdev);
2848 } else if (ret == RK29_CAM_EIO_REQUESTFAIL) {
2850 goto sensor_power_end;
2857 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2858 struct sensor *sensor = to_sensor(client);
2860 if (sensor->sensor_io_request && sensor->sensor_io_request->sensor_ioctrl) {
2861 sensor->sensor_io_request->sensor_ioctrl(icd->pdev,Cam_Flash, on);
2863 //flash off after 2 secs
2864 hrtimer_cancel(&(flash_off_timer.timer));
2865 hrtimer_start(&(flash_off_timer.timer),ktime_set(0, 800*1000*1000),HRTIMER_MODE_REL);
2872 SENSOR_TR("%s %s cmd(0x%x) is unknown!",SENSOR_NAME_STRING(),__FUNCTION__,cmd);
2881 static enum hrtimer_restart flash_off_func(struct hrtimer *timer){
2882 struct flash_timer *fps_timer = container_of(timer, struct flash_timer, timer);
2883 sensor_ioctrl(fps_timer->icd,Sensor_Flash,0);
2884 SENSOR_DG("%s %s !!!!!!",SENSOR_NAME_STRING(),__FUNCTION__);
2889 static int sensor_init(struct v4l2_subdev *sd, u32 val)
2891 struct i2c_client *client = v4l2_get_subdevdata(sd);
2892 struct soc_camera_device *icd = client->dev.platform_data;
2893 struct sensor *sensor = to_sensor(client);
2894 #if (ADJUST_OPTIMIZE_TIME_FALG == 0)
2895 const struct v4l2_queryctrl *qctrl;
2897 const struct sensor_datafmt *fmt;
2900 #if (SENSOR_RESET_REG != SEQUENCE_END)
2901 struct reginfo reg_info;
2904 SENSOR_DG("\n%s..%s.. \n",SENSOR_NAME_STRING(),__FUNCTION__);
2906 if (sensor_ioctrl(icd, Sensor_PowerDown, 0) < 0) {
2908 goto sensor_INIT_ERR;
2911 SENSOR_DG("\n soft reset..%s.\n",SENSOR_NAME_STRING());
2914 if (sensor_task_lock(client,1)<0)
2915 goto sensor_INIT_ERR;
2917 #if (SENSOR_RESET_REG != SEQUENCE_END)
2918 reg_info.reg = SENSOR_RESET_REG;
2919 reg_info.val = SENSOR_RESET_VAL;
2920 reg_info.reg_len = SENSOR_RESET_REG_LEN;
2921 ret = sensor_write(client, ®_info);
2923 SENSOR_TR("%s soft reset sensor failed\n",SENSOR_NAME_STRING());
2925 goto sensor_INIT_ERR;
2927 mdelay(5); //delay 5 microseconds
2930 /* check if it is an sensor sensor */
2931 #if (SENSOR_ID_REG != SEQUENCE_END)
2932 ret = sensor_read(client, SENSOR_ID_REG, &pid);
2934 SENSOR_TR("read chip id failed\n");
2936 goto sensor_INIT_ERR;
2938 SENSOR_DG("\n %s pid = 0x%x \n", SENSOR_NAME_STRING(), pid);
2943 if (pid == SENSOR_ID) {
2944 sensor->model = SENSOR_V4L2_IDENT;
2946 SENSOR_TR("error: %s mismatched pid = 0x%x\n", SENSOR_NAME_STRING(), pid);
2948 goto sensor_INIT_ERR;
2951 SENSOR_DG("\n sensor_init_data..%s.\n",SENSOR_NAME_STRING());
2953 ret =sensor_write_init_data(client, sensor_init_data);
2955 SENSOR_TR("error: %s initial failed\n",SENSOR_NAME_STRING());
2956 goto sensor_INIT_ERR;
2958 sensor_task_lock(client,0);
2959 sensor->info_priv.preview_w = SENSOR_INIT_WIDTH;
2960 sensor->info_priv.preview_h = SENSOR_INIT_HEIGHT;
2961 sensor->info_priv.capture_w = SENSOR_MAX_WIDTH;
2962 sensor->info_priv.capture_h = SENSOR_MAX_HEIGHT;
2963 sensor->info_priv.winseqe_cur_addr = SENSOR_INIT_WINSEQADR;
2964 fmt = sensor_find_datafmt(SENSOR_INIT_PIXFMT,sensor_colour_fmts, ARRAY_SIZE(sensor_colour_fmts));
2966 SENSOR_TR("error: %s initial array colour fmts is not support!!",SENSOR_NAME_STRING());
2968 goto sensor_INIT_ERR;
2970 sensor->info_priv.fmt = *fmt;
2972 /* sensor sensor information for initialization */
2973 #if ADJUST_OPTIMIZE_TIME_FALG
2974 SENSOR_DG("\n optimize code..%s.\n",SENSOR_NAME_STRING());
2975 #if CONFIG_SENSOR_WhiteBalance
2976 sensor->info_priv.whiteBalance = 0;
2978 #if CONFIG_SENSOR_Brightness
2979 sensor->info_priv.brightness = 0;
2981 #if CONFIG_SENSOR_Effect
2982 sensor->info_priv.effect = 0;
2984 #if CONFIG_SENSOR_Exposure
2985 sensor->info_priv.exposure = 0;
2987 #if CONFIG_SENSOR_Saturation
2988 sensor->info_priv.saturation = 0;
2990 #if CONFIG_SENSOR_Contrast
2991 sensor->info_priv.contrast = 0;
2993 #if CONFIG_SENSOR_Mirror
2994 sensor->info_priv.mirror = 1;
2996 #if CONFIG_SENSOR_Flip
2997 sensor->info_priv.flip = 1;
3000 #if CONFIG_SENSOR_Scene
3001 sensor->info_priv.scene = 0;
3004 #if CONFIG_SENSOR_DigitalZoom
3005 sensor->info_priv.digitalzoom = 0;
3007 #if CONFIG_SENSOR_Focus
3008 sensor->info_priv.focus = 125 ;
3009 if (sensor_af_init(client) < 0) {
3010 sensor->info_priv.funmodule_state &= ~SENSOR_AF_IS_OK;
3011 SENSOR_TR("%s auto focus module init is fail!\n",SENSOR_NAME_STRING());
3013 sensor->info_priv.funmodule_state |= SENSOR_AF_IS_OK;
3014 SENSOR_DG("%s auto focus module init is success!\n",SENSOR_NAME_STRING());
3017 #if CONFIG_SENSOR_Flash
3018 sensor->info_priv.flash = 0 ;
3022 SENSOR_DG("\n origin code..%s.\n",SENSOR_NAME_STRING());
3024 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE);
3026 sensor->info_priv.whiteBalance = qctrl->default_value;
3028 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_BRIGHTNESS);
3030 sensor->info_priv.brightness = qctrl->default_value;
3032 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT);
3034 sensor->info_priv.effect = qctrl->default_value;
3036 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EXPOSURE);
3038 sensor->info_priv.exposure = qctrl->default_value;
3040 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_SATURATION);
3042 sensor->info_priv.saturation = qctrl->default_value;
3044 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_CONTRAST);
3046 sensor->info_priv.contrast = qctrl->default_value;
3048 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_HFLIP);
3050 sensor->info_priv.mirror = qctrl->default_value;
3052 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_VFLIP);
3054 sensor->info_priv.flip = qctrl->default_value;
3056 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_SCENE);
3058 sensor->info_priv.scene = qctrl->default_value;
3060 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_ZOOM_ABSOLUTE);
3062 sensor->info_priv.digitalzoom = qctrl->default_value;
3064 /* ddl@rock-chips.com : if sensor support auto focus and flash, programer must run focus and flash code */
3065 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FOCUS_ABSOLUTE);
3067 sensor->info_priv.focus = qctrl->default_value;
3069 #if CONFIG_SENSOR_Focus
3070 if (sensor_af_init(client) < 0) {
3071 sensor->info_priv.funmodule_state &= ~SENSOR_AF_IS_OK;
3072 SENSOR_TR("%s auto focus module init is fail!\n",SENSOR_NAME_STRING());
3074 sensor->info_priv.funmodule_state |= SENSOR_AF_IS_OK;
3075 SENSOR_DG("%s auto focus module init is success!\n",SENSOR_NAME_STRING());
3078 #if CONFIG_SENSOR_Flash
3079 qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH);
3081 sensor->info_priv.flash = qctrl->default_value;
3083 hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL);
3084 flash_off_timer.icd = icd;
3085 flash_off_timer.timer.function = flash_off_func;
3088 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);
3089 sensor->info_priv.funmodule_state |= SENSOR_INIT_IS_OK;
3092 sensor->info_priv.funmodule_state &= ~SENSOR_INIT_IS_OK;
3093 sensor_task_lock(client,0);
3094 sensor_deactivate(client);
3097 static int sensor_deactivate(struct i2c_client *client)
3099 struct soc_camera_device *icd = client->dev.platform_data;
3100 struct sensor *sensor = to_sensor(client);
3102 SENSOR_DG("\n%s..%s.. Enter\n",SENSOR_NAME_STRING(),__FUNCTION__);
3104 /* ddl@rock-chips.com : all sensor output pin must change to input for other sensor */
3107 sensor_ioctrl(icd, Sensor_PowerDown, 1);
3110 /* ddl@rock-chips.com : sensor config init width , because next open sensor quickly(soc_camera_open -> Try to configure with default parameters) */
3111 icd->user_width = SENSOR_INIT_WIDTH;
3112 icd->user_height = SENSOR_INIT_HEIGHT;
3113 sensor->info_priv.funmodule_state &= ~SENSOR_INIT_IS_OK;
3117 static struct reginfo sensor_power_down_sequence[]=
3121 static int sensor_suspend(struct soc_camera_device *icd, pm_message_t pm_msg)
3124 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
3126 if (pm_msg.event == PM_EVENT_SUSPEND) {
3127 SENSOR_DG("\n %s Enter Suspend..pm_msg.event=%d \n", SENSOR_NAME_STRING(),pm_msg.event);
3128 ret = sensor_write_array(client, sensor_power_down_sequence) ;
3130 SENSOR_TR("\n %s..%s WriteReg Fail.. \n", SENSOR_NAME_STRING(),__FUNCTION__);
3133 ret = sensor_ioctrl(icd, Sensor_PowerDown, 1);
3135 SENSOR_TR("\n %s suspend fail for turn on power!\n", SENSOR_NAME_STRING());
3140 SENSOR_TR("\n %s cann't suppout Suspend..\n",SENSOR_NAME_STRING());
3147 static int sensor_resume(struct soc_camera_device *icd)
3151 ret = sensor_ioctrl(icd, Sensor_PowerDown, 0);
3153 SENSOR_TR("\n %s resume fail for turn on power!\n", SENSOR_NAME_STRING());
3157 SENSOR_DG("\n %s Enter Resume.. \n", SENSOR_NAME_STRING());
3161 static int sensor_set_bus_param(struct soc_camera_device *icd,
3162 unsigned long flags)
3168 static unsigned long sensor_query_bus_param(struct soc_camera_device *icd)
3170 struct soc_camera_link *icl = to_soc_camera_link(icd);
3171 unsigned long flags = SENSOR_BUS_PARAM;
3173 return soc_camera_apply_sensor_flags(icl, flags);
3176 static int sensor_g_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
3178 struct i2c_client *client = v4l2_get_subdevdata(sd);
3179 struct soc_camera_device *icd = client->dev.platform_data;
3180 struct sensor *sensor = to_sensor(client);
3182 mf->width = icd->user_width;
3183 mf->height = icd->user_height;
3184 mf->code = sensor->info_priv.fmt.code;
3185 mf->colorspace = sensor->info_priv.fmt.colorspace;
3186 mf->field = V4L2_FIELD_NONE;
3190 static bool sensor_fmt_capturechk(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
3194 if ((mf->width == 1024) && (mf->height == 768)) {
3196 } else if ((mf->width == 1280) && (mf->height == 1024)) {
3198 } else if ((mf->width == 1600) && (mf->height == 1200)) {
3200 } else if ((mf->width == 2048) && (mf->height == 1536)) {
3202 } else if ((mf->width == 2592) && (mf->height == 1944)) {
3207 SENSOR_DG("%s %dx%d is capture format\n", __FUNCTION__, mf->width, mf->height);
3211 static bool sensor_fmt_videochk(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
3215 if ((mf->width == 1280) && (mf->height == 720)) {
3217 } else if ((mf->width == 1920) && (mf->height == 1080)) {
3222 SENSOR_DG("%s %dx%d is video format\n", __FUNCTION__, mf->width, mf->height);
3225 static struct reginfo* sensor_fmt_catch(int set_w, int set_h, int *ret_w, int *ret_h)
3227 struct reginfo *winseqe_set_addr = NULL;
3229 if (set_w*240 == set_h*320) {
3230 if (((set_w >= 320) && (set_h >= 240)) && (sensor_qvga[0].reg!=SEQUENCE_END)) {
3231 winseqe_set_addr = sensor_qvga;
3236 #if ADJUST_FOR_VGA_FALG
3237 // to forbid preview err
3238 if (((set_w >= 576) && (set_h >= 432)) && (sensor_vga[0].reg!=SEQUENCE_END)) {
3239 winseqe_set_addr = sensor_vga;
3244 if (((set_w >= 640) && (set_h >= 480)) && (sensor_vga[0].reg!=SEQUENCE_END)) {
3245 winseqe_set_addr = sensor_vga;
3252 if (((set_w >= 800) && (set_h >= 600)) && (sensor_svga[0].reg!=SEQUENCE_END)) {
3253 winseqe_set_addr = sensor_svga;
3258 if (((set_w >= 1024) && (set_h >= 768)) && (sensor_xga[0].reg!=SEQUENCE_END)) {
3259 winseqe_set_addr = sensor_xga;
3264 if (((set_w >= 1280) && (set_h >= 1024)) && (sensor_sxga[0].reg!=SEQUENCE_END)) {
3265 winseqe_set_addr = sensor_sxga;
3270 if (((set_w >= 1600) && (set_h >= 1200)) && (sensor_uxga[0].reg!=SEQUENCE_END)) {
3271 winseqe_set_addr = sensor_uxga;
3276 if (((set_w >= 2048) && (set_h >= 1536)) && (sensor_qxga[0].reg!=SEQUENCE_END)) {
3277 winseqe_set_addr = sensor_qxga;
3282 if (((set_w >= 2592) && (set_h >= 1944)) && (sensor_qsxga[0].reg!=SEQUENCE_END)) {
3283 winseqe_set_addr = sensor_qsxga;
3288 if (winseqe_set_addr == NULL) {
3289 if (((set_w <= 176) && (set_h <= 144)) && (sensor_qcif[0].reg!=SEQUENCE_END)) {
3290 winseqe_set_addr = sensor_qcif;
3293 } else if (((set_w <= 352) && (set_h<= 288)) && (sensor_cif[0].reg!=SEQUENCE_END)) {
3294 winseqe_set_addr = sensor_cif;
3299 if (((set_w <= 1280) && (set_h <= 720)) && (sensor_720p[0].reg!=SEQUENCE_END)) {
3300 winseqe_set_addr = sensor_720p;
3303 } else if (((set_w <= 1920) && (set_h <= 1080)) && (sensor_1080p[0].reg!=SEQUENCE_END)) {
3304 winseqe_set_addr = sensor_1080p;
3310 } else if (set_w*288 == set_h*352) {
3311 if (((set_w >= 176) && (set_h >= 144)) && (sensor_qcif[0].reg!=SEQUENCE_END)) {
3312 winseqe_set_addr = sensor_qcif;
3315 } else if (((set_w >= 352) && (set_h >= 288)) && (sensor_cif[0].reg!=SEQUENCE_END)) {
3316 winseqe_set_addr = sensor_cif;
3321 if (winseqe_set_addr == NULL) {
3322 if (((set_w <= 320) && (set_h <= 240)) && (sensor_qvga[0].reg!=SEQUENCE_END)) {
3323 winseqe_set_addr = sensor_qvga;
3326 } else if (((set_w <= 640) && (set_h <= 480)) && (sensor_vga[0].reg!=SEQUENCE_END)) {
3327 winseqe_set_addr = sensor_vga;
3330 } else if (((set_w <= 800) && (set_h <= 600)) && (sensor_svga[0].reg!=SEQUENCE_END)) {
3331 winseqe_set_addr = sensor_svga;
3334 } else if (((set_w <= 1024) && (set_h <= 768)) && (sensor_xga[0].reg!=SEQUENCE_END)) {
3335 winseqe_set_addr = sensor_xga;
3338 } else if (((set_w <= 1280) && (set_h <= 1024)) && (sensor_sxga[0].reg!=SEQUENCE_END)) {
3339 winseqe_set_addr = sensor_sxga;
3342 } else if (((set_w <= 1600) && (set_h <= 1200)) && (sensor_uxga[0].reg!=SEQUENCE_END)) {
3343 winseqe_set_addr = sensor_uxga;
3346 } else if (((set_w <= 2048) && (set_h <= 1536)) && (sensor_qxga[0].reg!=SEQUENCE_END)) {
3347 winseqe_set_addr = sensor_qxga;
3350 } else if (((set_w <= 2592) && (set_h <= 1944)) && (sensor_qsxga[0].reg!=SEQUENCE_END)) {
3351 winseqe_set_addr = sensor_qsxga;
3357 if (((set_w <= 1280) && (set_h <= 720)) && (sensor_720p[0].reg!=SEQUENCE_END)) {
3358 winseqe_set_addr = sensor_720p;
3361 } else if (((set_w <= 1920) && (set_h <= 1080)) && (sensor_1080p[0].reg!=SEQUENCE_END)) {
3362 winseqe_set_addr = sensor_1080p;
3367 } else if (set_w*720 == set_h*1280) {
3368 if (((set_w >= 1280) && (set_h >= 720)) && (sensor_720p[0].reg!=SEQUENCE_END)) {
3369 winseqe_set_addr = sensor_720p;
3372 } else if (((set_w >= 1920) && (set_h >= 1080)) && (sensor_1080p[0].reg!=SEQUENCE_END)) {
3373 winseqe_set_addr = sensor_1080p;
3378 if (winseqe_set_addr == NULL) {
3380 if (((set_w <= 176) && (set_h <= 144)) && (sensor_qcif[0].reg!=SEQUENCE_END)) {
3381 winseqe_set_addr = sensor_qcif;
3384 } else if (((set_w <= 352) && (set_h<= 288)) && (sensor_cif[0].reg!=SEQUENCE_END)) {
3385 winseqe_set_addr = sensor_cif;
3390 if (((set_w <= 320) && (set_h <= 240)) && (sensor_qvga[0].reg!=SEQUENCE_END)) {
3391 winseqe_set_addr = sensor_qvga;
3394 } else if (((set_w <= 640) && (set_h <= 480)) && (sensor_vga[0].reg!=SEQUENCE_END)) {
3395 winseqe_set_addr = sensor_vga;
3398 } else if (((set_w <= 800) && (set_h <= 600)) && (sensor_svga[0].reg!=SEQUENCE_END)) {
3399 winseqe_set_addr = sensor_svga;
3402 } else if (((set_w <= 1024) && (set_h <= 768)) && (sensor_xga[0].reg!=SEQUENCE_END)) {
3403 winseqe_set_addr = sensor_xga;
3406 } else if (((set_w <= 1280) && (set_h <= 1024)) && (sensor_sxga[0].reg!=SEQUENCE_END)) {
3407 winseqe_set_addr = sensor_sxga;
3410 } else if (((set_w <= 1600) && (set_h <= 1200)) && (sensor_uxga[0].reg!=SEQUENCE_END)) {
3411 winseqe_set_addr = sensor_uxga;
3414 } else if (((set_w <= 2048) && (set_h <= 1536)) && (sensor_qxga[0].reg!=SEQUENCE_END)) {
3415 winseqe_set_addr = sensor_qxga;
3418 } else if (((set_w <= 2592) && (set_h <= 1944)) && (sensor_qsxga[0].reg!=SEQUENCE_END)) {
3419 winseqe_set_addr = sensor_qsxga;
3425 if (((set_w <= 176) && (set_h <= 144)) && (sensor_qcif[0].reg!=SEQUENCE_END)) {
3426 winseqe_set_addr = sensor_qcif;
3429 } else if (((set_w <= 320) && (set_h <= 240)) && (sensor_qvga[0].reg!=SEQUENCE_END)) {
3430 winseqe_set_addr = sensor_qvga;
3433 } else if (((set_w <= 352) && (set_h<= 288)) && (sensor_cif[0].reg!=SEQUENCE_END)) {
3434 winseqe_set_addr = sensor_cif;
3437 } else if (((set_w <= 640) && (set_h <= 480)) && (sensor_vga[0].reg!=SEQUENCE_END)) {
3438 winseqe_set_addr = sensor_vga;
3441 } else if (((set_w <= 800) && (set_h <= 600)) && (sensor_svga[0].reg!=SEQUENCE_END)) {
3442 winseqe_set_addr = sensor_svga;
3445 } else if (((set_w <= 1024) && (set_h <= 768)) && (sensor_xga[0].reg!=SEQUENCE_END)) {
3446 winseqe_set_addr = sensor_xga;
3449 } else if (((set_w <= 1280) && (set_h <= 720)) && (sensor_720p[0].reg!=SEQUENCE_END)) {
3450 winseqe_set_addr = sensor_720p;
3453 } else if (((set_w <= 1280) && (set_h <= 1024)) && (sensor_sxga[0].reg!=SEQUENCE_END)) {
3454 winseqe_set_addr = sensor_sxga;
3457 } else if (((set_w <= 1600) && (set_h <= 1200)) && (sensor_uxga[0].reg!=SEQUENCE_END)) {
3458 winseqe_set_addr = sensor_uxga;
3461 } else if (((set_w <= 1920) && (set_h <= 1080)) && (sensor_1080p[0].reg!=SEQUENCE_END)) {
3462 winseqe_set_addr = sensor_1080p;
3465 } else if (((set_w <= 2048) && (set_h <= 1536)) && (sensor_qxga[0].reg!=SEQUENCE_END)) {
3466 winseqe_set_addr = sensor_qxga;
3469 } else if (((set_w <= 2592) && (set_h <= 1944)) && (sensor_qsxga[0].reg!=SEQUENCE_END)) {
3470 winseqe_set_addr = sensor_qsxga;
3476 return winseqe_set_addr;
3479 /*modify image with resolution 2592*1944;solve bug that the first 32 pixel data*/
3480 /*in the first line have misplace with the last 32 pixel data in the last line*/
3481 static int sensor_cb(void *arg)
3483 void __iomem *vbpmem;
3484 struct videobuf_buffer *buffer;
3485 char *imagey_addr =NULL;
3486 char *imageuv_addr = NULL;
3487 char *tempaddr = NULL;
3490 buffer = (struct videobuf_buffer*)arg;
3491 if(buffer->width!=SENSOR_MAX_WIDTH||buffer->height!=SENSOR_MAX_HEIGHT||buffer==NULL)
3494 if (buffer->bsize< YUV420_BUFFER_MAX_SIZE) //yuv420 format size
3498 vbpmem = ioremap(buffer->boff,buffer->bsize);
3499 if(vbpmem == NULL) {
3500 SENSOR_DG("\n%s..%s..ioremap fail\n",__FUNCTION__,SENSOR_NAME_STRING());
3504 imagey_addr = (char*)vbpmem; // y data to be dealed with
3505 imageuv_addr = imagey_addr+buffer->width*buffer->height;
3507 tempaddr = imageuv_addr - 32;
3508 memcpy(tempaddr,imagey_addr,32);
3510 tempaddr = imagey_addr+32;
3511 memcpy(imagey_addr,tempaddr,32);
3513 //uv data to be dealed with
3514 tempsize = YUV420_BUFFER_MAX_SIZE-32;
3515 tempaddr = imagey_addr+tempsize;
3516 memcpy(tempaddr,imageuv_addr,32);
3518 tempaddr = imageuv_addr+32;
3519 memcpy(imageuv_addr,tempaddr,32);
3524 static int sensor_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
3526 struct i2c_client *client = v4l2_get_subdevdata(sd);
3527 struct soc_camera_device *icd = client->dev.platform_data;
3528 struct sensor *sensor = to_sensor(client);
3529 const struct sensor_datafmt *fmt;
3530 struct reginfo *winseqe_set_addr=NULL;
3531 int ret = 0, set_w,set_h,cnt;
3534 u16 targetbrightness,realbrightness;
3536 SENSOR_DG("\n%s..%s.. \n",__FUNCTION__,SENSOR_NAME_STRING());
3538 fmt = sensor_find_datafmt(mf->code, sensor_colour_fmts,
3539 ARRAY_SIZE(sensor_colour_fmts));
3542 goto sensor_s_fmt_end;
3545 if (sensor->info_priv.fmt.code != mf->code) {
3548 case V4L2_MBUS_FMT_YUYV8_2X8:
3550 winseqe_set_addr = sensor_ClrFmt_YUYV;
3553 case V4L2_MBUS_FMT_UYVY8_2X8:
3555 winseqe_set_addr = sensor_ClrFmt_UYVY;
3561 if (winseqe_set_addr != NULL) {
3562 sensor_write_array(client, winseqe_set_addr);
3563 sensor->info_priv.fmt.code = mf->code;
3564 sensor->info_priv.fmt.colorspace= mf->colorspace;
3565 SENSOR_DG("%s v4l2_mbus_code:%d set success!\n", SENSOR_NAME_STRING(),mf->code);
3567 SENSOR_TR("%s v4l2_mbus_code:%d is invalidate!\n", SENSOR_NAME_STRING(),mf->code);
3574 winseqe_set_addr = sensor_fmt_catch(set_w, set_h, &set_w, &set_h);
3576 if ((winseqe_set_addr != sensor->info_priv.winseqe_cur_addr) && winseqe_set_addr)
3578 /*solve bug that video set is ineffective */
3579 /*set five times to make sure sensor_720p set go into effect*/
3580 if(winseqe_set_addr==sensor_720p)
3590 ret |= sensor_write_array(client, winseqe_set_addr);
3592 SENSOR_TR("%s set format capability failed\n", SENSOR_NAME_STRING());
3593 goto sensor_s_fmt_end;
3597 sensor->info_priv.winseqe_cur_addr = winseqe_set_addr;
3598 if (winseqe_set_addr==sensor_qxga ||winseqe_set_addr==sensor_qsxga||winseqe_set_addr==sensor_uxga ||winseqe_set_addr==sensor_xga)
3600 SENSOR_DG("\n%s..%s..Capture icd->width = %d.. icd->height %d\n",SENSOR_NAME_STRING(),__FUNCTION__,set_w,set_h);
3602 SENSOR_DG("\n%s..%s..Video icd->width = %d.. icd->height %d\n",SENSOR_NAME_STRING(),__FUNCTION__,set_w,set_h);
3603 sensor->info_priv.preview_w = mf->width;
3604 sensor->info_priv.preview_h = mf->height;
3608 if (winseqe_set_addr && (winseqe_set_addr==sensor_qxga ||winseqe_set_addr==sensor_qsxga||winseqe_set_addr==sensor_uxga ||winseqe_set_addr==sensor_xga))
3610 ret |= sensor_write_array(client, sensor_Preview2Capture);
3612 SENSOR_TR("%s Preview 2 Capture failed\n", SENSOR_NAME_STRING());
3613 goto sensor_s_fmt_end;
3616 /*check state of register 0x8405 to make sure set is successful*/
3617 /*set sensor_Preview2Capture more times to make sure set go into effect */
3623 ret =sensor_read(client,0x8405, &seq_state);
3625 goto sensor_s_fmt_end;
3631 ret |= sensor_write_array(client, sensor_Preview2Capture);
3632 if (ret != 0||time >2) {
3633 SENSOR_TR("%s Preview 2 Capture failed\n", SENSOR_NAME_STRING());
3634 goto sensor_s_fmt_end;
3636 SENSOR_DG("mt9p111 Preview 2 Capture again\n");
3638 SENSOR_DG("mt9p111 Preview 2 Capture count = %d;seq_state = 0x%x\n",cnt,seq_state);
3639 } while((seq_state != 0x07) && (time < 4));
3641 SENSOR_TR("%s Preview 2 Capture successs\n", SENSOR_NAME_STRING());
3643 #if CONFIG_SENSOR_Flash
3644 /*The 0xA409 is AE target register address.*/
3645 /*The 0xB804 is currently total brightness Y value of sensor.*/
3646 targetbrightness = 0;
3648 if((sensor->info_priv.flash == 1) || (sensor->info_priv.flash == 2))
3650 if(sensor->info_priv.flash == 1)
3652 ret =sensor_read(client,0xA409, &targetbrightness);
3654 SENSOR_DG("%s ..%s..get targetbrightness fail\n", SENSOR_NAME_STRING(),__FUNCTION__);
3656 ret =sensor_read(client, 0xB804, &realbrightness);
3658 SENSOR_DG("%s ..%s..get realbrightness fail\n", SENSOR_NAME_STRING(),__FUNCTION__);
3661 if((realbrightness < targetbrightness)|| (sensor->info_priv.flash == 2))
3663 sensor_ioctrl(icd, Sensor_Flash, Flash_On);
3664 SENSOR_DG("%s flash on,realbrightness=%d,targetbrightness=%d\n", SENSOR_NAME_STRING(),realbrightness,targetbrightness);
3666 SENSOR_DG("%s not need to flash in capture!\n", SENSOR_NAME_STRING());
3670 sensor->info_priv.capture_w = set_w;
3671 sensor->info_priv.capture_h = set_h;
3672 sensor->info_priv.snap2preview = true;
3673 } else if (sensor->info_priv.snap2preview == true) {
3674 if (winseqe_set_addr || ((sensor->info_priv.preview_w == mf->width) && (sensor->info_priv.preview_h == mf->height))) {
3675 ret |= sensor_write_array(client, sensor_Capture2Preview);
3677 SENSOR_TR("%s Capture 2 Preview success\n", SENSOR_NAME_STRING());
3678 goto sensor_s_fmt_end;
3682 do{ //check state of register 0x8405 to make sure set is successful
3685 ret =sensor_read(client,0x8405, &seq_state);
3687 goto sensor_s_fmt_end;
3688 SENSOR_DG("mt9p111 Capture 2 Preview seq_state = 0x%x\n",seq_state);
3689 } while((seq_state != 0x03) && (cnt < 20));
3691 SENSOR_TR("%s Capture 2 Preview success\n", SENSOR_NAME_STRING());
3693 #if CONFIG_SENSOR_Flash
3694 if ((sensor->info_priv.flash == 1) || (sensor->info_priv.flash == 2)) {
3695 sensor_ioctrl(icd, Sensor_Flash, Flash_Off);
3696 SENSOR_DG("%s flash off in preivew!\n", SENSOR_NAME_STRING());
3699 sensor->info_priv.preview_w = mf->width;
3700 sensor->info_priv.preview_h = mf->height;
3701 sensor->info_priv.snap2preview = false;
3703 SENSOR_TR("\n %s..%s Format is Invalidate. pix->width = %d.. pix->height = %d\n",SENSOR_NAME_STRING(),__FUNCTION__,mf->width,mf->height);
3713 static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
3715 struct i2c_client *client = v4l2_get_subdevdata(sd);
3716 struct sensor *sensor = to_sensor(client);
3717 const struct sensor_datafmt *fmt;
3720 fmt = sensor_find_datafmt(mf->code, sensor_colour_fmts,
3721 ARRAY_SIZE(sensor_colour_fmts));
3723 fmt = &sensor->info_priv.fmt;
3724 mf->code = fmt->code;
3727 if (mf->height > SENSOR_MAX_HEIGHT)
3728 mf->height = SENSOR_MAX_HEIGHT;
3729 else if (mf->height < SENSOR_MIN_HEIGHT)
3730 mf->height = SENSOR_MIN_HEIGHT;
3732 if (mf->width > SENSOR_MAX_WIDTH)
3733 mf->width = SENSOR_MAX_WIDTH;
3734 else if (mf->width < SENSOR_MIN_WIDTH)
3735 mf->width = SENSOR_MIN_WIDTH;
3736 if (sensor_fmt_catch(mf->width, mf->height, &mf->width, &mf->height) == NULL) {
3740 mf->colorspace = fmt->colorspace;
3744 static int sensor_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *id)
3746 struct i2c_client *client = v4l2_get_subdevdata(sd);
3748 if (id->match.type != V4L2_CHIP_MATCH_I2C_ADDR)
3751 if (id->match.addr != client->addr)
3754 id->ident = SENSOR_V4L2_IDENT; /* ddl@rock-chips.com : Return OV2655 identifier */
3759 #if CONFIG_SENSOR_Brightness
3760 static int sensor_set_brightness(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
3762 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
3764 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
3766 if (sensor_BrightnessSeqe[value - qctrl->minimum] != NULL)
3768 if (sensor_write_array(client, sensor_BrightnessSeqe[value - qctrl->minimum]) != 0)
3770 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
3773 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
3777 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
3781 #if CONFIG_SENSOR_Effect
3782 static int sensor_set_effect(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
3786 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
3788 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
3790 if (sensor_EffectSeqe[value - qctrl->minimum] != NULL)
3792 /*set five times to make sure the set go into effect*/
3793 /*solve bug for setting invalidate during changing from preview to video*/
3797 ret |=sensor_write_array(client, sensor_EffectSeqe[value - qctrl->minimum]);
3800 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
3805 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
3809 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
3813 #if CONFIG_SENSOR_Exposure
3814 static int sensor_set_exposure(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
3816 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
3818 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
3820 if (sensor_ExposureSeqe[value - qctrl->minimum] != NULL)
3822 if (sensor_write_array(client, sensor_ExposureSeqe[value - qctrl->minimum]) != 0)
3824 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
3827 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
3831 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
3835 #if CONFIG_SENSOR_Saturation
3836 static int sensor_set_saturation(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
3838 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
3840 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
3842 if (sensor_SaturationSeqe[value - qctrl->minimum] != NULL)
3844 if (sensor_write_array(client, sensor_SaturationSeqe[value - qctrl->minimum]) != 0)
3846 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
3849 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
3853 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
3857 #if CONFIG_SENSOR_Contrast
3858 static int sensor_set_contrast(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
3860 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
3862 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
3864 if (sensor_ContrastSeqe[value - qctrl->minimum] != NULL)
3866 if (sensor_write_array(client, sensor_ContrastSeqe[value - qctrl->minimum]) != 0)
3868 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
3871 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
3875 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
3879 #if CONFIG_SENSOR_Mirror
3880 static int sensor_set_mirror(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
3882 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
3884 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
3886 if (sensor_MirrorSeqe[value - qctrl->minimum] != NULL)
3888 if (sensor_write_array(client, sensor_MirrorSeqe[value - qctrl->minimum]) != 0)
3890 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
3893 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
3897 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
3901 #if CONFIG_SENSOR_Flip
3902 static int sensor_set_flip(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
3904 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
3906 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
3908 if (sensor_FlipSeqe[value - qctrl->minimum] != NULL)
3910 if (sensor_write_array(client, sensor_FlipSeqe[value - qctrl->minimum]) != 0)
3912 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
3915 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
3919 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
3923 #if CONFIG_SENSOR_Scene
3924 static int sensor_set_scene(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
3926 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
3928 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
3930 if (sensor_SceneSeqe[value - qctrl->minimum] != NULL)
3932 if (sensor_write_array(client, sensor_SceneSeqe[value - qctrl->minimum]) != 0)
3934 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
3937 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
3941 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
3945 #if CONFIG_SENSOR_WhiteBalance
3946 static int sensor_set_whiteBalance(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
3948 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
3950 if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
3952 if (sensor_WhiteBalanceSeqe[value - qctrl->minimum] != NULL)
3954 if (sensor_write_array(client, sensor_WhiteBalanceSeqe[value - qctrl->minimum]) != 0)
3956 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
3959 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
3963 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
3967 #if CONFIG_SENSOR_DigitalZoom
3968 static int sensor_set_digitalzoom(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
3970 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
3971 struct sensor *sensor = to_sensor(client);
3972 const struct v4l2_queryctrl *qctrl_info;
3973 int digitalzoom_cur, digitalzoom_total;
3975 qctrl_info = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_ZOOM_ABSOLUTE);
3979 digitalzoom_cur = sensor->info_priv.digitalzoom;
3980 digitalzoom_total = qctrl_info->maximum;
3982 if ((value > 0) && (digitalzoom_cur >= digitalzoom_total))
3984 SENSOR_TR("%s digitalzoom is maximum - %x\n", SENSOR_NAME_STRING(), digitalzoom_cur);
3988 if ((value < 0) && (digitalzoom_cur <= qctrl_info->minimum))
3990 SENSOR_TR("%s digitalzoom is minimum - %x\n", SENSOR_NAME_STRING(), digitalzoom_cur);
3994 if ((value > 0) && ((digitalzoom_cur + value) > digitalzoom_total))
3996 value = digitalzoom_total - digitalzoom_cur;
3999 if ((value < 0) && ((digitalzoom_cur + value) < 0))
4001 value = 0 - digitalzoom_cur;
4004 digitalzoom_cur += value;
4006 if (sensor_ZoomSeqe[digitalzoom_cur] != NULL)
4008 if (sensor_write_array(client, sensor_ZoomSeqe[digitalzoom_cur]) != 0)
4010 SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
4013 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
4020 #if CONFIG_SENSOR_Flash
4021 static int sensor_set_flash(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
4023 if ((value >= qctrl->minimum) && (value <= qctrl->maximum)) {
4024 if (value == 3) { /* ddl@rock-chips.com: torch */
4025 sensor_ioctrl(icd, Sensor_Flash, Flash_Torch); /* Flash On */
4027 sensor_ioctrl(icd, Sensor_Flash, Flash_Off);
4029 SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
4033 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
4037 #if CONFIG_SENSOR_Focus
4038 static int sensor_set_focus_absolute(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
4040 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
4041 struct sensor *sensor = to_sensor(client);
4042 const struct v4l2_queryctrl *qctrl_info;
4045 qctrl_info = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FOCUS_ABSOLUTE);
4049 if ((sensor->info_priv.funmodule_state & SENSOR_AF_IS_OK) && (sensor->info_priv.affm_reinit == 0)) {
4050 if ((value >= qctrl_info->minimum) && (value <= qctrl_info->maximum)) {
4052 SENSOR_DG("%s..%s : %d ret:0x%x\n",SENSOR_NAME_STRING(),__FUNCTION__, value,ret);
4055 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
4059 SENSOR_TR("\n %s..%s AF module state(0x%x, 0x%x) is error!\n",SENSOR_NAME_STRING(),__FUNCTION__,
4060 sensor->info_priv.funmodule_state,sensor->info_priv.affm_reinit);
4063 sensor_set_focus_absolute_end:
4066 static int sensor_set_focus_relative(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
4068 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
4069 struct sensor *sensor = to_sensor(client);
4070 const struct v4l2_queryctrl *qctrl_info;
4073 qctrl_info = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FOCUS_RELATIVE);
4077 if ((sensor->info_priv.funmodule_state & SENSOR_AF_IS_OK) && (sensor->info_priv.affm_reinit == 0)) {
4078 if ((value >= qctrl_info->minimum) && (value <= qctrl_info->maximum)) {
4080 SENSOR_DG("%s..%s : %d ret:0x%x\n",SENSOR_NAME_STRING(),__FUNCTION__, value,ret);
4083 SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
4087 SENSOR_TR("\n %s..%s AF module state(0x%x, 0x%x) is error!\n",SENSOR_NAME_STRING(),__FUNCTION__,
4088 sensor->info_priv.funmodule_state,sensor->info_priv.affm_reinit);
4090 sensor_set_focus_relative_end:
4094 static int sensor_set_focus_mode(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
4096 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
4097 struct sensor *sensor = to_sensor(client);
4100 if ((sensor->info_priv.funmodule_state & SENSOR_AF_IS_OK) && (sensor->info_priv.affm_reinit == 0)) {
4103 case SENSOR_AF_MODE_AUTO:
4105 ret = sensor_af_single(client);
4109 case SENSOR_AF_MODE_MACRO:
4111 ret = sensor_set_focus_absolute(icd, qctrl, 0xff);
4115 case SENSOR_AF_MODE_INFINITY:
4117 ret = sensor_set_focus_absolute(icd, qctrl, 0x00);
4121 case SENSOR_AF_MODE_CONTINUOUS:
4123 ret = sensor_af_const(client);
4127 SENSOR_TR("\n %s..%s AF value(0x%x) is error!\n",SENSOR_NAME_STRING(),__FUNCTION__,value);
4132 SENSOR_DG("%s..%s : %d ret:0x%x\n",SENSOR_NAME_STRING(),__FUNCTION__, value,ret);
4135 SENSOR_TR("\n %s..%s AF module state(0x%x, 0x%x) is error!\n",SENSOR_NAME_STRING(),__FUNCTION__,
4136 sensor->info_priv.funmodule_state,sensor->info_priv.affm_reinit);
4142 static int sensor_g_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
4144 struct i2c_client *client = v4l2_get_subdevdata(sd);
4145 struct sensor *sensor = to_sensor(client);
4146 const struct v4l2_queryctrl *qctrl;
4147 SENSOR_DG("\n%s..%s.. \n",__FUNCTION__,SENSOR_NAME_STRING());
4149 qctrl = soc_camera_find_qctrl(&sensor_ops, ctrl->id);
4153 SENSOR_TR("\n %s ioctrl id = 0x%x is invalidate \n", SENSOR_NAME_STRING(), ctrl->id);
4159 case V4L2_CID_BRIGHTNESS:
4161 ctrl->value = sensor->info_priv.brightness;
4164 case V4L2_CID_SATURATION:
4166 ctrl->value = sensor->info_priv.saturation;
4169 case V4L2_CID_CONTRAST:
4171 ctrl->value = sensor->info_priv.contrast;
4174 case V4L2_CID_DO_WHITE_BALANCE:
4176 ctrl->value = sensor->info_priv.whiteBalance;
4179 case V4L2_CID_EXPOSURE:
4181 ctrl->value = sensor->info_priv.exposure;
4184 case V4L2_CID_HFLIP:
4186 ctrl->value = sensor->info_priv.mirror;
4189 case V4L2_CID_VFLIP:
4191 ctrl->value = sensor->info_priv.flip;
4202 static int sensor_s_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
4204 struct i2c_client *client = v4l2_get_subdevdata(sd);
4205 struct sensor *sensor = to_sensor(client);
4206 struct soc_camera_device *icd = client->dev.platform_data;
4207 const struct v4l2_queryctrl *qctrl;
4209 SENSOR_DG("\n%s..%s.. \n",__FUNCTION__,SENSOR_NAME_STRING());
4212 qctrl = soc_camera_find_qctrl(&sensor_ops, ctrl->id);
4216 SENSOR_TR("\n %s ioctrl id = 0x%x is invalidate \n", SENSOR_NAME_STRING(), ctrl->id);
4222 #if CONFIG_SENSOR_Brightness
4223 case V4L2_CID_BRIGHTNESS:
4225 if (ctrl->value != sensor->info_priv.brightness)
4227 if (sensor_set_brightness(icd, qctrl,ctrl->value) != 0)
4231 sensor->info_priv.brightness = ctrl->value;
4236 #if CONFIG_SENSOR_Exposure
4237 case V4L2_CID_EXPOSURE:
4239 if (ctrl->value != sensor->info_priv.exposure)
4241 if (sensor_set_exposure(icd, qctrl,ctrl->value) != 0)
4245 sensor->info_priv.exposure = ctrl->value;
4250 #if CONFIG_SENSOR_Saturation
4251 case V4L2_CID_SATURATION:
4253 if (ctrl->value != sensor->info_priv.saturation)
4255 if (sensor_set_saturation(icd, qctrl,ctrl->value) != 0)
4259 sensor->info_priv.saturation = ctrl->value;
4264 #if CONFIG_SENSOR_Contrast
4265 case V4L2_CID_CONTRAST:
4267 if (ctrl->value != sensor->info_priv.contrast)
4269 if (sensor_set_contrast(icd, qctrl,ctrl->value) != 0)
4273 sensor->info_priv.contrast = ctrl->value;
4278 #if CONFIG_SENSOR_WhiteBalance
4279 case V4L2_CID_DO_WHITE_BALANCE:
4281 if (ctrl->value != sensor->info_priv.whiteBalance)
4283 if (sensor_set_whiteBalance(icd, qctrl,ctrl->value) != 0)
4287 sensor->info_priv.whiteBalance = ctrl->value;
4292 #if CONFIG_SENSOR_Mirror
4293 case V4L2_CID_HFLIP:
4295 if (ctrl->value != sensor->info_priv.mirror)
4297 if (sensor_set_mirror(icd, qctrl,ctrl->value) != 0)
4299 sensor->info_priv.mirror = ctrl->value;
4304 #if CONFIG_SENSOR_Flip
4305 case V4L2_CID_VFLIP:
4307 if (ctrl->value != sensor->info_priv.flip)
4309 if (sensor_set_flip(icd, qctrl,ctrl->value) != 0)
4311 sensor->info_priv.flip = ctrl->value;
4322 static int sensor_g_ext_control(struct soc_camera_device *icd , struct v4l2_ext_control *ext_ctrl)
4324 const struct v4l2_queryctrl *qctrl;
4325 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
4326 struct sensor *sensor = to_sensor(client);
4328 SENSOR_DG("\n%s..%s.. \n",__FUNCTION__,SENSOR_NAME_STRING());
4330 qctrl = soc_camera_find_qctrl(&sensor_ops, ext_ctrl->id);
4334 SENSOR_TR("\n %s ioctrl id = 0x%x is invalidate \n", SENSOR_NAME_STRING(), ext_ctrl->id);
4338 switch (ext_ctrl->id)
4340 case V4L2_CID_SCENE:
4342 ext_ctrl->value = sensor->info_priv.scene;
4345 case V4L2_CID_EFFECT:
4347 ext_ctrl->value = sensor->info_priv.effect;
4350 case V4L2_CID_ZOOM_ABSOLUTE:
4352 ext_ctrl->value = sensor->info_priv.digitalzoom;
4355 case V4L2_CID_ZOOM_RELATIVE:
4359 case V4L2_CID_FOCUS_ABSOLUTE:
4363 case V4L2_CID_FOCUS_RELATIVE:
4367 case V4L2_CID_FLASH:
4369 ext_ctrl->value = sensor->info_priv.flash;
4377 static int sensor_s_ext_control(struct soc_camera_device *icd, struct v4l2_ext_control *ext_ctrl)
4379 const struct v4l2_queryctrl *qctrl;
4380 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
4381 struct sensor *sensor = to_sensor(client);
4384 qctrl = soc_camera_find_qctrl(&sensor_ops, ext_ctrl->id);
4388 SENSOR_TR("\n %s ioctrl id = 0x%x is invalidate \n", SENSOR_NAME_STRING(), ext_ctrl->id);
4393 switch (ext_ctrl->id)
4395 #if CONFIG_SENSOR_Scene
4396 case V4L2_CID_SCENE:
4398 if (ext_ctrl->value != sensor->info_priv.scene)
4400 if (sensor_set_scene(icd, qctrl,ext_ctrl->value) != 0)
4402 sensor->info_priv.scene = ext_ctrl->value;
4407 #if CONFIG_SENSOR_Effect
4408 case V4L2_CID_EFFECT:
4410 if (ext_ctrl->value != sensor->info_priv.effect)
4412 if (sensor_set_effect(icd, qctrl,ext_ctrl->value) != 0)
4414 sensor->info_priv.effect= ext_ctrl->value;
4419 #if CONFIG_SENSOR_DigitalZoom
4420 case V4L2_CID_ZOOM_ABSOLUTE:
4422 if ((ext_ctrl->value < qctrl->minimum) || (ext_ctrl->value > qctrl->maximum))
4425 if (ext_ctrl->value != sensor->info_priv.digitalzoom)
4427 val_offset = ext_ctrl->value -sensor->info_priv.digitalzoom;
4429 if (sensor_set_digitalzoom(icd, qctrl,&val_offset) != 0)
4431 sensor->info_priv.digitalzoom += val_offset;
4433 SENSOR_DG("%s digitalzoom is %x\n",SENSOR_NAME_STRING(), sensor->info_priv.digitalzoom);
4438 case V4L2_CID_ZOOM_RELATIVE:
4440 if (ext_ctrl->value)
4442 if (sensor_set_digitalzoom(icd, qctrl,&ext_ctrl->value) != 0)
4444 sensor->info_priv.digitalzoom += ext_ctrl->value;
4446 SENSOR_DG("%s digitalzoom is %x\n", SENSOR_NAME_STRING(), sensor->info_priv.digitalzoom);
4451 #if CONFIG_SENSOR_Focus
4452 case V4L2_CID_FOCUS_ABSOLUTE:
4454 if ((ext_ctrl->value < qctrl->minimum) || (ext_ctrl->value > qctrl->maximum))
4457 if (sensor_set_focus_absolute(icd, qctrl,ext_ctrl->value) == 0) {
4458 if (ext_ctrl->value == qctrl->minimum) {
4459 sensor->info_priv.auto_focus = SENSOR_AF_MODE_INFINITY;
4460 } else if (ext_ctrl->value == qctrl->maximum) {
4461 sensor->info_priv.auto_focus = SENSOR_AF_MODE_MACRO;
4463 sensor->info_priv.auto_focus = SENSOR_AF_MODE_FIXED;
4469 case V4L2_CID_FOCUS_RELATIVE:
4471 if ((ext_ctrl->value < qctrl->minimum) || (ext_ctrl->value > qctrl->maximum))
4474 sensor_set_focus_relative(icd, qctrl,ext_ctrl->value);
4477 case V4L2_CID_FOCUS_AUTO:
4479 if (ext_ctrl->value == 1) {
4480 if (sensor_set_focus_mode(icd, qctrl,SENSOR_AF_MODE_AUTO) != 0)
4482 sensor->info_priv.auto_focus = SENSOR_AF_MODE_AUTO;
4483 } else if (SENSOR_AF_MODE_AUTO == sensor->info_priv.auto_focus){
4484 if (ext_ctrl->value == 0)
4485 sensor->info_priv.auto_focus = SENSOR_AF_MODE_CLOSE;
4489 case V4L2_CID_FOCUS_CONTINUOUS:
4491 if (SENSOR_AF_MODE_CONTINUOUS != sensor->info_priv.auto_focus) {
4492 if (ext_ctrl->value == 1) {
4493 if (sensor_set_focus_mode(icd, qctrl,SENSOR_AF_MODE_CONTINUOUS) != 0)
4495 sensor->info_priv.auto_focus = SENSOR_AF_MODE_CONTINUOUS;
4498 if (ext_ctrl->value == 0)
4499 sensor->info_priv.auto_focus = SENSOR_AF_MODE_CLOSE;
4504 #if CONFIG_SENSOR_Flash
4505 case V4L2_CID_FLASH:
4507 if (sensor_set_flash(icd, qctrl,ext_ctrl->value) != 0)
4509 sensor->info_priv.flash = ext_ctrl->value;
4511 SENSOR_DG("%s flash is %x\n",SENSOR_NAME_STRING(), sensor->info_priv.flash);
4522 static int sensor_g_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl)
4524 struct i2c_client *client = v4l2_get_subdevdata(sd);
4525 struct soc_camera_device *icd = client->dev.platform_data;
4526 int i, error_cnt=0, error_idx=-1;
4528 SENSOR_DG("\n%s..%s.. \n",__FUNCTION__,SENSOR_NAME_STRING());
4531 for (i=0; i<ext_ctrl->count; i++) {
4532 if (sensor_g_ext_control(icd, &ext_ctrl->controls[i]) != 0) {
4539 error_idx = ext_ctrl->count;
4541 if (error_idx != -1) {
4542 ext_ctrl->error_idx = error_idx;
4549 static int sensor_s_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl)
4551 struct i2c_client *client = v4l2_get_subdevdata(sd);
4552 struct soc_camera_device *icd = client->dev.platform_data;
4553 int i, error_cnt=0, error_idx=-1;
4555 SENSOR_DG("\n%s..%s.. \n",__FUNCTION__,SENSOR_NAME_STRING());
4557 for (i=0; i<ext_ctrl->count; i++) {
4558 if (sensor_s_ext_control(icd, &ext_ctrl->controls[i]) != 0) {
4565 error_idx = ext_ctrl->count;
4567 if (error_idx != -1) {
4568 ext_ctrl->error_idx = error_idx;
4575 static int sensor_s_stream(struct v4l2_subdev *sd, int enable)
4577 struct i2c_client *client = v4l2_get_subdevdata(sd);
4578 struct sensor *sensor = to_sensor(client);
4581 sensor->info_priv.enable = 1;
4582 } else if (enable == 0) {
4583 sensor->info_priv.enable = 0;
4589 /* Interface active, can use i2c. If it fails, it can indeed mean, that
4590 * this wasn't our capture interface, so, we wait for the right one */
4591 static int sensor_video_probe(struct soc_camera_device *icd,
4592 struct i2c_client *client)
4595 struct sensor *sensor = to_sensor(client);
4596 #if (SENSOR_RESET_REG != SEQUENCE_END)
4597 struct reginfo reg_info;
4599 /* We must have a parent by now. And it cannot be a wrong one.
4600 * So this entire test is completely redundant. */
4601 if (!icd->dev.parent ||
4602 to_soc_camera_host(icd->dev.parent)->nr != icd->iface)
4605 if (sensor_ioctrl(icd, Sensor_PowerDown, 0) < 0) {
4607 goto sensor_video_probe_err;
4611 #if (SENSOR_RESET_REG != SEQUENCE_END)
4612 reg_info.reg = SENSOR_RESET_REG;
4613 reg_info.val = SENSOR_RESET_VAL;
4614 reg_info.reg_len = SENSOR_RESET_REG_LEN;
4615 ret = sensor_write(client, ®_info);
4617 SENSOR_TR("%s soft reset sensor failed\n",SENSOR_NAME_STRING());
4619 goto sensor_video_probe_err;
4622 mdelay(5); //delay 5 microseconds
4625 /* check if it is an sensor sensor */
4626 #if (SENSOR_ID_REG != SEQUENCE_END)
4627 ret = sensor_read(client, SENSOR_ID_REG, &pid);
4629 SENSOR_TR("read chip id failed\n");
4631 goto sensor_video_probe_err;
4634 SENSOR_DG("\n %s pid = 0x%x \n", SENSOR_NAME_STRING(), pid);
4639 if (pid == SENSOR_ID) {
4640 sensor->model = SENSOR_V4L2_IDENT;
4642 SENSOR_TR("error: %s mismatched pid = 0x%x\n", SENSOR_NAME_STRING(), pid);
4644 goto sensor_video_probe_err;
4649 sensor_video_probe_err:
4653 static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
4655 struct i2c_client *client = v4l2_get_subdevdata(sd);
4656 struct soc_camera_device *icd = client->dev.platform_data;
4657 struct sensor *sensor = to_sensor(client);
4658 #if CONFIG_SENSOR_Flash
4663 rk29_camera_sensor_cb_s *icd_cb =NULL;
4665 SENSOR_DG("\n%s..%s..cmd:%x \n",SENSOR_NAME_STRING(),__FUNCTION__,cmd);
4668 case RK29_CAM_SUBDEV_DEACTIVATE:
4670 sensor_deactivate(client);
4673 case RK29_CAM_SUBDEV_IOREQUEST:
4675 sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
4676 if (sensor->sensor_io_request != NULL) {
4677 sensor->sensor_gpio_res = NULL;
4678 for (i=0; i<RK29_CAM_SUPPORT_NUMS;i++) {
4679 if (sensor->sensor_io_request->gpio_res[i].dev_name &&
4680 (strcmp(sensor->sensor_io_request->gpio_res[i].dev_name, dev_name(icd->pdev)) == 0)) {
4681 sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[i];
4684 if (sensor->sensor_gpio_res == NULL) {
4685 SENSOR_TR("%s %s obtain gpio resource failed when RK29_CAM_SUBDEV_IOREQUEST \n",SENSOR_NAME_STRING(),__FUNCTION__);
4687 goto sensor_ioctl_end;
4690 SENSOR_TR("%s %s RK29_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
4692 goto sensor_ioctl_end;
4694 /* ddl@rock-chips.com : if gpio_flash havn't been set in board-xxx.c, sensor driver must notify is not support flash control
4696 #if CONFIG_SENSOR_Flash
4697 if (sensor->sensor_gpio_res) {
4698 if (sensor->sensor_gpio_res->gpio_flash == INVALID_GPIO) {
4699 for (i = 0; i < icd->ops->num_controls; i++) {
4700 if (V4L2_CID_FLASH == icd->ops->controls[i].id) {
4701 //memset((char*)&icd->ops->controls[i],0x00,sizeof(struct v4l2_queryctrl));
4702 sensor_controls[i].id=0xffff;
4705 sensor->info_priv.flash = 0xff;
4706 SENSOR_DG("%s flash gpio is invalidate!\n",SENSOR_NAME_STRING());
4707 }else{ //two cameras are the same,need to deal diffrently ,zyc
4708 for (i = 0; i < icd->ops->num_controls; i++) {
4709 if(0xffff == icd->ops->controls[i].id){
4710 sensor_controls[i].id=V4L2_CID_FLASH;
4718 case RK29_CAM_SUBDEV_CB_REGISTER:
4720 icd_cb = (rk29_camera_sensor_cb_s*)(arg);
4721 icd_cb->sensor_cb = sensor_cb;
4726 SENSOR_TR("%s %s cmd(0x%x) is unknown !\n",SENSOR_NAME_STRING(),__FUNCTION__,cmd);
4734 static int sensor_enum_fmt(struct v4l2_subdev *sd, unsigned int index,
4735 enum v4l2_mbus_pixelcode *code)
4737 if (index >= ARRAY_SIZE(sensor_colour_fmts))
4740 *code = sensor_colour_fmts[index].code;
4743 static struct v4l2_subdev_core_ops sensor_subdev_core_ops = {
4744 .init = sensor_init,
4745 .g_ctrl = sensor_g_control,
4746 .s_ctrl = sensor_s_control,
4747 .g_ext_ctrls = sensor_g_ext_controls,
4748 .s_ext_ctrls = sensor_s_ext_controls,
4749 .g_chip_ident = sensor_g_chip_ident,
4750 .ioctl = sensor_ioctl,
4752 static struct v4l2_subdev_video_ops sensor_subdev_video_ops = {
4753 .s_mbus_fmt = sensor_s_fmt,
4754 .g_mbus_fmt = sensor_g_fmt,
4755 .try_mbus_fmt = sensor_try_fmt,
4756 .enum_mbus_fmt = sensor_enum_fmt,
4757 .s_stream = sensor_s_stream,
4759 static struct v4l2_subdev_ops sensor_subdev_ops = {
4760 .core = &sensor_subdev_core_ops,
4761 .video = &sensor_subdev_video_ops,
4764 static int sensor_probe(struct i2c_client *client,
4765 const struct i2c_device_id *did)
4767 struct sensor *sensor;
4768 struct soc_camera_device *icd = client->dev.platform_data;
4769 struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
4770 struct soc_camera_link *icl;
4773 SENSOR_DG("\n%s..%s..%d..\n",__FUNCTION__,__FILE__,__LINE__);
4775 dev_err(&client->dev, "%s: missing soc-camera data!\n",SENSOR_NAME_STRING());
4779 icl = to_soc_camera_link(icd);
4781 dev_err(&client->dev, "%s driver needs platform data\n", SENSOR_NAME_STRING());
4785 if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) {
4786 dev_warn(&adapter->dev,
4787 "I2C-Adapter doesn't support I2C_FUNC_I2C\n");
4791 sensor = kzalloc(sizeof(struct sensor), GFP_KERNEL);
4795 v4l2_i2c_subdev_init(&sensor->subdev, client, &sensor_subdev_ops);
4797 /* Second stage probe - when a capture adapter is there */
4798 icd->ops = &sensor_ops;
4799 sensor->info_priv.fmt = sensor_colour_fmts[0];
4800 #if CONFIG_SENSOR_I2C_NOSCHED
4801 atomic_set(&sensor->tasklock_cnt,0);
4804 ret = sensor_video_probe(icd, client);
4807 i2c_set_clientdata(client, NULL);
4811 SENSOR_DG("\n%s..%s..%d ret = %x \n",__FUNCTION__,__FILE__,__LINE__,ret);
4815 static int sensor_remove(struct i2c_client *client)
4817 struct sensor *sensor = to_sensor(client);
4818 struct soc_camera_device *icd = client->dev.platform_data;
4820 #if CONFIG_SENSOR_Focus
4821 if (sensor->sensor_wq) {
4822 destroy_workqueue(sensor->sensor_wq);
4823 sensor->sensor_wq = NULL;
4828 i2c_set_clientdata(client, NULL);
4829 client->driver = NULL;
4835 static const struct i2c_device_id sensor_id[] = {
4836 {SENSOR_NAME_STRING(), 0 },
4839 MODULE_DEVICE_TABLE(i2c, sensor_id);
4841 static struct i2c_driver sensor_i2c_driver = {
4843 .name = SENSOR_NAME_STRING(),
4845 .probe = sensor_probe,
4846 .remove = sensor_remove,
4847 .id_table = sensor_id,
4850 static int __init sensor_mod_init(void)
4852 SENSOR_DG("\n%s..%s.. \n",__FUNCTION__,SENSOR_NAME_STRING());
4853 return i2c_add_driver(&sensor_i2c_driver);
4856 static void __exit sensor_mod_exit(void)
4858 SENSOR_DG("\n%s..%s.. \n",__FUNCTION__,SENSOR_NAME_STRING());
4859 i2c_del_driver(&sensor_i2c_driver);
4862 device_initcall_sync(sensor_mod_init);
4863 module_exit(sensor_mod_exit);
4865 MODULE_DESCRIPTION(SENSOR_NAME_STRING(Camera sensor driver));
4866 MODULE_AUTHOR("ddl <kernel@rock-chips>");
4867 MODULE_LICENSE("GPL");