]>
Commit | Line | Data |
---|---|---|
c109f816 EA |
1 | /* |
2 | * Driver for the po1030 sensor. | |
c109f816 | 3 | * |
0c505e68 | 4 | * Copyright (c) 2008 Erik Andrén |
c109f816 EA |
5 | * Copyright (c) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. |
6 | * Copyright (c) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> | |
7 | * | |
8 | * Portions of code to USB interface and ALi driver software, | |
9 | * Copyright (c) 2006 Willem Duinker | |
10 | * v4l2 interface modeled after the V4L2 driver | |
11 | * for SN9C10x PC Camera Controllers | |
12 | * | |
0bd7bd79 | 13 | * Register defines taken from Pascal Stangs Procyon Armlib |
c109f816 EA |
14 | * |
15 | * This program is free software; you can redistribute it and/or | |
16 | * modify it under the terms of the GNU General Public License as | |
17 | * published by the Free Software Foundation, version 2. | |
18 | * | |
19 | */ | |
20 | ||
21 | #ifndef M5602_PO1030_H_ | |
22 | #define M5602_PO1030_H_ | |
23 | ||
24 | #include "m5602_sensor.h" | |
25 | ||
26 | /*****************************************************************************/ | |
27 | ||
bb9460eb EA |
28 | #define PO1030_DEVID_H 0x00 |
29 | #define PO1030_DEVID_L 0x01 | |
30 | #define PO1030_FRAMEWIDTH_H 0x04 | |
31 | #define PO1030_FRAMEWIDTH_L 0x05 | |
32 | #define PO1030_FRAMEHEIGHT_H 0x06 | |
33 | #define PO1030_FRAMEHEIGHT_L 0x07 | |
34 | #define PO1030_WINDOWX_H 0x08 | |
35 | #define PO1030_WINDOWX_L 0x09 | |
36 | #define PO1030_WINDOWY_H 0x0a | |
37 | #define PO1030_WINDOWY_L 0x0b | |
38 | #define PO1030_WINDOWWIDTH_H 0x0c | |
39 | #define PO1030_WINDOWWIDTH_L 0x0d | |
40 | #define PO1030_WINDOWHEIGHT_H 0x0e | |
41 | #define PO1030_WINDOWHEIGHT_L 0x0f | |
42 | ||
43 | #define PO1030_GLOBALIBIAS 0x12 | |
44 | #define PO1030_PIXELIBIAS 0x13 | |
45 | ||
46 | #define PO1030_GLOBALGAIN 0x15 | |
47 | #define PO1030_RED_GAIN 0x16 | |
48 | #define PO1030_GREEN_1_GAIN 0x17 | |
49 | #define PO1030_BLUE_GAIN 0x18 | |
50 | #define PO1030_GREEN_2_GAIN 0x19 | |
51 | ||
52 | #define PO1030_INTEGLINES_H 0x1a | |
53 | #define PO1030_INTEGLINES_M 0x1b | |
54 | #define PO1030_INTEGLINES_L 0x1c | |
55 | ||
56 | #define PO1030_CONTROL1 0x1d | |
57 | #define PO1030_CONTROL2 0x1e | |
58 | #define PO1030_CONTROL3 0x1f | |
59 | #define PO1030_CONTROL4 0x20 | |
60 | ||
61 | #define PO1030_PERIOD50_H 0x23 | |
62 | #define PO1030_PERIOD50_L 0x24 | |
63 | #define PO1030_PERIOD60_H 0x25 | |
64 | #define PO1030_PERIOD60_L 0x26 | |
65 | #define PO1030_REGCLK167 0x27 | |
66 | #define PO1030_FLICKER_DELTA50 0x28 | |
67 | #define PO1030_FLICKERDELTA60 0x29 | |
68 | ||
69 | #define PO1030_ADCOFFSET 0x2c | |
c109f816 EA |
70 | |
71 | /* Gamma Correction Coeffs */ | |
bb9460eb EA |
72 | #define PO1030_GC0 0x2d |
73 | #define PO1030_GC1 0x2e | |
74 | #define PO1030_GC2 0x2f | |
75 | #define PO1030_GC3 0x30 | |
76 | #define PO1030_GC4 0x31 | |
77 | #define PO1030_GC5 0x32 | |
78 | #define PO1030_GC6 0x33 | |
79 | #define PO1030_GC7 0x34 | |
c109f816 EA |
80 | |
81 | /* Color Transform Matrix */ | |
bb9460eb EA |
82 | #define PO1030_CT0 0x35 |
83 | #define PO1030_CT1 0x36 | |
84 | #define PO1030_CT2 0x37 | |
85 | #define PO1030_CT3 0x38 | |
86 | #define PO1030_CT4 0x39 | |
87 | #define PO1030_CT5 0x3a | |
88 | #define PO1030_CT6 0x3b | |
89 | #define PO1030_CT7 0x3c | |
90 | #define PO1030_CT8 0x3d | |
91 | ||
92 | #define PO1030_AUTOCTRL1 0x3e | |
93 | #define PO1030_AUTOCTRL2 0x3f | |
94 | ||
95 | #define PO1030_YTARGET 0x40 | |
96 | #define PO1030_GLOBALGAINMIN 0x41 | |
97 | #define PO1030_GLOBALGAINMAX 0x42 | |
98 | ||
99 | #define PO1030_AWB_RED_TUNING 0x47 | |
100 | #define PO1030_AWB_BLUE_TUNING 0x48 | |
c109f816 EA |
101 | |
102 | /* Output format control */ | |
bb9460eb EA |
103 | #define PO1030_OUTFORMCTRL1 0x5a |
104 | #define PO1030_OUTFORMCTRL2 0x5b | |
105 | #define PO1030_OUTFORMCTRL3 0x5c | |
106 | #define PO1030_OUTFORMCTRL4 0x5d | |
107 | #define PO1030_OUTFORMCTRL5 0x5e | |
c109f816 | 108 | |
bb9460eb EA |
109 | #define PO1030_EDGE_ENH_OFF 0x5f |
110 | #define PO1030_EGA 0x60 | |
111 | ||
112 | #define PO1030_Cb_U_GAIN 0x63 | |
113 | #define PO1030_Cr_V_GAIN 0x64 | |
114 | ||
115 | #define PO1030_YCONTRAST 0x74 | |
116 | #define PO1030_YSATURATION 0x75 | |
c109f816 | 117 | |
27429082 EA |
118 | #define PO1030_HFLIP (1 << 7) |
119 | #define PO1030_VFLIP (1 << 6) | |
120 | ||
121 | #define PO1030_HREF_ENABLE (1 << 6) | |
122 | ||
123 | #define PO1030_RAW_RGB_BAYER 0x4 | |
124 | ||
125 | #define PO1030_FRAME_EQUAL (1 << 3) | |
126 | #define PO1030_AUTO_SUBSAMPLING (1 << 4) | |
127 | ||
128 | #define PO1030_WEIGHT_WIN_2X (1 << 3) | |
129 | ||
130 | #define PO1030_SHUTTER_MODE (1 << 6) | |
131 | #define PO1030_AUTO_SUBSAMPLING (1 << 4) | |
132 | #define PO1030_FRAME_EQUAL (1 << 3) | |
133 | ||
134 | #define PO1030_SENSOR_RESET (1 << 5) | |
e2c97491 | 135 | |
931a1c8d EA |
136 | #define PO1030_SUBSAMPLING (1 << 6) |
137 | ||
c109f816 EA |
138 | /*****************************************************************************/ |
139 | ||
140 | #define PO1030_GLOBAL_GAIN_DEFAULT 0x12 | |
e2c97491 | 141 | #define PO1030_EXPOSURE_DEFAULT 0x0085 |
780e3121 JFM |
142 | #define PO1030_BLUE_GAIN_DEFAULT 0x36 |
143 | #define PO1030_RED_GAIN_DEFAULT 0x36 | |
144 | #define PO1030_GREEN_GAIN_DEFAULT 0x40 | |
c109f816 EA |
145 | |
146 | /*****************************************************************************/ | |
147 | ||
148 | /* Kernel module parameters */ | |
149 | extern int force_sensor; | |
150 | extern int dump_sensor; | |
c109f816 EA |
151 | |
152 | int po1030_probe(struct sd *sd); | |
153 | int po1030_init(struct sd *sd); | |
c996b368 | 154 | int po1030_start(struct sd *sd); |
05d7d9ce | 155 | void po1030_disconnect(struct sd *sd); |
c109f816 | 156 | |
dac136e6 | 157 | static const struct m5602_sensor po1030 = { |
e4cc4fcc EA |
158 | .name = "PO1030", |
159 | ||
160 | .i2c_slave_id = 0xdc, | |
161 | .i2c_regW = 1, | |
162 | ||
163 | .probe = po1030_probe, | |
164 | .init = po1030_init, | |
c996b368 | 165 | .start = po1030_start, |
05d7d9ce | 166 | .disconnect = po1030_disconnect, |
c109f816 EA |
167 | }; |
168 | ||
780e3121 | 169 | static const unsigned char preinit_po1030[][3] = { |
c109f816 EA |
170 | {BRIDGE, M5602_XB_MCU_CLK_DIV, 0x02}, |
171 | {BRIDGE, M5602_XB_MCU_CLK_CTRL, 0xb0}, | |
172 | {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00}, | |
173 | {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0}, | |
174 | {BRIDGE, M5602_XB_ADC_CTRL, 0xc0}, | |
c109f816 | 175 | {BRIDGE, M5602_XB_SENSOR_CTRL, 0x00}, |
c109f816 | 176 | {BRIDGE, M5602_XB_SENSOR_TYPE, 0x0c}, |
e8a57405 | 177 | {BRIDGE, M5602_XB_ADC_CTRL, 0xc0}, |
c109f816 EA |
178 | {BRIDGE, M5602_XB_GPIO_DIR, 0x05}, |
179 | {BRIDGE, M5602_XB_GPIO_DAT, 0x04}, | |
180 | {BRIDGE, M5602_XB_GPIO_EN_H, 0x06}, | |
181 | {BRIDGE, M5602_XB_GPIO_DIR_H, 0x06}, | |
182 | {BRIDGE, M5602_XB_GPIO_DAT_H, 0x02}, | |
c109f816 | 183 | |
27429082 | 184 | {SENSOR, PO1030_AUTOCTRL2, PO1030_SENSOR_RESET | (1 << 2)}, |
c109f816 | 185 | |
c109f816 EA |
186 | {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x04}, |
187 | {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0}, | |
188 | {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00}, | |
189 | {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0}, | |
c109f816 EA |
190 | {BRIDGE, M5602_XB_SENSOR_TYPE, 0x0c}, |
191 | {BRIDGE, M5602_XB_GPIO_DIR, 0x05}, | |
192 | {BRIDGE, M5602_XB_GPIO_DAT, 0x00} | |
193 | }; | |
194 | ||
780e3121 | 195 | static const unsigned char init_po1030[][3] = { |
c109f816 EA |
196 | {BRIDGE, M5602_XB_MCU_CLK_DIV, 0x02}, |
197 | {BRIDGE, M5602_XB_MCU_CLK_CTRL, 0xb0}, | |
c109f816 EA |
198 | {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00}, |
199 | {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0}, | |
200 | {BRIDGE, M5602_XB_ADC_CTRL, 0xc0}, | |
c109f816 | 201 | {BRIDGE, M5602_XB_SENSOR_CTRL, 0x00}, |
c109f816 | 202 | {BRIDGE, M5602_XB_SENSOR_TYPE, 0x0c}, |
c109f816 | 203 | |
27429082 | 204 | {SENSOR, PO1030_AUTOCTRL2, PO1030_SENSOR_RESET | (1 << 2)}, |
c109f816 EA |
205 | |
206 | {BRIDGE, M5602_XB_GPIO_DIR, 0x05}, | |
207 | {BRIDGE, M5602_XB_GPIO_DAT, 0x04}, | |
208 | {BRIDGE, M5602_XB_GPIO_EN_H, 0x06}, | |
e8a57405 | 209 | {BRIDGE, M5602_XB_GPIO_EN_L, 0x00}, |
c109f816 EA |
210 | {BRIDGE, M5602_XB_GPIO_DIR_H, 0x06}, |
211 | {BRIDGE, M5602_XB_GPIO_DAT_H, 0x02}, | |
212 | {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x04}, | |
213 | {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0}, | |
d9a11e28 EA |
214 | {BRIDGE, M5602_XB_GPIO_DIR, 0x05}, |
215 | {BRIDGE, M5602_XB_GPIO_DAT, 0x00}, | |
d9a11e28 EA |
216 | |
217 | {SENSOR, PO1030_AUTOCTRL2, 0x04}, | |
bb9460eb | 218 | |
27429082 EA |
219 | {SENSOR, PO1030_OUTFORMCTRL2, PO1030_RAW_RGB_BAYER}, |
220 | {SENSOR, PO1030_AUTOCTRL1, PO1030_WEIGHT_WIN_2X}, | |
825f31b0 | 221 | |
bb9460eb | 222 | {SENSOR, PO1030_CONTROL2, 0x03}, |
c109f816 | 223 | {SENSOR, 0x21, 0x90}, |
bb9460eb | 224 | {SENSOR, PO1030_YTARGET, 0x60}, |
c109f816 | 225 | {SENSOR, 0x59, 0x13}, |
27429082 | 226 | {SENSOR, PO1030_OUTFORMCTRL1, PO1030_HREF_ENABLE}, |
bb9460eb EA |
227 | {SENSOR, PO1030_EDGE_ENH_OFF, 0x00}, |
228 | {SENSOR, PO1030_EGA, 0x80}, | |
c109f816 EA |
229 | {SENSOR, 0x78, 0x14}, |
230 | {SENSOR, 0x6f, 0x01}, | |
bb9460eb EA |
231 | {SENSOR, PO1030_GLOBALGAINMAX, 0x14}, |
232 | {SENSOR, PO1030_Cb_U_GAIN, 0x38}, | |
233 | {SENSOR, PO1030_Cr_V_GAIN, 0x38}, | |
27429082 EA |
234 | {SENSOR, PO1030_CONTROL1, PO1030_SHUTTER_MODE | |
235 | PO1030_AUTO_SUBSAMPLING | | |
236 | PO1030_FRAME_EQUAL}, | |
bb9460eb EA |
237 | {SENSOR, PO1030_GC0, 0x10}, |
238 | {SENSOR, PO1030_GC1, 0x20}, | |
239 | {SENSOR, PO1030_GC2, 0x40}, | |
240 | {SENSOR, PO1030_GC3, 0x60}, | |
241 | {SENSOR, PO1030_GC4, 0x80}, | |
242 | {SENSOR, PO1030_GC5, 0xa0}, | |
243 | {SENSOR, PO1030_GC6, 0xc0}, | |
244 | {SENSOR, PO1030_GC7, 0xff}, | |
cb29e691 | 245 | |
c86da6b3 EA |
246 | /* Set the width to 751 */ |
247 | {SENSOR, PO1030_FRAMEWIDTH_H, 0x02}, | |
248 | {SENSOR, PO1030_FRAMEWIDTH_L, 0xef}, | |
249 | ||
250 | /* Set the height to 540 */ | |
251 | {SENSOR, PO1030_FRAMEHEIGHT_H, 0x02}, | |
252 | {SENSOR, PO1030_FRAMEHEIGHT_L, 0x1c}, | |
253 | ||
254 | /* Set the x window to 1 */ | |
255 | {SENSOR, PO1030_WINDOWX_H, 0x00}, | |
256 | {SENSOR, PO1030_WINDOWX_L, 0x01}, | |
257 | ||
258 | /* Set the y window to 1 */ | |
259 | {SENSOR, PO1030_WINDOWY_H, 0x00}, | |
260 | {SENSOR, PO1030_WINDOWY_L, 0x01}, | |
261 | ||
262 | /* with a very low lighted environment increase the exposure but | |
263 | * decrease the FPS (Frame Per Second) */ | |
264 | {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00}, | |
265 | {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0}, | |
266 | ||
267 | {BRIDGE, M5602_XB_GPIO_DIR, 0x05}, | |
268 | {BRIDGE, M5602_XB_GPIO_DAT, 0x00}, | |
269 | {BRIDGE, M5602_XB_GPIO_EN_H, 0x06}, | |
270 | {BRIDGE, M5602_XB_GPIO_EN_L, 0x00}, | |
271 | }; | |
c109f816 | 272 | #endif |