1 /* linux/drivers/media/video/s5k4ba.h
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/
6 * Driver for S5K4BA (UXGA camera) from Samsung Electronics
7 * 1/4" 2.0Mp CMOS Image Sensor SoC with an Embedded Image Processor
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.
14 #define S5K4BA_COMPLETE
23 struct s5k4ba_regset_type {
24 unsigned char *regset;
31 #define REGSET_LENGTH(x) (sizeof(x)/sizeof(s5k4ba_reg))
34 * User defined commands
36 /* S/W defined features for tune */
37 #define REG_DELAY 0xFF00 /* in ms */
38 #define REG_CMD 0xFFFF /* Followed by command */
40 /* Following order should not be changed */
41 enum image_size_s5k4ba {
42 /* This SoC supports upto UXGA (1600*1200) */
52 HD720P, /* 1280*720 */
59 * Following values describe controls of camera
60 * in user aspect and must be match with index of s5k4ba_regset[]
61 * These values indicates each controls and should be used
62 * to control each control
75 #define S5K4BA_REGSET(x) { \
77 .len = sizeof(x)/sizeof(s5k4ba_reg),}
81 * User tuned register setting values
83 static unsigned char s5k4ba_init_reg[][2] = {
85 {0x66, 0x01}, /* Watch Dog Time On */
87 {0x00, 0xAA}, /* For EDS Check */
88 {0x21, 0x03}, /* peter0223 */
90 {0x04, 0x01}, /* ARM Clock Divider */
93 {0x30, 0x90}, /* Analog offset */
94 {0x37, 0x0d}, /* Global Gain */
95 {0x2d, 0x48}, /* Double Shutter */
96 {0x60, 0x00}, /* Blank_Adrs */
98 {0x45, 0x1e}, /*0e// CDS Timing for Average Sub_Sampling */
100 {0x02, 0x0e}, /* ADC Resolution */
101 {0x3d, 0x06}, /* Frame ADLC */
102 {0x4d, 0x08}, /* Doubler Volatage */
103 {0x54, 0x02}, /* Double Shutter */
104 {0x55, 0x1e}, /* Line ADLC */
106 {0x59, 0x00}, /* LineADLC offset */
107 {0x5b, 0x08}, /* R_Ref_Ctrl */
108 {0x44, 0x63}, /* CLP_EN */
109 {0x4A, 0x10}, /* Clamp Control */
113 /*========================================================== */
114 /* Table Set for Sub-Sampling */
115 /*========================================================== */
117 {0x2c, 0x00}, /* crcb_sel for Sub-Sampling Table */
118 {0x05, 0x46}, /* Output Image Size Set for Capture */
128 {0xc5, 0x26}, /* Output Image Size Set for Preview */
133 {0xec, 0x06}, /*CrCb sel = YCBYCR(0x06) by jsgood */
154 /* Jeongyun added still shot cbcr_sel */
164 /*========================================================== */
166 /*========================================================== */
168 {0x73, 0x21}, /* Frmae AE Enable peter */
169 {0x20, 0x02}, /* Change AWB Mode */
172 {0x6c, 0xb0}, /* AE target */
176 {0x16, 0x5a}, /* for Prevating AE Hunting */
179 {0x78, 0x6a}, /* AGC Max */
181 {0x16, 0x60}, /* Frame AE Start */
184 {0x57, 0x18}, /* Stable_Frame_AE */
185 {0x2C, 0x30}, /* For Forbidden Area */
186 {0x2E, 0x00}, /* For Forbidden Area */
188 {0x01, 0x00}, /* Stepless_Off */
191 {0x11, 0x02}, /* AWB G Gain offset */
194 {0x3e, 0x0a}, /* AWB Cut R max */
197 {0xc8, 0xd0}, /* AWB Y Max e0 */
199 {0x3e, 0x20}, /*30 AWB Y_min */
200 {0x3d, 0x10}, /* AWB Y_min Low */
202 {0x8c, 0x04}, /* AWB Min Y Weight */
203 {0x8d, 0x16}, /* AWB Max Y Weight */
206 {0x32, 0x04}, /* AWB moving average 8 frame */
207 {0x81, 0x10}, /* AWB G gain suppress Disable */
210 {0x29, 0x04}, /* Y level H */
211 {0x2a, 0x00}, /* Y level L */
212 {0x2b, 0x03}, /* color level H */
213 {0x2c, 0xc8}, /* color level L */
216 {0x37, 0x00}, /* Flicker Add for 32Mhz */
218 {0x72, 0xa0}, /* Flicker for 32MHz */
219 {0x74, 0x08}, /* flicker 60Hz Fix */
222 {0x02, 0x02}, /* Flicker Dgain Mode */
225 /*{0x23, 0x40}, // Mirror Option */
226 {0x62, 0x0a}, /* Mirror Option */
229 {0x4e, 0x00}, /* IO current 8mA set */
230 {0x4e, 0x00}, /* IO current 8mA set */
231 {0x4e, 0x00}, /* IO current 8mA set */
232 {0x4e, 0x00}, /* IO current 8mA set */
233 {0x4f, 0x0a}, /* 2a IO current 48mA set */
234 {0x4f, 0x0a}, /* IO current 48mA set */
235 {0x4f, 0x0a}, /* IO current 48mA set */
236 {0x4f, 0x0a}, /* IO current 48mA set */
239 {0x0c, 0x03}, /* Full YC Enable */
240 /*{0x0c,03}, // Full YC Enable */
241 /*{0x02,02}, // crcb_sel */
242 /*{0x02,02}, // crcb_sel peter0222 */
243 /*{0x01,01}, // pclk peter0222 */
246 /*========================================================== */
248 /*========================================================== */
249 {0xfc, 0x01}, /* color matrix */
271 /*========================================================== */
272 /* EDGE ENHANCEMENT */
273 /*========================================================== */
275 {0x89, 0x03}, /* Edge Suppress On */
277 {0x42, 0x50}, /* Edge AGC MIN */
278 {0x43, 0x60}, /* Edge AGC MAX */
279 {0x45, 0x18}, /* positive gain AGC MIN */
280 {0x49, 0x0a}, /* positive gain AGC MAX */
281 {0x4d, 0x18}, /* negative gain AGC MIN */
282 {0x51, 0x0a}, /* negative gain AGC MAX */
285 {0x34, 0x20}, /* APTCLP */
286 {0x35, 0x09}, /* APTSC */
287 {0x36, 0x0b}, /* ENHANCE */
288 {0x3f, 0x00}, /* NON-LIN */
289 {0x42, 0x10}, /* EGFALL */
290 {0x43, 0x00}, /* HLFALL */
291 {0x45, 0xa0}, /* EGREF */
292 {0x46, 0x7a}, /* HLREF */
293 {0x47, 0x40}, /* LLREF */
295 {0x49, 0x31}, /* CSSEL EGSEL CS_DLY */
297 {0x40, 0x41}, /* Y delay */
299 /*========================================================== */
301 /*========================================================== */
304 {0x6F, 0x0A}, /* R */
391 /*========================================================== */
393 /*========================================================== */
395 {0x48, 0x34}, /* 2000K */
404 {0x50, 0x34}, /* 3000K */
413 {0x58, 0x34}, /* 5100K */
421 /*========================================================== */
422 /* UPPRE0x0x FUNCTION */
423 /*========================================================== */
427 /*========================================================== */
429 /*========================================================== */
434 {0x0b, 0x00}, /* ISP BPR On start */
435 {0x0c, 0x20}, /* Th13 AGC Min */
436 {0x0d, 0x40}, /* Th13 AGC Max */
437 {0x0e, 0x00}, /* Th1 Max H for AGCMIN */
438 {0x0f, 0x20}, /* Th1 Max L for AGCMIN */
439 {0x10, 0x00}, /* Th1 Min H for AGCMAX */
440 {0x11, 0x10}, /* Th1 Min L for AGCMAX */
441 {0x12, 0x00}, /* Th3 Max H for AGCMIN */
442 {0x13, 0x00}, /* Th3 Max L for AGCMIN */
443 {0x14, 0xff}, /* Th3 Min H for AGCMAX */
444 {0x15, 0xff}, /* Th3 Min L for AGCMAX */
445 {0x16, 0x20}, /* Th57 AGC Min */
446 {0x17, 0x40}, /* Th57 AGC Max */
447 {0x18, 0x00}, /* Th5 Max H for AGCMIN */
448 {0x19, 0x00}, /* Th5 Max L for AGCMIN */
449 {0x1a, 0x00}, /* Th5 Min H for AGCMAX */
450 {0x1b, 0x20}, /* Th5 Min L for AGCMAX */
451 {0x1c, 0x00}, /* Th7 Max H for AGCMIN */
452 {0x1d, 0x00}, /* Th7 Max L for AGCMIN */
453 {0x1e, 0x00}, /* Th7 Min H for AGCMAX */
454 {0x1f, 0x20}, /* Th7 Min L for AGCMAX */
456 /*========================================================== */
457 /* GR/GB CORRECTION */
458 /*========================================================== */
463 {0x21, 0x00}, /* start AGC */
464 {0x22, 0x18}, /* AGCMIN */
465 {0x23, 0x58}, /* AGCMAX */
466 {0x24, 0x0d}, /* G Th AGCMIN */
467 {0x25, 0x30}, /* G Th AGCMAX */
468 {0x26, 0x0d}, /* RB Th AGCMIN */
469 {0x27, 0x30}, /* RB Th AGCMAX */
471 /*========================================================== */
473 /*========================================================== */
475 {0x4C, 0x01}, /* NR Enable */
476 {0x49, 0x15}, /* Sig_Th Mult */
477 {0x4B, 0x0A}, /* Pre_Th Mult */
480 {0x28, 0x00}, /* NR start AGC */
481 {0x29, 0x00}, /* SIG Th AGCMIN H */
482 {0x2a, 0x14}, /* SIG Th AGCMIN L */
483 {0x2b, 0x00}, /* SIG Th AGCMAX H */
484 {0x2c, 0x14}, /* SIG Th AGCMAX L */
485 {0x2d, 0x00}, /* PRE Th AGCMIN H */
486 {0x2e, 0x90}, /* PRE Th AGCMIN L */
487 {0x2f, 0x01}, /* PRE Th AGCMAX H */
488 {0x30, 0x00}, /* PRE Th AGCMAX L */
489 {0x31, 0x00}, /* POST Th AGCMIN H */
490 {0x32, 0xa0}, /* POST Th AGCMIN L */
491 {0x33, 0x01}, /* POST Th AGCMAX H */
492 {0x34, 0x10}, /* POST Th AGCMAX L */
494 /*========================================================== */
495 /* 1D-Y/C-SIGMA-LPF */
496 /*========================================================== */
501 {0x35, 0x00}, /* YLPF start AGC */
502 {0x36, 0x40}, /* YLPF01 AGCMIN */
503 {0x37, 0x60}, /* YLPF01 AGCMAX */
504 {0x38, 0x00}, /* YLPF SIG01 Th AGCMINH */
505 {0x39, 0x18}, /* YLPF SIG01 Th AGCMINL */
506 {0x3a, 0x00}, /* YLPF SIG01 Th AGCMAXH */
507 {0x3b, 0x40}, /* YLPF SIG01 Th AGCMAXH */
508 {0x3c, 0x50}, /* YLPF02 AGCMIN */
509 {0x3d, 0x60}, /* YLPF02 AGCMAX */
510 {0x3e, 0x00}, /* YLPF SIG02 Th AGCMINH */
511 {0x3f, 0x30}, /* YLPF SIG02 Th AGCMINL */
512 {0x40, 0x00}, /* YLPF SIG02 Th AGCMAXH */
513 {0x41, 0x40}, /* YLPF SIG02 Th AGCMAXH */
514 {0xd4, 0x40}, /* CLPF AGCMIN */
515 {0xd5, 0x60}, /* CLPF AGCMAX */
516 {0xd6, 0xb0}, /* CLPF SIG01 Th AGCMIN */
517 {0xd7, 0xf0}, /* CLPF SIG01 Th AGCMAX */
518 {0xd8, 0xb0}, /* CLPF SIG02 Th AGCMIN */
519 {0xd9, 0xf0}, /* CLPF SIG02 Th AGCMAX */
521 /*========================================================== */
523 /*========================================================== */
525 {0x08, 0x58}, /* Color suppress AGC MIN */
526 {0x09, 0x03}, /* Color suppress MIN H */
527 {0x0a, 0x80}, /* Color suppress MIN L */
529 /*========================================================== */
531 /*========================================================== */
533 /*Shading file for 3BAFX */
534 /*s90000// shading off */
535 /* DSP9_SH_WIDTH_H */
538 /* DSP9_SH_HEIGHT_H */
556 /* DSP9_SH_Del_eH_R */
565 /* DSP9_SH_Del_eH_G */
574 /* DSP9_SH_Del_eH_B */
583 /* DSP9_SH_VAL_R0H */
600 /* DSP9_SH_VAL_G0H */
617 /* DSP9_SH_VAL_B0H */
634 /* DSP9_SH_M_R2_R1H */
656 /* DSP9_SH_M_R2_G1H */
678 /* DSP9_SH_M_R2_B1H */
700 /* DSP9_SH_SUB_RR0H */
715 /* DSP9_SH_SUB_RG0H */
730 /* DSP9_SH_SUB_RB0H */
746 {0x00, 0x02}, /* {0xhading on */
748 /*========================================================== */
750 /*========================================================== */
832 /* x-shading temp. correlation factor */
834 {0xda, 0x00}, /* t0(3100K) */
836 {0xdc, 0x01}, /* tc(5100K) */
837 {0xdd, 0x30}, /* default eeh */
840 {0x81, 0x10}, /* xshading tem */
843 {0x80, 0x01}, /* X-Shading On */
845 /*========================================================== */
846 /* AE WINDOW WEIGHT */
847 /*========================================================== */
849 {0x03, 0x4b}, /* AE Suppress On */
852 {0x01, 0x35}, /* UXGA AE Window */
856 {0x31, 0x2a}, /* Subsampling AE Window */
862 {0x3D, 0x10}, /* 1c */
891 /*========================================================== */
893 /*========================================================== */
894 /*================================= */
896 /*================================= */
897 {0xfc, 0x22}, /* White Point (For Hue Control & MWB) */
898 {0x01, 0xD0}, /* D65 */
900 {0x05, 0xC0}, /* 5000K */
902 {0x09, 0xA7}, /* CWF */
904 {0x0d, 0x98}, /* 3000K */
906 {0x11, 0x85}, /* A */
909 {0x15, 0x80}, /* 2000K */
913 /*================================= */
915 /*================================= */
955 /*================================= */
956 /* Pixel Filter Setting */
957 /*================================= */
988 /*================================= */
989 /* Polygon AWB Region Tune */
990 /*================================= */
992 {0x18, 0x00}, /* 1 */
995 {0x1b, 0x00}, /* 2 */
998 {0x1e, 0x00}, /* 3 */
1001 {0x21, 0x00}, /* 4 */
1004 {0x24, 0x00}, /* 5 */
1007 {0x27, 0x00}, /* 6 */
1010 {0x2A, 0x00}, /* 7 */
1013 {0x2D, 0x00}, /* 8 */
1016 {0x30, 0x00}, /* 9 */
1019 {0x33, 0x00}, /* 10 */
1022 {0x36, 0x00}, /* 11 */
1025 {0x39, 0x00}, /* 12 */
1028 {0x3C, 0x00}, /* 13 */
1031 {0x3F, 0x00}, /* 14 */
1035 /*================================= */
1036 /* Moving Equation Weight */
1037 /*================================= */
1041 /*================================= */
1043 /*================================= */
1045 {0xb1, 0x00}, /* {0xunny */
1050 {0xb5, 0x00}, /* Cloudy */
1055 {0xd7, 0x00}, /* Shade */
1060 /*================================= */
1062 /*================================= */
1065 {0x7A, 0x02}, /* Global AWB gain off{0xet */
1068 {0x58, 0xf6}, /* D65 R Off{0xet */
1069 {0x59, 0xff}, /* D65 B Off{0xet */
1070 {0x5A, 0xfa}, /* 5000K R Off{0xet */
1071 {0x5B, 0xFe}, /* 5000K B Off{0xet */
1072 {0x5C, 0xfb}, /* CWF R Off{0xet */
1073 {0x5D, 0xFe}, /* CWF B Off{0xet */
1074 {0x5E, 0xfb}, /* 3000K R Off{0xet */
1075 {0x5F, 0xFb}, /* 3000K B Off{0xet */
1076 {0x60, 0xfb}, /* A R Off0xet */
1077 {0x61, 0xfb}, /* A B Off0xet */
1078 {0x62, 0xfb}, /* 2000K R Off0xet */
1079 {0x63, 0xfb}, /* 2000K B Off0xet */
1081 {0xde, 0x00}, /* LARGE OBJECT BUG FIX */
1082 {0xf0, 0x6a}, /* RB Ratio */
1083 /*================================= */
1084 /* Green Stablity Enhance */
1085 /*================================= */
1096 /*========================================================== */
1097 /* Special Effect */
1098 /*========================================================== */
1099 {0xfc, 0x07}, /* Special Effect */
1108 {0x73, 0x21}, /* Frame AE Enable */
1113 {0xFF, 0xFF} /* REGISTER END */
1116 #define S5K4BA_INIT_REGS \
1117 (sizeof(s5k4ba_init_reg) / sizeof(s5k4ba_init_reg[0]))
1123 static const struct s5k4ba_reg s5k4ba_ev_m6[] = {
1126 static const struct s5k4ba_reg s5k4ba_ev_m5[] = {
1129 static const struct s5k4ba_reg s5k4ba_ev_m4[] = {
1132 static const struct s5k4ba_reg s5k4ba_ev_m3[] = {
1135 static const struct s5k4ba_reg s5k4ba_ev_m2[] = {
1138 static const struct s5k4ba_reg s5k4ba_ev_m1[] = {
1141 static const struct s5k4ba_reg s5k4ba_ev_default[] = {
1144 static const struct s5k4ba_reg s5k4ba_ev_p1[] = {
1147 static const struct s5k4ba_reg s5k4ba_ev_p2[] = {
1150 static const struct s5k4ba_reg s5k4ba_ev_p3[] = {
1153 static const struct s5k4ba_reg s5k4ba_ev_p4[] = {
1156 static const struct s5k4ba_reg s5k4ba_ev_p5[] = {
1159 static const struct s5k4ba_reg s5k4ba_ev_p6[] = {
1162 #ifdef S5K4BA_COMPLETE
1163 /* Order of this array should be following the querymenu data */
1164 static const unsigned char *s5k4ba_regs_ev_bias[] = {
1165 (unsigned char *)s5k4ba_ev_m6, (unsigned char *)s5k4ba_ev_m5,
1166 (unsigned char *)s5k4ba_ev_m4, (unsigned char *)s5k4ba_ev_m3,
1167 (unsigned char *)s5k4ba_ev_m2, (unsigned char *)s5k4ba_ev_m1,
1168 (unsigned char *)s5k4ba_ev_default, (unsigned char *)s5k4ba_ev_p1,
1169 (unsigned char *)s5k4ba_ev_p2, (unsigned char *)s5k4ba_ev_p3,
1170 (unsigned char *)s5k4ba_ev_p4, (unsigned char *)s5k4ba_ev_p5,
1171 (unsigned char *)s5k4ba_ev_p6,
1175 * Auto White Balance configure
1177 static const struct s5k4ba_reg s5k4ba_awb_off[] = {
1180 static const struct s5k4ba_reg s5k4ba_awb_on[] = {
1183 static const unsigned char *s5k4ba_regs_awb_enable[] = {
1184 (unsigned char *)s5k4ba_awb_off,
1185 (unsigned char *)s5k4ba_awb_on,
1189 * Manual White Balance (presets)
1191 static const struct s5k4ba_reg s5k4ba_wb_tungsten[] = {
1195 static const struct s5k4ba_reg s5k4ba_wb_fluorescent[] = {
1199 static const struct s5k4ba_reg s5k4ba_wb_sunny[] = {
1203 static const struct s5k4ba_reg s5k4ba_wb_cloudy[] = {
1207 /* Order of this array should be following the querymenu data */
1208 static const unsigned char *s5k4ba_regs_wb_preset[] = {
1209 (unsigned char *)s5k4ba_wb_tungsten,
1210 (unsigned char *)s5k4ba_wb_fluorescent,
1211 (unsigned char *)s5k4ba_wb_sunny,
1212 (unsigned char *)s5k4ba_wb_cloudy,
1216 * Color Effect (COLORFX)
1218 static const struct s5k4ba_reg s5k4ba_color_sepia[] = {
1221 static const struct s5k4ba_reg s5k4ba_color_aqua[] = {
1224 static const struct s5k4ba_reg s5k4ba_color_monochrome[] = {
1227 static const struct s5k4ba_reg s5k4ba_color_negative[] = {
1230 static const struct s5k4ba_reg s5k4ba_color_sketch[] = {
1233 /* Order of this array should be following the querymenu data */
1234 static const unsigned char *s5k4ba_regs_color_effect[] = {
1235 (unsigned char *)s5k4ba_color_sepia,
1236 (unsigned char *)s5k4ba_color_aqua,
1237 (unsigned char *)s5k4ba_color_monochrome,
1238 (unsigned char *)s5k4ba_color_negative,
1239 (unsigned char *)s5k4ba_color_sketch,
1245 static const struct s5k4ba_reg s5k4ba_contrast_m2[] = {
1248 static const struct s5k4ba_reg s5k4ba_contrast_m1[] = {
1251 static const struct s5k4ba_reg s5k4ba_contrast_default[] = {
1254 static const struct s5k4ba_reg s5k4ba_contrast_p1[] = {
1257 static const struct s5k4ba_reg s5k4ba_contrast_p2[] = {
1260 static const unsigned char *s5k4ba_regs_contrast_bias[] = {
1261 (unsigned char *)s5k4ba_contrast_m2,
1262 (unsigned char *)s5k4ba_contrast_m1,
1263 (unsigned char *)s5k4ba_contrast_default,
1264 (unsigned char *)s5k4ba_contrast_p1,
1265 (unsigned char *)s5k4ba_contrast_p2,
1271 static const struct s5k4ba_reg s5k4ba_saturation_m2[] = {
1274 static const struct s5k4ba_reg s5k4ba_saturation_m1[] = {
1277 static const struct s5k4ba_reg s5k4ba_saturation_default[] = {
1280 static const struct s5k4ba_reg s5k4ba_saturation_p1[] = {
1283 static const struct s5k4ba_reg s5k4ba_saturation_p2[] = {
1286 static const unsigned char *s5k4ba_regs_saturation_bias[] = {
1287 (unsigned char *)s5k4ba_saturation_m2,
1288 (unsigned char *)s5k4ba_saturation_m1,
1289 (unsigned char *)s5k4ba_saturation_default,
1290 (unsigned char *)s5k4ba_saturation_p1,
1291 (unsigned char *)s5k4ba_saturation_p2,
1297 static const struct s5k4ba_reg s5k4ba_sharpness_m2[] = {
1300 static const struct s5k4ba_reg s5k4ba_sharpness_m1[] = {
1303 static const struct s5k4ba_reg s5k4ba_sharpness_default[] = {
1306 static const struct s5k4ba_reg s5k4ba_sharpness_p1[] = {
1309 static const struct s5k4ba_reg s5k4ba_sharpness_p2[] = {
1312 static const unsigned char *s5k4ba_regs_sharpness_bias[] = {
1313 (unsigned char *)s5k4ba_sharpness_m2,
1314 (unsigned char *)s5k4ba_sharpness_m1,
1315 (unsigned char *)s5k4ba_sharpness_default,
1316 (unsigned char *)s5k4ba_sharpness_p1,
1317 (unsigned char *)s5k4ba_sharpness_p2,
1319 #endif /* S5K4BA_COMPLETE */