Commit | Line | Data |
---|---|---|
6a7eba24 | 1 | /* |
5b34e3e4 | 2 | * Sonix sn9c102p sn9c105 sn9c120 (jpeg) subdriver |
d5aa3856 | 3 | * |
27c6f9e5 | 4 | * Copyright (C) 2009-2010 Jean-François Moine <http://moinejf.free.fr> |
5b34e3e4 | 5 | * Copyright (C) 2005 Michel Xhaard mxhaard@magic.fr |
6a7eba24 JFM |
6 | * |
7 | * This program is free software; you can redistribute it and/or modify | |
8 | * it under the terms of the GNU General Public License as published by | |
9 | * the Free Software Foundation; either version 2 of the License, or | |
10 | * any later version. | |
11 | * | |
12 | * This program is distributed in the hope that it will be useful, | |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | * GNU General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License | |
18 | * along with this program; if not, write to the Free Software | |
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
20 | */ | |
21 | ||
22 | #define MODULE_NAME "sonixj" | |
23 | ||
9712a8be | 24 | #include <linux/input.h> |
6a7eba24 JFM |
25 | #include "gspca.h" |
26 | #include "jpeg.h" | |
27 | ||
0cae8964 JFM |
28 | #define V4L2_CID_INFRARED (V4L2_CID_PRIVATE_BASE + 0) |
29 | ||
27c6f9e5 | 30 | MODULE_AUTHOR("Jean-François Moine <http://moinejf.free.fr>"); |
6a7eba24 JFM |
31 | MODULE_DESCRIPTION("GSPCA/SONIX JPEG USB Camera Driver"); |
32 | MODULE_LICENSE("GPL"); | |
33 | ||
34 | /* specific webcam descriptor */ | |
35 | struct sd { | |
36 | struct gspca_dev gspca_dev; /* !! must be the first item */ | |
37 | ||
cebf3b67 | 38 | atomic_t avg_lum; |
98819187 JFM |
39 | u32 exposure; |
40 | ||
41 | u16 brightness; | |
42 | u8 contrast; | |
43 | u8 colors; | |
44 | u8 autogain; | |
45 | u8 blue; | |
46 | u8 red; | |
592f4eb9 | 47 | u8 gamma; |
2797ba2a | 48 | u8 vflip; /* ov7630/ov7648 only */ |
878b35ae | 49 | u8 sharpness; |
3ef2c5be | 50 | u8 infrared; /* mt9v111 only */ |
37c6dbe2 | 51 | u8 freq; /* ov76xx only */ |
71cb2764 | 52 | u8 quality; /* image quality */ |
77ac0baf JFM |
53 | #define QUALITY_MIN 60 |
54 | #define QUALITY_MAX 95 | |
55 | #define QUALITY_DEF 80 | |
71cb2764 JFM |
56 | u8 jpegqual; /* webcam quality */ |
57 | ||
58 | u8 reg18; | |
6a7eba24 | 59 | |
98819187 | 60 | s8 ag_cnt; |
6a7eba24 JFM |
61 | #define AG_CNT_START 13 |
62 | ||
98819187 | 63 | u8 bridge; |
3647fea8 HG |
64 | #define BRIDGE_SN9C102P 0 |
65 | #define BRIDGE_SN9C105 1 | |
66 | #define BRIDGE_SN9C110 2 | |
67 | #define BRIDGE_SN9C120 3 | |
98819187 | 68 | u8 sensor; /* Type of image sensor chip */ |
11ce884a JFM |
69 | u8 i2c_addr; |
70 | ||
71 | u8 jpeg_hdr[JPEG_HDR_SZ]; | |
72 | }; | |
73 | enum sensors { | |
9c33afc6 | 74 | SENSOR_ADCM1700, |
ad98c0f6 | 75 | SENSOR_GC0307, |
9c33afc6 JFM |
76 | SENSOR_HV7131R, |
77 | SENSOR_MI0360, | |
78 | SENSOR_MO4000, | |
79 | SENSOR_MT9V111, | |
80 | SENSOR_OM6802, | |
81 | SENSOR_OV7630, | |
82 | SENSOR_OV7648, | |
83 | SENSOR_OV7660, | |
84 | SENSOR_PO1030, | |
ad98c0f6 | 85 | SENSOR_PO2030N, |
03ed2a11 | 86 | SENSOR_SOI768, |
9c33afc6 | 87 | SENSOR_SP80708, |
6a7eba24 JFM |
88 | }; |
89 | ||
90 | /* V4L2 controls supported by the driver */ | |
91 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val); | |
92 | static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val); | |
93 | static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val); | |
94 | static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val); | |
95 | static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val); | |
96 | static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val); | |
403123d2 JFM |
97 | static int sd_setblue_balance(struct gspca_dev *gspca_dev, __s32 val); |
98 | static int sd_getblue_balance(struct gspca_dev *gspca_dev, __s32 *val); | |
99 | static int sd_setred_balance(struct gspca_dev *gspca_dev, __s32 val); | |
100 | static int sd_getred_balance(struct gspca_dev *gspca_dev, __s32 *val); | |
592f4eb9 JFM |
101 | static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val); |
102 | static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val); | |
6a7eba24 JFM |
103 | static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val); |
104 | static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val); | |
6c86274f JFM |
105 | static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val); |
106 | static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val); | |
878b35ae JFM |
107 | static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val); |
108 | static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val); | |
0cae8964 JFM |
109 | static int sd_setinfrared(struct gspca_dev *gspca_dev, __s32 val); |
110 | static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val); | |
37c6dbe2 HG |
111 | static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val); |
112 | static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val); | |
6a7eba24 | 113 | |
7e64dc4c | 114 | static const struct ctrl sd_ctrls[] = { |
9764398b | 115 | #define BRIGHTNESS_IDX 0 |
6a7eba24 JFM |
116 | { |
117 | { | |
118 | .id = V4L2_CID_BRIGHTNESS, | |
119 | .type = V4L2_CTRL_TYPE_INTEGER, | |
120 | .name = "Brightness", | |
121 | .minimum = 0, | |
05b809c7 JFM |
122 | #define BRIGHTNESS_MAX 0xffff |
123 | .maximum = BRIGHTNESS_MAX, | |
6a7eba24 | 124 | .step = 1, |
b1b056a5 | 125 | #define BRIGHTNESS_DEF 0x8000 |
a5ae2062 | 126 | .default_value = BRIGHTNESS_DEF, |
6a7eba24 JFM |
127 | }, |
128 | .set = sd_setbrightness, | |
129 | .get = sd_getbrightness, | |
130 | }, | |
9764398b | 131 | #define CONTRAST_IDX 1 |
6a7eba24 JFM |
132 | { |
133 | { | |
134 | .id = V4L2_CID_CONTRAST, | |
135 | .type = V4L2_CTRL_TYPE_INTEGER, | |
136 | .name = "Contrast", | |
137 | .minimum = 0, | |
05b809c7 JFM |
138 | #define CONTRAST_MAX 127 |
139 | .maximum = CONTRAST_MAX, | |
6a7eba24 | 140 | .step = 1, |
a5ae2062 JFM |
141 | #define CONTRAST_DEF 63 |
142 | .default_value = CONTRAST_DEF, | |
6a7eba24 JFM |
143 | }, |
144 | .set = sd_setcontrast, | |
145 | .get = sd_getcontrast, | |
146 | }, | |
9764398b | 147 | #define COLOR_IDX 2 |
6a7eba24 JFM |
148 | { |
149 | { | |
150 | .id = V4L2_CID_SATURATION, | |
151 | .type = V4L2_CTRL_TYPE_INTEGER, | |
3fb4a57b | 152 | .name = "Saturation", |
6a7eba24 | 153 | .minimum = 0, |
403123d2 | 154 | .maximum = 40, |
6a7eba24 | 155 | .step = 1, |
3fb4a57b | 156 | #define COLOR_DEF 25 |
a5ae2062 | 157 | .default_value = COLOR_DEF, |
6a7eba24 JFM |
158 | }, |
159 | .set = sd_setcolors, | |
160 | .get = sd_getcolors, | |
161 | }, | |
9764398b | 162 | #define BLUE_BALANCE_IDX 3 |
403123d2 JFM |
163 | { |
164 | { | |
165 | .id = V4L2_CID_BLUE_BALANCE, | |
166 | .type = V4L2_CTRL_TYPE_INTEGER, | |
167 | .name = "Blue Balance", | |
168 | .minimum = 24, | |
169 | .maximum = 40, | |
170 | .step = 1, | |
171 | #define BLUE_BALANCE_DEF 32 | |
172 | .default_value = BLUE_BALANCE_DEF, | |
173 | }, | |
174 | .set = sd_setblue_balance, | |
175 | .get = sd_getblue_balance, | |
176 | }, | |
9764398b | 177 | #define RED_BALANCE_IDX 4 |
403123d2 JFM |
178 | { |
179 | { | |
180 | .id = V4L2_CID_RED_BALANCE, | |
181 | .type = V4L2_CTRL_TYPE_INTEGER, | |
182 | .name = "Red Balance", | |
183 | .minimum = 24, | |
184 | .maximum = 40, | |
185 | .step = 1, | |
186 | #define RED_BALANCE_DEF 32 | |
187 | .default_value = RED_BALANCE_DEF, | |
188 | }, | |
189 | .set = sd_setred_balance, | |
190 | .get = sd_getred_balance, | |
191 | }, | |
9764398b | 192 | #define GAMMA_IDX 5 |
592f4eb9 JFM |
193 | { |
194 | { | |
195 | .id = V4L2_CID_GAMMA, | |
196 | .type = V4L2_CTRL_TYPE_INTEGER, | |
197 | .name = "Gamma", | |
198 | .minimum = 0, | |
199 | .maximum = 40, | |
200 | .step = 1, | |
201 | #define GAMMA_DEF 20 | |
202 | .default_value = GAMMA_DEF, | |
203 | }, | |
204 | .set = sd_setgamma, | |
205 | .get = sd_getgamma, | |
206 | }, | |
9764398b | 207 | #define AUTOGAIN_IDX 6 |
6a7eba24 JFM |
208 | { |
209 | { | |
210 | .id = V4L2_CID_AUTOGAIN, | |
211 | .type = V4L2_CTRL_TYPE_BOOLEAN, | |
212 | .name = "Auto Gain", | |
213 | .minimum = 0, | |
214 | .maximum = 1, | |
215 | .step = 1, | |
a5ae2062 JFM |
216 | #define AUTOGAIN_DEF 1 |
217 | .default_value = AUTOGAIN_DEF, | |
6a7eba24 JFM |
218 | }, |
219 | .set = sd_setautogain, | |
220 | .get = sd_getautogain, | |
221 | }, | |
2797ba2a | 222 | /* ov7630/ov7648 only */ |
9764398b | 223 | #define VFLIP_IDX 7 |
6c86274f JFM |
224 | { |
225 | { | |
226 | .id = V4L2_CID_VFLIP, | |
227 | .type = V4L2_CTRL_TYPE_BOOLEAN, | |
228 | .name = "Vflip", | |
229 | .minimum = 0, | |
230 | .maximum = 1, | |
231 | .step = 1, | |
f800952c | 232 | #define VFLIP_DEF 0 |
6c86274f JFM |
233 | .default_value = VFLIP_DEF, |
234 | }, | |
235 | .set = sd_setvflip, | |
236 | .get = sd_getvflip, | |
237 | }, | |
878b35ae JFM |
238 | #define SHARPNESS_IDX 8 |
239 | { | |
240 | { | |
241 | .id = V4L2_CID_SHARPNESS, | |
242 | .type = V4L2_CTRL_TYPE_INTEGER, | |
243 | .name = "Sharpness", | |
244 | .minimum = 0, | |
245 | .maximum = 255, | |
246 | .step = 1, | |
247 | #define SHARPNESS_DEF 90 | |
248 | .default_value = SHARPNESS_DEF, | |
249 | }, | |
250 | .set = sd_setsharpness, | |
251 | .get = sd_getsharpness, | |
252 | }, | |
3ef2c5be | 253 | /* mt9v111 only */ |
878b35ae | 254 | #define INFRARED_IDX 9 |
0cae8964 JFM |
255 | { |
256 | { | |
257 | .id = V4L2_CID_INFRARED, | |
258 | .type = V4L2_CTRL_TYPE_BOOLEAN, | |
259 | .name = "Infrared", | |
260 | .minimum = 0, | |
261 | .maximum = 1, | |
262 | .step = 1, | |
263 | #define INFRARED_DEF 0 | |
264 | .default_value = INFRARED_DEF, | |
265 | }, | |
266 | .set = sd_setinfrared, | |
267 | .get = sd_getinfrared, | |
268 | }, | |
37c6dbe2 | 269 | /* ov7630/ov7648/ov7660 only */ |
878b35ae | 270 | #define FREQ_IDX 10 |
37c6dbe2 HG |
271 | { |
272 | { | |
273 | .id = V4L2_CID_POWER_LINE_FREQUENCY, | |
274 | .type = V4L2_CTRL_TYPE_MENU, | |
275 | .name = "Light frequency filter", | |
276 | .minimum = 0, | |
277 | .maximum = 2, /* 0: 0, 1: 50Hz, 2:60Hz */ | |
278 | .step = 1, | |
b8c8a5bf | 279 | #define FREQ_DEF 1 |
37c6dbe2 HG |
280 | .default_value = FREQ_DEF, |
281 | }, | |
282 | .set = sd_setfreq, | |
283 | .get = sd_getfreq, | |
284 | }, | |
6a7eba24 JFM |
285 | }; |
286 | ||
577cbf49 | 287 | /* table of the disabled controls */ |
9c33afc6 JFM |
288 | static const __u32 ctrl_dis[] = { |
289 | [SENSOR_ADCM1700] = (1 << AUTOGAIN_IDX) | | |
290 | (1 << INFRARED_IDX) | | |
291 | (1 << VFLIP_IDX) | | |
292 | (1 << FREQ_IDX), | |
293 | ||
c26b12d0 | 294 | [SENSOR_GC0307] = (1 << INFRARED_IDX) | |
ad98c0f6 JFM |
295 | (1 << VFLIP_IDX) | |
296 | (1 << FREQ_IDX), | |
297 | ||
9c33afc6 JFM |
298 | [SENSOR_HV7131R] = (1 << INFRARED_IDX) | |
299 | (1 << FREQ_IDX), | |
300 | ||
301 | [SENSOR_MI0360] = (1 << INFRARED_IDX) | | |
302 | (1 << VFLIP_IDX) | | |
303 | (1 << FREQ_IDX), | |
304 | ||
305 | [SENSOR_MO4000] = (1 << INFRARED_IDX) | | |
306 | (1 << VFLIP_IDX) | | |
307 | (1 << FREQ_IDX), | |
308 | ||
309 | [SENSOR_MT9V111] = (1 << VFLIP_IDX) | | |
310 | (1 << FREQ_IDX), | |
311 | ||
312 | [SENSOR_OM6802] = (1 << INFRARED_IDX) | | |
313 | (1 << VFLIP_IDX) | | |
314 | (1 << FREQ_IDX), | |
315 | ||
316 | [SENSOR_OV7630] = (1 << INFRARED_IDX), | |
317 | ||
318 | [SENSOR_OV7648] = (1 << INFRARED_IDX), | |
319 | ||
320 | [SENSOR_OV7660] = (1 << AUTOGAIN_IDX) | | |
321 | (1 << INFRARED_IDX) | | |
322 | (1 << VFLIP_IDX), | |
323 | ||
324 | [SENSOR_PO1030] = (1 << AUTOGAIN_IDX) | | |
325 | (1 << INFRARED_IDX) | | |
326 | (1 << VFLIP_IDX) | | |
327 | (1 << FREQ_IDX), | |
328 | ||
ad98c0f6 JFM |
329 | [SENSOR_PO2030N] = (1 << AUTOGAIN_IDX) | |
330 | (1 << INFRARED_IDX) | | |
331 | (1 << VFLIP_IDX) | | |
332 | (1 << FREQ_IDX), | |
03ed2a11 JFM |
333 | [SENSOR_SOI768] = (1 << AUTOGAIN_IDX) | |
334 | (1 << INFRARED_IDX) | | |
335 | (1 << VFLIP_IDX) | | |
336 | (1 << FREQ_IDX), | |
ad98c0f6 | 337 | |
9c33afc6 JFM |
338 | [SENSOR_SP80708] = (1 << AUTOGAIN_IDX) | |
339 | (1 << INFRARED_IDX) | | |
340 | (1 << VFLIP_IDX) | | |
341 | (1 << FREQ_IDX), | |
577cbf49 JFM |
342 | }; |
343 | ||
64677573 JFM |
344 | static const struct v4l2_pix_format cif_mode[] = { |
345 | {352, 288, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, | |
346 | .bytesperline = 352, | |
347 | .sizeimage = 352 * 288 * 4 / 8 + 590, | |
348 | .colorspace = V4L2_COLORSPACE_JPEG, | |
349 | .priv = 0}, | |
350 | }; | |
cc611b8a | 351 | static const struct v4l2_pix_format vga_mode[] = { |
c2446b3e JFM |
352 | {160, 120, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, |
353 | .bytesperline = 160, | |
5d05294a | 354 | .sizeimage = 160 * 120 * 4 / 8 + 590, |
c2446b3e JFM |
355 | .colorspace = V4L2_COLORSPACE_JPEG, |
356 | .priv = 2}, | |
357 | {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, | |
358 | .bytesperline = 320, | |
359 | .sizeimage = 320 * 240 * 3 / 8 + 590, | |
360 | .colorspace = V4L2_COLORSPACE_JPEG, | |
361 | .priv = 1}, | |
362 | {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, | |
363 | .bytesperline = 640, | |
a5d1cc39 HG |
364 | /* Note 3 / 8 is not large enough, not even 5 / 8 is ?! */ |
365 | .sizeimage = 640 * 480 * 3 / 4 + 590, | |
c2446b3e JFM |
366 | .colorspace = V4L2_COLORSPACE_JPEG, |
367 | .priv = 0}, | |
6a7eba24 JFM |
368 | }; |
369 | ||
64677573 JFM |
370 | static const u8 sn_adcm1700[0x1c] = { |
371 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ | |
878b35ae | 372 | 0x00, 0x43, 0x60, 0x00, 0x1a, 0x00, 0x00, 0x00, |
64677573 JFM |
373 | /* reg8 reg9 rega regb regc regd rege regf */ |
374 | 0x80, 0x51, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
375 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ | |
376 | 0x03, 0x00, 0x05, 0x01, 0x05, 0x16, 0x12, 0x42, | |
377 | /* reg18 reg19 reg1a reg1b */ | |
378 | 0x06, 0x00, 0x00, 0x00 | |
379 | }; | |
380 | ||
ad98c0f6 JFM |
381 | static const u8 sn_gc0307[0x1c] = { |
382 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ | |
383 | 0x00, 0x61, 0x62, 0x00, 0x1a, 0x00, 0x00, 0x00, | |
384 | /* reg8 reg9 rega regb regc regd rege regf */ | |
385 | 0x80, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
386 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ | |
387 | 0x03, 0x00, 0x03, 0x01, 0x08, 0x28, 0x1e, 0x02, | |
388 | /* reg18 reg19 reg1a reg1b */ | |
389 | 0x06, 0x00, 0x00, 0x00 | |
390 | }; | |
391 | ||
8c2ba441 | 392 | static const u8 sn_hv7131[0x1c] = { |
8f47a3ce | 393 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ |
19697b54 | 394 | 0x00, 0x03, 0x60, 0x00, 0x1a, 0x20, 0x20, 0x20, |
8f47a3ce | 395 | /* reg8 reg9 rega regb regc regd rege regf */ |
98941e4d | 396 | 0x81, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
8f47a3ce JFM |
397 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ |
398 | 0x03, 0x00, 0x00, 0x01, 0x03, 0x28, 0x1e, 0x41, | |
8c2ba441 JFM |
399 | /* reg18 reg19 reg1a reg1b */ |
400 | 0x0a, 0x00, 0x00, 0x00 | |
6a7eba24 JFM |
401 | }; |
402 | ||
8c2ba441 | 403 | static const u8 sn_mi0360[0x1c] = { |
8f47a3ce | 404 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ |
19697b54 | 405 | 0x00, 0x61, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20, |
8f47a3ce | 406 | /* reg8 reg9 rega regb regc regd rege regf */ |
98941e4d | 407 | 0x81, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
8f47a3ce JFM |
408 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ |
409 | 0x03, 0x00, 0x00, 0x02, 0x0a, 0x28, 0x1e, 0x61, | |
8c2ba441 JFM |
410 | /* reg18 reg19 reg1a reg1b */ |
411 | 0x06, 0x00, 0x00, 0x00 | |
6a7eba24 JFM |
412 | }; |
413 | ||
8c2ba441 | 414 | static const u8 sn_mo4000[0x1c] = { |
8f47a3ce | 415 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ |
8c2ba441 | 416 | 0x00, 0x23, 0x60, 0x00, 0x1a, 0x00, 0x20, 0x18, |
8f47a3ce JFM |
417 | /* reg8 reg9 rega regb regc regd rege regf */ |
418 | 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
419 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ | |
420 | 0x03, 0x00, 0x0b, 0x0f, 0x14, 0x28, 0x1e, 0x40, | |
8c2ba441 JFM |
421 | /* reg18 reg19 reg1a reg1b */ |
422 | 0x08, 0x00, 0x00, 0x00 | |
6a7eba24 JFM |
423 | }; |
424 | ||
3ef2c5be JFM |
425 | static const u8 sn_mt9v111[0x1c] = { |
426 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ | |
427 | 0x00, 0x61, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20, | |
428 | /* reg8 reg9 rega regb regc regd rege regf */ | |
98941e4d | 429 | 0x81, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
3ef2c5be JFM |
430 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ |
431 | 0x03, 0x00, 0x00, 0x02, 0x1c, 0x28, 0x1e, 0x40, | |
432 | /* reg18 reg19 reg1a reg1b */ | |
433 | 0x06, 0x00, 0x00, 0x00 | |
434 | }; | |
435 | ||
8c2ba441 | 436 | static const u8 sn_om6802[0x1c] = { |
d2d16e90 | 437 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ |
46b4f2ab | 438 | 0x00, 0x23, 0x72, 0x00, 0x1a, 0x20, 0x20, 0x19, |
d2d16e90 JFM |
439 | /* reg8 reg9 rega regb regc regd rege regf */ |
440 | 0x80, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
441 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ | |
442 | 0x03, 0x00, 0x51, 0x01, 0x00, 0x28, 0x1e, 0x40, | |
8c2ba441 JFM |
443 | /* reg18 reg19 reg1a reg1b */ |
444 | 0x05, 0x00, 0x00, 0x00 | |
d2d16e90 JFM |
445 | }; |
446 | ||
8c2ba441 | 447 | static const u8 sn_ov7630[0x1c] = { |
6ab0b174 | 448 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ |
0a85c74b | 449 | 0x00, 0x21, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00, |
6ab0b174 | 450 | /* reg8 reg9 rega regb regc regd rege regf */ |
98941e4d | 451 | 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
6ab0b174 JFM |
452 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ |
453 | 0x03, 0x00, 0x04, 0x01, 0x0a, 0x28, 0x1e, 0xc2, | |
8c2ba441 JFM |
454 | /* reg18 reg19 reg1a reg1b */ |
455 | 0x0b, 0x00, 0x00, 0x00 | |
6ab0b174 JFM |
456 | }; |
457 | ||
8c2ba441 | 458 | static const u8 sn_ov7648[0x1c] = { |
8f47a3ce | 459 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ |
6270330a | 460 | 0x00, 0x63, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20, |
8f47a3ce | 461 | /* reg8 reg9 rega regb regc regd rege regf */ |
98941e4d | 462 | 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
8f47a3ce | 463 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ |
6270330a | 464 | 0x03, 0x00, 0x00, 0x01, 0x00, 0x28, 0x1e, 0x00, |
8c2ba441 JFM |
465 | /* reg18 reg19 reg1a reg1b */ |
466 | 0x0b, 0x00, 0x00, 0x00 | |
6a7eba24 JFM |
467 | }; |
468 | ||
8c2ba441 | 469 | static const u8 sn_ov7660[0x1c] = { |
8f47a3ce | 470 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ |
c8b9b2ca | 471 | 0x00, 0x61, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00, |
8f47a3ce | 472 | /* reg8 reg9 rega regb regc regd rege regf */ |
c8b9b2ca | 473 | 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
8f47a3ce JFM |
474 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ |
475 | 0x03, 0x00, 0x01, 0x01, 0x08, 0x28, 0x1e, 0x20, | |
8c2ba441 JFM |
476 | /* reg18 reg19 reg1a reg1b */ |
477 | 0x07, 0x00, 0x00, 0x00 | |
6a7eba24 JFM |
478 | }; |
479 | ||
b8c8a5bf JFM |
480 | static const u8 sn_po1030[0x1c] = { |
481 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ | |
482 | 0x00, 0x21, 0x62, 0x00, 0x1a, 0x20, 0x20, 0x20, | |
483 | /* reg8 reg9 rega regb regc regd rege regf */ | |
484 | 0x81, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
485 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ | |
486 | 0x03, 0x00, 0x00, 0x06, 0x06, 0x28, 0x1e, 0x00, | |
487 | /* reg18 reg19 reg1a reg1b */ | |
488 | 0x07, 0x00, 0x00, 0x00 | |
489 | }; | |
490 | ||
ad98c0f6 JFM |
491 | static const u8 sn_po2030n[0x1c] = { |
492 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ | |
493 | 0x00, 0x63, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00, | |
494 | /* reg8 reg9 rega regb regc regd rege regf */ | |
495 | 0x81, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
496 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ | |
497 | 0x03, 0x00, 0x00, 0x01, 0x14, 0x28, 0x1e, 0x00, | |
498 | /* reg18 reg19 reg1a reg1b */ | |
499 | 0x07, 0x00, 0x00, 0x00 | |
500 | }; | |
501 | ||
03ed2a11 JFM |
502 | static const u8 sn_soi768[0x1c] = { |
503 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ | |
504 | 0x00, 0x21, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00, | |
505 | /* reg8 reg9 rega regb regc regd rege regf */ | |
506 | 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
507 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ | |
508 | 0x03, 0x00, 0x00, 0x01, 0x08, 0x28, 0x1e, 0x00, | |
509 | /* reg18 reg19 reg1a reg1b */ | |
510 | 0x07, 0x00, 0x00, 0x00 | |
511 | }; | |
512 | ||
5e31dc8d JFM |
513 | static const u8 sn_sp80708[0x1c] = { |
514 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ | |
515 | 0x00, 0x63, 0x60, 0x00, 0x1a, 0x20, 0x20, 0x20, | |
516 | /* reg8 reg9 rega regb regc regd rege regf */ | |
98941e4d | 517 | 0x81, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
5e31dc8d JFM |
518 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ |
519 | 0x03, 0x00, 0x00, 0x03, 0x04, 0x28, 0x1e, 0x00, | |
520 | /* reg18 reg19 reg1a reg1b */ | |
521 | 0x07, 0x00, 0x00, 0x00 | |
522 | }; | |
523 | ||
6a7eba24 | 524 | /* sequence specific to the sensors - !! index = SENSOR_xxx */ |
8c2ba441 | 525 | static const u8 *sn_tb[] = { |
9c33afc6 | 526 | [SENSOR_ADCM1700] = sn_adcm1700, |
ad98c0f6 | 527 | [SENSOR_GC0307] = sn_gc0307, |
9c33afc6 JFM |
528 | [SENSOR_HV7131R] = sn_hv7131, |
529 | [SENSOR_MI0360] = sn_mi0360, | |
530 | [SENSOR_MO4000] = sn_mo4000, | |
531 | [SENSOR_MT9V111] = sn_mt9v111, | |
532 | [SENSOR_OM6802] = sn_om6802, | |
533 | [SENSOR_OV7630] = sn_ov7630, | |
534 | [SENSOR_OV7648] = sn_ov7648, | |
535 | [SENSOR_OV7660] = sn_ov7660, | |
536 | [SENSOR_PO1030] = sn_po1030, | |
ad98c0f6 | 537 | [SENSOR_PO2030N] = sn_po2030n, |
03ed2a11 JFM |
538 | [SENSOR_SOI768] = sn_soi768, |
539 | [SENSOR_SP80708] = sn_sp80708, | |
6a7eba24 JFM |
540 | }; |
541 | ||
b083b92f | 542 | /* default gamma table */ |
98819187 | 543 | static const u8 gamma_def[17] = { |
6a7eba24 JFM |
544 | 0x00, 0x2d, 0x46, 0x5a, 0x6c, 0x7c, 0x8b, 0x99, |
545 | 0xa6, 0xb2, 0xbf, 0xca, 0xd5, 0xe0, 0xeb, 0xf5, 0xff | |
546 | }; | |
64677573 JFM |
547 | /* gamma for sensor ADCM1700 */ |
548 | static const u8 gamma_spec_0[17] = { | |
549 | 0x0f, 0x39, 0x5a, 0x74, 0x86, 0x95, 0xa6, 0xb4, | |
550 | 0xbd, 0xc4, 0xcc, 0xd4, 0xd5, 0xde, 0xe4, 0xed, 0xf5 | |
551 | }; | |
b083b92f JFM |
552 | /* gamma for sensors HV7131R and MT9V111 */ |
553 | static const u8 gamma_spec_1[17] = { | |
554 | 0x08, 0x3a, 0x52, 0x65, 0x75, 0x83, 0x91, 0x9d, | |
555 | 0xa9, 0xb4, 0xbe, 0xc8, 0xd2, 0xdb, 0xe4, 0xed, 0xf5 | |
556 | }; | |
ad98c0f6 | 557 | /* gamma for sensor GC0307 */ |
b083b92f | 558 | static const u8 gamma_spec_2[17] = { |
ad98c0f6 JFM |
559 | 0x14, 0x37, 0x50, 0x6a, 0x7c, 0x8d, 0x9d, 0xab, |
560 | 0xb5, 0xbf, 0xc2, 0xcb, 0xd1, 0xd6, 0xdb, 0xe1, 0xeb | |
561 | }; | |
562 | /* gamma for sensor SP80708 */ | |
563 | static const u8 gamma_spec_3[17] = { | |
b083b92f JFM |
564 | 0x0a, 0x2d, 0x4e, 0x68, 0x7d, 0x8f, 0x9f, 0xab, |
565 | 0xb7, 0xc2, 0xcc, 0xd3, 0xd8, 0xde, 0xe2, 0xe5, 0xe6 | |
566 | }; | |
592f4eb9 | 567 | |
803f9ccf | 568 | /* color matrix and offsets */ |
98819187 | 569 | static const u8 reg84[] = { |
803f9ccf JFM |
570 | 0x14, 0x00, 0x27, 0x00, 0x07, 0x00, /* YR YG YB gains */ |
571 | 0xe8, 0x0f, 0xda, 0x0f, 0x40, 0x00, /* UR UG UB */ | |
572 | 0x3e, 0x00, 0xcd, 0x0f, 0xf7, 0x0f, /* VR VG VB */ | |
573 | 0x00, 0x00, 0x00 /* YUV offsets */ | |
6a7eba24 | 574 | }; |
64677573 JFM |
575 | static const u8 adcm1700_sensor_init[][8] = { |
576 | {0xa0, 0x51, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
878b35ae | 577 | {0xb0, 0x51, 0x04, 0x08, 0x00, 0x00, 0x00, 0x10}, /* reset */ |
64677573 JFM |
578 | {0xdd, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, |
579 | {0xb0, 0x51, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
580 | {0xdd, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, | |
581 | {0xb0, 0x51, 0x0c, 0xe0, 0x2e, 0x00, 0x00, 0x10}, | |
582 | {0xb0, 0x51, 0x10, 0x02, 0x02, 0x00, 0x00, 0x10}, | |
583 | {0xb0, 0x51, 0x14, 0x0e, 0x0e, 0x00, 0x00, 0x10}, | |
584 | {0xb0, 0x51, 0x1c, 0x00, 0x80, 0x00, 0x00, 0x10}, | |
585 | {0xb0, 0x51, 0x20, 0x01, 0x00, 0x00, 0x00, 0x10}, | |
586 | {0xdd, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, | |
587 | {0xb0, 0x51, 0x04, 0x04, 0x00, 0x00, 0x00, 0x10}, | |
588 | {0xdd, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, | |
589 | {0xb0, 0x51, 0x04, 0x01, 0x00, 0x00, 0x00, 0x10}, | |
590 | {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10}, | |
591 | {0xb0, 0x51, 0x14, 0x01, 0x00, 0x00, 0x00, 0x10}, | |
592 | {0xb0, 0x51, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
593 | {} | |
594 | }; | |
595 | static const u8 adcm1700_sensor_param1[][8] = { | |
878b35ae | 596 | {0xb0, 0x51, 0x26, 0xf9, 0x01, 0x00, 0x00, 0x10}, /* exposure? */ |
64677573 JFM |
597 | {0xd0, 0x51, 0x1e, 0x8e, 0x8e, 0x8e, 0x8e, 0x10}, |
598 | ||
599 | {0xa0, 0x51, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x10}, | |
600 | {0xb0, 0x51, 0x00, 0x02, 0x00, 0x00, 0x00, 0x10}, | |
601 | {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10}, | |
602 | {0xb0, 0x51, 0x32, 0x00, 0x72, 0x00, 0x00, 0x10}, | |
878b35ae | 603 | {0xd0, 0x51, 0x1e, 0xbe, 0xd7, 0xe8, 0xbe, 0x10}, /* exposure? */ |
64677573 | 604 | |
878b35ae JFM |
605 | {0xa0, 0x51, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x10}, |
606 | {0xb0, 0x51, 0x00, 0x02, 0x00, 0x00, 0x00, 0x10}, | |
607 | {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10}, | |
608 | {0xb0, 0x51, 0x32, 0x00, 0xa2, 0x00, 0x00, 0x10}, | |
64677573 JFM |
609 | {} |
610 | }; | |
ad98c0f6 JFM |
611 | static const u8 gc0307_sensor_init[][8] = { |
612 | {0xa0, 0x21, 0x43, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
613 | {0xa0, 0x21, 0x44, 0xa2, 0x00, 0x00, 0x00, 0x10}, | |
614 | {0xa0, 0x21, 0x01, 0x6a, 0x00, 0x00, 0x00, 0x10}, | |
615 | {0xa0, 0x21, 0x02, 0x70, 0x00, 0x00, 0x00, 0x10}, | |
616 | {0xa0, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
617 | {0xa0, 0x21, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
618 | {0xa0, 0x21, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
619 | {0xa0, 0x21, 0x11, 0x05, 0x00, 0x00, 0x00, 0x10}, | |
620 | {0xa0, 0x21, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
621 | {0xa0, 0x21, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
622 | {0xa0, 0x21, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
623 | {0xa0, 0x21, 0x08, 0x02, 0x00, 0x00, 0x00, 0x10}, | |
624 | {0xa0, 0x21, 0x09, 0x01, 0x00, 0x00, 0x00, 0x10}, | |
625 | {0xa0, 0x21, 0x0a, 0xe8, 0x00, 0x00, 0x00, 0x10}, | |
626 | {0xa0, 0x21, 0x0b, 0x02, 0x00, 0x00, 0x00, 0x10}, | |
627 | {0xa0, 0x21, 0x0c, 0x80, 0x00, 0x00, 0x00, 0x10}, | |
628 | {0xa0, 0x21, 0x0d, 0x22, 0x00, 0x00, 0x00, 0x10}, | |
629 | {0xa0, 0x21, 0x0e, 0x02, 0x00, 0x00, 0x00, 0x10}, | |
630 | {0xa0, 0x21, 0x0f, 0xb2, 0x00, 0x00, 0x00, 0x10}, | |
631 | {0xa0, 0x21, 0x12, 0x70, 0x00, 0x00, 0x00, 0x10}, | |
632 | {0xdd, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 10ms*/ | |
633 | {0xa0, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
634 | {0xa0, 0x21, 0x15, 0xb8, 0x00, 0x00, 0x00, 0x10}, | |
635 | {0xa0, 0x21, 0x16, 0x13, 0x00, 0x00, 0x00, 0x10}, | |
636 | {0xa0, 0x21, 0x17, 0x52, 0x00, 0x00, 0x00, 0x10}, | |
637 | {0xa0, 0x21, 0x18, 0x50, 0x00, 0x00, 0x00, 0x10}, | |
638 | {0xa0, 0x21, 0x1e, 0x0d, 0x00, 0x00, 0x00, 0x10}, | |
639 | {0xa0, 0x21, 0x1f, 0x32, 0x00, 0x00, 0x00, 0x10}, | |
640 | {0xa0, 0x21, 0x61, 0x90, 0x00, 0x00, 0x00, 0x10}, | |
641 | {0xa0, 0x21, 0x63, 0x70, 0x00, 0x00, 0x00, 0x10}, | |
642 | {0xa0, 0x21, 0x65, 0x98, 0x00, 0x00, 0x00, 0x10}, | |
643 | {0xa0, 0x21, 0x67, 0x90, 0x00, 0x00, 0x00, 0x10}, | |
644 | {0xa0, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
645 | {0xa0, 0x21, 0x04, 0x96, 0x00, 0x00, 0x00, 0x10}, | |
646 | {0xa0, 0x21, 0x45, 0x27, 0x00, 0x00, 0x00, 0x10}, | |
647 | {0xa0, 0x21, 0x47, 0x2c, 0x00, 0x00, 0x00, 0x10}, | |
648 | {0xa0, 0x21, 0x43, 0x47, 0x00, 0x00, 0x00, 0x10}, | |
649 | {0xa0, 0x21, 0x44, 0xd8, 0x00, 0x00, 0x00, 0x10}, | |
650 | {} | |
651 | }; | |
652 | static const u8 gc0307_sensor_param1[][8] = { | |
653 | {0xa0, 0x21, 0x68, 0x13, 0x00, 0x00, 0x00, 0x10}, | |
654 | {0xd0, 0x21, 0x61, 0x80, 0x00, 0x80, 0x00, 0x10}, | |
655 | {0xc0, 0x21, 0x65, 0x80, 0x00, 0x80, 0x00, 0x10}, | |
656 | {0xc0, 0x21, 0x63, 0xa0, 0x00, 0xa6, 0x00, 0x10}, | |
657 | /*param3*/ | |
658 | {0xa0, 0x21, 0x01, 0x6e, 0x00, 0x00, 0x00, 0x10}, | |
659 | {0xa0, 0x21, 0x02, 0x88, 0x00, 0x00, 0x00, 0x10}, | |
ad98c0f6 JFM |
660 | {} |
661 | }; | |
662 | ||
98819187 | 663 | static const u8 hv7131r_sensor_init[][8] = { |
8c2ba441 JFM |
664 | {0xc1, 0x11, 0x01, 0x08, 0x01, 0x00, 0x00, 0x10}, |
665 | {0xb1, 0x11, 0x34, 0x17, 0x7f, 0x00, 0x00, 0x10}, | |
666 | {0xd1, 0x11, 0x40, 0xff, 0x7f, 0x7f, 0x7f, 0x10}, | |
667 | /* {0x91, 0x11, 0x44, 0x00, 0x00, 0x00, 0x00, 0x10}, */ | |
668 | {0xd1, 0x11, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
669 | {0xd1, 0x11, 0x14, 0x01, 0xe2, 0x02, 0x82, 0x10}, | |
670 | /* {0x91, 0x11, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10}, */ | |
671 | ||
672 | {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10}, | |
673 | {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10}, | |
674 | {0xc1, 0x11, 0x25, 0x00, 0x61, 0xa8, 0x00, 0x10}, | |
675 | {0xa1, 0x11, 0x30, 0x22, 0x00, 0x00, 0x00, 0x10}, | |
676 | {0xc1, 0x11, 0x31, 0x20, 0x2e, 0x20, 0x00, 0x10}, | |
677 | {0xc1, 0x11, 0x25, 0x00, 0xc3, 0x50, 0x00, 0x10}, | |
678 | {0xa1, 0x11, 0x30, 0x07, 0x00, 0x00, 0x00, 0x10}, /* gain14 */ | |
679 | {0xc1, 0x11, 0x31, 0x10, 0x10, 0x10, 0x00, 0x10}, /* r g b 101a10 */ | |
680 | ||
681 | {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10}, | |
682 | {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
7fb101ae | 683 | {0xa1, 0x11, 0x21, 0xd0, 0x00, 0x00, 0x00, 0x10}, |
8c2ba441 JFM |
684 | {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10}, |
685 | {0xa1, 0x11, 0x23, 0x09, 0x00, 0x00, 0x00, 0x10}, | |
686 | ||
687 | {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10}, | |
688 | {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
689 | {0xa1, 0x11, 0x21, 0xd0, 0x00, 0x00, 0x00, 0x10}, | |
690 | {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
691 | {0xa1, 0x11, 0x23, 0x10, 0x00, 0x00, 0x00, 0x10}, | |
23a98274 JFM |
692 | {0xa1, 0x11, 0x01, 0x18, 0x00, 0x00, 0x00, 0x10}, |
693 | /* set sensor clock */ | |
a5ae2062 | 694 | {} |
6a7eba24 | 695 | }; |
98819187 | 696 | static const u8 mi0360_sensor_init[][8] = { |
8c2ba441 | 697 | {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, |
98819187 | 698 | {0xb1, 0x5d, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10}, |
3ef2c5be | 699 | {0xb1, 0x5d, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10}, |
8c2ba441 JFM |
700 | {0xd1, 0x5d, 0x01, 0x00, 0x08, 0x00, 0x16, 0x10}, |
701 | {0xd1, 0x5d, 0x03, 0x01, 0xe2, 0x02, 0x82, 0x10}, | |
702 | {0xd1, 0x5d, 0x05, 0x00, 0x09, 0x00, 0x53, 0x10}, | |
703 | {0xb1, 0x5d, 0x0d, 0x00, 0x02, 0x00, 0x00, 0x10}, | |
704 | {0xd1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
705 | {0xd1, 0x5d, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
706 | {0xd1, 0x5d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
707 | {0xd1, 0x5d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
708 | {0xd1, 0x5d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
709 | {0xd1, 0x5d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
710 | {0xd1, 0x5d, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
711 | {0xd1, 0x5d, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
712 | {0xd1, 0x5d, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
713 | {0xd1, 0x5d, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
714 | {0xb1, 0x5d, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
715 | {0xd1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10}, | |
716 | {0xd1, 0x5d, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
717 | {0xd1, 0x5d, 0x24, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
718 | {0xd1, 0x5d, 0x26, 0x00, 0x00, 0x00, 0x24, 0x10}, | |
98819187 | 719 | {0xd1, 0x5d, 0x2f, 0xf7, 0xB0, 0x00, 0x04, 0x10}, |
8c2ba441 JFM |
720 | {0xd1, 0x5d, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10}, |
721 | {0xd1, 0x5d, 0x33, 0x00, 0x00, 0x01, 0x00, 0x10}, | |
722 | {0xb1, 0x5d, 0x3d, 0x06, 0x8f, 0x00, 0x00, 0x10}, | |
723 | {0xd1, 0x5d, 0x40, 0x01, 0xe0, 0x00, 0xd1, 0x10}, | |
724 | {0xb1, 0x5d, 0x44, 0x00, 0x82, 0x00, 0x00, 0x10}, | |
725 | {0xd1, 0x5d, 0x58, 0x00, 0x78, 0x00, 0x43, 0x10}, | |
726 | {0xd1, 0x5d, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
727 | {0xd1, 0x5d, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
728 | {0xd1, 0x5d, 0x5e, 0x00, 0x00, 0xa3, 0x1d, 0x10}, | |
729 | {0xb1, 0x5d, 0x62, 0x04, 0x11, 0x00, 0x00, 0x10}, | |
730 | ||
731 | {0xb1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10}, | |
732 | {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10}, | |
733 | {0xb1, 0x5d, 0x09, 0x00, 0x64, 0x00, 0x00, 0x10}, | |
734 | {0xd1, 0x5d, 0x2b, 0x00, 0xa0, 0x00, 0xb0, 0x10}, | |
735 | {0xd1, 0x5d, 0x2d, 0x00, 0xa0, 0x00, 0xa0, 0x10}, | |
736 | ||
737 | {0xb1, 0x5d, 0x0a, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor clck ?2 */ | |
738 | {0xb1, 0x5d, 0x06, 0x00, 0x30, 0x00, 0x00, 0x10}, | |
739 | {0xb1, 0x5d, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10}, | |
740 | {0xb1, 0x5d, 0x09, 0x02, 0x35, 0x00, 0x00, 0x10}, /* exposure 2 */ | |
741 | ||
742 | {0xd1, 0x5d, 0x2b, 0x00, 0xb9, 0x00, 0xe3, 0x10}, | |
743 | {0xd1, 0x5d, 0x2d, 0x00, 0x5f, 0x00, 0xb9, 0x10}, /* 42 */ | |
744 | /* {0xb1, 0x5d, 0x35, 0x00, 0x67, 0x00, 0x00, 0x10}, * gain orig */ | |
745 | /* {0xb1, 0x5d, 0x35, 0x00, 0x20, 0x00, 0x00, 0x10}, * gain */ | |
746 | {0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10}, /* update */ | |
747 | {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */ | |
a5ae2062 | 748 | {} |
6a7eba24 | 749 | }; |
98819187 | 750 | static const u8 mo4000_sensor_init[][8] = { |
6a7eba24 JFM |
751 | {0xa1, 0x21, 0x01, 0x02, 0x00, 0x00, 0x00, 0x10}, |
752 | {0xa1, 0x21, 0x02, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
753 | {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
754 | {0xa1, 0x21, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
755 | {0xa1, 0x21, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
756 | {0xa1, 0x21, 0x05, 0x04, 0x00, 0x00, 0x00, 0x10}, | |
757 | {0xa1, 0x21, 0x06, 0x80, 0x00, 0x00, 0x00, 0x10}, | |
758 | {0xa1, 0x21, 0x06, 0x81, 0x00, 0x00, 0x00, 0x10}, | |
759 | {0xa1, 0x21, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
760 | {0xa1, 0x21, 0x11, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
761 | {0xa1, 0x21, 0x11, 0x20, 0x00, 0x00, 0x00, 0x10}, | |
762 | {0xa1, 0x21, 0x11, 0x30, 0x00, 0x00, 0x00, 0x10}, | |
763 | {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10}, | |
764 | {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10}, | |
765 | {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
766 | {0xa1, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
767 | {0xa1, 0x21, 0x0f, 0x20, 0x00, 0x00, 0x00, 0x10}, | |
768 | {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10}, | |
769 | {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
770 | {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10}, | |
a5ae2062 | 771 | {} |
6a7eba24 | 772 | }; |
3ef2c5be JFM |
773 | static const u8 mt9v111_sensor_init[][8] = { |
774 | {0xb1, 0x5c, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10}, /* reset? */ | |
23a98274 | 775 | {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */ |
3ef2c5be JFM |
776 | {0xb1, 0x5c, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10}, |
777 | {0xb1, 0x5c, 0x01, 0x00, 0x01, 0x00, 0x00, 0x10}, /* IFP select */ | |
778 | {0xb1, 0x5c, 0x08, 0x04, 0x80, 0x00, 0x00, 0x10}, /* output fmt ctrl */ | |
779 | {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10}, /* op mode ctrl */ | |
2687a2fb JFM |
780 | {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10}, |
781 | {0xb1, 0x5c, 0x03, 0x01, 0xe1, 0x00, 0x00, 0x10}, | |
782 | {0xb1, 0x5c, 0x04, 0x02, 0x81, 0x00, 0x00, 0x10}, | |
783 | {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10}, | |
3ef2c5be | 784 | {0xb1, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10}, /* sensor select */ |
2687a2fb JFM |
785 | {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10}, |
786 | {0xb1, 0x5c, 0x03, 0x01, 0xe6, 0x00, 0x00, 0x10}, | |
787 | {0xb1, 0x5c, 0x04, 0x02, 0x86, 0x00, 0x00, 0x10}, | |
788 | {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10}, | |
789 | {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
3ef2c5be | 790 | {0xb1, 0x5c, 0x08, 0x00, 0x08, 0x00, 0x00, 0x10}, /* row start */ |
2687a2fb | 791 | {0xb1, 0x5c, 0x0e, 0x00, 0x08, 0x00, 0x00, 0x10}, |
3ef2c5be JFM |
792 | {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10}, /* col start */ |
793 | {0xb1, 0x5c, 0x03, 0x01, 0xe7, 0x00, 0x00, 0x10}, /* window height */ | |
794 | {0xb1, 0x5c, 0x04, 0x02, 0x87, 0x00, 0x00, 0x10}, /* window width */ | |
795 | {0xb1, 0x5c, 0x07, 0x30, 0x02, 0x00, 0x00, 0x10}, /* output ctrl */ | |
796 | {0xb1, 0x5c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10}, /* shutter delay */ | |
797 | {0xb1, 0x5c, 0x12, 0x00, 0xb0, 0x00, 0x00, 0x10}, /* zoom col start */ | |
798 | {0xb1, 0x5c, 0x13, 0x00, 0x7c, 0x00, 0x00, 0x10}, /* zoom row start */ | |
799 | {0xb1, 0x5c, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* digital zoom */ | |
800 | {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10}, /* read mode */ | |
801 | {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
3fccb774 JFM |
802 | {} |
803 | }; | |
804 | static const u8 mt9v111_sensor_param1[][8] = { | |
3ef2c5be JFM |
805 | {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10}, |
806 | {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
2687a2fb | 807 | {0xb1, 0x5c, 0x09, 0x01, 0x2c, 0x00, 0x00, 0x10}, |
3ef2c5be JFM |
808 | {0xd1, 0x5c, 0x2b, 0x00, 0x33, 0x00, 0xa0, 0x10}, /* green1 gain */ |
809 | {0xd1, 0x5c, 0x2d, 0x00, 0xa0, 0x00, 0x33, 0x10}, /* red gain */ | |
810 | /*******/ | |
811 | {0xb1, 0x5c, 0x06, 0x00, 0x1e, 0x00, 0x00, 0x10}, /* vert blanking */ | |
812 | {0xb1, 0x5c, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10}, /* horiz blanking */ | |
813 | {0xd1, 0x5c, 0x2c, 0x00, 0xad, 0x00, 0xad, 0x10}, /* blue gain */ | |
814 | {0xb1, 0x5c, 0x35, 0x01, 0xc0, 0x00, 0x00, 0x10}, /* global gain */ | |
815 | {} | |
816 | }; | |
3fccb774 JFM |
817 | static const u8 om6802_init0[2][8] = { |
818 | /*fixme: variable*/ | |
819 | {0xa0, 0x34, 0x29, 0x0e, 0x00, 0x00, 0x00, 0x10}, | |
820 | {0xa0, 0x34, 0x23, 0xb0, 0x00, 0x00, 0x00, 0x10}, | |
821 | }; | |
98819187 | 822 | static const u8 om6802_sensor_init[][8] = { |
3fccb774 JFM |
823 | {0xa0, 0x34, 0xdf, 0x6d, 0x00, 0x00, 0x00, 0x10}, |
824 | /* factory mode */ | |
d2d16e90 | 825 | {0xa0, 0x34, 0xdd, 0x18, 0x00, 0x00, 0x00, 0x10}, |
d5aa3856 | 826 | /* output raw RGB */ |
3fccb774 | 827 | {0xa0, 0x34, 0x5a, 0xc0, 0x00, 0x00, 0x00, 0x10}, |
d2d16e90 JFM |
828 | /* {0xa0, 0x34, 0xfb, 0x11, 0x00, 0x00, 0x00, 0x10}, */ |
829 | {0xa0, 0x34, 0xf0, 0x04, 0x00, 0x00, 0x00, 0x10}, | |
d5aa3856 | 830 | /* auto-exposure speed (0) / white balance mode (auto RGB) */ |
d2d16e90 JFM |
831 | /* {0xa0, 0x34, 0xf1, 0x02, 0x00, 0x00, 0x00, 0x10}, |
832 | * set color mode */ | |
833 | /* {0xa0, 0x34, 0xfe, 0x5b, 0x00, 0x00, 0x00, 0x10}, | |
834 | * max AGC value in AE */ | |
835 | /* {0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
836 | * preset AGC */ | |
837 | /* {0xa0, 0x34, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
838 | * preset brightness */ | |
839 | /* {0xa0, 0x34, 0xe7, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
840 | * preset contrast */ | |
841 | /* {0xa0, 0x34, 0xe8, 0x31, 0x00, 0x00, 0x00, 0x10}, | |
842 | * preset gamma */ | |
843 | {0xa0, 0x34, 0xe9, 0x0f, 0x00, 0x00, 0x00, 0x10}, | |
d5aa3856 | 844 | /* luminance mode (0x4f -> AutoExpo on) */ |
d2d16e90 JFM |
845 | {0xa0, 0x34, 0xe4, 0xff, 0x00, 0x00, 0x00, 0x10}, |
846 | /* preset shutter */ | |
847 | /* {0xa0, 0x34, 0xef, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
848 | * auto frame rate */ | |
849 | /* {0xa0, 0x34, 0xfb, 0xee, 0x00, 0x00, 0x00, 0x10}, */ | |
3fccb774 JFM |
850 | {0xa0, 0x34, 0x5d, 0x80, 0x00, 0x00, 0x00, 0x10}, |
851 | {} | |
852 | }; | |
853 | static const u8 om6802_sensor_param1[][8] = { | |
854 | {0xa0, 0x34, 0x71, 0x84, 0x00, 0x00, 0x00, 0x10}, | |
855 | {0xa0, 0x34, 0x72, 0x05, 0x00, 0x00, 0x00, 0x10}, | |
856 | {0xa0, 0x34, 0x68, 0x80, 0x00, 0x00, 0x00, 0x10}, | |
857 | {0xa0, 0x34, 0x69, 0x01, 0x00, 0x00, 0x00, 0x10}, | |
d2d16e90 JFM |
858 | {} |
859 | }; | |
98819187 | 860 | static const u8 ov7630_sensor_init[][8] = { |
6ab0b174 JFM |
861 | {0xa1, 0x21, 0x76, 0x01, 0x00, 0x00, 0x00, 0x10}, |
862 | {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10}, | |
23a98274 | 863 | {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */ |
6ab0b174 JFM |
864 | {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10}, |
865 | {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10}, | |
23a98274 | 866 | {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */ |
6ab0b174 | 867 | {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10}, |
05b809c7 | 868 | /* win: i2c_r from 00 to 80 */ |
6ab0b174 JFM |
869 | {0xd1, 0x21, 0x03, 0x80, 0x10, 0x20, 0x80, 0x10}, |
870 | {0xb1, 0x21, 0x0c, 0x20, 0x20, 0x00, 0x00, 0x10}, | |
cc7b5b57 HG |
871 | /* HDG: 0x11 was 0x00 change to 0x01 for better exposure (15 fps instead of 30) |
872 | 0x13 was 0xc0 change to 0xc3 for auto gain and exposure */ | |
873 | {0xd1, 0x21, 0x11, 0x01, 0x48, 0xc3, 0x00, 0x10}, | |
6ab0b174 JFM |
874 | {0xb1, 0x21, 0x15, 0x80, 0x03, 0x00, 0x00, 0x10}, |
875 | {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10}, | |
876 | {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10}, | |
877 | {0xd1, 0x21, 0x1f, 0x00, 0x80, 0x80, 0x80, 0x10}, | |
878 | {0xd1, 0x21, 0x23, 0xde, 0x10, 0x8a, 0xa0, 0x10}, | |
879 | {0xc1, 0x21, 0x27, 0xca, 0xa2, 0x74, 0x00, 0x10}, | |
880 | {0xd1, 0x21, 0x2a, 0x88, 0x00, 0x88, 0x01, 0x10}, | |
881 | {0xc1, 0x21, 0x2e, 0x80, 0x00, 0x18, 0x00, 0x10}, | |
882 | {0xa1, 0x21, 0x21, 0x08, 0x00, 0x00, 0x00, 0x10}, | |
883 | {0xa1, 0x21, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
884 | {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
885 | {0xb1, 0x21, 0x32, 0xc2, 0x08, 0x00, 0x00, 0x10}, | |
886 | {0xb1, 0x21, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
887 | {0xd1, 0x21, 0x60, 0x05, 0x40, 0x12, 0x57, 0x10}, | |
888 | {0xa1, 0x21, 0x64, 0x73, 0x00, 0x00, 0x00, 0x10}, | |
889 | {0xd1, 0x21, 0x65, 0x00, 0x55, 0x01, 0xac, 0x10}, | |
890 | {0xa1, 0x21, 0x69, 0x38, 0x00, 0x00, 0x00, 0x10}, | |
891 | {0xd1, 0x21, 0x6f, 0x1f, 0x01, 0x00, 0x10, 0x10}, | |
892 | {0xd1, 0x21, 0x73, 0x50, 0x20, 0x02, 0x01, 0x10}, | |
893 | {0xd1, 0x21, 0x77, 0xf3, 0x90, 0x98, 0x98, 0x10}, | |
894 | {0xc1, 0x21, 0x7b, 0x00, 0x4c, 0xf7, 0x00, 0x10}, | |
895 | {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10}, | |
896 | {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10}, | |
bdd2b93c JFM |
897 | {} |
898 | }; | |
899 | static const u8 ov7630_sensor_param1[][8] = { | |
6ab0b174 JFM |
900 | {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10}, |
901 | {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10}, | |
902 | /*fixme: + 0x12, 0x04*/ | |
6c86274f JFM |
903 | /* {0xa1, 0x21, 0x75, 0x82, 0x00, 0x00, 0x00, 0x10}, * COMN |
904 | * set by setvflip */ | |
6ab0b174 JFM |
905 | {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10}, |
906 | {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
907 | {0xb1, 0x21, 0x01, 0x80, 0x80, 0x00, 0x00, 0x10}, | |
05b809c7 | 908 | /* */ |
37c6dbe2 HG |
909 | /* {0xa1, 0x21, 0x2a, 0x88, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */ |
910 | /* {0xa1, 0x21, 0x2b, 0x34, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */ | |
05b809c7 | 911 | /* */ |
6ab0b174 | 912 | {0xa1, 0x21, 0x10, 0x83, 0x00, 0x00, 0x00, 0x10}, |
91de65ac | 913 | /* {0xb1, 0x21, 0x01, 0x88, 0x70, 0x00, 0x00, 0x10}, */ |
6ab0b174 JFM |
914 | {} |
915 | }; | |
6270330a | 916 | |
98819187 | 917 | static const u8 ov7648_sensor_init[][8] = { |
6270330a JFM |
918 | {0xa1, 0x21, 0x76, 0x00, 0x00, 0x00, 0x00, 0x10}, |
919 | {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */ | |
23a98274 | 920 | {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */ |
6270330a JFM |
921 | {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10}, |
922 | {0xd1, 0x21, 0x03, 0xa4, 0x30, 0x88, 0x00, 0x10}, | |
923 | {0xb1, 0x21, 0x11, 0x80, 0x08, 0x00, 0x00, 0x10}, | |
924 | {0xc1, 0x21, 0x13, 0xa0, 0x04, 0x84, 0x00, 0x10}, | |
925 | {0xd1, 0x21, 0x17, 0x1a, 0x02, 0xba, 0xf4, 0x10}, | |
926 | {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10}, | |
927 | {0xd1, 0x21, 0x1f, 0x41, 0xc0, 0x80, 0x80, 0x10}, | |
928 | {0xd1, 0x21, 0x23, 0xde, 0xa0, 0x80, 0x32, 0x10}, | |
929 | {0xd1, 0x21, 0x27, 0xfe, 0xa0, 0x00, 0x91, 0x10}, | |
930 | {0xd1, 0x21, 0x2b, 0x00, 0x88, 0x85, 0x80, 0x10}, | |
931 | {0xc1, 0x21, 0x2f, 0x9c, 0x00, 0xc4, 0x00, 0x10}, | |
932 | {0xd1, 0x21, 0x60, 0xa6, 0x60, 0x88, 0x12, 0x10}, | |
933 | {0xd1, 0x21, 0x64, 0x88, 0x00, 0x00, 0x94, 0x10}, | |
934 | {0xd1, 0x21, 0x68, 0x7a, 0x0c, 0x00, 0x00, 0x10}, | |
935 | {0xd1, 0x21, 0x6c, 0x11, 0x33, 0x22, 0x00, 0x10}, | |
936 | {0xd1, 0x21, 0x70, 0x11, 0x00, 0x10, 0x50, 0x10}, | |
937 | {0xd1, 0x21, 0x74, 0x20, 0x06, 0x00, 0xb5, 0x10}, | |
938 | {0xd1, 0x21, 0x78, 0x8a, 0x00, 0x00, 0x00, 0x10}, | |
939 | {0xb1, 0x21, 0x7c, 0x00, 0x43, 0x00, 0x00, 0x10}, | |
940 | ||
941 | {0xd1, 0x21, 0x21, 0x86, 0x00, 0xde, 0xa0, 0x10}, | |
942 | /* {0xd1, 0x21, 0x25, 0x80, 0x32, 0xfe, 0xa0, 0x10}, jfm done */ | |
943 | /* {0xd1, 0x21, 0x29, 0x00, 0x91, 0x00, 0x88, 0x10}, jfm done */ | |
37c6dbe2 | 944 | /* {0xb1, 0x21, 0x2d, 0x85, 0x00, 0x00, 0x00, 0x10}, set by setfreq */ |
3fccb774 JFM |
945 | {} |
946 | }; | |
947 | static const u8 ov7648_sensor_param1[][8] = { | |
6270330a | 948 | /* {0xa1, 0x21, 0x12, 0x08, 0x00, 0x00, 0x00, 0x10}, jfm done */ |
2797ba2a JFM |
949 | /* {0xa1, 0x21, 0x75, 0x06, 0x00, 0x00, 0x00, 0x10}, * COMN |
950 | * set by setvflip */ | |
6270330a JFM |
951 | {0xa1, 0x21, 0x19, 0x02, 0x00, 0x00, 0x00, 0x10}, |
952 | {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10}, | |
953 | /* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */ | |
954 | /* {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, * GAIN - def */ | |
955 | /* {0xb1, 0x21, 0x01, 0x6c, 0x6c, 0x00, 0x00, 0x10}, * B R - def: 80 */ | |
956 | /*...*/ | |
957 | {0xa1, 0x21, 0x11, 0x81, 0x00, 0x00, 0x00, 0x10}, /* CLKRC */ | |
958 | /* {0xa1, 0x21, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */ | |
959 | /* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */ | |
960 | /* {0xa1, 0x21, 0x2a, 0x91, 0x00, 0x00, 0x00, 0x10}, jfm done */ | |
961 | /* {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */ | |
962 | /* {0xb1, 0x21, 0x01, 0x64, 0x84, 0x00, 0x00, 0x10}, * B R - def: 80 */ | |
963 | ||
964 | {} | |
965 | }; | |
966 | ||
98819187 | 967 | static const u8 ov7660_sensor_init[][8] = { |
6a7eba24 | 968 | {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset SCCB */ |
23a98274 | 969 | {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */ |
6a7eba24 | 970 | {0xa1, 0x21, 0x12, 0x05, 0x00, 0x00, 0x00, 0x10}, |
738608ae | 971 | /* Outformat = rawRGB */ |
6a7eba24 | 972 | {0xa1, 0x21, 0x13, 0xb8, 0x00, 0x00, 0x00, 0x10}, /* init COM8 */ |
d8f400ef | 973 | {0xd1, 0x21, 0x00, 0x01, 0x74, 0x92, 0x00, 0x10}, |
6a7eba24 JFM |
974 | /* GAIN BLUE RED VREF */ |
975 | {0xd1, 0x21, 0x04, 0x00, 0x7d, 0x62, 0x00, 0x10}, | |
976 | /* COM 1 BAVE GEAVE AECHH */ | |
977 | {0xb1, 0x21, 0x08, 0x83, 0x01, 0x00, 0x00, 0x10}, /* RAVE COM2 */ | |
978 | {0xd1, 0x21, 0x0c, 0x00, 0x08, 0x04, 0x4f, 0x10}, /* COM 3 4 5 6 */ | |
47f7f6fb | 979 | {0xd1, 0x21, 0x10, 0x7f, 0x40, 0x05, 0xff, 0x10}, |
6a7eba24 JFM |
980 | /* AECH CLKRC COM7 COM8 */ |
981 | {0xc1, 0x21, 0x14, 0x2c, 0x00, 0x02, 0x00, 0x10}, /* COM9 COM10 */ | |
982 | {0xd1, 0x21, 0x17, 0x10, 0x60, 0x02, 0x7b, 0x10}, | |
983 | /* HSTART HSTOP VSTRT VSTOP */ | |
984 | {0xa1, 0x21, 0x1b, 0x02, 0x00, 0x00, 0x00, 0x10}, /* PSHFT */ | |
985 | {0xb1, 0x21, 0x1e, 0x01, 0x0e, 0x00, 0x00, 0x10}, /* MVFP LAEC */ | |
986 | {0xd1, 0x21, 0x20, 0x07, 0x07, 0x07, 0x07, 0x10}, | |
987 | /* BOS GBOS GROS ROS (BGGR offset) */ | |
738608ae JFM |
988 | /* {0xd1, 0x21, 0x24, 0x68, 0x58, 0xd4, 0x80, 0x10}, */ |
989 | {0xd1, 0x21, 0x24, 0x78, 0x68, 0xd4, 0x80, 0x10}, | |
6a7eba24 JFM |
990 | /* AEW AEB VPT BBIAS */ |
991 | {0xd1, 0x21, 0x28, 0x80, 0x30, 0x00, 0x00, 0x10}, | |
992 | /* GbBIAS RSVD EXHCH EXHCL */ | |
993 | {0xd1, 0x21, 0x2c, 0x80, 0x00, 0x00, 0x62, 0x10}, | |
994 | /* RBIAS ADVFL ASDVFH YAVE */ | |
995 | {0xc1, 0x21, 0x30, 0x08, 0x30, 0xb4, 0x00, 0x10}, | |
996 | /* HSYST HSYEN HREF */ | |
997 | {0xd1, 0x21, 0x33, 0x00, 0x07, 0x84, 0x00, 0x10}, /* reserved */ | |
998 | {0xd1, 0x21, 0x37, 0x0c, 0x02, 0x43, 0x00, 0x10}, | |
999 | /* ADC ACOM OFON TSLB */ | |
1000 | {0xd1, 0x21, 0x3b, 0x02, 0x6c, 0x19, 0x0e, 0x10}, | |
1001 | /* COM11 COM12 COM13 COM14 */ | |
1002 | {0xd1, 0x21, 0x3f, 0x41, 0xc1, 0x22, 0x08, 0x10}, | |
1003 | /* EDGE COM15 COM16 COM17 */ | |
1004 | {0xd1, 0x21, 0x43, 0xf0, 0x10, 0x78, 0xa8, 0x10}, /* reserved */ | |
1005 | {0xd1, 0x21, 0x47, 0x60, 0x80, 0x00, 0x00, 0x10}, /* reserved */ | |
1006 | {0xd1, 0x21, 0x4b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* reserved */ | |
1007 | {0xd1, 0x21, 0x4f, 0x46, 0x36, 0x0f, 0x17, 0x10}, /* MTX 1 2 3 4 */ | |
1008 | {0xd1, 0x21, 0x53, 0x7f, 0x96, 0x40, 0x40, 0x10}, /* MTX 5 6 7 8 */ | |
1009 | {0xb1, 0x21, 0x57, 0x40, 0x0f, 0x00, 0x00, 0x10}, /* MTX9 MTXS */ | |
1010 | {0xd1, 0x21, 0x59, 0xba, 0x9a, 0x22, 0xb9, 0x10}, /* reserved */ | |
1011 | {0xd1, 0x21, 0x5d, 0x9b, 0x10, 0xf0, 0x05, 0x10}, /* reserved */ | |
1012 | {0xa1, 0x21, 0x61, 0x60, 0x00, 0x00, 0x00, 0x10}, /* reserved */ | |
1013 | {0xd1, 0x21, 0x62, 0x00, 0x00, 0x50, 0x30, 0x10}, | |
1014 | /* LCC1 LCC2 LCC3 LCC4 */ | |
1015 | {0xa1, 0x21, 0x66, 0x00, 0x00, 0x00, 0x00, 0x10}, /* LCC5 */ | |
738608ae | 1016 | {0xd1, 0x21, 0x67, 0x80, 0x7a, 0x90, 0x80, 0x10}, /* MANU */ |
6a7eba24 | 1017 | {0xa1, 0x21, 0x6b, 0x0a, 0x00, 0x00, 0x00, 0x10}, |
738608ae | 1018 | /* band gap reference [0:3] DBLV */ |
6a7eba24 JFM |
1019 | {0xd1, 0x21, 0x6c, 0x30, 0x48, 0x80, 0x74, 0x10}, /* gamma curve */ |
1020 | {0xd1, 0x21, 0x70, 0x64, 0x60, 0x5c, 0x58, 0x10}, /* gamma curve */ | |
1021 | {0xd1, 0x21, 0x74, 0x54, 0x4c, 0x40, 0x38, 0x10}, /* gamma curve */ | |
1022 | {0xd1, 0x21, 0x78, 0x34, 0x30, 0x2f, 0x2b, 0x10}, /* gamma curve */ | |
1023 | {0xd1, 0x21, 0x7c, 0x03, 0x07, 0x17, 0x34, 0x10}, /* gamma curve */ | |
1024 | {0xd1, 0x21, 0x80, 0x41, 0x4d, 0x58, 0x63, 0x10}, /* gamma curve */ | |
1025 | {0xd1, 0x21, 0x84, 0x6e, 0x77, 0x87, 0x95, 0x10}, /* gamma curve */ | |
1026 | {0xc1, 0x21, 0x88, 0xaf, 0xc7, 0xdf, 0x00, 0x10}, /* gamma curve */ | |
1027 | {0xc1, 0x21, 0x8b, 0x99, 0x99, 0xcf, 0x00, 0x10}, /* reserved */ | |
738608ae | 1028 | {0xb1, 0x21, 0x92, 0x00, 0x00, 0x00, 0x00, 0x10}, /* DM_LNL/H */ |
3fccb774 | 1029 | /* not in all ms-win traces*/ |
47f7f6fb | 1030 | {0xa1, 0x21, 0xa1, 0x00, 0x00, 0x00, 0x00, 0x10}, |
3fccb774 JFM |
1031 | {} |
1032 | }; | |
1033 | static const u8 ov7660_sensor_param1[][8] = { | |
738608ae | 1034 | {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10}, /* MVFP */ |
6a7eba24 JFM |
1035 | /* bits[3..0]reserved */ |
1036 | {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10}, | |
1037 | {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
1038 | /* VREF vertical frame ctrl */ | |
1039 | {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
738608ae JFM |
1040 | {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10}, /* AECH 0x20 */ |
1041 | {0xa1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFL */ | |
1042 | {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFH */ | |
1043 | {0xa1, 0x21, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x10}, /* GAIN */ | |
1044 | /* {0xb1, 0x21, 0x01, 0x78, 0x78, 0x00, 0x00, 0x10}, * BLUE */ | |
6a7eba24 | 1045 | /****** (some exchanges in the win trace) ******/ |
3fccb774 | 1046 | /*fixme:param2*/ |
6a7eba24 | 1047 | {0xa1, 0x21, 0x93, 0x00, 0x00, 0x00, 0x00, 0x10},/* dummy line hight */ |
738608ae JFM |
1048 | {0xa1, 0x21, 0x92, 0x25, 0x00, 0x00, 0x00, 0x10}, /* dummy line low */ |
1049 | {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCH */ | |
1050 | {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCL */ | |
1051 | /* {0xa1, 0x21, 0x02, 0x90, 0x00, 0x00, 0x00, 0x10}, * RED */ | |
6a7eba24 | 1052 | /****** (some exchanges in the win trace) ******/ |
738608ae | 1053 | /******!! startsensor KO if changed !!****/ |
3fccb774 | 1054 | /*fixme: param3*/ |
6a7eba24 JFM |
1055 | {0xa1, 0x21, 0x93, 0x01, 0x00, 0x00, 0x00, 0x10}, |
1056 | {0xa1, 0x21, 0x92, 0xff, 0x00, 0x00, 0x00, 0x10}, | |
1057 | {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
1058 | {0xa1, 0x21, 0x2b, 0xc3, 0x00, 0x00, 0x00, 0x10}, | |
a5ae2062 | 1059 | {} |
6a7eba24 | 1060 | }; |
6a7eba24 | 1061 | |
b8c8a5bf JFM |
1062 | static const u8 po1030_sensor_init[][8] = { |
1063 | /* the sensor registers are described in m5602/m5602_po1030.h */ | |
1064 | {0xa1, 0x6e, 0x3f, 0x20, 0x00, 0x00, 0x00, 0x10}, /* sensor reset */ | |
1065 | {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */ | |
1066 | {0xa1, 0x6e, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
1067 | {0xa1, 0x6e, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
1068 | {0xd1, 0x6e, 0x04, 0x02, 0xb1, 0x02, 0x39, 0x10}, | |
1069 | {0xd1, 0x6e, 0x08, 0x00, 0x01, 0x00, 0x00, 0x10}, | |
1070 | {0xd1, 0x6e, 0x0c, 0x02, 0x7f, 0x01, 0xe0, 0x10}, | |
1071 | {0xd1, 0x6e, 0x12, 0x03, 0x02, 0x00, 0x03, 0x10}, | |
1072 | {0xd1, 0x6e, 0x16, 0x85, 0x40, 0x4a, 0x40, 0x10}, /* r/g1/b/g2 gains */ | |
1073 | {0xc1, 0x6e, 0x1a, 0x00, 0x80, 0x00, 0x00, 0x10}, | |
1074 | {0xd1, 0x6e, 0x1d, 0x08, 0x03, 0x00, 0x00, 0x10}, | |
1075 | {0xd1, 0x6e, 0x23, 0x00, 0xb0, 0x00, 0x94, 0x10}, | |
1076 | {0xd1, 0x6e, 0x27, 0x58, 0x00, 0x00, 0x00, 0x10}, | |
1077 | {0xb1, 0x6e, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
1078 | {0xd1, 0x6e, 0x2d, 0x14, 0x35, 0x61, 0x84, 0x10}, /* gamma corr */ | |
1079 | {0xd1, 0x6e, 0x31, 0xa2, 0xbd, 0xd8, 0xff, 0x10}, | |
1080 | {0xd1, 0x6e, 0x35, 0x06, 0x1e, 0x12, 0x02, 0x10}, /* color matrix */ | |
1081 | {0xd1, 0x6e, 0x39, 0xaa, 0x53, 0x37, 0xd5, 0x10}, | |
1082 | {0xa1, 0x6e, 0x3d, 0xf2, 0x00, 0x00, 0x00, 0x10}, | |
1083 | {0xd1, 0x6e, 0x3e, 0x00, 0x00, 0x80, 0x03, 0x10}, | |
1084 | {0xd1, 0x6e, 0x42, 0x03, 0x00, 0x00, 0x00, 0x10}, | |
1085 | {0xc1, 0x6e, 0x46, 0x00, 0x80, 0x80, 0x00, 0x10}, | |
1086 | {0xd1, 0x6e, 0x4b, 0x02, 0xef, 0x08, 0xcd, 0x10}, | |
1087 | {0xd1, 0x6e, 0x4f, 0x00, 0xd0, 0x00, 0xa0, 0x10}, | |
1088 | {0xd1, 0x6e, 0x53, 0x01, 0xaa, 0x01, 0x40, 0x10}, | |
1089 | {0xd1, 0x6e, 0x5a, 0x50, 0x04, 0x30, 0x03, 0x10}, /* raw rgb bayer */ | |
1090 | {0xa1, 0x6e, 0x5e, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
1091 | {0xd1, 0x6e, 0x5f, 0x10, 0x40, 0xff, 0x00, 0x10}, | |
1092 | ||
1093 | {0xd1, 0x6e, 0x63, 0x40, 0x40, 0x00, 0x00, 0x10}, | |
1094 | {0xd1, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
1095 | {0xd1, 0x6e, 0x6b, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
1096 | {0xd1, 0x6e, 0x6f, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
1097 | {0xc1, 0x6e, 0x73, 0x10, 0x80, 0xeb, 0x00, 0x10}, | |
1098 | {} | |
1099 | }; | |
1100 | static const u8 po1030_sensor_param1[][8] = { | |
1101 | /* from ms-win traces - these values change with auto gain/expo/wb.. */ | |
1102 | {0xa1, 0x6e, 0x1e, 0x03, 0x00, 0x00, 0x00, 0x10}, | |
1103 | {0xa1, 0x6e, 0x1e, 0x03, 0x00, 0x00, 0x00, 0x10}, | |
1104 | /* mean values */ | |
1105 | {0xc1, 0x6e, 0x1a, 0x02, 0xd4, 0xa4, 0x00, 0x10}, /* integlines */ | |
1106 | {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10}, /* global gain */ | |
1107 | {0xc1, 0x6e, 0x16, 0x40, 0x40, 0x40, 0x00, 0x10}, /* r/g1/b gains */ | |
1108 | ||
1109 | {0xa1, 0x6e, 0x1d, 0x08, 0x00, 0x00, 0x00, 0x10}, /* control1 */ | |
1110 | {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10}, /* frameheight */ | |
1111 | {0xa1, 0x6e, 0x07, 0xd5, 0x00, 0x00, 0x00, 0x10}, | |
1112 | /* {0xc1, 0x6e, 0x16, 0x49, 0x40, 0x45, 0x00, 0x10}, */ | |
1113 | {} | |
1114 | }; | |
1115 | ||
ad98c0f6 JFM |
1116 | static const u8 po2030n_sensor_init[][8] = { |
1117 | {0xa1, 0x6e, 0x1e, 0x1a, 0x00, 0x00, 0x00, 0x10}, | |
1118 | {0xa1, 0x6e, 0x1f, 0x99, 0x00, 0x00, 0x00, 0x10}, | |
1119 | {0xdd, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 10ms */ | |
1120 | {0xa1, 0x6e, 0x1e, 0x0a, 0x00, 0x00, 0x00, 0x10}, | |
1121 | {0xa1, 0x6e, 0x1f, 0x19, 0x00, 0x00, 0x00, 0x10}, | |
1122 | {0xdd, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 10ms */ | |
1123 | {0xa1, 0x6e, 0x20, 0x44, 0x00, 0x00, 0x00, 0x10}, | |
1124 | {0xa1, 0x6e, 0x04, 0x03, 0x00, 0x00, 0x00, 0x10}, | |
1125 | {0xa1, 0x6e, 0x05, 0x70, 0x00, 0x00, 0x00, 0x10}, | |
1126 | {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10}, | |
1127 | {0xa1, 0x6e, 0x07, 0x25, 0x00, 0x00, 0x00, 0x10}, | |
1128 | {0xd1, 0x6e, 0x08, 0x00, 0xd0, 0x00, 0x08, 0x10}, | |
1129 | {0xd1, 0x6e, 0x0c, 0x03, 0x50, 0x01, 0xe8, 0x10}, | |
1130 | {0xd1, 0x6e, 0x1d, 0x20, 0x0a, 0x19, 0x44, 0x10}, | |
1131 | {0xd1, 0x6e, 0x21, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
1132 | {0xd1, 0x6e, 0x25, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
1133 | {0xd1, 0x6e, 0x29, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
1134 | {0xd1, 0x6e, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
1135 | {0xd1, 0x6e, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
1136 | {0xd1, 0x6e, 0x35, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
1137 | {0xd1, 0x6e, 0x39, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
1138 | {0xd1, 0x6e, 0x3d, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
1139 | {0xd1, 0x6e, 0x41, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
1140 | {0xd1, 0x6e, 0x45, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
1141 | {0xd1, 0x6e, 0x49, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
1142 | {0xd1, 0x6e, 0x4d, 0x00, 0x00, 0x00, 0xed, 0x10}, | |
1143 | {0xd1, 0x6e, 0x51, 0x17, 0x4a, 0x2f, 0xc0, 0x10}, | |
1144 | {0xd1, 0x6e, 0x55, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
1145 | {0xd1, 0x6e, 0x59, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
1146 | {0xd1, 0x6e, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
1147 | {0xd1, 0x6e, 0x61, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
1148 | {0xd1, 0x6e, 0x65, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
1149 | {0xd1, 0x6e, 0x69, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
1150 | {0xd1, 0x6e, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
1151 | {0xd1, 0x6e, 0x71, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
1152 | {0xd1, 0x6e, 0x75, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
1153 | {0xd1, 0x6e, 0x79, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
1154 | {0xd1, 0x6e, 0x7d, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
1155 | {0xd1, 0x6e, 0x81, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
1156 | {0xd1, 0x6e, 0x85, 0x00, 0x00, 0x00, 0x08, 0x10}, | |
1157 | {0xd1, 0x6e, 0x89, 0x01, 0xe8, 0x00, 0x01, 0x10}, | |
1158 | {0xa1, 0x6e, 0x8d, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
1159 | {0xd1, 0x6e, 0x21, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
1160 | {0xd1, 0x6e, 0x25, 0x00, 0x00, 0x00, 0x01, 0x10}, | |
1161 | {0xd1, 0x6e, 0x29, 0xe6, 0x00, 0xbd, 0x03, 0x10}, | |
1162 | {0xd1, 0x6e, 0x2d, 0x41, 0x38, 0x68, 0x40, 0x10}, | |
1163 | {0xd1, 0x6e, 0x31, 0x2b, 0x00, 0x36, 0x00, 0x10}, | |
1164 | {0xd1, 0x6e, 0x35, 0x30, 0x30, 0x08, 0x00, 0x10}, | |
1165 | {0xd1, 0x6e, 0x39, 0x00, 0x00, 0x33, 0x06, 0x10}, | |
1166 | {0xb1, 0x6e, 0x3d, 0x06, 0x02, 0x00, 0x00, 0x10}, | |
1167 | {} | |
1168 | }; | |
1169 | static const u8 po2030n_sensor_param1[][8] = { | |
1170 | {0xa1, 0x6e, 0x1a, 0x01, 0x00, 0x00, 0x00, 0x10}, | |
1171 | {0xdd, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 8ms */ | |
1172 | {0xa1, 0x6e, 0x1b, 0xf4, 0x00, 0x00, 0x00, 0x10}, | |
1173 | {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10}, | |
1174 | {0xd1, 0x6e, 0x16, 0x50, 0x40, 0x49, 0x40, 0x10}, | |
1175 | /*param2*/ | |
1176 | {0xa1, 0x6e, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
1177 | {0xa1, 0x6e, 0x04, 0x03, 0x00, 0x00, 0x00, 0x10}, | |
1178 | {0xa1, 0x6e, 0x05, 0x6f, 0x00, 0x00, 0x00, 0x10}, | |
1179 | {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10}, | |
1180 | {0xa1, 0x6e, 0x07, 0x25, 0x00, 0x00, 0x00, 0x10}, | |
1181 | {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10}, | |
1182 | {0xc1, 0x6e, 0x16, 0x52, 0x40, 0x48, 0x00, 0x10}, | |
1183 | /*after start*/ | |
1184 | {0xa1, 0x6e, 0x15, 0x0f, 0x00, 0x00, 0x00, 0x10}, | |
1185 | {0xdd, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 5ms */ | |
1186 | {0xa1, 0x6e, 0x1a, 0x05, 0x00, 0x00, 0x00, 0x10}, | |
1187 | {0xdd, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 5ms */ | |
1188 | {0xa1, 0x6e, 0x1b, 0x53, 0x00, 0x00, 0x00, 0x10}, | |
1189 | {} | |
1190 | }; | |
1191 | ||
03ed2a11 JFM |
1192 | static const u8 soi768_sensor_init[][8] = { |
1193 | {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */ | |
1194 | {0xdd, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 96ms */ | |
1195 | {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
1196 | {0xa1, 0x21, 0x13, 0x80, 0x00, 0x00, 0x00, 0x10}, | |
1197 | {0xa1, 0x21, 0x0f, 0x03, 0x00, 0x00, 0x00, 0x10}, | |
1198 | {0xa1, 0x21, 0x19, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
1199 | {} | |
1200 | }; | |
1201 | static const u8 soi768_sensor_param1[][8] = { | |
1202 | {0xa1, 0x21, 0x10, 0x10, 0x00, 0x00, 0x00, 0x10}, | |
1203 | {0xa1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
1204 | {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
1205 | {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
1206 | {0xb1, 0x21, 0x01, 0x7f, 0x7f, 0x00, 0x00, 0x10}, | |
1207 | /* */ | |
1208 | /* {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10}, */ | |
1209 | /* {0xa1, 0x21, 0x2d, 0x25, 0x00, 0x00, 0x00, 0x10}, */ | |
1210 | {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
1211 | /* {0xb1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10}, */ | |
1212 | {0xa1, 0x21, 0x02, 0x8d, 0x00, 0x00, 0x00, 0x10}, | |
1213 | /* the next sequence should be used for auto gain */ | |
1214 | {0xa1, 0x21, 0x00, 0x07, 0x00, 0x00, 0x00, 0x10}, | |
1215 | /* global gain ? : 07 - change with 0x15 at the end */ | |
1216 | {0xa1, 0x21, 0x10, 0x3f, 0x00, 0x00, 0x00, 0x10}, /* ???? : 063f */ | |
1217 | {0xa1, 0x21, 0x04, 0x06, 0x00, 0x00, 0x00, 0x10}, | |
1218 | {0xb1, 0x21, 0x2d, 0x00, 0x02, 0x00, 0x00, 0x10}, | |
1219 | /* exposure ? : 0200 - change with 0x1e at the end */ | |
1220 | {} | |
1221 | }; | |
1222 | ||
5e31dc8d JFM |
1223 | static const u8 sp80708_sensor_init[][8] = { |
1224 | {0xa1, 0x18, 0x06, 0xf9, 0x00, 0x00, 0x00, 0x10}, | |
1225 | {0xa1, 0x18, 0x09, 0x1f, 0x00, 0x00, 0x00, 0x10}, | |
1226 | {0xa1, 0x18, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
1227 | {0xa1, 0x18, 0x0d, 0xc0, 0x00, 0x00, 0x00, 0x10}, | |
1228 | {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10}, | |
1229 | {0xa1, 0x18, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x10}, | |
1230 | {0xa1, 0x18, 0x10, 0x40, 0x00, 0x00, 0x00, 0x10}, | |
1231 | {0xa1, 0x18, 0x11, 0x4e, 0x00, 0x00, 0x00, 0x10}, | |
1232 | {0xa1, 0x18, 0x12, 0x53, 0x00, 0x00, 0x00, 0x10}, | |
1233 | {0xa1, 0x18, 0x15, 0x80, 0x00, 0x00, 0x00, 0x10}, | |
1234 | {0xa1, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x10}, | |
1235 | {0xa1, 0x18, 0x19, 0x18, 0x00, 0x00, 0x00, 0x10}, | |
1236 | {0xa1, 0x18, 0x1a, 0x10, 0x00, 0x00, 0x00, 0x10}, | |
1237 | {0xa1, 0x18, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x10}, | |
1238 | {0xa1, 0x18, 0x1c, 0x28, 0x00, 0x00, 0x00, 0x10}, | |
1239 | {0xa1, 0x18, 0x1d, 0x02, 0x00, 0x00, 0x00, 0x10}, | |
1240 | {0xa1, 0x18, 0x1e, 0x10, 0x00, 0x00, 0x00, 0x10}, | |
1241 | {0xa1, 0x18, 0x26, 0x04, 0x00, 0x00, 0x00, 0x10}, | |
1242 | {0xa1, 0x18, 0x27, 0x1e, 0x00, 0x00, 0x00, 0x10}, | |
1243 | {0xa1, 0x18, 0x28, 0x5a, 0x00, 0x00, 0x00, 0x10}, | |
1244 | {0xa1, 0x18, 0x29, 0x28, 0x00, 0x00, 0x00, 0x10}, | |
1245 | {0xa1, 0x18, 0x2a, 0x78, 0x00, 0x00, 0x00, 0x10}, | |
1246 | {0xa1, 0x18, 0x2b, 0x01, 0x00, 0x00, 0x00, 0x10}, | |
1247 | {0xa1, 0x18, 0x2c, 0xf7, 0x00, 0x00, 0x00, 0x10}, | |
1248 | {0xa1, 0x18, 0x2d, 0x2d, 0x00, 0x00, 0x00, 0x10}, | |
1249 | {0xa1, 0x18, 0x2e, 0xd5, 0x00, 0x00, 0x00, 0x10}, | |
1250 | {0xa1, 0x18, 0x39, 0x42, 0x00, 0x00, 0x00, 0x10}, | |
1251 | {0xa1, 0x18, 0x3a, 0x67, 0x00, 0x00, 0x00, 0x10}, | |
1252 | {0xa1, 0x18, 0x3b, 0x87, 0x00, 0x00, 0x00, 0x10}, | |
1253 | {0xa1, 0x18, 0x3c, 0xa3, 0x00, 0x00, 0x00, 0x10}, | |
1254 | {0xa1, 0x18, 0x3d, 0xb0, 0x00, 0x00, 0x00, 0x10}, | |
1255 | {0xa1, 0x18, 0x3e, 0xbc, 0x00, 0x00, 0x00, 0x10}, | |
1256 | {0xa1, 0x18, 0x3f, 0xc8, 0x00, 0x00, 0x00, 0x10}, | |
1257 | {0xa1, 0x18, 0x40, 0xd4, 0x00, 0x00, 0x00, 0x10}, | |
1258 | {0xa1, 0x18, 0x41, 0xdf, 0x00, 0x00, 0x00, 0x10}, | |
1259 | {0xa1, 0x18, 0x42, 0xea, 0x00, 0x00, 0x00, 0x10}, | |
1260 | {0xa1, 0x18, 0x43, 0xf5, 0x00, 0x00, 0x00, 0x10}, | |
1261 | {0xa1, 0x18, 0x45, 0x80, 0x00, 0x00, 0x00, 0x10}, | |
1262 | {0xa1, 0x18, 0x46, 0x60, 0x00, 0x00, 0x00, 0x10}, | |
1263 | {0xa1, 0x18, 0x47, 0x50, 0x00, 0x00, 0x00, 0x10}, | |
1264 | {0xa1, 0x18, 0x48, 0x30, 0x00, 0x00, 0x00, 0x10}, | |
1265 | {0xa1, 0x18, 0x49, 0x01, 0x00, 0x00, 0x00, 0x10}, | |
1266 | {0xa1, 0x18, 0x4d, 0xae, 0x00, 0x00, 0x00, 0x10}, | |
1267 | {0xa1, 0x18, 0x4e, 0x03, 0x00, 0x00, 0x00, 0x10}, | |
1268 | {0xa1, 0x18, 0x4f, 0x66, 0x00, 0x00, 0x00, 0x10}, | |
1269 | {0xa1, 0x18, 0x50, 0x1c, 0x00, 0x00, 0x00, 0x10}, | |
1270 | {0xa1, 0x18, 0x44, 0x10, 0x00, 0x00, 0x00, 0x10}, | |
1271 | {0xa1, 0x18, 0x4a, 0x30, 0x00, 0x00, 0x00, 0x10}, | |
1272 | {0xa1, 0x18, 0x51, 0x80, 0x00, 0x00, 0x00, 0x10}, | |
1273 | {0xa1, 0x18, 0x52, 0x80, 0x00, 0x00, 0x00, 0x10}, | |
1274 | {0xa1, 0x18, 0x53, 0x80, 0x00, 0x00, 0x00, 0x10}, | |
1275 | {0xa1, 0x18, 0x54, 0x80, 0x00, 0x00, 0x00, 0x10}, | |
1276 | {0xa1, 0x18, 0x55, 0x80, 0x00, 0x00, 0x00, 0x10}, | |
1277 | {0xa1, 0x18, 0x56, 0x80, 0x00, 0x00, 0x00, 0x10}, | |
1278 | {0xa1, 0x18, 0x57, 0xe0, 0x00, 0x00, 0x00, 0x10}, | |
1279 | {0xa1, 0x18, 0x58, 0xc0, 0x00, 0x00, 0x00, 0x10}, | |
1280 | {0xa1, 0x18, 0x59, 0xab, 0x00, 0x00, 0x00, 0x10}, | |
1281 | {0xa1, 0x18, 0x5a, 0xa0, 0x00, 0x00, 0x00, 0x10}, | |
1282 | {0xa1, 0x18, 0x5b, 0x99, 0x00, 0x00, 0x00, 0x10}, | |
1283 | {0xa1, 0x18, 0x5c, 0x90, 0x00, 0x00, 0x00, 0x10}, | |
1284 | {0xa1, 0x18, 0x5e, 0x24, 0x00, 0x00, 0x00, 0x10}, | |
1285 | {0xa1, 0x18, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
1286 | {0xa1, 0x18, 0x60, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
1287 | {0xa1, 0x18, 0x61, 0x73, 0x00, 0x00, 0x00, 0x10}, | |
1288 | {0xa1, 0x18, 0x63, 0x42, 0x00, 0x00, 0x00, 0x10}, | |
1289 | {0xa1, 0x18, 0x64, 0x42, 0x00, 0x00, 0x00, 0x10}, | |
1290 | {0xa1, 0x18, 0x65, 0x42, 0x00, 0x00, 0x00, 0x10}, | |
1291 | {0xa1, 0x18, 0x66, 0x24, 0x00, 0x00, 0x00, 0x10}, | |
1292 | {0xa1, 0x18, 0x67, 0x24, 0x00, 0x00, 0x00, 0x10}, | |
1293 | {0xa1, 0x18, 0x68, 0x08, 0x00, 0x00, 0x00, 0x10}, | |
1294 | {0xa1, 0x18, 0x2f, 0xc9, 0x00, 0x00, 0x00, 0x10}, | |
3fccb774 JFM |
1295 | {} |
1296 | }; | |
1297 | static const u8 sp80708_sensor_param1[][8] = { | |
5e31dc8d JFM |
1298 | {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10}, |
1299 | {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10}, | |
1300 | {0xa1, 0x18, 0x03, 0x01, 0x00, 0x00, 0x00, 0x10}, | |
1301 | {0xa1, 0x18, 0x04, 0xa4, 0x00, 0x00, 0x00, 0x10}, | |
1302 | {0xa1, 0x18, 0x14, 0x3f, 0x00, 0x00, 0x00, 0x10}, | |
1303 | {0xa1, 0x18, 0x5d, 0x80, 0x00, 0x00, 0x00, 0x10}, | |
1304 | {0xb1, 0x18, 0x11, 0x40, 0x40, 0x00, 0x00, 0x10}, | |
1305 | {} | |
1306 | }; | |
1307 | ||
9c33afc6 JFM |
1308 | static const u8 (*sensor_init[])[8] = { |
1309 | [SENSOR_ADCM1700] = adcm1700_sensor_init, | |
ad98c0f6 | 1310 | [SENSOR_GC0307] = gc0307_sensor_init, |
9c33afc6 JFM |
1311 | [SENSOR_HV7131R] = hv7131r_sensor_init, |
1312 | [SENSOR_MI0360] = mi0360_sensor_init, | |
1313 | [SENSOR_MO4000] = mo4000_sensor_init, | |
1314 | [SENSOR_MT9V111] = mt9v111_sensor_init, | |
1315 | [SENSOR_OM6802] = om6802_sensor_init, | |
1316 | [SENSOR_OV7630] = ov7630_sensor_init, | |
1317 | [SENSOR_OV7648] = ov7648_sensor_init, | |
1318 | [SENSOR_OV7660] = ov7660_sensor_init, | |
1319 | [SENSOR_PO1030] = po1030_sensor_init, | |
ad98c0f6 | 1320 | [SENSOR_PO2030N] = po2030n_sensor_init, |
03ed2a11 | 1321 | [SENSOR_SOI768] = soi768_sensor_init, |
9c33afc6 | 1322 | [SENSOR_SP80708] = sp80708_sensor_init, |
23a98274 JFM |
1323 | }; |
1324 | ||
8295d99e | 1325 | /* read <len> bytes to gspca_dev->usb_buf */ |
739570bb | 1326 | static void reg_r(struct gspca_dev *gspca_dev, |
98819187 | 1327 | u16 value, int len) |
6a7eba24 | 1328 | { |
8295d99e JFM |
1329 | #ifdef GSPCA_DEBUG |
1330 | if (len > USB_BUF_SZ) { | |
1331 | err("reg_r: buffer overflow"); | |
1332 | return; | |
1333 | } | |
1334 | #endif | |
739570bb JFM |
1335 | usb_control_msg(gspca_dev->dev, |
1336 | usb_rcvctrlpipe(gspca_dev->dev, 0), | |
6a7eba24 JFM |
1337 | 0, |
1338 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, | |
1339 | value, 0, | |
739570bb | 1340 | gspca_dev->usb_buf, len, |
6a7eba24 | 1341 | 500); |
60017617 | 1342 | PDEBUG(D_USBI, "reg_r [%02x] -> %02x", value, gspca_dev->usb_buf[0]); |
6a7eba24 JFM |
1343 | } |
1344 | ||
60017617 | 1345 | static void reg_w1(struct gspca_dev *gspca_dev, |
98819187 JFM |
1346 | u16 value, |
1347 | u8 data) | |
60017617 | 1348 | { |
3ef2c5be | 1349 | PDEBUG(D_USBO, "reg_w1 [%04x] = %02x", value, data); |
60017617 JFM |
1350 | gspca_dev->usb_buf[0] = data; |
1351 | usb_control_msg(gspca_dev->dev, | |
1352 | usb_sndctrlpipe(gspca_dev->dev, 0), | |
1353 | 0x08, | |
1354 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, | |
1355 | value, | |
1356 | 0, | |
1357 | gspca_dev->usb_buf, 1, | |
1358 | 500); | |
1359 | } | |
739570bb | 1360 | static void reg_w(struct gspca_dev *gspca_dev, |
98819187 JFM |
1361 | u16 value, |
1362 | const u8 *buffer, | |
6a7eba24 JFM |
1363 | int len) |
1364 | { | |
3ef2c5be | 1365 | PDEBUG(D_USBO, "reg_w [%04x] = %02x %02x ..", |
60017617 | 1366 | value, buffer[0], buffer[1]); |
8295d99e JFM |
1367 | #ifdef GSPCA_DEBUG |
1368 | if (len > USB_BUF_SZ) { | |
1369 | err("reg_w: buffer overflow"); | |
1370 | return; | |
bf7f0b98 | 1371 | } |
8295d99e JFM |
1372 | #endif |
1373 | memcpy(gspca_dev->usb_buf, buffer, len); | |
1374 | usb_control_msg(gspca_dev->dev, | |
1375 | usb_sndctrlpipe(gspca_dev->dev, 0), | |
1376 | 0x08, | |
1377 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, | |
1378 | value, 0, | |
1379 | gspca_dev->usb_buf, len, | |
1380 | 500); | |
6a7eba24 JFM |
1381 | } |
1382 | ||
60017617 | 1383 | /* I2C write 1 byte */ |
98819187 | 1384 | static void i2c_w1(struct gspca_dev *gspca_dev, u8 reg, u8 val) |
6a7eba24 JFM |
1385 | { |
1386 | struct sd *sd = (struct sd *) gspca_dev; | |
6a7eba24 | 1387 | |
cfd23c8e | 1388 | PDEBUG(D_USBO, "i2c_w1 [%02x] = %02x", reg, val); |
a782636c | 1389 | switch (sd->sensor) { |
64677573 | 1390 | case SENSOR_ADCM1700: |
ad98c0f6 JFM |
1391 | case SENSOR_OM6802: |
1392 | case SENSOR_GC0307: /* i2c command = a0 (100 kHz) */ | |
a782636c JFM |
1393 | gspca_dev->usb_buf[0] = 0x80 | (2 << 4); |
1394 | break; | |
1395 | default: /* i2c command = a1 (400 kHz) */ | |
1396 | gspca_dev->usb_buf[0] = 0x81 | (2 << 4); | |
1397 | break; | |
1398 | } | |
d5aa3856 | 1399 | gspca_dev->usb_buf[1] = sd->i2c_addr; |
60017617 JFM |
1400 | gspca_dev->usb_buf[2] = reg; |
1401 | gspca_dev->usb_buf[3] = val; | |
1402 | gspca_dev->usb_buf[4] = 0; | |
1403 | gspca_dev->usb_buf[5] = 0; | |
1404 | gspca_dev->usb_buf[6] = 0; | |
1405 | gspca_dev->usb_buf[7] = 0x10; | |
1406 | usb_control_msg(gspca_dev->dev, | |
1407 | usb_sndctrlpipe(gspca_dev->dev, 0), | |
1408 | 0x08, | |
1409 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, | |
1410 | 0x08, /* value = i2c */ | |
1411 | 0, | |
1412 | gspca_dev->usb_buf, 8, | |
1413 | 500); | |
6a7eba24 JFM |
1414 | } |
1415 | ||
739570bb JFM |
1416 | /* I2C write 8 bytes */ |
1417 | static void i2c_w8(struct gspca_dev *gspca_dev, | |
98819187 | 1418 | const u8 *buffer) |
6a7eba24 | 1419 | { |
cfd23c8e JFM |
1420 | PDEBUG(D_USBO, "i2c_w8 [%02x] = %02x ..", |
1421 | buffer[2], buffer[3]); | |
60017617 JFM |
1422 | memcpy(gspca_dev->usb_buf, buffer, 8); |
1423 | usb_control_msg(gspca_dev->dev, | |
1424 | usb_sndctrlpipe(gspca_dev->dev, 0), | |
1425 | 0x08, | |
1426 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, | |
1427 | 0x08, 0, /* value, index */ | |
1428 | gspca_dev->usb_buf, 8, | |
1429 | 500); | |
8d768e14 | 1430 | msleep(2); |
6a7eba24 JFM |
1431 | } |
1432 | ||
b8c8a5bf JFM |
1433 | /* sensor read 'len' (1..5) bytes in gspca_dev->usb_buf */ |
1434 | static void i2c_r(struct gspca_dev *gspca_dev, u8 reg, int len) | |
6a7eba24 JFM |
1435 | { |
1436 | struct sd *sd = (struct sd *) gspca_dev; | |
98819187 | 1437 | u8 mode[8]; |
6a7eba24 | 1438 | |
a782636c | 1439 | switch (sd->sensor) { |
64677573 | 1440 | case SENSOR_ADCM1700: |
ad98c0f6 JFM |
1441 | case SENSOR_OM6802: |
1442 | case SENSOR_GC0307: /* i2c command = a0 (100 kHz) */ | |
a782636c JFM |
1443 | mode[0] = 0x80 | 0x10; |
1444 | break; | |
1445 | default: /* i2c command = 91 (400 kHz) */ | |
1446 | mode[0] = 0x81 | 0x10; | |
1447 | break; | |
1448 | } | |
d5aa3856 | 1449 | mode[1] = sd->i2c_addr; |
6a7eba24 JFM |
1450 | mode[2] = reg; |
1451 | mode[3] = 0; | |
1452 | mode[4] = 0; | |
1453 | mode[5] = 0; | |
1454 | mode[6] = 0; | |
1455 | mode[7] = 0x10; | |
739570bb | 1456 | i2c_w8(gspca_dev, mode); |
60017617 | 1457 | msleep(2); |
b8c8a5bf | 1458 | mode[0] = (mode[0] & 0x81) | (len << 4) | 0x02; |
6a7eba24 | 1459 | mode[2] = 0; |
739570bb | 1460 | i2c_w8(gspca_dev, mode); |
60017617 | 1461 | msleep(2); |
739570bb | 1462 | reg_r(gspca_dev, 0x0a, 5); |
6a7eba24 JFM |
1463 | } |
1464 | ||
23a98274 JFM |
1465 | static void i2c_w_seq(struct gspca_dev *gspca_dev, |
1466 | const u8 (*data)[8]) | |
1467 | { | |
1468 | while ((*data)[0] != 0) { | |
1469 | if ((*data)[0] != 0xdd) | |
1470 | i2c_w8(gspca_dev, *data); | |
1471 | else | |
1472 | msleep((*data)[1]); | |
1473 | data++; | |
1474 | } | |
1475 | } | |
1476 | ||
7fb101ae | 1477 | static void hv7131r_probe(struct gspca_dev *gspca_dev) |
6a7eba24 | 1478 | { |
60017617 | 1479 | i2c_w1(gspca_dev, 0x02, 0); /* sensor wakeup */ |
6a7eba24 | 1480 | msleep(10); |
60017617 | 1481 | reg_w1(gspca_dev, 0x02, 0x66); /* Gpio on */ |
6a7eba24 | 1482 | msleep(10); |
b8c8a5bf | 1483 | i2c_r(gspca_dev, 0, 5); /* read sensor id */ |
739570bb JFM |
1484 | if (gspca_dev->usb_buf[0] == 0x02 |
1485 | && gspca_dev->usb_buf[1] == 0x09 | |
1486 | && gspca_dev->usb_buf[2] == 0x01 | |
1487 | && gspca_dev->usb_buf[3] == 0x00 | |
1488 | && gspca_dev->usb_buf[4] == 0x00) { | |
7fb101ae JFM |
1489 | PDEBUG(D_PROBE, "Sensor sn9c102P HV7131R found"); |
1490 | return; | |
6a7eba24 | 1491 | } |
7fb101ae | 1492 | PDEBUG(D_PROBE, "Sensor 0x%02x 0x%02x 0x%02x - sn9c102P not found", |
739570bb JFM |
1493 | gspca_dev->usb_buf[0], gspca_dev->usb_buf[1], |
1494 | gspca_dev->usb_buf[2]); | |
6a7eba24 JFM |
1495 | } |
1496 | ||
65c5259c | 1497 | static void mi0360_probe(struct gspca_dev *gspca_dev) |
3ef2c5be | 1498 | { |
65c5259c | 1499 | struct sd *sd = (struct sd *) gspca_dev; |
3ef2c5be | 1500 | int i, j; |
92e8c91b | 1501 | u16 val = 0; |
3ef2c5be | 1502 | static const u8 probe_tb[][4][8] = { |
65c5259c | 1503 | { /* mi0360 */ |
3ef2c5be JFM |
1504 | {0xb0, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, |
1505 | {0x90, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
1506 | {0xa2, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
1507 | {0xb0, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10} | |
1508 | }, | |
65c5259c | 1509 | { /* mt9v111 */ |
3ef2c5be JFM |
1510 | {0xb0, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10}, |
1511 | {0x90, 0x5c, 0x36, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
1512 | {0xa2, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, | |
1513 | {} | |
1514 | }, | |
1515 | }; | |
1516 | ||
1517 | for (i = 0; i < ARRAY_SIZE(probe_tb); i++) { | |
1518 | reg_w1(gspca_dev, 0x17, 0x62); | |
1519 | reg_w1(gspca_dev, 0x01, 0x08); | |
1520 | for (j = 0; j < 3; j++) | |
1521 | i2c_w8(gspca_dev, probe_tb[i][j]); | |
1522 | msleep(2); | |
1523 | reg_r(gspca_dev, 0x0a, 5); | |
1524 | val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4]; | |
1525 | if (probe_tb[i][3][0] != 0) | |
1526 | i2c_w8(gspca_dev, probe_tb[i][3]); | |
1527 | reg_w1(gspca_dev, 0x01, 0x29); | |
1528 | reg_w1(gspca_dev, 0x17, 0x42); | |
1529 | if (val != 0xffff) | |
1530 | break; | |
1531 | } | |
1532 | switch (val) { | |
1533 | case 0x823a: | |
1534 | PDEBUG(D_PROBE, "Sensor mt9v111"); | |
65c5259c | 1535 | sd->sensor = SENSOR_MT9V111; |
65c5259c | 1536 | break; |
3ef2c5be JFM |
1537 | case 0x8243: |
1538 | PDEBUG(D_PROBE, "Sensor mi0360"); | |
65c5259c JFM |
1539 | break; |
1540 | default: | |
1541 | PDEBUG(D_PROBE, "Unknown sensor %04x - forced to mi0360", val); | |
1542 | break; | |
3ef2c5be | 1543 | } |
3ef2c5be JFM |
1544 | } |
1545 | ||
03ed2a11 JFM |
1546 | static void ov7630_probe(struct gspca_dev *gspca_dev) |
1547 | { | |
1548 | struct sd *sd = (struct sd *) gspca_dev; | |
1549 | u16 val; | |
1550 | ||
1551 | /* check ov76xx */ | |
1552 | reg_w1(gspca_dev, 0x17, 0x62); | |
1553 | reg_w1(gspca_dev, 0x01, 0x08); | |
1554 | sd->i2c_addr = 0x21; | |
1555 | i2c_r(gspca_dev, 0x0a, 2); | |
1556 | val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4]; | |
1557 | reg_w1(gspca_dev, 0x01, 0x29); | |
1558 | reg_w1(gspca_dev, 0x17, 0x42); | |
1559 | if (val == 0x7628) { /* soi768 */ | |
1560 | sd->sensor = SENSOR_SOI768; | |
1561 | /*fixme: only valid for 0c45:613e?*/ | |
1562 | gspca_dev->cam.input_flags = | |
1563 | V4L2_IN_ST_VFLIP | V4L2_IN_ST_HFLIP; | |
1564 | PDEBUG(D_PROBE, "Sensor soi768"); | |
1565 | return; | |
1566 | } | |
1567 | PDEBUG(D_PROBE, "Sensor ov%04x", val); | |
1568 | } | |
1569 | ||
b8c8a5bf JFM |
1570 | static void ov7648_probe(struct gspca_dev *gspca_dev) |
1571 | { | |
1572 | struct sd *sd = (struct sd *) gspca_dev; | |
e3302cad | 1573 | u16 val; |
b8c8a5bf JFM |
1574 | |
1575 | /* check ov76xx */ | |
1576 | reg_w1(gspca_dev, 0x17, 0x62); | |
1577 | reg_w1(gspca_dev, 0x01, 0x08); | |
1578 | sd->i2c_addr = 0x21; | |
1579 | i2c_r(gspca_dev, 0x0a, 2); | |
e3302cad | 1580 | val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4]; |
b8c8a5bf JFM |
1581 | reg_w1(gspca_dev, 0x01, 0x29); |
1582 | reg_w1(gspca_dev, 0x17, 0x42); | |
e3302cad JFM |
1583 | if ((val & 0xff00) == 0x7600) { /* ov76xx */ |
1584 | PDEBUG(D_PROBE, "Sensor ov%04x", val); | |
1585 | return; | |
1586 | } | |
b8c8a5bf JFM |
1587 | |
1588 | /* check po1030 */ | |
1589 | reg_w1(gspca_dev, 0x17, 0x62); | |
1590 | reg_w1(gspca_dev, 0x01, 0x08); | |
1591 | sd->i2c_addr = 0x6e; | |
1592 | i2c_r(gspca_dev, 0x00, 2); | |
e3302cad JFM |
1593 | val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4]; |
1594 | reg_w1(gspca_dev, 0x01, 0x29); | |
1595 | reg_w1(gspca_dev, 0x17, 0x42); | |
1596 | if (val == 0x1030) { /* po1030 */ | |
b8c8a5bf JFM |
1597 | PDEBUG(D_PROBE, "Sensor po1030"); |
1598 | sd->sensor = SENSOR_PO1030; | |
1599 | return; | |
1600 | } | |
1601 | ||
e3302cad | 1602 | PDEBUG(D_PROBE, "Unknown sensor %04x", val); |
b8c8a5bf JFM |
1603 | } |
1604 | ||
ad98c0f6 JFM |
1605 | /* 0c45:6142 sensor may be po2030n, gc0305 or gc0307 */ |
1606 | static void po2030n_probe(struct gspca_dev *gspca_dev) | |
1607 | { | |
1608 | struct sd *sd = (struct sd *) gspca_dev; | |
e3302cad | 1609 | u16 val; |
ad98c0f6 JFM |
1610 | |
1611 | /* check gc0307 */ | |
1612 | reg_w1(gspca_dev, 0x17, 0x62); | |
1613 | reg_w1(gspca_dev, 0x01, 0x08); | |
1614 | reg_w1(gspca_dev, 0x02, 0x22); | |
1615 | sd->i2c_addr = 0x21; | |
1616 | i2c_r(gspca_dev, 0x00, 1); | |
e3302cad | 1617 | val = gspca_dev->usb_buf[4]; |
ad98c0f6 JFM |
1618 | reg_w1(gspca_dev, 0x01, 0x29); /* reset */ |
1619 | reg_w1(gspca_dev, 0x17, 0x42); | |
e3302cad | 1620 | if (val == 0x99) { /* gc0307 (?) */ |
ad98c0f6 JFM |
1621 | PDEBUG(D_PROBE, "Sensor gc0307"); |
1622 | sd->sensor = SENSOR_GC0307; | |
1623 | return; | |
1624 | } | |
1625 | ||
1626 | /* check po2030n */ | |
1627 | reg_w1(gspca_dev, 0x17, 0x62); | |
1628 | reg_w1(gspca_dev, 0x01, 0x0a); | |
1629 | sd->i2c_addr = 0x6e; | |
1630 | i2c_r(gspca_dev, 0x00, 2); | |
e3302cad | 1631 | val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4]; |
ad98c0f6 JFM |
1632 | reg_w1(gspca_dev, 0x01, 0x29); |
1633 | reg_w1(gspca_dev, 0x17, 0x42); | |
e3302cad | 1634 | if (val == 0x2030) { |
ad98c0f6 JFM |
1635 | PDEBUG(D_PROBE, "Sensor po2030n"); |
1636 | /* sd->sensor = SENSOR_PO2030N; */ | |
e3302cad JFM |
1637 | } else { |
1638 | PDEBUG(D_PROBE, "Unknown sensor ID %04x", val); | |
1639 | } | |
ad98c0f6 JFM |
1640 | } |
1641 | ||
3fccb774 | 1642 | static void bridge_init(struct gspca_dev *gspca_dev, |
98819187 | 1643 | const u8 *sn9c1xx) |
6a7eba24 JFM |
1644 | { |
1645 | struct sd *sd = (struct sd *) gspca_dev; | |
19697b54 | 1646 | u8 reg0102[2]; |
98819187 JFM |
1647 | const u8 *reg9a; |
1648 | static const u8 reg9a_def[] = | |
c8b9b2ca JFM |
1649 | {0x00, 0x40, 0x20, 0x00, 0x00, 0x00}; |
1650 | static const u8 reg9a_spec[] = | |
1651 | {0x00, 0x40, 0x38, 0x30, 0x00, 0x20}; | |
98819187 | 1652 | static const u8 regd4[] = {0x60, 0x00, 0x00}; |
6a7eba24 | 1653 | |
9712a8be HG |
1654 | /* sensor clock already enabled in sd_init */ |
1655 | /* reg_w1(gspca_dev, 0xf1, 0x00); */ | |
05b809c7 | 1656 | reg_w1(gspca_dev, 0x01, sn9c1xx[1]); |
6a7eba24 JFM |
1657 | |
1658 | /* configure gpio */ | |
19697b54 JFM |
1659 | reg0102[0] = sn9c1xx[1]; |
1660 | reg0102[1] = sn9c1xx[2]; | |
1661 | if (gspca_dev->audio) | |
1662 | reg0102[1] |= 0x04; /* keep the audio connection */ | |
1663 | reg_w(gspca_dev, 0x01, reg0102, 2); | |
739570bb | 1664 | reg_w(gspca_dev, 0x08, &sn9c1xx[8], 2); |
d5aa3856 | 1665 | reg_w(gspca_dev, 0x17, &sn9c1xx[0x17], 5); |
c8b9b2ca | 1666 | switch (sd->sensor) { |
ad98c0f6 | 1667 | case SENSOR_GC0307: |
c8b9b2ca | 1668 | case SENSOR_OV7660: |
b8c8a5bf | 1669 | case SENSOR_PO1030: |
ad98c0f6 | 1670 | case SENSOR_PO2030N: |
03ed2a11 | 1671 | case SENSOR_SOI768: |
c8b9b2ca JFM |
1672 | case SENSOR_SP80708: |
1673 | reg9a = reg9a_spec; | |
6a7eba24 | 1674 | break; |
6a7eba24 JFM |
1675 | default: |
1676 | reg9a = reg9a_def; | |
1677 | break; | |
1678 | } | |
739570bb | 1679 | reg_w(gspca_dev, 0x9a, reg9a, 6); |
6a7eba24 | 1680 | |
d5aa3856 | 1681 | reg_w(gspca_dev, 0xd4, regd4, sizeof regd4); |
6a7eba24 | 1682 | |
739570bb | 1683 | reg_w(gspca_dev, 0x03, &sn9c1xx[3], 0x0f); |
6a7eba24 | 1684 | |
d2d16e90 | 1685 | switch (sd->sensor) { |
64677573 | 1686 | case SENSOR_ADCM1700: |
878b35ae | 1687 | reg_w1(gspca_dev, 0x01, 0x43); |
64677573 JFM |
1688 | reg_w1(gspca_dev, 0x17, 0x62); |
1689 | reg_w1(gspca_dev, 0x01, 0x42); | |
1690 | reg_w1(gspca_dev, 0x01, 0x42); | |
1691 | break; | |
ad98c0f6 JFM |
1692 | case SENSOR_GC0307: |
1693 | msleep(50); | |
1694 | reg_w1(gspca_dev, 0x01, 0x61); | |
1695 | reg_w1(gspca_dev, 0x17, 0x22); | |
1696 | reg_w1(gspca_dev, 0x01, 0x60); | |
1697 | reg_w1(gspca_dev, 0x01, 0x40); | |
1698 | msleep(50); | |
1699 | break; | |
3ef2c5be JFM |
1700 | case SENSOR_MT9V111: |
1701 | reg_w1(gspca_dev, 0x01, 0x61); | |
1702 | reg_w1(gspca_dev, 0x17, 0x61); | |
1703 | reg_w1(gspca_dev, 0x01, 0x60); | |
1704 | reg_w1(gspca_dev, 0x01, 0x40); | |
1705 | break; | |
d2d16e90 | 1706 | case SENSOR_OM6802: |
3fccb774 JFM |
1707 | msleep(10); |
1708 | reg_w1(gspca_dev, 0x02, 0x73); | |
1709 | reg_w1(gspca_dev, 0x17, 0x60); | |
1710 | reg_w1(gspca_dev, 0x01, 0x22); | |
1711 | msleep(100); | |
1712 | reg_w1(gspca_dev, 0x01, 0x62); | |
d2d16e90 | 1713 | reg_w1(gspca_dev, 0x17, 0x64); |
3fccb774 JFM |
1714 | reg_w1(gspca_dev, 0x17, 0x64); |
1715 | reg_w1(gspca_dev, 0x01, 0x42); | |
1716 | msleep(10); | |
d2d16e90 | 1717 | reg_w1(gspca_dev, 0x01, 0x42); |
3fccb774 JFM |
1718 | i2c_w8(gspca_dev, om6802_init0[0]); |
1719 | i2c_w8(gspca_dev, om6802_init0[1]); | |
1720 | msleep(15); | |
1721 | reg_w1(gspca_dev, 0x02, 0x71); | |
1722 | msleep(150); | |
d2d16e90 | 1723 | break; |
05b809c7 JFM |
1724 | case SENSOR_OV7630: |
1725 | reg_w1(gspca_dev, 0x01, 0x61); | |
1726 | reg_w1(gspca_dev, 0x17, 0xe2); | |
1727 | reg_w1(gspca_dev, 0x01, 0x60); | |
1728 | reg_w1(gspca_dev, 0x01, 0x40); | |
1729 | break; | |
d2d16e90 | 1730 | case SENSOR_OV7648: |
6270330a JFM |
1731 | reg_w1(gspca_dev, 0x01, 0x63); |
1732 | reg_w1(gspca_dev, 0x17, 0x20); | |
c8b9b2ca | 1733 | reg_w1(gspca_dev, 0x01, 0x62); |
60017617 | 1734 | reg_w1(gspca_dev, 0x01, 0x42); |
6a7eba24 | 1735 | break; |
b8c8a5bf | 1736 | case SENSOR_PO1030: |
03ed2a11 | 1737 | case SENSOR_SOI768: |
b8c8a5bf JFM |
1738 | reg_w1(gspca_dev, 0x01, 0x61); |
1739 | reg_w1(gspca_dev, 0x17, 0x20); | |
1740 | reg_w1(gspca_dev, 0x01, 0x60); | |
1741 | reg_w1(gspca_dev, 0x01, 0x40); | |
1742 | break; | |
ad98c0f6 | 1743 | case SENSOR_PO2030N: |
19697b54 | 1744 | case SENSOR_OV7660: |
ad98c0f6 JFM |
1745 | reg_w1(gspca_dev, 0x01, 0x63); |
1746 | reg_w1(gspca_dev, 0x17, 0x20); | |
1747 | reg_w1(gspca_dev, 0x01, 0x62); | |
1748 | reg_w1(gspca_dev, 0x01, 0x42); | |
1749 | break; | |
5e31dc8d JFM |
1750 | case SENSOR_SP80708: |
1751 | reg_w1(gspca_dev, 0x01, 0x63); | |
1752 | reg_w1(gspca_dev, 0x17, 0x20); | |
1753 | reg_w1(gspca_dev, 0x01, 0x62); | |
1754 | reg_w1(gspca_dev, 0x01, 0x42); | |
1f78a976 | 1755 | msleep(100); |
5e31dc8d JFM |
1756 | reg_w1(gspca_dev, 0x02, 0x62); |
1757 | break; | |
d5aa3856 | 1758 | default: |
c8b9b2ca JFM |
1759 | /* case SENSOR_HV7131R: */ |
1760 | /* case SENSOR_MI0360: */ | |
1761 | /* case SENSOR_MO4000: */ | |
60017617 JFM |
1762 | reg_w1(gspca_dev, 0x01, 0x43); |
1763 | reg_w1(gspca_dev, 0x17, 0x61); | |
1764 | reg_w1(gspca_dev, 0x01, 0x42); | |
d5aa3856 JFM |
1765 | if (sd->sensor == SENSOR_HV7131R |
1766 | && sd->bridge == BRIDGE_SN9C102P) | |
7fb101ae | 1767 | hv7131r_probe(gspca_dev); |
d2d16e90 | 1768 | break; |
6a7eba24 | 1769 | } |
6a7eba24 JFM |
1770 | } |
1771 | ||
6a7eba24 JFM |
1772 | /* this function is called at probe time */ |
1773 | static int sd_config(struct gspca_dev *gspca_dev, | |
1774 | const struct usb_device_id *id) | |
1775 | { | |
1776 | struct sd *sd = (struct sd *) gspca_dev; | |
1777 | struct cam *cam; | |
6a7eba24 | 1778 | |
eac8f5fa JFM |
1779 | sd->bridge = id->driver_info >> 16; |
1780 | sd->sensor = id->driver_info; | |
1781 | ||
6a7eba24 | 1782 | cam = &gspca_dev->cam; |
64677573 JFM |
1783 | if (sd->sensor == SENSOR_ADCM1700) { |
1784 | cam->cam_mode = cif_mode; | |
1785 | cam->nmodes = ARRAY_SIZE(cif_mode); | |
1786 | } else { | |
1787 | cam->cam_mode = vga_mode; | |
1788 | cam->nmodes = ARRAY_SIZE(vga_mode); | |
1789 | } | |
49cb6b04 | 1790 | cam->npkt = 24; /* 24 packets per ISOC message */ |
a5ae2062 | 1791 | |
a5ae2062 JFM |
1792 | sd->brightness = BRIGHTNESS_DEF; |
1793 | sd->contrast = CONTRAST_DEF; | |
1794 | sd->colors = COLOR_DEF; | |
403123d2 JFM |
1795 | sd->blue = BLUE_BALANCE_DEF; |
1796 | sd->red = RED_BALANCE_DEF; | |
592f4eb9 | 1797 | sd->gamma = GAMMA_DEF; |
a5ae2062 | 1798 | sd->autogain = AUTOGAIN_DEF; |
cebf3b67 | 1799 | sd->ag_cnt = -1; |
f800952c | 1800 | sd->vflip = VFLIP_DEF; |
878b35ae JFM |
1801 | switch (sd->sensor) { |
1802 | case SENSOR_OM6802: | |
1803 | sd->sharpness = 0x10; | |
1804 | break; | |
1805 | default: | |
1806 | sd->sharpness = SHARPNESS_DEF; | |
1807 | break; | |
1808 | } | |
0cae8964 | 1809 | sd->infrared = INFRARED_DEF; |
37c6dbe2 | 1810 | sd->freq = FREQ_DEF; |
77ac0baf | 1811 | sd->quality = QUALITY_DEF; |
71cb2764 | 1812 | sd->jpegqual = 80; |
cebf3b67 | 1813 | |
6a7eba24 JFM |
1814 | return 0; |
1815 | } | |
1816 | ||
012d6b02 JFM |
1817 | /* this function is called at probe and resume time */ |
1818 | static int sd_init(struct gspca_dev *gspca_dev) | |
6a7eba24 JFM |
1819 | { |
1820 | struct sd *sd = (struct sd *) gspca_dev; | |
d5aa3856 | 1821 | const u8 *sn9c1xx; |
19697b54 | 1822 | u8 regGpio[] = { 0x29, 0x74 }; /* with audio */ |
98819187 | 1823 | u8 regF1; |
6a7eba24 | 1824 | |
3647fea8 | 1825 | /* setup a selector by bridge */ |
60017617 | 1826 | reg_w1(gspca_dev, 0xf1, 0x01); |
739570bb | 1827 | reg_r(gspca_dev, 0x00, 1); |
8f47a3ce JFM |
1828 | reg_w1(gspca_dev, 0xf1, gspca_dev->usb_buf[0]); |
1829 | reg_r(gspca_dev, 0x00, 1); /* get sonix chip id */ | |
739570bb | 1830 | regF1 = gspca_dev->usb_buf[0]; |
8f47a3ce | 1831 | PDEBUG(D_PROBE, "Sonix chip id: %02x", regF1); |
3647fea8 HG |
1832 | switch (sd->bridge) { |
1833 | case BRIDGE_SN9C102P: | |
6a7eba24 JFM |
1834 | if (regF1 != 0x11) |
1835 | return -ENODEV; | |
60017617 | 1836 | reg_w1(gspca_dev, 0x02, regGpio[1]); |
6a7eba24 | 1837 | break; |
3647fea8 | 1838 | case BRIDGE_SN9C105: |
6a7eba24 JFM |
1839 | if (regF1 != 0x11) |
1840 | return -ENODEV; | |
65c5259c JFM |
1841 | if (sd->sensor == SENSOR_MI0360) |
1842 | mi0360_probe(gspca_dev); | |
674cbc69 | 1843 | reg_w(gspca_dev, 0x01, regGpio, 2); |
6a7eba24 | 1844 | break; |
3647fea8 | 1845 | case BRIDGE_SN9C120: |
6a7eba24 JFM |
1846 | if (regF1 != 0x12) |
1847 | return -ENODEV; | |
b8c8a5bf JFM |
1848 | switch (sd->sensor) { |
1849 | case SENSOR_MI0360: | |
65c5259c | 1850 | mi0360_probe(gspca_dev); |
b8c8a5bf | 1851 | break; |
03ed2a11 JFM |
1852 | case SENSOR_OV7630: |
1853 | ov7630_probe(gspca_dev); | |
1854 | break; | |
b8c8a5bf JFM |
1855 | case SENSOR_OV7648: |
1856 | ov7648_probe(gspca_dev); | |
1857 | break; | |
ad98c0f6 JFM |
1858 | case SENSOR_PO2030N: |
1859 | po2030n_probe(gspca_dev); | |
1860 | break; | |
b8c8a5bf | 1861 | } |
19697b54 | 1862 | regGpio[1] = 0x70; /* no audio */ |
674cbc69 | 1863 | reg_w(gspca_dev, 0x01, regGpio, 2); |
6a7eba24 JFM |
1864 | break; |
1865 | default: | |
60017617 | 1866 | /* case BRIDGE_SN9C110: */ |
3647fea8 | 1867 | /* case BRIDGE_SN9C325: */ |
6a7eba24 JFM |
1868 | if (regF1 != 0x12) |
1869 | return -ENODEV; | |
60017617 | 1870 | reg_w1(gspca_dev, 0x02, 0x62); |
6a7eba24 JFM |
1871 | break; |
1872 | } | |
1873 | ||
9712a8be HG |
1874 | /* Note we do not disable the sensor clock here (power saving mode), |
1875 | as that also disables the button on the cam. */ | |
1876 | reg_w1(gspca_dev, 0xf1, 0x00); | |
6a7eba24 | 1877 | |
d5aa3856 JFM |
1878 | /* set the i2c address */ |
1879 | sn9c1xx = sn_tb[sd->sensor]; | |
1880 | sd->i2c_addr = sn9c1xx[9]; | |
1881 | ||
b8c8a5bf JFM |
1882 | gspca_dev->ctrl_dis = ctrl_dis[sd->sensor]; |
1883 | ||
6a7eba24 JFM |
1884 | return 0; |
1885 | } | |
1886 | ||
98819187 JFM |
1887 | static u32 setexposure(struct gspca_dev *gspca_dev, |
1888 | u32 expo) | |
6a7eba24 JFM |
1889 | { |
1890 | struct sd *sd = (struct sd *) gspca_dev; | |
6a7eba24 JFM |
1891 | |
1892 | switch (sd->sensor) { | |
c26b12d0 JFM |
1893 | case SENSOR_GC0307: { |
1894 | int a, b; | |
1895 | ||
1896 | /* expo = 0..255 -> a = 19..43 */ | |
1897 | a = 19 + expo * 25 / 256; | |
1898 | i2c_w1(gspca_dev, 0x68, a); | |
1899 | a -= 12; | |
1900 | b = a * a * 4; /* heuristic */ | |
1901 | i2c_w1(gspca_dev, 0x03, b >> 8); | |
1902 | i2c_w1(gspca_dev, 0x04, b); | |
1903 | break; | |
1904 | } | |
6a7eba24 | 1905 | case SENSOR_HV7131R: { |
98819187 | 1906 | u8 Expodoit[] = |
d5aa3856 | 1907 | { 0xc1, 0x11, 0x25, 0x00, 0x00, 0x00, 0x00, 0x16 }; |
6a7eba24 JFM |
1908 | |
1909 | Expodoit[3] = expo >> 16; | |
1910 | Expodoit[4] = expo >> 8; | |
1911 | Expodoit[5] = expo; | |
739570bb | 1912 | i2c_w8(gspca_dev, Expodoit); |
6a7eba24 JFM |
1913 | break; |
1914 | } | |
1915 | case SENSOR_MI0360: { | |
3ef2c5be | 1916 | u8 expoMi[] = /* exposure 0x0635 -> 4 fp/s 0x10 */ |
d5aa3856 | 1917 | { 0xb1, 0x5d, 0x09, 0x00, 0x00, 0x00, 0x00, 0x16 }; |
98819187 JFM |
1918 | static const u8 doit[] = /* update sensor */ |
1919 | { 0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10 }; | |
1920 | static const u8 sensorgo[] = /* sensor on */ | |
1921 | { 0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10 }; | |
6a7eba24 JFM |
1922 | |
1923 | if (expo > 0x0635) | |
1924 | expo = 0x0635; | |
1925 | else if (expo < 0x0001) | |
1926 | expo = 0x0001; | |
1927 | expoMi[3] = expo >> 8; | |
1928 | expoMi[4] = expo; | |
739570bb JFM |
1929 | i2c_w8(gspca_dev, expoMi); |
1930 | i2c_w8(gspca_dev, doit); | |
1931 | i2c_w8(gspca_dev, sensorgo); | |
6a7eba24 JFM |
1932 | break; |
1933 | } | |
1934 | case SENSOR_MO4000: { | |
98819187 | 1935 | u8 expoMof[] = |
d5aa3856 | 1936 | { 0xa1, 0x21, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x10 }; |
98819187 | 1937 | u8 expoMo10[] = |
d5aa3856 | 1938 | { 0xa1, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10 }; |
98819187 JFM |
1939 | static const u8 gainMo[] = |
1940 | { 0xa1, 0x21, 0x00, 0x10, 0x00, 0x00, 0x00, 0x1d }; | |
6a7eba24 JFM |
1941 | |
1942 | if (expo > 0x1fff) | |
1943 | expo = 0x1fff; | |
1944 | else if (expo < 0x0001) | |
1945 | expo = 0x0001; | |
1946 | expoMof[3] = (expo & 0x03fc) >> 2; | |
739570bb | 1947 | i2c_w8(gspca_dev, expoMof); |
6a7eba24 JFM |
1948 | expoMo10[3] = ((expo & 0x1c00) >> 10) |
1949 | | ((expo & 0x0003) << 4); | |
739570bb JFM |
1950 | i2c_w8(gspca_dev, expoMo10); |
1951 | i2c_w8(gspca_dev, gainMo); | |
3ef2c5be | 1952 | PDEBUG(D_FRAM, "set exposure %d", |
6a7eba24 JFM |
1953 | ((expoMo10[3] & 0x07) << 10) |
1954 | | (expoMof[3] << 2) | |
1955 | | ((expoMo10[3] & 0x30) >> 4)); | |
1956 | break; | |
1957 | } | |
3ef2c5be JFM |
1958 | case SENSOR_MT9V111: { |
1959 | u8 expo_c1[] = | |
1960 | { 0xb1, 0x5c, 0x09, 0x00, 0x00, 0x00, 0x00, 0x10 }; | |
1961 | ||
1962 | if (expo > 0x0280) | |
1963 | expo = 0x0280; | |
1964 | else if (expo < 0x0040) | |
1965 | expo = 0x0040; | |
1966 | expo_c1[3] = expo >> 8; | |
1967 | expo_c1[4] = expo; | |
1968 | i2c_w8(gspca_dev, expo_c1); | |
1969 | break; | |
1970 | } | |
d2d16e90 | 1971 | case SENSOR_OM6802: { |
98819187 | 1972 | u8 gainOm[] = |
d2d16e90 | 1973 | { 0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10 }; |
d5aa3856 | 1974 | /* preset AGC - works when AutoExpo = off */ |
d2d16e90 JFM |
1975 | |
1976 | if (expo > 0x03ff) | |
1977 | expo = 0x03ff; | |
1978 | if (expo < 0x0001) | |
1979 | expo = 0x0001; | |
1980 | gainOm[3] = expo >> 2; | |
1981 | i2c_w8(gspca_dev, gainOm); | |
d5aa3856 | 1982 | reg_w1(gspca_dev, 0x96, expo >> 5); |
3ef2c5be | 1983 | PDEBUG(D_FRAM, "set exposure %d", gainOm[3]); |
d2d16e90 JFM |
1984 | break; |
1985 | } | |
6a7eba24 JFM |
1986 | } |
1987 | return expo; | |
1988 | } | |
1989 | ||
1990 | static void setbrightness(struct gspca_dev *gspca_dev) | |
1991 | { | |
1992 | struct sd *sd = (struct sd *) gspca_dev; | |
1993 | unsigned int expo; | |
98819187 | 1994 | u8 k2; |
6a7eba24 | 1995 | |
b1b056a5 | 1996 | k2 = ((int) sd->brightness - 0x8000) >> 10; |
6a7eba24 | 1997 | switch (sd->sensor) { |
64677573 | 1998 | case SENSOR_ADCM1700: |
878b35ae JFM |
1999 | if (k2 > 0x1f) |
2000 | k2 = 0; /* only positive Y offset */ | |
2001 | break; | |
6a7eba24 JFM |
2002 | case SENSOR_HV7131R: |
2003 | expo = sd->brightness << 4; | |
2004 | if (expo > 0x002dc6c0) | |
2005 | expo = 0x002dc6c0; | |
2006 | else if (expo < 0x02a0) | |
2007 | expo = 0x02a0; | |
2008 | sd->exposure = setexposure(gspca_dev, expo); | |
2009 | break; | |
2010 | case SENSOR_MI0360: | |
6a7eba24 JFM |
2011 | case SENSOR_MO4000: |
2012 | expo = sd->brightness >> 4; | |
2013 | sd->exposure = setexposure(gspca_dev, expo); | |
2014 | break; | |
c26b12d0 | 2015 | case SENSOR_GC0307: |
3ef2c5be JFM |
2016 | case SENSOR_MT9V111: |
2017 | expo = sd->brightness >> 8; | |
2018 | sd->exposure = setexposure(gspca_dev, expo); | |
d5aa3856 | 2019 | return; /* don't set the Y offset */ |
d2d16e90 JFM |
2020 | case SENSOR_OM6802: |
2021 | expo = sd->brightness >> 6; | |
2022 | sd->exposure = setexposure(gspca_dev, expo); | |
b1b056a5 | 2023 | k2 = sd->brightness >> 11; |
d2d16e90 | 2024 | break; |
6a7eba24 JFM |
2025 | } |
2026 | ||
d5aa3856 | 2027 | reg_w1(gspca_dev, 0x96, k2); /* color matrix Y offset */ |
6a7eba24 JFM |
2028 | } |
2029 | ||
2030 | static void setcontrast(struct gspca_dev *gspca_dev) | |
2031 | { | |
2032 | struct sd *sd = (struct sd *) gspca_dev; | |
98819187 JFM |
2033 | u8 k2; |
2034 | u8 contrast[6]; | |
6a7eba24 | 2035 | |
91bd3412 JFM |
2036 | k2 = sd->contrast * 0x30 / (CONTRAST_MAX + 1) + 0x10; /* 10..40 */ |
2037 | contrast[0] = (k2 + 1) / 2; /* red */ | |
577cbf49 | 2038 | contrast[1] = 0; |
91bd3412 | 2039 | contrast[2] = k2; /* green */ |
577cbf49 | 2040 | contrast[3] = 0; |
91bd3412 | 2041 | contrast[4] = (k2 + 1) / 5; /* blue */ |
577cbf49 JFM |
2042 | contrast[5] = 0; |
2043 | reg_w(gspca_dev, 0x84, contrast, sizeof contrast); | |
6a7eba24 JFM |
2044 | } |
2045 | ||
2046 | static void setcolors(struct gspca_dev *gspca_dev) | |
2047 | { | |
2048 | struct sd *sd = (struct sd *) gspca_dev; | |
403123d2 | 2049 | int i, v; |
98819187 | 2050 | u8 reg8a[12]; /* U & V gains */ |
9c33afc6 | 2051 | static const s16 uv[6] = { /* same as reg84 in signed decimal */ |
403123d2 JFM |
2052 | -24, -38, 64, /* UR UG UB */ |
2053 | 62, -51, -9 /* VR VG VB */ | |
2054 | }; | |
d5aa3856 | 2055 | |
403123d2 JFM |
2056 | for (i = 0; i < 6; i++) { |
2057 | v = uv[i] * sd->colors / COLOR_DEF; | |
bd088835 JFM |
2058 | reg8a[i * 2] = v; |
2059 | reg8a[i * 2 + 1] = (v >> 8) & 0x0f; | |
d55b83d3 | 2060 | } |
bd088835 | 2061 | reg_w(gspca_dev, 0x8a, reg8a, sizeof reg8a); |
403123d2 JFM |
2062 | } |
2063 | ||
2064 | static void setredblue(struct gspca_dev *gspca_dev) | |
2065 | { | |
2066 | struct sd *sd = (struct sd *) gspca_dev; | |
2067 | ||
2068 | reg_w1(gspca_dev, 0x05, sd->red); | |
9c5f70f2 | 2069 | /* reg_w1(gspca_dev, 0x07, 32); */ |
403123d2 | 2070 | reg_w1(gspca_dev, 0x06, sd->blue); |
6a7eba24 JFM |
2071 | } |
2072 | ||
592f4eb9 JFM |
2073 | static void setgamma(struct gspca_dev *gspca_dev) |
2074 | { | |
2075 | struct sd *sd = (struct sd *) gspca_dev; | |
2076 | int i; | |
2077 | u8 gamma[17]; | |
b083b92f | 2078 | const u8 *gamma_base; |
592f4eb9 JFM |
2079 | static const u8 delta[17] = { |
2080 | 0x00, 0x14, 0x1c, 0x1c, 0x1c, 0x1c, 0x1b, 0x1a, | |
2081 | 0x18, 0x13, 0x10, 0x0e, 0x08, 0x07, 0x04, 0x02, 0x00 | |
2082 | }; | |
2083 | ||
b083b92f | 2084 | switch (sd->sensor) { |
64677573 JFM |
2085 | case SENSOR_ADCM1700: |
2086 | gamma_base = gamma_spec_0; | |
2087 | break; | |
b083b92f JFM |
2088 | case SENSOR_HV7131R: |
2089 | case SENSOR_MT9V111: | |
2090 | gamma_base = gamma_spec_1; | |
2091 | break; | |
ad98c0f6 | 2092 | case SENSOR_GC0307: |
b083b92f JFM |
2093 | gamma_base = gamma_spec_2; |
2094 | break; | |
ad98c0f6 JFM |
2095 | case SENSOR_SP80708: |
2096 | gamma_base = gamma_spec_3; | |
2097 | break; | |
b083b92f JFM |
2098 | default: |
2099 | gamma_base = gamma_def; | |
2100 | break; | |
2101 | } | |
5e31dc8d | 2102 | |
592f4eb9 | 2103 | for (i = 0; i < sizeof gamma; i++) |
b083b92f | 2104 | gamma[i] = gamma_base[i] |
592f4eb9 JFM |
2105 | + delta[i] * (sd->gamma - GAMMA_DEF) / 32; |
2106 | reg_w(gspca_dev, 0x20, gamma, sizeof gamma); | |
2107 | } | |
2108 | ||
cebf3b67 JFM |
2109 | static void setautogain(struct gspca_dev *gspca_dev) |
2110 | { | |
2111 | struct sd *sd = (struct sd *) gspca_dev; | |
2112 | ||
f50ba1be JFM |
2113 | if (gspca_dev->ctrl_dis & (1 << AUTOGAIN_IDX)) |
2114 | return; | |
2797ba2a JFM |
2115 | switch (sd->sensor) { |
2116 | case SENSOR_OV7630: | |
2117 | case SENSOR_OV7648: { | |
2118 | u8 comb; | |
2119 | ||
2120 | if (sd->sensor == SENSOR_OV7630) | |
2121 | comb = 0xc0; | |
2122 | else | |
2123 | comb = 0xa0; | |
2124 | if (sd->autogain) | |
1fec747c | 2125 | comb |= 0x03; |
2797ba2a JFM |
2126 | i2c_w1(&sd->gspca_dev, 0x13, comb); |
2127 | return; | |
2128 | } | |
2129 | } | |
f50ba1be JFM |
2130 | if (sd->autogain) |
2131 | sd->ag_cnt = AG_CNT_START; | |
2132 | else | |
2133 | sd->ag_cnt = -1; | |
cebf3b67 JFM |
2134 | } |
2135 | ||
f6b22e5e | 2136 | /* hv7131r/ov7630/ov7648 only */ |
6c86274f JFM |
2137 | static void setvflip(struct sd *sd) |
2138 | { | |
2797ba2a JFM |
2139 | u8 comn; |
2140 | ||
0939e266 JFM |
2141 | if (sd->gspca_dev.ctrl_dis & (1 << VFLIP_IDX)) |
2142 | return; | |
f6b22e5e JFM |
2143 | switch (sd->sensor) { |
2144 | case SENSOR_HV7131R: | |
2145 | comn = 0x18; /* clkdiv = 1, ablcen = 1 */ | |
2146 | if (sd->vflip) | |
2147 | comn |= 0x01; | |
2148 | i2c_w1(&sd->gspca_dev, 0x01, comn); /* sctra */ | |
2149 | break; | |
2150 | case SENSOR_OV7630: | |
2797ba2a | 2151 | comn = 0x02; |
f800952c HG |
2152 | if (!sd->vflip) |
2153 | comn |= 0x80; | |
f6b22e5e JFM |
2154 | i2c_w1(&sd->gspca_dev, 0x75, comn); |
2155 | break; | |
2156 | default: | |
2157 | /* case SENSOR_OV7648: */ | |
2797ba2a | 2158 | comn = 0x06; |
f800952c HG |
2159 | if (sd->vflip) |
2160 | comn |= 0x80; | |
f6b22e5e JFM |
2161 | i2c_w1(&sd->gspca_dev, 0x75, comn); |
2162 | break; | |
f800952c | 2163 | } |
6c86274f JFM |
2164 | } |
2165 | ||
878b35ae JFM |
2166 | static void setsharpness(struct sd *sd) |
2167 | { | |
2168 | reg_w1(&sd->gspca_dev, 0x99, sd->sharpness); | |
2169 | } | |
2170 | ||
0cae8964 JFM |
2171 | static void setinfrared(struct sd *sd) |
2172 | { | |
47f7f6fb JFM |
2173 | if (sd->gspca_dev.ctrl_dis & (1 << INFRARED_IDX)) |
2174 | return; | |
0cae8964 JFM |
2175 | /*fixme: different sequence for StarCam Clip and StarCam 370i */ |
2176 | /* Clip */ | |
2177 | i2c_w1(&sd->gspca_dev, 0x02, /* gpio */ | |
2178 | sd->infrared ? 0x66 : 0x64); | |
2179 | } | |
2180 | ||
37c6dbe2 HG |
2181 | static void setfreq(struct gspca_dev *gspca_dev) |
2182 | { | |
2183 | struct sd *sd = (struct sd *) gspca_dev; | |
2184 | ||
27954930 JFM |
2185 | if (gspca_dev->ctrl_dis & (1 << FREQ_IDX)) |
2186 | return; | |
37c6dbe2 | 2187 | if (sd->sensor == SENSOR_OV7660) { |
d8f400ef JFM |
2188 | u8 com8; |
2189 | ||
47f7f6fb | 2190 | com8 = 0xdf; /* auto gain/wb/expo */ |
37c6dbe2 HG |
2191 | switch (sd->freq) { |
2192 | case 0: /* Banding filter disabled */ | |
47f7f6fb | 2193 | i2c_w1(gspca_dev, 0x13, com8 | 0x20); |
37c6dbe2 HG |
2194 | break; |
2195 | case 1: /* 50 hz */ | |
d8f400ef | 2196 | i2c_w1(gspca_dev, 0x13, com8); |
37c6dbe2 HG |
2197 | i2c_w1(gspca_dev, 0x3b, 0x0a); |
2198 | break; | |
2199 | case 2: /* 60 hz */ | |
d8f400ef | 2200 | i2c_w1(gspca_dev, 0x13, com8); |
37c6dbe2 HG |
2201 | i2c_w1(gspca_dev, 0x3b, 0x02); |
2202 | break; | |
2203 | } | |
2204 | } else { | |
2205 | u8 reg2a = 0, reg2b = 0, reg2d = 0; | |
2206 | ||
2207 | /* Get reg2a / reg2d base values */ | |
2208 | switch (sd->sensor) { | |
2209 | case SENSOR_OV7630: | |
2210 | reg2a = 0x08; | |
2211 | reg2d = 0x01; | |
2212 | break; | |
2213 | case SENSOR_OV7648: | |
2214 | reg2a = 0x11; | |
2215 | reg2d = 0x81; | |
2216 | break; | |
2217 | } | |
2218 | ||
2219 | switch (sd->freq) { | |
2220 | case 0: /* Banding filter disabled */ | |
2221 | break; | |
2222 | case 1: /* 50 hz (filter on and framerate adj) */ | |
2223 | reg2a |= 0x80; | |
2224 | reg2b = 0xac; | |
2225 | reg2d |= 0x04; | |
2226 | break; | |
2227 | case 2: /* 60 hz (filter on, no framerate adj) */ | |
2228 | reg2a |= 0x80; | |
2229 | reg2d |= 0x04; | |
2230 | break; | |
2231 | } | |
2232 | i2c_w1(gspca_dev, 0x2a, reg2a); | |
2233 | i2c_w1(gspca_dev, 0x2b, reg2b); | |
2234 | i2c_w1(gspca_dev, 0x2d, reg2d); | |
2235 | } | |
2236 | } | |
2237 | ||
71cb2764 JFM |
2238 | static void setjpegqual(struct gspca_dev *gspca_dev) |
2239 | { | |
2240 | struct sd *sd = (struct sd *) gspca_dev; | |
2241 | int i, sc; | |
2242 | ||
2243 | if (sd->jpegqual < 50) | |
2244 | sc = 5000 / sd->jpegqual; | |
2245 | else | |
2246 | sc = 200 - sd->jpegqual * 2; | |
2247 | #if USB_BUF_SZ < 64 | |
2248 | #error "No room enough in usb_buf for quantization table" | |
2249 | #endif | |
2250 | for (i = 0; i < 64; i++) | |
2251 | gspca_dev->usb_buf[i] = | |
2252 | (jpeg_head[JPEG_QT0_OFFSET + i] * sc + 50) / 100; | |
2253 | usb_control_msg(gspca_dev->dev, | |
2254 | usb_sndctrlpipe(gspca_dev->dev, 0), | |
2255 | 0x08, | |
2256 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, | |
2257 | 0x0100, 0, | |
2258 | gspca_dev->usb_buf, 64, | |
2259 | 500); | |
2260 | for (i = 0; i < 64; i++) | |
2261 | gspca_dev->usb_buf[i] = | |
2262 | (jpeg_head[JPEG_QT1_OFFSET + i] * sc + 50) / 100; | |
2263 | usb_control_msg(gspca_dev->dev, | |
2264 | usb_sndctrlpipe(gspca_dev->dev, 0), | |
2265 | 0x08, | |
2266 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, | |
2267 | 0x0140, 0, | |
2268 | gspca_dev->usb_buf, 64, | |
2269 | 500); | |
2270 | ||
2271 | sd->reg18 ^= 0x40; | |
2272 | reg_w1(gspca_dev, 0x18, sd->reg18); | |
2273 | } | |
2274 | ||
6a7eba24 | 2275 | /* -- start the camera -- */ |
72ab97ce | 2276 | static int sd_start(struct gspca_dev *gspca_dev) |
6a7eba24 JFM |
2277 | { |
2278 | struct sd *sd = (struct sd *) gspca_dev; | |
6a7eba24 | 2279 | int i; |
19697b54 | 2280 | u8 reg1, reg17; |
98819187 | 2281 | const u8 *sn9c1xx; |
3fccb774 | 2282 | const u8 (*init)[8]; |
6a7eba24 | 2283 | int mode; |
98819187 JFM |
2284 | static const u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f }; |
2285 | static const u8 CA[] = { 0x28, 0xd8, 0x14, 0xec }; | |
64677573 JFM |
2286 | static const u8 CA_adcm1700[] = |
2287 | { 0x14, 0xec, 0x0a, 0xf6 }; | |
ad98c0f6 JFM |
2288 | static const u8 CA_po2030n[] = |
2289 | { 0x1e, 0xe2, 0x14, 0xec }; | |
98819187 | 2290 | static const u8 CE[] = { 0x32, 0xdd, 0x2d, 0xdd }; /* MI0360 */ |
ad98c0f6 JFM |
2291 | static const u8 CE_gc0307[] = |
2292 | { 0x32, 0xce, 0x2d, 0xd3 }; | |
98819187 | 2293 | static const u8 CE_ov76xx[] = |
674cbc69 | 2294 | { 0x32, 0xdd, 0x32, 0xdd }; |
ad98c0f6 JFM |
2295 | static const u8 CE_po2030n[] = |
2296 | { 0x14, 0xe7, 0x1e, 0xdd }; | |
6a7eba24 | 2297 | |
71cb2764 | 2298 | /* create the JPEG header */ |
71cb2764 JFM |
2299 | jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width, |
2300 | 0x21); /* JPEG 422 */ | |
2301 | jpeg_set_qual(sd->jpeg_hdr, sd->quality); | |
2302 | ||
3fccb774 JFM |
2303 | /* initialize the bridge */ |
2304 | sn9c1xx = sn_tb[sd->sensor]; | |
2305 | bridge_init(gspca_dev, sn9c1xx); | |
d5aa3856 | 2306 | |
3fccb774 JFM |
2307 | /* initialize the sensor */ |
2308 | i2c_w_seq(gspca_dev, sensor_init[sd->sensor]); | |
2309 | ||
60017617 JFM |
2310 | reg_w1(gspca_dev, 0x15, sn9c1xx[0x15]); |
2311 | reg_w1(gspca_dev, 0x16, sn9c1xx[0x16]); | |
2312 | reg_w1(gspca_dev, 0x12, sn9c1xx[0x12]); | |
2313 | reg_w1(gspca_dev, 0x13, sn9c1xx[0x13]); | |
2314 | reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]); | |
64677573 | 2315 | if (sd->sensor == SENSOR_ADCM1700) { |
878b35ae JFM |
2316 | reg_w1(gspca_dev, 0xd2, 0x3a); /* AE_H_SIZE = 116 */ |
2317 | reg_w1(gspca_dev, 0xd3, 0x30); /* AE_V_SIZE = 96 */ | |
64677573 | 2318 | } else { |
878b35ae JFM |
2319 | reg_w1(gspca_dev, 0xd2, 0x6a); /* AE_H_SIZE = 212 */ |
2320 | reg_w1(gspca_dev, 0xd3, 0x50); /* AE_V_SIZE = 160 */ | |
64677573 | 2321 | } |
60017617 JFM |
2322 | reg_w1(gspca_dev, 0xc6, 0x00); |
2323 | reg_w1(gspca_dev, 0xc7, 0x00); | |
64677573 | 2324 | if (sd->sensor == SENSOR_ADCM1700) { |
878b35ae JFM |
2325 | reg_w1(gspca_dev, 0xc8, 0x2c); /* AW_H_STOP = 352 */ |
2326 | reg_w1(gspca_dev, 0xc9, 0x24); /* AW_V_STOP = 288 */ | |
64677573 | 2327 | } else { |
878b35ae JFM |
2328 | reg_w1(gspca_dev, 0xc8, 0x50); /* AW_H_STOP = 640 */ |
2329 | reg_w1(gspca_dev, 0xc9, 0x3c); /* AW_V_STOP = 480 */ | |
64677573 | 2330 | } |
60017617 | 2331 | reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]); |
6ab0b174 | 2332 | switch (sd->sensor) { |
ad98c0f6 JFM |
2333 | case SENSOR_GC0307: |
2334 | reg17 = 0xa2; | |
2335 | break; | |
3ef2c5be JFM |
2336 | case SENSOR_MT9V111: |
2337 | reg17 = 0xe0; | |
2338 | break; | |
64677573 | 2339 | case SENSOR_ADCM1700: |
6ab0b174 JFM |
2340 | case SENSOR_OV7630: |
2341 | reg17 = 0xe2; | |
2342 | break; | |
2343 | case SENSOR_OV7648: | |
6270330a | 2344 | reg17 = 0x20; |
568788a7 | 2345 | break; |
6ab0b174 | 2346 | case SENSOR_OV7660: |
03ed2a11 | 2347 | case SENSOR_SOI768: |
c8b9b2ca JFM |
2348 | reg17 = 0xa0; |
2349 | break; | |
b8c8a5bf | 2350 | case SENSOR_PO1030: |
ad98c0f6 | 2351 | case SENSOR_PO2030N: |
b8c8a5bf JFM |
2352 | reg17 = 0xa0; |
2353 | break; | |
568788a7 | 2354 | default: |
8f47a3ce | 2355 | reg17 = 0x60; |
568788a7 JFM |
2356 | break; |
2357 | } | |
8f47a3ce | 2358 | reg_w1(gspca_dev, 0x17, reg17); |
878b35ae JFM |
2359 | |
2360 | reg_w1(gspca_dev, 0x05, 0x00); /* red */ | |
2361 | reg_w1(gspca_dev, 0x07, 0x00); /* green */ | |
2362 | reg_w1(gspca_dev, 0x06, 0x00); /* blue */ | |
60017617 | 2363 | reg_w1(gspca_dev, 0x14, sn9c1xx[0x14]); |
b083b92f | 2364 | |
5e31dc8d JFM |
2365 | setgamma(gspca_dev); |
2366 | ||
878b35ae | 2367 | /*fixme: 8 times with all zeroes and 1 or 2 times with normal values */ |
05b809c7 JFM |
2368 | for (i = 0; i < 8; i++) |
2369 | reg_w(gspca_dev, 0x84, reg84, sizeof reg84); | |
674cbc69 | 2370 | switch (sd->sensor) { |
64677573 | 2371 | case SENSOR_ADCM1700: |
878b35ae JFM |
2372 | case SENSOR_OV7660: |
2373 | case SENSOR_SP80708: | |
64677573 | 2374 | reg_w1(gspca_dev, 0x9a, 0x05); |
64677573 | 2375 | break; |
ad98c0f6 | 2376 | case SENSOR_GC0307: |
3ef2c5be JFM |
2377 | case SENSOR_MT9V111: |
2378 | reg_w1(gspca_dev, 0x9a, 0x07); | |
3fccb774 | 2379 | break; |
0a85c74b | 2380 | case SENSOR_OV7630: |
6270330a JFM |
2381 | case SENSOR_OV7648: |
2382 | reg_w1(gspca_dev, 0x9a, 0x0a); | |
5e31dc8d | 2383 | break; |
ad98c0f6 | 2384 | case SENSOR_PO2030N: |
03ed2a11 | 2385 | case SENSOR_SOI768: |
ad98c0f6 JFM |
2386 | reg_w1(gspca_dev, 0x9a, 0x06); |
2387 | break; | |
674cbc69 | 2388 | default: |
60017617 | 2389 | reg_w1(gspca_dev, 0x9a, 0x08); |
674cbc69 JFM |
2390 | break; |
2391 | } | |
878b35ae | 2392 | setsharpness(sd); |
6a7eba24 | 2393 | |
3fccb774 | 2394 | reg_w(gspca_dev, 0x84, reg84, sizeof reg84); |
878b35ae JFM |
2395 | reg_w1(gspca_dev, 0x05, 0x20); /* red */ |
2396 | reg_w1(gspca_dev, 0x07, 0x20); /* green */ | |
2397 | reg_w1(gspca_dev, 0x06, 0x20); /* blue */ | |
23a98274 | 2398 | |
3fccb774 | 2399 | init = NULL; |
d5aa3856 | 2400 | mode = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv; |
60017617 | 2401 | if (mode) |
1432f306 | 2402 | reg1 = 0x46; /* 320x240: clk 48Mhz, video trf enable */ |
60017617 | 2403 | else |
1432f306 JFM |
2404 | reg1 = 0x06; /* 640x480: clk 24Mhz, video trf enable */ |
2405 | reg17 = 0x61; /* 0x:20: enable sensor clock */ | |
6a7eba24 | 2406 | switch (sd->sensor) { |
64677573 JFM |
2407 | case SENSOR_ADCM1700: |
2408 | init = adcm1700_sensor_param1; | |
2409 | reg1 = 0x46; | |
2410 | reg17 = 0xe2; | |
2411 | break; | |
ad98c0f6 JFM |
2412 | case SENSOR_GC0307: |
2413 | init = gc0307_sensor_param1; | |
2414 | reg17 = 0xa2; | |
2415 | reg1 = 0x44; | |
2416 | break; | |
6a7eba24 | 2417 | case SENSOR_MO4000: |
6a7eba24 JFM |
2418 | if (mode) { |
2419 | /* reg1 = 0x46; * 320 clk 48Mhz 60fp/s */ | |
2420 | reg1 = 0x06; /* clk 24Mz */ | |
2421 | } else { | |
2422 | reg17 = 0x22; /* 640 MCKSIZE */ | |
60017617 | 2423 | /* reg1 = 0x06; * 640 clk 24Mz (done) */ |
6a7eba24 JFM |
2424 | } |
2425 | break; | |
3ef2c5be | 2426 | case SENSOR_MT9V111: |
3fccb774 | 2427 | init = mt9v111_sensor_param1; |
3ef2c5be JFM |
2428 | if (mode) { |
2429 | reg1 = 0x04; /* 320 clk 48Mhz */ | |
2430 | } else { | |
2431 | /* reg1 = 0x06; * 640 clk 24Mz (done) */ | |
2687a2fb | 2432 | reg17 = 0xc2; |
3ef2c5be | 2433 | } |
0fbe0574 | 2434 | break; |
d2d16e90 | 2435 | case SENSOR_OM6802: |
3fccb774 | 2436 | init = om6802_sensor_param1; |
d2d16e90 JFM |
2437 | reg17 = 0x64; /* 640 MCKSIZE */ |
2438 | break; | |
6ab0b174 | 2439 | case SENSOR_OV7630: |
bdd2b93c | 2440 | init = ov7630_sensor_param1; |
6ab0b174 | 2441 | reg17 = 0xe2; |
5b064da8 | 2442 | reg1 = 0x44; |
6ab0b174 | 2443 | break; |
6a7eba24 | 2444 | case SENSOR_OV7648: |
3fccb774 | 2445 | init = ov7648_sensor_param1; |
6270330a JFM |
2446 | reg17 = 0x21; |
2447 | /* reg1 = 0x42; * 42 - 46? */ | |
6a7eba24 | 2448 | break; |
5e31dc8d | 2449 | case SENSOR_OV7660: |
3fccb774 | 2450 | init = ov7660_sensor_param1; |
daa5cb42 JFM |
2451 | if (sd->bridge == BRIDGE_SN9C120) { |
2452 | if (mode) { /* 320x240 - 160x120 */ | |
1432f306 JFM |
2453 | reg17 = 0xa2; |
2454 | reg1 = 0x44; /* 48 Mhz, video trf eneble */ | |
1432f306 | 2455 | } |
daa5cb42 JFM |
2456 | } else { |
2457 | reg17 = 0x22; | |
2458 | reg1 = 0x06; /* 24 Mhz, video trf eneble | |
2459 | * inverse power down */ | |
6a7eba24 JFM |
2460 | } |
2461 | break; | |
b8c8a5bf JFM |
2462 | case SENSOR_PO1030: |
2463 | init = po1030_sensor_param1; | |
2464 | reg17 = 0xa2; | |
2465 | reg1 = 0x44; | |
2466 | break; | |
ad98c0f6 JFM |
2467 | case SENSOR_PO2030N: |
2468 | init = po2030n_sensor_param1; | |
2469 | reg1 = 0x46; | |
2470 | reg17 = 0xa2; | |
2471 | break; | |
03ed2a11 JFM |
2472 | case SENSOR_SOI768: |
2473 | init = soi768_sensor_param1; | |
2474 | reg1 = 0x44; | |
2475 | reg17 = 0xa2; | |
2476 | break; | |
5e31dc8d JFM |
2477 | default: |
2478 | /* case SENSOR_SP80708: */ | |
3fccb774 | 2479 | init = sp80708_sensor_param1; |
5e31dc8d JFM |
2480 | if (mode) { |
2481 | /*?? reg1 = 0x04; * 320 clk 48Mhz */ | |
5e31dc8d JFM |
2482 | } else { |
2483 | reg1 = 0x46; /* 640 clk 48Mz */ | |
2484 | reg17 = 0xa2; | |
2485 | } | |
2486 | break; | |
6a7eba24 | 2487 | } |
3fccb774 JFM |
2488 | |
2489 | /* more sensor initialization - param1 */ | |
2490 | if (init != NULL) { | |
2491 | i2c_w_seq(gspca_dev, init); | |
2492 | /* init = NULL; */ | |
2493 | } | |
2494 | ||
739570bb | 2495 | reg_w(gspca_dev, 0xc0, C0, 6); |
ad98c0f6 JFM |
2496 | switch (sd->sensor) { |
2497 | case SENSOR_ADCM1700: | |
2498 | case SENSOR_GC0307: | |
03ed2a11 | 2499 | case SENSOR_SOI768: |
64677573 | 2500 | reg_w(gspca_dev, 0xca, CA_adcm1700, 4); |
ad98c0f6 JFM |
2501 | break; |
2502 | case SENSOR_PO2030N: | |
2503 | reg_w(gspca_dev, 0xca, CA_po2030n, 4); | |
2504 | break; | |
2505 | default: | |
64677573 | 2506 | reg_w(gspca_dev, 0xca, CA, 4); |
ad98c0f6 JFM |
2507 | break; |
2508 | } | |
6ab0b174 | 2509 | switch (sd->sensor) { |
64677573 | 2510 | case SENSOR_ADCM1700: |
6ab0b174 JFM |
2511 | case SENSOR_OV7630: |
2512 | case SENSOR_OV7648: | |
674cbc69 | 2513 | case SENSOR_OV7660: |
03ed2a11 | 2514 | case SENSOR_SOI768: |
6ab0b174 | 2515 | reg_w(gspca_dev, 0xce, CE_ov76xx, 4); |
6a7eba24 | 2516 | break; |
ad98c0f6 JFM |
2517 | case SENSOR_GC0307: |
2518 | reg_w(gspca_dev, 0xce, CE_gc0307, 4); | |
2519 | break; | |
2520 | case SENSOR_PO2030N: | |
2521 | reg_w(gspca_dev, 0xce, CE_po2030n, 4); | |
2522 | break; | |
6a7eba24 | 2523 | default: |
739570bb | 2524 | reg_w(gspca_dev, 0xce, CE, 4); |
6a7eba24 JFM |
2525 | /* ?? {0x1e, 0xdd, 0x2d, 0xe7} */ |
2526 | break; | |
2527 | } | |
2528 | ||
3fccb774 | 2529 | |
6a7eba24 | 2530 | /* here change size mode 0 -> VGA; 1 -> CIF */ |
71cb2764 JFM |
2531 | sd->reg18 = sn9c1xx[0x18] | (mode << 4) | 0x40; |
2532 | reg_w1(gspca_dev, 0x18, sd->reg18); | |
2533 | setjpegqual(gspca_dev); | |
6a7eba24 | 2534 | |
60017617 | 2535 | reg_w1(gspca_dev, 0x17, reg17); |
1432f306 | 2536 | reg_w1(gspca_dev, 0x01, reg1); |
3fccb774 | 2537 | |
1e5eb113 | 2538 | setvflip(sd); |
91bd3412 JFM |
2539 | setbrightness(gspca_dev); |
2540 | setcontrast(gspca_dev); | |
fff2f708 | 2541 | setcolors(gspca_dev); |
cebf3b67 | 2542 | setautogain(gspca_dev); |
37c6dbe2 | 2543 | setfreq(gspca_dev); |
72ab97ce | 2544 | return 0; |
6a7eba24 JFM |
2545 | } |
2546 | ||
2547 | static void sd_stopN(struct gspca_dev *gspca_dev) | |
2548 | { | |
2549 | struct sd *sd = (struct sd *) gspca_dev; | |
98819187 | 2550 | static const u8 stophv7131[] = |
6a7eba24 | 2551 | { 0xa1, 0x11, 0x02, 0x09, 0x00, 0x00, 0x00, 0x10 }; |
98819187 | 2552 | static const u8 stopmi0360[] = |
6a7eba24 | 2553 | { 0xb1, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10 }; |
98819187 | 2554 | static const u8 stopov7648[] = |
6270330a | 2555 | { 0xa1, 0x21, 0x76, 0x20, 0x00, 0x00, 0x00, 0x10 }; |
03ed2a11 JFM |
2556 | static const u8 stopsoi768[] = |
2557 | { 0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10 }; | |
98819187 JFM |
2558 | u8 data; |
2559 | const u8 *sn9c1xx; | |
6a7eba24 JFM |
2560 | |
2561 | data = 0x0b; | |
2562 | switch (sd->sensor) { | |
ad98c0f6 JFM |
2563 | case SENSOR_GC0307: |
2564 | data = 0x29; | |
2565 | break; | |
6a7eba24 | 2566 | case SENSOR_HV7131R: |
739570bb | 2567 | i2c_w8(gspca_dev, stophv7131); |
6a7eba24 JFM |
2568 | data = 0x2b; |
2569 | break; | |
2570 | case SENSOR_MI0360: | |
739570bb | 2571 | i2c_w8(gspca_dev, stopmi0360); |
6a7eba24 JFM |
2572 | data = 0x29; |
2573 | break; | |
6a7eba24 | 2574 | case SENSOR_OV7648: |
6270330a JFM |
2575 | i2c_w8(gspca_dev, stopov7648); |
2576 | /* fall thru */ | |
3ef2c5be | 2577 | case SENSOR_MT9V111: |
6270330a | 2578 | case SENSOR_OV7630: |
b8c8a5bf | 2579 | case SENSOR_PO1030: |
6a7eba24 JFM |
2580 | data = 0x29; |
2581 | break; | |
03ed2a11 JFM |
2582 | case SENSOR_SOI768: |
2583 | i2c_w8(gspca_dev, stopsoi768); | |
2584 | data = 0x29; | |
2585 | break; | |
6a7eba24 | 2586 | } |
d5aa3856 | 2587 | sn9c1xx = sn_tb[sd->sensor]; |
60017617 JFM |
2588 | reg_w1(gspca_dev, 0x01, sn9c1xx[1]); |
2589 | reg_w1(gspca_dev, 0x17, sn9c1xx[0x17]); | |
2590 | reg_w1(gspca_dev, 0x01, sn9c1xx[1]); | |
2591 | reg_w1(gspca_dev, 0x01, data); | |
9712a8be HG |
2592 | /* Don't disable sensor clock as that disables the button on the cam */ |
2593 | /* reg_w1(gspca_dev, 0xf1, 0x01); */ | |
6a7eba24 JFM |
2594 | } |
2595 | ||
cebf3b67 | 2596 | static void do_autogain(struct gspca_dev *gspca_dev) |
6a7eba24 JFM |
2597 | { |
2598 | struct sd *sd = (struct sd *) gspca_dev; | |
6a7eba24 | 2599 | int delta; |
cebf3b67 | 2600 | int expotimes; |
98819187 JFM |
2601 | u8 luma_mean = 130; |
2602 | u8 luma_delta = 20; | |
6a7eba24 | 2603 | |
cebf3b67 JFM |
2604 | /* Thanks S., without your advice, autobright should not work :) */ |
2605 | if (sd->ag_cnt < 0) | |
2606 | return; | |
2607 | if (--sd->ag_cnt >= 0) | |
2608 | return; | |
2609 | sd->ag_cnt = AG_CNT_START; | |
2610 | ||
2611 | delta = atomic_read(&sd->avg_lum); | |
2612 | PDEBUG(D_FRAM, "mean lum %d", delta); | |
6a7eba24 JFM |
2613 | if (delta < luma_mean - luma_delta || |
2614 | delta > luma_mean + luma_delta) { | |
2615 | switch (sd->sensor) { | |
c26b12d0 JFM |
2616 | case SENSOR_GC0307: |
2617 | expotimes = sd->exposure; | |
2618 | expotimes += (luma_mean - delta) >> 6; | |
2619 | if (expotimes < 0) | |
2620 | expotimes = 0; | |
2621 | sd->exposure = setexposure(gspca_dev, | |
2622 | (unsigned int) expotimes); | |
2623 | break; | |
6a7eba24 JFM |
2624 | case SENSOR_HV7131R: |
2625 | expotimes = sd->exposure >> 8; | |
2626 | expotimes += (luma_mean - delta) >> 4; | |
2627 | if (expotimes < 0) | |
2628 | expotimes = 0; | |
2629 | sd->exposure = setexposure(gspca_dev, | |
2630 | (unsigned int) (expotimes << 8)); | |
2631 | break; | |
46b4f2ab AM |
2632 | case SENSOR_OM6802: |
2633 | expotimes = sd->exposure; | |
2634 | expotimes += (luma_mean - delta) >> 2; | |
2635 | if (expotimes < 0) | |
2636 | expotimes = 0; | |
2637 | sd->exposure = setexposure(gspca_dev, | |
2638 | (unsigned int) expotimes); | |
2639 | setredblue(gspca_dev); | |
2640 | break; | |
cebf3b67 JFM |
2641 | default: |
2642 | /* case SENSOR_MO4000: */ | |
2643 | /* case SENSOR_MI0360: */ | |
3ef2c5be | 2644 | /* case SENSOR_MT9V111: */ |
6a7eba24 JFM |
2645 | expotimes = sd->exposure; |
2646 | expotimes += (luma_mean - delta) >> 6; | |
2647 | if (expotimes < 0) | |
2648 | expotimes = 0; | |
2649 | sd->exposure = setexposure(gspca_dev, | |
2650 | (unsigned int) expotimes); | |
403123d2 | 2651 | setredblue(gspca_dev); |
6a7eba24 JFM |
2652 | break; |
2653 | } | |
2654 | } | |
2655 | } | |
2656 | ||
cebf3b67 JFM |
2657 | /* scan the URB packets */ |
2658 | /* This function is run at interrupt level. */ | |
6a7eba24 | 2659 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, |
98819187 | 2660 | u8 *data, /* isoc packet */ |
6a7eba24 JFM |
2661 | int len) /* iso packet length */ |
2662 | { | |
2663 | struct sd *sd = (struct sd *) gspca_dev; | |
2664 | int sof, avg_lum; | |
2665 | ||
2666 | sof = len - 64; | |
2667 | if (sof >= 0 && data[sof] == 0xff && data[sof + 1] == 0xd9) { | |
2668 | ||
2669 | /* end of frame */ | |
2670 | gspca_frame_add(gspca_dev, LAST_PACKET, | |
76dd272b | 2671 | data, sof + 2); |
6a7eba24 JFM |
2672 | if (sd->ag_cnt < 0) |
2673 | return; | |
6a7eba24 JFM |
2674 | /* w1 w2 w3 */ |
2675 | /* w4 w5 w6 */ | |
2676 | /* w7 w8 */ | |
2677 | /* w4 */ | |
2678 | avg_lum = ((data[sof + 29] << 8) | data[sof + 30]) >> 6; | |
2679 | /* w6 */ | |
2680 | avg_lum += ((data[sof + 33] << 8) | data[sof + 34]) >> 6; | |
2681 | /* w2 */ | |
2682 | avg_lum += ((data[sof + 25] << 8) | data[sof + 26]) >> 6; | |
2683 | /* w8 */ | |
2684 | avg_lum += ((data[sof + 37] << 8) | data[sof + 38]) >> 6; | |
2685 | /* w5 */ | |
2686 | avg_lum += ((data[sof + 31] << 8) | data[sof + 32]) >> 4; | |
2687 | avg_lum >>= 4; | |
cebf3b67 | 2688 | atomic_set(&sd->avg_lum, avg_lum); |
6a7eba24 JFM |
2689 | return; |
2690 | } | |
2691 | if (gspca_dev->last_packet_type == LAST_PACKET) { | |
2692 | ||
2693 | /* put the JPEG 422 header */ | |
76dd272b | 2694 | gspca_frame_add(gspca_dev, FIRST_PACKET, |
71cb2764 | 2695 | sd->jpeg_hdr, JPEG_HDR_SZ); |
6a7eba24 | 2696 | } |
76dd272b | 2697 | gspca_frame_add(gspca_dev, INTER_PACKET, data, len); |
6a7eba24 JFM |
2698 | } |
2699 | ||
6a7eba24 JFM |
2700 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) |
2701 | { | |
2702 | struct sd *sd = (struct sd *) gspca_dev; | |
2703 | ||
2704 | sd->brightness = val; | |
91bd3412 JFM |
2705 | if (gspca_dev->streaming) |
2706 | setbrightness(gspca_dev); | |
6a7eba24 JFM |
2707 | return 0; |
2708 | } | |
2709 | ||
2710 | static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val) | |
2711 | { | |
2712 | struct sd *sd = (struct sd *) gspca_dev; | |
2713 | ||
6a7eba24 JFM |
2714 | *val = sd->brightness; |
2715 | return 0; | |
2716 | } | |
2717 | ||
2718 | static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val) | |
2719 | { | |
2720 | struct sd *sd = (struct sd *) gspca_dev; | |
2721 | ||
2722 | sd->contrast = val; | |
91bd3412 JFM |
2723 | if (gspca_dev->streaming) |
2724 | setcontrast(gspca_dev); | |
6a7eba24 JFM |
2725 | return 0; |
2726 | } | |
2727 | ||
2728 | static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val) | |
2729 | { | |
2730 | struct sd *sd = (struct sd *) gspca_dev; | |
2731 | ||
2732 | *val = sd->contrast; | |
2733 | return 0; | |
2734 | } | |
2735 | ||
2736 | static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val) | |
2737 | { | |
2738 | struct sd *sd = (struct sd *) gspca_dev; | |
2739 | ||
2740 | sd->colors = val; | |
2741 | if (gspca_dev->streaming) | |
2742 | setcolors(gspca_dev); | |
2743 | return 0; | |
2744 | } | |
2745 | ||
2746 | static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val) | |
2747 | { | |
2748 | struct sd *sd = (struct sd *) gspca_dev; | |
2749 | ||
2750 | *val = sd->colors; | |
2751 | return 0; | |
2752 | } | |
2753 | ||
403123d2 JFM |
2754 | static int sd_setblue_balance(struct gspca_dev *gspca_dev, __s32 val) |
2755 | { | |
2756 | struct sd *sd = (struct sd *) gspca_dev; | |
2757 | ||
2758 | sd->blue = val; | |
2759 | if (gspca_dev->streaming) | |
2760 | setredblue(gspca_dev); | |
2761 | return 0; | |
2762 | } | |
2763 | ||
2764 | static int sd_getblue_balance(struct gspca_dev *gspca_dev, __s32 *val) | |
2765 | { | |
2766 | struct sd *sd = (struct sd *) gspca_dev; | |
2767 | ||
2768 | *val = sd->blue; | |
2769 | return 0; | |
2770 | } | |
2771 | ||
2772 | static int sd_setred_balance(struct gspca_dev *gspca_dev, __s32 val) | |
2773 | { | |
2774 | struct sd *sd = (struct sd *) gspca_dev; | |
2775 | ||
2776 | sd->red = val; | |
2777 | if (gspca_dev->streaming) | |
2778 | setredblue(gspca_dev); | |
2779 | return 0; | |
2780 | } | |
2781 | ||
2782 | static int sd_getred_balance(struct gspca_dev *gspca_dev, __s32 *val) | |
2783 | { | |
2784 | struct sd *sd = (struct sd *) gspca_dev; | |
2785 | ||
2786 | *val = sd->red; | |
2787 | return 0; | |
2788 | } | |
2789 | ||
592f4eb9 JFM |
2790 | static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val) |
2791 | { | |
2792 | struct sd *sd = (struct sd *) gspca_dev; | |
2793 | ||
2794 | sd->gamma = val; | |
2795 | if (gspca_dev->streaming) | |
2796 | setgamma(gspca_dev); | |
2797 | return 0; | |
2798 | } | |
2799 | ||
2800 | static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val) | |
2801 | { | |
2802 | struct sd *sd = (struct sd *) gspca_dev; | |
2803 | ||
2804 | *val = sd->gamma; | |
2805 | return 0; | |
2806 | } | |
2807 | ||
6a7eba24 JFM |
2808 | static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val) |
2809 | { | |
2810 | struct sd *sd = (struct sd *) gspca_dev; | |
2811 | ||
2812 | sd->autogain = val; | |
cebf3b67 JFM |
2813 | if (gspca_dev->streaming) |
2814 | setautogain(gspca_dev); | |
6a7eba24 JFM |
2815 | return 0; |
2816 | } | |
2817 | ||
2818 | static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val) | |
2819 | { | |
2820 | struct sd *sd = (struct sd *) gspca_dev; | |
2821 | ||
2822 | *val = sd->autogain; | |
2823 | return 0; | |
2824 | } | |
2825 | ||
878b35ae JFM |
2826 | static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val) |
2827 | { | |
2828 | struct sd *sd = (struct sd *) gspca_dev; | |
2829 | ||
2830 | sd->sharpness = val; | |
2831 | if (gspca_dev->streaming) | |
2832 | setsharpness(sd); | |
2833 | return 0; | |
2834 | } | |
2835 | ||
2836 | static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val) | |
2837 | { | |
2838 | struct sd *sd = (struct sd *) gspca_dev; | |
2839 | ||
2840 | *val = sd->sharpness; | |
2841 | return 0; | |
2842 | } | |
2843 | ||
6c86274f JFM |
2844 | static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val) |
2845 | { | |
2846 | struct sd *sd = (struct sd *) gspca_dev; | |
2847 | ||
2848 | sd->vflip = val; | |
79a9098a JFM |
2849 | if (gspca_dev->streaming) |
2850 | setvflip(sd); | |
6c86274f JFM |
2851 | return 0; |
2852 | } | |
2853 | ||
2854 | static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val) | |
2855 | { | |
2856 | struct sd *sd = (struct sd *) gspca_dev; | |
2857 | ||
2858 | *val = sd->vflip; | |
2859 | return 0; | |
2860 | } | |
2861 | ||
0cae8964 JFM |
2862 | static int sd_setinfrared(struct gspca_dev *gspca_dev, __s32 val) |
2863 | { | |
2864 | struct sd *sd = (struct sd *) gspca_dev; | |
2865 | ||
2866 | sd->infrared = val; | |
2867 | if (gspca_dev->streaming) | |
2868 | setinfrared(sd); | |
2869 | return 0; | |
2870 | } | |
2871 | ||
2872 | static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val) | |
2873 | { | |
2874 | struct sd *sd = (struct sd *) gspca_dev; | |
2875 | ||
2876 | *val = sd->infrared; | |
2877 | return 0; | |
2878 | } | |
2879 | ||
37c6dbe2 HG |
2880 | static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val) |
2881 | { | |
2882 | struct sd *sd = (struct sd *) gspca_dev; | |
2883 | ||
2884 | sd->freq = val; | |
2885 | if (gspca_dev->streaming) | |
2886 | setfreq(gspca_dev); | |
2887 | return 0; | |
2888 | } | |
2889 | ||
2890 | static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val) | |
2891 | { | |
2892 | struct sd *sd = (struct sd *) gspca_dev; | |
2893 | ||
2894 | *val = sd->freq; | |
2895 | return 0; | |
2896 | } | |
2897 | ||
77ac0baf JFM |
2898 | static int sd_set_jcomp(struct gspca_dev *gspca_dev, |
2899 | struct v4l2_jpegcompression *jcomp) | |
2900 | { | |
2901 | struct sd *sd = (struct sd *) gspca_dev; | |
2902 | ||
2903 | if (jcomp->quality < QUALITY_MIN) | |
2904 | sd->quality = QUALITY_MIN; | |
2905 | else if (jcomp->quality > QUALITY_MAX) | |
2906 | sd->quality = QUALITY_MAX; | |
2907 | else | |
2908 | sd->quality = jcomp->quality; | |
2909 | if (gspca_dev->streaming) | |
2910 | jpeg_set_qual(sd->jpeg_hdr, sd->quality); | |
2911 | return 0; | |
2912 | } | |
2913 | ||
2914 | static int sd_get_jcomp(struct gspca_dev *gspca_dev, | |
2915 | struct v4l2_jpegcompression *jcomp) | |
2916 | { | |
2917 | struct sd *sd = (struct sd *) gspca_dev; | |
2918 | ||
2919 | memset(jcomp, 0, sizeof *jcomp); | |
2920 | jcomp->quality = sd->quality; | |
2921 | jcomp->jpeg_markers = V4L2_JPEG_MARKER_DHT | |
2922 | | V4L2_JPEG_MARKER_DQT; | |
2923 | return 0; | |
2924 | } | |
2925 | ||
37c6dbe2 HG |
2926 | static int sd_querymenu(struct gspca_dev *gspca_dev, |
2927 | struct v4l2_querymenu *menu) | |
2928 | { | |
2929 | switch (menu->id) { | |
2930 | case V4L2_CID_POWER_LINE_FREQUENCY: | |
2931 | switch (menu->index) { | |
2932 | case 0: /* V4L2_CID_POWER_LINE_FREQUENCY_DISABLED */ | |
2933 | strcpy((char *) menu->name, "NoFliker"); | |
2934 | return 0; | |
2935 | case 1: /* V4L2_CID_POWER_LINE_FREQUENCY_50HZ */ | |
2936 | strcpy((char *) menu->name, "50 Hz"); | |
2937 | return 0; | |
2938 | case 2: /* V4L2_CID_POWER_LINE_FREQUENCY_60HZ */ | |
2939 | strcpy((char *) menu->name, "60 Hz"); | |
2940 | return 0; | |
2941 | } | |
2942 | break; | |
2943 | } | |
2944 | return -EINVAL; | |
2945 | } | |
2946 | ||
9712a8be HG |
2947 | #ifdef CONFIG_INPUT |
2948 | static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, | |
2949 | u8 *data, /* interrupt packet data */ | |
2950 | int len) /* interrupt packet length */ | |
2951 | { | |
2952 | int ret = -EINVAL; | |
2953 | ||
2954 | if (len == 1 && data[0] == 1) { | |
2955 | input_report_key(gspca_dev->input_dev, KEY_CAMERA, 1); | |
2956 | input_sync(gspca_dev->input_dev); | |
2957 | input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0); | |
2958 | input_sync(gspca_dev->input_dev); | |
2959 | ret = 0; | |
2960 | } | |
2961 | ||
2962 | return ret; | |
2963 | } | |
2964 | #endif | |
2965 | ||
6a7eba24 | 2966 | /* sub-driver description */ |
a5ae2062 | 2967 | static const struct sd_desc sd_desc = { |
6a7eba24 JFM |
2968 | .name = MODULE_NAME, |
2969 | .ctrls = sd_ctrls, | |
2970 | .nctrls = ARRAY_SIZE(sd_ctrls), | |
2971 | .config = sd_config, | |
012d6b02 | 2972 | .init = sd_init, |
6a7eba24 JFM |
2973 | .start = sd_start, |
2974 | .stopN = sd_stopN, | |
6a7eba24 | 2975 | .pkt_scan = sd_pkt_scan, |
cebf3b67 | 2976 | .dq_callback = do_autogain, |
77ac0baf JFM |
2977 | .get_jcomp = sd_get_jcomp, |
2978 | .set_jcomp = sd_set_jcomp, | |
37c6dbe2 | 2979 | .querymenu = sd_querymenu, |
9712a8be HG |
2980 | #ifdef CONFIG_INPUT |
2981 | .int_pkt_scan = sd_int_pkt_scan, | |
2982 | #endif | |
6a7eba24 JFM |
2983 | }; |
2984 | ||
2985 | /* -- module initialisation -- */ | |
d5aa3856 | 2986 | #define BS(bridge, sensor) \ |
9d64fdb1 | 2987 | .driver_info = (BRIDGE_ ## bridge << 16) \ |
d5aa3856 | 2988 | | SENSOR_ ## sensor |
a5ae2062 | 2989 | static const __devinitdata struct usb_device_id device_table[] = { |
222a07ff | 2990 | #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE |
d5aa3856 JFM |
2991 | {USB_DEVICE(0x0458, 0x7025), BS(SN9C120, MI0360)}, |
2992 | {USB_DEVICE(0x0458, 0x702e), BS(SN9C120, OV7660)}, | |
a08d81af | 2993 | #endif |
d5aa3856 JFM |
2994 | {USB_DEVICE(0x045e, 0x00f5), BS(SN9C105, OV7660)}, |
2995 | {USB_DEVICE(0x045e, 0x00f7), BS(SN9C105, OV7660)}, | |
2996 | {USB_DEVICE(0x0471, 0x0327), BS(SN9C105, MI0360)}, | |
2997 | {USB_DEVICE(0x0471, 0x0328), BS(SN9C105, MI0360)}, | |
2998 | {USB_DEVICE(0x0471, 0x0330), BS(SN9C105, MI0360)}, | |
2999 | {USB_DEVICE(0x06f8, 0x3004), BS(SN9C105, OV7660)}, | |
3000 | {USB_DEVICE(0x06f8, 0x3008), BS(SN9C105, OV7660)}, | |
3001 | /* {USB_DEVICE(0x0c45, 0x603a), BS(SN9C102P, OV7648)}, */ | |
3002 | {USB_DEVICE(0x0c45, 0x6040), BS(SN9C102P, HV7131R)}, | |
3003 | /* {USB_DEVICE(0x0c45, 0x607a), BS(SN9C102P, OV7648)}, */ | |
3004 | /* {USB_DEVICE(0x0c45, 0x607b), BS(SN9C102P, OV7660)}, */ | |
3005 | {USB_DEVICE(0x0c45, 0x607c), BS(SN9C102P, HV7131R)}, | |
3006 | /* {USB_DEVICE(0x0c45, 0x607e), BS(SN9C102P, OV7630)}, */ | |
3007 | {USB_DEVICE(0x0c45, 0x60c0), BS(SN9C105, MI0360)}, | |
3008 | /* {USB_DEVICE(0x0c45, 0x60c2), BS(SN9C105, P1030xC)}, */ | |
3009 | /* {USB_DEVICE(0x0c45, 0x60c8), BS(SN9C105, OM6802)}, */ | |
3010 | /* {USB_DEVICE(0x0c45, 0x60cc), BS(SN9C105, HV7131GP)}, */ | |
c4f95d84 | 3011 | {USB_DEVICE(0x0c45, 0x60ce), BS(SN9C105, SP80708)}, |
d5aa3856 JFM |
3012 | {USB_DEVICE(0x0c45, 0x60ec), BS(SN9C105, MO4000)}, |
3013 | /* {USB_DEVICE(0x0c45, 0x60ef), BS(SN9C105, ICM105C)}, */ | |
3014 | /* {USB_DEVICE(0x0c45, 0x60fa), BS(SN9C105, OV7648)}, */ | |
6804675e | 3015 | /* {USB_DEVICE(0x0c45, 0x60f2), BS(SN9C105, OV7660)}, */ |
d5aa3856 | 3016 | {USB_DEVICE(0x0c45, 0x60fb), BS(SN9C105, OV7660)}, |
3c41cb77 | 3017 | #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE |
d5aa3856 JFM |
3018 | {USB_DEVICE(0x0c45, 0x60fc), BS(SN9C105, HV7131R)}, |
3019 | {USB_DEVICE(0x0c45, 0x60fe), BS(SN9C105, OV7630)}, | |
3c41cb77 | 3020 | #endif |
d5aa3856 | 3021 | {USB_DEVICE(0x0c45, 0x6100), BS(SN9C120, MI0360)}, /*sn9c128*/ |
6804675e | 3022 | /* {USB_DEVICE(0x0c45, 0x6102), BS(SN9C120, PO2030N)}, * / GC0305*/ |
d5aa3856 JFM |
3023 | /* {USB_DEVICE(0x0c45, 0x6108), BS(SN9C120, OM6802)}, */ |
3024 | {USB_DEVICE(0x0c45, 0x610a), BS(SN9C120, OV7648)}, /*sn9c128*/ | |
3025 | {USB_DEVICE(0x0c45, 0x610b), BS(SN9C120, OV7660)}, /*sn9c128*/ | |
3026 | {USB_DEVICE(0x0c45, 0x610c), BS(SN9C120, HV7131R)}, /*sn9c128*/ | |
3027 | {USB_DEVICE(0x0c45, 0x610e), BS(SN9C120, OV7630)}, /*sn9c128*/ | |
3028 | /* {USB_DEVICE(0x0c45, 0x610f), BS(SN9C120, S5K53BEB)}, */ | |
3029 | /* {USB_DEVICE(0x0c45, 0x6122), BS(SN9C110, ICM105C)}, */ | |
3030 | /* {USB_DEVICE(0x0c45, 0x6123), BS(SN9C110, SanyoCCD)}, */ | |
3031 | {USB_DEVICE(0x0c45, 0x6128), BS(SN9C120, OM6802)}, /*sn9c325?*/ | |
d2d16e90 | 3032 | /*bw600.inf:*/ |
b8c8a5bf | 3033 | {USB_DEVICE(0x0c45, 0x612a), BS(SN9C120, OV7648)}, /*sn9c325?*/ |
d5aa3856 JFM |
3034 | {USB_DEVICE(0x0c45, 0x612c), BS(SN9C110, MO4000)}, |
3035 | {USB_DEVICE(0x0c45, 0x612e), BS(SN9C110, OV7630)}, | |
3036 | /* {USB_DEVICE(0x0c45, 0x612f), BS(SN9C110, ICM105C)}, */ | |
222a07ff | 3037 | #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE |
d5aa3856 | 3038 | {USB_DEVICE(0x0c45, 0x6130), BS(SN9C120, MI0360)}, |
222a07ff | 3039 | #endif |
d5aa3856 JFM |
3040 | /* {USB_DEVICE(0x0c45, 0x6132), BS(SN9C120, OV7670)}, */ |
3041 | {USB_DEVICE(0x0c45, 0x6138), BS(SN9C120, MO4000)}, | |
3042 | {USB_DEVICE(0x0c45, 0x613a), BS(SN9C120, OV7648)}, | |
222a07ff | 3043 | #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE |
d5aa3856 | 3044 | {USB_DEVICE(0x0c45, 0x613b), BS(SN9C120, OV7660)}, |
8d97770a | 3045 | #endif |
d5aa3856 JFM |
3046 | {USB_DEVICE(0x0c45, 0x613c), BS(SN9C120, HV7131R)}, |
3047 | {USB_DEVICE(0x0c45, 0x613e), BS(SN9C120, OV7630)}, | |
ad98c0f6 | 3048 | {USB_DEVICE(0x0c45, 0x6142), BS(SN9C120, PO2030N)}, /*sn9c120b*/ |
6804675e | 3049 | /* or GC0305 / GC0307 */ |
d5aa3856 JFM |
3050 | {USB_DEVICE(0x0c45, 0x6143), BS(SN9C120, SP80708)}, /*sn9c120b*/ |
3051 | {USB_DEVICE(0x0c45, 0x6148), BS(SN9C120, OM6802)}, /*sn9c120b*/ | |
64677573 | 3052 | {USB_DEVICE(0x0c45, 0x614a), BS(SN9C120, ADCM1700)}, /*sn9c120b*/ |
6a7eba24 JFM |
3053 | {} |
3054 | }; | |
3055 | MODULE_DEVICE_TABLE(usb, device_table); | |
3056 | ||
3057 | /* -- device connect -- */ | |
3058 | static int sd_probe(struct usb_interface *intf, | |
3059 | const struct usb_device_id *id) | |
3060 | { | |
3061 | return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd), | |
3062 | THIS_MODULE); | |
3063 | } | |
3064 | ||
3065 | static struct usb_driver sd_driver = { | |
3066 | .name = MODULE_NAME, | |
3067 | .id_table = device_table, | |
3068 | .probe = sd_probe, | |
3069 | .disconnect = gspca_disconnect, | |
6a709749 JFM |
3070 | #ifdef CONFIG_PM |
3071 | .suspend = gspca_suspend, | |
3072 | .resume = gspca_resume, | |
3073 | #endif | |
6a7eba24 JFM |
3074 | }; |
3075 | ||
3076 | /* -- module insert / remove -- */ | |
3077 | static int __init sd_mod_init(void) | |
3078 | { | |
54826437 | 3079 | return usb_register(&sd_driver); |
6a7eba24 JFM |
3080 | } |
3081 | static void __exit sd_mod_exit(void) | |
3082 | { | |
3083 | usb_deregister(&sd_driver); | |
6a7eba24 JFM |
3084 | } |
3085 | ||
3086 | module_init(sd_mod_init); | |
3087 | module_exit(sd_mod_exit); |