1 /* linux/drivers/media/video/s5k3ba.h
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/
6 * Driver for S5K3BA (UXGA camera) from Samsung Electronics
7 * 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 S5K3BA_COMPLETE
23 struct s5k3ba_regset_type {
24 unsigned char *regset;
31 #define REGSET_LENGTH(x) (sizeof(x)/sizeof(s5k3ba_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_s5k3ba {
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 s5k3ba_regset[]
61 * These values indicates each controls and should be used
62 * to control each control
75 #define S5K3BA_REGSET(x) { \
77 .len = sizeof(x)/sizeof(s5k3ba_reg),}
81 * User tuned register setting values
84 static unsigned char s5k3ba_init_reg[][2] = {
86 {0x03, 0x01},/* sw reset */
92 {0x52, 0x80},/* pll_m */
104 static unsigned char s5k3ba_init_reg[][2] = {
105 /* 1. initial setting */
107 {0x04, 0x03},/* ARM Clock divider(1/4) */
110 /* {0x52, 0x80},PLL M */
111 /* {0x50, 0x14},1b PLL S,P (15fps) */
112 /* In case of PCLK = 64MHz */
115 {0x52, 0x80},/* PLL M M= 128 setting. */
119 {0x50, 0x19},PLL S= 0 ,P = 25 PCLK=128/2=64Mhz 15 Frmae Setting
120 {0x50, 0x14},PLL S= 0 ,P = 20 PCLK=128/2=64Mhz 15 Frmae Setting
121 {0x50, 0x59},PLL S= 1 ,P = 25 PCLK=64/2=32Mhz ,7~8Frame Setting
138 {0xbc, 0xe0},/* AWB_AE_DIFF */
140 {0xfc, 0x03},/* ************************************************* */
143 {0x02, 0x02},/* YCbCr Order */
146 {0x4a, 0xc1},/* SC type selection */
147 {0x37, 0x18},/* 16 SC type global gain */
148 {0x47, 0xc4},/* r-ramp by chin */
150 {0xfc, 0x01},/* AWB Window Area (except sky) */
156 {0x30, 0x84},/* Analog offset */
159 {0x3d, 0x10},/* AWB Low Y limit */
162 {0x3d, 0x06},/* ADLC OFF */
163 {0x44, 0x5b},/* clamp enable */
172 {0x78, 0x58},/* AGC MAX (30lux_Micron Y=60code) */
175 {0x45, 0x8c},/* CDS timing greenish(15fps) */
176 {0x49, 0x80},/* APS Current 2uA */
179 {0x25, 0x14},/* 10 Digital Clamp */
182 {0x6d, 0x01},/* AE target high (Macbeth white=240) */
183 {0x6c, 0x00},/* AE target (Macbeth white=240) */
189 /* {0x01, 0x00},I2C hold mode off */
192 {0x00, 0x00},/* ISP BPR Off */
193 {0x0c, 0x02},/* Full YC */
194 {0xc8, 0x19},/* AWB Y Max */
197 {0x81, 0x00},/* AWB G gain suppress disable */
200 {0x2b, 0x04},/* color level */
204 {0x11, 0x00},/* G offset */
205 {0x37, 0x00},/* Flicker Add */
208 {0x72, 0xa0},/* Flicker for 32MHz */
209 {0x74, 0x18},/* Flicker */
210 {0x73, 0x00},/* Frame AE */
213 {0x64, 0x00},/* Darkslice R */
214 {0x65, 0x00},/* Darkslice G */
215 {0x66, 0x00},/* Darkslice B */
219 {0x2c, 0x0a},/* 14 positive gain */
220 {0x30, 0x0a},/* 10 negative edge gain */
221 {0x34, 0x1a},/* APTCLP */
222 {0x35, 0x10},/* 0a APTSC */
223 {0x36, 0x0b},/* ENHANCE */
224 {0x3f, 0x00},/* NON-LIN */
225 {0x45, 0x30},/* EGREF */
226 {0x47, 0x00},/* LLREF */
227 {0x48, 0x08},/* by chin */
228 {0x49, 0x39},/* CSSEL EGSEL CS_DLY by */
229 {0x40, 0x41},/* Y delay */
233 /* s7e8c NR GrGb off */
234 /* [7]: BPR [6]:Noise Filter(1D/NR)
235 * [4]: GrGb Enable [3]:BPR Data Threshold */
236 /* [2]: color suppress [1]: Y gain suppress [0]: Digital Clamp */
237 /* GrGb Correction setting */
242 /* / [4]: GrGb full [3]: GrGb On */
243 /* / [2]: GrGb Rb On */
245 {0x21, 0x00},/* Start AGC */
246 {0x22, 0x10},/* AGCMIN */
247 {0x23, 0x50},/* AGCMAX */
248 {0x24, 0x18},/* G Th AGCMIN(23d) */
249 {0x25, 0x52},/* G Th AGCMAX(50d) */
250 {0x26, 0x38},/* RB Th AGCMIN */
251 {0x27, 0x52},/* RB Th AGCMAX */
252 /* GrGb Correction setting End */
256 {0x3f, 0x00},/* setting because S/W bug */
259 {0x0b, 0x00},/* ISP BPR On Start */
260 {0x0c, 0x00},/* Th13 AGC Min */
261 {0x0d, 0x5a},/* Th13 AGC Max */
262 {0x0e, 0x01},/* 00 Th1 Max H for AGCMIN */
263 {0x0f, 0xff},/* c0 Th1 Max L for AGCMIN */
264 {0x10, 0x00},/* Th1 Min H for AGCMAX */
265 {0x11, 0x10},/* 00 Th1 Min L for AGCMAX */
266 {0x12, 0xff},/* Th3 Max H for AGCMIN */
267 {0x13, 0xff},/* Th3 Max L for AGCMIN */
268 {0x14, 0xff},/* Th3 Min H for AGCMAX */
269 {0x15, 0xff},/* Th3 Min L for AGCMAX */
273 {0x4b, 0x01},/* NR Enable */
274 /* s4b00 NR Enable */
277 {0x28, 0x00},/* NR Start AGC */
278 {0x29, 0x00},/* SIG Th AGCMIN H */
279 {0x2a, 0x0a},/* 14 SIG Th AGCMIN L */
280 {0x2b, 0x00},/* SIG Th AGCMAX H */
281 {0x2c, 0x0a},/* 14 SIG Th AGCMAX L */
282 {0x2d, 0x00},/* PRE Th AGCMIN H */
283 {0x2e, 0xc0},/* 64 PRE Th AGCMIN L(100d) */
284 {0x2f, 0x01},/* PRE Th AGCMAX H(300d) */
285 {0x30, 0x2c},/* PRE Th AGCMAX L */
286 {0x31, 0x00},/* POST Th AGCMIN H */
287 {0x32, 0xe0},/* 64 POST Th AGCMIN L(100d) */
288 {0x33, 0x01},/* POST Th AGCMAX H(300d) */
289 {0x34, 0x2c},/* POST Th AGCMAX L */
293 /* Color suppress setting */
295 {0x08, 0x50},/* C suppress AGC MIN */
296 {0x09, 0x03},/* C suppress MIN H */
297 {0x0a, 0x80},/* C suppress MIN L */
298 /* C Suppress Setting End */
301 {0x4a, 0x00},/* 01 Edge Color Suppress,9/13 */
303 /* 1D Y LPF Filter */
305 /* s05e0 Default s60 */
306 {0x05, 0x60},/* Default s60 */
307 /* [7]: Y LPF filter On [6]: Clap On */
310 {0x35, 0x00},/* YLPF Start AGC */
311 {0x36, 0x50},/* YLPF01 AGCMIN */
312 {0x37, 0x50},/* YLPF01 AGCMAX */
313 {0x38, 0x00},/* YLPF SIG01 Th AGCMINH */
314 {0x39, 0x90},/* 00 YLPF SIG01 Th AGCMINL */
315 {0x3a, 0x01},/* YLPF SIG01 Th AGCMAXH */
316 {0x3b, 0xa0},/* YLPF SIG01 Th AGCMAXL */
317 {0x3c, 0x50},/* YLPF02 AGCMIN */
318 {0x3d, 0x50},/* YLPF02 AGCMAX */
319 {0x3e, 0x00},/* YLPF SIG02 Th AGCMINH */
320 {0x3f, 0xa0},/* 00 YLPF SIG02 Th AGCMINL */
321 {0x40, 0x01},/* YLPF SIG02 Th AGCMAXH s73 */
322 {0x41, 0xb0},/* YLPF SIG02 Th AGCMAXL */
323 /* Y LPF Filter setting End */
325 /* SET EDGE COLOR SUPPRESS AND Y-LPF */
339 /* ***************************************************************** */
342 {0x4b, 0x01},/* NR Enable */
343 /* Set multipliers (which are not suppressed)********************** */
346 /* Suppressed parameters */
356 {0x28, 0x00},/* NR Start AGC */
357 {0x29, 0x00},/* SIG Th AGCMIN H */
358 {0x2A, 0x02},/* SIG Th AGCMIN L */
359 {0x2B, 0x00},/* SIG Th AGCMAX H */
360 {0x2C, 0x14},/* SIG Th AGCMAX L */
361 {0x2D, 0x03},/* PRE Th AGCMIN H */
362 {0x2E, 0x84},/* PRE Th AGCMIN L */
363 {0x2F, 0x03},/* PRE Th AGCMAX H */
364 {0x30, 0x84},/* PRE Th AGCMAX L */
365 {0x31, 0x00},/* POST Th AGCMIN H */
366 {0x32, 0x00},/* POST Th AGCMIN L */
367 {0x33, 0x00},/* POST Th AGCMAX H */
368 {0x34, 0xC8},/* POST Th AGCMAX L */
369 {0x35, 0x00},/* 1D Y filter setting */
382 /* ***************************************************************** */
384 /* To avoid AWB tracking @ max AGC gain even though
385 * AE is unstable state
388 {0xba, 0x50},/* AE Target minus AE Average */
391 /* ***************************************************************** */
393 /* 3. AE weight & etc linear */
394 /* AE Window Weight linear(EVT1)0929 */
395 {0xfc, 0x20},/* upper window weight zero */
429 /* AE window Weight setting End */
430 /* hue gain linear */
456 {0x62, 0x00},/* hue enable OFF */
458 /* 4. shading (Flex 3000K manual shading) */
460 /* DSP9_SH_WIDTH_H */
463 /* DSP9_SH_HEIGHT_H */
502 /* DSP9_SH_VAL_R0H */
552 /* DSP9_SH_M_R2_R1H */
574 /* DSP9_SH_M_R2_G1H */
596 /* DSP9_SH_M_R2_B1H */
618 /* DSP9_SH_SUB_RR0H */
633 /* DSP9_SH_SUB_RG0H */
648 /* DSP9_SH_SUB_RB0H */
663 {0x00, 0x02},/* shading on */
669 /* 5.color correction */
671 /* 2.0251 -1.0203 -0.0048 */
672 /* -0.7080 1.8970 -0.1889 */
673 /* -0.468 -0.444 1.912 */
778 {0x62, 0x00},/* hue auto control off */
795 /* AWB Start Point */
811 {0x40, 0x8a},/* 2000K */
813 {0x42, 0x95},/* 3100K */
815 {0x44, 0xbc},/* 5100K */
827 {0x31, 0x00},/* skin tone[6],CW delete[5] */
831 #define S5K3BA_INIT_REGS \
832 (sizeof(s5k3ba_init_reg) / sizeof(s5k3ba_init_reg[0]))
838 static const struct s5k3ba_reg s5k3ba_ev_m6[] = {
841 static const struct s5k3ba_reg s5k3ba_ev_m5[] = {
844 static const struct s5k3ba_reg s5k3ba_ev_m4[] = {
847 static const struct s5k3ba_reg s5k3ba_ev_m3[] = {
850 static const struct s5k3ba_reg s5k3ba_ev_m2[] = {
853 static const struct s5k3ba_reg s5k3ba_ev_m1[] = {
856 static const struct s5k3ba_reg s5k3ba_ev_default[] = {
859 static const struct s5k3ba_reg s5k3ba_ev_p1[] = {
862 static const struct s5k3ba_reg s5k3ba_ev_p2[] = {
865 static const struct s5k3ba_reg s5k3ba_ev_p3[] = {
868 static const struct s5k3ba_reg s5k3ba_ev_p4[] = {
871 static const struct s5k3ba_reg s5k3ba_ev_p5[] = {
874 static const struct s5k3ba_reg s5k3ba_ev_p6[] = {
877 #ifdef S5K3BA_COMPLETE
878 /* Order of this array should be following the querymenu data */
879 static const unsigned char *s5k3ba_regs_ev_bias[] = {
880 (unsigned char *)s5k3ba_ev_m6, (unsigned char *)s5k3ba_ev_m5,
881 (unsigned char *)s5k3ba_ev_m4, (unsigned char *)s5k3ba_ev_m3,
882 (unsigned char *)s5k3ba_ev_m2, (unsigned char *)s5k3ba_ev_m1,
883 (unsigned char *)s5k3ba_ev_default, (unsigned char *)s5k3ba_ev_p1,
884 (unsigned char *)s5k3ba_ev_p2, (unsigned char *)s5k3ba_ev_p3,
885 (unsigned char *)s5k3ba_ev_p4, (unsigned char *)s5k3ba_ev_p5,
886 (unsigned char *)s5k3ba_ev_p6,
890 * Auto White Balance configure
892 static const struct s5k3ba_reg s5k3ba_awb_off[] = {
895 static const struct s5k3ba_reg s5k3ba_awb_on[] = {
898 static const unsigned char *s5k3ba_regs_awb_enable[] = {
899 (unsigned char *)s5k3ba_awb_off,
900 (unsigned char *)s5k3ba_awb_on,
904 * Manual White Balance (presets)
906 static const struct s5k3ba_reg s5k3ba_wb_tungsten[] = {
910 static const struct s5k3ba_reg s5k3ba_wb_fluorescent[] = {
914 static const struct s5k3ba_reg s5k3ba_wb_sunny[] = {
918 static const struct s5k3ba_reg s5k3ba_wb_cloudy[] = {
922 /* Order of this array should be following the querymenu data */
923 static const unsigned char *s5k3ba_regs_wb_preset[] = {
924 (unsigned char *)s5k3ba_wb_tungsten,
925 (unsigned char *)s5k3ba_wb_fluorescent,
926 (unsigned char *)s5k3ba_wb_sunny,
927 (unsigned char *)s5k3ba_wb_cloudy,
931 * Color Effect (COLORFX)
933 static const struct s5k3ba_reg s5k3ba_color_sepia[] = {
936 static const struct s5k3ba_reg s5k3ba_color_aqua[] = {
939 static const struct s5k3ba_reg s5k3ba_color_monochrome[] = {
942 static const struct s5k3ba_reg s5k3ba_color_negative[] = {
945 static const struct s5k3ba_reg s5k3ba_color_sketch[] = {
948 /* Order of this array should be following the querymenu data */
949 static const unsigned char *s5k3ba_regs_color_effect[] = {
950 (unsigned char *)s5k3ba_color_sepia,
951 (unsigned char *)s5k3ba_color_aqua,
952 (unsigned char *)s5k3ba_color_monochrome,
953 (unsigned char *)s5k3ba_color_negative,
954 (unsigned char *)s5k3ba_color_sketch,
960 static const struct s5k3ba_reg s5k3ba_contrast_m2[] = {
963 static const struct s5k3ba_reg s5k3ba_contrast_m1[] = {
966 static const struct s5k3ba_reg s5k3ba_contrast_default[] = {
969 static const struct s5k3ba_reg s5k3ba_contrast_p1[] = {
972 static const struct s5k3ba_reg s5k3ba_contrast_p2[] = {
975 static const unsigned char *s5k3ba_regs_contrast_bias[] = {
976 (unsigned char *)s5k3ba_contrast_m2,
977 (unsigned char *)s5k3ba_contrast_m1,
978 (unsigned char *)s5k3ba_contrast_default,
979 (unsigned char *)s5k3ba_contrast_p1,
980 (unsigned char *)s5k3ba_contrast_p2,
986 static const struct s5k3ba_reg s5k3ba_saturation_m2[] = {
989 static const struct s5k3ba_reg s5k3ba_saturation_m1[] = {
992 static const struct s5k3ba_reg s5k3ba_saturation_default[] = {
995 static const struct s5k3ba_reg s5k3ba_saturation_p1[] = {
998 static const struct s5k3ba_reg s5k3ba_saturation_p2[] = {
1001 static const unsigned char *s5k3ba_regs_saturation_bias[] = {
1002 (unsigned char *)s5k3ba_saturation_m2,
1003 (unsigned char *)s5k3ba_saturation_m1,
1004 (unsigned char *)s5k3ba_saturation_default,
1005 (unsigned char *)s5k3ba_saturation_p1,
1006 (unsigned char *)s5k3ba_saturation_p2,
1012 static const struct s5k3ba_reg s5k3ba_sharpness_m2[] = {
1015 static const struct s5k3ba_reg s5k3ba_sharpness_m1[] = {
1018 static const struct s5k3ba_reg s5k3ba_sharpness_default[] = {
1021 static const struct s5k3ba_reg s5k3ba_sharpness_p1[] = {
1024 static const struct s5k3ba_reg s5k3ba_sharpness_p2[] = {
1027 static const unsigned char *s5k3ba_regs_sharpness_bias[] = {
1028 (unsigned char *)s5k3ba_sharpness_m2,
1029 (unsigned char *)s5k3ba_sharpness_m1,
1030 (unsigned char *)s5k3ba_sharpness_default,
1031 (unsigned char *)s5k3ba_sharpness_p1,
1032 (unsigned char *)s5k3ba_sharpness_p2,
1034 #endif /* S5K3BA_COMPLETE */