1 #include "generic_sensor.h"
5 *v0.0.1: this driver is compatible with generic_sensor
7 * add sensor_focus_af_const_pause_usr_cb;
9 static int version = KERNEL_VERSION(0,1,1);
10 module_param(version, int, S_IRUGO);
14 module_param(debug, int, S_IRUGO|S_IWUSR);
16 #define dprintk(level, fmt, arg...) do { \
18 printk(KERN_WARNING fmt , ## arg); } while (0)
20 /* Sensor Driver Configuration Begin */
21 #define SENSOR_NAME RK29_CAM_SENSOR_HM5065
22 #define SENSOR_V4L2_IDENT V4L2_IDENT_HM5065
23 #define SENSOR_ID 0x039E
24 #define SENSOR_BUS_PARAM (V4L2_MBUS_MASTER |\
25 V4L2_MBUS_PCLK_SAMPLE_RISING|V4L2_MBUS_HSYNC_ACTIVE_HIGH| V4L2_MBUS_VSYNC_ACTIVE_LOW|\
26 V4L2_MBUS_DATA_ACTIVE_HIGH |SOCAM_MCLK_24MHZ)
27 #define SENSOR_PREVIEW_W 1280 //800
28 #define SENSOR_PREVIEW_H 960//600
29 #define SENSOR_PREVIEW_FPS 15000 // 15fps
30 #define SENSOR_FULLRES_L_FPS 7500 // 7.5fps
31 #define SENSOR_FULLRES_H_FPS 7500 // 7.5fps
32 #define SENSOR_720P_FPS 30000
33 #define SENSOR_1080P_FPS 15000
35 #define SENSOR_REGISTER_LEN 2 // sensor register address bytes
36 #define SENSOR_VALUE_LEN 1 // sensor register value bytes
38 #define SENSOR_AF_CONFIG 1
40 #ifdef SENSOR_AF_CONFIG
41 static unsigned int SensorConfiguration = (CFG_WhiteBalance|CFG_Effect
42 |CFG_Scene|CFG_Focus|CFG_FocusContinues
46 static unsigned int SensorConfiguration = (CFG_WhiteBalance|CFG_Effect
50 static unsigned int SensorChipID[] = {SENSOR_ID};
51 /* Sensor Driver Configuration End */
54 #define SENSOR_NAME_STRING(a) STR(CONS(SENSOR_NAME, a))
55 #define SENSOR_NAME_VARFUN(a) CONS(SENSOR_NAME, a)
57 #define SensorRegVal(a,b) CONS4(SensorReg,SENSOR_REGISTER_LEN,Val,SENSOR_VALUE_LEN)(a,b)
58 #define sensor_write(client,reg,v) CONS4(sensor_write_reg,SENSOR_REGISTER_LEN,val,SENSOR_VALUE_LEN)(client,(reg),(v))
59 #define sensor_read(client,reg,v) CONS4(sensor_read_reg,SENSOR_REGISTER_LEN,val,SENSOR_VALUE_LEN)(client,(reg),(v))
60 #define sensor_write_array generic_sensor_write_array
63 /* hm5065 VCM Command and Status Registers */
64 #define AF_TARGETPOS_REG_H 0x0700
65 #define AF_TARGETPOS_REG_L 0x0701
67 #define AF_MODES_REG 0x070A
68 #define AF_AUTOCMDS_REG 0x070b
69 #define AF_LENSPOS_REG_H 0x06F0
70 #define AF_LENSPOS_REG_L 0x06F1
71 #define AF_MANUCMDS_REG 0x070c
72 #define AF_FINISHCHK_REG 0x07ae //[0]: false [1] : true
74 #define FACE_LC 0x0714 //[0] : focus , [1] : AE Â
\93\84Ó
75 #define FACE_START_XH 0x0715
76 #define FACE_START_XL 0x0716
77 #define FACE_SIZE_XH 0x0717
78 #define FACE_SIZE_XL 0x0718
79 #define FACE_START_YH 0x0719
80 #define FACE_START_YL 0x071A
81 #define FACE_SIZE_YH 0x071B
82 #define FACE_SIZE_YL 0x071C
85 #define AF_ZONE0_WEIGHT 0x0808
86 #define AF_ZONE1_WEIGHT 0x0809
87 #define AF_ZONE2_WEIGHT 0x080A
88 #define AF_ZONE3_WEIGHT 0x080B
89 #define AF_ZONE4_WEIGHT 0x080C
90 #define AF_ZONE5_WEIGHT 0x080D
91 #define AF_ZONE6_WEIGHT 0x080E
94 struct sensor_parameter
99 struct specific_sensor{
100 struct generic_sensor common_sensor;
101 //define user data below
102 struct sensor_parameter parameter;
107 * The follow setting need been filled.
110 * sensor_init_data : Sensor initial setting;
111 * sensor_fullres_lowfps_data : Sensor full resolution setting with best auality, recommand for video;
112 * sensor_preview_data : Sensor preview resolution setting, recommand it is vga or svga;
113 * sensor_softreset_data : Sensor software reset register;
114 * sensor_check_id_data : Sensir chip id register;
117 * sensor_fullres_highfps_data: Sensor full resolution setting with high framerate, recommand for video;
118 * sensor_720p: Sensor 720p setting, it is for video;
119 * sensor_1080p: Sensor 1080p setting, it is for video;
122 * The SensorEnd which is the setting end flag must be filled int the last of each setting;
125 /* Sensor initial setting */
126 static struct rk_sensor_reg sensor_init_data[] = {
128 {0xffff,0x01}, // 2013-03-01 Start new patch
1642 {0xffff,0x00}, // 2013-03-01 end
1673 {0x0041,0x00},//00:5M 03:SVGA
1731 {0x004C,0x0D},//enoch
1749 {0x0049,0x14}, // PipeSetupBank0 bGammaGain
1750 {0x004A,0x0E}, // PipeSetupBank0 bGammaInterpolationGain
1751 {0x0069,0x14}, // PipeSetupBank1 bGammaGain
1752 {0x006A,0x0E}, // PipeSetupBank1 bGammaInterpolationGain
1753 {0x0090,0x5A}, // GammaGainDamperControl fpX1 {MSB} //24000
1754 {0x0091,0xEE}, // GammaGainDamperControl fpX1 {LSB}
1755 {0x0092,0x3E}, // GammaGainDamperControl fpY1 {MSB} //1
1756 {0x0093,0x00}, // GammaGainDamperControl fpY1 {LSB}
1757 {0x0094,0x69}, // GammaGainDamperControl fpX2 {MSB} //3444736
1758 {0x0095,0x49}, // GammaGainDamperControl fpX2 {LSB}
1759 {0x0096,0x39}, // GammaGainDamperControl fpY2 {MSB} //0.238
1760 {0x0097,0xCF}, // GammaGainDamperControl fpY2 {LSB}
1761 {0x0098,0x01}, // GammaGainDamperControl fDisable
1762 {0x00A0,0x5A}, // GammaInterpolationDamperControl fpX1 {MSB} //24000
1763 {0x00A1,0xEE}, // GammaInterpolationDamperControl fpX1 {LSB}
1764 {0x00A2,0x3E}, // GammaInterpolationDamperControl fpY1 {MSB} //1
1765 {0x00A3,0x00}, // GammaInterpolationDamperControl fpY1 {LSB}
1766 {0x00A4,0x69}, // GammaInterpolationDamperControl fpX2 {MSB} //3444736
1767 {0x00A5,0x49}, // GammaInterpolationDamperControl fpX2 {LSB}
1768 {0x00A6,0x3B}, // GammaInterpolationDamperControl fpY2 {MSB} //0.4375
1769 {0x00A7,0x80}, // GammaInterpolationDamperControl fpY2 {LSB}
1770 {0x00A8,0x01}, // GammaInterpolationDamperControl fDisable
1772 {0x0420,0x00}, //new LSC start - 0306
2031 {0x0564,0x00}, //new LSC end
2034 {0x0420,0x00}, //C0_GreenRed_X
2035 {0x0421,0x1E}, //C0_GreenRed_X LSB
2036 {0x0422,0xFF}, //C0_GreenRed_Y
2037 {0x0423,0xF3}, //C0_GreenRed_Y LSB
2038 {0x0424,0x00}, //C0_GreenRed_X2
2039 {0x0425,0x6E}, //C0_GreenRed_X2 LSB
2040 {0x0426,0x00}, //C0_GreenRed_Y2
2041 {0x0427,0x96}, //C0_GreenRed_Y2 LSB
2042 {0x0428,0x00}, //C0_GreenRed_XY
2043 {0x0429,0x40}, //C0_GreenRed_XY LSB
2044 {0x042A,0x00}, //C0_GreenRed_X2Y
2045 {0x042B,0x3F}, //C0_GreenRed_X2Y LSB
2046 {0x042C,0x00}, //C0_GreenRed_XY2
2047 {0x042D,0x99}, //C0_GreenRed_XY2 LSB
2048 {0x042E,0xFF}, //C0_GreenRed_X2Y2
2049 {0x042F,0xCD}, //C0_GreenRed_X2Y2 LSB
2050 {0x0430,0xFF}, //C0_Red_X
2051 {0x0431,0xC1}, //C0_Red_X LSB
2052 {0x0432,0xFF}, //C0_Red_Y
2053 {0x0433,0x8C}, //C0_Red_Y LSB
2054 {0x0434,0x00}, //C0_Red_X2
2055 {0x0435,0xD1}, //C0_Red_X2 LSB
2056 {0x0436,0x00}, //C0_Red_Y2
2057 {0x0437,0xF9}, //C0_Red_Y2 LSB
2058 {0x0438,0xFF}, //C0_Red_XY
2059 {0x0439,0xD0}, //C0_Red_XY LSB
2060 {0x043A,0xFF}, //C0_Red_X2Y
2061 {0x043B,0xD4}, //C0_Red_X2Y LSB
2062 {0x043C,0x00}, //C0_Red_XY2
2063 {0x043D,0x46}, //C0_Red_XY2 LSB
2064 {0x043E,0xFF}, //C0_Red_X2Y2
2065 {0x043F,0x1F}, //C0_Red_X2Y2 LSB
2066 {0x0440,0x00}, //C0_GreenBlue_X
2067 {0x0441,0x00}, //C0_GreenBlue_X LSB
2068 {0x0442,0xFF}, //C0_GreenBlue_Y
2069 {0x0443,0xEC}, //C0_GreenBlue_Y LSB
2070 {0x0444,0x00}, //C0_GreenBlue_X2
2071 {0x0445,0x7D}, //C0_GreenBlue_X2 LSB
2072 {0x0446,0x00}, //C0_GreenBlue_Y2
2073 {0x0447,0x89}, //C0_GreenBlue_Y2 LSB
2074 {0x0448,0x00}, //C0_GreenBlue_XY
2075 {0x0449,0x4A}, //C0_GreenBlue_XY LSB
2076 {0x044A,0x00}, //C0_GreenBlue_X2Y
2077 {0x044B,0x00}, //C0_GreenBlue_X2Y LSB
2078 {0x044C,0x00}, //C0_GreenBlue_XY2
2079 {0x044D,0x6C}, //C0_GreenBlue_XY2 LSB
2080 {0x044E,0xFF}, //C0_GreenBlue_X2Y2
2081 {0x044F,0xB5}, //C0_GreenBlue_X2Y2 LSB // C9
2082 {0x0450,0x00}, //C0_Blue_X
2083 {0x0451,0x03}, //C0_Blue_X LSB
2084 {0x0452,0xFF}, //C0_Blue_Y
2085 {0x0453,0xC8}, //C0_Blue_Y LSB
2086 {0x0454,0x00}, //C0_Blue_X2
2087 {0x0455,0x5D}, //C0_Blue_X2 LSB
2088 {0x0456,0x00}, //C0_Blue_Y2
2089 {0x0457,0x7F}, //C0_Blue_Y2 LSB
2090 {0x0458,0xFF}, //C0_Blue_XY
2091 {0x0459,0xD0}, //C0_Blue_XY LSB
2092 {0x045A,0x00}, //C0_Blue_X2Y
2093 {0x045B,0x1A}, //C0_Blue_X2Y LSB
2094 {0x045C,0xFF}, //C0_Blue_XY2
2095 {0x045D,0xC8}, //C0_Blue_XY2 LSB
2096 {0x045E,0xFF}, //C0_Blue_X2Y2
2097 {0x045F,0xDA}, //C0_Blue_X2Y2 LSB
2098 {0x0460,0x00}, //C1_GreenRed_X
2099 {0x0461,0x25}, //C1_GreenRed_X LSB
2100 {0x0462,0x00}, //C1_GreenRed_Y
2101 {0x0463,0x00}, //C1_GreenRed_Y LSB
2102 {0x0464,0x00}, //C1_GreenRed_X2
2103 {0x0465,0x65}, //C1_GreenRed_X2 LSB
2104 {0x0466,0x00}, //C1_GreenRed_Y2
2105 {0x0467,0x85}, //C1_GreenRed_Y2 LSB
2106 {0x0468,0x00}, //C1_GreenRed_XY
2107 {0x0469,0x41}, //C1_GreenRed_XY LSB
2108 {0x046A,0x00}, //C1_GreenRed_X2Y
2109 {0x046B,0x42}, //C1_GreenRed_X2Y LSB
2110 {0x046C,0x00}, //C1_GreenRed_XY2
2111 {0x046D,0x91}, //C1_GreenRed_XY2 LSB
2112 {0x046E,0xFF}, //C1_GreenRed_X2Y2
2113 {0x046F,0xDA}, //C1_GreenRed_X2Y2 LSB // F0
2114 {0x0470,0xFF}, //C1_Red_X
2115 {0x0471,0xD7}, //C1_Red_X LSB
2116 {0x0472,0xFF}, //C1_Red_Y
2117 {0x0473,0xA0}, //C1_Red_Y LSB
2118 {0x0474,0x00}, //C1_Red_X2
2119 {0x0475,0x8C}, //C1_Red_X2 LSB
2120 {0x0476,0x00}, //C1_Red_Y2
2121 {0x0477,0xA5}, //C1_Red_Y2 LSB
2122 {0x0478,0xFF}, //C1_Red_XY
2123 {0x0479,0xD6}, //C1_Red_XY LSB
2124 {0x047A,0xFF}, //C1_Red_X2Y
2125 {0x047B,0xDA}, //C1_Red_X2Y LSB
2126 {0x047C,0x00}, //C1_Red_XY2
2127 {0x047D,0x58}, //C1_Red_XY2 LSB
2128 {0x047E,0xFF}, //C1_Red_X2Y2
2129 {0x047F,0xC4}, //C1_Red_X2Y2 LSB
2130 {0x0480,0x00}, //C1_GreenBlue_X
2131 {0x0481,0x04}, //C1_GreenBlue_X LSB
2132 {0x0482,0xFF}, //C1_GreenBlue_Y
2133 {0x0483,0xFA}, //C1_GreenBlue_Y LSB
2134 {0x0484,0x00}, //C1_GreenBlue_X2
2135 {0x0485,0x70}, //C1_GreenBlue_X2 LSB
2136 {0x0486,0x00}, //C1_GreenBlue_Y2
2137 {0x0487,0x7B}, //C1_GreenBlue_Y2 LSB
2138 {0x0488,0x00}, //C1_GreenBlue_XY
2139 {0x0489,0x4E}, //C1_GreenBlue_XY LSB
2140 {0x048A,0x00}, //C1_GreenBlue_X2Y
2141 {0x048B,0x00}, //C1_GreenBlue_X2Y LSB
2142 {0x048C,0x00}, //C1_GreenBlue_XY2
2143 {0x048D,0x8F}, //C1_GreenBlue_XY2 LSB
2144 {0x048E,0xFF}, //C1_GreenBlue_X2Y2
2145 {0x048F,0xEC}, //C1_GreenBlue_X2Y2 LSB
2146 {0x0490,0x00}, //C1_Blue_X
2147 {0x0491,0x08}, //C1_Blue_X LSB
2148 {0x0492,0xFF}, //C1_Blue_Y
2149 {0x0493,0xD0}, //C1_Blue_Y LSB
2150 {0x0494,0x00}, //C1_Blue_X2
2151 {0x0495,0x55}, //C1_Blue_X2 LSB
2152 {0x0496,0x00}, //C1_Blue_Y2
2153 {0x0497,0x70}, //C1_Blue_Y2 LSB
2154 {0x0498,0xFF}, //C1_Blue_XY
2155 {0x0499,0xC4}, //C1_Blue_XY LSB
2156 {0x049A,0x00}, //C1_Blue_X2Y
2157 {0x049B,0x03}, //C1_Blue_X2Y LSB
2158 {0x049C,0xFF}, //C1_Blue_XY2
2159 {0x049D,0xD2}, //C1_Blue_XY2 LSB
2160 {0x049E,0x00}, //C1_Blue_X2Y2
2161 {0x049F,0x04}, //C1_Blue_X2Y2 LSB
2162 {0x04A0,0x00}, //C2_GreenRed_X
2163 {0x04A1,0x28}, //C2_GreenRed_X LSB
2164 {0x04A2,0xFF}, //C2_GreenRed_Y
2165 {0x04A3,0xFA}, //C2_GreenRed_Y LSB
2166 {0x04A4,0x00}, //C2_GreenRed_X2
2167 {0x04A5,0x69}, //C2_GreenRed_X2 LSB
2168 {0x04A6,0x00}, //C2_GreenRed_Y2
2169 {0x04A7,0x88}, //C2_GreenRed_Y2 LSB
2170 {0x04A8,0x00}, //C2_GreenRed_XY
2171 {0x04A9,0x47}, //C2_GreenRed_XY LSB
2172 {0x04AA,0x00}, //C2_GreenRed_X2Y
2173 {0x04AB,0x46}, //C2_GreenRed_X2Y LSB
2174 {0x04AC,0x00}, //C2_GreenRed_XY2
2175 {0x04AD,0xA2}, //C2_GreenRed_XY2 LSB
2176 {0x04AE,0xFF}, //C2_GreenRed_X2Y2
2177 {0x04AF,0xCF}, //C2_GreenRed_X2Y2 LSB // EA
2178 {0x04B0,0xFF}, //C2_Red_X
2179 {0x04B1,0xDC}, //C2_Red_X LSB
2180 {0x04B2,0xFF}, //C2_Red_Y
2181 {0x04B3,0xA4}, //C2_Red_Y LSB
2182 {0x04B4,0x00}, //C2_Red_X2
2183 {0x04B5,0x93}, //C2_Red_X2 LSB
2184 {0x04B6,0x00}, //C2_Red_Y2
2185 {0x04B7,0xB2}, //C2_Red_Y2 LSB
2186 {0x04B8,0xFF}, //C2_Red_XY
2187 {0x04B9,0xD8}, //C2_Red_XY LSB
2188 {0x04BA,0xFF}, //C2_Red_X2Y
2189 {0x04BB,0xCD}, //C2_Red_X2Y LSB
2190 {0x04BC,0x00}, //C2_Red_XY2
2191 {0x04BD,0x48}, //C2_Red_XY2 LSB
2192 {0x04BE,0xFF}, //C2_Red_X2Y2
2193 {0x04BF,0x9B}, //C2_Red_X2Y2 LSB
2194 {0x04C0,0x00}, //C2_GreenBlue_X
2195 {0x04C1,0x08}, //C2_GreenBlue_X LSB
2196 {0x04C2,0x00}, //C2_GreenBlue_Y
2197 {0x04C3,0x00}, //C2_GreenBlue_Y LSB
2198 {0x04C4,0x00}, //C2_GreenBlue_X2
2199 {0x04C5,0x73}, //C2_GreenBlue_X2 LSB
2200 {0x04C6,0x00}, //C2_GreenBlue_Y2
2201 {0x04C7,0x80}, //C2_GreenBlue_Y2 LSB
2202 {0x04C8,0x00}, //C2_GreenBlue_XY
2203 {0x04C9,0x4F}, //C2_GreenBlue_XY LSB
2204 {0x04CA,0xFF}, //C2_GreenBlue_X2Y
2205 {0x04CB,0xEF}, //C2_GreenBlue_X2Y LSB
2206 {0x04CC,0x00}, //C2_GreenBlue_XY2
2207 {0x04CD,0x89}, //C2_GreenBlue_XY2 LSB
2208 {0x04CE,0xFF}, //C2_GreenBlue_X2Y2
2209 {0x04CF,0xE2}, //C2_GreenBlue_X2Y2 LSB
2210 {0x04D0,0x00}, //C2_Blue_X
2211 {0x04D1,0x0C}, //C2_Blue_X LSB
2212 {0x04D2,0xFF}, //C2_Blue_Y
2213 {0x04D3,0xCE}, //C2_Blue_Y LSB
2214 {0x04D4,0x00}, //C2_Blue_X2
2215 {0x04D5,0x57}, //C2_Blue_X2 LSB
2216 {0x04D6,0x00}, //C2_Blue_Y2
2217 {0x04D7,0x72}, //C2_Blue_Y2 LSB
2218 {0x04D8,0xFF}, //C2_Blue_XY
2219 {0x04D9,0xC4}, //C2_Blue_XY LSB
2220 {0x04DA,0x00}, //C2_Blue_X2Y
2221 {0x04DB,0x09}, //C2_Blue_X2Y LSB
2222 {0x04DC,0xFF}, //C2_Blue_XY2
2223 {0x04DD,0xD2}, //C2_Blue_XY2 LSB
2224 {0x04DE,0xFF}, //C2_Blue_X2Y2
2225 {0x04DF,0xFC}, //C2_Blue_X2Y2 LSB
2226 {0x04E0,0x00}, //C3_GreenRed_X
2227 {0x04E1,0x2C}, //C3_GreenRed_X LSB
2228 {0x04E2,0xFF}, //C3_GreenRed_Y
2229 {0x04E3,0xFB}, //C3_GreenRed_Y LSB
2230 {0x04E4,0x00}, //C3_GreenRed_X2
2231 {0x04E5,0x69}, //C3_GreenRed_X2 LSB
2232 {0x04E6,0x00}, //C3_GreenRed_Y2
2233 {0x04E7,0x87}, //C3_GreenRed_Y2 LSB
2234 {0x04E8,0x00}, //C3_GreenRed_XY
2235 {0x04E9,0x4A}, //C3_GreenRed_XY LSB
2236 {0x04EA,0x00}, //C3_GreenRed_X2Y
2237 {0x04EB,0x56}, //C3_GreenRed_X2Y LSB
2238 {0x04EC,0x00}, //C3_GreenRed_XY2
2239 {0x04ED,0x9A}, //C3_GreenRed_XY2 LSB
2240 {0x04EE,0xFF}, //C3_GreenRed_X2Y2
2241 {0x04EF,0xBE}, //C3_GreenRed_X2Y2 LSB // DC
2242 {0x04F0,0xFF}, //C3_Red_X
2243 {0x04F1,0xEB}, //C3_Red_X LSB
2244 {0x04F2,0xFF}, //C3_Red_Y
2245 {0x04F3,0x9B}, //C3_Red_Y LSB
2246 {0x04F4,0x00}, //C3_Red_X2
2247 {0x04F5,0xA5}, //C3_Red_X2 LSB
2248 {0x04F6,0x00}, //C3_Red_Y2
2249 {0x04F7,0xCC}, //C3_Red_Y2 LSB
2250 {0x04F8,0xFF}, //C3_Red_XY
2251 {0x04F9,0xE1}, //C3_Red_XY LSB
2252 {0x04FA,0xFF}, //C3_Red_X2Y
2253 {0x04FB,0xD9}, //C3_Red_X2Y LSB
2254 {0x04FC,0x00}, //C3_Red_XY2
2255 {0x04FD,0x6A}, //C3_Red_XY2 LSB
2256 {0x04FE,0xFF}, //C3_Red_X2Y2
2257 {0x04FF,0x5E}, //C3_Red_X2Y2 LSB
2258 {0x0500,0x00}, //C3_GreenBlue_X
2259 {0x0501,0x06}, //C3_GreenBlue_X LSB
2260 {0x0502,0xFF}, //C3_GreenBlue_Y
2261 {0x0503,0xFC}, //C3_GreenBlue_Y LSB
2262 {0x0504,0x00}, //C3_GreenBlue_X2
2263 {0x0505,0x6F}, //C3_GreenBlue_X2 LSB
2264 {0x0506,0x00}, //C3_GreenBlue_Y2
2265 {0x0507,0x83}, //C3_GreenBlue_Y2 LSB
2266 {0x0508,0x00}, //C3_GreenBlue_XY
2267 {0x0509,0x5A}, //C3_GreenBlue_XY LSB
2268 {0x050A,0xFF}, //C3_GreenBlue_X2Y
2269 {0x050B,0xF7}, //C3_GreenBlue_X2Y LSB
2270 {0x050C,0x00}, //C3_GreenBlue_XY2
2271 {0x050D,0x80}, //C3_GreenBlue_XY2 LSB
2272 {0x050E,0xFF}, //C3_GreenBlue_X2Y2
2273 {0x050F,0xD3}, //C3_GreenBlue_X2Y2 LSB
2274 {0x0510,0x00}, //C3_Blue_X
2275 {0x0511,0x0B}, //C3_Blue_X LSB
2276 {0x0512,0xFF}, //C3_Blue_Y
2277 {0x0513,0xCE}, //C3_Blue_Y LSB
2278 {0x0514,0x00}, //C3_Blue_X2
2279 {0x0515,0x58}, //C3_Blue_X2 LSB
2280 {0x0516,0x00}, //C3_Blue_Y2
2281 {0x0517,0x73}, //C3_Blue_Y2 LSB
2282 {0x0518,0xFF}, //C3_Blue_XY
2283 {0x0519,0xBE}, //C3_Blue_XY LSB
2284 {0x051A,0xFF}, //C3_Blue_X2Y
2285 {0x051B,0xFB}, //C3_Blue_X2Y LSB
2286 {0x051C,0xFF}, //C3_Blue_XY2
2287 {0x051D,0xD2}, //C3_Blue_XY2 LSB
2288 {0x051E,0xFF}, //C3_Blue_X2Y2
2289 {0x051F,0xFA}, //C3_Blue_X2Y2 LSB
2290 {0x0561,0x05}, //C0 Unity
2291 {0x0562,0x01}, //C1 Unity
2292 {0x0563,0x01}, //C2 Unity
2293 {0x0564,0x09}, //C3 Unity
2388 {0x0081,0x64}, //6E->55
2400 // SensorWaitMs(200),
2407 {0x0659,0x01},//03-06 new af @ vcm
2419 {0x06D6,0xBD},//60->BC->66
2470 // {0x0040,0x01}, //AB2
2471 // {0x0041,0x03}, //SVGA mode
2483 /* Senor full resolution setting: recommand for capture */
2484 static struct rk_sensor_reg sensor_fullres_lowfps_data[] ={
2487 // SensorWaitMs(100),
2494 // SensorWaitMs(150),
2498 /* Senor full resolution setting: recommand for video */
2499 static struct rk_sensor_reg sensor_fullres_highfps_data[] ={
2502 /* Preview resolution setting*/
2503 static struct rk_sensor_reg sensor_preview_data[] =
2507 // SensorWaitMs(100),
2519 // SensorWaitMs(150),
2524 static struct rk_sensor_reg sensor_720p[]={
2529 static struct rk_sensor_reg sensor_1080p[]={
2534 static struct rk_sensor_reg sensor_softreset_data[]={
2538 static struct rk_sensor_reg sensor_check_id_data[]={
2539 SensorRegVal(0x0000,0),
2540 SensorRegVal(0x0001,0),
2544 * The following setting must been filled, if the function is turn on by CONFIG_SENSOR_xxxx
2546 static struct rk_sensor_reg sensor_WhiteB_Auto[]=
2551 /* Cloudy Colour Temperature : 6500K - 8000K */
2552 static struct rk_sensor_reg sensor_WhiteB_Cloudy[]=
2557 /* ClearDay Colour Temperature : 5000K - 6500K */
2558 static struct rk_sensor_reg sensor_WhiteB_ClearDay[]=
2563 /* Office Colour Temperature : 3500K - 5000K */
2564 static struct rk_sensor_reg sensor_WhiteB_TungstenLamp1[]=
2570 /* Home Colour Temperature : 2500K - 3500K */
2571 static struct rk_sensor_reg sensor_WhiteB_TungstenLamp2[]=
2576 static struct rk_sensor_reg *sensor_WhiteBalanceSeqe[] = {sensor_WhiteB_Auto, sensor_WhiteB_TungstenLamp1,sensor_WhiteB_TungstenLamp2,
2577 sensor_WhiteB_ClearDay, sensor_WhiteB_Cloudy,NULL,
2580 static struct rk_sensor_reg sensor_Brightness0[]=
2586 static struct rk_sensor_reg sensor_Brightness1[]=
2593 static struct rk_sensor_reg sensor_Brightness2[]=
2600 static struct rk_sensor_reg sensor_Brightness3[]=
2607 static struct rk_sensor_reg sensor_Brightness4[]=
2614 static struct rk_sensor_reg sensor_Brightness5[]=
2620 static struct rk_sensor_reg *sensor_BrightnessSeqe[] = {sensor_Brightness0, sensor_Brightness1, sensor_Brightness2, sensor_Brightness3,
2621 sensor_Brightness4, sensor_Brightness5,NULL,
2624 static struct rk_sensor_reg sensor_Effect_Normal[] =
2633 static struct rk_sensor_reg sensor_Effect_WandB[] =
2642 static struct rk_sensor_reg sensor_Effect_Sepia[] =
2651 static struct rk_sensor_reg sensor_Effect_Negative[] =
2660 static struct rk_sensor_reg sensor_Effect_Bluish[] =
2670 static struct rk_sensor_reg sensor_Effect_Green[] =
2679 static struct rk_sensor_reg *sensor_EffectSeqe[] = {sensor_Effect_Normal, sensor_Effect_WandB, sensor_Effect_Negative,sensor_Effect_Sepia,
2680 sensor_Effect_Bluish, sensor_Effect_Green,NULL,
2683 static struct rk_sensor_reg sensor_Exposure0[]=
2688 static struct rk_sensor_reg sensor_Exposure1[]=
2693 static struct rk_sensor_reg sensor_Exposure2[]=
2698 static struct rk_sensor_reg sensor_Exposure3[]=
2703 static struct rk_sensor_reg sensor_Exposure4[]=
2708 static struct rk_sensor_reg sensor_Exposure5[]=
2713 static struct rk_sensor_reg sensor_Exposure6[]=
2718 static struct rk_sensor_reg *sensor_ExposureSeqe[] = {sensor_Exposure0, sensor_Exposure1, sensor_Exposure2, sensor_Exposure3,
2719 sensor_Exposure4, sensor_Exposure5,sensor_Exposure6,NULL,
2722 static struct rk_sensor_reg sensor_Saturation0[]=
2727 static struct rk_sensor_reg sensor_Saturation1[]=
2732 static struct rk_sensor_reg sensor_Saturation2[]=
2736 static struct rk_sensor_reg *sensor_SaturationSeqe[] = {sensor_Saturation0, sensor_Saturation1, sensor_Saturation2, NULL,};
2738 static struct rk_sensor_reg sensor_Contrast0[]=
2743 static struct rk_sensor_reg sensor_Contrast1[]=
2748 static struct rk_sensor_reg sensor_Contrast2[]=
2753 static struct rk_sensor_reg sensor_Contrast3[]=
2758 static struct rk_sensor_reg sensor_Contrast4[]=
2764 static struct rk_sensor_reg sensor_Contrast5[]=
2769 static struct rk_sensor_reg sensor_Contrast6[]=
2773 static struct rk_sensor_reg *sensor_ContrastSeqe[] = {sensor_Contrast0, sensor_Contrast1, sensor_Contrast2, sensor_Contrast3,
2774 sensor_Contrast4, sensor_Contrast5, sensor_Contrast6, NULL,
2776 static struct rk_sensor_reg sensor_SceneAuto[] =
2782 static struct rk_sensor_reg sensor_SceneNight[] =
2786 static struct rk_sensor_reg *sensor_SceneSeqe[] = {sensor_SceneAuto, sensor_SceneNight,NULL,};
2788 static struct rk_sensor_reg sensor_Zoom0[] =
2793 static struct rk_sensor_reg sensor_Zoom1[] =
2798 static struct rk_sensor_reg sensor_Zoom2[] =
2804 static struct rk_sensor_reg sensor_Zoom3[] =
2808 static struct rk_sensor_reg *sensor_ZoomSeqe[] = {sensor_Zoom0, sensor_Zoom1, sensor_Zoom2, sensor_Zoom3, NULL,};
2811 * User could be add v4l2_querymenu in sensor_controls by new_usr_v4l2menu
2813 static struct v4l2_querymenu sensor_menus[] =
2817 * User could be add v4l2_queryctrl in sensor_controls by new_user_v4l2ctrl
2819 static struct sensor_v4l2ctrl_usr_s sensor_controls[] =
2823 //MUST define the current used format as the first item
2824 static struct rk_sensor_datafmt sensor_colour_fmts[] = {
2825 {V4L2_MBUS_FMT_UYVY8_2X8, V4L2_COLORSPACE_JPEG}
2830 **********************************************************
2831 * Following is local code:
2833 * Please codeing your program here
2834 **********************************************************
2839 **********************************************************
2840 * Following is callback
2841 * If necessary, you could coding these callback
2842 **********************************************************
2846 * the function is called in open sensor
2848 static int sensor_activate_cb(struct i2c_client *client)
2850 SENSOR_DG("%s",__FUNCTION__);
2854 * the function is called in close sensor
2856 static int sensor_deactivate_cb(struct i2c_client *client)
2858 SENSOR_DG("%s",__FUNCTION__);
2862 * the function is called before sensor register setting in VIDIOC_S_FMT
2864 static int sensor_s_fmt_cb_th(struct i2c_client *client,struct v4l2_mbus_framefmt *mf, bool capture)
2866 //struct generic_sensor*sensor = to_generic_sensor(client);
2871 static int sensor_softrest_usr_cb(struct i2c_client *client,struct rk_sensor_reg *series)
2876 static int sensor_check_id_usr_cb(struct i2c_client *client,struct rk_sensor_reg *series)
2882 * the function is called after sensor register setting finished in VIDIOC_S_FMT
2884 static int sensor_s_fmt_cb_bh (struct i2c_client *client,struct v4l2_mbus_framefmt *mf, bool capture)
2886 struct soc_camera_subdev_desc *ssdd = client->dev.platform_data;
2887 struct soc_camera_device *icd = ssdd->socdev;
2888 struct generic_sensor *gsensor = to_generic_sensor(client);
2891 generic_sensor_af_workqueue_set(icd, WqCmd_af_special_pos,0,true);
2893 if (gsensor->sensor_focus.focus_mode == V4L2_CID_FOCUS_AUTO) {
2894 generic_sensor_af_workqueue_set(icd, WqCmd_af_close,0,false);
2895 } else if (gsensor->sensor_focus.focus_mode == V4L2_CID_FOCUS_CONTINUOUS) {
2896 generic_sensor_af_workqueue_set(icd,WqCmd_af_continues,0,false);
2901 static int sensor_try_fmt_cb_th(struct i2c_client *client,struct v4l2_mbus_framefmt *mf)
2903 struct soc_camera_subdev_desc *ssdd = client->dev.platform_data;
2904 struct soc_camera_device *icd = ssdd->socdev;
2905 struct generic_sensor *gsensor = to_generic_sensor(client);
2907 if (gsensor->sensor_focus.focus_mode == V4L2_CID_FOCUS_CONTINUOUS) {
2908 generic_sensor_af_workqueue_set(icd,WqCmd_af_continues_pause,0,true);
2913 static int sensor_suspend(struct soc_camera_device *icd, pm_message_t pm_msg)
2915 //struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2917 if (pm_msg.event == PM_EVENT_SUSPEND) {
2918 SENSOR_DG("Suspend");
2921 SENSOR_TR("pm_msg.event(0x%x) != PM_EVENT_SUSPEND\n",pm_msg.event);
2927 static int sensor_resume(struct soc_camera_device *icd)
2930 SENSOR_DG("Resume");
2935 static int sensor_mirror_cb (struct i2c_client *client, int mirror)
2938 SENSOR_DG("mirror: %d",mirror);
2943 * the function is v4l2 control V4L2_CID_HFLIP callback
2945 static int sensor_v4l2ctrl_mirror_cb(struct soc_camera_device *icd, struct sensor_v4l2ctrl_info_s *ctrl_info,
2946 struct v4l2_ext_control *ext_ctrl)
2948 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2950 if (sensor_mirror_cb(client,ext_ctrl->value) != 0)
2951 SENSOR_TR("sensor_mirror failed, value:0x%x",ext_ctrl->value);
2953 SENSOR_DG("sensor_mirror success, value:0x%x",ext_ctrl->value);
2957 static int sensor_flip_cb(struct i2c_client *client, int flip)
2959 SENSOR_DG("flip: %d",flip);
2964 * the function is v4l2 control V4L2_CID_VFLIP callback
2966 static int sensor_v4l2ctrl_flip_cb(struct soc_camera_device *icd, struct sensor_v4l2ctrl_info_s *ctrl_info,
2967 struct v4l2_ext_control *ext_ctrl)
2969 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
2971 if (sensor_flip_cb(client,ext_ctrl->value) != 0)
2972 SENSOR_TR("sensor_flip failed, value:0x%x",ext_ctrl->value);
2974 SENSOR_DG("sensor_flip success, value:0x%x",ext_ctrl->value);
2978 * the functions are focus callbacks
2980 static int sensor_focus_af_single_usr_cb(struct i2c_client *client);
2982 static int sensor_focus_init_usr_cb(struct i2c_client *client)
2987 static int sensor_focus_af_single_usr_cb(struct i2c_client *client)
2991 #ifdef SENSOR_AF_CONFIG //xhh
2992 struct generic_sensor *sensor = to_generic_sensor(client);
2993 struct specific_sensor *ssensor = to_specific_sensor(sensor);
2995 sensor_write(client,0x0751,0x00);//add by jink 20141127
2996 ret |= sensor_write(client,AF_MODES_REG,0x03);
2997 msleep(200); //add by jink 20141127
2998 ret |= sensor_write(client,AF_AUTOCMDS_REG,0x01);
2999 msleep(200);//add by jink 20141127
3000 ret |= sensor_write(client,AF_AUTOCMDS_REG,0x02);
3005 // sensor_read(client,AF_FINISHCHK_REG,&state);
3007 // }while ((state != 1) && (cnt<100));
3009 // if (state == 1) {
3010 sensor_read(client, AF_LENSPOS_REG_H,(char*)&ssensor->parameter.af_pos[0]);
3011 sensor_read(client, AF_LENSPOS_REG_L,(char*)&ssensor->parameter.af_pos[1]);
3014 //SENSOR_DG("single focus, state: %d cnt: %d",state,cnt);
3016 //sensor_af_single_end:
3020 static int sensor_focus_af_near_usr_cb(struct i2c_client *client)
3025 static int sensor_focus_af_far_usr_cb(struct i2c_client *client)
3031 static int sensor_focus_af_specialpos_usr_cb(struct i2c_client *client,int pos)
3033 struct generic_sensor *sensor = to_generic_sensor(client);
3034 struct specific_sensor *ssensor = to_specific_sensor(sensor);
3035 #ifdef SENSOR_AF_CONFIG //xhh
3036 sensor_write(client,0x070A, 0x00);
3037 sensor_write(client,0x0734, ssensor->parameter.af_pos[0]& 0xFF);
3038 sensor_write(client,0x0735, ssensor->parameter.af_pos[1] & 0xFF);
3039 sensor_write(client,0x070C, 0x00);
3041 sensor_write(client,0x070C, 0x05);
3046 static int sensor_focus_af_const_usr_cb(struct i2c_client *client)
3049 #ifdef SENSOR_AF_CONFIG //xhh
3050 sensor_write(client,0x0751,0x00);//add by jink 20141127
3051 ret = sensor_write(client, AF_MODES_REG, 0x01);
3053 //sensor_af_const_end:
3056 static int sensor_focus_af_const_pause_usr_cb(struct i2c_client *client)
3059 #ifdef SENSOR_AF_CONFIG //xhh
3061 struct generic_sensor *sensor = to_generic_sensor(client);
3062 struct specific_sensor *ssensor = to_specific_sensor(sensor);
3064 sensor_read(client, 0x07ae, &status); //add by jink 20141127
3067 sensor_read(client, AF_LENSPOS_REG_H,(char*)&ssensor->parameter.af_pos[0]);
3068 sensor_read(client, AF_LENSPOS_REG_L,(char*)&ssensor->parameter.af_pos[1]);
3070 sensor_focus_af_single_usr_cb(client);
3075 static int sensor_focus_af_close_usr_cb(struct i2c_client *client)
3078 #ifdef SENSOR_AF_CONFIG //xhh
3079 sensor_write(client,0x0751,0x01);//add by jink 20141127
3081 ret |= sensor_write(client,0x070A, 0x00);
3082 ret |= sensor_write(client,0x0700, 0x03);
3083 ret |= sensor_write(client,0x0701, 0xFF);
3084 ret |= sensor_write(client,0x070C, 0x00);
3085 ret |= sensor_write(client,0x070C, 0x07);
3088 SENSOR_DG("%s",__FUNCTION__);
3092 static int sensor_focus_af_zoneupdate_usr_cb(struct i2c_client *client, int *zone_tm_pos)
3095 #ifdef SENSOR_AF_CONFIG //xhh
3098 *zone_tm_pos += 1000;
3099 *(zone_tm_pos+1) += 1000;
3100 *(zone_tm_pos+2) += 1000;
3101 *(zone_tm_pos+3) += 1000;
3103 xstart = ((*zone_tm_pos + *(zone_tm_pos+2))>>1)*800/2000;
3104 ystart = ((*(zone_tm_pos+1) + *(zone_tm_pos+3))>>1)*600/2000;
3118 ret |= sensor_write(client, AF_ZONE0_WEIGHT,0x01);
3119 ret |= sensor_write(client, AF_ZONE1_WEIGHT,0x00);
3120 ret |= sensor_write(client, AF_ZONE2_WEIGHT,0x00);
3121 ret |= sensor_write(client, AF_ZONE3_WEIGHT,0x00);
3122 ret |= sensor_write(client, AF_ZONE4_WEIGHT,0x00);
3123 ret |= sensor_write(client, AF_ZONE5_WEIGHT,0x00);
3124 ret |= sensor_write(client, AF_ZONE6_WEIGHT,0x00);
3125 ret |= sensor_write(client, FACE_LC,0x01);
3127 ret |= sensor_write(client, FACE_START_XH, ((xstart&0xff00)>>8));
3128 ret |= sensor_write(client, FACE_START_XL, xstart&0xff);
3129 ret |= sensor_write(client, FACE_START_YH, ((ystart&0xff00)>>8));
3130 ret |= sensor_write(client, FACE_START_YL, ystart&0xff);
3132 ret |= sensor_write(client, FACE_SIZE_XH, 0x01);
3133 ret |= sensor_write(client, FACE_SIZE_XL, 0x40);
3134 ret |= sensor_write(client, FACE_SIZE_YH, 0x01);
3135 ret |= sensor_write(client, FACE_SIZE_YL, 0x40);
3137 //sensor_af_zone_end:
3142 face defect call back
3144 static int sensor_face_detect_usr_cb(struct i2c_client *client,int on){
3149 * The function can been run in sensor_init_parametres which run in sensor_probe, so user can do some
3150 * initialization in the function.
3152 static void sensor_init_parameters_user(struct specific_sensor* spsensor,struct soc_camera_device *icd)
3159 * It is not allowed to modify the following code
3162 sensor_init_parameters_default_code();
3164 sensor_v4l2_struct_initialization();
3166 sensor_probe_default_code();
3168 sensor_remove_default_code();
3170 sensor_driver_default_module_code();