1 /*
2 * A V4L2 driver for ov5640 YUV cameras.
3 *
4 * Copyright (c) 2017 by Allwinnertech Co., Ltd. http://www.allwinnertech.com
5 *
6 * Authors: Zhao Wei <zhaowei@allwinnertech.com>
7 * Yang Feng <yangfeng@allwinnertech.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13
14 #include <linux/init.h>
15 #include <linux/module.h>
16 #include <linux/slab.h>
17 #include <linux/i2c.h>
18 #include <linux/delay.h>
19 #include <linux/videodev2.h>
20 #include <linux/clk.h>
21 #include <media/v4l2-device.h>
22 #include <media/v4l2-mediabus.h>
23 #include <linux/io.h>
24
25 #include "camera.h"
26 #include "sensor_helper.h"
27
28 MODULE_AUTHOR("raymonxiu");
29 MODULE_DESCRIPTION("A low-level driver for ov5640 sensors");
30 MODULE_LICENSE("GPL");
31
32 #define AF_WIN_NEW_COORD
33
34 #define MCLK (24*1000*1000)
35 int MCLK_DIV = 1;
36 #ifdef CONFIG_ARCH_SUN9IW1P1
37 int A80_VERSION;
38 #endif
39
40 #define VREF_POL V4L2_MBUS_VSYNC_ACTIVE_HIGH
41 #define HREF_POL V4L2_MBUS_HSYNC_ACTIVE_HIGH
42 #define CLK_POL V4L2_MBUS_PCLK_SAMPLE_FALLING
43 #define V4L2_IDENT_SENSOR 0x5640
44
45 #define SENSOR_NAME "ov5640"
46
47 #ifdef _FLASH_FUNC_
48 #include "../modules/flash/flash.h"
49 unsigned int to_flash;
50 static unsigned int flash_auto_level = 0x1c;
51 #endif
52 #define CONTINUEOUS_AF
53
54 #define DENOISE_LV_AUTO
55 #define SHARPNESS 0x18
56
57 #ifdef AUTO_FPS
58
59 #endif
60
61 #ifndef DENOISE_LV_AUTO
62 #define DENOISE_LV 0x8
63 #endif
64
65 #define AE_CW 1
66
67 unsigned int night_mode;
68 unsigned int Nfrms = 1;
69 unsigned int cap_manual_gain = 0x10;
70 #define CAP_GAIN_CAL 0
71 #define CAP_MULTI_FRAMES
72 #ifdef CAP_MULTI_FRAMES
73 #define MAX_FRM_CAP 4
74 #else
75 #define MAX_FRM_CAP 1
76 #endif
77
78 /*
79 * Our nominal (default) frame rate.
80 */
81 #define SENSOR_FRAME_RATE 30
82
83 /*
84 * The ov5640 sits on i2c with ID 0x78
85 */
86 #define I2C_ADDR 0x78
87
88 struct cfg_array { /* coming later */
89 struct regval_list *regs;
90 int size;
91 };
92
93
94
95 /*
96 * The default register settings
97 *
98 */
99
100 static struct regval_list sensor_default_regs[] = {
101 {0x3103, 0x11},
102 {0x3008, 0x82},
103 {REG_DLY, 0x1e},
104 {0x3008, 0x42},
105 {0x3103, 0x03},
106 {0x3017, 0x00},
107 {0x3018, 0x00},
108 {0x3034, 0x18},
109 {0x3035, 0x21},
110 {0x3036, 0x46},
111 {0x3037, 0x13},
112 {0x3108, 0x01},
113 {0x3824, 0x01},
114 {0x3630, 0x36},
115 {0x3631, 0x0e},
116 {0x3632, 0xe2},
117 {0x3633, 0x12},
118 {0x3621, 0xe0},
119 {0x3704, 0xa0},
120 {0x3703, 0x5a},
121 {0x3715, 0x78},
122 {0x3717, 0x01},
123 {0x370b, 0x60},
124 {0x3705, 0x1a},
125 {0x3905, 0x02},
126 {0x3906, 0x10},
127 {0x3901, 0x0a},
128 {0x3731, 0x12},
129 {0x3600, 0x08},
130 {0x3601, 0x33},
131 {0x3620, 0x52},
132 {0x371b, 0x20},
133 {0x471c, 0x50},
134 {0x3a13, 0x43},
135 {0x3a18, 0x00},
136 {0x3a19, 0x88},
137 {0x3635, 0x13},
138 {0x3636, 0x03},
139 {0x3634, 0x40},
140 {0x3622, 0x01},
141 {0x3c01, 0x34},
142 {0x3c04, 0x28},
143 {0x3c05, 0x98},
144 {0x3c06, 0x00},
145 {0x3c07, 0x08},
146 {0x3c08, 0x00},
147 {0x3c09, 0x1c},
148 {0x3c0a, 0x9c},
149 {0x3c0b, 0x40},
150 {0x3814, 0x31},
151 {0x3815, 0x31},
152 {0x3800, 0x00},
153 {0x3801, 0x00},
154 {0x3802, 0x00},
155 {0x3803, 0x04},
156 {0x3804, 0x0a},
157 {0x3805, 0x3f},
158 {0x3806, 0x07},
159 {0x3807, 0x9b},
160 {0x3808, 0x02},
161 {0x3809, 0x80},
162 {0x380a, 0x01},
163 {0x380b, 0xe0},
164 {0x380c, 0x07},
165 {0x380d, 0x68},
166 {0x380e, 0x03},
167 {0x380f, 0xd8},
168 {0x3810, 0x00},
169 {0x3811, 0x10},
170 {0x3812, 0x00},
171 {0x3813, 0x06},
172 {0x3618, 0x00},
173 {0x3612, 0x29},
174 {0x3708, 0x64},
175 {0x3709, 0x52},
176 {0x370c, 0x03},
177 {0x3a00, 0x78},
178 {0x3a02, 0x03},
179 {0x3a03, 0xd8},
180 {0x3a08, 0x01},
181 {0x3a09, 0x27},
182 {0x3a0a, 0x00},
183 {0x3a0b, 0xf6},
184 {0x3a0e, 0x03},
185 {0x3a0d, 0x04},
186 {0x3a14, 0x03},
187 {0x3a15, 0xd8},
188 {0x4001, 0x02},
189 {0x4004, 0x02},
190 {0x3000, 0x00},
191 {0x3002, 0x1c},
192 {0x3004, 0xff},
193 {0x3006, 0xc3},
194 {0x300e, 0x58},
195 {0x302c, 0x42},
196 {0x4300, 0x30},
197 {0x501f, 0x00},
198 {0x4713, 0x03},
199 {0x4407, 0x04},
200 {0x440e, 0x00},
201 {0x460b, 0x35},
202 {0x460c, 0x20},
203 {0x4837, 0x22},
204 {0x5000, 0xa7},
205 {0x5001, 0xa3},
206 {0x4740, 0x21},
207 {0x3406, 0x00},
208 {0x5180, 0xff},
209 {0x5181, 0xf2},
210 {0x5182, 0x00},
211 {0x5183, 0x14},
212 {0x5184, 0x25},
213 {0x5185, 0x24},
214 {0x5186, 0x16},
215 {0x5187, 0x16},
216 {0x5188, 0x16},
217 {0x5189, 0x6e},
218 {0x518a, 0x68},
219 {0x518b, 0xe0},
220 {0x518c, 0xb2},
221 {0x518d, 0x42},
222 {0x518e, 0x3e},
223 {0x518f, 0x4c},
224 {0x5190, 0x56},
225 {0x5191, 0xf8},
226 {0x5192, 0x04},
227 {0x5193, 0x70},
228 {0x5194, 0xf0},
229 {0x5195, 0xf0},
230 {0x5196, 0x03},
231 {0x5197, 0x01},
232 {0x5198, 0x04},
233 {0x5199, 0x12},
234 {0x519a, 0x04},
235 {0x519b, 0x00},
236 {0x519c, 0x06},
237 {0x519d, 0x82},
238 {0x519e, 0x38},
239 {0x5381, 0x1e},
240 {0x5382, 0x5b},
241 {0x5383, 0x14},
242 {0x5384, 0x05},
243 {0x5385, 0x77},
244 {0x5386, 0x7c},
245 {0x5387, 0x72},
246 {0x5388, 0x58},
247 {0x5389, 0x1a},
248 {0x538a, 0x01},
249 {0x538b, 0x98},
250 {0x5300, 0x08},
251 {0x5301, 0x30},
252 {0x5302, 0x30},
253 {0x5303, 0x10},
254 {0x5308, 0x25},
255 {0x5304, 0x08},
256 {0x5305, 0x30},
257 {0x5306, 0x1c},
258 {0x5307, 0x2c},
259 {0x5309, 0x08},
260 {0x530a, 0x30},
261 {0x530b, 0x04},
262 {0x530c, 0x06},
263 {0x5480, 0x01},
264 {0x5481, 0x06},
265 {0x5482, 0x12},
266 {0x5483, 0x1e},
267 {0x5484, 0x4a},
268 {0x5485, 0x58},
269 {0x5486, 0x65},
270 {0x5487, 0x72},
271 {0x5488, 0x7d},
272 {0x5489, 0x88},
273 {0x548a, 0x92},
274 {0x548b, 0xa3},
275 {0x548c, 0xb2},
276 {0x548d, 0xc8},
277 {0x548e, 0xdd},
278 {0x548f, 0xf0},
279 {0x5490, 0x15},
280 {0x5580, 0x06},
281 {0x5583, 0x40},
282 {0x5584, 0x10},
283 {0x5589, 0x10},
284 {0x558a, 0x00},
285 {0x558b, 0xf8},
286 {0x501d, 0x40},
287 {0x5800, 0x15},
288 {0x5801, 0x10},
289 {0x5802, 0x0D},
290 {0x5803, 0x0D},
291 {0x5804, 0x0F},
292 {0x5805, 0x15},
293 {0x5806, 0x0A},
294 {0x5807, 0x07},
295 {0x5808, 0x05},
296 {0x5809, 0x05},
297 {0x580A, 0x07},
298 {0x580B, 0x0B},
299 {0x580C, 0x07},
300 {0x580D, 0x03},
301 {0x580E, 0x01},
302 {0x580F, 0x01},
303 {0x5810, 0x03},
304 {0x5811, 0x07},
305 {0x5812, 0x07},
306 {0x5813, 0x03},
307 {0x5814, 0x01},
308 {0x5815, 0x01},
309 {0x5816, 0x03},
310 {0x5817, 0x06},
311 {0x5818, 0x0D},
312 {0x5819, 0x08},
313 {0x581A, 0x06},
314 {0x581B, 0x06},
315 {0x581C, 0x07},
316 {0x581D, 0x0B},
317 {0x581E, 0x14},
318 {0x581F, 0x13},
319 {0x5820, 0x0E},
320 {0x5821, 0x0E},
321 {0x5822, 0x12},
322 {0x5823, 0x12},
323 {0x5824, 0x46},
324 {0x5825, 0x26},
325 {0x5826, 0x06},
326 {0x5827, 0x46},
327 {0x5828, 0x44},
328 {0x5829, 0x26},
329 {0x582A, 0x24},
330 {0x582B, 0x42},
331 {0x582C, 0x24},
332 {0x582D, 0x46},
333 {0x582E, 0x24},
334 {0x582F, 0x42},
335 {0x5830, 0x60},
336 {0x5831, 0x42},
337 {0x5832, 0x24},
338 {0x5833, 0x26},
339 {0x5834, 0x24},
340 {0x5835, 0x24},
341 {0x5836, 0x24},
342 {0x5837, 0x46},
343 {0x5838, 0x44},
344 {0x5839, 0x46},
345 {0x583A, 0x26},
346 {0x583B, 0x48},
347 {0x583C, 0x44},
348 {0x583D, 0xBF},
349 {0x3a0f, 0x30},
350 {0x3a10, 0x28},
351 {0x3a1b, 0x30},
352 {0x3a1e, 0x26},
353 {0x3a11, 0x60},
354 {0x3a1f, 0x14},
355 {0x5025, 0x00},
356 {0x3031, 0x08},
357 {0x503d, 0x00},
358 {0x3008, 0x02},
359 };
360
361
362 static struct regval_list sensor_qsxga_regs[] = {
363 {0x3820, 0x40},
364 {0x3821, 0x06},
365 {0x3034, 0x18},
366 #ifndef FPGA_VER
367 {0x3035, 0x21},
368 #else
369 {0x3035, 0x41},
370 #endif
371 {0x3036, 0x54},
372 {0x3037, 0x13},
373 {0x3108, 0x01},
374 {0x3824, 0x01},
375 {REG_DLY, 0x05},
376 {0x3808, 0x0a},
377 {0x3809, 0x20},
378 {0x380a, 0x07},
379 {0x380b, 0x90},
380 {0x380c, 0x0b},
381 {0x380d, 0x1c},
382 {0x380e, 0x07},
383 {0x380f, 0xb0},
384 #ifndef FPGA_VER
385 {0x3a08, 0x00},
386 {0x3a09, 0x93},
387 {0x3a0a, 0x00},
388 {0x3a0b, 0x7b},
389 {0x3a0e, 0x0d},
390 {0x3a0d, 0x10},
391 #else
392 {0x3a08, 0x00},
393 {0x3a09, 0x93},
394 {0x3a0a, 0x00},
395 {0x3a0b, 0x7b},
396 {0x3a0e, 0x0d},
397 {0x3a0d, 0x10},
398 #endif
399 {0x3503, 0x07},
400 {0x350c, 0x00},
401 {0x350d, 0x00},
402 {0x3c07, 0x07},
403 {0x3814, 0x11},
404 {0x3815, 0x11},
405 {0x3800, 0x00},
406 {0x3801, 0x00},
407 {0x3802, 0x00},
408 {0x3803, 0x00},
409 {0x3804, 0x0a},
410 {0x3805, 0x3f},
411 {0x3806, 0x07},
412 {0x3807, 0x9f},
413 {0x3810, 0x00},
414 {0x3811, 0x10},
415 {0x3812, 0x00},
416 {0x3813, 0x04},
417 {0x4002, 0xc5},
418 {0x4005, 0x1a},
419 {0x3618, 0x04},
420 {0x3612, 0x2b},
421 {0x3709, 0x12},
422 {0x370c, 0x00},
423 {0x3a02, 0x07},
424 {0x3a03, 0xb0},
425 {0x3a14, 0x07},
426 {0x3a15, 0xb0},
427 {0x4004, 0x06},
428 {0x4837, 0x2c},
429 {0x5001, 0xa3},
430 {0x302c, 0x42},
431 };
432
433 static struct regval_list sensor_qxga_regs[] = {
434 {0x3034, 0x18},
435 #ifndef FPGA_VER
436 {0x3035, 0x21},
437 #else
438 {0x3035, 0x41},
439 #endif
440 {0x3036, 0x54},
441 {0x3037, 0x13},
442 {0x3108, 0x01},
443 {0x3824, 0x01},
444 {REG_DLY, 0x05},
445 {0x3808, 0x08},
446 {0x3809, 0x00},
447 {0x380a, 0x06},
448 {0x380b, 0x00},
449 {0x380c, 0x0b},
450 {0x380d, 0x1c},
451 {0x380e, 0x07},
452 {0x380f, 0xb0},
453 #ifndef FPGA_VER
454 {0x3a08, 0x00},
455 {0x3a09, 0x93},
456 {0x3a0a, 0x00},
457 {0x3a0b, 0x7b},
458 {0x3a0e, 0x0d},
459 {0x3a0d, 0x10},
460 #else
461 {0x3a08, 0x00},
462 {0x3a09, 0x49},
463 {0x3a0a, 0x00},
464 {0x3a0b, 0x3d},
465 {0x3a0e, 0x1a},
466 {0x3a0d, 0x20},
467 #endif
468 {0x350c, 0x00},
469 {0x350d, 0x00},
470 {0x3c07, 0x07},
471 {0x3814, 0x11},
472 {0x3815, 0x11},
473 {0x3800, 0x00},
474 {0x3801, 0x00},
475 {0x3802, 0x00},
476 {0x3803, 0x00},
477 {0x3804, 0x0a},
478 {0x3805, 0x3f},
479 {0x3806, 0x07},
480 {0x3807, 0x9f},
481 {0x3810, 0x00},
482 {0x3811, 0x10},
483 {0x3812, 0x00},
484 {0x3813, 0x04},
485 {0x4002, 0xc5},
486 {0x4005, 0x1a},
487 {0x3618, 0x04},
488 {0x3612, 0x2b},
489 {0x3709, 0x12},
490 {0x370c, 0x00},
491 {0x3a02, 0x07},
492 {0x3a03, 0xb0},
493 {0x3a14, 0x07},
494 {0x3a15, 0xb0},
495 {0x4004, 0x06},
496 {0x4837, 0x2c},
497 {0x5001, 0xa3},
498 {0x302c, 0x42},
499 };
500
501 static struct regval_list sensor_uxga_regs[] = {
502 {0x3034, 0x18},
503 #ifndef FPGA_VER
504 {0x3035, 0x21},
505 #else
506 {0x3035, 0x41},
507 #endif
508 {0x3036, 0x54},
509 {0x3037, 0x13},
510 {0x3108, 0x01},
511 {0x3824, 0x01},
512 {REG_DLY, 0x05},
513 {0x3808, 0x06},
514 {0x3809, 0x40},
515 {0x380a, 0x04},
516 {0x380b, 0xb0},
517 {0x380c, 0x0b},
518 {0x380d, 0x1c},
519 {0x380e, 0x07},
520 {0x380f, 0xb0},
521 #ifndef FPGA_VER
522 {0x3a08, 0x00},
523 {0x3a09, 0x93},
524 {0x3a0a, 0x00},
525 {0x3a0b, 0x7b},
526 {0x3a0e, 0x0d},
527 {0x3a0d, 0x10},
528 #else
529 {0x3a08, 0x00},
530 {0x3a09, 0x49},
531 {0x3a0a, 0x00},
532 {0x3a0b, 0x3d},
533 {0x3a0e, 0x1a},
534 {0x3a0d, 0x20},
535 #endif
536 {0x350c, 0x00},
537 {0x350d, 0x00},
538 {0x3c07, 0x07},
539 {0x3814, 0x11},
540 {0x3815, 0x11},
541 {0x3800, 0x00},
542 {0x3801, 0x00},
543 {0x3802, 0x00},
544 {0x3803, 0x00},
545 {0x3804, 0x0a},
546 {0x3805, 0x3f},
547 {0x3806, 0x07},
548 {0x3807, 0x9f},
549 {0x3810, 0x00},
550 {0x3811, 0x10},
551 {0x3812, 0x00},
552 {0x3813, 0x04},
553 {0x4002, 0xc5},
554 {0x4005, 0x12},
555 {0x3618, 0x04},
556 {0x3612, 0x2b},
557 {0x3709, 0x12},
558 {0x370c, 0x00},
559 {0x3a02, 0x07},
560 {0x3a03, 0xb0},
561 {0x3a14, 0x07},
562 {0x3a15, 0xb0},
563 {0x4004, 0x06},
564 {0x4837, 0x2c},
565 {0x5001, 0xa3},
566 {0x302c, 0x42},
567 };
568
569 static struct regval_list sensor_sxga_regs[] = {
570 {0x3820, 0x40},
571 {0x3821, 0x06},
572
573 {0x3034, 0x18},
574 #ifndef FPGA_VER
575 {0x3035, 0x11},
576 #else
577 {0x3035, 0x21},
578 #endif
579 {0x3036, 0x54},
580 {0x3037, 0x13},
581 {0x3108, 0x01},
582 {0x3824, 0x01},
583 {REG_DLY, 0x05},
584 {0x3808, 0x05},
585 {0x3809, 0x00},
586 {0x380a, 0x03},
587 {0x380b, 0xc0},
588 {0x380c, 0x0b},
589 {0x380d, 0x1c},
590 {0x380e, 0x07},
591 {0x380f, 0xb0},
592 #ifndef FPGA_VER
593 {0x3a08, 0x00},
594 {0x3a09, 0x94},
595 {0x3a0a, 0x00},
596 {0x3a0b, 0x7b},
597 {0x3a0e, 0x06},
598 {0x3a0d, 0x08},
599 #else
600 {0x3a08, 0x00},
601 {0x3a09, 0x94},
602 {0x3a0a, 0x00},
603 {0x3a0b, 0x7b},
604 {0x3a0e, 0x06},
605 {0x3a0d, 0x08},
606 #endif
607 {0x3503, 0x00},
608 {0x350c, 0x00},
609 {0x350d, 0x00},
610 {0x3c07, 0x07},
611 {0x3814, 0x11},
612 {0x3815, 0x11},
613 {0x3800, 0x00},
614 {0x3801, 0x00},
615 {0x3802, 0x00},
616 {0x3803, 0x00},
617 {0x3804, 0x0a},
618 {0x3805, 0x3f},
619 {0x3806, 0x07},
620 {0x3807, 0x9f},
621 {0x3810, 0x00},
622 {0x3811, 0x10},
623 {0x3812, 0x00},
624 {0x3813, 0x04},
625 {0x4002, 0xc5},
626 {0x4005, 0x12},
627 {0x3618, 0x04},
628 {0x3612, 0x2b},
629 {0x3709, 0x12},
630 {0x370c, 0x00},
631 {0x3a02, 0x07},
632 {0x3a03, 0xb0},
633 {0x3a14, 0x07},
634 {0x3a15, 0xb0},
635 {0x4004, 0x06},
636 {0x4837, 0x2c},
637 {0x5001, 0xa3},
638 {0x302c, 0x42},
639 {0x3a18, 0x00},
640 {0x3a19, 0xf8},
641 };
642
643 static struct regval_list sensor_xga_regs[] = {
644 {0x3034, 0x18},
645 #ifndef FPGA_VER
646 {0x3035, 0x21},
647 #else
648 {0x3035, 0x41},
649 #endif
650 {0x3036, 0x54},
651 {0x3037, 0x13},
652 {0x3108, 0x01},
653 {0x3824, 0x01},
654 {REG_DLY, 0x05},
655 {0x3808, 0x04},
656 {0x3809, 0x00},
657 {0x380a, 0x03},
658 {0x380b, 0x00},
659 {0x380c, 0x0b},
660 {0x380d, 0x1c},
661 {0x380e, 0x07},
662 {0x380f, 0xb0},
663 #ifndef FPGA_VER
664 {0x3a08, 0x00},
665 {0x3a09, 0x93},
666 {0x3a0a, 0x00},
667 {0x3a0b, 0x7b},
668 {0x3a0e, 0x0d},
669 {0x3a0d, 0x10},
670 #else
671
672 {0x3a08, 0x00},
673 {0x3a09, 0x49},
674 {0x3a0a, 0x00},
675 {0x3a0b, 0x3d},
676 {0x3a0e, 0x1a},
677 {0x3a0d, 0x20},
678 #endif
679
680 {0x350c, 0x00},
681 {0x350d, 0x00},
682 {0x3c07, 0x07},
683 {0x3814, 0x11},
684 {0x3815, 0x11},
685 {0x3800, 0x00},
686 {0x3801, 0x00},
687 {0x3802, 0x00},
688 {0x3803, 0x00},
689 {0x3804, 0x0a},
690 {0x3805, 0x3f},
691 {0x3806, 0x07},
692 {0x3807, 0x9f},
693 {0x3810, 0x00},
694 {0x3811, 0x10},
695 {0x3812, 0x00},
696 {0x3813, 0x04},
697 {0x4002, 0xc5},
698 {0x4005, 0x12},
699 {0x3618, 0x00},
700 {0x3612, 0x29},
701 {0x3709, 0x52},
702 {0x370c, 0x03},
703 {0x3a02, 0x03},
704 {0x3a03, 0xd8},
705 {0x3a14, 0x03},
706 {0x3a15, 0xd8},
707 {0x4004, 0x02},
708 {0x4837, 0x22},
709 {0x5001, 0xa3},
710 {0x3618, 0x04},
711 {0x3612, 0x2b},
712 {0x3709, 0x12},
713 {0x370c, 0x00},
714 {0x3a02, 0x07},
715 {0x3a03, 0xb0},
716 {0x3a14, 0x07},
717 {0x3a15, 0xb0},
718 {0x4004, 0x06},
719 {0x4837, 0x2c},
720 {0x5001, 0xa3},
721 {0x302c, 0x42},
722 };
723
724
725 static struct regval_list sensor_1080p_regs[] = {
726 {0x3820, 0x40},
727 {0x3821, 0x06},
728 {0x3034, 0x18},
729 #ifndef FPGA_VER
730 {0x3035, 0x21},
731 #else
732 {0x3035, 0x41},
733 #endif
734 {0x3036, 0x54},
735 {0x3037, 0x13},
736 {0x3108, 0x01},
737 {0x3824, 0x01},
738 {REG_DLY, 0x05},
739 {0x3808, 0x07},
740 {0x3809, 0x80},
741 {0x380a, 0x04},
742 {0x380b, 0x38},
743 {0x380c, 0x09},
744 {0x380d, 0xc4},
745 {0x380e, 0x04},
746 {0x380f, 0x60},
747 #ifndef FPGA_VER
748 {0x3a08, 0x01},
749 {0x3a09, 0x50},
750 {0x3a0a, 0x01},
751 {0x3a0b, 0x18},
752 {0x3a0e, 0x03},
753 {0x3a0d, 0x04},
754 #else
755 {0x3a08, 0x00},
756 {0x3a09, 0x54},
757 {0x3a0a, 0x00},
758 {0x3a0b, 0x46},
759 {0x3a0e, 0x0d},
760 {0x3a0d, 0x10},
761 #endif
762 {0x3503, 0x00},
763 {0x350c, 0x00},
764 {0x350d, 0x00},
765 {0x3c07, 0x07},
766 {0x3814, 0x11},
767 {0x3815, 0x11},
768 {0x3800, 0x01},
769 {0x3801, 0x50},
770 {0x3802, 0x01},
771 {0x3803, 0xb2},
772 {0x3804, 0x08},
773 {0x3805, 0xef},
774 {0x3806, 0x05},
775 {0x3807, 0xf1},
776 {0x3810, 0x00},
777 {0x3811, 0x10},
778 {0x3812, 0x00},
779 {0x3813, 0x04},
780 {0x4002, 0x45},
781 {0x4005, 0x18},
782 {0x3618, 0x04},
783 {0x3612, 0x2b},
784 {0x3709, 0x12},
785 {0x370c, 0x00},
786 {0x3a02, 0x04},
787 {0x3a03, 0x60},
788 {0x3a14, 0x04},
789 {0x3a15, 0x60},
790 {0x4004, 0x06},
791 {0x3002, 0x1c},
792 {0x3006, 0xc3},
793 {0x460b, 0x37},
794 {0x460c, 0x20},
795 {0x4837, 0x16},
796 {0x5001, 0x83},
797 {0x302c, 0x42},
798 {0x3a18, 0x00},
799 {0x3a19, 0x80},
800 };
801
802 static struct regval_list sensor_720p_regs[] = {
803 {0x3820, 0x41},
804 {0x3821, 0x07},
805 {0x3034, 0x18},
806 #ifndef FPGA_VER
807 {0x3035, 0x21},
808 #else
809 {0x3035, 0x41},
810 #endif
811 {0x3036, 0x54},
812 {0x3037, 0x13},
813 {0x3108, 0x01},
814 {0x3824, 0x01},
815 {REG_DLY, 0x05},
816 {0x3808, 0x05},
817 {0x3809, 0x00},
818 {0x380a, 0x02},
819 {0x380b, 0xd0},
820 {0x380c, 0x07},
821 {0x380d, 0x64},
822 {0x380e, 0x02},
823 {0x380f, 0xe4},
824 #ifndef FPGA_VER
825 {0x3a08, 0x00},
826 {0x3a09, 0xdd},
827 {0x3a0a, 0x00},
828 {0x3a0b, 0xb8},
829 {0x3a0e, 0x03},
830 {0x3a0d, 0x04},
831 #else
832 {0x3a08, 0x00},
833 {0x3a09, 0xdd},
834 {0x3a0a, 0x00},
835 {0x3a0b, 0xb8},
836 {0x3a0e, 0x03},
837 {0x3a0d, 0x04},
838 #endif
839 {0x3503, 0x00},
840 {0x350c, 0x00},
841 {0x350d, 0x00},
842 {0x3c07, 0x07},
843 {0x3814, 0x31},
844 {0x3815, 0x31},
845 {0x3800, 0x00},
846 {0x3801, 0x00},
847 {0x3802, 0x00},
848 {0x3803, 0xfa},
849 {0x3804, 0x0a},
850 {0x3805, 0x3f},
851 {0x3806, 0x06},
852 {0x3807, 0xa9},
853 {0x3810, 0x00},
854 {0x3811, 0x10},
855 {0x3812, 0x00},
856 {0x3813, 0x04},
857 {0x4002, 0x45},
858 {0x4005, 0x18},
859 {0x3618, 0x00},
860 {0x3612, 0x29},
861 {0x3709, 0x52},
862 {0x370c, 0x03},
863 {0x3a02, 0x02},
864 {0x3a03, 0xe0},
865 {0x3a14, 0x02},
866 {0x3a15, 0xe0},
867 {0x4004, 0x02},
868 {0x3002, 0x1c},
869 {0x3006, 0xc3},
870 {0x460b, 0x37},
871 {0x460c, 0x20},
872 {0x4837, 0x16},
873 {0x5001, 0x83},
874 {0x302c, 0x42},
875 {0x3a18, 0x00},
876 {0x3a19, 0xd8},
877 };
878
879 static struct regval_list sensor_svga_regs[] = {
880 {0x3034, 0x1a},
881 #ifndef FPGA_VER
882 {0x3035, 0x11},
883 #else
884 {0x3035, 0x21},
885 #endif
886 {0x3036, 0x46},
887 {0x3037, 0x13},
888 {0x3108, 0x01},
889 {0x3824, 0x01},
890 {REG_DLY, 0x05},
891 {0x3808, 0x3},
892 {0x3809, 0x20},
893 {0x380a, 0x2},
894 {0x380b, 0x58},
895 {0x380c, 0x07},
896 {0x380d, 0x68},
897 {0x380e, 0x03},
898 {0x380f, 0xd8},
899 #ifndef FPGA_VER
900 {0x3a08, 0x01},
901 {0x3a09, 0x27},
902 {0x3a0a, 0x00},
903 {0x3a0b, 0xf6},
904 {0x3a0e, 0x03},
905 {0x3a0d, 0x04},
906 #else
907 {0x3a08, 0x00},
908 {0x3a09, 0x93},
909 {0x3a0a, 0x00},
910 {0x3a0b, 0x7b},
911 {0x3a0e, 0x06},
912 {0x3a0d, 0x08},
913 #endif
914 {0x3c07, 0x08},
915 {0x3814, 0x31},
916 {0x3815, 0x31},
917 {0x3800, 0x00},
918 {0x3801, 0x00},
919 {0x3802, 0x00},
920 {0x3803, 0x04},
921 {0x3804, 0x0a},
922 {0x3805, 0x3f},
923 {0x3806, 0x07},
924 {0x3807, 0x9b},
925 {0x3810, 0x00},
926 {0x3811, 0x10},
927 {0x3812, 0x00},
928 {0x3813, 0x06},
929 {0x4002, 0x45},
930 {0x4005, 0x18},
931 {0x3618, 0x00},
932 {0x3612, 0x29},
933 {0x3709, 0x52},
934 {0x370c, 0x03},
935 {0x3a02, 0x03},
936 {0x3a03, 0xd8},
937 {0x3a14, 0x03},
938 {0x3a15, 0xd8},
939 {0x4004, 0x02},
940 {0x4837, 0x22},
941 {0x5001, 0xa3},
942 {0x302c, 0x42},
943 };
944
945 static struct regval_list sensor_vga_regs[] = {
946 {0x3820, 0x41},
947 {0x3821, 0x07},
948
949 {0x3034, 0x1a},
950 #ifndef FPGA_VER
951 {0x3035, 0x11},
952 #else
953 {0x3035, 0x41},
954 #endif
955 {0x3036, 0x46},
956 {0x3037, 0x13},
957 {0x3108, 0x01},
958 {0x3824, 0x01},
959 {REG_DLY, 0x05},
960
961 {0x3808, 0x02},
962 {0x3809, 0x80},
963 {0x380a, 0x01},
964 {0x380b, 0xe0},
965 {0x380c, 0x07},
966 {0x380d, 0x68},
967 {0x380e, 0x03},
968 {0x380f, 0xd8},
969 #ifndef FPGA_VER
970 {0x3a08, 0x01},
971 {0x3a09, 0x27},
972 {0x3a0a, 0x00},
973 {0x3a0b, 0xf6},
974 {0x3a0e, 0x03},
975 {0x3a0d, 0x04},
976 #else
977
978 {0x3a08, 0x00},
979 {0x3a09, 0x93},
980 {0x3a0a, 0x00},
981 {0x3a0b, 0x7b},
982 {0x3a0e, 0x06},
983 {0x3a0d, 0x08},
984 #endif
985 {0x3618, 0x00},
986 {0x3612, 0x29},
987 {0x3709, 0x52},
988 {0x370c, 0x03},
989 {0x3a02, 0x03},
990 {0x3a03, 0xd8},
991 {0x3a14, 0x03},
992 {0x3a15, 0xd8},
993 {0x4004, 0x02},
994
995 {0x3503, 0x00},
996 {0x350c, 0x00},
997 {0x350d, 0x00},
998 {0x3c07, 0x08},
999
1000 {0x3814, 0x31},
1001 {0x3815, 0x31},
1002 {0x3800, 0x00},
1003 {0x3801, 0x00},
1004 {0x3802, 0x00},
1005 {0x3803, 0x04},
1006 {0x3804, 0x0a},
1007 {0x3805, 0x3f},
1008 {0x3806, 0x07},
1009 {0x3807, 0x9b},
1010 {0x3810, 0x00},
1011 {0x3811, 0x10},
1012 {0x3812, 0x00},
1013 {0x3813, 0x06},
1014
1015 {0x4002, 0x45},
1016 {0x4005, 0x18},
1017
1018 {0x4837, 0x22},
1019 {0x5001, 0xa3},
1020 #ifndef FPGA_VER
1021 {0x302c, 0x02},
1022 #else
1023 {0x302c, 0x02},
1024 #endif
1025 {0x3a18, 0x00},
1026 {0x3a19, 0xf8},
1027 };
1028
1029 #ifdef AUTO_FPS
1030
1031 static struct regval_list sensor_auto_fps_mode[] = {
1032 {0x3008, 0x42},
1033 {0x3a00, 0x7c},
1034 {0x3a02, 0x07},
1035 {0x3a03, 0xb0},
1036 {0x3a14, 0x07},
1037 {0x3a15, 0xb0},
1038 {0x3008, 0x02},
1039 };
1040
1041
1042 static struct regval_list sensor_fix_fps_mode[] = {
1043 {0x3a00, 0x78},
1044 };
1045 #endif
1046
1047 static struct regval_list sensor_oe_disable_regs[] = {
1048 {0x3017, 0x00},
1049 {0x3018, 0x00},
1050 };
1051
1052 static struct regval_list sensor_oe_enable_regs[] = {
1053 {0x3017, 0x7f},
1054 {0x3018, 0xf0},
1055 };
1056
1057 static struct regval_list sensor_sw_stby_on_regs[] = {
1058 {0x3008, 0x42},
1059 };
1060
1061 static struct regval_list sensor_sw_stby_off_regs[] = {
1062 {0x3008, 0x02},
1063 };
1064
1065 static unsigned char sensor_af_fw_regs[] = {
1066 0x02, 0x0f, 0xd6, 0x02, 0x0a, 0x39, 0xc2, 0x01,
1067 0x22, 0x22, 0x00, 0x02, 0x0f, 0xb2, 0xe5, 0x1f,
1068 0x70, 0x72, 0xf5, 0x1e, 0xd2, 0x35, 0xff, 0xef,
1069 0x25, 0xe0, 0x24, 0x4e, 0xf8, 0xe4, 0xf6, 0x08,
1070 0xf6, 0x0f, 0xbf, 0x34, 0xf2, 0x90, 0x0e, 0x93,
1071 0xe4, 0x93, 0xff, 0xe5, 0x4b, 0xc3, 0x9f, 0x50,
1072 0x04, 0x7f, 0x05, 0x80, 0x02, 0x7f, 0xfb, 0x78,
1073 0xbd, 0xa6, 0x07, 0x12, 0x0f, 0x04, 0x40, 0x04,
1074 0x7f, 0x03, 0x80, 0x02, 0x7f, 0x30, 0x78, 0xbc,
1075 0xa6, 0x07, 0xe6, 0x18, 0xf6, 0x08, 0xe6, 0x78,
1076 0xb9, 0xf6, 0x78, 0xbc, 0xe6, 0x78, 0xba, 0xf6,
1077 0x78, 0xbf, 0x76, 0x33, 0xe4, 0x08, 0xf6, 0x78,
1078 0xb8, 0x76, 0x01, 0x75, 0x4a, 0x02, 0x78, 0xb6,
1079 0xf6, 0x08, 0xf6, 0x74, 0xff, 0x78, 0xc1, 0xf6,
1080 0x08, 0xf6, 0x75, 0x1f, 0x01, 0x78, 0xbc, 0xe6,
1081 0x75, 0xf0, 0x05, 0xa4, 0xf5, 0x4b, 0x12, 0x0a,
1082 0xff, 0xc2, 0x37, 0x22, 0x78, 0xb8, 0xe6, 0xd3,
1083 0x94, 0x00, 0x40, 0x02, 0x16, 0x22, 0xe5, 0x1f,
1084 0xb4, 0x05, 0x23, 0xe4, 0xf5, 0x1f, 0xc2, 0x01,
1085 0x78, 0xb6, 0xe6, 0xfe, 0x08, 0xe6, 0xff, 0x78,
1086 0x4e, 0xa6, 0x06, 0x08, 0xa6, 0x07, 0xa2, 0x37,
1087 0xe4, 0x33, 0xf5, 0x3c, 0x90, 0x30, 0x28, 0xf0,
1088 0x75, 0x1e, 0x10, 0xd2, 0x35, 0x22, 0xe5, 0x4b,
1089 0x75, 0xf0, 0x05, 0x84, 0x78, 0xbc, 0xf6, 0x90,
1090 0x0e, 0x8c, 0xe4, 0x93, 0xff, 0x25, 0xe0, 0x24,
1091 0x0a, 0xf8, 0xe6, 0xfc, 0x08, 0xe6, 0xfd, 0x78,
1092 0xbc, 0xe6, 0x25, 0xe0, 0x24, 0x4e, 0xf8, 0xa6,
1093 0x04, 0x08, 0xa6, 0x05, 0xef, 0x12, 0x0f, 0x0b,
1094 0xd3, 0x78, 0xb7, 0x96, 0xee, 0x18, 0x96, 0x40,
1095 0x0d, 0x78, 0xbc, 0xe6, 0x78, 0xb9, 0xf6, 0x78,
1096 0xb6, 0xa6, 0x06, 0x08, 0xa6, 0x07, 0x90, 0x0e,
1097 0x8c, 0xe4, 0x93, 0x12, 0x0f, 0x0b, 0xc3, 0x78,
1098 0xc2, 0x96, 0xee, 0x18, 0x96, 0x50, 0x0d, 0x78,
1099 0xbc, 0xe6, 0x78, 0xba, 0xf6, 0x78, 0xc1, 0xa6,
1100 0x06, 0x08, 0xa6, 0x07, 0x78, 0xb6, 0xe6, 0xfe,
1101 0x08, 0xe6, 0xc3, 0x78, 0xc2, 0x96, 0xff, 0xee,
1102 0x18, 0x96, 0x78, 0xc3, 0xf6, 0x08, 0xa6, 0x07,
1103 0x90, 0x0e, 0x95, 0xe4, 0x18, 0x12, 0x0e, 0xe9,
1104 0x40, 0x02, 0xd2, 0x37, 0x78, 0xbc, 0xe6, 0x08,
1105 0x26, 0x08, 0xf6, 0xe5, 0x1f, 0x64, 0x01, 0x70,
1106 0x4a, 0xe6, 0xc3, 0x78, 0xc0, 0x12, 0x0e, 0xdf,
1107 0x40, 0x05, 0x12, 0x0e, 0xda, 0x40, 0x39, 0x12,
1108 0x0f, 0x02, 0x40, 0x04, 0x7f, 0xfe, 0x80, 0x02,
1109 0x7f, 0x02, 0x78, 0xbd, 0xa6, 0x07, 0x78, 0xb9,
1110 0xe6, 0x24, 0x03, 0x78, 0xbf, 0xf6, 0x78, 0xb9,
1111 0xe6, 0x24, 0xfd, 0x78, 0xc0, 0xf6, 0x12, 0x0f,
1112 0x02, 0x40, 0x06, 0x78, 0xc0, 0xe6, 0xff, 0x80,
1113 0x04, 0x78, 0xbf, 0xe6, 0xff, 0x78, 0xbe, 0xa6,
1114 0x07, 0x75, 0x1f, 0x02, 0x78, 0xb8, 0x76, 0x01,
1115 0x02, 0x02, 0x4a, 0xe5, 0x1f, 0x64, 0x02, 0x60,
1116 0x03, 0x02, 0x02, 0x2a, 0x78, 0xbe, 0xe6, 0xff,
1117 0xc3, 0x78, 0xc0, 0x12, 0x0e, 0xe0, 0x40, 0x08,
1118 0x12, 0x0e, 0xda, 0x50, 0x03, 0x02, 0x02, 0x28,
1119 0x12, 0x0f, 0x02, 0x40, 0x04, 0x7f, 0xff, 0x80,
1120 0x02, 0x7f, 0x01, 0x78, 0xbd, 0xa6, 0x07, 0x78,
1121 0xb9, 0xe6, 0x04, 0x78, 0xbf, 0xf6, 0x78, 0xb9,
1122 0xe6, 0x14, 0x78, 0xc0, 0xf6, 0x18, 0x12, 0x0f,
1123 0x04, 0x40, 0x04, 0xe6, 0xff, 0x80, 0x02, 0x7f,
1124 0x00, 0x78, 0xbf, 0xa6, 0x07, 0xd3, 0x08, 0xe6,
1125 0x64, 0x80, 0x94, 0x80, 0x40, 0x04, 0xe6, 0xff,
1126 0x80, 0x02, 0x7f, 0x00, 0x78, 0xc0, 0xa6, 0x07,
1127 0xc3, 0x18, 0xe6, 0x64, 0x80, 0x94, 0xb3, 0x50,
1128 0x04, 0xe6, 0xff, 0x80, 0x02, 0x7f, 0x33, 0x78,
1129 0xbf, 0xa6, 0x07, 0xc3, 0x08, 0xe6, 0x64, 0x80,
1130 0x94, 0xb3, 0x50, 0x04, 0xe6, 0xff, 0x80, 0x02,
1131 0x7f, 0x33, 0x78, 0xc0, 0xa6, 0x07, 0x12, 0x0f,
1132 0x02, 0x40, 0x06, 0x78, 0xc0, 0xe6, 0xff, 0x80,
1133 0x04, 0x78, 0xbf, 0xe6, 0xff, 0x78, 0xbe, 0xa6,
1134 0x07, 0x75, 0x1f, 0x03, 0x78, 0xb8, 0x76, 0x01,
1135 0x80, 0x20, 0xe5, 0x1f, 0x64, 0x03, 0x70, 0x26,
1136 0x78, 0xbe, 0xe6, 0xff, 0xc3, 0x78, 0xc0, 0x12,
1137 0x0e, 0xe0, 0x40, 0x05, 0x12, 0x0e, 0xda, 0x40,
1138 0x09, 0x78, 0xb9, 0xe6, 0x78, 0xbe, 0xf6, 0x75,
1139 0x1f, 0x04, 0x78, 0xbe, 0xe6, 0x75, 0xf0, 0x05,
1140 0xa4, 0xf5, 0x4b, 0x02, 0x0a, 0xff, 0xe5, 0x1f,
1141 0xb4, 0x04, 0x10, 0x90, 0x0e, 0x94, 0xe4, 0x78,
1142 0xc3, 0x12, 0x0e, 0xe9, 0x40, 0x02, 0xd2, 0x37,
1143 0x75, 0x1f, 0x05, 0x22, 0x30, 0x01, 0x03, 0x02,
1144 0x04, 0xc0, 0x30, 0x02, 0x03, 0x02, 0x04, 0xc0,
1145 0x90, 0x51, 0xa5, 0xe0, 0x78, 0x93, 0xf6, 0xa3,
1146 0xe0, 0x08, 0xf6, 0xa3, 0xe0, 0x08, 0xf6, 0xe5,
1147 0x1f, 0x70, 0x3c, 0x75, 0x1e, 0x20, 0xd2, 0x35,
1148 0x12, 0x0c, 0x7a, 0x78, 0x7e, 0xa6, 0x06, 0x08,
1149 0xa6, 0x07, 0x78, 0x8b, 0xa6, 0x09, 0x18, 0x76,
1150 0x01, 0x12, 0x0c, 0x5b, 0x78, 0x4e, 0xa6, 0x06,
1151 0x08, 0xa6, 0x07, 0x78, 0x8b, 0xe6, 0x78, 0x6e,
1152 0xf6, 0x75, 0x1f, 0x01, 0x78, 0x93, 0xe6, 0x78,
1153 0x90, 0xf6, 0x78, 0x94, 0xe6, 0x78, 0x91, 0xf6,
1154 0x78, 0x95, 0xe6, 0x78, 0x92, 0xf6, 0x22, 0x79,
1155 0x90, 0xe7, 0xd3, 0x78, 0x93, 0x96, 0x40, 0x05,
1156 0xe7, 0x96, 0xff, 0x80, 0x08, 0xc3, 0x79, 0x93,
1157 0xe7, 0x78, 0x90, 0x96, 0xff, 0x78, 0x88, 0x76,
1158 0x00, 0x08, 0xa6, 0x07, 0x79, 0x91, 0xe7, 0xd3,
1159 0x78, 0x94, 0x96, 0x40, 0x05, 0xe7, 0x96, 0xff,
1160 0x80, 0x08, 0xc3, 0x79, 0x94, 0xe7, 0x78, 0x91,
1161 0x96, 0xff, 0x12, 0x0c, 0x8e, 0x79, 0x92, 0xe7,
1162 0xd3, 0x78, 0x95, 0x96, 0x40, 0x05, 0xe7, 0x96,
1163 0xff, 0x80, 0x08, 0xc3, 0x79, 0x95, 0xe7, 0x78,
1164 0x92, 0x96, 0xff, 0x12, 0x0c, 0x8e, 0x12, 0x0c,
1165 0x5b, 0x78, 0x8a, 0xe6, 0x25, 0xe0, 0x24, 0x4e,
1166 0xf8, 0xa6, 0x06, 0x08, 0xa6, 0x07, 0x78, 0x8a,
1167 0xe6, 0x24, 0x6e, 0xf8, 0xa6, 0x09, 0x78, 0x8a,
1168 0xe6, 0x24, 0x01, 0xff, 0xe4, 0x33, 0xfe, 0xd3,
1169 0xef, 0x94, 0x0f, 0xee, 0x64, 0x80, 0x94, 0x80,
1170 0x40, 0x04, 0x7f, 0x00, 0x80, 0x05, 0x78, 0x8a,
1171 0xe6, 0x04, 0xff, 0x78, 0x8a, 0xa6, 0x07, 0xe5,
1172 0x1f, 0xb4, 0x01, 0x0a, 0xe6, 0x60, 0x03, 0x02,
1173 0x04, 0xc0, 0x75, 0x1f, 0x02, 0x22, 0x12, 0x0c,
1174 0x7a, 0x78, 0x80, 0xa6, 0x06, 0x08, 0xa6, 0x07,
1175 0x12, 0x0c, 0x7a, 0x78, 0x82, 0xa6, 0x06, 0x08,
1176 0xa6, 0x07, 0x78, 0x6e, 0xe6, 0x78, 0x8c, 0xf6,
1177 0x78, 0x6e, 0xe6, 0x78, 0x8d, 0xf6, 0x7f, 0x01,
1178 0xef, 0x25, 0xe0, 0x24, 0x4f, 0xf9, 0xc3, 0x78,
1179 0x81, 0xe6, 0x97, 0x18, 0xe6, 0x19, 0x97, 0x50,
1180 0x0a, 0x12, 0x0c, 0x82, 0x78, 0x80, 0xa6, 0x04,
1181 0x08, 0xa6, 0x05, 0x74, 0x6e, 0x2f, 0xf9, 0x78,
1182 0x8c, 0xe6, 0xc3, 0x97, 0x50, 0x08, 0x74, 0x6e,
1183 0x2f, 0xf8, 0xe6, 0x78, 0x8c, 0xf6, 0xef, 0x25,
1184 0xe0, 0x24, 0x4f, 0xf9, 0xd3, 0x78, 0x83, 0xe6,
1185 0x97, 0x18, 0xe6, 0x19, 0x97, 0x40, 0x0a, 0x12,
1186 0x0c, 0x82, 0x78, 0x82, 0xa6, 0x04, 0x08, 0xa6,
1187 0x05, 0x74, 0x6e, 0x2f, 0xf9, 0x78, 0x8d, 0xe6,
1188 0xd3, 0x97, 0x40, 0x08, 0x74, 0x6e, 0x2f, 0xf8,
1189 0xe6, 0x78, 0x8d, 0xf6, 0x0f, 0xef, 0x64, 0x10,
1190 0x70, 0x9e, 0xc3, 0x79, 0x81, 0xe7, 0x78, 0x83,
1191 0x96, 0xff, 0x19, 0xe7, 0x18, 0x96, 0x78, 0x84,
1192 0xf6, 0x08, 0xa6, 0x07, 0xc3, 0x79, 0x8c, 0xe7,
1193 0x78, 0x8d, 0x96, 0x08, 0xf6, 0xd3, 0x79, 0x81,
1194 0xe7, 0x78, 0x7f, 0x96, 0x19, 0xe7, 0x18, 0x96,
1195 0x40, 0x05, 0x09, 0xe7, 0x08, 0x80, 0x06, 0xc3,
1196 0x79, 0x7f, 0xe7, 0x78, 0x81, 0x96, 0xff, 0x19,
1197 0xe7, 0x18, 0x96, 0xfe, 0x78, 0x86, 0xa6, 0x06,
1198 0x08, 0xa6, 0x07, 0x79, 0x8c, 0xe7, 0xd3, 0x78,
1199 0x8b, 0x96, 0x40, 0x05, 0xe7, 0x96, 0xff, 0x80,
1200 0x08, 0xc3, 0x79, 0x8b, 0xe7, 0x78, 0x8c, 0x96,
1201 0xff, 0x78, 0x8f, 0xa6, 0x07, 0xe5, 0x1f, 0x64,
1202 0x02, 0x70, 0x69, 0x90, 0x0e, 0x91, 0x93, 0xff,
1203 0x18, 0xe6, 0xc3, 0x9f, 0x50, 0x72, 0x12, 0x0c,
1204 0x4a, 0x12, 0x0c, 0x2f, 0x90, 0x0e, 0x8e, 0x12,
1205 0x0c, 0x38, 0x78, 0x80, 0x12, 0x0c, 0x6b, 0x7b,
1206 0x04, 0x12, 0x0c, 0x1d, 0xc3, 0x12, 0x06, 0x45,
1207 0x50, 0x56, 0x90, 0x0e, 0x92, 0xe4, 0x93, 0xff,
1208 0x78, 0x8f, 0xe6, 0x9f, 0x40, 0x02, 0x80, 0x11,
1209 0x90, 0x0e, 0x90, 0xe4, 0x93, 0xff, 0xd3, 0x78,
1210 0x89, 0xe6, 0x9f, 0x18, 0xe6, 0x94, 0x00, 0x40,
1211 0x03, 0x75, 0x1f, 0x05, 0x12, 0x0c, 0x4a, 0x12,
1212 0x0c, 0x2f, 0x90, 0x0e, 0x8f, 0x12, 0x0c, 0x38,
1213 0x78, 0x7e, 0x12, 0x0c, 0x6b, 0x7b, 0x40, 0x12,
1214 0x0c, 0x1d, 0xd3, 0x12, 0x06, 0x45, 0x40, 0x18,
1215 0x75, 0x1f, 0x05, 0x22, 0xe5, 0x1f, 0xb4, 0x05,
1216 0x0f, 0xd2, 0x01, 0xc2, 0x02, 0xe4, 0xf5, 0x1f,
1217 0xf5, 0x1e, 0xd2, 0x35, 0xd2, 0x33, 0xd2, 0x36,
1218 0x22, 0xef, 0x8d, 0xf0, 0xa4, 0xa8, 0xf0, 0xcf,
1219 0x8c, 0xf0, 0xa4, 0x28, 0xce, 0x8d, 0xf0, 0xa4,
1220 0x2e, 0xfe, 0x22, 0xbc, 0x00, 0x0b, 0xbe, 0x00,
1221 0x29, 0xef, 0x8d, 0xf0, 0x84, 0xff, 0xad, 0xf0,
1222 0x22, 0xe4, 0xcc, 0xf8, 0x75, 0xf0, 0x08, 0xef,
1223 0x2f, 0xff, 0xee, 0x33, 0xfe, 0xec, 0x33, 0xfc,
1224 0xee, 0x9d, 0xec, 0x98, 0x40, 0x05, 0xfc, 0xee,
1225 0x9d, 0xfe, 0x0f, 0xd5, 0xf0, 0xe9, 0xe4, 0xce,
1226 0xfd, 0x22, 0xed, 0xf8, 0xf5, 0xf0, 0xee, 0x84,
1227 0x20, 0xd2, 0x1c, 0xfe, 0xad, 0xf0, 0x75, 0xf0,
1228 0x08, 0xef, 0x2f, 0xff, 0xed, 0x33, 0xfd, 0x40,
1229 0x07, 0x98, 0x50, 0x06, 0xd5, 0xf0, 0xf2, 0x22,
1230 0xc3, 0x98, 0xfd, 0x0f, 0xd5, 0xf0, 0xea, 0x22,
1231 0xe8, 0x8f, 0xf0, 0xa4, 0xcc, 0x8b, 0xf0, 0xa4,
1232 0x2c, 0xfc, 0xe9, 0x8e, 0xf0, 0xa4, 0x2c, 0xfc,
1233 0x8a, 0xf0, 0xed, 0xa4, 0x2c, 0xfc, 0xea, 0x8e,
1234 0xf0, 0xa4, 0xcd, 0xa8, 0xf0, 0x8b, 0xf0, 0xa4,
1235 0x2d, 0xcc, 0x38, 0x25, 0xf0, 0xfd, 0xe9, 0x8f,
1236 0xf0, 0xa4, 0x2c, 0xcd, 0x35, 0xf0, 0xfc, 0xeb,
1237 0x8e, 0xf0, 0xa4, 0xfe, 0xa9, 0xf0, 0xeb, 0x8f,
1238 0xf0, 0xa4, 0xcf, 0xc5, 0xf0, 0x2e, 0xcd, 0x39,
1239 0xfe, 0xe4, 0x3c, 0xfc, 0xea, 0xa4, 0x2d, 0xce,
1240 0x35, 0xf0, 0xfd, 0xe4, 0x3c, 0xfc, 0x22, 0x75,
1241 0xf0, 0x08, 0x75, 0x82, 0x00, 0xef, 0x2f, 0xff,
1242 0xee, 0x33, 0xfe, 0xcd, 0x33, 0xcd, 0xcc, 0x33,
1243 0xcc, 0xc5, 0x82, 0x33, 0xc5, 0x82, 0x9b, 0xed,
1244 0x9a, 0xec, 0x99, 0xe5, 0x82, 0x98, 0x40, 0x0c,
1245 0xf5, 0x82, 0xee, 0x9b, 0xfe, 0xed, 0x9a, 0xfd,
1246 0xec, 0x99, 0xfc, 0x0f, 0xd5, 0xf0, 0xd6, 0xe4,
1247 0xce, 0xfb, 0xe4, 0xcd, 0xfa, 0xe4, 0xcc, 0xf9,
1248 0xa8, 0x82, 0x22, 0xb8, 0x00, 0xc1, 0xb9, 0x00,
1249 0x59, 0xba, 0x00, 0x2d, 0xec, 0x8b, 0xf0, 0x84,
1250 0xcf, 0xce, 0xcd, 0xfc, 0xe5, 0xf0, 0xcb, 0xf9,
1251 0x78, 0x18, 0xef, 0x2f, 0xff, 0xee, 0x33, 0xfe,
1252 0xed, 0x33, 0xfd, 0xec, 0x33, 0xfc, 0xeb, 0x33,
1253 0xfb, 0x10, 0xd7, 0x03, 0x99, 0x40, 0x04, 0xeb,
1254 0x99, 0xfb, 0x0f, 0xd8, 0xe5, 0xe4, 0xf9, 0xfa,
1255 0x22, 0x78, 0x18, 0xef, 0x2f, 0xff, 0xee, 0x33,
1256 0xfe, 0xed, 0x33, 0xfd, 0xec, 0x33, 0xfc, 0xc9,
1257 0x33, 0xc9, 0x10, 0xd7, 0x05, 0x9b, 0xe9, 0x9a,
1258 0x40, 0x07, 0xec, 0x9b, 0xfc, 0xe9, 0x9a, 0xf9,
1259 0x0f, 0xd8, 0xe0, 0xe4, 0xc9, 0xfa, 0xe4, 0xcc,
1260 0xfb, 0x22, 0x75, 0xf0, 0x10, 0xef, 0x2f, 0xff,
1261 0xee, 0x33, 0xfe, 0xed, 0x33, 0xfd, 0xcc, 0x33,
1262 0xcc, 0xc8, 0x33, 0xc8, 0x10, 0xd7, 0x07, 0x9b,
1263 0xec, 0x9a, 0xe8, 0x99, 0x40, 0x0a, 0xed, 0x9b,
1264 0xfd, 0xec, 0x9a, 0xfc, 0xe8, 0x99, 0xf8, 0x0f,
1265 0xd5, 0xf0, 0xda, 0xe4, 0xcd, 0xfb, 0xe4, 0xcc,
1266 0xfa, 0xe4, 0xc8, 0xf9, 0x22, 0xeb, 0x9f, 0xf5,
1267 0xf0, 0xea, 0x9e, 0x42, 0xf0, 0xe9, 0x9d, 0x42,
1268 0xf0, 0xe8, 0x9c, 0x45, 0xf0, 0x22, 0xe8, 0x60,
1269 0x0f, 0xec, 0xc3, 0x13, 0xfc, 0xed, 0x13, 0xfd,
1270 0xee, 0x13, 0xfe, 0xef, 0x13, 0xff, 0xd8, 0xf1,
1271 0x22, 0xe8, 0x60, 0x0f, 0xef, 0xc3, 0x33, 0xff,
1272 0xee, 0x33, 0xfe, 0xed, 0x33, 0xfd, 0xec, 0x33,
1273 0xfc, 0xd8, 0xf1, 0x22, 0xe4, 0x93, 0xfc, 0x74,
1274 0x01, 0x93, 0xfd, 0x74, 0x02, 0x93, 0xfe, 0x74,
1275 0x03, 0x93, 0xff, 0x22, 0xe6, 0xfb, 0x08, 0xe6,
1276 0xf9, 0x08, 0xe6, 0xfa, 0x08, 0xe6, 0xcb, 0xf8,
1277 0x22, 0xec, 0xf6, 0x08, 0xed, 0xf6, 0x08, 0xee,
1278 0xf6, 0x08, 0xef, 0xf6, 0x22, 0xa4, 0x25, 0x82,
1279 0xf5, 0x82, 0xe5, 0xf0, 0x35, 0x83, 0xf5, 0x83,
1280 0x22, 0xd0, 0x83, 0xd0, 0x82, 0xf8, 0xe4, 0x93,
1281 0x70, 0x12, 0x74, 0x01, 0x93, 0x70, 0x0d, 0xa3,
1282 0xa3, 0x93, 0xf8, 0x74, 0x01, 0x93, 0xf5, 0x82,
1283 0x88, 0x83, 0xe4, 0x73, 0x74, 0x02, 0x93, 0x68,
1284 0x60, 0xef, 0xa3, 0xa3, 0xa3, 0x80, 0xdf, 0x90,
1285 0x38, 0x04, 0x78, 0x52, 0x12, 0x0b, 0xfd, 0x90,
1286 0x38, 0x00, 0xe0, 0xfe, 0xa3, 0xe0, 0xfd, 0xed,
1287 0xff, 0xc3, 0x12, 0x0b, 0x9e, 0x90, 0x38, 0x10,
1288 0x12, 0x0b, 0x92, 0x90, 0x38, 0x06, 0x78, 0x54,
1289 0x12, 0x0b, 0xfd, 0x90, 0x38, 0x02, 0xe0, 0xfe,
1290 0xa3, 0xe0, 0xfd, 0xed, 0xff, 0xc3, 0x12, 0x0b,
1291 0x9e, 0x90, 0x38, 0x12, 0x12, 0x0b, 0x92, 0xa3,
1292 0xe0, 0xb4, 0x31, 0x07, 0x78, 0x52, 0x79, 0x52,
1293 0x12, 0x0c, 0x13, 0x90, 0x38, 0x14, 0xe0, 0xb4,
1294 0x71, 0x15, 0x78, 0x52, 0xe6, 0xfe, 0x08, 0xe6,
1295 0x78, 0x02, 0xce, 0xc3, 0x13, 0xce, 0x13, 0xd8,
1296 0xf9, 0x79, 0x53, 0xf7, 0xee, 0x19, 0xf7, 0x90,
1297 0x38, 0x15, 0xe0, 0xb4, 0x31, 0x07, 0x78, 0x54,
1298 0x79, 0x54, 0x12, 0x0c, 0x13, 0x90, 0x38, 0x15,
1299 0xe0, 0xb4, 0x71, 0x15, 0x78, 0x54, 0xe6, 0xfe,
1300 0x08, 0xe6, 0x78, 0x02, 0xce, 0xc3, 0x13, 0xce,
1301 0x13, 0xd8, 0xf9, 0x79, 0x55, 0xf7, 0xee, 0x19,
1302 0xf7, 0x79, 0x52, 0x12, 0x0b, 0xd9, 0x09, 0x12,
1303 0x0b, 0xd9, 0xaf, 0x47, 0x12, 0x0b, 0xb2, 0xe5,
1304 0x44, 0xfb, 0x7a, 0x00, 0xfd, 0x7c, 0x00, 0x12,
1305 0x04, 0xd3, 0x78, 0x5a, 0xa6, 0x06, 0x08, 0xa6,
1306 0x07, 0xaf, 0x45, 0x12, 0x0b, 0xb2, 0xad, 0x03,
1307 0x7c, 0x00, 0x12, 0x04, 0xd3, 0x78, 0x56, 0xa6,
1308 0x06, 0x08, 0xa6, 0x07, 0xaf, 0x48, 0x78, 0x54,
1309 0x12, 0x0b, 0xb4, 0xe5, 0x43, 0xfb, 0xfd, 0x7c,
1310 0x00, 0x12, 0x04, 0xd3, 0x78, 0x5c, 0xa6, 0x06,
1311 0x08, 0xa6, 0x07, 0xaf, 0x46, 0x7e, 0x00, 0x78,
1312 0x54, 0x12, 0x0b, 0xb6, 0xad, 0x03, 0x7c, 0x00,
1313 0x12, 0x04, 0xd3, 0x78, 0x58, 0xa6, 0x06, 0x08,
1314 0xa6, 0x07, 0xc3, 0x78, 0x5b, 0xe6, 0x94, 0x08,
1315 0x18, 0xe6, 0x94, 0x00, 0x50, 0x05, 0x76, 0x00,
1316 0x08, 0x76, 0x08, 0xc3, 0x78, 0x5d, 0xe6, 0x94,
1317 0x08, 0x18, 0xe6, 0x94, 0x00, 0x50, 0x05, 0x76,
1318 0x00, 0x08, 0x76, 0x08, 0x78, 0x5a, 0x12, 0x0b,
1319 0xc6, 0xff, 0xd3, 0x78, 0x57, 0xe6, 0x9f, 0x18,
1320 0xe6, 0x9e, 0x40, 0x0e, 0x78, 0x5a, 0xe6, 0x13,
1321 0xfe, 0x08, 0xe6, 0x78, 0x57, 0x12, 0x0c, 0x08,
1322 0x80, 0x04, 0x7e, 0x00, 0x7f, 0x00, 0x78, 0x5e,
1323 0x12, 0x0b, 0xbe, 0xff, 0xd3, 0x78, 0x59, 0xe6,
1324 0x9f, 0x18, 0xe6, 0x9e, 0x40, 0x0e, 0x78, 0x5c,
1325 0xe6, 0x13, 0xfe, 0x08, 0xe6, 0x78, 0x59, 0x12,
1326 0x0c, 0x08, 0x80, 0x04, 0x7e, 0x00, 0x7f, 0x00,
1327 0xe4, 0xfc, 0xfd, 0x78, 0x62, 0x12, 0x06, 0x99,
1328 0x78, 0x5a, 0x12, 0x0b, 0xc6, 0x78, 0x57, 0x26,
1329 0xff, 0xee, 0x18, 0x36, 0xfe, 0x78, 0x66, 0x12,
1330 0x0b, 0xbe, 0x78, 0x59, 0x26, 0xff, 0xee, 0x18,
1331 0x36, 0xfe, 0xe4, 0xfc, 0xfd, 0x78, 0x6a, 0x12,
1332 0x06, 0x99, 0x12, 0x0b, 0xce, 0x78, 0x66, 0x12,
1333 0x06, 0x8c, 0xd3, 0x12, 0x06, 0x45, 0x40, 0x08,
1334 0x12, 0x0b, 0xce, 0x78, 0x66, 0x12, 0x06, 0x99,
1335 0x78, 0x54, 0x12, 0x0b, 0xd0, 0x78, 0x6a, 0x12,
1336 0x06, 0x8c, 0xd3, 0x12, 0x06, 0x45, 0x40, 0x0a,
1337 0x78, 0x54, 0x12, 0x0b, 0xd0, 0x78, 0x6a, 0x12,
1338 0x06, 0x99, 0x78, 0x61, 0xe6, 0x90, 0x60, 0x01,
1339 0xf0, 0x78, 0x65, 0xe6, 0xa3, 0xf0, 0x78, 0x69,
1340 0xe6, 0xa3, 0xf0, 0x78, 0x55, 0xe6, 0xa3, 0xf0,
1341 0x7d, 0x01, 0x78, 0x61, 0x12, 0x0b, 0xe9, 0x24,
1342 0x01, 0x12, 0x0b, 0xa6, 0x78, 0x65, 0x12, 0x0b,
1343 0xe9, 0x24, 0x02, 0x12, 0x0b, 0xa6, 0x78, 0x69,
1344 0x12, 0x0b, 0xe9, 0x24, 0x03, 0x12, 0x0b, 0xa6,
1345 0x78, 0x6d, 0x12, 0x0b, 0xe9, 0x24, 0x04, 0x12,
1346 0x0b, 0xa6, 0x0d, 0xbd, 0x05, 0xd4, 0xc2, 0x0e,
1347 0xc2, 0x06, 0x22, 0x85, 0x08, 0x41, 0x90, 0x30,
1348 0x24, 0xe0, 0xf5, 0x3d, 0xa3, 0xe0, 0xf5, 0x3e,
1349 0xa3, 0xe0, 0xf5, 0x3f, 0xa3, 0xe0, 0xf5, 0x40,
1350 0xa3, 0xe0, 0xf5, 0x3c, 0xd2, 0x34, 0xe5, 0x41,
1351 0x12, 0x06, 0xb1, 0x09, 0x31, 0x03, 0x09, 0x35,
1352 0x04, 0x09, 0x3b, 0x05, 0x09, 0x3e, 0x06, 0x09,
1353 0x41, 0x07, 0x09, 0x4a, 0x08, 0x09, 0x5b, 0x12,
1354 0x09, 0x73, 0x18, 0x09, 0x89, 0x19, 0x09, 0x5e,
1355 0x1a, 0x09, 0x6a, 0x1b, 0x09, 0xad, 0x80, 0x09,
1356 0xb2, 0x81, 0x0a, 0x1d, 0x8f, 0x0a, 0x09, 0x90,
1357 0x0a, 0x1d, 0x91, 0x0a, 0x1d, 0x92, 0x0a, 0x1d,
1358 0x93, 0x0a, 0x1d, 0x94, 0x0a, 0x1d, 0x98, 0x0a,
1359 0x17, 0x9f, 0x0a, 0x1a, 0xec, 0x00, 0x00, 0x0a,
1360 0x38, 0x12, 0x0f, 0x74, 0x22, 0x12, 0x0f, 0x74,
1361 0xd2, 0x03, 0x22, 0xd2, 0x03, 0x22, 0xc2, 0x03,
1362 0x22, 0xa2, 0x37, 0xe4, 0x33, 0xf5, 0x3c, 0x02,
1363 0x0a, 0x1d, 0xc2, 0x01, 0xc2, 0x02, 0xc2, 0x03,
1364 0x12, 0x0d, 0x0d, 0x75, 0x1e, 0x70, 0xd2, 0x35,
1365 0x02, 0x0a, 0x1d, 0x02, 0x0a, 0x04, 0x85, 0x40,
1366 0x4a, 0x85, 0x3c, 0x4b, 0x12, 0x0a, 0xff, 0x02,
1367 0x0a, 0x1d, 0x85, 0x4a, 0x40, 0x85, 0x4b, 0x3c,
1368 0x02, 0x0a, 0x1d, 0xe4, 0xf5, 0x22, 0xf5, 0x23,
1369 0x85, 0x40, 0x31, 0x85, 0x3f, 0x30, 0x85, 0x3e,
1370 0x2f, 0x85, 0x3d, 0x2e, 0x12, 0x0f, 0x46, 0x80,
1371 0x1f, 0x75, 0x22, 0x00, 0x75, 0x23, 0x01, 0x74,
1372 0xff, 0xf5, 0x2d, 0xf5, 0x2c, 0xf5, 0x2b, 0xf5,
1373 0x2a, 0x12, 0x0f, 0x46, 0x85, 0x2d, 0x40, 0x85,
1374 0x2c, 0x3f, 0x85, 0x2b, 0x3e, 0x85, 0x2a, 0x3d,
1375 0xe4, 0xf5, 0x3c, 0x80, 0x70, 0x12, 0x0f, 0x16,
1376 0x80, 0x6b, 0x85, 0x3d, 0x45, 0x85, 0x3e, 0x46,
1377 0xe5, 0x47, 0xc3, 0x13, 0xff, 0xe5, 0x45, 0xc3,
1378 0x9f, 0x50, 0x02, 0x8f, 0x45, 0xe5, 0x48, 0xc3,
1379 0x13, 0xff, 0xe5, 0x46, 0xc3, 0x9f, 0x50, 0x02,
1380 0x8f, 0x46, 0xe5, 0x47, 0xc3, 0x13, 0xff, 0xfd,
1381 0xe5, 0x45, 0x2d, 0xfd, 0xe4, 0x33, 0xfc, 0xe5,
1382 0x44, 0x12, 0x0f, 0x90, 0x40, 0x05, 0xe5, 0x44,
1383 0x9f, 0xf5, 0x45, 0xe5, 0x48, 0xc3, 0x13, 0xff,
1384 0xfd, 0xe5, 0x46, 0x2d, 0xfd, 0xe4, 0x33, 0xfc,
1385 0xe5, 0x43, 0x12, 0x0f, 0x90, 0x40, 0x05, 0xe5,
1386 0x43, 0x9f, 0xf5, 0x46, 0x12, 0x06, 0xd7, 0x80,
1387 0x14, 0x85, 0x40, 0x48, 0x85, 0x3f, 0x47, 0x85,
1388 0x3e, 0x46, 0x85, 0x3d, 0x45, 0x80, 0x06, 0x02,
1389 0x06, 0xd7, 0x12, 0x0d, 0x7e, 0x90, 0x30, 0x24,
1390 0xe5, 0x3d, 0xf0, 0xa3, 0xe5, 0x3e, 0xf0, 0xa3,
1391 0xe5, 0x3f, 0xf0, 0xa3, 0xe5, 0x40, 0xf0, 0xa3,
1392 0xe5, 0x3c, 0xf0, 0x90, 0x30, 0x23, 0xe4, 0xf0,
1393 0x22, 0xc0, 0xe0, 0xc0, 0x83, 0xc0, 0x82, 0xc0,
1394 0xd0, 0x90, 0x3f, 0x0c, 0xe0, 0xf5, 0x32, 0xe5,
1395 0x32, 0x30, 0xe3, 0x74, 0x30, 0x36, 0x66, 0x90,
1396 0x60, 0x19, 0xe0, 0xf5, 0x0a, 0xa3, 0xe0, 0xf5,
1397 0x0b, 0x90, 0x60, 0x1d, 0xe0, 0xf5, 0x14, 0xa3,
1398 0xe0, 0xf5, 0x15, 0x90, 0x60, 0x21, 0xe0, 0xf5,
1399 0x0c, 0xa3, 0xe0, 0xf5, 0x0d, 0x90, 0x60, 0x29,
1400 0xe0, 0xf5, 0x0e, 0xa3, 0xe0, 0xf5, 0x0f, 0x90,
1401 0x60, 0x31, 0xe0, 0xf5, 0x10, 0xa3, 0xe0, 0xf5,
1402 0x11, 0x90, 0x60, 0x39, 0xe0, 0xf5, 0x12, 0xa3,
1403 0xe0, 0xf5, 0x13, 0x30, 0x01, 0x06, 0x30, 0x33,
1404 0x03, 0xd3, 0x80, 0x01, 0xc3, 0x92, 0x09, 0x30,
1405 0x02, 0x06, 0x30, 0x33, 0x03, 0xd3, 0x80, 0x01,
1406 0xc3, 0x92, 0x0a, 0x30, 0x33, 0x0c, 0x30, 0x03,
1407 0x09, 0x20, 0x02, 0x06, 0x20, 0x01, 0x03, 0xd3,
1408 0x80, 0x01, 0xc3, 0x92, 0x0b, 0x90, 0x30, 0x01,
1409 0xe0, 0x44, 0x40, 0xf0, 0xe0, 0x54, 0xbf, 0xf0,
1410 0xe5, 0x32, 0x30, 0xe1, 0x14, 0x30, 0x34, 0x11,
1411 0x90, 0x30, 0x22, 0xe0, 0xf5, 0x08, 0xe4, 0xf0,
1412 0x30, 0x00, 0x03, 0xd3, 0x80, 0x01, 0xc3, 0x92,
1413 0x08, 0xe5, 0x32, 0x30, 0xe5, 0x12, 0x90, 0x56,
1414 0xa1, 0xe0, 0xf5, 0x09, 0x30, 0x31, 0x09, 0x30,
1415 0x05, 0x03, 0xd3, 0x80, 0x01, 0xc3, 0x92, 0x0d,
1416 0x90, 0x3f, 0x0c, 0xe5, 0x32, 0xf0, 0xd0, 0xd0,
1417 0xd0, 0x82, 0xd0, 0x83, 0xd0, 0xe0, 0x32, 0x90,
1418 0x0e, 0x7e, 0xe4, 0x93, 0xfe, 0x74, 0x01, 0x93,
1419 0xff, 0xc3, 0x90, 0x0e, 0x7c, 0x74, 0x01, 0x93,
1420 0x9f, 0xff, 0xe4, 0x93, 0x9e, 0xfe, 0xe4, 0x8f,
1421 0x3b, 0x8e, 0x3a, 0xf5, 0x39, 0xf5, 0x38, 0xab,
1422 0x3b, 0xaa, 0x3a, 0xa9, 0x39, 0xa8, 0x38, 0xaf,
1423 0x4b, 0xfc, 0xfd, 0xfe, 0x12, 0x05, 0x28, 0x12,
1424 0x0d, 0xe1, 0xe4, 0x7b, 0xff, 0xfa, 0xf9, 0xf8,
1425 0x12, 0x05, 0xb3, 0x12, 0x0d, 0xe1, 0x90, 0x0e,
1426 0x69, 0xe4, 0x12, 0x0d, 0xf6, 0x12, 0x0d, 0xe1,
1427 0xe4, 0x85, 0x4a, 0x37, 0xf5, 0x36, 0xf5, 0x35,
1428 0xf5, 0x34, 0xaf, 0x37, 0xae, 0x36, 0xad, 0x35,
1429 0xac, 0x34, 0xa3, 0x12, 0x0d, 0xf6, 0x8f, 0x37,
1430 0x8e, 0x36, 0x8d, 0x35, 0x8c, 0x34, 0xe5, 0x3b,
1431 0x45, 0x37, 0xf5, 0x3b, 0xe5, 0x3a, 0x45, 0x36,
1432 0xf5, 0x3a, 0xe5, 0x39, 0x45, 0x35, 0xf5, 0x39,
1433 0xe5, 0x38, 0x45, 0x34, 0xf5, 0x38, 0xe4, 0xf5,
1434 0x22, 0xf5, 0x23, 0x85, 0x3b, 0x31, 0x85, 0x3a,
1435 0x30, 0x85, 0x39, 0x2f, 0x85, 0x38, 0x2e, 0x02,
1436 0x0f, 0x46, 0xe0, 0xa3, 0xe0, 0x75, 0xf0, 0x02,
1437 0xa4, 0xff, 0xae, 0xf0, 0xc3, 0x08, 0xe6, 0x9f,
1438 0xf6, 0x18, 0xe6, 0x9e, 0xf6, 0x22, 0xff, 0xe5,
1439 0xf0, 0x34, 0x60, 0x8f, 0x82, 0xf5, 0x83, 0xec,
1440 0xf0, 0x22, 0x78, 0x52, 0x7e, 0x00, 0xe6, 0xfc,
1441 0x08, 0xe6, 0xfd, 0x02, 0x04, 0xc1, 0xe4, 0xfc,
1442 0xfd, 0x12, 0x06, 0x99, 0x78, 0x5c, 0xe6, 0xc3,
1443 0x13, 0xfe, 0x08, 0xe6, 0x13, 0x22, 0x78, 0x52,
1444 0xe6, 0xfe, 0x08, 0xe6, 0xff, 0xe4, 0xfc, 0xfd,
1445 0x22, 0xe7, 0xc4, 0xf8, 0x54, 0xf0, 0xc8, 0x68,
1446 0xf7, 0x09, 0xe7, 0xc4, 0x54, 0x0f, 0x48, 0xf7,
1447 0x22, 0xe6, 0xfc, 0xed, 0x75, 0xf0, 0x04, 0xa4,
1448 0x22, 0x12, 0x06, 0x7c, 0x8f, 0x48, 0x8e, 0x47,
1449 0x8d, 0x46, 0x8c, 0x45, 0x22, 0xe0, 0xfe, 0xa3,
1450 0xe0, 0xfd, 0xee, 0xf6, 0xed, 0x08, 0xf6, 0x22,
1451 0x13, 0xff, 0xc3, 0xe6, 0x9f, 0xff, 0x18, 0xe6,
1452 0x9e, 0xfe, 0x22, 0xe6, 0xc3, 0x13, 0xf7, 0x08,
1453 0xe6, 0x13, 0x09, 0xf7, 0x22, 0xad, 0x39, 0xac,
1454 0x38, 0xfa, 0xf9, 0xf8, 0x12, 0x05, 0x28, 0x8f,
1455 0x3b, 0x8e, 0x3a, 0x8d, 0x39, 0x8c, 0x38, 0xab,
1456 0x37, 0xaa, 0x36, 0xa9, 0x35, 0xa8, 0x34, 0x22,
1457 0x93, 0xff, 0xe4, 0xfc, 0xfd, 0xfe, 0x12, 0x05,
1458 0x28, 0x8f, 0x37, 0x8e, 0x36, 0x8d, 0x35, 0x8c,
1459 0x34, 0x22, 0x78, 0x84, 0xe6, 0xfe, 0x08, 0xe6,
1460 0xff, 0xe4, 0x8f, 0x37, 0x8e, 0x36, 0xf5, 0x35,
1461 0xf5, 0x34, 0x22, 0x90, 0x0e, 0x8c, 0xe4, 0x93,
1462 0x25, 0xe0, 0x24, 0x0a, 0xf8, 0xe6, 0xfe, 0x08,
1463 0xe6, 0xff, 0x22, 0xe6, 0xfe, 0x08, 0xe6, 0xff,
1464 0xe4, 0x8f, 0x3b, 0x8e, 0x3a, 0xf5, 0x39, 0xf5,
1465 0x38, 0x22, 0x78, 0x4e, 0xe6, 0xfe, 0x08, 0xe6,
1466 0xff, 0x22, 0xef, 0x25, 0xe0, 0x24, 0x4e, 0xf8,
1467 0xe6, 0xfc, 0x08, 0xe6, 0xfd, 0x22, 0x78, 0x89,
1468 0xef, 0x26, 0xf6, 0x18, 0xe4, 0x36, 0xf6, 0x22,
1469 0x75, 0x89, 0x03, 0x75, 0xa8, 0x01, 0x75, 0xb8,
1470 0x04, 0x75, 0x34, 0xff, 0x75, 0x35, 0x0e, 0x75,
1471 0x36, 0x15, 0x75, 0x37, 0x0d, 0x12, 0x0e, 0x9a,
1472 0x12, 0x00, 0x09, 0x12, 0x0f, 0x16, 0x12, 0x00,
1473 0x06, 0xd2, 0x00, 0xd2, 0x34, 0xd2, 0xaf, 0x75,
1474 0x34, 0xff, 0x75, 0x35, 0x0e, 0x75, 0x36, 0x49,
1475 0x75, 0x37, 0x03, 0x12, 0x0e, 0x9a, 0x30, 0x08,
1476 0x09, 0xc2, 0x34, 0x12, 0x08, 0xcb, 0xc2, 0x08,
1477 0xd2, 0x34, 0x30, 0x0b, 0x09, 0xc2, 0x36, 0x12,
1478 0x02, 0x6c, 0xc2, 0x0b, 0xd2, 0x36, 0x30, 0x09,
1479 0x09, 0xc2, 0x36, 0x12, 0x00, 0x0e, 0xc2, 0x09,
1480 0xd2, 0x36, 0x30, 0x0e, 0x03, 0x12, 0x06, 0xd7,
1481 0x30, 0x35, 0xd3, 0x90, 0x30, 0x29, 0xe5, 0x1e,
1482 0xf0, 0xb4, 0x10, 0x05, 0x90, 0x30, 0x23, 0xe4,
1483 0xf0, 0xc2, 0x35, 0x80, 0xc1, 0xe4, 0xf5, 0x4b,
1484 0x90, 0x0e, 0x7a, 0x93, 0xff, 0xe4, 0x8f, 0x37,
1485 0xf5, 0x36, 0xf5, 0x35, 0xf5, 0x34, 0xaf, 0x37,
1486 0xae, 0x36, 0xad, 0x35, 0xac, 0x34, 0x90, 0x0e,
1487 0x6a, 0x12, 0x0d, 0xf6, 0x8f, 0x37, 0x8e, 0x36,
1488 0x8d, 0x35, 0x8c, 0x34, 0x90, 0x0e, 0x72, 0x12,
1489 0x06, 0x7c, 0xef, 0x45, 0x37, 0xf5, 0x37, 0xee,
1490 0x45, 0x36, 0xf5, 0x36, 0xed, 0x45, 0x35, 0xf5,
1491 0x35, 0xec, 0x45, 0x34, 0xf5, 0x34, 0xe4, 0xf5,
1492 0x22, 0xf5, 0x23, 0x85, 0x37, 0x31, 0x85, 0x36,
1493 0x30, 0x85, 0x35, 0x2f, 0x85, 0x34, 0x2e, 0x12,
1494 0x0f, 0x46, 0xe4, 0xf5, 0x22, 0xf5, 0x23, 0x90,
1495 0x0e, 0x72, 0x12, 0x0d, 0xea, 0x12, 0x0f, 0x46,
1496 0xe4, 0xf5, 0x22, 0xf5, 0x23, 0x90, 0x0e, 0x6e,
1497 0x12, 0x0d, 0xea, 0x02, 0x0f, 0x46, 0xe5, 0x40,
1498 0x24, 0xf2, 0xf5, 0x37, 0xe5, 0x3f, 0x34, 0x43,
1499 0xf5, 0x36, 0xe5, 0x3e, 0x34, 0xa2, 0xf5, 0x35,
1500 0xe5, 0x3d, 0x34, 0x28, 0xf5, 0x34, 0xe5, 0x37,
1501 0xff, 0xe4, 0xfe, 0xfd, 0xfc, 0x78, 0x18, 0x12,
1502 0x06, 0x69, 0x8f, 0x40, 0x8e, 0x3f, 0x8d, 0x3e,
1503 0x8c, 0x3d, 0xe5, 0x37, 0x54, 0xa0, 0xff, 0xe5,
1504 0x36, 0xfe, 0xe4, 0xfd, 0xfc, 0x78, 0x07, 0x12,
1505 0x06, 0x56, 0x78, 0x10, 0x12, 0x0f, 0x9a, 0xe4,
1506 0xff, 0xfe, 0xe5, 0x35, 0xfd, 0xe4, 0xfc, 0x78,
1507 0x0e, 0x12, 0x06, 0x56, 0x12, 0x0f, 0x9d, 0xe4,
1508 0xff, 0xfe, 0xfd, 0xe5, 0x34, 0xfc, 0x78, 0x18,
1509 0x12, 0x06, 0x56, 0x78, 0x08, 0x12, 0x0f, 0x9a,
1510 0x22, 0x8f, 0x3b, 0x8e, 0x3a, 0x8d, 0x39, 0x8c,
1511 0x38, 0x22, 0x12, 0x06, 0x7c, 0x8f, 0x31, 0x8e,
1512 0x30, 0x8d, 0x2f, 0x8c, 0x2e, 0x22, 0x93, 0xf9,
1513 0xf8, 0x02, 0x06, 0x69, 0x00, 0x00, 0x00, 0x00,
1514 0x12, 0x01, 0x17, 0x08, 0x31, 0x15, 0x53, 0x54,
1515 0x44, 0x20, 0x20, 0x20, 0x20, 0x20, 0x13, 0x01,
1516 0x10, 0x01, 0x56, 0x40, 0x1a, 0x30, 0x29, 0x7e,
1517 0x00, 0x30, 0x04, 0x20, 0xdf, 0x30, 0x05, 0x40,
1518 0xbf, 0x50, 0x03, 0x00, 0xfd, 0x50, 0x27, 0x01,
1519 0xfe, 0x60, 0x00, 0x11, 0x00, 0x3f, 0x05, 0x30,
1520 0x00, 0x3f, 0x06, 0x22, 0x00, 0x3f, 0x01, 0x2a,
1521 0x00, 0x3f, 0x02, 0x00, 0x00, 0x36, 0x06, 0x07,
1522 0x00, 0x3f, 0x0b, 0x0f, 0xf0, 0x00, 0x00, 0x00,
1523 0x00, 0x30, 0x01, 0x40, 0xbf, 0x30, 0x01, 0x00,
1524 0xbf, 0x30, 0x29, 0x70, 0x00, 0x3a, 0x00, 0x00,
1525 0xff, 0x3a, 0x00, 0x00, 0xff, 0x36, 0x03, 0x36,
1526 0x02, 0x41, 0x44, 0x58, 0x20, 0x18, 0x10, 0x0a,
1527 0x04, 0x04, 0x00, 0x03, 0xff, 0x64, 0x00, 0x00,
1528 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
1529 0x04, 0x06, 0x06, 0x00, 0x03, 0x51, 0x00, 0x7a,
1530 0x50, 0x3c, 0x28, 0x1e, 0x10, 0x10, 0x50, 0x2d,
1531 0x28, 0x16, 0x10, 0x10, 0x02, 0x00, 0x10, 0x0c,
1532 0x10, 0x04, 0x0c, 0x6e, 0x06, 0x05, 0x00, 0xa5,
1533 0x5a, 0x00, 0xae, 0x35, 0xaf, 0x36, 0xe4, 0xfd,
1534 0xed, 0xc3, 0x95, 0x37, 0x50, 0x33, 0x12, 0x0f,
1535 0xe2, 0xe4, 0x93, 0xf5, 0x38, 0x74, 0x01, 0x93,
1536 0xf5, 0x39, 0x45, 0x38, 0x60, 0x23, 0x85, 0x39,
1537 0x82, 0x85, 0x38, 0x83, 0xe0, 0xfc, 0x12, 0x0f,
1538 0xe2, 0x74, 0x03, 0x93, 0x52, 0x04, 0x12, 0x0f,
1539 0xe2, 0x74, 0x02, 0x93, 0x42, 0x04, 0x85, 0x39,
1540 0x82, 0x85, 0x38, 0x83, 0xec, 0xf0, 0x0d, 0x80,
1541 0xc7, 0x22, 0x78, 0xbe, 0xe6, 0xd3, 0x08, 0xff,
1542 0xe6, 0x64, 0x80, 0xf8, 0xef, 0x64, 0x80, 0x98,
1543 0x22, 0x93, 0xff, 0x7e, 0x00, 0xe6, 0xfc, 0x08,
1544 0xe6, 0xfd, 0x12, 0x04, 0xc1, 0x78, 0xc1, 0xe6,
1545 0xfc, 0x08, 0xe6, 0xfd, 0xd3, 0xef, 0x9d, 0xee,
1546 0x9c, 0x22, 0x78, 0xbd, 0xd3, 0xe6, 0x64, 0x80,
1547 0x94, 0x80, 0x22, 0x25, 0xe0, 0x24, 0x0a, 0xf8,
1548 0xe6, 0xfe, 0x08, 0xe6, 0xff, 0x22, 0xe5, 0x3c,
1549 0xd3, 0x94, 0x00, 0x40, 0x0b, 0x90, 0x0e, 0x88,
1550 0x12, 0x0b, 0xf1, 0x90, 0x0e, 0x86, 0x80, 0x09,
1551 0x90, 0x0e, 0x82, 0x12, 0x0b, 0xf1, 0x90, 0x0e,
1552 0x80, 0xe4, 0x93, 0xf5, 0x44, 0xa3, 0xe4, 0x93,
1553 0xf5, 0x43, 0xd2, 0x06, 0x30, 0x06, 0x03, 0xd3,
1554 0x80, 0x01, 0xc3, 0x92, 0x0e, 0x22, 0xa2, 0xaf,
1555 0x92, 0x32, 0xc2, 0xaf, 0xe5, 0x23, 0x45, 0x22,
1556 0x90, 0x0e, 0x5d, 0x60, 0x0e, 0x12, 0x0f, 0xcb,
1557 0xe0, 0xf5, 0x2c, 0x12, 0x0f, 0xc8, 0xe0, 0xf5,
1558 0x2d, 0x80, 0x0c, 0x12, 0x0f, 0xcb, 0xe5, 0x30,
1559 0xf0, 0x12, 0x0f, 0xc8, 0xe5, 0x31, 0xf0, 0xa2,
1560 0x32, 0x92, 0xaf, 0x22, 0xd2, 0x01, 0xc2, 0x02,
1561 0xe4, 0xf5, 0x1f, 0xf5, 0x1e, 0xd2, 0x35, 0xd2,
1562 0x33, 0xd2, 0x36, 0xd2, 0x01, 0xc2, 0x02, 0xf5,
1563 0x1f, 0xf5, 0x1e, 0xd2, 0x35, 0xd2, 0x33, 0x22,
1564 0xfb, 0xd3, 0xed, 0x9b, 0x74, 0x80, 0xf8, 0x6c,
1565 0x98, 0x22, 0x12, 0x06, 0x69, 0xe5, 0x40, 0x2f,
1566 0xf5, 0x40, 0xe5, 0x3f, 0x3e, 0xf5, 0x3f, 0xe5,
1567 0x3e, 0x3d, 0xf5, 0x3e, 0xe5, 0x3d, 0x3c, 0xf5,
1568 0x3d, 0x22, 0xc0, 0xe0, 0xc0, 0x83, 0xc0, 0x82,
1569 0x90, 0x3f, 0x0d, 0xe0, 0xf5, 0x33, 0xe5, 0x33,
1570 0xf0, 0xd0, 0x82, 0xd0, 0x83, 0xd0, 0xe0, 0x32,
1571 0x90, 0x0e, 0x5f, 0xe4, 0x93, 0xfe, 0x74, 0x01,
1572 0x93, 0xf5, 0x82, 0x8e, 0x83, 0x22, 0x78, 0x7f,
1573 0xe4, 0xf6, 0xd8, 0xfd, 0x75, 0x81, 0xcd, 0x02,
1574 0x0c, 0x98, 0x8f, 0x82, 0x8e, 0x83, 0x75, 0xf0,
1575 0x04, 0xed, 0x02, 0x06, 0xa5,
1576 };
1577
1578 /*
1579 * The white balance settings
1580 * Here only tune the R G B channel gain.
1581 * The white balance enalbe bit is modified in sensor_s_autowb and sensor_s_wb
1582 */
1583 static struct regval_list sensor_wb_manual[] = {
1584 {0x3406, 0x1},
1585 };
1586
1587 static struct regval_list sensor_wb_auto_regs[] = {
1588
1589 {0x3406, 0x00},
1590 };
1591
1592 static struct regval_list sensor_wb_incandescence_regs[] = {
1593
1594 {0x3406, 0x1},
1595 {0x3400, 0x5},
1596 {0x3401, 0x48},
1597 {0x3402, 0x4},
1598 {0x3403, 0x0},
1599 {0x3404, 0x7},
1600 {0x3405, 0xcf},
1601 };
1602
1603 static struct regval_list sensor_wb_fluorescent_regs[] = {
1604
1605 {0x3406, 0x1},
1606 {0x3400, 0x5},
1607 {0x3401, 0x48},
1608 {0x3402, 0x4},
1609 {0x3403, 0x0},
1610 {0x3404, 0x7},
1611 {0x3405, 0xcf},
1612 };
1613
1614 static struct regval_list sensor_wb_tungsten_regs[] = {
1615
1616 {0x3406, 0x1},
1617 {0x3400, 0x4},
1618 {0x3401, 0x10},
1619 {0x3402, 0x4},
1620 {0x3403, 0x0},
1621 {0x3404, 0x8},
1622 {0x3405, 0xb6},
1623 };
1624
1625 static struct regval_list sensor_wb_horizon[] = {
1626
1627 };
1628
1629 static struct regval_list sensor_wb_daylight_regs[] = {
1630
1631 {0x3406, 0x1},
1632 {0x3400, 0x6},
1633 {0x3401, 0x1c},
1634 {0x3402, 0x4},
1635 {0x3403, 0x0},
1636 {0x3404, 0x4},
1637 {0x3405, 0xf3},
1638 };
1639
1640 static struct regval_list sensor_wb_flash[] = {
1641
1642 };
1643
1644 static struct regval_list sensor_wb_cloud_regs[] = {
1645 {0x3406, 0x1},
1646 {0x3400, 0x6},
1647 {0x3401, 0x48},
1648 {0x3402, 0x4},
1649 {0x3403, 0x0},
1650 {0x3404, 0x4},
1651 {0x3405, 0xd3},
1652 };
1653
1654 static struct regval_list sensor_wb_shade[] = {
1655
1656 };
1657
1658 static struct cfg_array sensor_wb[] = {
1659 {
1660 .regs = sensor_wb_manual,
1661 .size = ARRAY_SIZE(sensor_wb_manual),
1662 },
1663 {
1664 .regs = sensor_wb_auto_regs,
1665 .size = ARRAY_SIZE(sensor_wb_auto_regs),
1666 },
1667 {
1668 .regs = sensor_wb_incandescence_regs,
1669 .size = ARRAY_SIZE(sensor_wb_incandescence_regs),
1670 },
1671 {
1672 .regs = sensor_wb_fluorescent_regs,
1673 .size = ARRAY_SIZE(sensor_wb_fluorescent_regs),
1674 },
1675 {
1676 .regs = sensor_wb_tungsten_regs,
1677 .size = ARRAY_SIZE(sensor_wb_tungsten_regs),
1678 },
1679 {
1680 .regs = sensor_wb_horizon,
1681 .size = ARRAY_SIZE(sensor_wb_horizon),
1682 },
1683 {
1684 .regs = sensor_wb_daylight_regs,
1685 .size = ARRAY_SIZE(sensor_wb_daylight_regs),
1686 },
1687 {
1688 .regs = sensor_wb_flash,
1689 .size = ARRAY_SIZE(sensor_wb_flash),
1690 },
1691 {
1692 .regs = sensor_wb_cloud_regs,
1693 .size = ARRAY_SIZE(sensor_wb_cloud_regs),
1694 },
1695 {
1696 .regs = sensor_wb_shade,
1697 .size = ARRAY_SIZE(sensor_wb_shade),
1698 },
1699 };
1700
1701 /*
1702 * The color effect settings
1703 */
1704 static struct regval_list sensor_colorfx_none_regs[] = {
1705 {0x5580, 0x06},
1706 {0x5583, 0x40},
1707 {0x5584, 0x10},
1708 };
1709
1710 static struct regval_list sensor_colorfx_bw_regs[] = {
1711 {0x5580, 0x1e},
1712 {0x5583, 0x80},
1713 {0x5584, 0x80},
1714 };
1715
1716 static struct regval_list sensor_colorfx_sepia_regs[] = {
1717 {0x5580, 0x1e},
1718 {0x5583, 0x40},
1719 {0x5584, 0xa0},
1720 };
1721
1722 static struct regval_list sensor_colorfx_negative_regs[] = {
1723 {0x5580, 0x46},
1724 };
1725
1726 static struct regval_list sensor_colorfx_emboss_regs[] = {
1727 {0x5580, 0x1e},
1728 {0x5583, 0x80},
1729 {0x5584, 0xc0},
1730 };
1731
1732 static struct regval_list sensor_colorfx_sketch_regs[] = {
1733 {0x5580, 0x1e},
1734 {0x5583, 0x80},
1735 {0x5584, 0xc0},
1736 };
1737
1738 static struct regval_list sensor_colorfx_sky_blue_regs[] = {
1739 {0x5580, 0x1e},
1740 {0x5583, 0xa0},
1741 {0x5584, 0x40},
1742 };
1743
1744 static struct regval_list sensor_colorfx_grass_green_regs[] = {
1745 {0x5580, 0x1e},
1746 {0x5583, 0x60},
1747 {0x5584, 0x60},
1748 };
1749
1750 static struct regval_list sensor_colorfx_skin_whiten_regs[] = {
1751
1752 };
1753
1754 static struct regval_list sensor_colorfx_vivid_regs[] = {
1755
1756 };
1757
1758 static struct regval_list sensor_colorfx_aqua_regs[] = {
1759
1760 };
1761
1762 static struct regval_list sensor_colorfx_art_freeze_regs[] = {
1763
1764 };
1765
1766 static struct regval_list sensor_colorfx_silhouette_regs[] = {
1767
1768 };
1769
1770 static struct regval_list sensor_colorfx_solarization_regs[] = {
1771
1772 };
1773
1774 static struct regval_list sensor_colorfx_antique_regs[] = {
1775
1776 };
1777
1778 static struct regval_list sensor_colorfx_set_cbcr_regs[] = {
1779
1780 };
1781
1782 static struct cfg_array sensor_colorfx[] = {
1783 {
1784 .regs = sensor_colorfx_none_regs,
1785 .size = ARRAY_SIZE(sensor_colorfx_none_regs),
1786 },
1787 {
1788 .regs = sensor_colorfx_bw_regs,
1789 .size = ARRAY_SIZE(sensor_colorfx_bw_regs),
1790 },
1791 {
1792 .regs = sensor_colorfx_sepia_regs,
1793 .size = ARRAY_SIZE(sensor_colorfx_sepia_regs),
1794 },
1795 {
1796 .regs = sensor_colorfx_negative_regs,
1797 .size = ARRAY_SIZE(sensor_colorfx_negative_regs),
1798 },
1799 {
1800 .regs = sensor_colorfx_emboss_regs,
1801 .size = ARRAY_SIZE(sensor_colorfx_emboss_regs),
1802 },
1803 {
1804 .regs = sensor_colorfx_sketch_regs,
1805 .size = ARRAY_SIZE(sensor_colorfx_sketch_regs),
1806 },
1807 {
1808 .regs = sensor_colorfx_sky_blue_regs,
1809 .size = ARRAY_SIZE(sensor_colorfx_sky_blue_regs),
1810 },
1811 {
1812 .regs = sensor_colorfx_grass_green_regs,
1813 .size = ARRAY_SIZE(sensor_colorfx_grass_green_regs),
1814 },
1815 {
1816 .regs = sensor_colorfx_skin_whiten_regs,
1817 .size = ARRAY_SIZE(sensor_colorfx_skin_whiten_regs),
1818 },
1819 {
1820 .regs = sensor_colorfx_vivid_regs,
1821 .size = ARRAY_SIZE(sensor_colorfx_vivid_regs),
1822 },
1823 {
1824 .regs = sensor_colorfx_aqua_regs,
1825 .size = ARRAY_SIZE(sensor_colorfx_aqua_regs),
1826 },
1827 {
1828 .regs = sensor_colorfx_art_freeze_regs,
1829 .size = ARRAY_SIZE(sensor_colorfx_art_freeze_regs),
1830 },
1831 {
1832 .regs = sensor_colorfx_silhouette_regs,
1833 .size = ARRAY_SIZE(sensor_colorfx_silhouette_regs),
1834 },
1835 {
1836 .regs = sensor_colorfx_solarization_regs,
1837 .size = ARRAY_SIZE(sensor_colorfx_solarization_regs),
1838 },
1839 {
1840 .regs = sensor_colorfx_antique_regs,
1841 .size = ARRAY_SIZE(sensor_colorfx_antique_regs),
1842 },
1843 {
1844 .regs = sensor_colorfx_set_cbcr_regs,
1845 .size = ARRAY_SIZE(sensor_colorfx_set_cbcr_regs),
1846 },
1847 };
1848
1849 #if 1
1850 static struct regval_list sensor_sharpness_auto_regs[] = {
1851 {0x5308, 0x25},
1852 {0x5300, 0x08},
1853 {0x5301, 0x30},
1854 {0x5302, 0x10},
1855 {0x5303, 0x00},
1856 {0x5304, 0x08},
1857 {0x5305, 0x30},
1858 {0x5306, 0x08},
1859 {0x5307, 0x16},
1860 {0x5309, 0x08},
1861 {0x530a, 0x30},
1862 {0x530b, 0x04},
1863 {0x530c, 0x06},
1864 };
1865 #endif
1866 #if 1
1867 static struct regval_list sensor_denoise_auto_regs[] = {
1868 {0x5304, 0x08},
1869 {0x5305, 0x30},
1870 {0x5306, 0x1c},
1871 {0x5307, 0x2c},
1872 };
1873 #endif
1874
1875 /*
1876 * The brightness setttings
1877 */
1878 static struct regval_list sensor_brightness_neg4_regs[] = {
1879
1880 };
1881
1882 static struct regval_list sensor_brightness_neg3_regs[] = {
1883
1884 };
1885
1886 static struct regval_list sensor_brightness_neg2_regs[] = {
1887
1888 };
1889
1890 static struct regval_list sensor_brightness_neg1_regs[] = {
1891
1892 };
1893
1894 static struct regval_list sensor_brightness_zero_regs[] = {
1895
1896 };
1897
1898 static struct regval_list sensor_brightness_pos1_regs[] = {
1899
1900 };
1901
1902 static struct regval_list sensor_brightness_pos2_regs[] = {
1903
1904 };
1905
1906 static struct regval_list sensor_brightness_pos3_regs[] = {
1907
1908 };
1909
1910 static struct regval_list sensor_brightness_pos4_regs[] = {
1911
1912 };
1913
1914 static struct cfg_array sensor_brightness[] = {
1915 {
1916 .regs = sensor_brightness_neg4_regs,
1917 .size = ARRAY_SIZE(sensor_brightness_neg4_regs),
1918 },
1919 {
1920 .regs = sensor_brightness_neg3_regs,
1921 .size = ARRAY_SIZE(sensor_brightness_neg3_regs),
1922 },
1923 {
1924 .regs = sensor_brightness_neg2_regs,
1925 .size = ARRAY_SIZE(sensor_brightness_neg2_regs),
1926 },
1927 {
1928 .regs = sensor_brightness_neg1_regs,
1929 .size = ARRAY_SIZE(sensor_brightness_neg1_regs),
1930 },
1931 {
1932 .regs = sensor_brightness_zero_regs,
1933 .size = ARRAY_SIZE(sensor_brightness_zero_regs),
1934 },
1935 {
1936 .regs = sensor_brightness_pos1_regs,
1937 .size = ARRAY_SIZE(sensor_brightness_pos1_regs),
1938 },
1939 {
1940 .regs = sensor_brightness_pos2_regs,
1941 .size = ARRAY_SIZE(sensor_brightness_pos2_regs),
1942 },
1943 {
1944 .regs = sensor_brightness_pos3_regs,
1945 .size = ARRAY_SIZE(sensor_brightness_pos3_regs),
1946 },
1947 {
1948 .regs = sensor_brightness_pos4_regs,
1949 .size = ARRAY_SIZE(sensor_brightness_pos4_regs),
1950 },
1951 };
1952
1953 /*
1954 * The contrast setttings
1955 */
1956 static struct regval_list sensor_contrast_neg4_regs[] = {
1957
1958 };
1959
1960 static struct regval_list sensor_contrast_neg3_regs[] = {
1961
1962 };
1963
1964 static struct regval_list sensor_contrast_neg2_regs[] = {
1965
1966 };
1967
1968 static struct regval_list sensor_contrast_neg1_regs[] = {
1969
1970 };
1971
1972 static struct regval_list sensor_contrast_zero_regs[] = {
1973
1974 };
1975
1976 static struct regval_list sensor_contrast_pos1_regs[] = {
1977
1978 };
1979
1980 static struct regval_list sensor_contrast_pos2_regs[] = {
1981
1982 };
1983
1984 static struct regval_list sensor_contrast_pos3_regs[] = {
1985
1986 };
1987
1988 static struct regval_list sensor_contrast_pos4_regs[] = {
1989
1990 };
1991
1992 static struct cfg_array sensor_contrast[] = {
1993 {
1994 .regs = sensor_contrast_neg4_regs,
1995 .size = ARRAY_SIZE(sensor_contrast_neg4_regs),
1996 },
1997 {
1998 .regs = sensor_contrast_neg3_regs,
1999 .size = ARRAY_SIZE(sensor_contrast_neg3_regs),
2000 },
2001 {
2002 .regs = sensor_contrast_neg2_regs,
2003 .size = ARRAY_SIZE(sensor_contrast_neg2_regs),
2004 },
2005 {
2006 .regs = sensor_contrast_neg1_regs,
2007 .size = ARRAY_SIZE(sensor_contrast_neg1_regs),
2008 },
2009 {
2010 .regs = sensor_contrast_zero_regs,
2011 .size = ARRAY_SIZE(sensor_contrast_zero_regs),
2012 },
2013 {
2014 .regs = sensor_contrast_pos1_regs,
2015 .size = ARRAY_SIZE(sensor_contrast_pos1_regs),
2016 },
2017 {
2018 .regs = sensor_contrast_pos2_regs,
2019 .size = ARRAY_SIZE(sensor_contrast_pos2_regs),
2020 },
2021 {
2022 .regs = sensor_contrast_pos3_regs,
2023 .size = ARRAY_SIZE(sensor_contrast_pos3_regs),
2024 },
2025 {
2026 .regs = sensor_contrast_pos4_regs,
2027 .size = ARRAY_SIZE(sensor_contrast_pos4_regs),
2028 },
2029 };
2030
2031 /*
2032 * The saturation setttings
2033 */
2034 static struct regval_list sensor_saturation_neg4_regs[] = {
2035
2036 };
2037
2038 static struct regval_list sensor_saturation_neg3_regs[] = {
2039
2040 };
2041
2042 static struct regval_list sensor_saturation_neg2_regs[] = {
2043
2044 };
2045
2046 static struct regval_list sensor_saturation_neg1_regs[] = {
2047
2048 };
2049
2050 static struct regval_list sensor_saturation_zero_regs[] = {
2051
2052 };
2053
2054 static struct regval_list sensor_saturation_pos1_regs[] = {
2055
2056 };
2057
2058 static struct regval_list sensor_saturation_pos2_regs[] = {
2059
2060 };
2061
2062 static struct regval_list sensor_saturation_pos3_regs[] = {
2063
2064 };
2065
2066 static struct regval_list sensor_saturation_pos4_regs[] = {
2067
2068 };
2069
2070 static struct cfg_array sensor_saturation[] = {
2071 {
2072 .regs = sensor_saturation_neg4_regs,
2073 .size = ARRAY_SIZE(sensor_saturation_neg4_regs),
2074 },
2075 {
2076 .regs = sensor_saturation_neg3_regs,
2077 .size = ARRAY_SIZE(sensor_saturation_neg3_regs),
2078 },
2079 {
2080 .regs = sensor_saturation_neg2_regs,
2081 .size = ARRAY_SIZE(sensor_saturation_neg2_regs),
2082 },
2083 {
2084 .regs = sensor_saturation_neg1_regs,
2085 .size = ARRAY_SIZE(sensor_saturation_neg1_regs),
2086 },
2087 {
2088 .regs = sensor_saturation_zero_regs,
2089 .size = ARRAY_SIZE(sensor_saturation_zero_regs),
2090 },
2091 {
2092 .regs = sensor_saturation_pos1_regs,
2093 .size = ARRAY_SIZE(sensor_saturation_pos1_regs),
2094 },
2095 {
2096 .regs = sensor_saturation_pos2_regs,
2097 .size = ARRAY_SIZE(sensor_saturation_pos2_regs),
2098 },
2099 {
2100 .regs = sensor_saturation_pos3_regs,
2101 .size = ARRAY_SIZE(sensor_saturation_pos3_regs),
2102 },
2103 {
2104 .regs = sensor_saturation_pos4_regs,
2105 .size = ARRAY_SIZE(sensor_saturation_pos4_regs),
2106 },
2107 };
2108
2109 /*
2110 * The exposure target setttings
2111 */
2112
2113 static struct regval_list sensor_ev_neg4_regs[] = {
2114 {0x3a0f, 0x10},
2115 {0x3a10, 0x08},
2116 {0x3a1b, 0x10},
2117 {0x3a1e, 0x08},
2118 {0x3a11, 0x20},
2119 {0x3a1f, 0x10},
2120
2121 };
2122
2123 static struct regval_list sensor_ev_neg3_regs[] = {
2124 {0x3a0f, 0x18},
2125 {0x3a10, 0x10},
2126 {0x3a1b, 0x18},
2127 {0x3a1e, 0x10},
2128 {0x3a11, 0x30},
2129 {0x3a1f, 0x10},
2130 };
2131
2132 static struct regval_list sensor_ev_neg2_regs[] = {
2133 {0x3a0f, 0x20},
2134 {0x3a10, 0x18},
2135 {0x3a1b, 0x20},
2136 {0x3a1e, 0x18},
2137 {0x3a11, 0x41},
2138 {0x3a1f, 0x10},
2139 };
2140
2141 static struct regval_list sensor_ev_neg1_regs[] = {
2142 {0x3a0f, 0x28},
2143 {0x3a10, 0x20},
2144 {0x3a1b, 0x28},
2145 {0x3a1e, 0x20},
2146 {0x3a11, 0x51},
2147 {0x3a1f, 0x10},
2148 };
2149
2150 static struct regval_list sensor_ev_zero_regs[] = {
2151 {0x3a0f, 0x30},
2152 {0x3a10, 0x28},
2153 {0x3a1b, 0x30},
2154 {0x3a1e, 0x28},
2155 {0x3a11, 0x61},
2156 {0x3a1f, 0x10},
2157 };
2158
2159 static struct regval_list sensor_ev_pos1_regs[] = {
2160 {0x3a0f, 0x38},
2161 {0x3a10, 0x30},
2162 {0x3a1b, 0x38},
2163 {0x3a1e, 0x30},
2164 {0x3a11, 0x61},
2165 {0x3a1f, 0x10},
2166 };
2167
2168 static struct regval_list sensor_ev_pos2_regs[] = {
2169 {0x3a0f, 0x40},
2170 {0x3a10, 0x38},
2171 {0x3a1b, 0x40},
2172 {0x3a1e, 0x38},
2173 {0x3a11, 0x71},
2174 {0x3a1f, 0x10},
2175 };
2176
2177 static struct regval_list sensor_ev_pos3_regs[] = {
2178 {0x3a0f, 0x48},
2179 {0x3a10, 0x40},
2180 {0x3a1b, 0x48},
2181 {0x3a1e, 0x40},
2182 {0x3a11, 0x80},
2183 {0x3a1f, 0x20},
2184 };
2185
2186 static struct regval_list sensor_ev_pos4_regs[] = {
2187 {0x3a0f, 0x50},
2188 {0x3a10, 0x48},
2189 {0x3a1b, 0x50},
2190 {0x3a1e, 0x48},
2191 {0x3a11, 0x90},
2192 {0x3a1f, 0x20},
2193 };
2194
2195 static struct cfg_array sensor_ev[] = {
2196 {
2197 .regs = sensor_ev_neg4_regs,
2198 .size = ARRAY_SIZE(sensor_ev_neg4_regs),
2199 },
2200 {
2201 .regs = sensor_ev_neg3_regs,
2202 .size = ARRAY_SIZE(sensor_ev_neg3_regs),
2203 },
2204 {
2205 .regs = sensor_ev_neg2_regs,
2206 .size = ARRAY_SIZE(sensor_ev_neg2_regs),
2207 },
2208 {
2209 .regs = sensor_ev_neg1_regs,
2210 .size = ARRAY_SIZE(sensor_ev_neg1_regs),
2211 },
2212 {
2213 .regs = sensor_ev_zero_regs,
2214 .size = ARRAY_SIZE(sensor_ev_zero_regs),
2215 },
2216 {
2217 .regs = sensor_ev_pos1_regs,
2218 .size = ARRAY_SIZE(sensor_ev_pos1_regs),
2219 },
2220 {
2221 .regs = sensor_ev_pos2_regs,
2222 .size = ARRAY_SIZE(sensor_ev_pos2_regs),
2223 },
2224 {
2225 .regs = sensor_ev_pos3_regs,
2226 .size = ARRAY_SIZE(sensor_ev_pos3_regs),
2227 },
2228 {
2229 .regs = sensor_ev_pos4_regs,
2230 .size = ARRAY_SIZE(sensor_ev_pos4_regs),
2231 },
2232 };
2233
2234 /*
2235 * Here we'll try to encapsulate the changes for just the output
2236 * video format.
2237 *
2238 */
2239
2240 static struct regval_list sensor_fmt_yuv422_yuyv[] = {
2241 {0x4300, 0x30},
2242 };
2243
2244 static struct regval_list sensor_fmt_yuv422_yvyu[] = {
2245 {0x4300, 0x31},
2246 };
2247
2248 static struct regval_list sensor_fmt_yuv422_vyuy[] = {
2249 {0x4300, 0x33},
2250 };
2251
2252 static struct regval_list sensor_fmt_yuv422_uyvy[] = {
2253 {0x4300, 0x32},
2254 };
2255
2256 static struct regval_list sensor_fmt_raw[] = {
2257 {0x4300, 0x00},
2258 };
2259
2260 static struct regval_list ae_average_tbl[] = {
2261 /* Whole Image Average */
2262 {0x5688, 0x11}, /* Zone 1/Zone 0 weight */
2263 {0x5689, 0x11}, /* Zone 3/Zone 2 weight */
2264 {0x569a, 0x11}, /* Zone 5/Zone 4 weight */
2265 {0x569b, 0x11}, /* Zone 7/Zone 6 weight */
2266 {0x569c, 0x11}, /* Zone 9/Zone 8 weight */
2267 {0x569d, 0x11}, /* Zone b/Zone a weight */
2268 {0x569e, 0x11}, /* Zone d/Zone c weight */
2269 {0x569f, 0x11}, /* Zone f/Zone e weight */
2270 };
2271
2272 static struct regval_list ae_centerweight_tbl[] = {
2273 /* Whole Image Center More weight */
2274 {0x5688, 0x62},
2275 {0x5689, 0x26},
2276 {0x568a, 0xe6},
2277 {0x568b, 0x6e},
2278 {0x568c, 0xea},
2279 {0x568d, 0xae},
2280 {0x568e, 0xa6},
2281 {0x568f, 0x6a},
2282 };
2283
2284 static data_type current_lum = 0xff;
sensor_get_lum(struct v4l2_subdev * sd)2285 static data_type sensor_get_lum(struct v4l2_subdev *sd)
2286 {
2287 sensor_read(sd, 0x56a1, ¤t_lum);
2288 sensor_dbg("check luminance=0x%x\n", current_lum);
2289 return current_lum;
2290 }
2291
2292 /* stuff about exposure when capturing image and video*/
2293 static int sensor_s_denoise_value(struct v4l2_subdev *sd, data_type value);
2294 data_type ogain, oexposurelow, oexposuremid, oexposurehigh;
2295 unsigned int preview_exp_line, preview_fps;
2296 unsigned long preview_pclk;
2297
cal_cap_gain(data_type prv_gain,data_type lum)2298 static unsigned int cal_cap_gain(data_type prv_gain, data_type lum)
2299 {
2300 unsigned int gain_ret = 0x18;
2301
2302 if (current_lum > 0xa0) {
2303 if (ogain > 0x40)
2304 gain_ret = 0x20;
2305 else if (ogain > 0x20)
2306 gain_ret = 0x18;
2307 else
2308 gain_ret = 0x10;
2309 } else if (current_lum > 0x80) {
2310 if (ogain > 0x40)
2311 gain_ret = 0x30;
2312 else if (ogain > 0x20)
2313 gain_ret = 0x28;
2314 else
2315 gain_ret = 0x20;
2316 } else if (current_lum > 0x40) {
2317 if (ogain > 0x60)
2318 gain_ret = ogain / 3;
2319 else if (ogain > 0x40)
2320 gain_ret = ogain / 2;
2321 else
2322 gain_ret = ogain;
2323 } else if (current_lum > 0x20) {
2324 if (ogain > 0x60)
2325 gain_ret = ogain / 6;
2326 else if (ogain > 0x20)
2327 gain_ret = ogain / 2;
2328 else
2329 gain_ret = ogain;
2330 } else {
2331 if (ogain > 0xf0)
2332 gain_ret = 0x10;
2333 else if (ogain > 0xe0)
2334 gain_ret = 0x14;
2335 else
2336 gain_ret = 0x18;
2337 }
2338
2339 if (gain_ret < 0x10)
2340 gain_ret = 0x10;
2341
2342 return gain_ret;
2343 }
2344
sensor_set_capture_exposure(struct v4l2_subdev * sd)2345 static int sensor_set_capture_exposure(struct v4l2_subdev *sd)
2346 {
2347 unsigned long lines_10ms;
2348 unsigned int cap_expLines;
2349 unsigned int pre_explines;
2350 unsigned long prevExp;
2351 unsigned long cap_Exp;
2352 unsigned long cap_exp_gain;
2353 unsigned long capture_gain;
2354 data_type gain, explow, expmid, exphigh;
2355 unsigned int cap_vts = 0;
2356 unsigned int cap_vts_diff = 0;
2357 unsigned int bd_step = 1;
2358 unsigned int cap_fps;
2359 data_type rdval;
2360 struct sensor_info *info = to_state(sd);
2361
2362 #ifndef FPGA_VER
2363 cap_fps = 75 / MCLK_DIV;
2364 #else
2365 cap_fps = 37;
2366 #endif
2367
2368 sensor_dbg("sensor_set_capture_exposure\n");
2369 preview_fps = preview_fps * 10;
2370
2371 if (info->low_speed == 1)
2372 cap_fps = cap_fps / 2;
2373
2374 pre_explines = preview_exp_line;
2375 cap_expLines = 1968;
2376 if (info->band_filter == V4L2_CID_POWER_LINE_FREQUENCY_60HZ)
2377 lines_10ms = cap_fps * cap_expLines * 1000 / 12000;
2378 else
2379 lines_10ms = cap_fps * cap_expLines * 1000 / 10000;
2380 prevExp = ((unsigned int)(oexposurehigh)) << 12;
2381 prevExp += ((unsigned int)oexposuremid) << 4;
2382 prevExp += (oexposurelow >> 4);
2383
2384 if (0 == pre_explines || 0 == lines_10ms)
2385 return 0;
2386
2387 if (pre_explines == 0 || preview_fps == 0)
2388 return -EFAULT;
2389
2390 if (night_mode == 0) {
2391 cap_Exp = 1 * prevExp * cap_fps * cap_expLines /
2392 (pre_explines * preview_fps);
2393 } else {
2394 cap_Exp =
2395 night_mode * prevExp * cap_fps * cap_expLines /
2396 (pre_explines * preview_fps);
2397 }
2398 sensor_dbg("cap_Exp=0x%lx\n", cap_Exp);
2399
2400 if (CAP_GAIN_CAL == 0) {
2401 capture_gain = (unsigned long)cal_cap_gain(ogain, current_lum);
2402 cap_Exp = cap_Exp * ogain / capture_gain;
2403 cap_exp_gain = cap_Exp * capture_gain;
2404 if (cap_Exp > Nfrms * cap_expLines) {
2405 capture_gain = cap_exp_gain / (Nfrms * cap_expLines);
2406 cap_Exp = Nfrms * cap_expLines;
2407 }
2408 if (capture_gain > 0xf8)
2409 capture_gain = 0xf8;
2410 } else {
2411 capture_gain = cap_manual_gain;
2412 cap_Exp = cap_Exp * ogain / capture_gain;
2413 }
2414
2415 if (cap_Exp * 1000 > lines_10ms)
2416 bd_step = cap_Exp * 1000 / lines_10ms;
2417
2418 if (cap_Exp == 0)
2419 cap_Exp = 1;
2420
2421 sensor_dbg("cap_Exp = 0x%lx\n", cap_Exp);
2422
2423 if ((1000 * cap_Exp - bd_step * lines_10ms) * 16 > lines_10ms)
2424 capture_gain = cap_exp_gain / cap_Exp;
2425
2426 if (cap_Exp > 1968) {
2427 cap_vts = cap_Exp;
2428 cap_vts_diff = cap_Exp - 1968;
2429 } else {
2430 cap_vts = 1968;
2431 cap_vts_diff = 0;
2432 }
2433
2434 explow = ((data_type) cap_Exp) << 4;
2435 expmid = (data_type) (cap_Exp >> 4) & 0xff;
2436 exphigh = (data_type) (cap_Exp >> 12);
2437 gain = (data_type) capture_gain;
2438
2439 sensor_read(sd, 0x3503, &rdval);
2440 #ifdef DENOISE_LV_AUTO
2441 sensor_s_denoise_value(sd, 1 + gain * gain / 0x100);
2442 #else
2443 sensor_s_denoise_value(sd, DENOISE_LV);
2444 #endif
2445
2446 sensor_write(sd, 0x380e, (data_type) (cap_vts >> 8));
2447 sensor_write(sd, 0x380f, (data_type) (cap_vts));
2448 sensor_write(sd, 0x350c, (data_type) ((cap_vts_diff) >> 8));
2449 sensor_write(sd, 0x350d, (data_type) (cap_vts_diff));
2450
2451 sensor_write(sd, 0x350b, gain);
2452 sensor_write(sd, 0x3502, explow);
2453 sensor_write(sd, 0x3501, expmid);
2454 sensor_write(sd, 0x3500, exphigh);
2455
2456 return 0;
2457 }
sensor_get_pclk(struct v4l2_subdev * sd)2458 static int sensor_get_pclk(struct v4l2_subdev *sd)
2459 {
2460 unsigned long pclk;
2461 data_type pre_div, mul, sys_div, pll_rdiv, bit_div, sclk_rdiv;
2462
2463 sensor_read(sd, 0x3037, &pre_div);
2464 pre_div = pre_div & 0x0f;
2465
2466 if (pre_div == 0)
2467 pre_div = 1;
2468
2469 sensor_read(sd, 0x3036, &mul);
2470 if (mul >= 128)
2471 mul = mul / 2 * 2;
2472
2473 sensor_read(sd, 0x3035, &sys_div);
2474 sys_div = (sys_div & 0xf0) >> 4;
2475
2476 sensor_read(sd, 0x3037, &pll_rdiv);
2477 pll_rdiv = (pll_rdiv & 0x10) >> 4;
2478 pll_rdiv = pll_rdiv + 1;
2479
2480 sensor_read(sd, 0x3034, &bit_div);
2481 bit_div = (bit_div & 0x0f);
2482
2483 sensor_read(sd, 0x3108, &sclk_rdiv);
2484 sclk_rdiv = (sclk_rdiv & 0x03);
2485 sclk_rdiv = sclk_rdiv << sclk_rdiv;
2486
2487 if ((pre_div && sys_div && pll_rdiv && sclk_rdiv) == 0)
2488 return -EFAULT;
2489
2490 if (bit_div == 8)
2491 pclk =
2492 MCLK / MCLK_DIV / pre_div * mul / sys_div / pll_rdiv / 2 /
2493 sclk_rdiv;
2494 else if (bit_div == 10)
2495 pclk =
2496 MCLK / MCLK_DIV / pre_div * mul / sys_div / pll_rdiv * 2 /
2497 5 / sclk_rdiv;
2498 else
2499 pclk =
2500 MCLK / MCLK_DIV / pre_div * mul / sys_div / pll_rdiv / 1 /
2501 sclk_rdiv;
2502
2503 sensor_dbg("pclk = %ld\n", pclk);
2504
2505 preview_pclk = pclk;
2506 return 0;
2507 }
2508
sensor_get_fps(struct v4l2_subdev * sd)2509 static int sensor_get_fps(struct v4l2_subdev *sd)
2510 {
2511 data_type vts_low, vts_high, hts_low, hts_high, vts_extra_high,
2512 vts_extra_low;
2513 unsigned long vts, hts, vts_extra;
2514
2515 sensor_read(sd, 0x380c, &hts_high);
2516 sensor_read(sd, 0x380d, &hts_low);
2517 sensor_read(sd, 0x380e, &vts_high);
2518 sensor_read(sd, 0x380f, &vts_low);
2519 sensor_read(sd, 0x350c, &vts_extra_high);
2520 sensor_read(sd, 0x350d, &vts_extra_low);
2521
2522 hts = hts_high * 256 + hts_low;
2523 vts = vts_high * 256 + vts_low;
2524 vts_extra = vts_extra_high * 256 + vts_extra_low;
2525
2526 if ((hts && (vts + vts_extra)) == 0)
2527 return -EFAULT;
2528
2529 if (sensor_get_pclk(sd))
2530 sensor_err("get pclk error!\n");
2531
2532 preview_fps = preview_pclk / ((vts_extra + vts) * hts);
2533 sensor_dbg("preview fps = %d\n", preview_fps);
2534
2535 return 0;
2536 }
2537
sensor_get_preview_exposure(struct v4l2_subdev * sd)2538 static int sensor_get_preview_exposure(struct v4l2_subdev *sd)
2539 {
2540 data_type vts_low, vts_high, vts_extra_high, vts_extra_low;
2541 unsigned long vts, vts_extra;
2542
2543 sensor_read(sd, 0x350b, &ogain);
2544 sensor_read(sd, 0x3502, &oexposurelow);
2545 sensor_read(sd, 0x3501, &oexposuremid);
2546 sensor_read(sd, 0x3500, &oexposurehigh);
2547 sensor_read(sd, 0x380e, &vts_high);
2548 sensor_read(sd, 0x380f, &vts_low);
2549 sensor_read(sd, 0x350c, &vts_extra_high);
2550 sensor_read(sd, 0x350d, &vts_extra_low);
2551
2552 vts = vts_high * 256 + vts_low;
2553 vts_extra = vts_extra_high * 256 + vts_extra_low;
2554 preview_exp_line = vts + vts_extra;
2555
2556 sensor_dbg("preview_exp_line = %d\n", preview_exp_line);
2557
2558 return 0;
2559 }
2560
sensor_set_preview_exposure(struct v4l2_subdev * sd)2561 static int sensor_set_preview_exposure(struct v4l2_subdev *sd)
2562 {
2563 data_type rdval;
2564
2565 sensor_read(sd, 0x3503, &rdval);
2566
2567 sensor_write(sd, 0x350b, ogain);
2568 sensor_write(sd, 0x3502, oexposurelow);
2569 sensor_write(sd, 0x3501, oexposuremid);
2570 sensor_write(sd, 0x3500, oexposurehigh);
2571 return 0;
2572 }
2573
2574 #ifdef _FLASH_FUNC_
check_to_flash(struct v4l2_subdev * sd)2575 void check_to_flash(struct v4l2_subdev *sd)
2576 {
2577 struct sensor_info *info = to_state(sd);
2578
2579 if (info->flash_mode == V4L2_FLASH_LED_MODE_FLASH) {
2580 to_flash = 1;
2581 } else if (info->flash_mode == V4L2_FLASH_LED_MODE_AUTO) {
2582 sensor_get_lum(sd);
2583 if (current_lum < flash_auto_level)
2584 to_flash = 1;
2585 else
2586 to_flash = 0;
2587 } else {
2588 to_flash = 0;
2589 }
2590
2591 sensor_dbg("to_flash=%d\n", to_flash);
2592 }
2593 #endif
2594
2595 /* stuff about auto focus */
2596
sensor_download_af_fw(struct v4l2_subdev * sd)2597 static int sensor_download_af_fw(struct v4l2_subdev *sd)
2598 {
2599 int ret, cnt;
2600 data_type rdval;
2601 int reload_cnt = 0;
2602
2603 struct regval_list af_fw_reset_reg[] = {
2604 {0x3000, 0x20},
2605 };
2606 struct regval_list af_fw_start_reg[] = {
2607 {0x3022, 0x00},
2608 {0x3023, 0x00},
2609 {0x3024, 0x00},
2610 {0x3025, 0x00},
2611 {0x3026, 0x00},
2612 {0x3027, 0x00},
2613 {0x3028, 0x00},
2614 {0x3029, 0x7f},
2615 {0x3000, 0x00},
2616 };
2617
2618
2619 ret =
2620 sensor_write_array(sd, af_fw_reset_reg,
2621 ARRAY_SIZE(af_fw_reset_reg));
2622 if (ret < 0) {
2623 sensor_err("reset sensor MCU error\n");
2624 return ret;
2625 }
2626
2627 ret =
2628 cci_write_a16_d8_continuous_helper(sd, 0x8000, sensor_af_fw_regs,
2629 ARRAY_SIZE(sensor_af_fw_regs));
2630 if (ret < 0) {
2631 sensor_err("download af fw error\n");
2632 return ret;
2633 }
2634
2635 ret =
2636 sensor_write_array(sd, af_fw_start_reg,
2637 ARRAY_SIZE(af_fw_start_reg));
2638 if (ret < 0) {
2639 sensor_err("start af firmware error\n");
2640 return ret;
2641 }
2642
2643 usleep_range(10000, 10500);
2644
2645 rdval = 0xff;
2646 cnt = 0;
2647 recheck_af_fw:
2648 while (rdval != 0x70) {
2649 ret = sensor_read(sd, 0x3029, &rdval);
2650 if (ret < 0) {
2651 sensor_err
2652 ("sensor check the af firmware status err !\n");
2653 return ret;
2654 }
2655 cnt++;
2656 if (cnt > 3) {
2657 sensor_err("AF firmware check status time out !\n");
2658 reload_cnt++;
2659 if (reload_cnt <= 2) {
2660 sensor_err("AF firmware reload retry %d\n",
2661 reload_cnt);
2662 vin_gpio_write(sd, PWDN, CSI_GPIO_HIGH);
2663 usleep_range(10000, 12000);
2664 vin_gpio_write(sd, PWDN, CSI_GPIO_LOW);
2665 usleep_range(10000, 12000);
2666 goto recheck_af_fw;
2667 }
2668 return -EFAULT;
2669 }
2670 usleep_range(5000, 10000);
2671 }
2672 sensor_print("AF firmware check status complete, 0x3029 = 0x%x\n",
2673 rdval);
2674 return 0;
2675 }
2676
sensor_g_single_af(struct v4l2_subdev * sd)2677 static int sensor_g_single_af(struct v4l2_subdev *sd)
2678 {
2679 data_type rdval;
2680 struct sensor_info *info = to_state(sd);
2681 #ifdef _FLASH_FUNC_
2682 struct modules_config *modules = sd_to_modules(sd);
2683 #endif
2684 if (info->focus_status != 1)
2685 return V4L2_AUTO_FOCUS_STATUS_IDLE;
2686 rdval = 0xff;
2687 sensor_read(sd, 0x3029, &rdval);
2688 if (rdval == 0x10) {
2689 int ret = 0;
2690
2691 info->focus_status = 0;
2692 sensor_read(sd, 0x3028, &rdval);
2693 if (rdval == 0) {
2694 sensor_print("Single AF focus fail, 0x3028 = 0x%x\n",
2695 rdval);
2696 ret = V4L2_AUTO_FOCUS_STATUS_FAILED;
2697 } else {
2698 sensor_dbg("Single AF focus ok, 0x3028 = 0x%x\n",
2699 rdval);
2700 ret = V4L2_AUTO_FOCUS_STATUS_REACHED;
2701 }
2702 #ifdef _FLASH_FUNC_
2703 if (info->flash_mode != V4L2_FLASH_LED_MODE_NONE) {
2704 sensor_print("shut flash when af fail/ok\n");
2705 io_set_flash_ctrl(modules->modules.flash.sd,
2706 SW_CTRL_FLASH_OFF);
2707 }
2708 #endif
2709 return ret;
2710 } else if (rdval == 0x70) {
2711 info->focus_status = 0;
2712 #ifdef _FLASH_FUNC_
2713 if (info->flash_mode != V4L2_FLASH_LED_MODE_NONE) {
2714 sensor_print("shut flash when af idle 2\n");
2715 io_set_flash_ctrl(modules->modules.flash.sd,
2716 SW_CTRL_FLASH_OFF);
2717 }
2718 #endif
2719 return V4L2_AUTO_FOCUS_STATUS_IDLE;
2720 } else if (rdval == 0x00) {
2721 info->focus_status = 1;
2722 return V4L2_AUTO_FOCUS_STATUS_BUSY;
2723 }
2724 return V4L2_AUTO_FOCUS_STATUS_BUSY;
2725 }
2726
sensor_g_contin_af(struct v4l2_subdev * sd)2727 static int sensor_g_contin_af(struct v4l2_subdev *sd)
2728 {
2729 data_type rdval;
2730 struct sensor_info *info = to_state(sd);
2731
2732 rdval = 0xff;
2733 sensor_read(sd, 0x3029, &rdval);
2734
2735 if (rdval == 0x20 || rdval == 0x10) {
2736 info->focus_status = 0;
2737 sensor_read(sd, 0x3028, &rdval);
2738 if (rdval == 0)
2739 return V4L2_AUTO_FOCUS_STATUS_FAILED;
2740 else
2741 return V4L2_AUTO_FOCUS_STATUS_REACHED;
2742 } else if (rdval == 0x00) {
2743 info->focus_status = 1;
2744 return V4L2_AUTO_FOCUS_STATUS_BUSY;
2745 } else {
2746 info->focus_status = 0;
2747 return V4L2_AUTO_FOCUS_STATUS_IDLE;
2748 }
2749 }
2750
sensor_g_af_status(struct v4l2_subdev * sd)2751 static int sensor_g_af_status(struct v4l2_subdev *sd)
2752 {
2753 int ret = 0;
2754 struct sensor_info *info = to_state(sd);
2755
2756 if (info->auto_focus == 1)
2757 ret = sensor_g_contin_af(sd);
2758 else
2759 ret = sensor_g_single_af(sd);
2760
2761 return ret;
2762 }
2763
sensor_g_3a_lock(struct v4l2_subdev * sd)2764 static int sensor_g_3a_lock(struct v4l2_subdev *sd)
2765 {
2766 struct sensor_info *info = to_state(sd);
2767
2768 return ((info->auto_focus == 0) ? V4L2_LOCK_FOCUS : ~V4L2_LOCK_FOCUS |
2769 (info->autowb == 0) ? V4L2_LOCK_WHITE_BALANCE :
2770 ~V4L2_LOCK_WHITE_BALANCE | (~V4L2_LOCK_EXPOSURE));
2771 }
2772
sensor_s_init_af(struct v4l2_subdev * sd)2773 static int sensor_s_init_af(struct v4l2_subdev *sd)
2774 {
2775 int ret;
2776 struct sensor_info *info = to_state(sd);
2777
2778 ret = sensor_download_af_fw(sd);
2779 if (ret == 0)
2780 info->af_first_flag = 0;
2781 return ret;
2782 }
2783
sensor_s_single_af(struct v4l2_subdev * sd)2784 static int sensor_s_single_af(struct v4l2_subdev *sd)
2785 {
2786 int ret;
2787 struct sensor_info *info = to_state(sd);
2788 #ifdef _FLASH_FUNC_
2789 struct modules_config *modules = sd_to_modules(sd);
2790 #endif
2791 data_type rdval = 0xff;
2792 unsigned int cnt = 0;
2793
2794 sensor_print("sensor_s_single_af\n");
2795
2796 info->focus_status = 0;
2797
2798 sensor_write(sd, 0x3023, 0x01);
2799
2800 ret = sensor_write(sd, 0x3022, 0x03);
2801 if (ret < 0) {
2802 sensor_err("sensor tigger single af err !\n");
2803 return ret;
2804 }
2805
2806 while (rdval != 0 && cnt < 10) {
2807 usleep_range(1000, 1200);
2808 ret = sensor_read(sd, 0x3023, &rdval);
2809 cnt++;
2810 }
2811 if (cnt > 10)
2812 sensor_dbg("set single af timeout\n");
2813
2814 #ifdef _FLASH_FUNC_
2815 if (info->flash_mode != V4L2_FLASH_LED_MODE_NONE) {
2816 check_to_flash(sd);
2817 if (to_flash == 1) {
2818 sensor_print("open torch when start single af\n");
2819 io_set_flash_ctrl(modules->modules.flash.sd,
2820 SW_CTRL_TORCH_ON);
2821 }
2822 }
2823 #endif
2824 info->focus_status = 1;
2825 info->auto_focus = 0;
2826 return 0;
2827 }
2828
sensor_s_continueous_af(struct v4l2_subdev * sd,int value)2829 static int sensor_s_continueous_af(struct v4l2_subdev *sd, int value)
2830 {
2831 struct sensor_info *info = to_state(sd);
2832
2833 sensor_print("sensor_s_continuous_af[0x%x]\n", value);
2834 if (info->focus_status == 1) {
2835 sensor_err("continuous focus not accepted when single focus\n");
2836 return -1;
2837 }
2838 if ((info->auto_focus == value)) {
2839 sensor_dbg("already in same focus mode\n");
2840 return 0;
2841 }
2842
2843 if (value == 1) {
2844 sensor_write(sd, 0x3022, 0x04);
2845 sensor_write(sd, 0x3022, 0x80);
2846 info->auto_focus = 1;
2847 } else {
2848 sensor_write(sd, 0x3022, 0x06);
2849 info->auto_focus = 0;
2850 }
2851 return 0;
2852 }
2853
sensor_s_pause_af(struct v4l2_subdev * sd)2854 static int sensor_s_pause_af(struct v4l2_subdev *sd)
2855 {
2856
2857 sensor_print("sensor_s_pause_af\n");
2858 sensor_write(sd, 0x3022, 0x06);
2859 return 0;
2860 }
2861
sensor_s_release_af(struct v4l2_subdev * sd)2862 static int sensor_s_release_af(struct v4l2_subdev *sd)
2863 {
2864
2865 sensor_print("sensor_s_release_af\n");
2866 sensor_write(sd, 0x3022, 0x08);
2867 return 0;
2868 }
2869
2870 #if 1
sensor_s_relaunch_af_zone(struct v4l2_subdev * sd)2871 static int sensor_s_relaunch_af_zone(struct v4l2_subdev *sd)
2872 {
2873
2874 sensor_print("sensor_s_relaunch_af_zone\n");
2875 sensor_write(sd, 0x3023, 0x01);
2876 sensor_write(sd, 0x3022, 0x80);
2877 usleep_range(5000, 6000);
2878 return 0;
2879 }
2880 #endif
2881
sensor_s_af_zone(struct v4l2_subdev * sd,struct v4l2_win_coordinate * win_c)2882 static int sensor_s_af_zone(struct v4l2_subdev *sd,
2883 struct v4l2_win_coordinate *win_c)
2884 {
2885 struct sensor_info *info = to_state(sd);
2886 int ret;
2887
2888 int x1, y1, x2, y2;
2889 unsigned int xc, yc;
2890 unsigned int prv_x, prv_y;
2891
2892 sensor_print("sensor_s_af_zone\n");
2893
2894 if (info->width == 0 || info->height == 0) {
2895 sensor_err("current width or height is zero!\n");
2896 return -EINVAL;
2897 }
2898
2899 prv_x = (int)info->width;
2900 prv_y = (int)info->height;
2901
2902 x1 = win_c->x1;
2903 y1 = win_c->y1;
2904 x2 = win_c->x2;
2905 y2 = win_c->y2;
2906
2907 #ifdef AF_WIN_NEW_COORD
2908 xc = prv_x * ((unsigned int)(2000 + x1 + x2) / 2) / 2000;
2909 yc = (prv_y * ((unsigned int)(2000 + y1 + y2) / 2) / 2000);
2910 #else
2911 xc = (x1 + x2) / 2;
2912 yc = (y1 + y2) / 2;
2913 #endif
2914
2915 sensor_dbg("af zone input xc=%d,yc=%d\n", xc, yc);
2916
2917 if (x1 > x2 || y1 > y2 || xc > info->width || yc > info->height) {
2918 sensor_dbg("invalid af win![%d,%d][%d,%d] prv[%d/%d]\n", x1,
2919 y1, x2, y2, prv_x, prv_y);
2920 return -EINVAL;
2921 }
2922
2923 if (info->focus_status == 1)
2924 return 0;
2925
2926 xc = (xc * 80 * 2 / info->width + 1) / 2;
2927 if ((info->width == HD720_WIDTH && info->height == HD720_HEIGHT) ||
2928 (info->width == HD1080_WIDTH && info->height == HD1080_HEIGHT)) {
2929 yc = (yc * 45 * 2 / info->height + 1) / 2;
2930 } else {
2931 yc = (yc * 60 * 2 / info->height + 1) / 2;
2932 }
2933
2934 sensor_dbg("af zone after xc=%d,yc=%d\n", xc, yc);
2935
2936 ret = sensor_write(sd, 0x3024, xc);
2937 if (ret < 0) {
2938 sensor_err("sensor_s_af_zone_xc error!\n");
2939 return ret;
2940 }
2941
2942 ret = sensor_write(sd, 0x3025, yc);
2943 if (ret < 0) {
2944 sensor_err("sensor_s_af_zone_yc error!\n");
2945 return ret;
2946 }
2947
2948 ret = sensor_write(sd, 0x3023, 0x01);
2949
2950 ret |= sensor_write(sd, 0x3022, 0x81);
2951 if (ret < 0) {
2952 sensor_err("sensor_s_af_zone error!\n");
2953 return ret;
2954 }
2955
2956 sensor_s_relaunch_af_zone(sd);
2957 return 0;
2958 }
2959
sensor_s_3a_lock(struct v4l2_subdev * sd,int value)2960 static int sensor_s_3a_lock(struct v4l2_subdev *sd, int value)
2961 {
2962 int ret;
2963
2964 value = !((value & V4L2_LOCK_FOCUS) >> 2);
2965 if (value == 0)
2966 ret = sensor_s_pause_af(sd);
2967 else
2968 ret = sensor_s_relaunch_af_zone(sd);
2969
2970 return ret;
2971 }
2972
2973 #if 1
sensor_s_sharpness_auto(struct v4l2_subdev * sd)2974 static int sensor_s_sharpness_auto(struct v4l2_subdev *sd)
2975 {
2976 data_type rdval;
2977
2978 sensor_read(sd, 0x5308, &rdval);
2979 sensor_write(sd, 0x5308, rdval & 0xbf);
2980 return sensor_write_array(sd, sensor_sharpness_auto_regs,
2981 ARRAY_SIZE(sensor_sharpness_auto_regs));
2982 }
2983 #endif
2984
sensor_s_sharpness_value(struct v4l2_subdev * sd,data_type value)2985 static int sensor_s_sharpness_value(struct v4l2_subdev *sd, data_type value)
2986 {
2987 data_type rdval;
2988
2989 sensor_read(sd, 0x5308, &rdval);
2990 sensor_write(sd, 0x5308, rdval | 0x40);
2991 return sensor_write(sd, 0x5302, value);
2992 }
2993
2994 #if 1
sensor_s_denoise_auto(struct v4l2_subdev * sd)2995 static int sensor_s_denoise_auto(struct v4l2_subdev *sd)
2996 {
2997 data_type rdval;
2998
2999 sensor_read(sd, 0x5308, &rdval);
3000 sensor_write(sd, 0x5308, rdval & 0xef);
3001 return sensor_write_array(sd, sensor_denoise_auto_regs,
3002 ARRAY_SIZE(sensor_denoise_auto_regs));
3003 }
3004 #endif
3005
sensor_s_denoise_value(struct v4l2_subdev * sd,data_type value)3006 static int sensor_s_denoise_value(struct v4l2_subdev *sd, data_type value)
3007 {
3008 data_type rdval;
3009
3010 sensor_read(sd, 0x5308, &rdval);
3011 sensor_write(sd, 0x5308, rdval | 0x10);
3012 return sensor_write(sd, 0x5306, value);
3013 }
3014
3015 /* **********************begin of ******************************* */
3016
sensor_g_hflip(struct v4l2_subdev * sd,__s32 * value)3017 static int sensor_g_hflip(struct v4l2_subdev *sd, __s32 *value)
3018 {
3019 struct sensor_info *info = to_state(sd);
3020 data_type rdval;
3021
3022 sensor_read(sd, 0x3821, &rdval);
3023
3024 rdval &= (1 << 1);
3025 rdval >>= 1;
3026
3027 *value = rdval;
3028
3029 info->hflip = *value;
3030 return 0;
3031 }
3032
sensor_s_hflip(struct v4l2_subdev * sd,int value)3033 static int sensor_s_hflip(struct v4l2_subdev *sd, int value)
3034 {
3035 struct sensor_info *info = to_state(sd);
3036 data_type rdval;
3037
3038 if (info->hflip == value)
3039 return 0;
3040
3041 sensor_read(sd, 0x3821, &rdval);
3042
3043 switch (value) {
3044 case 0:
3045 rdval &= 0xf9;
3046 break;
3047 case 1:
3048 rdval |= 0x06;
3049 break;
3050 default:
3051 return -EINVAL;
3052 }
3053
3054 sensor_write(sd, 0x3821, rdval);
3055
3056 usleep_range(10000, 12000);
3057 info->hflip = value;
3058 return 0;
3059 }
3060
sensor_g_vflip(struct v4l2_subdev * sd,__s32 * value)3061 static int sensor_g_vflip(struct v4l2_subdev *sd, __s32 *value)
3062 {
3063 struct sensor_info *info = to_state(sd);
3064 data_type rdval;
3065
3066 sensor_read(sd, 0x3820, &rdval);
3067
3068 rdval &= (1 << 1);
3069 *value = rdval;
3070 rdval >>= 1;
3071
3072 info->vflip = *value;
3073 return 0;
3074 }
3075
sensor_s_vflip(struct v4l2_subdev * sd,int value)3076 static int sensor_s_vflip(struct v4l2_subdev *sd, int value)
3077 {
3078 struct sensor_info *info = to_state(sd);
3079 data_type rdval;
3080
3081 if (info->vflip == value)
3082 return 0;
3083
3084 sensor_read(sd, 0x3820, &rdval);
3085
3086 switch (value) {
3087 case 0:
3088 rdval &= 0xf9;
3089 break;
3090 case 1:
3091 rdval |= 0x06;
3092 break;
3093 default:
3094 return -EINVAL;
3095 }
3096
3097 sensor_write(sd, 0x3820, rdval);
3098
3099 usleep_range(10000, 12000);
3100 info->vflip = value;
3101 return 0;
3102 }
3103
sensor_g_autogain(struct v4l2_subdev * sd,__s32 * value)3104 static int sensor_g_autogain(struct v4l2_subdev *sd, __s32 *value)
3105 {
3106 struct sensor_info *info = to_state(sd);
3107 data_type rdval;
3108
3109 sensor_read(sd, 0x3503, &rdval);
3110
3111 if ((rdval & 0x02) == 0x02)
3112 *value = 0;
3113 else
3114 *value = 1;
3115
3116 info->autogain = *value;
3117 return 0;
3118 }
3119
sensor_s_autogain(struct v4l2_subdev * sd,int value)3120 static int sensor_s_autogain(struct v4l2_subdev *sd, int value)
3121 {
3122 struct sensor_info *info = to_state(sd);
3123 data_type rdval;
3124
3125 sensor_read(sd, 0x3503, &rdval);
3126
3127 switch (value) {
3128 case 0:
3129 rdval |= 0x02;
3130 break;
3131 case 1:
3132 rdval &= 0xfd;
3133 break;
3134 default:
3135 return -EINVAL;
3136 }
3137
3138 sensor_write(sd, 0x3503, rdval);
3139
3140 info->autogain = value;
3141 return 0;
3142 }
3143
sensor_g_autoexp(struct v4l2_subdev * sd,__s32 * value)3144 static int sensor_g_autoexp(struct v4l2_subdev *sd, __s32 *value)
3145 {
3146 struct sensor_info *info = to_state(sd);
3147 data_type rdval;
3148
3149 sensor_read(sd, 0x3503, &rdval);
3150
3151 if ((rdval & 0x01) == 0x01)
3152 *value = V4L2_EXPOSURE_MANUAL;
3153 else
3154 *value = V4L2_EXPOSURE_AUTO;
3155
3156 info->autoexp = *value;
3157 return 0;
3158 }
3159
sensor_s_autoexp(struct v4l2_subdev * sd,enum v4l2_exposure_auto_type value)3160 static int sensor_s_autoexp(struct v4l2_subdev *sd,
3161 enum v4l2_exposure_auto_type value)
3162 {
3163 struct sensor_info *info = to_state(sd);
3164 data_type rdval;
3165
3166 sensor_read(sd, 0x3503, &rdval);
3167
3168 switch (value) {
3169 case V4L2_EXPOSURE_AUTO:
3170 rdval &= 0xfe;
3171 break;
3172 case V4L2_EXPOSURE_MANUAL:
3173 rdval |= 0x01;
3174 break;
3175 case V4L2_EXPOSURE_SHUTTER_PRIORITY:
3176 return -EINVAL;
3177 case V4L2_EXPOSURE_APERTURE_PRIORITY:
3178 return -EINVAL;
3179 default:
3180 return -EINVAL;
3181 }
3182
3183 sensor_write(sd, 0x3503, rdval);
3184
3185 info->autoexp = value;
3186 return 0;
3187 }
3188
sensor_g_autowb(struct v4l2_subdev * sd,int * value)3189 static int sensor_g_autowb(struct v4l2_subdev *sd, int *value)
3190 {
3191 struct sensor_info *info = to_state(sd);
3192 data_type rdval;
3193
3194 sensor_read(sd, 0x3406, &rdval);
3195
3196 rdval &= (1 << 1);
3197 rdval = rdval >> 1;
3198
3199 *value = (rdval == 1) ? 0 : 1;
3200 info->autowb = *value;
3201 return 0;
3202 }
3203
sensor_s_autowb(struct v4l2_subdev * sd,int value)3204 static int sensor_s_autowb(struct v4l2_subdev *sd, int value)
3205 {
3206 struct sensor_info *info = to_state(sd);
3207 data_type rdval;
3208
3209 if (info->autowb == value)
3210 return 0;
3211
3212 sensor_write_array(sd, sensor_wb_auto_regs,
3213 ARRAY_SIZE(sensor_wb_auto_regs));
3214 sensor_read(sd, 0x3406, &rdval);
3215
3216 switch (value) {
3217 case 0:
3218 rdval |= 0x01;
3219 break;
3220 case 1:
3221 rdval &= 0xfe;
3222 break;
3223 default:
3224 break;
3225 }
3226
3227 sensor_write(sd, 0x3406, rdval);
3228
3229 info->autowb = value;
3230 return 0;
3231 }
3232
3233 int ov5640_sensor_vts;
sensor_s_exp_gain(struct v4l2_subdev * sd,struct sensor_exp_gain * exp_gain)3234 static int sensor_s_exp_gain(struct v4l2_subdev *sd,
3235 struct sensor_exp_gain *exp_gain)
3236 {
3237 int exp_val, gain_val, frame_length, shutter;
3238 unsigned char explow = 0, expmid = 0, exphigh = 0;
3239 unsigned char gainlow = 0, gainhigh = 0;
3240 struct sensor_info *info = to_state(sd);
3241
3242 exp_val = exp_gain->exp_val;
3243 gain_val = exp_gain->gain_val;
3244
3245 sensor_print("exp_val %d, gain_val %d\n", exp_val, gain_val);
3246
3247 if (gain_val < 1 * 16)
3248 gain_val = 16;
3249 if (gain_val > 64 * 16 - 1)
3250 gain_val = 64 * 16 - 1;
3251
3252 if (exp_val > 0xfffff)
3253 exp_val = 0xfffff;
3254
3255 gainlow = (unsigned char)(gain_val & 0xff);
3256 gainhigh = (unsigned char)((gain_val >> 8) & 0x3);
3257
3258 exphigh = (unsigned char)((0x0f0000 & exp_val) >> 16);
3259 expmid = (unsigned char)((0x00ff00 & exp_val) >> 8);
3260 explow = (unsigned char)((0x0000ff & exp_val));
3261 shutter = exp_val / 16;
3262
3263
3264 if (shutter > ov5640_sensor_vts - 4)
3265 frame_length = shutter + 4;
3266 else
3267 frame_length = ov5640_sensor_vts;
3268
3269
3270 sensor_write(sd, 0x3208, 0x00);
3271
3272 sensor_write(sd, 0x3503, 0x07);
3273
3274 sensor_write(sd, 0x380f, (frame_length & 0xff));
3275 sensor_write(sd, 0x380e, (frame_length >> 8));
3276
3277 sensor_write(sd, 0x350b, gainlow);
3278 sensor_write(sd, 0x350a, gainhigh);
3279
3280 sensor_write(sd, 0x3502, explow);
3281 sensor_write(sd, 0x3501, expmid);
3282 sensor_write(sd, 0x3500, exphigh);
3283 sensor_write(sd, 0x3208, 0x10);
3284 sensor_write(sd, 0x3208, 0xa0);
3285 info->exp = exp_val;
3286 info->gain = gain_val;
3287 return 0;
3288 }
3289
sensor_g_hue(struct v4l2_subdev * sd,__s32 * value)3290 static int sensor_g_hue(struct v4l2_subdev *sd, __s32 *value)
3291 {
3292 return -EINVAL;
3293 }
3294
sensor_s_hue(struct v4l2_subdev * sd,int value)3295 static int sensor_s_hue(struct v4l2_subdev *sd, int value)
3296 {
3297 return -EINVAL;
3298 }
3299
sensor_g_gain(struct v4l2_subdev * sd,__s32 * value)3300 static int sensor_g_gain(struct v4l2_subdev *sd, __s32 *value)
3301 {
3302 return -EINVAL;
3303 }
3304
sensor_s_gain(struct v4l2_subdev * sd,int value)3305 static int sensor_s_gain(struct v4l2_subdev *sd, int value)
3306 {
3307 return -EINVAL;
3308 }
3309
sensor_g_band_filter(struct v4l2_subdev * sd,__s32 * value)3310 static int sensor_g_band_filter(struct v4l2_subdev *sd, __s32 *value)
3311 {
3312 struct sensor_info *info = to_state(sd);
3313 data_type rdval;
3314
3315 sensor_read(sd, 0x3a00, &rdval);
3316
3317 if ((rdval & (1 << 5)) == (1 << 5))
3318 info->band_filter = V4L2_CID_POWER_LINE_FREQUENCY_DISABLED;
3319 else {
3320 sensor_read(sd, 0x3c00, &rdval);
3321 if ((rdval & (1 << 2)) == (1 << 2))
3322 info->band_filter = V4L2_CID_POWER_LINE_FREQUENCY_50HZ;
3323 else
3324 info->band_filter = V4L2_CID_POWER_LINE_FREQUENCY_60HZ;
3325 }
3326 return 0;
3327 }
3328
sensor_s_band_filter(struct v4l2_subdev * sd,enum v4l2_power_line_frequency value)3329 static int sensor_s_band_filter(struct v4l2_subdev *sd,
3330 enum v4l2_power_line_frequency value)
3331 {
3332 struct sensor_info *info = to_state(sd);
3333 data_type rdval;
3334
3335 if (info->band_filter == value)
3336 return 0;
3337
3338 switch (value) {
3339 case V4L2_CID_POWER_LINE_FREQUENCY_DISABLED:
3340 sensor_read(sd, 0x3a00, &rdval);
3341 sensor_write(sd, 0x3a00, rdval & 0xdf);
3342 break;
3343 case V4L2_CID_POWER_LINE_FREQUENCY_50HZ:
3344 sensor_write(sd, 0x3c00, 0x04);
3345 sensor_write(sd, 0x3c01, 0x80);
3346 sensor_read(sd, 0x3a00, &rdval);
3347 sensor_write(sd, 0x3a00, rdval | 0x20);
3348 break;
3349 case V4L2_CID_POWER_LINE_FREQUENCY_60HZ:
3350 sensor_write(sd, 0x3c00, 0x00);
3351 sensor_write(sd, 0x3c01, 0x80);
3352 sensor_read(sd, 0x3a00, &rdval);
3353 sensor_write(sd, 0x3a00, rdval | 0x20);
3354 break;
3355 case V4L2_CID_POWER_LINE_FREQUENCY_AUTO:
3356 break;
3357 default:
3358 break;
3359 }
3360
3361 info->band_filter = value;
3362 return 0;
3363 }
3364
3365 /* ********************************end of ******************************* */
3366
sensor_g_brightness(struct v4l2_subdev * sd,__s32 * value)3367 static int sensor_g_brightness(struct v4l2_subdev *sd, __s32 *value)
3368 {
3369 struct sensor_info *info = to_state(sd);
3370
3371 *value = info->brightness;
3372 return 0;
3373 }
3374
sensor_s_brightness(struct v4l2_subdev * sd,int value)3375 static int sensor_s_brightness(struct v4l2_subdev *sd, int value)
3376 {
3377 struct sensor_info *info = to_state(sd);
3378
3379 if (info->brightness == value)
3380 return 0;
3381
3382 if (value < 0 || value > 8)
3383 return -ERANGE;
3384
3385 sensor_write_array(sd, sensor_brightness[value].regs,
3386 sensor_brightness[value].size);
3387
3388 info->brightness = value;
3389 return 0;
3390 }
3391
sensor_g_contrast(struct v4l2_subdev * sd,__s32 * value)3392 static int sensor_g_contrast(struct v4l2_subdev *sd, __s32 *value)
3393 {
3394 struct sensor_info *info = to_state(sd);
3395
3396 *value = info->contrast;
3397 return 0;
3398 }
3399
sensor_s_contrast(struct v4l2_subdev * sd,int value)3400 static int sensor_s_contrast(struct v4l2_subdev *sd, int value)
3401 {
3402 struct sensor_info *info = to_state(sd);
3403
3404 if (info->contrast == value)
3405 return 0;
3406
3407 if (value < 0 || value > 8)
3408 return -ERANGE;
3409
3410 sensor_write_array(sd, sensor_contrast[value].regs,
3411 sensor_contrast[value].size);
3412
3413 info->contrast = value;
3414 return 0;
3415 }
3416
sensor_g_saturation(struct v4l2_subdev * sd,__s32 * value)3417 static int sensor_g_saturation(struct v4l2_subdev *sd, __s32 *value)
3418 {
3419 struct sensor_info *info = to_state(sd);
3420
3421 *value = info->saturation;
3422 return 0;
3423 }
3424
sensor_s_saturation(struct v4l2_subdev * sd,int value)3425 static int sensor_s_saturation(struct v4l2_subdev *sd, int value)
3426 {
3427 struct sensor_info *info = to_state(sd);
3428
3429 if (info->saturation == value)
3430 return 0;
3431
3432 if (value < 0 || value > 8)
3433 return -ERANGE;
3434
3435 sensor_write_array(sd, sensor_saturation[value].regs,
3436 sensor_saturation[value].size);
3437
3438 info->saturation = value;
3439 return 0;
3440 }
3441
sensor_g_exp_bias(struct v4l2_subdev * sd,__s32 * value)3442 static int sensor_g_exp_bias(struct v4l2_subdev *sd, __s32 *value)
3443 {
3444 struct sensor_info *info = to_state(sd);
3445
3446 *value = info->exp_bias;
3447 return 0;
3448 }
3449
sensor_s_exp_bias(struct v4l2_subdev * sd,int value)3450 static int sensor_s_exp_bias(struct v4l2_subdev *sd, int value)
3451 {
3452 struct sensor_info *info = to_state(sd);
3453
3454 if (info->exp_bias == value)
3455 return 0;
3456
3457 if (value < 0 || value > 8)
3458 return -ERANGE;
3459
3460 sensor_write(sd, 0x3503, 0x07);
3461 sensor_get_preview_exposure(sd);
3462 sensor_write(sd, 0x3503, 0x00);
3463
3464 sensor_write_array(sd, sensor_ev[value].regs,
3465 sensor_ev[value].size);
3466
3467 info->exp_bias = value;
3468 return 0;
3469 }
3470
sensor_g_wb(struct v4l2_subdev * sd,int * value)3471 static int sensor_g_wb(struct v4l2_subdev *sd, int *value)
3472 {
3473 struct sensor_info *info = to_state(sd);
3474 enum v4l2_auto_n_preset_white_balance *wb_type =
3475 (enum v4l2_auto_n_preset_white_balance *)value;
3476
3477 *wb_type = info->wb;
3478
3479 return 0;
3480 }
3481
sensor_s_wb(struct v4l2_subdev * sd,enum v4l2_auto_n_preset_white_balance value)3482 static int sensor_s_wb(struct v4l2_subdev *sd,
3483 enum v4l2_auto_n_preset_white_balance value)
3484 {
3485 struct sensor_info *info = to_state(sd);
3486
3487 if (info->capture_mode == V4L2_MODE_IMAGE)
3488 return 0;
3489
3490 if (info->wb == value)
3491 return 0;
3492 sensor_write_array(sd, sensor_wb[value].regs,
3493 sensor_wb[value].size);
3494
3495 if (value == V4L2_WHITE_BALANCE_AUTO)
3496 info->autowb = 1;
3497 else
3498 info->autowb = 0;
3499
3500 info->wb = value;
3501 return 0;
3502 }
3503
sensor_g_colorfx(struct v4l2_subdev * sd,__s32 * value)3504 static int sensor_g_colorfx(struct v4l2_subdev *sd, __s32 *value)
3505 {
3506 struct sensor_info *info = to_state(sd);
3507 enum v4l2_colorfx *clrfx_type = (enum v4l2_colorfx *)value;
3508
3509 *clrfx_type = info->clrfx;
3510 return 0;
3511 }
3512
sensor_s_colorfx(struct v4l2_subdev * sd,enum v4l2_colorfx value)3513 static int sensor_s_colorfx(struct v4l2_subdev *sd, enum v4l2_colorfx value)
3514 {
3515 struct sensor_info *info = to_state(sd);
3516
3517 if (info->clrfx == value)
3518 return 0;
3519
3520 sensor_write_array(sd, sensor_colorfx[value].regs,
3521 sensor_colorfx[value].size);
3522
3523 info->clrfx = value;
3524 return 0;
3525 }
3526
sensor_g_flash_mode(struct v4l2_subdev * sd,__s32 * value)3527 static int sensor_g_flash_mode(struct v4l2_subdev *sd, __s32 *value)
3528 {
3529 struct sensor_info *info = to_state(sd);
3530
3531 enum v4l2_flash_led_mode *flash_mode =
3532 (enum v4l2_flash_led_mode *)value;
3533
3534 *flash_mode = info->flash_mode;
3535 return 0;
3536 }
3537
sensor_s_flash_mode(struct v4l2_subdev * sd,enum v4l2_flash_led_mode value)3538 static int sensor_s_flash_mode(struct v4l2_subdev *sd,
3539 enum v4l2_flash_led_mode value)
3540 {
3541 struct sensor_info *info = to_state(sd);
3542
3543 sensor_dbg("sensor_s_flash_mode[%d]!\n", value);
3544
3545 info->flash_mode = value;
3546 return 0;
3547 }
3548
3549 /*
3550 * Stuff that knows about the sensor.
3551 */
3552
sensor_power(struct v4l2_subdev * sd,int on)3553 static int sensor_power(struct v4l2_subdev *sd, int on)
3554 {
3555 int ret = 0;
3556 #ifdef _FLASH_FUNC_
3557 struct modules_config *modules = sd_to_modules(sd);
3558 #endif
3559 switch (on) {
3560 case STBY_ON:
3561 sensor_dbg("STBY_ON!\n");
3562 #ifdef _FLASH_FUNC_
3563 io_set_flash_ctrl(modules->modules.flash.sd,
3564 SW_CTRL_FLASH_OFF);
3565 #endif
3566 sensor_s_release_af(sd);
3567 ret =
3568 sensor_write_array(sd, sensor_sw_stby_on_regs,
3569 ARRAY_SIZE(sensor_sw_stby_on_regs));
3570 if (ret < 0)
3571 sensor_err("soft stby falied!\n");
3572 usleep_range(10000, 12000);
3573 sensor_print("disalbe oe!\n");
3574 ret =
3575 sensor_write_array(sd, sensor_oe_disable_regs,
3576 ARRAY_SIZE(sensor_oe_disable_regs));
3577 if (ret < 0)
3578 sensor_err("disalbe oe falied!\n");
3579
3580 cci_lock(sd);
3581 vin_gpio_write(sd, PWDN, CSI_GPIO_HIGH);
3582 cci_unlock(sd);
3583 vin_set_mclk(sd, OFF);
3584 break;
3585 case STBY_OFF:
3586 sensor_dbg("STBY_OFF!\n");
3587 cci_lock(sd);
3588 vin_set_mclk_freq(sd, MCLK / MCLK_DIV);
3589 vin_set_mclk(sd, ON);
3590 usleep_range(10000, 12000);
3591 vin_gpio_write(sd, PWDN, CSI_GPIO_LOW);
3592 usleep_range(10000, 12000);
3593 cci_unlock(sd);
3594 sensor_print("enable oe!\n");
3595 ret =
3596 sensor_write_array(sd, sensor_oe_enable_regs,
3597 ARRAY_SIZE(sensor_oe_enable_regs));
3598 if (ret < 0)
3599 sensor_err("enable oe falied!\n");
3600 ret =
3601 sensor_write_array(sd, sensor_sw_stby_off_regs,
3602 ARRAY_SIZE(sensor_sw_stby_off_regs));
3603 if (ret < 0)
3604 sensor_err("soft stby off falied!\n");
3605 usleep_range(10000, 12000);
3606 break;
3607 case PWR_ON:
3608 sensor_print("PWR_ON!\n");
3609 cci_lock(sd);
3610 vin_set_pmu_channel(sd, CAMERAVDD, ON);
3611 vin_gpio_set_status(sd, PWDN, 1);
3612 vin_gpio_set_status(sd, RESET, 1);
3613 vin_gpio_write(sd, PWDN, CSI_GPIO_HIGH);
3614 vin_gpio_write(sd, RESET, CSI_GPIO_LOW);
3615 usleep_range(1000, 1200);
3616 vin_set_mclk_freq(sd, MCLK / MCLK_DIV);
3617 vin_set_mclk(sd, ON);
3618 usleep_range(10000, 12000);
3619 vin_gpio_write(sd, POWER_EN, CSI_GPIO_HIGH);
3620 vin_set_pmu_channel(sd, IOVDD, ON);
3621 vin_set_pmu_channel(sd, AVDD, ON);
3622 vin_set_pmu_channel(sd, DVDD, ON);
3623 vin_set_pmu_channel(sd, AFVDD, ON);
3624 vin_gpio_write(sd, PWDN, CSI_GPIO_LOW);
3625 usleep_range(10000, 12000);
3626 vin_gpio_write(sd, RESET, CSI_GPIO_HIGH);
3627 usleep_range(30000, 31000);
3628 cci_unlock(sd);
3629 break;
3630 case PWR_OFF:
3631 sensor_print("PWR_OFF!\n");
3632 cci_lock(sd);
3633 vin_set_mclk(sd, OFF);
3634 vin_gpio_write(sd, POWER_EN, CSI_GPIO_LOW);
3635 vin_set_pmu_channel(sd, AFVDD, OFF);
3636 vin_set_pmu_channel(sd, DVDD, OFF);
3637 vin_set_pmu_channel(sd, AVDD, OFF);
3638 vin_set_pmu_channel(sd, IOVDD, OFF);
3639 vin_set_pmu_channel(sd, CAMERAVDD, OFF);
3640 usleep_range(10000, 12000);
3641 vin_gpio_write(sd, PWDN, CSI_GPIO_HIGH);
3642 vin_gpio_write(sd, RESET, CSI_GPIO_LOW);
3643 vin_gpio_set_status(sd, RESET, 0);
3644 vin_gpio_set_status(sd, PWDN, 0);
3645 cci_unlock(sd);
3646 break;
3647 default:
3648 return -EINVAL;
3649 }
3650
3651 return 0;
3652 }
3653
sensor_reset(struct v4l2_subdev * sd,u32 val)3654 static int sensor_reset(struct v4l2_subdev *sd, u32 val)
3655 {
3656 switch (val) {
3657 case 0:
3658 vin_gpio_write(sd, RESET, CSI_GPIO_HIGH);
3659 usleep_range(10000, 12000);
3660 break;
3661 case 1:
3662 vin_gpio_write(sd, RESET, CSI_GPIO_LOW);
3663 usleep_range(10000, 12000);
3664 break;
3665 default:
3666 return -EINVAL;
3667 }
3668
3669 return 0;
3670 }
3671
sensor_detect(struct v4l2_subdev * sd)3672 static int sensor_detect(struct v4l2_subdev *sd)
3673 {
3674 unsigned int SENSOR_ID = 0;
3675 data_type val;
3676 int cnt = 0;
3677
3678 sensor_read(sd, 0x300a, &val);
3679 SENSOR_ID |= (val << 8);
3680 sensor_read(sd, 0x300b, &val);
3681 SENSOR_ID |= (val);
3682 sensor_print("V4L2_IDENT_SENSOR = %x\n", SENSOR_ID);
3683
3684 while ((SENSOR_ID != V4L2_IDENT_SENSOR) && (cnt < 5)) {
3685 sensor_read(sd, 0x300a, &val);
3686 SENSOR_ID |= (val << 8);
3687 sensor_read(sd, 0x300b, &val);
3688 SENSOR_ID |= (val);
3689 sensor_print("retry = %d, V4L2_IDENT_SENSOR = %x\n", cnt, SENSOR_ID);
3690 cnt++;
3691 }
3692
3693 if (SENSOR_ID != V4L2_IDENT_SENSOR)
3694 return -ENODEV;
3695
3696 return 0;
3697
3698 }
3699
sensor_init(struct v4l2_subdev * sd,u32 val)3700 static int sensor_init(struct v4l2_subdev *sd, u32 val)
3701 {
3702 int ret;
3703 struct sensor_info *info = to_state(sd);
3704
3705 sensor_dbg("sensor_init 0x%x\n", val);
3706
3707 /*Make sure it is a target sensor */
3708 ret = sensor_detect(sd);
3709 if (ret) {
3710 sensor_err("chip found is not an target chip.\n");
3711 return ret;
3712 }
3713
3714 ogain = 0x28;
3715 oexposurelow = 0x00;
3716 oexposuremid = 0x3d;
3717 oexposurehigh = 0x00;
3718 info->focus_status = 0;
3719 info->low_speed = 0;
3720 info->width = 0;
3721 info->height = 0;
3722 info->brightness = 0;
3723 info->contrast = 0;
3724 info->saturation = 0;
3725 info->hue = 0;
3726 info->hflip = 0;
3727 info->vflip = 0;
3728 info->gain = 0;
3729 info->autogain = 1;
3730 info->exp_bias = 0;
3731 info->autoexp = 1;
3732 info->autowb = 1;
3733 info->wb = V4L2_WHITE_BALANCE_AUTO;
3734 info->clrfx = V4L2_COLORFX_NONE;
3735 info->band_filter = V4L2_CID_POWER_LINE_FREQUENCY_50HZ;
3736
3737
3738 info->tpf.numerator = 1;
3739 info->tpf.denominator = 30; /* 30fps */
3740
3741 ret =
3742 sensor_write_array(sd, sensor_default_regs,
3743 ARRAY_SIZE(sensor_default_regs));
3744 if (ret < 0) {
3745 sensor_err("write sensor_default_regs error\n");
3746 return ret;
3747 }
3748
3749 sensor_s_band_filter(sd, V4L2_CID_POWER_LINE_FREQUENCY_50HZ);
3750
3751 info->preview_first_flag = 1;
3752 night_mode = 0;
3753 Nfrms = MAX_FRM_CAP;
3754
3755 if (1 == AE_CW)
3756 sensor_write_array(sd, ae_centerweight_tbl,
3757 ARRAY_SIZE(ae_centerweight_tbl));
3758 else
3759 sensor_write_array(sd, ae_average_tbl,
3760 ARRAY_SIZE(ae_average_tbl));
3761
3762 return 0;
3763 }
3764
sensor_g_exif(struct v4l2_subdev * sd,struct sensor_exif_attribute * exif)3765 static int sensor_g_exif(struct v4l2_subdev *sd,
3766 struct sensor_exif_attribute *exif)
3767 {
3768 int ret = 0;
3769
3770 exif->fnumber = 220;
3771 exif->focal_length = 180;
3772 exif->brightness = 125;
3773 exif->flash_fire = 0;
3774 exif->iso_speed = 200;
3775 exif->exposure_time_num = 1;
3776 exif->exposure_time_den = 15;
3777 return ret;
3778 }
sensor_s_af_win(struct v4l2_subdev * sd,struct v4l2_win_setting * af_win)3779 static void sensor_s_af_win(struct v4l2_subdev *sd,
3780 struct v4l2_win_setting *af_win)
3781 {
3782 sensor_s_af_zone(sd, &af_win->coor);
3783 }
sensor_s_ae_win(struct v4l2_subdev * sd,struct v4l2_win_setting * ae_win)3784 static void sensor_s_ae_win(struct v4l2_subdev *sd,
3785 struct v4l2_win_setting *ae_win)
3786 {
3787
3788 }
3789
sensor_ioctl(struct v4l2_subdev * sd,unsigned int cmd,void * arg)3790 static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
3791 {
3792 int ret = 0;
3793
3794 switch (cmd) {
3795 case GET_SENSOR_EXIF:
3796 sensor_g_exif(sd, (struct sensor_exif_attribute *)arg);
3797 break;
3798 case SET_AUTO_FOCUS_WIN:
3799 sensor_s_af_win(sd, (struct v4l2_win_setting *)arg);
3800 break;
3801 case SET_AUTO_EXPOSURE_WIN:
3802 sensor_s_ae_win(sd, (struct v4l2_win_setting *)arg);
3803 break;
3804 case VIDIOC_VIN_SENSOR_EXP_GAIN:
3805 sensor_s_exp_gain(sd, (struct sensor_exp_gain *)arg);
3806 break;
3807 case VIDIOC_VIN_SENSOR_CFG_REQ:
3808 sensor_cfg_req(sd, (struct sensor_config *)arg);
3809 break;
3810
3811 default:
3812 return -EINVAL;
3813 }
3814 return ret;
3815 }
3816
3817 /*
3818 * Store information about the video data format.
3819 */
3820 static struct sensor_format_struct sensor_formats[] = {
3821 {
3822 .desc = "YUYV 4:2:2",
3823 .mbus_code = MEDIA_BUS_FMT_YUYV8_2X8,
3824 .regs = sensor_fmt_yuv422_yuyv,
3825 .regs_size = ARRAY_SIZE(sensor_fmt_yuv422_yuyv),
3826 .bpp = 2,
3827 }, {
3828 .desc = "YVYU 4:2:2",
3829 .mbus_code = MEDIA_BUS_FMT_YVYU8_2X8,
3830 .regs = sensor_fmt_yuv422_yvyu,
3831 .regs_size = ARRAY_SIZE(sensor_fmt_yuv422_yvyu),
3832 .bpp = 2,
3833 }, {
3834 .desc = "UYVY 4:2:2",
3835 .mbus_code = MEDIA_BUS_FMT_UYVY8_2X8,
3836 .regs = sensor_fmt_yuv422_uyvy,
3837 .regs_size = ARRAY_SIZE(sensor_fmt_yuv422_uyvy),
3838 .bpp = 2,
3839 }, {
3840 .desc = "VYUY 4:2:2",
3841 .mbus_code = MEDIA_BUS_FMT_VYUY8_2X8,
3842 .regs = sensor_fmt_yuv422_vyuy,
3843 .regs_size = ARRAY_SIZE(sensor_fmt_yuv422_vyuy),
3844 .bpp = 2,
3845 }, {
3846 .desc = "Raw RGB Bayer",
3847 .mbus_code = MEDIA_BUS_FMT_SBGGR8_1X8,
3848 .regs = sensor_fmt_raw,
3849 .regs_size = ARRAY_SIZE(sensor_fmt_raw),
3850 .bpp = 1
3851 },
3852 };
3853
3854 #define N_FMTS ARRAY_SIZE(sensor_formats)
3855
3856 /*
3857 * Then there is the issue of window sizes. Try to capture the info here.
3858 */
3859
3860 static struct sensor_win_size sensor_win_sizes[] = {
3861 /* qsxga: 2592*1936 */
3862 {
3863 .width = QSXGA_WIDTH,
3864 .height = QSXGA_HEIGHT,
3865 .hoffset = 0,
3866 .voffset = 0,
3867 .regs = sensor_qsxga_regs,
3868 .regs_size = ARRAY_SIZE(sensor_qsxga_regs),
3869 .set_size = NULL,
3870 },
3871 /* qxga: 2048*1536 */
3872 {
3873 .width = QXGA_WIDTH,
3874 .height = QXGA_HEIGHT,
3875 .hoffset = 0,
3876 .voffset = 0,
3877 .regs = sensor_qxga_regs,
3878 .regs_size = ARRAY_SIZE(sensor_qxga_regs),
3879 .set_size = NULL,
3880 },
3881 /* 1080P */
3882 {
3883 .width = HD1080_WIDTH,
3884 .height = HD1080_HEIGHT,
3885 .hoffset = 0,
3886 .voffset = 0,
3887 .regs = sensor_1080p_regs,
3888 .regs_size = ARRAY_SIZE(sensor_1080p_regs),
3889 .set_size = NULL,
3890 },
3891 /* UXGA */
3892 {
3893 .width = UXGA_WIDTH,
3894 .height = UXGA_HEIGHT,
3895 .hoffset = 0,
3896 .voffset = 0,
3897 .regs = sensor_uxga_regs,
3898 .regs_size = ARRAY_SIZE(sensor_uxga_regs),
3899 .set_size = NULL,
3900 },
3901 /* SXGA */
3902 {
3903 .width = SXGA_WIDTH,
3904 .height = SXGA_HEIGHT,
3905 .hoffset = 0,
3906 .voffset = 0,
3907 .regs = sensor_sxga_regs,
3908 .regs_size = ARRAY_SIZE(sensor_sxga_regs),
3909 .set_size = NULL,
3910 },
3911 /* 720p */
3912 {
3913 .width = HD720_WIDTH,
3914 .height = HD720_HEIGHT,
3915 .hoffset = 0,
3916 .voffset = 0,
3917 .hts = 1750,
3918 .vts = 800,
3919 .pclk = 42 * 1000 * 1000,
3920 .fps_fixed = 1,
3921 .bin_factor = 1,
3922 .intg_min = 1,
3923 .intg_max = 800 << 4,
3924 .gain_min = 1 << 4,
3925 .gain_max = 10 << 4,
3926 .regs = sensor_720p_regs,
3927 .regs_size = ARRAY_SIZE(sensor_720p_regs),
3928 .set_size = NULL,
3929 },
3930 /* XGA */
3931 {
3932 .width = XGA_WIDTH,
3933 .height = XGA_HEIGHT,
3934 .hoffset = 0,
3935 .voffset = 0,
3936 .regs = sensor_xga_regs,
3937 .regs_size = ARRAY_SIZE(sensor_xga_regs),
3938 .set_size = NULL,
3939 },
3940 /* SVGA */
3941 {
3942 .width = SVGA_WIDTH,
3943 .height = SVGA_HEIGHT,
3944 .hoffset = 0,
3945 .voffset = 0,
3946 .regs = sensor_svga_regs,
3947 .regs_size = ARRAY_SIZE(sensor_svga_regs),
3948 .set_size = NULL,
3949 },
3950 /* VGA */
3951 {
3952 .width = VGA_WIDTH,
3953 .height = VGA_HEIGHT,
3954 .hoffset = 0,
3955 .voffset = 0,
3956 .hts = 640,
3957 .vts = 480,
3958 .pclk = 9216 * 1000,
3959 .fps_fixed = 1,
3960 .bin_factor = 1,
3961 .intg_min = 1,
3962 .intg_max = 480 << 4,
3963 .gain_min = 1 << 4,
3964 .gain_max = 10 << 4,
3965 .regs = sensor_vga_regs,
3966 .regs_size = ARRAY_SIZE(sensor_vga_regs),
3967 .set_size = NULL,
3968 },
3969 };
3970
3971 #define N_WIN_SIZES (ARRAY_SIZE(sensor_win_sizes))
3972
sensor_g_mbus_config(struct v4l2_subdev * sd,unsigned int pad,struct v4l2_mbus_config * cfg)3973 static int sensor_g_mbus_config(struct v4l2_subdev *sd, unsigned int pad,
3974 struct v4l2_mbus_config *cfg)
3975 {
3976 cfg->type = V4L2_MBUS_PARALLEL;
3977 cfg->flags = V4L2_MBUS_MASTER | VREF_POL | HREF_POL | CLK_POL;
3978
3979 return 0;
3980 }
3981
3982 /*
3983 * Code for dealing with controls.
3984 * fill with different sensor module
3985 * different sensor module has different settings here
3986 * if not support the follow function ,retrun -EINVAL
3987 */
3988
3989 /* *****************************begin of ******************************* */
3990
sensor_g_ctrl(struct v4l2_ctrl * ctrl)3991 static int sensor_g_ctrl(struct v4l2_ctrl *ctrl)
3992 {
3993 struct sensor_info *info =
3994 container_of(ctrl->handler, struct sensor_info, handler);
3995 struct v4l2_subdev *sd = &info->sd;
3996
3997 switch (ctrl->id) {
3998 case V4L2_CID_BRIGHTNESS:
3999 return sensor_g_brightness(sd, &ctrl->val);
4000 case V4L2_CID_CONTRAST:
4001 return sensor_g_contrast(sd, &ctrl->val);
4002 case V4L2_CID_SATURATION:
4003 return sensor_g_saturation(sd, &ctrl->val);
4004 case V4L2_CID_HUE:
4005 return sensor_g_hue(sd, &ctrl->val);
4006 case V4L2_CID_VFLIP:
4007 return sensor_g_vflip(sd, &ctrl->val);
4008 case V4L2_CID_HFLIP:
4009 return sensor_g_hflip(sd, &ctrl->val);
4010 case V4L2_CID_GAIN:
4011 return sensor_g_gain(sd, &ctrl->val);
4012 case V4L2_CID_AUTOGAIN:
4013 return sensor_g_autogain(sd, &ctrl->val);
4014 case V4L2_CID_EXPOSURE:
4015 case V4L2_CID_AUTO_EXPOSURE_BIAS:
4016 return sensor_g_exp_bias(sd, &ctrl->val);
4017 case V4L2_CID_EXPOSURE_AUTO:
4018 return sensor_g_autoexp(sd, &ctrl->val);
4019 case V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE:
4020 return sensor_g_wb(sd, &ctrl->val);
4021 case V4L2_CID_AUTO_WHITE_BALANCE:
4022 return sensor_g_autowb(sd, &ctrl->val);
4023 case V4L2_CID_COLORFX:
4024 return sensor_g_colorfx(sd, &ctrl->val);
4025 case V4L2_CID_FLASH_LED_MODE:
4026 return sensor_g_flash_mode(sd, &ctrl->val);
4027 case V4L2_CID_POWER_LINE_FREQUENCY:
4028 return sensor_g_band_filter(sd, &ctrl->val);
4029 case V4L2_CID_3A_LOCK:
4030 return sensor_g_3a_lock(sd);
4031 case V4L2_CID_AUTO_FOCUS_STATUS:
4032 return sensor_g_af_status(sd);
4033
4034 }
4035 return -EINVAL;
4036 }
4037
sensor_s_ctrl(struct v4l2_ctrl * ctrl)4038 static int sensor_s_ctrl(struct v4l2_ctrl *ctrl)
4039 {
4040 struct sensor_info *info =
4041 container_of(ctrl->handler, struct sensor_info, handler);
4042 struct v4l2_subdev *sd = &info->sd;
4043
4044 switch (ctrl->id) {
4045 case V4L2_CID_BRIGHTNESS:
4046 return sensor_s_brightness(sd, ctrl->val);
4047 case V4L2_CID_CONTRAST:
4048 return sensor_s_contrast(sd, ctrl->val);
4049 case V4L2_CID_SATURATION:
4050 return sensor_s_saturation(sd, ctrl->val);
4051 case V4L2_CID_HUE:
4052 return sensor_s_hue(sd, ctrl->val);
4053 case V4L2_CID_VFLIP:
4054 return sensor_s_vflip(sd, ctrl->val);
4055 case V4L2_CID_HFLIP:
4056 return sensor_s_hflip(sd, ctrl->val);
4057 case V4L2_CID_GAIN:
4058 return sensor_s_gain(sd, ctrl->val);
4059 case V4L2_CID_AUTOGAIN:
4060 return sensor_s_autogain(sd, ctrl->val);
4061 case V4L2_CID_EXPOSURE:
4062 case V4L2_CID_AUTO_EXPOSURE_BIAS:
4063 return sensor_s_exp_bias(sd, ctrl->val);
4064 case V4L2_CID_EXPOSURE_AUTO:
4065 return sensor_s_autoexp(sd,
4066 (enum v4l2_exposure_auto_type)ctrl->val);
4067 case V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE:
4068 return sensor_s_wb(sd,
4069 (enum v4l2_auto_n_preset_white_balance)ctrl->val);
4070 case V4L2_CID_AUTO_WHITE_BALANCE:
4071 return sensor_s_autowb(sd, ctrl->val);
4072 case V4L2_CID_COLORFX:
4073 return sensor_s_colorfx(sd, (enum v4l2_colorfx)ctrl->val);
4074 case V4L2_CID_FLASH_LED_MODE:
4075 return sensor_s_flash_mode(sd,
4076 (enum v4l2_flash_led_mode)ctrl->val);
4077 case V4L2_CID_POWER_LINE_FREQUENCY:
4078 return sensor_s_band_filter(sd,
4079 (enum v4l2_power_line_frequency)ctrl->val);
4080 case V4L2_CID_3A_LOCK:
4081 return sensor_s_3a_lock(sd, ctrl->val);
4082 case V4L2_CID_AUTO_FOCUS_INIT:
4083 return sensor_s_init_af(sd);
4084 case V4L2_CID_AUTO_FOCUS_RELEASE:
4085 return sensor_s_release_af(sd);
4086 case V4L2_CID_AUTO_FOCUS_START:
4087 return sensor_s_single_af(sd);
4088 case V4L2_CID_AUTO_FOCUS_STOP:
4089 return sensor_s_pause_af(sd);
4090 case V4L2_CID_FOCUS_AUTO:
4091 return sensor_s_continueous_af(sd, ctrl->val);
4092 default:
4093 return -EINVAL;
4094 }
4095 return -EINVAL;
4096 }
4097
sensor_reg_init(struct sensor_info * info)4098 static int sensor_reg_init(struct sensor_info *info)
4099 {
4100 int ret;
4101 struct v4l2_subdev *sd = &info->sd;
4102 struct sensor_format_struct *sensor_fmt = info->fmt;
4103 struct sensor_win_size *wsize = info->current_wins;
4104
4105 #ifdef _FLASH_FUNC_
4106 struct modules_config *modules = sd_to_modules(sd);
4107 #endif
4108 sensor_dbg("sensor_reg_init\n");
4109
4110 /*
4111 ret =
4112 sensor_write_array(sd, sensor_default_regs,
4113 ARRAY_SIZE(sensor_default_regs));
4114 if (ret < 0) {
4115 sensor_err("write sensor_default_regs error\n");
4116 return ret;
4117 }
4118
4119 sensor_s_band_filter(sd, V4L2_CID_POWER_LINE_FREQUENCY_50HZ);
4120
4121 info->preview_first_flag = 1;
4122 night_mode = 0;
4123 Nfrms = MAX_FRM_CAP;
4124
4125 if (1 == AE_CW)
4126 sensor_write_array(sd, ae_centerweight_tbl,
4127 ARRAY_SIZE(ae_centerweight_tbl));
4128 else
4129 sensor_write_array(sd, ae_average_tbl,
4130 ARRAY_SIZE(ae_average_tbl));
4131 */
4132
4133 sensor_write_array(sd, sensor_oe_disable_regs,
4134 ARRAY_SIZE(sensor_oe_disable_regs));
4135
4136 if (info->capture_mode == V4L2_MODE_VIDEO) {
4137
4138 #ifdef _FLASH_FUNC_
4139 if (info->flash_mode != V4L2_FLASH_LED_MODE_NONE) {
4140
4141 io_set_flash_ctrl(modules->modules.flash.sd,
4142 SW_CTRL_FLASH_OFF);
4143 }
4144 #endif
4145 } else if (info->capture_mode == V4L2_MODE_IMAGE) {
4146
4147 ret = sensor_s_autoexp(sd, V4L2_EXPOSURE_MANUAL);
4148 if (ret < 0)
4149 sensor_err
4150 ("sensor_s_autoexp off err when capturing image!\n");
4151
4152 ret = sensor_s_autogain(sd, 0);
4153 if (ret < 0)
4154 sensor_err
4155 ("sensor_s_autogain off err when capturing image!\n");
4156
4157 if (wsize->width > SVGA_WIDTH) {
4158 #ifdef _FLASH_FUNC_
4159 check_to_flash(sd);
4160 #endif
4161 sensor_get_lum(sd);
4162 sensor_get_preview_exposure(sd);
4163 sensor_get_fps(sd);
4164 }
4165 #ifdef _FLASH_FUNC_
4166 if (info->flash_mode != V4L2_FLASH_LED_MODE_NONE) {
4167 if (to_flash == 1) {
4168 sensor_dbg("open flash when capture\n");
4169 io_set_flash_ctrl(modules->modules.flash.sd,
4170 SW_CTRL_FLASH_ON);
4171 sensor_get_lum(sd);
4172 sensor_get_preview_exposure(sd);
4173 sensor_get_fps(sd);
4174 msleep(50);
4175 }
4176 }
4177 #endif
4178 ret = sensor_s_autowb(sd, 0);
4179 if (ret < 0)
4180 sensor_err("sensor_s_autowb off err when image mode\n");
4181 }
4182
4183 sensor_write_array(sd, sensor_fmt->regs, sensor_fmt->regs_size);
4184
4185 if (wsize->regs)
4186 sensor_write_array(sd, wsize->regs, wsize->regs_size);
4187
4188 if (wsize->set_size)
4189 wsize->set_size(sd);
4190
4191 sensor_s_hflip(sd, info->hflip);
4192 sensor_s_vflip(sd, info->vflip);
4193
4194 if (info->capture_mode == V4L2_MODE_VIDEO ||
4195 info->capture_mode == V4L2_MODE_PREVIEW) {
4196 #ifdef AUTO_FPS
4197 if (info->capture_mode == V4L2_MODE_PREVIEW) {
4198 sensor_write_array(sd, sensor_auto_fps_mode,
4199 ARRAY_SIZE(sensor_auto_fps_mode));
4200 } else {
4201 sensor_write_array(sd, sensor_fix_fps_mode,
4202 ARRAY_SIZE(sensor_fix_fps_mode));
4203 }
4204 #endif
4205 ret = sensor_set_preview_exposure(sd);
4206 if (ret < 0)
4207 sensor_err("sensor_set_preview_exposure err!\n");
4208
4209 ret = sensor_s_autoexp(sd, V4L2_EXPOSURE_AUTO);
4210 if (ret < 0)
4211 sensor_err("sensor_s_autoexp on err at video mode\n");
4212
4213 ret = sensor_s_autogain(sd, 1);
4214 if (ret < 0)
4215 sensor_err("sensor_s_autogain on err at video mode\n");
4216
4217 if (info->wb == V4L2_WHITE_BALANCE_AUTO) {
4218 ret = sensor_s_autowb(sd, 1);
4219 if (ret < 0)
4220 sensor_err
4221 ("sensor_s_autowb on err at image mode\n");
4222 }
4223
4224 if (info->capture_mode == V4L2_MODE_VIDEO) {
4225
4226 if (wsize->width == 640) {
4227 sensor_s_sharpness_value(sd, 0x20);
4228 sensor_s_denoise_value(sd, 0x04);
4229 } else if (wsize->height == 960) {
4230 sensor_s_sharpness_value(sd, 0x08);
4231 sensor_s_denoise_value(sd, 0x08);
4232 } else if (wsize->height == 720) {
4233 sensor_s_sharpness_value(sd, 0x08);
4234 sensor_s_denoise_value(sd, 0x04);
4235 } else if (wsize->width == 1920) {
4236 sensor_s_sharpness_value(sd, 0x08);
4237 sensor_s_denoise_value(sd, 0x14);
4238 } else {
4239 sensor_s_sharpness_auto(sd);
4240 sensor_s_denoise_auto(sd);
4241 }
4242 } else if (info->capture_mode == V4L2_MODE_PREVIEW) {
4243 sensor_s_sharpness_value(sd, 0x20);
4244 sensor_s_denoise_value(sd, 0x10);
4245 }
4246 if (info->low_speed == 1) {
4247 if (info->preview_first_flag == 1) {
4248 info->preview_first_flag = 0;
4249 msleep(600);
4250 } else {
4251 msleep(200);
4252 }
4253 }
4254 if ((info->width != QSXGA_WIDTH)
4255 && (info->preview_first_flag != 1)) {
4256 ret = sensor_s_relaunch_af_zone(sd);
4257 if (ret < 0)
4258 sensor_err("sensor_s_relaunch_af_zone err\n");
4259 ret = sensor_write(sd, 0x3022, 0x03);
4260 if (ret < 0)
4261 sensor_err("sensor_s_single_af err\n");
4262 if (info->auto_focus == 1)
4263 sensor_s_continueous_af(sd, 1);
4264 msleep(100);
4265 } else
4266 msleep(150);
4267 } else {
4268 if (wsize->width > SVGA_WIDTH) {
4269 ret = sensor_set_capture_exposure(sd);
4270 if (ret < 0)
4271 sensor_err("sensor_set_capture_exposure err\n");
4272 }
4273
4274 sensor_s_sharpness_value(sd, SHARPNESS);
4275
4276 if (info->low_speed == 1) {
4277 data_type rdval;
4278
4279 sensor_read(sd, 0x3035, &rdval);
4280 sensor_write(sd, 0x3035,
4281 (rdval & 0x0f) | ((rdval & 0xf0) * 2));
4282
4283 }
4284 msleep(300);
4285 }
4286 info->width = wsize->width;
4287 info->height = wsize->height;
4288 ov5640_sensor_vts = wsize->vts;
4289 sensor_print("s_fmt set width = %d, height = %d\n", wsize->width,
4290 wsize->height);
4291 sensor_write_array(sd, sensor_oe_enable_regs,
4292 ARRAY_SIZE(sensor_oe_enable_regs));
4293 return 0;
4294 }
4295
sensor_s_stream(struct v4l2_subdev * sd,int enable)4296 static int sensor_s_stream(struct v4l2_subdev *sd, int enable)
4297 {
4298 struct sensor_info *info = to_state(sd);
4299
4300 sensor_print("%s on = %d, %d*%d %x\n", __func__, enable,
4301 info->current_wins->width,
4302 info->current_wins->height, info->fmt->mbus_code);
4303
4304 if (!enable)
4305 return 0;
4306 return sensor_reg_init(info);
4307 }
4308
4309
4310
4311 /* ----------------------------------------------------------------------- */
4312
4313 static const struct v4l2_ctrl_ops sensor_ctrl_ops = {
4314 .g_volatile_ctrl = sensor_g_ctrl,
4315 .s_ctrl = sensor_s_ctrl,
4316 };
4317
4318 static const s64 sensor_exp_bias_qmenu[] = {
4319 -4, -3, -2, -1, 0, 1, 2, 3, 4,
4320 };
4321
4322 static const struct v4l2_ctrl_config sensor_custom_ctrls[] = {
4323 {
4324 .ops = &sensor_ctrl_ops,
4325 .id = V4L2_CID_AUTO_FOCUS_INIT,
4326 .name = "AutoFocus Initial",
4327 .type = V4L2_CTRL_TYPE_BUTTON,
4328 .min = 0,
4329 .max = 0,
4330 .step = 0,
4331 .def = 0,
4332 }, {
4333 .ops = &sensor_ctrl_ops,
4334 .id = V4L2_CID_AUTO_FOCUS_RELEASE,
4335 .name = "AutoFocus Release",
4336 .type = V4L2_CTRL_TYPE_BUTTON,
4337 .min = 0,
4338 .max = 0,
4339 .step = 0,
4340 .def = 0,
4341 },
4342 };
4343
4344 static const struct v4l2_subdev_core_ops sensor_core_ops = {
4345 .reset = sensor_reset,
4346 .init = sensor_init,
4347 .s_power = sensor_power,
4348 .ioctl = sensor_ioctl,
4349 #ifdef CONFIG_COMPAT
4350 .compat_ioctl32 = sensor_compat_ioctl32,
4351 #endif
4352 };
4353
4354 static const struct v4l2_subdev_video_ops sensor_video_ops = {
4355 .s_stream = sensor_s_stream,
4356 };
4357
4358 static const struct v4l2_subdev_pad_ops sensor_pad_ops = {
4359 .enum_mbus_code = sensor_enum_mbus_code,
4360 .enum_frame_size = sensor_enum_frame_size,
4361 .get_fmt = sensor_get_fmt,
4362 .set_fmt = sensor_set_fmt,
4363 .get_mbus_config = sensor_g_mbus_config,
4364 };
4365
4366 static const struct v4l2_subdev_ops sensor_ops = {
4367 .core = &sensor_core_ops,
4368 .video = &sensor_video_ops,
4369 .pad = &sensor_pad_ops,
4370 };
4371
4372
4373 /* ----------------------------------------------------------------------- */
4374 static struct cci_driver cci_drv = {
4375 .name = SENSOR_NAME,
4376 .addr_width = CCI_BITS_16,
4377 .data_width = CCI_BITS_8,
4378 };
4379
sensor_init_controls(struct v4l2_subdev * sd,const struct v4l2_ctrl_ops * ops)4380 static int sensor_init_controls(struct v4l2_subdev *sd, const struct v4l2_ctrl_ops *ops)
4381 {
4382 struct sensor_info *info = to_state(sd);
4383 struct v4l2_ctrl_handler *handler = &info->handler;
4384 struct v4l2_ctrl *ctrl;
4385 int i;
4386 int ret = 0;
4387
4388 v4l2_ctrl_handler_init(handler, 14 + ARRAY_SIZE(sensor_custom_ctrls));
4389
4390 v4l2_ctrl_new_std(handler, ops, V4L2_CID_VFLIP, 0, 1, 1, 0);
4391 v4l2_ctrl_new_std(handler, ops, V4L2_CID_HFLIP, 0, 1, 1, 0);
4392 ctrl = v4l2_ctrl_new_std(handler, ops, V4L2_CID_EXPOSURE, 0,
4393 65536 * 16, 1, 0);
4394 if (ctrl != NULL)
4395 ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE;
4396 v4l2_ctrl_new_int_menu(handler, ops, V4L2_CID_AUTO_EXPOSURE_BIAS,
4397 ARRAY_SIZE(sensor_exp_bias_qmenu) - 1,
4398 ARRAY_SIZE(sensor_exp_bias_qmenu) / 2, sensor_exp_bias_qmenu);
4399 v4l2_ctrl_new_std_menu(handler, ops, V4L2_CID_EXPOSURE_AUTO,
4400 V4L2_EXPOSURE_APERTURE_PRIORITY, 0,
4401 V4L2_EXPOSURE_AUTO);
4402 v4l2_ctrl_new_std_menu(handler, ops,
4403 V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE,
4404 V4L2_WHITE_BALANCE_SHADE, 0,
4405 V4L2_WHITE_BALANCE_AUTO);
4406 v4l2_ctrl_new_std(handler, ops, V4L2_CID_AUTO_WHITE_BALANCE, 0, 1, 1, 1);
4407 v4l2_ctrl_new_std_menu(handler, ops, V4L2_CID_COLORFX,
4408 V4L2_COLORFX_SET_CBCR, 0, V4L2_COLORFX_NONE);
4409 v4l2_ctrl_new_std_menu(handler, ops, V4L2_CID_FLASH_LED_MODE,
4410 V4L2_FLASH_LED_MODE_RED_EYE, 0,
4411 V4L2_FLASH_LED_MODE_NONE);
4412 ctrl = v4l2_ctrl_new_std(handler, ops, V4L2_CID_3A_LOCK, 0, 7, 0, 0);
4413 if (ctrl != NULL)
4414 ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE;
4415 for (i = 0; i < ARRAY_SIZE(sensor_custom_ctrls); i++)
4416 v4l2_ctrl_new_custom(handler, &sensor_custom_ctrls[i], NULL);
4417 v4l2_ctrl_new_std(handler, ops, V4L2_CID_AUTO_FOCUS_START, 0, 0, 0, 0);
4418 v4l2_ctrl_new_std(handler, ops, V4L2_CID_AUTO_FOCUS_STOP, 0, 0, 0, 0);
4419 v4l2_ctrl_new_std(handler, ops, V4L2_CID_AUTO_FOCUS_STATUS, 0, 7, 0, 0);
4420 v4l2_ctrl_new_std(handler, ops, V4L2_CID_FOCUS_AUTO, 0, 1, 1, 1);
4421
4422 if (handler->error) {
4423 ret = handler->error;
4424 v4l2_ctrl_handler_free(handler);
4425 }
4426
4427 sd->ctrl_handler = handler;
4428
4429 return ret;
4430 }
4431
sensor_probe(struct i2c_client * client,const struct i2c_device_id * id)4432 static int sensor_probe(struct i2c_client *client,
4433 const struct i2c_device_id *id)
4434 {
4435 struct v4l2_subdev *sd;
4436 struct sensor_info *info;
4437
4438 info = kzalloc(sizeof(struct sensor_info), GFP_KERNEL);
4439 if (info == NULL)
4440 return -ENOMEM;
4441 sd = &info->sd;
4442 cci_dev_probe_helper(sd, client, &sensor_ops, &cci_drv);
4443 sensor_init_controls(sd, &sensor_ctrl_ops);
4444
4445 mutex_init(&info->lock);
4446 #ifdef CONFIG_SAME_I2C
4447 info->sensor_i2c_addr = I2C_ADDR >> 1;
4448 #endif
4449 info->fmt = &sensor_formats[0];
4450 info->fmt_pt = &sensor_formats[0];
4451 info->win_pt = &sensor_win_sizes[0];
4452 info->fmt_num = N_FMTS;
4453 info->win_size_num = N_WIN_SIZES;
4454 info->sensor_field = V4L2_FIELD_NONE;
4455 info->af_first_flag = 1;
4456 info->auto_focus = 0;
4457 return 0;
4458 }
4459
sensor_remove(struct i2c_client * client)4460 static int sensor_remove(struct i2c_client *client)
4461 {
4462 struct v4l2_subdev *sd;
4463
4464 sd = cci_dev_remove_helper(client, &cci_drv);
4465 pr_info("sensor_remove ov5640 sd = %p!\n", sd);
4466 kfree(to_state(sd));
4467 return 0;
4468 }
4469
4470 static const struct i2c_device_id sensor_id[] = {
4471 {SENSOR_NAME, 0},
4472 {}
4473 };
4474
4475 MODULE_DEVICE_TABLE(i2c, sensor_id);
4476 static struct i2c_driver sensor_driver = {
4477 .driver = {
4478 .owner = THIS_MODULE,
4479 .name = SENSOR_NAME,
4480 },
4481 .probe = sensor_probe,
4482 .remove = sensor_remove,
4483 .id_table = sensor_id,
4484 };
init_sensor(void)4485 static __init int init_sensor(void)
4486 {
4487 #ifdef CONFIG_ARCH_SUN9IW1P1
4488 A80_VERSION = sunxi_get_soc_ver();
4489 if (A80_VERSION >= SUN9IW1P1_REV_B)
4490 MCLK_DIV = 1;
4491 else
4492 MCLK_DIV = 2;
4493 pr_info("A80_VERSION = %d , SUN9IW1P1_REV_B = %d, MCLK_DIV = %d\n",
4494 A80_VERSION, SUN9IW1P1_REV_B, MCLK_DIV);
4495 #else
4496 MCLK_DIV = 1;
4497 #endif
4498 return cci_dev_init_helper(&sensor_driver);
4499 }
4500
exit_sensor(void)4501 static __exit void exit_sensor(void)
4502 {
4503 cci_dev_exit_helper(&sensor_driver);
4504 }
4505
4506 module_init(init_sensor);
4507 module_exit(exit_sensor);
4508