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