4 * Copyright (C) 2008 Jean-Francois Moine (http://moinejf.free.fr)
6 * This module is adapted from the ov51x-jpeg package, which itself
7 * was adapted from the ov511 driver.
9 * Original copyright for the ov511 driver is:
11 * Copyright (c) 1999-2004 Mark W. McClelland
12 * Support for OV519, OV8610 Copyright (c) 2003 Joerg Heckenbach
14 * ov51x-jpeg original copyright is:
16 * Copyright (c) 2004-2007 Romain Beauxis <toots@rastageeks.org>
17 * Support for OV7670 sensors was contributed by Sam Skipsey <aoanla@yahoo.com>
19 * This program is free software; you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation; either version 2 of the License, or
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
29 * You should have received a copy of the GNU General Public License
30 * along with this program; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
34 #define MODULE_NAME "ov519"
38 MODULE_AUTHOR("Jean-Francois Moine <http://moinejf.free.fr>");
39 MODULE_DESCRIPTION("OV519 USB Camera Driver");
40 MODULE_LICENSE("GPL");
42 /* global parameters */
43 static int frame_rate;
45 /* Number of times to retry a failed I2C transaction. Increase this if you
46 * are getting "Failed to read sensor ID..." */
47 static int i2c_detect_tries = 10;
49 /* ov519 device descriptor */
51 struct gspca_dev gspca_dev; /* !! must be the first item */
54 #define BRIDGE_OV511 0
55 #define BRIDGE_OV511PLUS 1
56 #define BRIDGE_OV518 2
57 #define BRIDGE_OV518PLUS 3
58 #define BRIDGE_OV519 4
60 /* Determined by sensor type */
69 __u8 stopped; /* Streaming is temporarily paused */
71 __u8 frame_rate; /* current Framerate (OV519 only) */
72 __u8 clockdiv; /* clockdiv override for OV519 only */
74 char sensor; /* Type of image sensor chip (SEN_*) */
86 /* V4L2 controls supported by the driver */
87 static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val);
88 static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val);
89 static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val);
90 static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val);
91 static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val);
92 static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val);
93 static int sd_sethflip(struct gspca_dev *gspca_dev, __s32 val);
94 static int sd_gethflip(struct gspca_dev *gspca_dev, __s32 *val);
95 static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val);
96 static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val);
97 static void setbrightness(struct gspca_dev *gspca_dev);
98 static void setcontrast(struct gspca_dev *gspca_dev);
99 static void setcolors(struct gspca_dev *gspca_dev);
101 static struct ctrl sd_ctrls[] = {
104 .id = V4L2_CID_BRIGHTNESS,
105 .type = V4L2_CTRL_TYPE_INTEGER,
106 .name = "Brightness",
110 #define BRIGHTNESS_DEF 127
111 .default_value = BRIGHTNESS_DEF,
113 .set = sd_setbrightness,
114 .get = sd_getbrightness,
118 .id = V4L2_CID_CONTRAST,
119 .type = V4L2_CTRL_TYPE_INTEGER,
124 #define CONTRAST_DEF 127
125 .default_value = CONTRAST_DEF,
127 .set = sd_setcontrast,
128 .get = sd_getcontrast,
132 .id = V4L2_CID_SATURATION,
133 .type = V4L2_CTRL_TYPE_INTEGER,
138 #define COLOR_DEF 127
139 .default_value = COLOR_DEF,
144 /* next controls work with ov7670 only */
148 .id = V4L2_CID_HFLIP,
149 .type = V4L2_CTRL_TYPE_BOOLEAN,
155 .default_value = HFLIP_DEF,
163 .id = V4L2_CID_VFLIP,
164 .type = V4L2_CTRL_TYPE_BOOLEAN,
170 .default_value = VFLIP_DEF,
177 static const struct v4l2_pix_format ov519_vga_mode[] = {
178 {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
180 .sizeimage = 320 * 240 * 3 / 8 + 590,
181 .colorspace = V4L2_COLORSPACE_JPEG,
183 {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
185 .sizeimage = 640 * 480 * 3 / 8 + 590,
186 .colorspace = V4L2_COLORSPACE_JPEG,
189 static const struct v4l2_pix_format ov519_sif_mode[] = {
190 {176, 144, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
192 .sizeimage = 176 * 144 * 3 / 8 + 590,
193 .colorspace = V4L2_COLORSPACE_JPEG,
195 {352, 288, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
197 .sizeimage = 352 * 288 * 3 / 8 + 590,
198 .colorspace = V4L2_COLORSPACE_JPEG,
202 static const struct v4l2_pix_format ov518_vga_mode[] = {
203 {320, 240, V4L2_PIX_FMT_OV518, V4L2_FIELD_NONE,
205 .sizeimage = 320 * 240 * 3 / 8 + 590,
206 .colorspace = V4L2_COLORSPACE_JPEG,
208 {640, 480, V4L2_PIX_FMT_OV518, V4L2_FIELD_NONE,
210 .sizeimage = 640 * 480 * 3 / 8 + 590,
211 .colorspace = V4L2_COLORSPACE_JPEG,
214 static const struct v4l2_pix_format ov518_sif_mode[] = {
215 {176, 144, V4L2_PIX_FMT_OV518, V4L2_FIELD_NONE,
218 .colorspace = V4L2_COLORSPACE_JPEG,
220 {352, 288, V4L2_PIX_FMT_OV518, V4L2_FIELD_NONE,
222 .sizeimage = 352 * 288 * 3 / 8 + 590,
223 .colorspace = V4L2_COLORSPACE_JPEG,
228 /* Registers common to OV511 / OV518 */
229 #define R51x_SYS_RESET 0x50
230 #define R51x_SYS_INIT 0x53
231 #define R51x_SYS_SNAP 0x52
232 #define R51x_SYS_CUST_ID 0x5F
233 #define R51x_COMP_LUT_BEGIN 0x80
235 /* OV511 Camera interface register numbers */
236 #define R511_SYS_LED_CTL 0x55 /* OV511+ only */
237 #define OV511_RESET_NOREGS 0x3F /* All but OV511 & regs */
239 /* OV518 Camera interface register numbers */
240 #define R518_GPIO_OUT 0x56 /* OV518(+) only */
241 #define R518_GPIO_CTL 0x57 /* OV518(+) only */
243 /* OV519 Camera interface register numbers */
244 #define OV519_R10_H_SIZE 0x10
245 #define OV519_R11_V_SIZE 0x11
246 #define OV519_R12_X_OFFSETL 0x12
247 #define OV519_R13_X_OFFSETH 0x13
248 #define OV519_R14_Y_OFFSETL 0x14
249 #define OV519_R15_Y_OFFSETH 0x15
250 #define OV519_R16_DIVIDER 0x16
251 #define OV519_R20_DFR 0x20
252 #define OV519_R25_FORMAT 0x25
254 /* OV519 System Controller register numbers */
255 #define OV519_SYS_RESET1 0x51
256 #define OV519_SYS_EN_CLK1 0x54
258 #define OV519_GPIO_DATA_OUT0 0x71
259 #define OV519_GPIO_IO_CTRL0 0x72
261 #define OV511_ENDPOINT_ADDRESS 1 /* Isoc endpoint number */
264 #define R51x_I2C_W_SID 0x41
265 #define R51x_I2C_SADDR_3 0x42
266 #define R51x_I2C_SADDR_2 0x43
267 #define R51x_I2C_R_SID 0x44
268 #define R51x_I2C_DATA 0x45
269 #define R518_I2C_CTL 0x47 /* OV518(+) only */
272 #define OV7xx0_SID 0x42
273 #define OV8xx0_SID 0xa0
274 #define OV6xx0_SID 0xc0
276 /* OV7610 registers */
277 #define OV7610_REG_GAIN 0x00 /* gain setting (5:0) */
278 #define OV7610_REG_BLUE 0x01 /* blue channel balance */
279 #define OV7610_REG_RED 0x02 /* red channel balance */
280 #define OV7610_REG_SAT 0x03 /* saturation */
281 #define OV8610_REG_HUE 0x04 /* 04 reserved */
282 #define OV7610_REG_CNT 0x05 /* Y contrast */
283 #define OV7610_REG_BRT 0x06 /* Y brightness */
284 #define OV7610_REG_COM_C 0x14 /* misc common regs */
285 #define OV7610_REG_ID_HIGH 0x1c /* manufacturer ID MSB */
286 #define OV7610_REG_ID_LOW 0x1d /* manufacturer ID LSB */
287 #define OV7610_REG_COM_I 0x29 /* misc settings */
289 /* OV7670 registers */
290 #define OV7670_REG_GAIN 0x00 /* Gain lower 8 bits (rest in vref) */
291 #define OV7670_REG_BLUE 0x01 /* blue gain */
292 #define OV7670_REG_RED 0x02 /* red gain */
293 #define OV7670_REG_VREF 0x03 /* Pieces of GAIN, VSTART, VSTOP */
294 #define OV7670_REG_COM1 0x04 /* Control 1 */
295 #define OV7670_REG_AECHH 0x07 /* AEC MS 5 bits */
296 #define OV7670_REG_COM3 0x0c /* Control 3 */
297 #define OV7670_REG_COM4 0x0d /* Control 4 */
298 #define OV7670_REG_COM5 0x0e /* All "reserved" */
299 #define OV7670_REG_COM6 0x0f /* Control 6 */
300 #define OV7670_REG_AECH 0x10 /* More bits of AEC value */
301 #define OV7670_REG_CLKRC 0x11 /* Clock control */
302 #define OV7670_REG_COM7 0x12 /* Control 7 */
303 #define OV7670_COM7_FMT_VGA 0x00
304 #define OV7670_COM7_YUV 0x00 /* YUV */
305 #define OV7670_COM7_FMT_QVGA 0x10 /* QVGA format */
306 #define OV7670_COM7_FMT_MASK 0x38
307 #define OV7670_COM7_RESET 0x80 /* Register reset */
308 #define OV7670_REG_COM8 0x13 /* Control 8 */
309 #define OV7670_COM8_AEC 0x01 /* Auto exposure enable */
310 #define OV7670_COM8_AWB 0x02 /* White balance enable */
311 #define OV7670_COM8_AGC 0x04 /* Auto gain enable */
312 #define OV7670_COM8_BFILT 0x20 /* Band filter enable */
313 #define OV7670_COM8_AECSTEP 0x40 /* Unlimited AEC step size */
314 #define OV7670_COM8_FASTAEC 0x80 /* Enable fast AGC/AEC */
315 #define OV7670_REG_COM9 0x14 /* Control 9 - gain ceiling */
316 #define OV7670_REG_COM10 0x15 /* Control 10 */
317 #define OV7670_REG_HSTART 0x17 /* Horiz start high bits */
318 #define OV7670_REG_HSTOP 0x18 /* Horiz stop high bits */
319 #define OV7670_REG_VSTART 0x19 /* Vert start high bits */
320 #define OV7670_REG_VSTOP 0x1a /* Vert stop high bits */
321 #define OV7670_REG_MVFP 0x1e /* Mirror / vflip */
322 #define OV7670_MVFP_VFLIP 0x10 /* vertical flip */
323 #define OV7670_MVFP_MIRROR 0x20 /* Mirror image */
324 #define OV7670_REG_AEW 0x24 /* AGC upper limit */
325 #define OV7670_REG_AEB 0x25 /* AGC lower limit */
326 #define OV7670_REG_VPT 0x26 /* AGC/AEC fast mode op region */
327 #define OV7670_REG_HREF 0x32 /* HREF pieces */
328 #define OV7670_REG_TSLB 0x3a /* lots of stuff */
329 #define OV7670_REG_COM11 0x3b /* Control 11 */
330 #define OV7670_COM11_EXP 0x02
331 #define OV7670_COM11_HZAUTO 0x10 /* Auto detect 50/60 Hz */
332 #define OV7670_REG_COM12 0x3c /* Control 12 */
333 #define OV7670_REG_COM13 0x3d /* Control 13 */
334 #define OV7670_COM13_GAMMA 0x80 /* Gamma enable */
335 #define OV7670_COM13_UVSAT 0x40 /* UV saturation auto adjustment */
336 #define OV7670_REG_COM14 0x3e /* Control 14 */
337 #define OV7670_REG_EDGE 0x3f /* Edge enhancement factor */
338 #define OV7670_REG_COM15 0x40 /* Control 15 */
339 #define OV7670_COM15_R00FF 0xc0 /* 00 to FF */
340 #define OV7670_REG_COM16 0x41 /* Control 16 */
341 #define OV7670_COM16_AWBGAIN 0x08 /* AWB gain enable */
342 #define OV7670_REG_BRIGHT 0x55 /* Brightness */
343 #define OV7670_REG_CONTRAS 0x56 /* Contrast control */
344 #define OV7670_REG_GFIX 0x69 /* Fix gain control */
345 #define OV7670_REG_RGB444 0x8c /* RGB 444 control */
346 #define OV7670_REG_HAECC1 0x9f /* Hist AEC/AGC control 1 */
347 #define OV7670_REG_HAECC2 0xa0 /* Hist AEC/AGC control 2 */
348 #define OV7670_REG_BD50MAX 0xa5 /* 50hz banding step limit */
349 #define OV7670_REG_HAECC3 0xa6 /* Hist AEC/AGC control 3 */
350 #define OV7670_REG_HAECC4 0xa7 /* Hist AEC/AGC control 4 */
351 #define OV7670_REG_HAECC5 0xa8 /* Hist AEC/AGC control 5 */
352 #define OV7670_REG_HAECC6 0xa9 /* Hist AEC/AGC control 6 */
353 #define OV7670_REG_HAECC7 0xaa /* Hist AEC/AGC control 7 */
354 #define OV7670_REG_BD60MAX 0xab /* 60hz banding step limit */
360 struct ov_i2c_regvals {
365 static const struct ov_i2c_regvals norm_6x20[] = {
366 { 0x12, 0x80 }, /* reset */
369 { 0x05, 0x7f }, /* For when autoadjust is off */
371 /* The ratio of 0x0c and 0x0d controls the white point */
374 { 0x0f, 0x15 }, /* COMS */
375 { 0x10, 0x75 }, /* AEC Exposure time */
376 { 0x12, 0x24 }, /* Enable AGC */
378 /* 0x16: 0x06 helps frame stability with moving objects */
380 /* { 0x20, 0x30 }, * Aperture correction enable */
381 { 0x26, 0xb2 }, /* BLC enable */
382 /* 0x28: 0x05 Selects RGB format if RGB on */
384 { 0x2a, 0x04 }, /* Disable framerate adjust */
385 /* { 0x2b, 0xac }, * Framerate; Set 2a[7] first */
387 { 0x33, 0xa0 }, /* Color Processing Parameter */
388 { 0x34, 0xd2 }, /* Max A/D range */
392 { 0x3c, 0x39 }, /* Enable AEC mode changing */
393 { 0x3c, 0x3c }, /* Change AEC mode */
394 { 0x3c, 0x24 }, /* Disable AEC mode changing */
397 /* These next two registers (0x4a, 0x4b) are undocumented.
398 * They control the color balance */
401 { 0x4d, 0xd2 }, /* This reduces noise a bit */
404 /* Do 50-53 have any effect? */
405 /* Toggle 0x12[2] off and on here? */
408 static const struct ov_i2c_regvals norm_6x30[] = {
409 { 0x12, 0x80 }, /* Reset */
410 { 0x00, 0x1f }, /* Gain */
411 { 0x01, 0x99 }, /* Blue gain */
412 { 0x02, 0x7c }, /* Red gain */
413 { 0x03, 0xc0 }, /* Saturation */
414 { 0x05, 0x0a }, /* Contrast */
415 { 0x06, 0x95 }, /* Brightness */
416 { 0x07, 0x2d }, /* Sharpness */
422 { 0x11, 0x00 }, /* Pixel clock = fastest */
423 { 0x12, 0x24 }, /* Enable AGC and AWB */
438 { 0x23, 0xc0 }, /* Crystal circuit power level */
439 { 0x25, 0x9a }, /* Increase AEC black ratio */
440 { 0x26, 0xb2 }, /* BLC enable */
444 { 0x2a, 0x84 }, /* 60 Hz power */
445 { 0x2b, 0xa8 }, /* 60 Hz power */
447 { 0x2d, 0x95 }, /* Enable auto-brightness */
461 { 0x40, 0x00 }, /* White bal */
462 { 0x41, 0x00 }, /* White bal */
464 { 0x43, 0x3f }, /* White bal */
474 { 0x4d, 0x10 }, /* U = 0.563u, V = 0.714v */
476 { 0x4f, 0x07 }, /* UV avg., col. killer: max */
478 { 0x54, 0x23 }, /* Max AGC gain: 18dB */
483 { 0x59, 0x01 }, /* AGC dark current comp.: +1 */
485 { 0x5b, 0x0f }, /* AWB chrominance levels */
489 { 0x12, 0x20 }, /* Toggle AWB */
493 /* Lawrence Glaister <lg@jfm.bc.ca> reports:
495 * Register 0x0f in the 7610 has the following effects:
497 * 0x85 (AEC method 1): Best overall, good contrast range
498 * 0x45 (AEC method 2): Very overexposed
499 * 0xa5 (spec sheet default): Ok, but the black level is
500 * shifted resulting in loss of contrast
501 * 0x05 (old driver setting): very overexposed, too much
504 static const struct ov_i2c_regvals norm_7610[] = {
511 { 0x28, 0x24 }, /* 0c */
512 { 0x0f, 0x85 }, /* lg's setting */
534 static const struct ov_i2c_regvals norm_7620[] = {
535 { 0x00, 0x00 }, /* gain */
536 { 0x01, 0x80 }, /* blue gain */
537 { 0x02, 0x80 }, /* red gain */
538 { 0x03, 0xc0 }, /* OV7670_REG_VREF */
600 /* 7640 and 7648. The defaults should be OK for most registers. */
601 static const struct ov_i2c_regvals norm_7640[] = {
606 /* 7670. Defaults taken from OmniVision provided data,
607 * as provided by Jonathan Corbet of OLPC */
608 static const struct ov_i2c_regvals norm_7670[] = {
609 { OV7670_REG_COM7, OV7670_COM7_RESET },
610 { OV7670_REG_TSLB, 0x04 }, /* OV */
611 { OV7670_REG_COM7, OV7670_COM7_FMT_VGA }, /* VGA */
612 { OV7670_REG_CLKRC, 0x01 },
614 * Set the hardware window. These values from OV don't entirely
615 * make sense - hstop is less than hstart. But they work...
617 { OV7670_REG_HSTART, 0x13 },
618 { OV7670_REG_HSTOP, 0x01 },
619 { OV7670_REG_HREF, 0xb6 },
620 { OV7670_REG_VSTART, 0x02 },
621 { OV7670_REG_VSTOP, 0x7a },
622 { OV7670_REG_VREF, 0x0a },
624 { OV7670_REG_COM3, 0x00 },
625 { OV7670_REG_COM14, 0x00 },
626 /* Mystery scaling numbers */
632 /* { OV7670_REG_COM10, 0x0 }, */
634 /* Gamma curve values */
652 /* AGC and AEC parameters. Note we start by disabling those features,
653 then turn them only after tweaking the values. */
654 { OV7670_REG_COM8, OV7670_COM8_FASTAEC
655 | OV7670_COM8_AECSTEP
656 | OV7670_COM8_BFILT },
657 { OV7670_REG_GAIN, 0x00 },
658 { OV7670_REG_AECH, 0x00 },
659 { OV7670_REG_COM4, 0x40 }, /* magic reserved bit */
660 { OV7670_REG_COM9, 0x18 }, /* 4x gain + magic rsvd bit */
661 { OV7670_REG_BD50MAX, 0x05 },
662 { OV7670_REG_BD60MAX, 0x07 },
663 { OV7670_REG_AEW, 0x95 },
664 { OV7670_REG_AEB, 0x33 },
665 { OV7670_REG_VPT, 0xe3 },
666 { OV7670_REG_HAECC1, 0x78 },
667 { OV7670_REG_HAECC2, 0x68 },
668 { 0xa1, 0x03 }, /* magic */
669 { OV7670_REG_HAECC3, 0xd8 },
670 { OV7670_REG_HAECC4, 0xd8 },
671 { OV7670_REG_HAECC5, 0xf0 },
672 { OV7670_REG_HAECC6, 0x90 },
673 { OV7670_REG_HAECC7, 0x94 },
674 { OV7670_REG_COM8, OV7670_COM8_FASTAEC
675 | OV7670_COM8_AECSTEP
680 /* Almost all of these are magic "reserved" values. */
681 { OV7670_REG_COM5, 0x61 },
682 { OV7670_REG_COM6, 0x4b },
684 { OV7670_REG_MVFP, 0x07 },
693 { OV7670_REG_COM12, 0x78 },
696 { OV7670_REG_GFIX, 0x00 },
712 /* More reserved magic, some of which tweaks white balance */
729 /* "9e for advance AWB" */
731 { OV7670_REG_BLUE, 0x40 },
732 { OV7670_REG_RED, 0x60 },
733 { OV7670_REG_COM8, OV7670_COM8_FASTAEC
734 | OV7670_COM8_AECSTEP
740 /* Matrix coefficients */
749 { OV7670_REG_COM16, OV7670_COM16_AWBGAIN },
750 { OV7670_REG_EDGE, 0x00 },
755 { OV7670_REG_COM13, OV7670_COM13_GAMMA
760 { OV7670_REG_COM16, 0x38 },
764 { OV7670_REG_COM11, OV7670_COM11_EXP|OV7670_COM11_HZAUTO },
777 /* Extra-weird stuff. Some sort of multiplexor register */
803 static const struct ov_i2c_regvals norm_8610[] = {
810 { 0x05, 0x30 }, /* was 0x10, new from windrv 090403 */
811 { 0x06, 0x70 }, /* was 0x80, new from windrv 090403 */
820 { 0x15, 0x01 }, /* Lin and Win think different about UV order */
822 { 0x17, 0x38 }, /* was 0x2f, new from windrv 090403 */
823 { 0x18, 0xea }, /* was 0xcf, new from windrv 090403 */
824 { 0x19, 0x02 }, /* was 0x06, new from windrv 090403 */
827 { 0x20, 0xd0 }, /* was 0x90, new from windrv 090403 */
828 { 0x23, 0xc0 }, /* was 0x00, new from windrv 090403 */
829 { 0x24, 0x30 }, /* was 0x1d, new from windrv 090403 */
830 { 0x25, 0x50 }, /* was 0x57, new from windrv 090403 */
836 { 0x2b, 0xc8 }, /* was 0xcc, new from windrv 090403 */
838 { 0x2d, 0x45 }, /* was 0xd5, new from windrv 090403 */
840 { 0x2f, 0x14 }, /* was 0x01, new from windrv 090403 */
842 { 0x4d, 0x30 }, /* was 0x10, new from windrv 090403 */
843 { 0x60, 0x02 }, /* was 0x01, new from windrv 090403 */
844 { 0x61, 0x00 }, /* was 0x09, new from windrv 090403 */
845 { 0x62, 0x5f }, /* was 0xd7, new from windrv 090403 */
847 { 0x64, 0x53 }, /* new windrv 090403 says 0x57,
848 * maybe thats wrong */
852 { 0x68, 0xc0 }, /* was 0xaf, new from windrv 090403 */
856 { 0x6c, 0x99 }, /* was 0x80, old windrv says 0x00, but
857 * deleting bit7 colors the first images red */
858 { 0x6d, 0x11 }, /* was 0x00, new from windrv 090403 */
859 { 0x6e, 0x11 }, /* was 0x00, new from windrv 090403 */
865 { 0x74, 0x00 },/* 0x60? - was 0x00, new from windrv 090403 */
867 { 0x76, 0x02 }, /* was 0x02, new from windrv 090403 */
872 { 0x7b, 0x10 }, /* was 0x13, new from windrv 090403 */
874 { 0x7d, 0x08 }, /* was 0x09, new from windrv 090403 */
875 { 0x7e, 0x08 }, /* was 0xc0, new from windrv 090403 */
882 { 0x85, 0x62 }, /* was 0x61, new from windrv 090403 */
888 { 0x12, 0x25 }, /* was 0x24, new from windrv 090403 */
891 static unsigned char ov7670_abs_to_sm(unsigned char v)
895 return (128 - v) | 0x80;
898 /* Write a OV519 register */
899 static int reg_w(struct sd *sd, __u16 index, __u8 value)
902 int req = (sd->bridge <= BRIDGE_OV511PLUS) ? 2 : 1;
904 sd->gspca_dev.usb_buf[0] = value;
905 ret = usb_control_msg(sd->gspca_dev.dev,
906 usb_sndctrlpipe(sd->gspca_dev.dev, 0),
908 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
910 sd->gspca_dev.usb_buf, 1, 500);
912 PDEBUG(D_ERR, "Write reg [%02x] %02x failed", index, value);
916 /* Read from a OV519 register */
917 /* returns: negative is error, pos or zero is data */
918 static int reg_r(struct sd *sd, __u16 index)
921 int req = (sd->bridge <= BRIDGE_OV511PLUS) ? 3 : 1;
923 ret = usb_control_msg(sd->gspca_dev.dev,
924 usb_rcvctrlpipe(sd->gspca_dev.dev, 0),
926 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
927 0, index, sd->gspca_dev.usb_buf, 1, 500);
930 ret = sd->gspca_dev.usb_buf[0];
932 PDEBUG(D_ERR, "Read reg [0x%02x] failed", index);
936 /* Read 8 values from a OV519 register */
937 static int reg_r8(struct sd *sd,
942 ret = usb_control_msg(sd->gspca_dev.dev,
943 usb_rcvctrlpipe(sd->gspca_dev.dev, 0),
945 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
946 0, index, sd->gspca_dev.usb_buf, 8, 500);
949 ret = sd->gspca_dev.usb_buf[0];
951 PDEBUG(D_ERR, "Read reg 8 [0x%02x] failed", index);
956 * Writes bits at positions specified by mask to an OV51x reg. Bits that are in
957 * the same position as 1's in "mask" are cleared and set to "value". Bits
958 * that are in the same position as 0's in "mask" are preserved, regardless
959 * of their respective state in "value".
961 static int reg_w_mask(struct sd *sd,
970 value &= mask; /* Enforce mask on value */
971 ret = reg_r(sd, index);
975 oldval = ret & ~mask; /* Clear the masked bits */
976 value |= oldval; /* Set the desired bits */
978 return reg_w(sd, index, value);
982 * Writes multiple (n) byte value to a single register. Only valid with certain
983 * registers (0x30 and 0xc4 - 0xce).
985 static int ov518_reg_w32(struct sd *sd, __u16 index, u32 value, int n)
989 *((u32 *)sd->gspca_dev.usb_buf) = __cpu_to_le32(value);
991 ret = usb_control_msg(sd->gspca_dev.dev,
992 usb_sndctrlpipe(sd->gspca_dev.dev, 0),
994 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
996 sd->gspca_dev.usb_buf, n, 500);
998 PDEBUG(D_ERR, "Write reg32 [%02x] %08x failed", index, value);
1004 * The OV518 I2C I/O procedure is different, hence, this function.
1005 * This is normally only called from i2c_w(). Note that this function
1006 * always succeeds regardless of whether the sensor is present and working.
1008 static int i2c_w(struct sd *sd,
1014 PDEBUG(D_USBO, "i2c 0x%02x -> [0x%02x]", value, reg);
1016 /* Select camera register */
1017 rc = reg_w(sd, R51x_I2C_SADDR_3, reg);
1021 /* Write "value" to I2C data port of OV511 */
1022 rc = reg_w(sd, R51x_I2C_DATA, value);
1026 /* Initiate 3-byte write cycle */
1027 rc = reg_w(sd, R518_I2C_CTL, 0x01);
1031 /* wait for write complete */
1033 return reg_r8(sd, R518_I2C_CTL);
1037 * returns: negative is error, pos or zero is data
1039 * The OV518 I2C I/O procedure is different, hence, this function.
1040 * This is normally only called from i2c_r(). Note that this function
1041 * always succeeds regardless of whether the sensor is present and working.
1043 static int i2c_r(struct sd *sd, __u8 reg)
1047 /* Select camera register */
1048 rc = reg_w(sd, R51x_I2C_SADDR_2, reg);
1052 /* Initiate 2-byte write cycle */
1053 rc = reg_w(sd, R518_I2C_CTL, 0x03);
1057 /* Initiate 2-byte read cycle */
1058 rc = reg_w(sd, R518_I2C_CTL, 0x05);
1061 value = reg_r(sd, R51x_I2C_DATA);
1062 PDEBUG(D_USBI, "i2c [0x%02X] -> 0x%02X", reg, value);
1066 /* Writes bits at positions specified by mask to an I2C reg. Bits that are in
1067 * the same position as 1's in "mask" are cleared and set to "value". Bits
1068 * that are in the same position as 0's in "mask" are preserved, regardless
1069 * of their respective state in "value".
1071 static int i2c_w_mask(struct sd *sd,
1079 value &= mask; /* Enforce mask on value */
1080 rc = i2c_r(sd, reg);
1083 oldval = rc & ~mask; /* Clear the masked bits */
1084 value |= oldval; /* Set the desired bits */
1085 return i2c_w(sd, reg, value);
1088 /* Temporarily stops OV511 from functioning. Must do this before changing
1089 * registers while the camera is streaming */
1090 static inline int ov51x_stop(struct sd *sd)
1092 PDEBUG(D_STREAM, "stopping");
1094 switch (sd->bridge) {
1096 case BRIDGE_OV511PLUS:
1097 return reg_w(sd, R51x_SYS_RESET, 0x3d);
1099 case BRIDGE_OV518PLUS:
1100 return reg_w_mask(sd, R51x_SYS_RESET, 0x3a, 0x3a);
1102 return reg_w(sd, OV519_SYS_RESET1, 0x0f);
1108 /* Restarts OV511 after ov511_stop() is called. Has no effect if it is not
1109 * actually stopped (for performance). */
1110 static inline int ov51x_restart(struct sd *sd)
1114 PDEBUG(D_STREAM, "restarting");
1119 /* Reinitialize the stream */
1120 switch (sd->bridge) {
1122 case BRIDGE_OV511PLUS:
1123 return reg_w(sd, R51x_SYS_RESET, 0x00);
1125 case BRIDGE_OV518PLUS:
1126 rc = reg_w(sd, 0x2f, 0x80);
1129 return reg_w(sd, R51x_SYS_RESET, 0x00);
1131 return reg_w(sd, OV519_SYS_RESET1, 0x00);
1137 /* This does an initial reset of an OmniVision sensor and ensures that I2C
1138 * is synchronized. Returns <0 on failure.
1140 static int init_ov_sensor(struct sd *sd)
1144 /* Reset the sensor */
1145 if (i2c_w(sd, 0x12, 0x80) < 0)
1148 /* Wait for it to initialize */
1151 for (i = 0; i < i2c_detect_tries; i++) {
1152 if (i2c_r(sd, OV7610_REG_ID_HIGH) == 0x7f &&
1153 i2c_r(sd, OV7610_REG_ID_LOW) == 0xa2) {
1154 PDEBUG(D_PROBE, "I2C synced in %d attempt(s)", i);
1158 /* Reset the sensor */
1159 if (i2c_w(sd, 0x12, 0x80) < 0)
1161 /* Wait for it to initialize */
1163 /* Dummy read to sync I2C */
1164 if (i2c_r(sd, 0x00) < 0)
1170 /* Set the read and write slave IDs. The "slave" argument is the write slave,
1171 * and the read slave will be set to (slave + 1).
1172 * This should not be called from outside the i2c I/O functions.
1173 * Sets I2C read and write slave IDs. Returns <0 for error
1175 static int ov51x_set_slave_ids(struct sd *sd,
1180 rc = reg_w(sd, R51x_I2C_W_SID, slave);
1183 return reg_w(sd, R51x_I2C_R_SID, slave + 1);
1186 static int write_regvals(struct sd *sd,
1187 const struct ov_regvals *regvals,
1193 rc = reg_w(sd, regvals->reg, regvals->val);
1201 static int write_i2c_regvals(struct sd *sd,
1202 const struct ov_i2c_regvals *regvals,
1208 rc = i2c_w(sd, regvals->reg, regvals->val);
1216 /****************************************************************************
1218 * OV511 and sensor configuration
1220 ***************************************************************************/
1222 /* This initializes the OV8110, OV8610 sensor. The OV8110 uses
1223 * the same register settings as the OV8610, since they are very similar.
1225 static int ov8xx0_configure(struct sd *sd)
1229 PDEBUG(D_PROBE, "starting ov8xx0 configuration");
1231 /* Detect sensor (sub)type */
1232 rc = i2c_r(sd, OV7610_REG_COM_I);
1234 PDEBUG(D_ERR, "Error detecting sensor type");
1237 if ((rc & 3) == 1) {
1238 sd->sensor = SEN_OV8610;
1240 PDEBUG(D_ERR, "Unknown image sensor version: %d", rc & 3);
1244 /* Set sensor-specific vars */
1245 /* sd->sif = 0; already done */
1249 /* This initializes the OV7610, OV7620, or OV76BE sensor. The OV76BE uses
1250 * the same register settings as the OV7610, since they are very similar.
1252 static int ov7xx0_configure(struct sd *sd)
1257 PDEBUG(D_PROBE, "starting OV7xx0 configuration");
1259 /* Detect sensor (sub)type */
1260 rc = i2c_r(sd, OV7610_REG_COM_I);
1263 * it appears to be wrongly detected as a 7610 by default */
1265 PDEBUG(D_ERR, "Error detecting sensor type");
1268 if ((rc & 3) == 3) {
1269 /* quick hack to make OV7670s work */
1270 high = i2c_r(sd, 0x0a);
1271 low = i2c_r(sd, 0x0b);
1272 /* info("%x, %x", high, low); */
1273 if (high == 0x76 && low == 0x73) {
1274 PDEBUG(D_PROBE, "Sensor is an OV7670");
1275 sd->sensor = SEN_OV7670;
1277 PDEBUG(D_PROBE, "Sensor is an OV7610");
1278 sd->sensor = SEN_OV7610;
1280 } else if ((rc & 3) == 1) {
1281 /* I don't know what's different about the 76BE yet. */
1282 if (i2c_r(sd, 0x15) & 1)
1283 PDEBUG(D_PROBE, "Sensor is an OV7620AE");
1285 PDEBUG(D_PROBE, "Sensor is an OV76BE");
1287 /* OV511+ will return all zero isoc data unless we
1288 * configure the sensor as a 7620. Someone needs to
1289 * find the exact reg. setting that causes this. */
1290 sd->sensor = SEN_OV76BE;
1291 } else if ((rc & 3) == 0) {
1292 /* try to read product id registers */
1293 high = i2c_r(sd, 0x0a);
1295 PDEBUG(D_ERR, "Error detecting camera chip PID");
1298 low = i2c_r(sd, 0x0b);
1300 PDEBUG(D_ERR, "Error detecting camera chip VER");
1306 PDEBUG(D_PROBE, "Sensor is an OV7630/OV7635");
1308 "7630 is not supported by this driver");
1311 PDEBUG(D_PROBE, "Sensor is an OV7645");
1312 sd->sensor = SEN_OV7640; /* FIXME */
1315 PDEBUG(D_PROBE, "Sensor is an OV7645B");
1316 sd->sensor = SEN_OV7640; /* FIXME */
1319 PDEBUG(D_PROBE, "Sensor is an OV7648");
1320 sd->sensor = SEN_OV7640; /* FIXME */
1323 PDEBUG(D_PROBE, "Unknown sensor: 0x76%x", low);
1327 PDEBUG(D_PROBE, "Sensor is an OV7620");
1328 sd->sensor = SEN_OV7620;
1331 PDEBUG(D_ERR, "Unknown image sensor version: %d", rc & 3);
1335 /* Set sensor-specific vars */
1336 /* sd->sif = 0; already done */
1340 /* This initializes the OV6620, OV6630, OV6630AE, or OV6630AF sensor. */
1341 static int ov6xx0_configure(struct sd *sd)
1344 PDEBUG(D_PROBE, "starting OV6xx0 configuration");
1346 /* Detect sensor (sub)type */
1347 rc = i2c_r(sd, OV7610_REG_COM_I);
1349 PDEBUG(D_ERR, "Error detecting sensor type");
1353 /* Ugh. The first two bits are the version bits, but
1354 * the entire register value must be used. I guess OVT
1355 * underestimated how many variants they would make. */
1358 sd->sensor = SEN_OV6630;
1360 "WARNING: Sensor is an OV66308. Your camera may have");
1361 PDEBUG(D_ERR, "been misdetected in previous driver versions.");
1364 sd->sensor = SEN_OV6620;
1367 sd->sensor = SEN_OV6630;
1368 PDEBUG(D_PROBE, "Sensor is an OV66308AE");
1371 sd->sensor = SEN_OV6630;
1372 PDEBUG(D_PROBE, "Sensor is an OV66308AF");
1375 sd->sensor = SEN_OV6630;
1377 "WARNING: Sensor is an OV66307. Your camera may have");
1378 PDEBUG(D_ERR, "been misdetected in previous driver versions.");
1381 PDEBUG(D_ERR, "FATAL: Unknown sensor version: 0x%02x", rc);
1385 /* Set sensor-specific vars */
1391 /* Turns on or off the LED. Only has an effect with OV511+/OV518(+)/OV519 */
1392 static void ov51x_led_control(struct sd *sd, int on)
1394 switch (sd->bridge) {
1395 /* OV511 has no LED control */
1396 case BRIDGE_OV511PLUS:
1397 reg_w(sd, R511_SYS_LED_CTL, on ? 1 : 0);
1400 case BRIDGE_OV518PLUS:
1401 reg_w_mask(sd, R518_GPIO_OUT, on ? 0x02 : 0x00, 0x02);
1404 reg_w_mask(sd, OV519_GPIO_DATA_OUT0, !on, 1); /* 0 / 1 */
1409 /* OV518 quantization tables are 8x4 (instead of 8x8) */
1410 static int ov518_upload_quan_tables(struct sd *sd)
1412 const unsigned char yQuanTable518[] = {
1413 5, 4, 5, 6, 6, 7, 7, 7,
1414 5, 5, 5, 5, 6, 7, 7, 7,
1415 6, 6, 6, 6, 7, 7, 7, 8,
1416 7, 7, 6, 7, 7, 7, 8, 8
1419 const unsigned char uvQuanTable518[] = {
1420 6, 6, 6, 7, 7, 7, 7, 7,
1421 6, 6, 6, 7, 7, 7, 7, 7,
1422 6, 6, 6, 7, 7, 7, 7, 8,
1423 7, 7, 7, 7, 7, 7, 8, 8
1426 const unsigned char *pYTable = yQuanTable518;
1427 const unsigned char *pUVTable = uvQuanTable518;
1428 unsigned char val0, val1;
1429 int i, rc, reg = R51x_COMP_LUT_BEGIN;
1431 PDEBUG(D_PROBE, "Uploading quantization tables");
1433 for (i = 0; i < 16; i++) {
1439 rc = reg_w(sd, reg, val0);
1448 rc = reg_w(sd, reg + 16, val0);
1458 /* This initializes the OV518/OV518+ and the sensor */
1459 static int ov518_configure(struct gspca_dev *gspca_dev)
1461 struct sd *sd = (struct sd *) gspca_dev;
1464 /* For 518 and 518+ */
1465 static struct ov_regvals init_518[] = {
1466 { R51x_SYS_RESET, 0x40 },
1467 { R51x_SYS_INIT, 0xe1 },
1468 { R51x_SYS_RESET, 0x3e },
1469 { R51x_SYS_INIT, 0xe1 },
1470 { R51x_SYS_RESET, 0x00 },
1471 { R51x_SYS_INIT, 0xe1 },
1476 static struct ov_regvals norm_518[] = {
1477 { R51x_SYS_SNAP, 0x02 }, /* Reset */
1478 { R51x_SYS_SNAP, 0x01 }, /* Enable */
1489 static struct ov_regvals norm_518_p[] = {
1490 { R51x_SYS_SNAP, 0x02 }, /* Reset */
1491 { R51x_SYS_SNAP, 0x01 }, /* Enable */
1508 /* First 5 bits of custom ID reg are a revision ID on OV518 */
1509 PDEBUG(D_PROBE, "Device revision %d",
1510 0x1F & reg_r(sd, R51x_SYS_CUST_ID));
1512 rc = write_regvals(sd, init_518, ARRAY_SIZE(init_518));
1516 /* Set LED GPIO pin to output mode */
1517 rc = reg_w_mask(sd, R518_GPIO_CTL, 0x00, 0x02);
1521 switch (sd->bridge) {
1523 rc = write_regvals(sd, norm_518, ARRAY_SIZE(norm_518));
1527 case BRIDGE_OV518PLUS:
1528 rc = write_regvals(sd, norm_518_p, ARRAY_SIZE(norm_518_p));
1534 rc = ov518_upload_quan_tables(sd);
1536 PDEBUG(D_ERR, "Error uploading quantization tables");
1540 rc = reg_w(sd, 0x2f, 0x80);
1547 static int ov519_configure(struct sd *sd)
1549 static const struct ov_regvals init_519[] = {
1550 { 0x5a, 0x6d }, /* EnableSystem */
1552 { 0x54, 0xff }, /* set bit2 to enable jpeg */
1556 /* Set LED pin to output mode. Bit 4 must be cleared or sensor
1557 * detection will fail. This deserves further investigation. */
1558 { OV519_GPIO_IO_CTRL0, 0xee },
1559 { 0x51, 0x0f }, /* SetUsbInit */
1562 /* windows reads 0x55 at this point*/
1565 return write_regvals(sd, init_519, ARRAY_SIZE(init_519));
1568 /* this function is called at probe time */
1569 static int sd_config(struct gspca_dev *gspca_dev,
1570 const struct usb_device_id *id)
1572 struct sd *sd = (struct sd *) gspca_dev;
1576 sd->bridge = id->driver_info;
1578 switch (sd->bridge) {
1580 case BRIDGE_OV518PLUS:
1581 ret = ov518_configure(gspca_dev);
1584 ret = ov519_configure(sd);
1591 ov51x_led_control(sd, 0); /* turn LED off */
1594 if (ov51x_set_slave_ids(sd, OV7xx0_SID) < 0)
1597 /* The OV519 must be more aggressive about sensor detection since
1598 * I2C write will never fail if the sensor is not present. We have
1599 * to try to initialize the sensor to detect its presence */
1600 if (init_ov_sensor(sd) >= 0) {
1601 if (ov7xx0_configure(sd) < 0) {
1602 PDEBUG(D_ERR, "Failed to configure OV7xx0");
1608 if (ov51x_set_slave_ids(sd, OV6xx0_SID) < 0)
1611 if (init_ov_sensor(sd) >= 0) {
1612 if (ov6xx0_configure(sd) < 0) {
1613 PDEBUG(D_ERR, "Failed to configure OV6xx0");
1619 if (ov51x_set_slave_ids(sd, OV8xx0_SID) < 0)
1622 if (init_ov_sensor(sd) < 0) {
1624 "Can't determine sensor slave IDs");
1627 if (ov8xx0_configure(sd) < 0) {
1629 "Failed to configure OV8xx0 sensor");
1635 cam = &gspca_dev->cam;
1636 switch (sd->bridge) {
1638 case BRIDGE_OV518PLUS:
1640 cam->cam_mode = ov518_vga_mode;
1641 cam->nmodes = ARRAY_SIZE(ov518_vga_mode);
1643 cam->cam_mode = ov518_sif_mode;
1644 cam->nmodes = ARRAY_SIZE(ov518_sif_mode);
1649 cam->cam_mode = ov519_vga_mode;
1650 cam->nmodes = ARRAY_SIZE(ov519_vga_mode);
1652 cam->cam_mode = ov519_sif_mode;
1653 cam->nmodes = ARRAY_SIZE(ov519_sif_mode);
1657 sd->brightness = BRIGHTNESS_DEF;
1658 sd->contrast = CONTRAST_DEF;
1659 sd->colors = COLOR_DEF;
1660 sd->hflip = HFLIP_DEF;
1661 sd->vflip = VFLIP_DEF;
1662 if (sd->sensor != SEN_OV7670)
1663 gspca_dev->ctrl_dis = (1 << HFLIP_IDX)
1667 PDEBUG(D_ERR, "OV519 Config failed");
1671 /* this function is called at probe and resume time */
1672 static int sd_init(struct gspca_dev *gspca_dev)
1674 struct sd *sd = (struct sd *) gspca_dev;
1676 /* initialize the sensor */
1677 switch (sd->sensor) {
1679 if (write_i2c_regvals(sd, norm_6x20, ARRAY_SIZE(norm_6x20)))
1683 if (write_i2c_regvals(sd, norm_6x30, ARRAY_SIZE(norm_6x30)))
1687 /* case SEN_OV7610: */
1688 /* case SEN_OV76BE: */
1689 if (write_i2c_regvals(sd, norm_7610, ARRAY_SIZE(norm_7610)))
1693 if (write_i2c_regvals(sd, norm_7620, ARRAY_SIZE(norm_7620)))
1697 if (write_i2c_regvals(sd, norm_7640, ARRAY_SIZE(norm_7640)))
1701 if (write_i2c_regvals(sd, norm_7670, ARRAY_SIZE(norm_7670)))
1705 if (write_i2c_regvals(sd, norm_8610, ARRAY_SIZE(norm_8610)))
1712 /* Sets up the OV518/OV518+ with the given image parameters
1714 * OV518 needs a completely different approach, until we can figure out what
1715 * the individual registers do. Also, only 15 FPS is supported now.
1717 * Do not put any sensor-specific code in here (including I2C I/O functions)
1719 static int ov518_mode_init_regs(struct sd *sd)
1723 /******** Set the mode ********/
1734 if (sd->bridge == BRIDGE_OV518) {
1735 /* Set 8-bit (YVYU) input format */
1736 reg_w_mask(sd, 0x20, 0x08, 0x08);
1738 /* Set 12-bit (4:2:0) output format */
1739 reg_w_mask(sd, 0x28, 0x80, 0xf0);
1740 reg_w_mask(sd, 0x38, 0x80, 0xf0);
1742 reg_w(sd, 0x28, 0x80);
1743 reg_w(sd, 0x38, 0x80);
1746 hsegs = sd->gspca_dev.width / 16;
1747 vsegs = sd->gspca_dev.height / 4;
1749 reg_w(sd, 0x29, hsegs);
1750 reg_w(sd, 0x2a, vsegs);
1752 reg_w(sd, 0x39, hsegs);
1753 reg_w(sd, 0x3a, vsegs);
1755 /* Windows driver does this here; who knows why */
1756 reg_w(sd, 0x2f, 0x80);
1758 /******** Set the framerate (to 30 FPS) ********/
1759 if (sd->bridge == BRIDGE_OV518PLUS)
1764 /* Mode independent, but framerate dependent, regs */
1765 reg_w(sd, 0x51, 0x04); /* Clock divider; lower==faster */
1766 reg_w(sd, 0x22, 0x18);
1767 reg_w(sd, 0x23, 0xff);
1769 if (sd->bridge == BRIDGE_OV518PLUS)
1770 reg_w(sd, 0x21, 0x19);
1772 reg_w(sd, 0x71, 0x17); /* Compression-related? */
1774 /* FIXME: Sensor-specific */
1775 /* Bit 5 is what matters here. Of course, it is "reserved" */
1776 i2c_w(sd, 0x54, 0x23);
1778 reg_w(sd, 0x2f, 0x80);
1780 if (sd->bridge == BRIDGE_OV518PLUS) {
1781 reg_w(sd, 0x24, 0x94);
1782 reg_w(sd, 0x25, 0x90);
1783 ov518_reg_w32(sd, 0xc4, 400, 2); /* 190h */
1784 ov518_reg_w32(sd, 0xc6, 540, 2); /* 21ch */
1785 ov518_reg_w32(sd, 0xc7, 540, 2); /* 21ch */
1786 ov518_reg_w32(sd, 0xc8, 108, 2); /* 6ch */
1787 ov518_reg_w32(sd, 0xca, 131098, 3); /* 2001ah */
1788 ov518_reg_w32(sd, 0xcb, 532, 2); /* 214h */
1789 ov518_reg_w32(sd, 0xcc, 2400, 2); /* 960h */
1790 ov518_reg_w32(sd, 0xcd, 32, 2); /* 20h */
1791 ov518_reg_w32(sd, 0xce, 608, 2); /* 260h */
1793 reg_w(sd, 0x24, 0x9f);
1794 reg_w(sd, 0x25, 0x90);
1795 ov518_reg_w32(sd, 0xc4, 400, 2); /* 190h */
1796 ov518_reg_w32(sd, 0xc6, 381, 2); /* 17dh */
1797 ov518_reg_w32(sd, 0xc7, 381, 2); /* 17dh */
1798 ov518_reg_w32(sd, 0xc8, 128, 2); /* 80h */
1799 ov518_reg_w32(sd, 0xca, 183331, 3); /* 2cc23h */
1800 ov518_reg_w32(sd, 0xcb, 746, 2); /* 2eah */
1801 ov518_reg_w32(sd, 0xcc, 1750, 2); /* 6d6h */
1802 ov518_reg_w32(sd, 0xcd, 45, 2); /* 2dh */
1803 ov518_reg_w32(sd, 0xce, 851, 2); /* 353h */
1806 reg_w(sd, 0x2f, 0x80);
1812 /* Sets up the OV519 with the given image parameters
1814 * OV519 needs a completely different approach, until we can figure out what
1815 * the individual registers do.
1817 * Do not put any sensor-specific code in here (including I2C I/O functions)
1819 static int ov519_mode_init_regs(struct sd *sd)
1821 static const struct ov_regvals mode_init_519_ov7670[] = {
1822 { 0x5d, 0x03 }, /* Turn off suspend mode */
1823 { 0x53, 0x9f }, /* was 9b in 1.65-1.08 */
1824 { 0x54, 0x0f }, /* bit2 (jpeg enable) */
1825 { 0xa2, 0x20 }, /* a2-a5 are undocumented */
1829 { 0x37, 0x00 }, /* SetUsbInit */
1830 { 0x55, 0x02 }, /* 4.096 Mhz audio clock */
1831 /* Enable both fields, YUV Input, disable defect comp (why?) */
1835 { 0x17, 0x50 }, /* undocumented */
1836 { 0x37, 0x00 }, /* undocumented */
1837 { 0x40, 0xff }, /* I2C timeout counter */
1838 { 0x46, 0x00 }, /* I2C clock prescaler */
1839 { 0x59, 0x04 }, /* new from windrv 090403 */
1840 { 0xff, 0x00 }, /* undocumented */
1841 /* windows reads 0x55 at this point, why? */
1844 static const struct ov_regvals mode_init_519[] = {
1845 { 0x5d, 0x03 }, /* Turn off suspend mode */
1846 { 0x53, 0x9f }, /* was 9b in 1.65-1.08 */
1847 { 0x54, 0x0f }, /* bit2 (jpeg enable) */
1848 { 0xa2, 0x20 }, /* a2-a5 are undocumented */
1852 { 0x37, 0x00 }, /* SetUsbInit */
1853 { 0x55, 0x02 }, /* 4.096 Mhz audio clock */
1854 /* Enable both fields, YUV Input, disable defect comp (why?) */
1856 { 0x17, 0x50 }, /* undocumented */
1857 { 0x37, 0x00 }, /* undocumented */
1858 { 0x40, 0xff }, /* I2C timeout counter */
1859 { 0x46, 0x00 }, /* I2C clock prescaler */
1860 { 0x59, 0x04 }, /* new from windrv 090403 */
1861 { 0xff, 0x00 }, /* undocumented */
1862 /* windows reads 0x55 at this point, why? */
1865 /******** Set the mode ********/
1866 if (sd->sensor != SEN_OV7670) {
1867 if (write_regvals(sd, mode_init_519,
1868 ARRAY_SIZE(mode_init_519)))
1870 if (sd->sensor == SEN_OV7640) {
1871 /* Select 8-bit input mode */
1872 reg_w_mask(sd, OV519_R20_DFR, 0x10, 0x10);
1875 if (write_regvals(sd, mode_init_519_ov7670,
1876 ARRAY_SIZE(mode_init_519_ov7670)))
1880 reg_w(sd, OV519_R10_H_SIZE, sd->gspca_dev.width >> 4);
1881 reg_w(sd, OV519_R11_V_SIZE, sd->gspca_dev.height >> 3);
1882 reg_w(sd, OV519_R12_X_OFFSETL, 0x00);
1883 reg_w(sd, OV519_R13_X_OFFSETH, 0x00);
1884 reg_w(sd, OV519_R14_Y_OFFSETL, 0x00);
1885 reg_w(sd, OV519_R15_Y_OFFSETH, 0x00);
1886 reg_w(sd, OV519_R16_DIVIDER, 0x00);
1887 reg_w(sd, OV519_R25_FORMAT, 0x03); /* YUV422 */
1888 reg_w(sd, 0x26, 0x00); /* Undocumented */
1890 /******** Set the framerate ********/
1892 sd->frame_rate = frame_rate;
1894 /* FIXME: These are only valid at the max resolution. */
1896 switch (sd->sensor) {
1898 switch (sd->frame_rate) {
1901 reg_w(sd, 0xa4, 0x0c);
1902 reg_w(sd, 0x23, 0xff);
1905 reg_w(sd, 0xa4, 0x0c);
1906 reg_w(sd, 0x23, 0x1f);
1909 reg_w(sd, 0xa4, 0x0c);
1910 reg_w(sd, 0x23, 0x1b);
1913 reg_w(sd, 0xa4, 0x04);
1914 reg_w(sd, 0x23, 0xff);
1918 reg_w(sd, 0xa4, 0x04);
1919 reg_w(sd, 0x23, 0x1f);
1923 reg_w(sd, 0xa4, 0x04);
1924 reg_w(sd, 0x23, 0x1b);
1930 switch (sd->frame_rate) {
1931 default: /* 15 fps */
1933 reg_w(sd, 0xa4, 0x06);
1934 reg_w(sd, 0x23, 0xff);
1937 reg_w(sd, 0xa4, 0x06);
1938 reg_w(sd, 0x23, 0x1f);
1941 reg_w(sd, 0xa4, 0x06);
1942 reg_w(sd, 0x23, 0x1b);
1946 case SEN_OV7670: /* guesses, based on 7640 */
1947 PDEBUG(D_STREAM, "Setting framerate to %d fps",
1948 (sd->frame_rate == 0) ? 15 : sd->frame_rate);
1949 reg_w(sd, 0xa4, 0x10);
1950 switch (sd->frame_rate) {
1952 reg_w(sd, 0x23, 0xff);
1955 reg_w(sd, 0x23, 0x1b);
1959 reg_w(sd, 0x23, 0xff);
1968 static int mode_init_ov_sensor_regs(struct sd *sd)
1970 struct gspca_dev *gspca_dev;
1973 gspca_dev = &sd->gspca_dev;
1974 qvga = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv;
1976 /******** Mode (VGA/QVGA) and sensor specific regs ********/
1977 switch (sd->sensor) {
1979 /* For OV8610 qvga means qsvga */
1980 i2c_w_mask(sd, OV7610_REG_COM_C, qvga ? (1 << 5) : 0, 1 << 5);
1983 i2c_w_mask(sd, 0x14, qvga ? 0x20 : 0x00, 0x20);
1986 /* i2c_w(sd, 0x2b, 0x00); */
1987 i2c_w_mask(sd, 0x14, qvga ? 0x20 : 0x00, 0x20);
1988 i2c_w_mask(sd, 0x28, qvga ? 0x00 : 0x20, 0x20);
1989 i2c_w(sd, 0x24, qvga ? 0x20 : 0x3a);
1990 i2c_w(sd, 0x25, qvga ? 0x30 : 0x60);
1991 i2c_w_mask(sd, 0x2d, qvga ? 0x40 : 0x00, 0x40);
1992 i2c_w_mask(sd, 0x67, qvga ? 0xf0 : 0x90, 0xf0);
1993 i2c_w_mask(sd, 0x74, qvga ? 0x20 : 0x00, 0x20);
1996 /* i2c_w(sd, 0x2b, 0x00); */
1997 i2c_w_mask(sd, 0x14, qvga ? 0x20 : 0x00, 0x20);
2000 /* i2c_w(sd, 0x2b, 0x00); */
2001 i2c_w_mask(sd, 0x14, qvga ? 0x20 : 0x00, 0x20);
2002 i2c_w_mask(sd, 0x28, qvga ? 0x00 : 0x20, 0x20);
2003 /* i2c_w(sd, 0x24, qvga ? 0x20 : 0x3a); */
2004 /* i2c_w(sd, 0x25, qvga ? 0x30 : 0x60); */
2005 /* i2c_w_mask(sd, 0x2d, qvga ? 0x40 : 0x00, 0x40); */
2006 /* i2c_w_mask(sd, 0x67, qvga ? 0xf0 : 0x90, 0xf0); */
2007 /* i2c_w_mask(sd, 0x74, qvga ? 0x20 : 0x00, 0x20); */
2010 /* set COM7_FMT_VGA or COM7_FMT_QVGA
2011 * do we need to set anything else?
2012 * HSTART etc are set in set_ov_sensor_window itself */
2013 i2c_w_mask(sd, OV7670_REG_COM7,
2014 qvga ? OV7670_COM7_FMT_QVGA : OV7670_COM7_FMT_VGA,
2015 OV7670_COM7_FMT_MASK);
2019 i2c_w_mask(sd, 0x14, qvga ? 0x20 : 0x00, 0x20);
2025 /******** Palette-specific regs ********/
2026 if (sd->sensor == SEN_OV7610 || sd->sensor == SEN_OV76BE) {
2027 /* not valid on the OV6620/OV7620/6630? */
2028 i2c_w_mask(sd, 0x0e, 0x00, 0x40);
2031 /* The OV518 needs special treatment. Although both the OV518
2032 * and the OV6630 support a 16-bit video bus, only the 8 bit Y
2033 * bus is actually used. The UV bus is tied to ground.
2034 * Therefore, the OV6630 needs to be in 8-bit multiplexed
2037 /* OV7640 is 8-bit only */
2039 if (sd->sensor != SEN_OV6630 && sd->sensor != SEN_OV7640)
2040 i2c_w_mask(sd, 0x13, 0x00, 0x20);
2042 /******** Clock programming ********/
2043 /* The OV6620 needs special handling. This prevents the
2044 * severe banding that normally occurs */
2045 if (sd->sensor == SEN_OV6620) {
2048 i2c_w(sd, 0x2a, 0x04);
2049 i2c_w(sd, 0x11, sd->clockdiv);
2050 i2c_w(sd, 0x2a, 0x84);
2051 /* This next setting is critical. It seems to improve
2052 * the gain or the contrast. The "reserved" bits seem
2053 * to have some effect in this case. */
2054 i2c_w(sd, 0x2d, 0x85);
2056 i2c_w(sd, 0x11, sd->clockdiv);
2059 /******** Special Features ********/
2060 /* no evidence this is possible with OV7670, either */
2062 if (sd->sensor != SEN_OV7640 && sd->sensor != SEN_OV7670)
2063 i2c_w_mask(sd, 0x12, 0x00, 0x02);
2065 /* Enable auto white balance */
2066 if (sd->sensor == SEN_OV7670)
2067 i2c_w_mask(sd, OV7670_REG_COM8, OV7670_COM8_AWB,
2070 i2c_w_mask(sd, 0x12, 0x04, 0x04);
2072 /* This will go away as soon as ov51x_mode_init_sensor_regs() */
2073 /* is fully tested. */
2074 /* 7620/6620/6630? don't have register 0x35, so play it safe */
2075 if (sd->sensor == SEN_OV7610 || sd->sensor == SEN_OV76BE) {
2077 i2c_w(sd, 0x35, 0x9e);
2079 i2c_w(sd, 0x35, 0x1e);
2084 static void sethvflip(struct sd *sd)
2086 if (sd->sensor != SEN_OV7670)
2088 if (sd->gspca_dev.streaming)
2090 i2c_w_mask(sd, OV7670_REG_MVFP,
2091 OV7670_MVFP_MIRROR * sd->hflip
2092 | OV7670_MVFP_VFLIP * sd->vflip,
2093 OV7670_MVFP_MIRROR | OV7670_MVFP_VFLIP);
2094 if (sd->gspca_dev.streaming)
2098 static int set_ov_sensor_window(struct sd *sd)
2100 struct gspca_dev *gspca_dev;
2102 int hwsbase, hwebase, vwsbase, vwebase, hwscale, vwscale;
2103 int ret, hstart, hstop, vstop, vstart;
2106 gspca_dev = &sd->gspca_dev;
2107 qvga = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv;
2109 /* The different sensor ICs handle setting up of window differently.
2110 * IF YOU SET IT WRONG, YOU WILL GET ALL ZERO ISOC DATA FROM OV51x!! */
2111 switch (sd->sensor) {
2122 vwsbase = vwebase = 0x05;
2131 /* HDG: this fixes U and V getting swapped */
2137 hwsbase = 0x2f; /* From 7620.SET (spec is wrong) */
2139 vwsbase = vwebase = 0x05;
2144 vwsbase = vwebase = 0x03;
2147 /*handling of OV7670 hardware sensor start and stop values
2148 * is very odd, compared to the other OV sensors */
2149 vwsbase = vwebase = hwebase = hwsbase = 0x00;
2155 switch (sd->sensor) {
2158 if (qvga) { /* QCIF */
2163 vwscale = 1; /* The datasheet says 0;
2168 if (qvga) { /* QSVGA */
2176 default: /* SEN_OV7xx0 */
2177 if (qvga) { /* QVGA */
2186 ret = mode_init_ov_sensor_regs(sd);
2190 if (sd->sensor == SEN_OV8610) {
2191 i2c_w_mask(sd, 0x2d, 0x05, 0x40);
2192 /* old 0x95, new 0x05 from windrv 090403 */
2193 /* bits 5-7: reserved */
2194 i2c_w_mask(sd, 0x28, 0x20, 0x20);
2195 /* bit 5: progressive mode on */
2198 /* The below is wrong for OV7670s because their window registers
2199 * only store the high bits in 0x17 to 0x1a */
2201 /* SRH Use sd->max values instead of requested win values */
2202 /* SCS Since we're sticking with only the max hardware widths
2203 * for a given mode */
2204 /* I can hard code this for OV7670s */
2205 /* Yes, these numbers do look odd, but they're tested and work! */
2206 if (sd->sensor == SEN_OV7670) {
2207 if (qvga) { /* QVGA from ov7670.c by
2208 * Jonathan Corbet */
2219 /* OV7670 hardware window registers are split across
2220 * multiple locations */
2221 i2c_w(sd, OV7670_REG_HSTART, hstart >> 3);
2222 i2c_w(sd, OV7670_REG_HSTOP, hstop >> 3);
2223 v = i2c_r(sd, OV7670_REG_HREF);
2224 v = (v & 0xc0) | ((hstop & 0x7) << 3) | (hstart & 0x07);
2225 msleep(10); /* need to sleep between read and write to
2227 i2c_w(sd, OV7670_REG_HREF, v);
2229 i2c_w(sd, OV7670_REG_VSTART, vstart >> 2);
2230 i2c_w(sd, OV7670_REG_VSTOP, vstop >> 2);
2231 v = i2c_r(sd, OV7670_REG_VREF);
2232 v = (v & 0xc0) | ((vstop & 0x3) << 2) | (vstart & 0x03);
2233 msleep(10); /* need to sleep between read and write to
2235 i2c_w(sd, OV7670_REG_VREF, v);
2238 i2c_w(sd, 0x17, hwsbase);
2239 i2c_w(sd, 0x18, hwebase + (sd->gspca_dev.width >> hwscale));
2240 i2c_w(sd, 0x19, vwsbase);
2241 i2c_w(sd, 0x1a, vwebase + (sd->gspca_dev.height >> vwscale));
2246 /* -- start the camera -- */
2247 static int sd_start(struct gspca_dev *gspca_dev)
2249 struct sd *sd = (struct sd *) gspca_dev;
2252 switch (sd->bridge) {
2254 case BRIDGE_OV518PLUS:
2255 ret = ov518_mode_init_regs(sd);
2258 ret = ov519_mode_init_regs(sd);
2264 ret = set_ov_sensor_window(sd);
2268 setcontrast(gspca_dev);
2269 setbrightness(gspca_dev);
2270 setcolors(gspca_dev);
2272 ret = ov51x_restart(sd);
2275 ov51x_led_control(sd, 1);
2278 PDEBUG(D_ERR, "camera start error:%d", ret);
2282 static void sd_stopN(struct gspca_dev *gspca_dev)
2284 struct sd *sd = (struct sd *) gspca_dev;
2287 ov51x_led_control(sd, 0);
2290 static void ov518_pkt_scan(struct gspca_dev *gspca_dev,
2291 struct gspca_frame *frame, /* target */
2292 __u8 *data, /* isoc packet */
2293 int len) /* iso packet length */
2295 PDEBUG(D_STREAM, "ov518_pkt_scan: %d bytes", len);
2299 PDEBUG(D_STREAM, "packet number: %d\n", (int)data[len]);
2302 /* A false positive here is likely, until OVT gives me
2303 * the definitive SOF/EOF format */
2304 if ((!(data[0] | data[1] | data[2] | data[3] | data[5])) && data[6]) {
2305 gspca_frame_add(gspca_dev, LAST_PACKET, frame, data, 0);
2306 gspca_frame_add(gspca_dev, FIRST_PACKET, frame, data, 0);
2309 /* intermediate packet */
2310 gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len);
2313 static void ov519_pkt_scan(struct gspca_dev *gspca_dev,
2314 struct gspca_frame *frame, /* target */
2315 __u8 *data, /* isoc packet */
2316 int len) /* iso packet length */
2318 /* Header of ov519 is 16 bytes:
2319 * Byte Value Description
2323 * 3 0xXX 0x50 = SOF, 0x51 = EOF
2324 * 9 0xXX 0x01 initial frame without data,
2325 * 0x00 standard frame with image
2326 * 14 Lo in EOF: length of image data / 8
2330 if (data[0] == 0xff && data[1] == 0xff && data[2] == 0xff) {
2332 case 0x50: /* start of frame */
2337 if (data[0] == 0xff || data[1] == 0xd8)
2338 gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
2341 gspca_dev->last_packet_type = DISCARD_PACKET;
2343 case 0x51: /* end of frame */
2345 gspca_dev->last_packet_type = DISCARD_PACKET;
2346 gspca_frame_add(gspca_dev, LAST_PACKET, frame,
2352 /* intermediate packet */
2353 gspca_frame_add(gspca_dev, INTER_PACKET, frame,
2357 static void sd_pkt_scan(struct gspca_dev *gspca_dev,
2358 struct gspca_frame *frame, /* target */
2359 __u8 *data, /* isoc packet */
2360 int len) /* iso packet length */
2362 struct sd *sd = (struct sd *) gspca_dev;
2364 switch (sd->bridge) {
2366 case BRIDGE_OV511PLUS:
2369 case BRIDGE_OV518PLUS:
2370 ov518_pkt_scan(gspca_dev, frame, data, len);
2373 ov519_pkt_scan(gspca_dev, frame, data, len);
2378 /* -- management routines -- */
2380 static void setbrightness(struct gspca_dev *gspca_dev)
2382 struct sd *sd = (struct sd *) gspca_dev;
2385 val = sd->brightness;
2386 switch (sd->sensor) {
2393 i2c_w(sd, OV7610_REG_BRT, val);
2396 /* 7620 doesn't like manual changes when in auto mode */
2398 * if (!sd->auto_brt) */
2399 i2c_w(sd, OV7610_REG_BRT, val);
2403 * i2c_w_mask(sd, OV7670_REG_COM8, 0, OV7670_COM8_AEC); */
2404 i2c_w(sd, OV7670_REG_BRIGHT, ov7670_abs_to_sm(val));
2409 static void setcontrast(struct gspca_dev *gspca_dev)
2411 struct sd *sd = (struct sd *) gspca_dev;
2415 switch (sd->sensor) {
2418 i2c_w(sd, OV7610_REG_CNT, val);
2421 i2c_w_mask(sd, OV7610_REG_CNT, val >> 4, 0x0f);
2424 static const __u8 ctab[] = {
2425 0x03, 0x09, 0x0b, 0x0f, 0x53, 0x6f, 0x35, 0x7f
2428 /* Use Y gamma control instead. Bit 0 enables it. */
2429 i2c_w(sd, 0x64, ctab[val >> 5]);
2433 static const __u8 ctab[] = {
2434 0x01, 0x05, 0x09, 0x11, 0x15, 0x35, 0x37, 0x57,
2435 0x5b, 0xa5, 0xa7, 0xc7, 0xc9, 0xcf, 0xef, 0xff
2438 /* Use Y gamma control instead. Bit 0 enables it. */
2439 i2c_w(sd, 0x64, ctab[val >> 4]);
2443 /* Use gain control instead. */
2444 i2c_w(sd, OV7610_REG_GAIN, val >> 2);
2447 /* check that this isn't just the same as ov7610 */
2448 i2c_w(sd, OV7670_REG_CONTRAS, val >> 1);
2453 static void setcolors(struct gspca_dev *gspca_dev)
2455 struct sd *sd = (struct sd *) gspca_dev;
2459 switch (sd->sensor) {
2465 i2c_w(sd, OV7610_REG_SAT, val);
2468 /* Use UV gamma control instead. Bits 0 & 7 are reserved. */
2469 /* rc = ov_i2c_write(sd->dev, 0x62, (val >> 9) & 0x7e);
2472 i2c_w(sd, OV7610_REG_SAT, val);
2475 i2c_w(sd, OV7610_REG_SAT, val & 0xf0);
2478 /* supported later once I work out how to do it
2479 * transparently fail now! */
2480 /* set REG_COM13 values for UV sat auto mode */
2485 static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
2487 struct sd *sd = (struct sd *) gspca_dev;
2489 sd->brightness = val;
2490 if (gspca_dev->streaming)
2491 setbrightness(gspca_dev);
2495 static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val)
2497 struct sd *sd = (struct sd *) gspca_dev;
2499 *val = sd->brightness;
2503 static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val)
2505 struct sd *sd = (struct sd *) gspca_dev;
2508 if (gspca_dev->streaming)
2509 setcontrast(gspca_dev);
2513 static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val)
2515 struct sd *sd = (struct sd *) gspca_dev;
2517 *val = sd->contrast;
2521 static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val)
2523 struct sd *sd = (struct sd *) gspca_dev;
2526 if (gspca_dev->streaming)
2527 setcolors(gspca_dev);
2531 static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val)
2533 struct sd *sd = (struct sd *) gspca_dev;
2539 static int sd_sethflip(struct gspca_dev *gspca_dev, __s32 val)
2541 struct sd *sd = (struct sd *) gspca_dev;
2544 if (gspca_dev->streaming)
2549 static int sd_gethflip(struct gspca_dev *gspca_dev, __s32 *val)
2551 struct sd *sd = (struct sd *) gspca_dev;
2557 static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val)
2559 struct sd *sd = (struct sd *) gspca_dev;
2562 if (gspca_dev->streaming)
2567 static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val)
2569 struct sd *sd = (struct sd *) gspca_dev;
2575 /* sub-driver description */
2576 static const struct sd_desc sd_desc = {
2577 .name = MODULE_NAME,
2579 .nctrls = ARRAY_SIZE(sd_ctrls),
2580 .config = sd_config,
2584 .pkt_scan = sd_pkt_scan,
2587 /* -- module initialisation -- */
2588 static const __devinitdata struct usb_device_id device_table[] = {
2589 {USB_DEVICE(0x041e, 0x4052), .driver_info = BRIDGE_OV519 },
2590 {USB_DEVICE(0x041e, 0x405f), .driver_info = BRIDGE_OV519 },
2591 {USB_DEVICE(0x041e, 0x4060), .driver_info = BRIDGE_OV519 },
2592 {USB_DEVICE(0x041e, 0x4061), .driver_info = BRIDGE_OV519 },
2593 {USB_DEVICE(0x041e, 0x4064), .driver_info = BRIDGE_OV519 },
2594 {USB_DEVICE(0x041e, 0x4068), .driver_info = BRIDGE_OV519 },
2595 {USB_DEVICE(0x045e, 0x028c), .driver_info = BRIDGE_OV519 },
2596 {USB_DEVICE(0x054c, 0x0154), .driver_info = BRIDGE_OV519 },
2597 {USB_DEVICE(0x054c, 0x0155), .driver_info = BRIDGE_OV519 },
2598 {USB_DEVICE(0x05a9, 0x0518), .driver_info = BRIDGE_OV518 },
2599 {USB_DEVICE(0x05a9, 0x0519), .driver_info = BRIDGE_OV519 },
2600 {USB_DEVICE(0x05a9, 0x0530), .driver_info = BRIDGE_OV519 },
2601 {USB_DEVICE(0x05a9, 0x4519), .driver_info = BRIDGE_OV519 },
2602 {USB_DEVICE(0x05a9, 0x8519), .driver_info = BRIDGE_OV519 },
2603 {USB_DEVICE(0x05a9, 0xa518), .driver_info = BRIDGE_OV518PLUS },
2607 MODULE_DEVICE_TABLE(usb, device_table);
2609 /* -- device connect -- */
2610 static int sd_probe(struct usb_interface *intf,
2611 const struct usb_device_id *id)
2613 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
2617 static struct usb_driver sd_driver = {
2618 .name = MODULE_NAME,
2619 .id_table = device_table,
2621 .disconnect = gspca_disconnect,
2623 .suspend = gspca_suspend,
2624 .resume = gspca_resume,
2628 /* -- module insert / remove -- */
2629 static int __init sd_mod_init(void)
2632 ret = usb_register(&sd_driver);
2635 PDEBUG(D_PROBE, "registered");
2638 static void __exit sd_mod_exit(void)
2640 usb_deregister(&sd_driver);
2641 PDEBUG(D_PROBE, "deregistered");
2644 module_init(sd_mod_init);
2645 module_exit(sd_mod_exit);
2647 module_param(frame_rate, int, 0644);
2648 MODULE_PARM_DESC(frame_rate, "Frame rate (5, 10, 15, 20 or 30 fps)");