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