4 * Copyright (C) 2008 Jean-Francois Moine (http://moinejf.free.fr)
5 * Copyright (C) 2009 Hans de Goede <hdegoede@redhat.com>
7 * This module is adapted from the ov51x-jpeg package, which itself
8 * was adapted from the ov511 driver.
10 * Original copyright for the ov511 driver is:
12 * Copyright (c) 1999-2006 Mark W. McClelland
13 * Support for OV519, OV8610 Copyright (c) 2003 Joerg Heckenbach
14 * Many improvements by Bret Wallach <bwallac1@san.rr.com>
15 * Color fixes by by Orion Sky Lawlor <olawlor@acm.org> (2/26/2000)
16 * OV7620 fixes by Charl P. Botha <cpbotha@ieee.org>
17 * Changes by Claudio Matsuoka <claudio@conectiva.com>
19 * ov51x-jpeg original copyright is:
21 * Copyright (c) 2004-2007 Romain Beauxis <toots@rastageeks.org>
22 * Support for OV7670 sensors was contributed by Sam Skipsey <aoanla@yahoo.com>
24 * This program is free software; you can redistribute it and/or modify
25 * it under the terms of the GNU General Public License as published by
26 * the Free Software Foundation; either version 2 of the License, or
29 * This program is distributed in the hope that it will be useful,
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 * GNU General Public License for more details.
34 * You should have received a copy of the GNU General Public License
35 * along with this program; if not, write to the Free Software
36 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
39 #define MODULE_NAME "ov519"
41 #include <linux/input.h>
44 /* The jpeg_hdr is used by w996Xcf only */
45 /* The CONEX_CAM define for jpeg.h needs renaming, now its used here too */
49 MODULE_AUTHOR("Jean-Francois Moine <http://moinejf.free.fr>");
50 MODULE_DESCRIPTION("OV519 USB Camera Driver");
51 MODULE_LICENSE("GPL");
53 /* global parameters */
54 static int frame_rate
;
56 /* Number of times to retry a failed I2C transaction. Increase this if you
57 * are getting "Failed to read sensor ID..." */
58 static int i2c_detect_tries
= 10;
60 /* ov519 device descriptor */
62 struct gspca_dev gspca_dev
; /* !! must be the first item */
67 #define BRIDGE_OV511 0
68 #define BRIDGE_OV511PLUS 1
69 #define BRIDGE_OV518 2
70 #define BRIDGE_OV518PLUS 3
71 #define BRIDGE_OV519 4
72 #define BRIDGE_OVFX2 5
73 #define BRIDGE_W9968CF 6
77 #define BRIDGE_INVERT_LED 8
79 char snapshot_pressed
;
80 char snapshot_needs_reset
;
82 /* Determined by sensor type */
93 #define QUALITY_MIN 50
94 #define QUALITY_MAX 70
95 #define QUALITY_DEF 50
97 __u8 stopped
; /* Streaming is temporarily paused */
100 __u8 frame_rate
; /* current Framerate */
101 __u8 clockdiv
; /* clockdiv override */
103 char sensor
; /* Type of image sensor chip (SEN_*) */
104 #define SEN_UNKNOWN 0
109 #define SEN_OV66308AF 5
112 #define SEN_OV7620AE 8
114 #define SEN_OV7648 10
115 #define SEN_OV7670 11
116 #define SEN_OV76BE 12
117 #define SEN_OV8610 13
122 int sensor_reg_cache
[256];
124 u8 jpeg_hdr
[JPEG_HDR_SZ
];
127 /* Note this is a bit of a hack, but the w9968cf driver needs the code for all
128 the ov sensors which is already present here. When we have the time we
129 really should move the sensor drivers to v4l2 sub drivers. */
132 /* V4L2 controls supported by the driver */
133 static int sd_setbrightness(struct gspca_dev
*gspca_dev
, __s32 val
);
134 static int sd_getbrightness(struct gspca_dev
*gspca_dev
, __s32
*val
);
135 static int sd_setcontrast(struct gspca_dev
*gspca_dev
, __s32 val
);
136 static int sd_getcontrast(struct gspca_dev
*gspca_dev
, __s32
*val
);
137 static int sd_setcolors(struct gspca_dev
*gspca_dev
, __s32 val
);
138 static int sd_getcolors(struct gspca_dev
*gspca_dev
, __s32
*val
);
139 static int sd_sethflip(struct gspca_dev
*gspca_dev
, __s32 val
);
140 static int sd_gethflip(struct gspca_dev
*gspca_dev
, __s32
*val
);
141 static int sd_setvflip(struct gspca_dev
*gspca_dev
, __s32 val
);
142 static int sd_getvflip(struct gspca_dev
*gspca_dev
, __s32
*val
);
143 static int sd_setautobrightness(struct gspca_dev
*gspca_dev
, __s32 val
);
144 static int sd_getautobrightness(struct gspca_dev
*gspca_dev
, __s32
*val
);
145 static int sd_setfreq(struct gspca_dev
*gspca_dev
, __s32 val
);
146 static int sd_getfreq(struct gspca_dev
*gspca_dev
, __s32
*val
);
147 static void setbrightness(struct gspca_dev
*gspca_dev
);
148 static void setcontrast(struct gspca_dev
*gspca_dev
);
149 static void setcolors(struct gspca_dev
*gspca_dev
);
150 static void setautobrightness(struct sd
*sd
);
151 static void setfreq(struct sd
*sd
);
153 static const struct ctrl sd_ctrls
[] = {
154 #define BRIGHTNESS_IDX 0
157 .id
= V4L2_CID_BRIGHTNESS
,
158 .type
= V4L2_CTRL_TYPE_INTEGER
,
159 .name
= "Brightness",
163 #define BRIGHTNESS_DEF 127
164 .default_value
= BRIGHTNESS_DEF
,
166 .set
= sd_setbrightness
,
167 .get
= sd_getbrightness
,
169 #define CONTRAST_IDX 1
172 .id
= V4L2_CID_CONTRAST
,
173 .type
= V4L2_CTRL_TYPE_INTEGER
,
178 #define CONTRAST_DEF 127
179 .default_value
= CONTRAST_DEF
,
181 .set
= sd_setcontrast
,
182 .get
= sd_getcontrast
,
187 .id
= V4L2_CID_SATURATION
,
188 .type
= V4L2_CTRL_TYPE_INTEGER
,
193 #define COLOR_DEF 127
194 .default_value
= COLOR_DEF
,
199 /* The flip controls work with ov7670 only */
203 .id
= V4L2_CID_HFLIP
,
204 .type
= V4L2_CTRL_TYPE_BOOLEAN
,
210 .default_value
= HFLIP_DEF
,
218 .id
= V4L2_CID_VFLIP
,
219 .type
= V4L2_CTRL_TYPE_BOOLEAN
,
225 .default_value
= VFLIP_DEF
,
230 #define AUTOBRIGHT_IDX 5
233 .id
= V4L2_CID_AUTOBRIGHTNESS
,
234 .type
= V4L2_CTRL_TYPE_BOOLEAN
,
235 .name
= "Auto Brightness",
239 #define AUTOBRIGHT_DEF 1
240 .default_value
= AUTOBRIGHT_DEF
,
242 .set
= sd_setautobrightness
,
243 .get
= sd_getautobrightness
,
248 .id
= V4L2_CID_POWER_LINE_FREQUENCY
,
249 .type
= V4L2_CTRL_TYPE_MENU
,
250 .name
= "Light frequency filter",
252 .maximum
= 2, /* 0: 0, 1: 50Hz, 2:60Hz */
255 .default_value
= FREQ_DEF
,
260 #define OV7670_FREQ_IDX 7
263 .id
= V4L2_CID_POWER_LINE_FREQUENCY
,
264 .type
= V4L2_CTRL_TYPE_MENU
,
265 .name
= "Light frequency filter",
267 .maximum
= 3, /* 0: 0, 1: 50Hz, 2:60Hz 3: Auto Hz */
269 #define OV7670_FREQ_DEF 3
270 .default_value
= OV7670_FREQ_DEF
,
277 static const struct v4l2_pix_format ov519_vga_mode
[] = {
278 {320, 240, V4L2_PIX_FMT_JPEG
, V4L2_FIELD_NONE
,
280 .sizeimage
= 320 * 240 * 3 / 8 + 590,
281 .colorspace
= V4L2_COLORSPACE_JPEG
,
283 {640, 480, V4L2_PIX_FMT_JPEG
, V4L2_FIELD_NONE
,
285 .sizeimage
= 640 * 480 * 3 / 8 + 590,
286 .colorspace
= V4L2_COLORSPACE_JPEG
,
289 static const struct v4l2_pix_format ov519_sif_mode
[] = {
290 {160, 120, V4L2_PIX_FMT_JPEG
, V4L2_FIELD_NONE
,
292 .sizeimage
= 160 * 120 * 3 / 8 + 590,
293 .colorspace
= V4L2_COLORSPACE_JPEG
,
295 {176, 144, V4L2_PIX_FMT_JPEG
, V4L2_FIELD_NONE
,
297 .sizeimage
= 176 * 144 * 3 / 8 + 590,
298 .colorspace
= V4L2_COLORSPACE_JPEG
,
300 {320, 240, V4L2_PIX_FMT_JPEG
, V4L2_FIELD_NONE
,
302 .sizeimage
= 320 * 240 * 3 / 8 + 590,
303 .colorspace
= V4L2_COLORSPACE_JPEG
,
305 {352, 288, V4L2_PIX_FMT_JPEG
, V4L2_FIELD_NONE
,
307 .sizeimage
= 352 * 288 * 3 / 8 + 590,
308 .colorspace
= V4L2_COLORSPACE_JPEG
,
312 /* Note some of the sizeimage values for the ov511 / ov518 may seem
313 larger then necessary, however they need to be this big as the ov511 /
314 ov518 always fills the entire isoc frame, using 0 padding bytes when
315 it doesn't have any data. So with low framerates the amount of data
316 transfered can become quite large (libv4l will remove all the 0 padding
318 static const struct v4l2_pix_format ov518_vga_mode
[] = {
319 {320, 240, V4L2_PIX_FMT_OV518
, V4L2_FIELD_NONE
,
321 .sizeimage
= 320 * 240 * 3,
322 .colorspace
= V4L2_COLORSPACE_JPEG
,
324 {640, 480, V4L2_PIX_FMT_OV518
, V4L2_FIELD_NONE
,
326 .sizeimage
= 640 * 480 * 2,
327 .colorspace
= V4L2_COLORSPACE_JPEG
,
330 static const struct v4l2_pix_format ov518_sif_mode
[] = {
331 {160, 120, V4L2_PIX_FMT_OV518
, V4L2_FIELD_NONE
,
334 .colorspace
= V4L2_COLORSPACE_JPEG
,
336 {176, 144, V4L2_PIX_FMT_OV518
, V4L2_FIELD_NONE
,
339 .colorspace
= V4L2_COLORSPACE_JPEG
,
341 {320, 240, V4L2_PIX_FMT_OV518
, V4L2_FIELD_NONE
,
343 .sizeimage
= 320 * 240 * 3,
344 .colorspace
= V4L2_COLORSPACE_JPEG
,
346 {352, 288, V4L2_PIX_FMT_OV518
, V4L2_FIELD_NONE
,
348 .sizeimage
= 352 * 288 * 3,
349 .colorspace
= V4L2_COLORSPACE_JPEG
,
353 static const struct v4l2_pix_format ov511_vga_mode
[] = {
354 {320, 240, V4L2_PIX_FMT_OV511
, V4L2_FIELD_NONE
,
356 .sizeimage
= 320 * 240 * 3,
357 .colorspace
= V4L2_COLORSPACE_JPEG
,
359 {640, 480, V4L2_PIX_FMT_OV511
, V4L2_FIELD_NONE
,
361 .sizeimage
= 640 * 480 * 2,
362 .colorspace
= V4L2_COLORSPACE_JPEG
,
365 static const struct v4l2_pix_format ov511_sif_mode
[] = {
366 {160, 120, V4L2_PIX_FMT_OV511
, V4L2_FIELD_NONE
,
369 .colorspace
= V4L2_COLORSPACE_JPEG
,
371 {176, 144, V4L2_PIX_FMT_OV511
, V4L2_FIELD_NONE
,
374 .colorspace
= V4L2_COLORSPACE_JPEG
,
376 {320, 240, V4L2_PIX_FMT_OV511
, V4L2_FIELD_NONE
,
378 .sizeimage
= 320 * 240 * 3,
379 .colorspace
= V4L2_COLORSPACE_JPEG
,
381 {352, 288, V4L2_PIX_FMT_OV511
, V4L2_FIELD_NONE
,
383 .sizeimage
= 352 * 288 * 3,
384 .colorspace
= V4L2_COLORSPACE_JPEG
,
388 static const struct v4l2_pix_format ovfx2_vga_mode
[] = {
389 {320, 240, V4L2_PIX_FMT_SBGGR8
, V4L2_FIELD_NONE
,
391 .sizeimage
= 320 * 240,
392 .colorspace
= V4L2_COLORSPACE_SRGB
,
394 {640, 480, V4L2_PIX_FMT_SBGGR8
, V4L2_FIELD_NONE
,
396 .sizeimage
= 640 * 480,
397 .colorspace
= V4L2_COLORSPACE_SRGB
,
400 static const struct v4l2_pix_format ovfx2_cif_mode
[] = {
401 {160, 120, V4L2_PIX_FMT_SBGGR8
, V4L2_FIELD_NONE
,
403 .sizeimage
= 160 * 120,
404 .colorspace
= V4L2_COLORSPACE_SRGB
,
406 {176, 144, V4L2_PIX_FMT_SBGGR8
, V4L2_FIELD_NONE
,
408 .sizeimage
= 176 * 144,
409 .colorspace
= V4L2_COLORSPACE_SRGB
,
411 {320, 240, V4L2_PIX_FMT_SBGGR8
, V4L2_FIELD_NONE
,
413 .sizeimage
= 320 * 240,
414 .colorspace
= V4L2_COLORSPACE_SRGB
,
416 {352, 288, V4L2_PIX_FMT_SBGGR8
, V4L2_FIELD_NONE
,
418 .sizeimage
= 352 * 288,
419 .colorspace
= V4L2_COLORSPACE_SRGB
,
422 static const struct v4l2_pix_format ovfx2_ov2610_mode
[] = {
423 {1600, 1200, V4L2_PIX_FMT_SBGGR8
, V4L2_FIELD_NONE
,
424 .bytesperline
= 1600,
425 .sizeimage
= 1600 * 1200,
426 .colorspace
= V4L2_COLORSPACE_SRGB
},
428 static const struct v4l2_pix_format ovfx2_ov3610_mode
[] = {
429 {640, 480, V4L2_PIX_FMT_SBGGR8
, V4L2_FIELD_NONE
,
431 .sizeimage
= 640 * 480,
432 .colorspace
= V4L2_COLORSPACE_SRGB
,
434 {800, 600, V4L2_PIX_FMT_SBGGR8
, V4L2_FIELD_NONE
,
436 .sizeimage
= 800 * 600,
437 .colorspace
= V4L2_COLORSPACE_SRGB
,
439 {1024, 768, V4L2_PIX_FMT_SBGGR8
, V4L2_FIELD_NONE
,
440 .bytesperline
= 1024,
441 .sizeimage
= 1024 * 768,
442 .colorspace
= V4L2_COLORSPACE_SRGB
,
444 {1600, 1200, V4L2_PIX_FMT_SBGGR8
, V4L2_FIELD_NONE
,
445 .bytesperline
= 1600,
446 .sizeimage
= 1600 * 1200,
447 .colorspace
= V4L2_COLORSPACE_SRGB
,
449 {2048, 1536, V4L2_PIX_FMT_SBGGR8
, V4L2_FIELD_NONE
,
450 .bytesperline
= 2048,
451 .sizeimage
= 2048 * 1536,
452 .colorspace
= V4L2_COLORSPACE_SRGB
,
457 /* Registers common to OV511 / OV518 */
458 #define R51x_FIFO_PSIZE 0x30 /* 2 bytes wide w/ OV518(+) */
459 #define R51x_SYS_RESET 0x50
460 /* Reset type flags */
461 #define OV511_RESET_OMNICE 0x08
462 #define R51x_SYS_INIT 0x53
463 #define R51x_SYS_SNAP 0x52
464 #define R51x_SYS_CUST_ID 0x5F
465 #define R51x_COMP_LUT_BEGIN 0x80
467 /* OV511 Camera interface register numbers */
468 #define R511_CAM_DELAY 0x10
469 #define R511_CAM_EDGE 0x11
470 #define R511_CAM_PXCNT 0x12
471 #define R511_CAM_LNCNT 0x13
472 #define R511_CAM_PXDIV 0x14
473 #define R511_CAM_LNDIV 0x15
474 #define R511_CAM_UV_EN 0x16
475 #define R511_CAM_LINE_MODE 0x17
476 #define R511_CAM_OPTS 0x18
478 #define R511_SNAP_FRAME 0x19
479 #define R511_SNAP_PXCNT 0x1A
480 #define R511_SNAP_LNCNT 0x1B
481 #define R511_SNAP_PXDIV 0x1C
482 #define R511_SNAP_LNDIV 0x1D
483 #define R511_SNAP_UV_EN 0x1E
484 #define R511_SNAP_UV_EN 0x1E
485 #define R511_SNAP_OPTS 0x1F
487 #define R511_DRAM_FLOW_CTL 0x20
488 #define R511_FIFO_OPTS 0x31
489 #define R511_I2C_CTL 0x40
490 #define R511_SYS_LED_CTL 0x55 /* OV511+ only */
491 #define R511_COMP_EN 0x78
492 #define R511_COMP_LUT_EN 0x79
494 /* OV518 Camera interface register numbers */
495 #define R518_GPIO_OUT 0x56 /* OV518(+) only */
496 #define R518_GPIO_CTL 0x57 /* OV518(+) only */
498 /* OV519 Camera interface register numbers */
499 #define OV519_R10_H_SIZE 0x10
500 #define OV519_R11_V_SIZE 0x11
501 #define OV519_R12_X_OFFSETL 0x12
502 #define OV519_R13_X_OFFSETH 0x13
503 #define OV519_R14_Y_OFFSETL 0x14
504 #define OV519_R15_Y_OFFSETH 0x15
505 #define OV519_R16_DIVIDER 0x16
506 #define OV519_R20_DFR 0x20
507 #define OV519_R25_FORMAT 0x25
509 /* OV519 System Controller register numbers */
510 #define OV519_SYS_RESET1 0x51
511 #define OV519_SYS_EN_CLK1 0x54
513 #define OV519_GPIO_DATA_OUT0 0x71
514 #define OV519_GPIO_IO_CTRL0 0x72
516 #define OV511_ENDPOINT_ADDRESS 1 /* Isoc endpoint number */
519 * The FX2 chip does not give us a zero length read at end of frame.
520 * It does, however, give a short read at the end of a frame, if
521 * necessary, rather than run two frames together.
523 * By choosing the right bulk transfer size, we are guaranteed to always
524 * get a short read for the last read of each frame. Frame sizes are
525 * always a composite number (width * height, or a multiple) so if we
526 * choose a prime number, we are guaranteed that the last read of a
527 * frame will be short.
529 * But it isn't that easy: the 2.6 kernel requires a multiple of 4KB,
530 * otherwise EOVERFLOW "babbling" errors occur. I have not been able
531 * to figure out why. [PMiller]
533 * The constant (13 * 4096) is the largest "prime enough" number less than 64KB.
535 * It isn't enough to know the number of bytes per frame, in case we
536 * have data dropouts or buffer overruns (even though the FX2 double
537 * buffers, there are some pretty strict real time constraints for
538 * isochronous transfer for larger frame sizes).
540 #define OVFX2_BULK_SIZE (13 * 4096)
543 #define R51x_I2C_W_SID 0x41
544 #define R51x_I2C_SADDR_3 0x42
545 #define R51x_I2C_SADDR_2 0x43
546 #define R51x_I2C_R_SID 0x44
547 #define R51x_I2C_DATA 0x45
548 #define R518_I2C_CTL 0x47 /* OV518(+) only */
549 #define OVFX2_I2C_ADDR 0x00
552 #define OV7xx0_SID 0x42
553 #define OV_HIRES_SID 0x60 /* OV9xxx / OV2xxx / OV3xxx */
554 #define OV8xx0_SID 0xa0
555 #define OV6xx0_SID 0xc0
557 /* OV7610 registers */
558 #define OV7610_REG_GAIN 0x00 /* gain setting (5:0) */
559 #define OV7610_REG_BLUE 0x01 /* blue channel balance */
560 #define OV7610_REG_RED 0x02 /* red channel balance */
561 #define OV7610_REG_SAT 0x03 /* saturation */
562 #define OV8610_REG_HUE 0x04 /* 04 reserved */
563 #define OV7610_REG_CNT 0x05 /* Y contrast */
564 #define OV7610_REG_BRT 0x06 /* Y brightness */
565 #define OV7610_REG_COM_C 0x14 /* misc common regs */
566 #define OV7610_REG_ID_HIGH 0x1c /* manufacturer ID MSB */
567 #define OV7610_REG_ID_LOW 0x1d /* manufacturer ID LSB */
568 #define OV7610_REG_COM_I 0x29 /* misc settings */
570 /* OV7670 registers */
571 #define OV7670_REG_GAIN 0x00 /* Gain lower 8 bits (rest in vref) */
572 #define OV7670_REG_BLUE 0x01 /* blue gain */
573 #define OV7670_REG_RED 0x02 /* red gain */
574 #define OV7670_REG_VREF 0x03 /* Pieces of GAIN, VSTART, VSTOP */
575 #define OV7670_REG_COM1 0x04 /* Control 1 */
576 #define OV7670_REG_AECHH 0x07 /* AEC MS 5 bits */
577 #define OV7670_REG_COM3 0x0c /* Control 3 */
578 #define OV7670_REG_COM4 0x0d /* Control 4 */
579 #define OV7670_REG_COM5 0x0e /* All "reserved" */
580 #define OV7670_REG_COM6 0x0f /* Control 6 */
581 #define OV7670_REG_AECH 0x10 /* More bits of AEC value */
582 #define OV7670_REG_CLKRC 0x11 /* Clock control */
583 #define OV7670_REG_COM7 0x12 /* Control 7 */
584 #define OV7670_COM7_FMT_VGA 0x00
585 #define OV7670_COM7_YUV 0x00 /* YUV */
586 #define OV7670_COM7_FMT_QVGA 0x10 /* QVGA format */
587 #define OV7670_COM7_FMT_MASK 0x38
588 #define OV7670_COM7_RESET 0x80 /* Register reset */
589 #define OV7670_REG_COM8 0x13 /* Control 8 */
590 #define OV7670_COM8_AEC 0x01 /* Auto exposure enable */
591 #define OV7670_COM8_AWB 0x02 /* White balance enable */
592 #define OV7670_COM8_AGC 0x04 /* Auto gain enable */
593 #define OV7670_COM8_BFILT 0x20 /* Band filter enable */
594 #define OV7670_COM8_AECSTEP 0x40 /* Unlimited AEC step size */
595 #define OV7670_COM8_FASTAEC 0x80 /* Enable fast AGC/AEC */
596 #define OV7670_REG_COM9 0x14 /* Control 9 - gain ceiling */
597 #define OV7670_REG_COM10 0x15 /* Control 10 */
598 #define OV7670_REG_HSTART 0x17 /* Horiz start high bits */
599 #define OV7670_REG_HSTOP 0x18 /* Horiz stop high bits */
600 #define OV7670_REG_VSTART 0x19 /* Vert start high bits */
601 #define OV7670_REG_VSTOP 0x1a /* Vert stop high bits */
602 #define OV7670_REG_MVFP 0x1e /* Mirror / vflip */
603 #define OV7670_MVFP_VFLIP 0x10 /* vertical flip */
604 #define OV7670_MVFP_MIRROR 0x20 /* Mirror image */
605 #define OV7670_REG_AEW 0x24 /* AGC upper limit */
606 #define OV7670_REG_AEB 0x25 /* AGC lower limit */
607 #define OV7670_REG_VPT 0x26 /* AGC/AEC fast mode op region */
608 #define OV7670_REG_HREF 0x32 /* HREF pieces */
609 #define OV7670_REG_TSLB 0x3a /* lots of stuff */
610 #define OV7670_REG_COM11 0x3b /* Control 11 */
611 #define OV7670_COM11_EXP 0x02
612 #define OV7670_COM11_HZAUTO 0x10 /* Auto detect 50/60 Hz */
613 #define OV7670_REG_COM12 0x3c /* Control 12 */
614 #define OV7670_REG_COM13 0x3d /* Control 13 */
615 #define OV7670_COM13_GAMMA 0x80 /* Gamma enable */
616 #define OV7670_COM13_UVSAT 0x40 /* UV saturation auto adjustment */
617 #define OV7670_REG_COM14 0x3e /* Control 14 */
618 #define OV7670_REG_EDGE 0x3f /* Edge enhancement factor */
619 #define OV7670_REG_COM15 0x40 /* Control 15 */
620 #define OV7670_COM15_R00FF 0xc0 /* 00 to FF */
621 #define OV7670_REG_COM16 0x41 /* Control 16 */
622 #define OV7670_COM16_AWBGAIN 0x08 /* AWB gain enable */
623 #define OV7670_REG_BRIGHT 0x55 /* Brightness */
624 #define OV7670_REG_CONTRAS 0x56 /* Contrast control */
625 #define OV7670_REG_GFIX 0x69 /* Fix gain control */
626 #define OV7670_REG_RGB444 0x8c /* RGB 444 control */
627 #define OV7670_REG_HAECC1 0x9f /* Hist AEC/AGC control 1 */
628 #define OV7670_REG_HAECC2 0xa0 /* Hist AEC/AGC control 2 */
629 #define OV7670_REG_BD50MAX 0xa5 /* 50hz banding step limit */
630 #define OV7670_REG_HAECC3 0xa6 /* Hist AEC/AGC control 3 */
631 #define OV7670_REG_HAECC4 0xa7 /* Hist AEC/AGC control 4 */
632 #define OV7670_REG_HAECC5 0xa8 /* Hist AEC/AGC control 5 */
633 #define OV7670_REG_HAECC6 0xa9 /* Hist AEC/AGC control 6 */
634 #define OV7670_REG_HAECC7 0xaa /* Hist AEC/AGC control 7 */
635 #define OV7670_REG_BD60MAX 0xab /* 60hz banding step limit */
641 struct ov_i2c_regvals
{
646 /* Settings for OV2610 camera chip */
647 static const struct ov_i2c_regvals norm_2610
[] =
649 { 0x12, 0x80 }, /* reset */
652 static const struct ov_i2c_regvals norm_3620b
[] =
655 * From the datasheet: "Note that after writing to register COMH
656 * (0x12) to change the sensor mode, registers related to the
657 * sensor’s cropping window will be reset back to their default
660 * "wait 4096 external clock ... to make sure the sensor is
661 * stable and ready to access registers" i.e. 160us at 24MHz
664 { 0x12, 0x80 }, /* COMH reset */
665 { 0x12, 0x00 }, /* QXGA, master */
668 * 11 CLKRC "Clock Rate Control"
669 * [7] internal frequency doublers: on
670 * [6] video port mode: master
671 * [5:0] clock divider: 1
676 * 13 COMI "Common Control I"
677 * = 192 (0xC0) 11000000
678 * COMI[7] "AEC speed selection"
679 * = 1 (0x01) 1....... "Faster AEC correction"
680 * COMI[6] "AEC speed step selection"
681 * = 1 (0x01) .1...... "Big steps, fast"
682 * COMI[5] "Banding filter on off"
683 * = 0 (0x00) ..0..... "Off"
684 * COMI[4] "Banding filter option"
685 * = 0 (0x00) ...0.... "Main clock is 48 MHz and
688 * = 0 (0x00) ....0...
689 * COMI[2] "AGC auto manual control selection"
690 * = 0 (0x00) .....0.. "Manual"
691 * COMI[1] "AWB auto manual control selection"
692 * = 0 (0x00) ......0. "Manual"
693 * COMI[0] "Exposure control"
694 * = 0 (0x00) .......0 "Manual"
699 * 09 COMC "Common Control C"
700 * = 8 (0x08) 00001000
701 * COMC[7:5] "Reserved"
702 * = 0 (0x00) 000.....
703 * COMC[4] "Sleep Mode Enable"
704 * = 0 (0x00) ...0.... "Normal mode"
705 * COMC[3:2] "Sensor sampling reset timing selection"
706 * = 2 (0x02) ....10.. "Longer reset time"
707 * COMC[1:0] "Output drive current select"
708 * = 0 (0x00) ......00 "Weakest"
713 * 0C COMD "Common Control D"
714 * = 8 (0x08) 00001000
716 * = 0 (0x00) 0.......
717 * COMD[6] "Swap MSB and LSB at the output port"
718 * = 0 (0x00) .0...... "False"
719 * COMD[5:3] "Reserved"
720 * = 1 (0x01) ..001...
721 * COMD[2] "Output Average On Off"
722 * = 0 (0x00) .....0.. "Output Normal"
723 * COMD[1] "Sensor precharge voltage selection"
724 * = 0 (0x00) ......0. "Selects internal
725 * reference precharge
727 * COMD[0] "Snapshot option"
728 * = 0 (0x00) .......0 "Enable live video output
729 * after snapshot sequence"
734 * 0D COME "Common Control E"
735 * = 161 (0xA1) 10100001
736 * COME[7] "Output average option"
737 * = 1 (0x01) 1....... "Output average of 4 pixels"
738 * COME[6] "Anti-blooming control"
739 * = 0 (0x00) .0...... "Off"
740 * COME[5:3] "Reserved"
741 * = 4 (0x04) ..100...
742 * COME[2] "Clock output power down pin status"
743 * = 0 (0x00) .....0.. "Tri-state data output pin
745 * COME[1] "Data output pin status selection at power down"
746 * = 0 (0x00) ......0. "Tri-state VSYNC, PCLK,
747 * HREF, and CHSYNC pins on
749 * COME[0] "Auto zero circuit select"
750 * = 1 (0x01) .......1 "On"
755 * 0E COMF "Common Control F"
756 * = 112 (0x70) 01110000
757 * COMF[7] "System clock selection"
758 * = 0 (0x00) 0....... "Use 24 MHz system clock"
759 * COMF[6:4] "Reserved"
760 * = 7 (0x07) .111....
761 * COMF[3] "Manual auto negative offset canceling selection"
762 * = 0 (0x00) ....0... "Auto detect negative
763 * offset and cancel it"
764 * COMF[2:0] "Reserved"
765 * = 0 (0x00) .....000
770 * 0F COMG "Common Control G"
771 * = 66 (0x42) 01000010
772 * COMG[7] "Optical black output selection"
773 * = 0 (0x00) 0....... "Disable"
774 * COMG[6] "Black level calibrate selection"
775 * = 1 (0x01) .1...... "Use optical black pixels
777 * COMG[5:4] "Reserved"
778 * = 0 (0x00) ..00....
779 * COMG[3] "Channel offset adjustment"
780 * = 0 (0x00) ....0... "Disable offset adjustment"
781 * COMG[2] "ADC black level calibration option"
782 * = 0 (0x00) .....0.. "Use B/G line and G/R
783 * line to calibrate each
784 * channel's black level"
786 * = 1 (0x01) ......1.
787 * COMG[0] "ADC black level calibration enable"
788 * = 0 (0x00) .......0 "Disable"
793 * 14 COMJ "Common Control J"
794 * = 198 (0xC6) 11000110
795 * COMJ[7:6] "AGC gain ceiling"
796 * = 3 (0x03) 11...... "8x"
797 * COMJ[5:4] "Reserved"
798 * = 0 (0x00) ..00....
799 * COMJ[3] "Auto banding filter"
800 * = 0 (0x00) ....0... "Banding filter is always
801 * on off depending on
803 * COMJ[2] "VSYNC drop option"
804 * = 1 (0x01) .....1.. "SYNC is dropped if frame
806 * COMJ[1] "Frame data drop"
807 * = 1 (0x01) ......1. "Drop frame data if
808 * exposure is not within
809 * tolerance. In AEC mode,
810 * data is normally dropped
811 * when data is out of
814 * = 0 (0x00) .......0
819 * 15 COMK "Common Control K"
820 * = 2 (0x02) 00000010
821 * COMK[7] "CHSYNC pin output swap"
822 * = 0 (0x00) 0....... "CHSYNC"
823 * COMK[6] "HREF pin output swap"
824 * = 0 (0x00) .0...... "HREF"
825 * COMK[5] "PCLK output selection"
826 * = 0 (0x00) ..0..... "PCLK always output"
827 * COMK[4] "PCLK edge selection"
828 * = 0 (0x00) ...0.... "Data valid on falling edge"
829 * COMK[3] "HREF output polarity"
830 * = 0 (0x00) ....0... "positive"
832 * = 0 (0x00) .....0..
833 * COMK[1] "VSYNC polarity"
834 * = 1 (0x01) ......1. "negative"
835 * COMK[0] "HSYNC polarity"
836 * = 0 (0x00) .......0 "positive"
841 * 33 CHLF "Current Control"
842 * = 9 (0x09) 00001001
843 * CHLF[7:6] "Sensor current control"
844 * = 0 (0x00) 00......
845 * CHLF[5] "Sensor current range control"
846 * = 0 (0x00) ..0..... "normal range"
847 * CHLF[4] "Sensor current"
848 * = 0 (0x00) ...0.... "normal current"
849 * CHLF[3] "Sensor buffer current control"
850 * = 1 (0x01) ....1... "half current"
851 * CHLF[2] "Column buffer current control"
852 * = 0 (0x00) .....0.. "normal current"
853 * CHLF[1] "Analog DSP current control"
854 * = 0 (0x00) ......0. "normal current"
855 * CHLF[1] "ADC current control"
856 * = 0 (0x00) ......0. "normal current"
861 * 34 VBLM "Blooming Control"
862 * = 80 (0x50) 01010000
863 * VBLM[7] "Hard soft reset switch"
864 * = 0 (0x00) 0....... "Hard reset"
865 * VBLM[6:4] "Blooming voltage selection"
866 * = 5 (0x05) .101....
867 * VBLM[3:0] "Sensor current control"
868 * = 0 (0x00) ....0000
873 * 36 VCHG "Sensor Precharge Voltage Control"
874 * = 0 (0x00) 00000000
876 * = 0 (0x00) 0.......
877 * VCHG[6:4] "Sensor precharge voltage control"
878 * = 0 (0x00) .000....
879 * VCHG[3:0] "Sensor array common reference"
880 * = 0 (0x00) ....0000
885 * 37 ADC "ADC Reference Control"
886 * = 4 (0x04) 00000100
887 * ADC[7:4] "Reserved"
888 * = 0 (0x00) 0000....
889 * ADC[3] "ADC input signal range"
890 * = 0 (0x00) ....0... "Input signal 1.0x"
891 * ADC[2:0] "ADC range control"
892 * = 4 (0x04) .....100
897 * 38 ACOM "Analog Common Ground"
898 * = 82 (0x52) 01010010
899 * ACOM[7] "Analog gain control"
900 * = 0 (0x00) 0....... "Gain 1x"
901 * ACOM[6] "Analog black level calibration"
902 * = 1 (0x01) .1...... "On"
903 * ACOM[5:0] "Reserved"
904 * = 18 (0x12) ..010010
909 * 3A FREFA "Internal Reference Adjustment"
910 * = 0 (0x00) 00000000
912 * = 0 (0x00) 00000000
917 * 3C FVOPT "Internal Reference Adjustment"
918 * = 31 (0x1F) 00011111
920 * = 31 (0x1F) 00011111
925 * 44 Undocumented = 0 (0x00) 00000000
926 * 44[7:0] "It's a secret"
927 * = 0 (0x00) 00000000
932 * 40 Undocumented = 0 (0x00) 00000000
933 * 40[7:0] "It's a secret"
934 * = 0 (0x00) 00000000
939 * 41 Undocumented = 0 (0x00) 00000000
940 * 41[7:0] "It's a secret"
941 * = 0 (0x00) 00000000
946 * 42 Undocumented = 0 (0x00) 00000000
947 * 42[7:0] "It's a secret"
948 * = 0 (0x00) 00000000
953 * 43 Undocumented = 0 (0x00) 00000000
954 * 43[7:0] "It's a secret"
955 * = 0 (0x00) 00000000
960 * 45 Undocumented = 128 (0x80) 10000000
961 * 45[7:0] "It's a secret"
962 * = 128 (0x80) 10000000
967 * 48 Undocumented = 192 (0xC0) 11000000
968 * 48[7:0] "It's a secret"
969 * = 192 (0xC0) 11000000
974 * 49 Undocumented = 25 (0x19) 00011001
975 * 49[7:0] "It's a secret"
976 * = 25 (0x19) 00011001
981 * 4B Undocumented = 128 (0x80) 10000000
982 * 4B[7:0] "It's a secret"
983 * = 128 (0x80) 10000000
988 * 4D Undocumented = 196 (0xC4) 11000100
989 * 4D[7:0] "It's a secret"
990 * = 196 (0xC4) 11000100
995 * 35 VREF "Reference Voltage Control"
996 * = 76 (0x4C) 01001100
997 * VREF[7:5] "Column high reference control"
998 * = 2 (0x02) 010..... "higher voltage"
999 * VREF[4:2] "Column low reference control"
1000 * = 3 (0x03) ...011.. "Highest voltage"
1001 * VREF[1:0] "Reserved"
1002 * = 0 (0x00) ......00
1007 * 3D Undocumented = 0 (0x00) 00000000
1008 * 3D[7:0] "It's a secret"
1009 * = 0 (0x00) 00000000
1014 * 3E Undocumented = 0 (0x00) 00000000
1015 * 3E[7:0] "It's a secret"
1016 * = 0 (0x00) 00000000
1021 * 3B FREFB "Internal Reference Adjustment"
1022 * = 24 (0x18) 00011000
1023 * FREFB[7:0] "Range"
1024 * = 24 (0x18) 00011000
1029 * 33 CHLF "Current Control"
1030 * = 25 (0x19) 00011001
1031 * CHLF[7:6] "Sensor current control"
1032 * = 0 (0x00) 00......
1033 * CHLF[5] "Sensor current range control"
1034 * = 0 (0x00) ..0..... "normal range"
1035 * CHLF[4] "Sensor current"
1036 * = 1 (0x01) ...1.... "double current"
1037 * CHLF[3] "Sensor buffer current control"
1038 * = 1 (0x01) ....1... "half current"
1039 * CHLF[2] "Column buffer current control"
1040 * = 0 (0x00) .....0.. "normal current"
1041 * CHLF[1] "Analog DSP current control"
1042 * = 0 (0x00) ......0. "normal current"
1043 * CHLF[1] "ADC current control"
1044 * = 0 (0x00) ......0. "normal current"
1049 * 34 VBLM "Blooming Control"
1050 * = 90 (0x5A) 01011010
1051 * VBLM[7] "Hard soft reset switch"
1052 * = 0 (0x00) 0....... "Hard reset"
1053 * VBLM[6:4] "Blooming voltage selection"
1054 * = 5 (0x05) .101....
1055 * VBLM[3:0] "Sensor current control"
1056 * = 10 (0x0A) ....1010
1061 * 3B FREFB "Internal Reference Adjustment"
1062 * = 0 (0x00) 00000000
1063 * FREFB[7:0] "Range"
1064 * = 0 (0x00) 00000000
1069 * 33 CHLF "Current Control"
1070 * = 9 (0x09) 00001001
1071 * CHLF[7:6] "Sensor current control"
1072 * = 0 (0x00) 00......
1073 * CHLF[5] "Sensor current range control"
1074 * = 0 (0x00) ..0..... "normal range"
1075 * CHLF[4] "Sensor current"
1076 * = 0 (0x00) ...0.... "normal current"
1077 * CHLF[3] "Sensor buffer current control"
1078 * = 1 (0x01) ....1... "half current"
1079 * CHLF[2] "Column buffer current control"
1080 * = 0 (0x00) .....0.. "normal current"
1081 * CHLF[1] "Analog DSP current control"
1082 * = 0 (0x00) ......0. "normal current"
1083 * CHLF[1] "ADC current control"
1084 * = 0 (0x00) ......0. "normal current"
1089 * 34 VBLM "Blooming Control"
1090 * = 80 (0x50) 01010000
1091 * VBLM[7] "Hard soft reset switch"
1092 * = 0 (0x00) 0....... "Hard reset"
1093 * VBLM[6:4] "Blooming voltage selection"
1094 * = 5 (0x05) .101....
1095 * VBLM[3:0] "Sensor current control"
1096 * = 0 (0x00) ....0000
1101 * 12 COMH "Common Control H"
1102 * = 64 (0x40) 01000000
1104 * = 0 (0x00) 0....... "No-op"
1105 * COMH[6:4] "Resolution selection"
1106 * = 4 (0x04) .100.... "XGA"
1107 * COMH[3] "Master slave selection"
1108 * = 0 (0x00) ....0... "Master mode"
1109 * COMH[2] "Internal B/R channel option"
1110 * = 0 (0x00) .....0.. "B/R use same channel"
1111 * COMH[1] "Color bar test pattern"
1112 * = 0 (0x00) ......0. "Off"
1113 * COMH[0] "Reserved"
1114 * = 0 (0x00) .......0
1119 * 17 HREFST "Horizontal window start"
1120 * = 31 (0x1F) 00011111
1121 * HREFST[7:0] "Horizontal window start, 8 MSBs"
1122 * = 31 (0x1F) 00011111
1127 * 18 HREFEND "Horizontal window end"
1128 * = 95 (0x5F) 01011111
1129 * HREFEND[7:0] "Horizontal Window End, 8 MSBs"
1130 * = 95 (0x5F) 01011111
1135 * 19 VSTRT "Vertical window start"
1136 * = 0 (0x00) 00000000
1137 * VSTRT[7:0] "Vertical Window Start, 8 MSBs"
1138 * = 0 (0x00) 00000000
1143 * 1A VEND "Vertical window end"
1144 * = 96 (0x60) 01100000
1145 * VEND[7:0] "Vertical Window End, 8 MSBs"
1146 * = 96 (0x60) 01100000
1151 * 32 COMM "Common Control M"
1152 * = 18 (0x12) 00010010
1153 * COMM[7:6] "Pixel clock divide option"
1154 * = 0 (0x00) 00...... "/1"
1155 * COMM[5:3] "Horizontal window end position, 3 LSBs"
1156 * = 2 (0x02) ..010...
1157 * COMM[2:0] "Horizontal window start position, 3 LSBs"
1158 * = 2 (0x02) .....010
1163 * 03 COMA "Common Control A"
1164 * = 74 (0x4A) 01001010
1165 * COMA[7:4] "AWB Update Threshold"
1166 * = 4 (0x04) 0100....
1167 * COMA[3:2] "Vertical window end line control 2 LSBs"
1168 * = 2 (0x02) ....10..
1169 * COMA[1:0] "Vertical window start line control 2 LSBs"
1170 * = 2 (0x02) ......10
1175 * 11 CLKRC "Clock Rate Control"
1176 * = 128 (0x80) 10000000
1177 * CLKRC[7] "Internal frequency doublers on off seclection"
1178 * = 1 (0x01) 1....... "On"
1179 * CLKRC[6] "Digital video master slave selection"
1180 * = 0 (0x00) .0...... "Master mode, sensor
1182 * CLKRC[5:0] "Clock divider { CLK = PCLK/(1+CLKRC[5:0]) }"
1183 * = 0 (0x00) ..000000
1188 * 12 COMH "Common Control H"
1189 * = 0 (0x00) 00000000
1191 * = 0 (0x00) 0....... "No-op"
1192 * COMH[6:4] "Resolution selection"
1193 * = 0 (0x00) .000.... "QXGA"
1194 * COMH[3] "Master slave selection"
1195 * = 0 (0x00) ....0... "Master mode"
1196 * COMH[2] "Internal B/R channel option"
1197 * = 0 (0x00) .....0.. "B/R use same channel"
1198 * COMH[1] "Color bar test pattern"
1199 * = 0 (0x00) ......0. "Off"
1200 * COMH[0] "Reserved"
1201 * = 0 (0x00) .......0
1206 * 12 COMH "Common Control H"
1207 * = 64 (0x40) 01000000
1209 * = 0 (0x00) 0....... "No-op"
1210 * COMH[6:4] "Resolution selection"
1211 * = 4 (0x04) .100.... "XGA"
1212 * COMH[3] "Master slave selection"
1213 * = 0 (0x00) ....0... "Master mode"
1214 * COMH[2] "Internal B/R channel option"
1215 * = 0 (0x00) .....0.. "B/R use same channel"
1216 * COMH[1] "Color bar test pattern"
1217 * = 0 (0x00) ......0. "Off"
1218 * COMH[0] "Reserved"
1219 * = 0 (0x00) .......0
1224 * 17 HREFST "Horizontal window start"
1225 * = 31 (0x1F) 00011111
1226 * HREFST[7:0] "Horizontal window start, 8 MSBs"
1227 * = 31 (0x1F) 00011111
1232 * 18 HREFEND "Horizontal window end"
1233 * = 95 (0x5F) 01011111
1234 * HREFEND[7:0] "Horizontal Window End, 8 MSBs"
1235 * = 95 (0x5F) 01011111
1240 * 19 VSTRT "Vertical window start"
1241 * = 0 (0x00) 00000000
1242 * VSTRT[7:0] "Vertical Window Start, 8 MSBs"
1243 * = 0 (0x00) 00000000
1248 * 1A VEND "Vertical window end"
1249 * = 96 (0x60) 01100000
1250 * VEND[7:0] "Vertical Window End, 8 MSBs"
1251 * = 96 (0x60) 01100000
1256 * 32 COMM "Common Control M"
1257 * = 18 (0x12) 00010010
1258 * COMM[7:6] "Pixel clock divide option"
1259 * = 0 (0x00) 00...... "/1"
1260 * COMM[5:3] "Horizontal window end position, 3 LSBs"
1261 * = 2 (0x02) ..010...
1262 * COMM[2:0] "Horizontal window start position, 3 LSBs"
1263 * = 2 (0x02) .....010
1268 * 03 COMA "Common Control A"
1269 * = 74 (0x4A) 01001010
1270 * COMA[7:4] "AWB Update Threshold"
1271 * = 4 (0x04) 0100....
1272 * COMA[3:2] "Vertical window end line control 2 LSBs"
1273 * = 2 (0x02) ....10..
1274 * COMA[1:0] "Vertical window start line control 2 LSBs"
1275 * = 2 (0x02) ......10
1280 * 02 RED "Red Gain Control"
1281 * = 175 (0xAF) 10101111
1283 * = 1 (0x01) 1....... "gain = 1/(1+bitrev([6:0]))"
1285 * = 47 (0x2F) .0101111
1290 * 2D ADDVSL "VSYNC Pulse Width"
1291 * = 210 (0xD2) 11010010
1292 * ADDVSL[7:0] "VSYNC pulse width, LSB"
1293 * = 210 (0xD2) 11010010
1298 * 00 GAIN = 24 (0x18) 00011000
1299 * GAIN[7:6] "Reserved"
1300 * = 0 (0x00) 00......
1302 * = 0 (0x00) ..0..... "False"
1304 * = 1 (0x01) ...1.... "True"
1306 * = 8 (0x08) ....1000
1311 * 01 BLUE "Blue Gain Control"
1312 * = 240 (0xF0) 11110000
1314 * = 1 (0x01) 1....... "gain = 1/(1+bitrev([6:0]))"
1316 * = 112 (0x70) .1110000
1321 * 10 AEC "Automatic Exposure Control"
1322 * = 10 (0x0A) 00001010
1323 * AEC[7:0] "Automatic Exposure Control, 8 MSBs"
1324 * = 10 (0x0A) 00001010
1336 static const struct ov_i2c_regvals norm_6x20
[] = {
1337 { 0x12, 0x80 }, /* reset */
1340 { 0x05, 0x7f }, /* For when autoadjust is off */
1342 /* The ratio of 0x0c and 0x0d controls the white point */
1345 { 0x0f, 0x15 }, /* COMS */
1346 { 0x10, 0x75 }, /* AEC Exposure time */
1347 { 0x12, 0x24 }, /* Enable AGC */
1349 /* 0x16: 0x06 helps frame stability with moving objects */
1351 /* { 0x20, 0x30 }, * Aperture correction enable */
1352 { 0x26, 0xb2 }, /* BLC enable */
1353 /* 0x28: 0x05 Selects RGB format if RGB on */
1355 { 0x2a, 0x04 }, /* Disable framerate adjust */
1356 /* { 0x2b, 0xac }, * Framerate; Set 2a[7] first */
1358 { 0x33, 0xa0 }, /* Color Processing Parameter */
1359 { 0x34, 0xd2 }, /* Max A/D range */
1363 { 0x3c, 0x39 }, /* Enable AEC mode changing */
1364 { 0x3c, 0x3c }, /* Change AEC mode */
1365 { 0x3c, 0x24 }, /* Disable AEC mode changing */
1368 /* These next two registers (0x4a, 0x4b) are undocumented.
1369 * They control the color balance */
1372 { 0x4d, 0xd2 }, /* This reduces noise a bit */
1375 /* Do 50-53 have any effect? */
1376 /* Toggle 0x12[2] off and on here? */
1379 static const struct ov_i2c_regvals norm_6x30
[] = {
1380 { 0x12, 0x80 }, /* Reset */
1381 { 0x00, 0x1f }, /* Gain */
1382 { 0x01, 0x99 }, /* Blue gain */
1383 { 0x02, 0x7c }, /* Red gain */
1384 { 0x03, 0xc0 }, /* Saturation */
1385 { 0x05, 0x0a }, /* Contrast */
1386 { 0x06, 0x95 }, /* Brightness */
1387 { 0x07, 0x2d }, /* Sharpness */
1390 { 0x0e, 0xa0 }, /* Was 0x20, bit7 enables a 2x gain which we need */
1393 { 0x11, 0x00 }, /* Pixel clock = fastest */
1394 { 0x12, 0x24 }, /* Enable AGC and AWB */
1409 { 0x23, 0xc0 }, /* Crystal circuit power level */
1410 { 0x25, 0x9a }, /* Increase AEC black ratio */
1411 { 0x26, 0xb2 }, /* BLC enable */
1415 { 0x2a, 0x84 }, /* 60 Hz power */
1416 { 0x2b, 0xa8 }, /* 60 Hz power */
1418 { 0x2d, 0x95 }, /* Enable auto-brightness */
1432 { 0x40, 0x00 }, /* White bal */
1433 { 0x41, 0x00 }, /* White bal */
1435 { 0x43, 0x3f }, /* White bal */
1445 { 0x4d, 0x10 }, /* U = 0.563u, V = 0.714v */
1447 { 0x4f, 0x07 }, /* UV avg., col. killer: max */
1449 { 0x54, 0x23 }, /* Max AGC gain: 18dB */
1454 { 0x59, 0x01 }, /* AGC dark current comp.: +1 */
1456 { 0x5b, 0x0f }, /* AWB chrominance levels */
1460 { 0x12, 0x20 }, /* Toggle AWB */
1464 /* Lawrence Glaister <lg@jfm.bc.ca> reports:
1466 * Register 0x0f in the 7610 has the following effects:
1468 * 0x85 (AEC method 1): Best overall, good contrast range
1469 * 0x45 (AEC method 2): Very overexposed
1470 * 0xa5 (spec sheet default): Ok, but the black level is
1471 * shifted resulting in loss of contrast
1472 * 0x05 (old driver setting): very overexposed, too much
1475 static const struct ov_i2c_regvals norm_7610
[] = {
1482 { 0x28, 0x24 }, /* 0c */
1483 { 0x0f, 0x85 }, /* lg's setting */
1505 static const struct ov_i2c_regvals norm_7620
[] = {
1506 { 0x12, 0x80 }, /* reset */
1507 { 0x00, 0x00 }, /* gain */
1508 { 0x01, 0x80 }, /* blue gain */
1509 { 0x02, 0x80 }, /* red gain */
1510 { 0x03, 0xc0 }, /* OV7670_REG_VREF */
1533 { 0x28, 0x22 }, /* Was 0x20, bit1 enables a 2x gain which we need */
1572 /* 7640 and 7648. The defaults should be OK for most registers. */
1573 static const struct ov_i2c_regvals norm_7640
[] = {
1578 /* 7670. Defaults taken from OmniVision provided data,
1579 * as provided by Jonathan Corbet of OLPC */
1580 static const struct ov_i2c_regvals norm_7670
[] = {
1581 { OV7670_REG_COM7
, OV7670_COM7_RESET
},
1582 { OV7670_REG_TSLB
, 0x04 }, /* OV */
1583 { OV7670_REG_COM7
, OV7670_COM7_FMT_VGA
}, /* VGA */
1584 { OV7670_REG_CLKRC
, 0x01 },
1586 * Set the hardware window. These values from OV don't entirely
1587 * make sense - hstop is less than hstart. But they work...
1589 { OV7670_REG_HSTART
, 0x13 },
1590 { OV7670_REG_HSTOP
, 0x01 },
1591 { OV7670_REG_HREF
, 0xb6 },
1592 { OV7670_REG_VSTART
, 0x02 },
1593 { OV7670_REG_VSTOP
, 0x7a },
1594 { OV7670_REG_VREF
, 0x0a },
1596 { OV7670_REG_COM3
, 0x00 },
1597 { OV7670_REG_COM14
, 0x00 },
1598 /* Mystery scaling numbers */
1604 /* { OV7670_REG_COM10, 0x0 }, */
1606 /* Gamma curve values */
1624 /* AGC and AEC parameters. Note we start by disabling those features,
1625 then turn them only after tweaking the values. */
1626 { OV7670_REG_COM8
, OV7670_COM8_FASTAEC
1627 | OV7670_COM8_AECSTEP
1628 | OV7670_COM8_BFILT
},
1629 { OV7670_REG_GAIN
, 0x00 },
1630 { OV7670_REG_AECH
, 0x00 },
1631 { OV7670_REG_COM4
, 0x40 }, /* magic reserved bit */
1632 { OV7670_REG_COM9
, 0x18 }, /* 4x gain + magic rsvd bit */
1633 { OV7670_REG_BD50MAX
, 0x05 },
1634 { OV7670_REG_BD60MAX
, 0x07 },
1635 { OV7670_REG_AEW
, 0x95 },
1636 { OV7670_REG_AEB
, 0x33 },
1637 { OV7670_REG_VPT
, 0xe3 },
1638 { OV7670_REG_HAECC1
, 0x78 },
1639 { OV7670_REG_HAECC2
, 0x68 },
1640 { 0xa1, 0x03 }, /* magic */
1641 { OV7670_REG_HAECC3
, 0xd8 },
1642 { OV7670_REG_HAECC4
, 0xd8 },
1643 { OV7670_REG_HAECC5
, 0xf0 },
1644 { OV7670_REG_HAECC6
, 0x90 },
1645 { OV7670_REG_HAECC7
, 0x94 },
1646 { OV7670_REG_COM8
, OV7670_COM8_FASTAEC
1647 | OV7670_COM8_AECSTEP
1650 | OV7670_COM8_AEC
},
1652 /* Almost all of these are magic "reserved" values. */
1653 { OV7670_REG_COM5
, 0x61 },
1654 { OV7670_REG_COM6
, 0x4b },
1656 { OV7670_REG_MVFP
, 0x07 },
1665 { OV7670_REG_COM12
, 0x78 },
1668 { OV7670_REG_GFIX
, 0x00 },
1684 /* More reserved magic, some of which tweaks white balance */
1701 /* "9e for advance AWB" */
1703 { OV7670_REG_BLUE
, 0x40 },
1704 { OV7670_REG_RED
, 0x60 },
1705 { OV7670_REG_COM8
, OV7670_COM8_FASTAEC
1706 | OV7670_COM8_AECSTEP
1710 | OV7670_COM8_AWB
},
1712 /* Matrix coefficients */
1721 { OV7670_REG_COM16
, OV7670_COM16_AWBGAIN
},
1722 { OV7670_REG_EDGE
, 0x00 },
1727 { OV7670_REG_COM13
, OV7670_COM13_GAMMA
1728 | OV7670_COM13_UVSAT
1732 { OV7670_REG_COM16
, 0x38 },
1736 { OV7670_REG_COM11
, OV7670_COM11_EXP
|OV7670_COM11_HZAUTO
},
1749 /* Extra-weird stuff. Some sort of multiplexor register */
1775 static const struct ov_i2c_regvals norm_8610
[] = {
1782 { 0x05, 0x30 }, /* was 0x10, new from windrv 090403 */
1783 { 0x06, 0x70 }, /* was 0x80, new from windrv 090403 */
1792 { 0x15, 0x01 }, /* Lin and Win think different about UV order */
1794 { 0x17, 0x38 }, /* was 0x2f, new from windrv 090403 */
1795 { 0x18, 0xea }, /* was 0xcf, new from windrv 090403 */
1796 { 0x19, 0x02 }, /* was 0x06, new from windrv 090403 */
1799 { 0x20, 0xd0 }, /* was 0x90, new from windrv 090403 */
1800 { 0x23, 0xc0 }, /* was 0x00, new from windrv 090403 */
1801 { 0x24, 0x30 }, /* was 0x1d, new from windrv 090403 */
1802 { 0x25, 0x50 }, /* was 0x57, new from windrv 090403 */
1808 { 0x2b, 0xc8 }, /* was 0xcc, new from windrv 090403 */
1810 { 0x2d, 0x45 }, /* was 0xd5, new from windrv 090403 */
1812 { 0x2f, 0x14 }, /* was 0x01, new from windrv 090403 */
1814 { 0x4d, 0x30 }, /* was 0x10, new from windrv 090403 */
1815 { 0x60, 0x02 }, /* was 0x01, new from windrv 090403 */
1816 { 0x61, 0x00 }, /* was 0x09, new from windrv 090403 */
1817 { 0x62, 0x5f }, /* was 0xd7, new from windrv 090403 */
1819 { 0x64, 0x53 }, /* new windrv 090403 says 0x57,
1820 * maybe thats wrong */
1824 { 0x68, 0xc0 }, /* was 0xaf, new from windrv 090403 */
1828 { 0x6c, 0x99 }, /* was 0x80, old windrv says 0x00, but
1829 * deleting bit7 colors the first images red */
1830 { 0x6d, 0x11 }, /* was 0x00, new from windrv 090403 */
1831 { 0x6e, 0x11 }, /* was 0x00, new from windrv 090403 */
1837 { 0x74, 0x00 },/* 0x60? - was 0x00, new from windrv 090403 */
1839 { 0x76, 0x02 }, /* was 0x02, new from windrv 090403 */
1844 { 0x7b, 0x10 }, /* was 0x13, new from windrv 090403 */
1846 { 0x7d, 0x08 }, /* was 0x09, new from windrv 090403 */
1847 { 0x7e, 0x08 }, /* was 0xc0, new from windrv 090403 */
1854 { 0x85, 0x62 }, /* was 0x61, new from windrv 090403 */
1860 { 0x12, 0x25 }, /* was 0x24, new from windrv 090403 */
1863 static unsigned char ov7670_abs_to_sm(unsigned char v
)
1867 return (128 - v
) | 0x80;
1870 /* Write a OV519 register */
1871 static int reg_w(struct sd
*sd
, __u16 index
, __u16 value
)
1875 switch (sd
->bridge
) {
1877 case BRIDGE_OV511PLUS
:
1883 case BRIDGE_W9968CF
:
1884 ret
= usb_control_msg(sd
->gspca_dev
.dev
,
1885 usb_sndctrlpipe(sd
->gspca_dev
.dev
, 0),
1887 USB_DIR_OUT
| USB_TYPE_VENDOR
| USB_RECIP_DEVICE
,
1888 value
, index
, NULL
, 0, 500);
1894 sd
->gspca_dev
.usb_buf
[0] = value
;
1895 ret
= usb_control_msg(sd
->gspca_dev
.dev
,
1896 usb_sndctrlpipe(sd
->gspca_dev
.dev
, 0),
1898 USB_DIR_OUT
| USB_TYPE_VENDOR
| USB_RECIP_DEVICE
,
1900 sd
->gspca_dev
.usb_buf
, 1, 500);
1903 PDEBUG(D_ERR
, "Write reg 0x%04x -> [0x%02x] failed",
1908 PDEBUG(D_USBO
, "Write reg 0x%04x -> [0x%02x]", value
, index
);
1912 /* Read from a OV519 register, note not valid for the w9968cf!! */
1913 /* returns: negative is error, pos or zero is data */
1914 static int reg_r(struct sd
*sd
, __u16 index
)
1919 switch (sd
->bridge
) {
1921 case BRIDGE_OV511PLUS
:
1931 ret
= usb_control_msg(sd
->gspca_dev
.dev
,
1932 usb_rcvctrlpipe(sd
->gspca_dev
.dev
, 0),
1934 USB_DIR_IN
| USB_TYPE_VENDOR
| USB_RECIP_DEVICE
,
1935 0, index
, sd
->gspca_dev
.usb_buf
, 1, 500);
1938 ret
= sd
->gspca_dev
.usb_buf
[0];
1939 PDEBUG(D_USBI
, "Read reg [0x%02X] -> 0x%04X", index
, ret
);
1941 PDEBUG(D_ERR
, "Read reg [0x%02x] failed", index
);
1946 /* Read 8 values from a OV519 register */
1947 static int reg_r8(struct sd
*sd
,
1952 ret
= usb_control_msg(sd
->gspca_dev
.dev
,
1953 usb_rcvctrlpipe(sd
->gspca_dev
.dev
, 0),
1955 USB_DIR_IN
| USB_TYPE_VENDOR
| USB_RECIP_DEVICE
,
1956 0, index
, sd
->gspca_dev
.usb_buf
, 8, 500);
1959 ret
= sd
->gspca_dev
.usb_buf
[0];
1961 PDEBUG(D_ERR
, "Read reg 8 [0x%02x] failed", index
);
1967 * Writes bits at positions specified by mask to an OV51x reg. Bits that are in
1968 * the same position as 1's in "mask" are cleared and set to "value". Bits
1969 * that are in the same position as 0's in "mask" are preserved, regardless
1970 * of their respective state in "value".
1972 static int reg_w_mask(struct sd
*sd
,
1981 value
&= mask
; /* Enforce mask on value */
1982 ret
= reg_r(sd
, index
);
1986 oldval
= ret
& ~mask
; /* Clear the masked bits */
1987 value
|= oldval
; /* Set the desired bits */
1989 return reg_w(sd
, index
, value
);
1993 * Writes multiple (n) byte value to a single register. Only valid with certain
1994 * registers (0x30 and 0xc4 - 0xce).
1996 static int ov518_reg_w32(struct sd
*sd
, __u16 index
, u32 value
, int n
)
2000 *((__le32
*) sd
->gspca_dev
.usb_buf
) = __cpu_to_le32(value
);
2002 ret
= usb_control_msg(sd
->gspca_dev
.dev
,
2003 usb_sndctrlpipe(sd
->gspca_dev
.dev
, 0),
2005 USB_DIR_OUT
| USB_TYPE_VENDOR
| USB_RECIP_DEVICE
,
2007 sd
->gspca_dev
.usb_buf
, n
, 500);
2009 PDEBUG(D_ERR
, "Write reg32 [%02x] %08x failed", index
, value
);
2016 static int ov511_i2c_w(struct sd
*sd
, __u8 reg
, __u8 value
)
2020 PDEBUG(D_USBO
, "i2c 0x%02x -> [0x%02x]", value
, reg
);
2022 /* Three byte write cycle */
2023 for (retries
= 6; ; ) {
2024 /* Select camera register */
2025 rc
= reg_w(sd
, R51x_I2C_SADDR_3
, reg
);
2029 /* Write "value" to I2C data port of OV511 */
2030 rc
= reg_w(sd
, R51x_I2C_DATA
, value
);
2034 /* Initiate 3-byte write cycle */
2035 rc
= reg_w(sd
, R511_I2C_CTL
, 0x01);
2040 rc
= reg_r(sd
, R511_I2C_CTL
);
2041 } while (rc
> 0 && ((rc
& 1) == 0)); /* Retry until idle */
2046 if ((rc
& 2) == 0) /* Ack? */
2048 if (--retries
< 0) {
2049 PDEBUG(D_USBO
, "i2c write retries exhausted");
2057 static int ov511_i2c_r(struct sd
*sd
, __u8 reg
)
2059 int rc
, value
, retries
;
2061 /* Two byte write cycle */
2062 for (retries
= 6; ; ) {
2063 /* Select camera register */
2064 rc
= reg_w(sd
, R51x_I2C_SADDR_2
, reg
);
2068 /* Initiate 2-byte write cycle */
2069 rc
= reg_w(sd
, R511_I2C_CTL
, 0x03);
2074 rc
= reg_r(sd
, R511_I2C_CTL
);
2075 } while (rc
> 0 && ((rc
& 1) == 0)); /* Retry until idle */
2080 if ((rc
& 2) == 0) /* Ack? */
2084 reg_w(sd
, R511_I2C_CTL
, 0x10);
2086 if (--retries
< 0) {
2087 PDEBUG(D_USBI
, "i2c write retries exhausted");
2092 /* Two byte read cycle */
2093 for (retries
= 6; ; ) {
2094 /* Initiate 2-byte read cycle */
2095 rc
= reg_w(sd
, R511_I2C_CTL
, 0x05);
2100 rc
= reg_r(sd
, R511_I2C_CTL
);
2101 } while (rc
> 0 && ((rc
& 1) == 0)); /* Retry until idle */
2106 if ((rc
& 2) == 0) /* Ack? */
2110 rc
= reg_w(sd
, R511_I2C_CTL
, 0x10);
2114 if (--retries
< 0) {
2115 PDEBUG(D_USBI
, "i2c read retries exhausted");
2120 value
= reg_r(sd
, R51x_I2C_DATA
);
2122 PDEBUG(D_USBI
, "i2c [0x%02X] -> 0x%02X", reg
, value
);
2124 /* This is needed to make i2c_w() work */
2125 rc
= reg_w(sd
, R511_I2C_CTL
, 0x05);
2133 * The OV518 I2C I/O procedure is different, hence, this function.
2134 * This is normally only called from i2c_w(). Note that this function
2135 * always succeeds regardless of whether the sensor is present and working.
2137 static int ov518_i2c_w(struct sd
*sd
,
2143 PDEBUG(D_USBO
, "i2c 0x%02x -> [0x%02x]", value
, reg
);
2145 /* Select camera register */
2146 rc
= reg_w(sd
, R51x_I2C_SADDR_3
, reg
);
2150 /* Write "value" to I2C data port of OV511 */
2151 rc
= reg_w(sd
, R51x_I2C_DATA
, value
);
2155 /* Initiate 3-byte write cycle */
2156 rc
= reg_w(sd
, R518_I2C_CTL
, 0x01);
2160 /* wait for write complete */
2162 return reg_r8(sd
, R518_I2C_CTL
);
2166 * returns: negative is error, pos or zero is data
2168 * The OV518 I2C I/O procedure is different, hence, this function.
2169 * This is normally only called from i2c_r(). Note that this function
2170 * always succeeds regardless of whether the sensor is present and working.
2172 static int ov518_i2c_r(struct sd
*sd
, __u8 reg
)
2176 /* Select camera register */
2177 rc
= reg_w(sd
, R51x_I2C_SADDR_2
, reg
);
2181 /* Initiate 2-byte write cycle */
2182 rc
= reg_w(sd
, R518_I2C_CTL
, 0x03);
2186 /* Initiate 2-byte read cycle */
2187 rc
= reg_w(sd
, R518_I2C_CTL
, 0x05);
2190 value
= reg_r(sd
, R51x_I2C_DATA
);
2191 PDEBUG(D_USBI
, "i2c [0x%02X] -> 0x%02X", reg
, value
);
2195 static int ovfx2_i2c_w(struct sd
*sd
, __u8 reg
, __u8 value
)
2199 ret
= usb_control_msg(sd
->gspca_dev
.dev
,
2200 usb_sndctrlpipe(sd
->gspca_dev
.dev
, 0),
2202 USB_DIR_OUT
| USB_TYPE_VENDOR
| USB_RECIP_DEVICE
,
2203 (__u16
)value
, (__u16
)reg
, NULL
, 0, 500);
2206 PDEBUG(D_ERR
, "i2c 0x%02x -> [0x%02x] failed", value
, reg
);
2210 PDEBUG(D_USBO
, "i2c 0x%02x -> [0x%02x]", value
, reg
);
2214 static int ovfx2_i2c_r(struct sd
*sd
, __u8 reg
)
2218 ret
= usb_control_msg(sd
->gspca_dev
.dev
,
2219 usb_rcvctrlpipe(sd
->gspca_dev
.dev
, 0),
2221 USB_DIR_IN
| USB_TYPE_VENDOR
| USB_RECIP_DEVICE
,
2222 0, (__u16
)reg
, sd
->gspca_dev
.usb_buf
, 1, 500);
2225 ret
= sd
->gspca_dev
.usb_buf
[0];
2226 PDEBUG(D_USBI
, "i2c [0x%02X] -> 0x%02X", reg
, ret
);
2228 PDEBUG(D_ERR
, "i2c read [0x%02x] failed", reg
);
2233 static int i2c_w(struct sd
*sd
, __u8 reg
, __u8 value
)
2237 if (sd
->sensor_reg_cache
[reg
] == value
)
2240 switch (sd
->bridge
) {
2242 case BRIDGE_OV511PLUS
:
2243 ret
= ov511_i2c_w(sd
, reg
, value
);
2246 case BRIDGE_OV518PLUS
:
2248 ret
= ov518_i2c_w(sd
, reg
, value
);
2251 ret
= ovfx2_i2c_w(sd
, reg
, value
);
2253 case BRIDGE_W9968CF
:
2254 ret
= w9968cf_i2c_w(sd
, reg
, value
);
2259 /* Up on sensor reset empty the register cache */
2260 if (reg
== 0x12 && (value
& 0x80))
2261 memset(sd
->sensor_reg_cache
, -1,
2262 sizeof(sd
->sensor_reg_cache
));
2264 sd
->sensor_reg_cache
[reg
] = value
;
2270 static int i2c_r(struct sd
*sd
, __u8 reg
)
2274 if (sd
->sensor_reg_cache
[reg
] != -1)
2275 return sd
->sensor_reg_cache
[reg
];
2277 switch (sd
->bridge
) {
2279 case BRIDGE_OV511PLUS
:
2280 ret
= ov511_i2c_r(sd
, reg
);
2283 case BRIDGE_OV518PLUS
:
2285 ret
= ov518_i2c_r(sd
, reg
);
2288 ret
= ovfx2_i2c_r(sd
, reg
);
2290 case BRIDGE_W9968CF
:
2291 ret
= w9968cf_i2c_r(sd
, reg
);
2296 sd
->sensor_reg_cache
[reg
] = ret
;
2301 /* Writes bits at positions specified by mask to an I2C reg. Bits that are in
2302 * the same position as 1's in "mask" are cleared and set to "value". Bits
2303 * that are in the same position as 0's in "mask" are preserved, regardless
2304 * of their respective state in "value".
2306 static int i2c_w_mask(struct sd
*sd
,
2314 value
&= mask
; /* Enforce mask on value */
2315 rc
= i2c_r(sd
, reg
);
2318 oldval
= rc
& ~mask
; /* Clear the masked bits */
2319 value
|= oldval
; /* Set the desired bits */
2320 return i2c_w(sd
, reg
, value
);
2323 /* Temporarily stops OV511 from functioning. Must do this before changing
2324 * registers while the camera is streaming */
2325 static inline int ov51x_stop(struct sd
*sd
)
2327 PDEBUG(D_STREAM
, "stopping");
2329 switch (sd
->bridge
) {
2331 case BRIDGE_OV511PLUS
:
2332 return reg_w(sd
, R51x_SYS_RESET
, 0x3d);
2334 case BRIDGE_OV518PLUS
:
2335 return reg_w_mask(sd
, R51x_SYS_RESET
, 0x3a, 0x3a);
2337 return reg_w(sd
, OV519_SYS_RESET1
, 0x0f);
2339 return reg_w_mask(sd
, 0x0f, 0x00, 0x02);
2340 case BRIDGE_W9968CF
:
2341 return reg_w(sd
, 0x3c, 0x0a05); /* stop USB transfer */
2347 /* Restarts OV511 after ov511_stop() is called. Has no effect if it is not
2348 * actually stopped (for performance). */
2349 static inline int ov51x_restart(struct sd
*sd
)
2353 PDEBUG(D_STREAM
, "restarting");
2358 /* Reinitialize the stream */
2359 switch (sd
->bridge
) {
2361 case BRIDGE_OV511PLUS
:
2362 return reg_w(sd
, R51x_SYS_RESET
, 0x00);
2364 case BRIDGE_OV518PLUS
:
2365 rc
= reg_w(sd
, 0x2f, 0x80);
2368 return reg_w(sd
, R51x_SYS_RESET
, 0x00);
2370 return reg_w(sd
, OV519_SYS_RESET1
, 0x00);
2372 return reg_w_mask(sd
, 0x0f, 0x02, 0x02);
2373 case BRIDGE_W9968CF
:
2374 return reg_w(sd
, 0x3c, 0x8a05); /* USB FIFO enable */
2380 static int ov51x_set_slave_ids(struct sd
*sd
, __u8 slave
);
2382 /* This does an initial reset of an OmniVision sensor and ensures that I2C
2383 * is synchronized. Returns <0 on failure.
2385 static int init_ov_sensor(struct sd
*sd
, __u8 slave
)
2389 if (ov51x_set_slave_ids(sd
, slave
) < 0)
2392 /* Reset the sensor */
2393 if (i2c_w(sd
, 0x12, 0x80) < 0)
2396 /* Wait for it to initialize */
2399 for (i
= 0; i
< i2c_detect_tries
; i
++) {
2400 if (i2c_r(sd
, OV7610_REG_ID_HIGH
) == 0x7f &&
2401 i2c_r(sd
, OV7610_REG_ID_LOW
) == 0xa2) {
2402 PDEBUG(D_PROBE
, "I2C synced in %d attempt(s)", i
);
2406 /* Reset the sensor */
2407 if (i2c_w(sd
, 0x12, 0x80) < 0)
2409 /* Wait for it to initialize */
2411 /* Dummy read to sync I2C */
2412 if (i2c_r(sd
, 0x00) < 0)
2418 /* Set the read and write slave IDs. The "slave" argument is the write slave,
2419 * and the read slave will be set to (slave + 1).
2420 * This should not be called from outside the i2c I/O functions.
2421 * Sets I2C read and write slave IDs. Returns <0 for error
2423 static int ov51x_set_slave_ids(struct sd
*sd
,
2428 switch (sd
->bridge
) {
2430 return reg_w(sd
, OVFX2_I2C_ADDR
, slave
);
2431 case BRIDGE_W9968CF
:
2432 sd
->sensor_addr
= slave
;
2436 rc
= reg_w(sd
, R51x_I2C_W_SID
, slave
);
2439 return reg_w(sd
, R51x_I2C_R_SID
, slave
+ 1);
2442 static int write_regvals(struct sd
*sd
,
2443 const struct ov_regvals
*regvals
,
2449 rc
= reg_w(sd
, regvals
->reg
, regvals
->val
);
2457 static int write_i2c_regvals(struct sd
*sd
,
2458 const struct ov_i2c_regvals
*regvals
,
2464 rc
= i2c_w(sd
, regvals
->reg
, regvals
->val
);
2472 /****************************************************************************
2474 * OV511 and sensor configuration
2476 ***************************************************************************/
2478 /* This initializes the OV2x10 / OV3610 / OV3620 */
2479 static int ov_hires_configure(struct sd
*sd
)
2483 if (sd
->bridge
!= BRIDGE_OVFX2
) {
2484 PDEBUG(D_ERR
, "error hires sensors only supported with ovfx2");
2488 PDEBUG(D_PROBE
, "starting ov hires configuration");
2490 /* Detect sensor (sub)type */
2491 high
= i2c_r(sd
, 0x0a);
2492 low
= i2c_r(sd
, 0x0b);
2493 /* info("%x, %x", high, low); */
2494 if (high
== 0x96 && low
== 0x40) {
2495 PDEBUG(D_PROBE
, "Sensor is an OV2610");
2496 sd
->sensor
= SEN_OV2610
;
2497 } else if (high
== 0x36 && (low
& 0x0f) == 0x00) {
2498 PDEBUG(D_PROBE
, "Sensor is an OV3610");
2499 sd
->sensor
= SEN_OV3610
;
2501 PDEBUG(D_ERR
, "Error unknown sensor type: 0x%02x%02x",
2506 /* Set sensor-specific vars */
2511 /* This initializes the OV8110, OV8610 sensor. The OV8110 uses
2512 * the same register settings as the OV8610, since they are very similar.
2514 static int ov8xx0_configure(struct sd
*sd
)
2518 PDEBUG(D_PROBE
, "starting ov8xx0 configuration");
2520 /* Detect sensor (sub)type */
2521 rc
= i2c_r(sd
, OV7610_REG_COM_I
);
2523 PDEBUG(D_ERR
, "Error detecting sensor type");
2526 if ((rc
& 3) == 1) {
2527 sd
->sensor
= SEN_OV8610
;
2529 PDEBUG(D_ERR
, "Unknown image sensor version: %d", rc
& 3);
2533 /* Set sensor-specific vars */
2537 /* This initializes the OV7610, OV7620, or OV76BE sensor. The OV76BE uses
2538 * the same register settings as the OV7610, since they are very similar.
2540 static int ov7xx0_configure(struct sd
*sd
)
2545 PDEBUG(D_PROBE
, "starting OV7xx0 configuration");
2547 /* Detect sensor (sub)type */
2548 rc
= i2c_r(sd
, OV7610_REG_COM_I
);
2551 * it appears to be wrongly detected as a 7610 by default */
2553 PDEBUG(D_ERR
, "Error detecting sensor type");
2556 if ((rc
& 3) == 3) {
2557 /* quick hack to make OV7670s work */
2558 high
= i2c_r(sd
, 0x0a);
2559 low
= i2c_r(sd
, 0x0b);
2560 /* info("%x, %x", high, low); */
2561 if (high
== 0x76 && low
== 0x73) {
2562 PDEBUG(D_PROBE
, "Sensor is an OV7670");
2563 sd
->sensor
= SEN_OV7670
;
2565 PDEBUG(D_PROBE
, "Sensor is an OV7610");
2566 sd
->sensor
= SEN_OV7610
;
2568 } else if ((rc
& 3) == 1) {
2569 /* I don't know what's different about the 76BE yet. */
2570 if (i2c_r(sd
, 0x15) & 1) {
2571 PDEBUG(D_PROBE
, "Sensor is an OV7620AE");
2572 sd
->sensor
= SEN_OV7620AE
;
2574 PDEBUG(D_PROBE
, "Sensor is an OV76BE");
2575 sd
->sensor
= SEN_OV76BE
;
2577 } else if ((rc
& 3) == 0) {
2578 /* try to read product id registers */
2579 high
= i2c_r(sd
, 0x0a);
2581 PDEBUG(D_ERR
, "Error detecting camera chip PID");
2584 low
= i2c_r(sd
, 0x0b);
2586 PDEBUG(D_ERR
, "Error detecting camera chip VER");
2592 PDEBUG(D_PROBE
, "Sensor is an OV7630/OV7635");
2594 "7630 is not supported by this driver");
2597 PDEBUG(D_PROBE
, "Sensor is an OV7645");
2598 sd
->sensor
= SEN_OV7640
;
2601 PDEBUG(D_PROBE
, "Sensor is an OV7645B");
2602 sd
->sensor
= SEN_OV7640
;
2605 PDEBUG(D_PROBE
, "Sensor is an OV7648");
2606 sd
->sensor
= SEN_OV7648
;
2609 PDEBUG(D_PROBE
, "Unknown sensor: 0x76%x", low
);
2613 PDEBUG(D_PROBE
, "Sensor is an OV7620");
2614 sd
->sensor
= SEN_OV7620
;
2617 PDEBUG(D_ERR
, "Unknown image sensor version: %d", rc
& 3);
2621 /* Set sensor-specific vars */
2625 /* This initializes the OV6620, OV6630, OV6630AE, or OV6630AF sensor. */
2626 static int ov6xx0_configure(struct sd
*sd
)
2629 PDEBUG(D_PROBE
, "starting OV6xx0 configuration");
2631 /* Detect sensor (sub)type */
2632 rc
= i2c_r(sd
, OV7610_REG_COM_I
);
2634 PDEBUG(D_ERR
, "Error detecting sensor type");
2638 /* Ugh. The first two bits are the version bits, but
2639 * the entire register value must be used. I guess OVT
2640 * underestimated how many variants they would make. */
2643 sd
->sensor
= SEN_OV6630
;
2645 "WARNING: Sensor is an OV66308. Your camera may have");
2646 PDEBUG(D_ERR
, "been misdetected in previous driver versions.");
2649 sd
->sensor
= SEN_OV6620
;
2650 PDEBUG(D_PROBE
, "Sensor is an OV6620");
2653 sd
->sensor
= SEN_OV6630
;
2654 PDEBUG(D_PROBE
, "Sensor is an OV66308AE");
2657 sd
->sensor
= SEN_OV66308AF
;
2658 PDEBUG(D_PROBE
, "Sensor is an OV66308AF");
2661 sd
->sensor
= SEN_OV6630
;
2663 "WARNING: Sensor is an OV66307. Your camera may have");
2664 PDEBUG(D_ERR
, "been misdetected in previous driver versions.");
2667 PDEBUG(D_ERR
, "FATAL: Unknown sensor version: 0x%02x", rc
);
2671 /* Set sensor-specific vars */
2677 /* Turns on or off the LED. Only has an effect with OV511+/OV518(+)/OV519 */
2678 static void ov51x_led_control(struct sd
*sd
, int on
)
2683 switch (sd
->bridge
) {
2684 /* OV511 has no LED control */
2685 case BRIDGE_OV511PLUS
:
2686 reg_w(sd
, R511_SYS_LED_CTL
, on
? 1 : 0);
2689 case BRIDGE_OV518PLUS
:
2690 reg_w_mask(sd
, R518_GPIO_OUT
, on
? 0x02 : 0x00, 0x02);
2693 reg_w_mask(sd
, OV519_GPIO_DATA_OUT0
, !on
, 1); /* 0 / 1 */
2698 static void sd_reset_snapshot(struct gspca_dev
*gspca_dev
)
2700 struct sd
*sd
= (struct sd
*) gspca_dev
;
2702 if (!sd
->snapshot_needs_reset
)
2705 /* Note it is important that we clear sd->snapshot_needs_reset,
2706 before actually clearing the snapshot state in the bridge
2707 otherwise we might race with the pkt_scan interrupt handler */
2708 sd
->snapshot_needs_reset
= 0;
2710 switch (sd
->bridge
) {
2712 case BRIDGE_OV511PLUS
:
2713 reg_w(sd
, R51x_SYS_SNAP
, 0x02);
2714 reg_w(sd
, R51x_SYS_SNAP
, 0x00);
2717 case BRIDGE_OV518PLUS
:
2718 reg_w(sd
, R51x_SYS_SNAP
, 0x02); /* Reset */
2719 reg_w(sd
, R51x_SYS_SNAP
, 0x01); /* Enable */
2722 reg_w(sd
, R51x_SYS_RESET
, 0x40);
2723 reg_w(sd
, R51x_SYS_RESET
, 0x00);
2728 static int ov51x_upload_quan_tables(struct sd
*sd
)
2730 const unsigned char yQuanTable511
[] = {
2731 0, 1, 1, 2, 2, 3, 3, 4,
2732 1, 1, 1, 2, 2, 3, 4, 4,
2733 1, 1, 2, 2, 3, 4, 4, 4,
2734 2, 2, 2, 3, 4, 4, 4, 4,
2735 2, 2, 3, 4, 4, 5, 5, 5,
2736 3, 3, 4, 4, 5, 5, 5, 5,
2737 3, 4, 4, 4, 5, 5, 5, 5,
2738 4, 4, 4, 4, 5, 5, 5, 5
2741 const unsigned char uvQuanTable511
[] = {
2742 0, 2, 2, 3, 4, 4, 4, 4,
2743 2, 2, 2, 4, 4, 4, 4, 4,
2744 2, 2, 3, 4, 4, 4, 4, 4,
2745 3, 4, 4, 4, 4, 4, 4, 4,
2746 4, 4, 4, 4, 4, 4, 4, 4,
2747 4, 4, 4, 4, 4, 4, 4, 4,
2748 4, 4, 4, 4, 4, 4, 4, 4,
2749 4, 4, 4, 4, 4, 4, 4, 4
2752 /* OV518 quantization tables are 8x4 (instead of 8x8) */
2753 const unsigned char yQuanTable518
[] = {
2754 5, 4, 5, 6, 6, 7, 7, 7,
2755 5, 5, 5, 5, 6, 7, 7, 7,
2756 6, 6, 6, 6, 7, 7, 7, 8,
2757 7, 7, 6, 7, 7, 7, 8, 8
2760 const unsigned char uvQuanTable518
[] = {
2761 6, 6, 6, 7, 7, 7, 7, 7,
2762 6, 6, 6, 7, 7, 7, 7, 7,
2763 6, 6, 6, 7, 7, 7, 7, 8,
2764 7, 7, 7, 7, 7, 7, 8, 8
2767 const unsigned char *pYTable
, *pUVTable
;
2768 unsigned char val0
, val1
;
2769 int i
, size
, rc
, reg
= R51x_COMP_LUT_BEGIN
;
2771 PDEBUG(D_PROBE
, "Uploading quantization tables");
2773 if (sd
->bridge
== BRIDGE_OV511
|| sd
->bridge
== BRIDGE_OV511PLUS
) {
2774 pYTable
= yQuanTable511
;
2775 pUVTable
= uvQuanTable511
;
2778 pYTable
= yQuanTable518
;
2779 pUVTable
= uvQuanTable518
;
2783 for (i
= 0; i
< size
; i
++) {
2789 rc
= reg_w(sd
, reg
, val0
);
2798 rc
= reg_w(sd
, reg
+ size
, val0
);
2808 /* This initializes the OV511/OV511+ and the sensor */
2809 static int ov511_configure(struct gspca_dev
*gspca_dev
)
2811 struct sd
*sd
= (struct sd
*) gspca_dev
;
2814 /* For 511 and 511+ */
2815 const struct ov_regvals init_511
[] = {
2816 { R51x_SYS_RESET
, 0x7f },
2817 { R51x_SYS_INIT
, 0x01 },
2818 { R51x_SYS_RESET
, 0x7f },
2819 { R51x_SYS_INIT
, 0x01 },
2820 { R51x_SYS_RESET
, 0x3f },
2821 { R51x_SYS_INIT
, 0x01 },
2822 { R51x_SYS_RESET
, 0x3d },
2825 const struct ov_regvals norm_511
[] = {
2826 { R511_DRAM_FLOW_CTL
, 0x01 },
2827 { R51x_SYS_SNAP
, 0x00 },
2828 { R51x_SYS_SNAP
, 0x02 },
2829 { R51x_SYS_SNAP
, 0x00 },
2830 { R511_FIFO_OPTS
, 0x1f },
2831 { R511_COMP_EN
, 0x00 },
2832 { R511_COMP_LUT_EN
, 0x03 },
2835 const struct ov_regvals norm_511_p
[] = {
2836 { R511_DRAM_FLOW_CTL
, 0xff },
2837 { R51x_SYS_SNAP
, 0x00 },
2838 { R51x_SYS_SNAP
, 0x02 },
2839 { R51x_SYS_SNAP
, 0x00 },
2840 { R511_FIFO_OPTS
, 0xff },
2841 { R511_COMP_EN
, 0x00 },
2842 { R511_COMP_LUT_EN
, 0x03 },
2845 const struct ov_regvals compress_511
[] = {
2856 PDEBUG(D_PROBE
, "Device custom id %x", reg_r(sd
, R51x_SYS_CUST_ID
));
2858 rc
= write_regvals(sd
, init_511
, ARRAY_SIZE(init_511
));
2862 switch (sd
->bridge
) {
2864 rc
= write_regvals(sd
, norm_511
, ARRAY_SIZE(norm_511
));
2868 case BRIDGE_OV511PLUS
:
2869 rc
= write_regvals(sd
, norm_511_p
, ARRAY_SIZE(norm_511_p
));
2875 /* Init compression */
2876 rc
= write_regvals(sd
, compress_511
, ARRAY_SIZE(compress_511
));
2880 rc
= ov51x_upload_quan_tables(sd
);
2882 PDEBUG(D_ERR
, "Error uploading quantization tables");
2889 /* This initializes the OV518/OV518+ and the sensor */
2890 static int ov518_configure(struct gspca_dev
*gspca_dev
)
2892 struct sd
*sd
= (struct sd
*) gspca_dev
;
2895 /* For 518 and 518+ */
2896 const struct ov_regvals init_518
[] = {
2897 { R51x_SYS_RESET
, 0x40 },
2898 { R51x_SYS_INIT
, 0xe1 },
2899 { R51x_SYS_RESET
, 0x3e },
2900 { R51x_SYS_INIT
, 0xe1 },
2901 { R51x_SYS_RESET
, 0x00 },
2902 { R51x_SYS_INIT
, 0xe1 },
2907 const struct ov_regvals norm_518
[] = {
2908 { R51x_SYS_SNAP
, 0x02 }, /* Reset */
2909 { R51x_SYS_SNAP
, 0x01 }, /* Enable */
2920 const struct ov_regvals norm_518_p
[] = {
2921 { R51x_SYS_SNAP
, 0x02 }, /* Reset */
2922 { R51x_SYS_SNAP
, 0x01 }, /* Enable */
2939 /* First 5 bits of custom ID reg are a revision ID on OV518 */
2940 PDEBUG(D_PROBE
, "Device revision %d",
2941 0x1F & reg_r(sd
, R51x_SYS_CUST_ID
));
2943 rc
= write_regvals(sd
, init_518
, ARRAY_SIZE(init_518
));
2947 /* Set LED GPIO pin to output mode */
2948 rc
= reg_w_mask(sd
, R518_GPIO_CTL
, 0x00, 0x02);
2952 switch (sd
->bridge
) {
2954 rc
= write_regvals(sd
, norm_518
, ARRAY_SIZE(norm_518
));
2958 case BRIDGE_OV518PLUS
:
2959 rc
= write_regvals(sd
, norm_518_p
, ARRAY_SIZE(norm_518_p
));
2965 rc
= ov51x_upload_quan_tables(sd
);
2967 PDEBUG(D_ERR
, "Error uploading quantization tables");
2971 rc
= reg_w(sd
, 0x2f, 0x80);
2978 static int ov519_configure(struct sd
*sd
)
2980 static const struct ov_regvals init_519
[] = {
2981 { 0x5a, 0x6d }, /* EnableSystem */
2983 { 0x54, 0xff }, /* set bit2 to enable jpeg */
2987 /* Set LED pin to output mode. Bit 4 must be cleared or sensor
2988 * detection will fail. This deserves further investigation. */
2989 { OV519_GPIO_IO_CTRL0
, 0xee },
2990 { 0x51, 0x0f }, /* SetUsbInit */
2993 /* windows reads 0x55 at this point*/
2996 return write_regvals(sd
, init_519
, ARRAY_SIZE(init_519
));
2999 static int ovfx2_configure(struct sd
*sd
)
3001 static const struct ov_regvals init_fx2
[] = {
3013 return write_regvals(sd
, init_fx2
, ARRAY_SIZE(init_fx2
));
3016 /* this function is called at probe time */
3017 static int sd_config(struct gspca_dev
*gspca_dev
,
3018 const struct usb_device_id
*id
)
3020 struct sd
*sd
= (struct sd
*) gspca_dev
;
3021 struct cam
*cam
= &gspca_dev
->cam
;
3024 sd
->bridge
= id
->driver_info
& BRIDGE_MASK
;
3025 sd
->invert_led
= id
->driver_info
& BRIDGE_INVERT_LED
;
3027 switch (sd
->bridge
) {
3029 case BRIDGE_OV511PLUS
:
3030 ret
= ov511_configure(gspca_dev
);
3033 case BRIDGE_OV518PLUS
:
3034 ret
= ov518_configure(gspca_dev
);
3037 ret
= ov519_configure(sd
);
3040 ret
= ovfx2_configure(sd
);
3041 cam
->bulk_size
= OVFX2_BULK_SIZE
;
3042 cam
->bulk_nurbs
= MAX_NURBS
;
3045 case BRIDGE_W9968CF
:
3046 ret
= w9968cf_configure(sd
);
3047 cam
->reverse_alts
= 1;
3054 ov51x_led_control(sd
, 0); /* turn LED off */
3056 /* The OV519 must be more aggressive about sensor detection since
3057 * I2C write will never fail if the sensor is not present. We have
3058 * to try to initialize the sensor to detect its presence */
3061 if (init_ov_sensor(sd
, OV7xx0_SID
) >= 0) {
3062 if (ov7xx0_configure(sd
) < 0) {
3063 PDEBUG(D_ERR
, "Failed to configure OV7xx0");
3067 } else if (init_ov_sensor(sd
, OV6xx0_SID
) >= 0) {
3068 if (ov6xx0_configure(sd
) < 0) {
3069 PDEBUG(D_ERR
, "Failed to configure OV6xx0");
3073 } else if (init_ov_sensor(sd
, OV8xx0_SID
) >= 0) {
3074 if (ov8xx0_configure(sd
) < 0) {
3075 PDEBUG(D_ERR
, "Failed to configure OV8xx0");
3078 /* Test for 3xxx / 2xxx */
3079 } else if (init_ov_sensor(sd
, OV_HIRES_SID
) >= 0) {
3080 if (ov_hires_configure(sd
) < 0) {
3081 PDEBUG(D_ERR
, "Failed to configure high res OV");
3085 PDEBUG(D_ERR
, "Can't determine sensor slave IDs");
3089 switch (sd
->bridge
) {
3091 case BRIDGE_OV511PLUS
:
3093 cam
->cam_mode
= ov511_vga_mode
;
3094 cam
->nmodes
= ARRAY_SIZE(ov511_vga_mode
);
3096 cam
->cam_mode
= ov511_sif_mode
;
3097 cam
->nmodes
= ARRAY_SIZE(ov511_sif_mode
);
3101 case BRIDGE_OV518PLUS
:
3103 cam
->cam_mode
= ov518_vga_mode
;
3104 cam
->nmodes
= ARRAY_SIZE(ov518_vga_mode
);
3106 cam
->cam_mode
= ov518_sif_mode
;
3107 cam
->nmodes
= ARRAY_SIZE(ov518_sif_mode
);
3112 cam
->cam_mode
= ov519_vga_mode
;
3113 cam
->nmodes
= ARRAY_SIZE(ov519_vga_mode
);
3115 cam
->cam_mode
= ov519_sif_mode
;
3116 cam
->nmodes
= ARRAY_SIZE(ov519_sif_mode
);
3120 if (sd
->sensor
== SEN_OV2610
) {
3121 cam
->cam_mode
= ovfx2_ov2610_mode
;
3122 cam
->nmodes
= ARRAY_SIZE(ovfx2_ov2610_mode
);
3123 } else if (sd
->sensor
== SEN_OV3610
) {
3124 cam
->cam_mode
= ovfx2_ov3610_mode
;
3125 cam
->nmodes
= ARRAY_SIZE(ovfx2_ov3610_mode
);
3126 } else if (!sd
->sif
) {
3127 cam
->cam_mode
= ov519_vga_mode
;
3128 cam
->nmodes
= ARRAY_SIZE(ov519_vga_mode
);
3130 cam
->cam_mode
= ov519_sif_mode
;
3131 cam
->nmodes
= ARRAY_SIZE(ov519_sif_mode
);
3134 case BRIDGE_W9968CF
:
3135 cam
->cam_mode
= w9968cf_vga_mode
;
3136 cam
->nmodes
= ARRAY_SIZE(w9968cf_vga_mode
);
3140 /* w9968cf needs initialisation once the sensor is known */
3141 if (w9968cf_init(sd
) < 0)
3145 sd
->brightness
= BRIGHTNESS_DEF
;
3146 if (sd
->sensor
== SEN_OV6630
|| sd
->sensor
== SEN_OV66308AF
)
3147 sd
->contrast
= 200; /* The default is too low for the ov6630 */
3149 sd
->contrast
= CONTRAST_DEF
;
3150 sd
->colors
= COLOR_DEF
;
3151 sd
->hflip
= HFLIP_DEF
;
3152 sd
->vflip
= VFLIP_DEF
;
3153 sd
->autobrightness
= AUTOBRIGHT_DEF
;
3154 if (sd
->sensor
== SEN_OV7670
) {
3155 sd
->freq
= OV7670_FREQ_DEF
;
3156 gspca_dev
->ctrl_dis
= (1 << FREQ_IDX
) | (1 << COLOR_IDX
);
3158 sd
->freq
= FREQ_DEF
;
3159 gspca_dev
->ctrl_dis
= (1 << HFLIP_IDX
) | (1 << VFLIP_IDX
) |
3160 (1 << OV7670_FREQ_IDX
);
3162 sd
->quality
= QUALITY_DEF
;
3163 if (sd
->sensor
== SEN_OV7640
||
3164 sd
->sensor
== SEN_OV7648
)
3165 gspca_dev
->ctrl_dis
|= (1 << AUTOBRIGHT_IDX
) |
3166 (1 << CONTRAST_IDX
);
3167 if (sd
->sensor
== SEN_OV7670
)
3168 gspca_dev
->ctrl_dis
|= 1 << AUTOBRIGHT_IDX
;
3169 /* OV8610 Frequency filter control should work but needs testing */
3170 if (sd
->sensor
== SEN_OV8610
)
3171 gspca_dev
->ctrl_dis
|= 1 << FREQ_IDX
;
3172 /* No controls for the OV2610/OV3610 */
3173 if (sd
->sensor
== SEN_OV2610
|| sd
->sensor
== SEN_OV3610
)
3174 gspca_dev
->ctrl_dis
|= 0xFF;
3178 PDEBUG(D_ERR
, "OV519 Config failed");
3182 /* this function is called at probe and resume time */
3183 static int sd_init(struct gspca_dev
*gspca_dev
)
3185 struct sd
*sd
= (struct sd
*) gspca_dev
;
3187 /* initialize the sensor */
3188 switch (sd
->sensor
) {
3190 if (write_i2c_regvals(sd
, norm_2610
, ARRAY_SIZE(norm_2610
)))
3192 /* Enable autogain, autoexpo, awb, bandfilter */
3193 if (i2c_w_mask(sd
, 0x13, 0x27, 0x27) < 0)
3197 if (write_i2c_regvals(sd
, norm_3620b
, ARRAY_SIZE(norm_3620b
)))
3199 /* Enable autogain, autoexpo, awb, bandfilter */
3200 if (i2c_w_mask(sd
, 0x13, 0x27, 0x27) < 0)
3204 if (write_i2c_regvals(sd
, norm_6x20
, ARRAY_SIZE(norm_6x20
)))
3209 if (write_i2c_regvals(sd
, norm_6x30
, ARRAY_SIZE(norm_6x30
)))
3213 /* case SEN_OV7610: */
3214 /* case SEN_OV76BE: */
3215 if (write_i2c_regvals(sd
, norm_7610
, ARRAY_SIZE(norm_7610
)))
3217 if (i2c_w_mask(sd
, 0x0e, 0x00, 0x40))
3222 if (write_i2c_regvals(sd
, norm_7620
, ARRAY_SIZE(norm_7620
)))
3227 if (write_i2c_regvals(sd
, norm_7640
, ARRAY_SIZE(norm_7640
)))
3231 if (write_i2c_regvals(sd
, norm_7670
, ARRAY_SIZE(norm_7670
)))
3235 if (write_i2c_regvals(sd
, norm_8610
, ARRAY_SIZE(norm_8610
)))
3242 /* Set up the OV511/OV511+ with the given image parameters.
3244 * Do not put any sensor-specific code in here (including I2C I/O functions)
3246 static int ov511_mode_init_regs(struct sd
*sd
)
3248 int hsegs
, vsegs
, packet_size
, fps
, needed
;
3250 struct usb_host_interface
*alt
;
3251 struct usb_interface
*intf
;
3253 intf
= usb_ifnum_to_if(sd
->gspca_dev
.dev
, sd
->gspca_dev
.iface
);
3254 alt
= usb_altnum_to_altsetting(intf
, sd
->gspca_dev
.alt
);
3256 PDEBUG(D_ERR
, "Couldn't get altsetting");
3260 packet_size
= le16_to_cpu(alt
->endpoint
[0].desc
.wMaxPacketSize
);
3261 reg_w(sd
, R51x_FIFO_PSIZE
, packet_size
>> 5);
3263 reg_w(sd
, R511_CAM_UV_EN
, 0x01);
3264 reg_w(sd
, R511_SNAP_UV_EN
, 0x01);
3265 reg_w(sd
, R511_SNAP_OPTS
, 0x03);
3267 /* Here I'm assuming that snapshot size == image size.
3268 * I hope that's always true. --claudio
3270 hsegs
= (sd
->gspca_dev
.width
>> 3) - 1;
3271 vsegs
= (sd
->gspca_dev
.height
>> 3) - 1;
3273 reg_w(sd
, R511_CAM_PXCNT
, hsegs
);
3274 reg_w(sd
, R511_CAM_LNCNT
, vsegs
);
3275 reg_w(sd
, R511_CAM_PXDIV
, 0x00);
3276 reg_w(sd
, R511_CAM_LNDIV
, 0x00);
3278 /* YUV420, low pass filter on */
3279 reg_w(sd
, R511_CAM_OPTS
, 0x03);
3281 /* Snapshot additions */
3282 reg_w(sd
, R511_SNAP_PXCNT
, hsegs
);
3283 reg_w(sd
, R511_SNAP_LNCNT
, vsegs
);
3284 reg_w(sd
, R511_SNAP_PXDIV
, 0x00);
3285 reg_w(sd
, R511_SNAP_LNDIV
, 0x00);
3287 /******** Set the framerate ********/
3289 sd
->frame_rate
= frame_rate
;
3291 switch (sd
->sensor
) {
3293 /* No framerate control, doesn't like higher rates yet */
3302 if (sd
->gspca_dev
.width
== 320)
3308 switch (sd
->frame_rate
) {
3311 /* Not enough bandwidth to do 640x480 @ 30 fps */
3312 if (sd
->gspca_dev
.width
!= 640) {
3316 /* Fall through for 640x480 case */
3330 sd
->clockdiv
= (sd
->clockdiv
+ 1) * 2 - 1;
3331 /* Higher then 10 does not work */
3332 if (sd
->clockdiv
> 10)
3338 /* No framerate control ?? */
3343 /* Check if we have enough bandwidth to disable compression */
3344 fps
= (interlaced
? 60 : 30) / (sd
->clockdiv
+ 1) + 1;
3345 needed
= fps
* sd
->gspca_dev
.width
* sd
->gspca_dev
.height
* 3 / 2;
3346 /* 1400 is a conservative estimate of the max nr of isoc packets/sec */
3347 if (needed
> 1400 * packet_size
) {
3348 /* Enable Y and UV quantization and compression */
3349 reg_w(sd
, R511_COMP_EN
, 0x07);
3350 reg_w(sd
, R511_COMP_LUT_EN
, 0x03);
3352 reg_w(sd
, R511_COMP_EN
, 0x06);
3353 reg_w(sd
, R511_COMP_LUT_EN
, 0x00);
3356 reg_w(sd
, R51x_SYS_RESET
, OV511_RESET_OMNICE
);
3357 reg_w(sd
, R51x_SYS_RESET
, 0);
3362 /* Sets up the OV518/OV518+ with the given image parameters
3364 * OV518 needs a completely different approach, until we can figure out what
3365 * the individual registers do. Also, only 15 FPS is supported now.
3367 * Do not put any sensor-specific code in here (including I2C I/O functions)
3369 static int ov518_mode_init_regs(struct sd
*sd
)
3371 int hsegs
, vsegs
, packet_size
;
3372 struct usb_host_interface
*alt
;
3373 struct usb_interface
*intf
;
3375 intf
= usb_ifnum_to_if(sd
->gspca_dev
.dev
, sd
->gspca_dev
.iface
);
3376 alt
= usb_altnum_to_altsetting(intf
, sd
->gspca_dev
.alt
);
3378 PDEBUG(D_ERR
, "Couldn't get altsetting");
3382 packet_size
= le16_to_cpu(alt
->endpoint
[0].desc
.wMaxPacketSize
);
3383 ov518_reg_w32(sd
, R51x_FIFO_PSIZE
, packet_size
& ~7, 2);
3385 /******** Set the mode ********/
3396 if (sd
->bridge
== BRIDGE_OV518
) {
3397 /* Set 8-bit (YVYU) input format */
3398 reg_w_mask(sd
, 0x20, 0x08, 0x08);
3400 /* Set 12-bit (4:2:0) output format */
3401 reg_w_mask(sd
, 0x28, 0x80, 0xf0);
3402 reg_w_mask(sd
, 0x38, 0x80, 0xf0);
3404 reg_w(sd
, 0x28, 0x80);
3405 reg_w(sd
, 0x38, 0x80);
3408 hsegs
= sd
->gspca_dev
.width
/ 16;
3409 vsegs
= sd
->gspca_dev
.height
/ 4;
3411 reg_w(sd
, 0x29, hsegs
);
3412 reg_w(sd
, 0x2a, vsegs
);
3414 reg_w(sd
, 0x39, hsegs
);
3415 reg_w(sd
, 0x3a, vsegs
);
3417 /* Windows driver does this here; who knows why */
3418 reg_w(sd
, 0x2f, 0x80);
3420 /******** Set the framerate ********/
3423 /* Mode independent, but framerate dependent, regs */
3424 /* 0x51: Clock divider; Only works on some cams which use 2 crystals */
3425 reg_w(sd
, 0x51, 0x04);
3426 reg_w(sd
, 0x22, 0x18);
3427 reg_w(sd
, 0x23, 0xff);
3429 if (sd
->bridge
== BRIDGE_OV518PLUS
) {
3430 switch (sd
->sensor
) {
3432 if (sd
->gspca_dev
.width
== 320) {
3433 reg_w(sd
, 0x20, 0x00);
3434 reg_w(sd
, 0x21, 0x19);
3436 reg_w(sd
, 0x20, 0x60);
3437 reg_w(sd
, 0x21, 0x1f);
3441 reg_w(sd
, 0x20, 0x00);
3442 reg_w(sd
, 0x21, 0x19);
3445 reg_w(sd
, 0x21, 0x19);
3448 reg_w(sd
, 0x71, 0x17); /* Compression-related? */
3450 /* Bit 5 is what matters here. Of course, it is "reserved" */
3451 i2c_w(sd
, 0x54, 0x23);
3453 reg_w(sd
, 0x2f, 0x80);
3455 if (sd
->bridge
== BRIDGE_OV518PLUS
) {
3456 reg_w(sd
, 0x24, 0x94);
3457 reg_w(sd
, 0x25, 0x90);
3458 ov518_reg_w32(sd
, 0xc4, 400, 2); /* 190h */
3459 ov518_reg_w32(sd
, 0xc6, 540, 2); /* 21ch */
3460 ov518_reg_w32(sd
, 0xc7, 540, 2); /* 21ch */
3461 ov518_reg_w32(sd
, 0xc8, 108, 2); /* 6ch */
3462 ov518_reg_w32(sd
, 0xca, 131098, 3); /* 2001ah */
3463 ov518_reg_w32(sd
, 0xcb, 532, 2); /* 214h */
3464 ov518_reg_w32(sd
, 0xcc, 2400, 2); /* 960h */
3465 ov518_reg_w32(sd
, 0xcd, 32, 2); /* 20h */
3466 ov518_reg_w32(sd
, 0xce, 608, 2); /* 260h */
3468 reg_w(sd
, 0x24, 0x9f);
3469 reg_w(sd
, 0x25, 0x90);
3470 ov518_reg_w32(sd
, 0xc4, 400, 2); /* 190h */
3471 ov518_reg_w32(sd
, 0xc6, 381, 2); /* 17dh */
3472 ov518_reg_w32(sd
, 0xc7, 381, 2); /* 17dh */
3473 ov518_reg_w32(sd
, 0xc8, 128, 2); /* 80h */
3474 ov518_reg_w32(sd
, 0xca, 183331, 3); /* 2cc23h */
3475 ov518_reg_w32(sd
, 0xcb, 746, 2); /* 2eah */
3476 ov518_reg_w32(sd
, 0xcc, 1750, 2); /* 6d6h */
3477 ov518_reg_w32(sd
, 0xcd, 45, 2); /* 2dh */
3478 ov518_reg_w32(sd
, 0xce, 851, 2); /* 353h */
3481 reg_w(sd
, 0x2f, 0x80);
3487 /* Sets up the OV519 with the given image parameters
3489 * OV519 needs a completely different approach, until we can figure out what
3490 * the individual registers do.
3492 * Do not put any sensor-specific code in here (including I2C I/O functions)
3494 static int ov519_mode_init_regs(struct sd
*sd
)
3496 static const struct ov_regvals mode_init_519_ov7670
[] = {
3497 { 0x5d, 0x03 }, /* Turn off suspend mode */
3498 { 0x53, 0x9f }, /* was 9b in 1.65-1.08 */
3499 { 0x54, 0x0f }, /* bit2 (jpeg enable) */
3500 { 0xa2, 0x20 }, /* a2-a5 are undocumented */
3504 { 0x37, 0x00 }, /* SetUsbInit */
3505 { 0x55, 0x02 }, /* 4.096 Mhz audio clock */
3506 /* Enable both fields, YUV Input, disable defect comp (why?) */
3510 { 0x17, 0x50 }, /* undocumented */
3511 { 0x37, 0x00 }, /* undocumented */
3512 { 0x40, 0xff }, /* I2C timeout counter */
3513 { 0x46, 0x00 }, /* I2C clock prescaler */
3514 { 0x59, 0x04 }, /* new from windrv 090403 */
3515 { 0xff, 0x00 }, /* undocumented */
3516 /* windows reads 0x55 at this point, why? */
3519 static const struct ov_regvals mode_init_519
[] = {
3520 { 0x5d, 0x03 }, /* Turn off suspend mode */
3521 { 0x53, 0x9f }, /* was 9b in 1.65-1.08 */
3522 { 0x54, 0x0f }, /* bit2 (jpeg enable) */
3523 { 0xa2, 0x20 }, /* a2-a5 are undocumented */
3527 { 0x37, 0x00 }, /* SetUsbInit */
3528 { 0x55, 0x02 }, /* 4.096 Mhz audio clock */
3529 /* Enable both fields, YUV Input, disable defect comp (why?) */
3531 { 0x17, 0x50 }, /* undocumented */
3532 { 0x37, 0x00 }, /* undocumented */
3533 { 0x40, 0xff }, /* I2C timeout counter */
3534 { 0x46, 0x00 }, /* I2C clock prescaler */
3535 { 0x59, 0x04 }, /* new from windrv 090403 */
3536 { 0xff, 0x00 }, /* undocumented */
3537 /* windows reads 0x55 at this point, why? */
3540 /******** Set the mode ********/
3541 if (sd
->sensor
!= SEN_OV7670
) {
3542 if (write_regvals(sd
, mode_init_519
,
3543 ARRAY_SIZE(mode_init_519
)))
3545 if (sd
->sensor
== SEN_OV7640
||
3546 sd
->sensor
== SEN_OV7648
) {
3547 /* Select 8-bit input mode */
3548 reg_w_mask(sd
, OV519_R20_DFR
, 0x10, 0x10);
3551 if (write_regvals(sd
, mode_init_519_ov7670
,
3552 ARRAY_SIZE(mode_init_519_ov7670
)))
3556 reg_w(sd
, OV519_R10_H_SIZE
, sd
->gspca_dev
.width
>> 4);
3557 reg_w(sd
, OV519_R11_V_SIZE
, sd
->gspca_dev
.height
>> 3);
3558 if (sd
->sensor
== SEN_OV7670
&&
3559 sd
->gspca_dev
.cam
.cam_mode
[sd
->gspca_dev
.curr_mode
].priv
)
3560 reg_w(sd
, OV519_R12_X_OFFSETL
, 0x04);
3561 else if (sd
->sensor
== SEN_OV7648
&&
3562 sd
->gspca_dev
.cam
.cam_mode
[sd
->gspca_dev
.curr_mode
].priv
)
3563 reg_w(sd
, OV519_R12_X_OFFSETL
, 0x01);
3565 reg_w(sd
, OV519_R12_X_OFFSETL
, 0x00);
3566 reg_w(sd
, OV519_R13_X_OFFSETH
, 0x00);
3567 reg_w(sd
, OV519_R14_Y_OFFSETL
, 0x00);
3568 reg_w(sd
, OV519_R15_Y_OFFSETH
, 0x00);
3569 reg_w(sd
, OV519_R16_DIVIDER
, 0x00);
3570 reg_w(sd
, OV519_R25_FORMAT
, 0x03); /* YUV422 */
3571 reg_w(sd
, 0x26, 0x00); /* Undocumented */
3573 /******** Set the framerate ********/
3575 sd
->frame_rate
= frame_rate
;
3578 switch (sd
->sensor
) {
3581 switch (sd
->frame_rate
) {
3584 reg_w(sd
, 0xa4, 0x0c);
3585 reg_w(sd
, 0x23, 0xff);
3588 reg_w(sd
, 0xa4, 0x0c);
3589 reg_w(sd
, 0x23, 0x1f);
3592 reg_w(sd
, 0xa4, 0x0c);
3593 reg_w(sd
, 0x23, 0x1b);
3596 reg_w(sd
, 0xa4, 0x04);
3597 reg_w(sd
, 0x23, 0xff);
3601 reg_w(sd
, 0xa4, 0x04);
3602 reg_w(sd
, 0x23, 0x1f);
3606 reg_w(sd
, 0xa4, 0x04);
3607 reg_w(sd
, 0x23, 0x1b);
3613 switch (sd
->frame_rate
) {
3614 default: /* 15 fps */
3616 reg_w(sd
, 0xa4, 0x06);
3617 reg_w(sd
, 0x23, 0xff);
3620 reg_w(sd
, 0xa4, 0x06);
3621 reg_w(sd
, 0x23, 0x1f);
3624 reg_w(sd
, 0xa4, 0x06);
3625 reg_w(sd
, 0x23, 0x1b);
3629 case SEN_OV7670
: /* guesses, based on 7640 */
3630 PDEBUG(D_STREAM
, "Setting framerate to %d fps",
3631 (sd
->frame_rate
== 0) ? 15 : sd
->frame_rate
);
3632 reg_w(sd
, 0xa4, 0x10);
3633 switch (sd
->frame_rate
) {
3635 reg_w(sd
, 0x23, 0xff);
3638 reg_w(sd
, 0x23, 0x1b);
3642 reg_w(sd
, 0x23, 0xff);
3651 static int mode_init_ov_sensor_regs(struct sd
*sd
)
3653 struct gspca_dev
*gspca_dev
;
3654 int qvga
, xstart
, xend
, ystart
, yend
;
3657 gspca_dev
= &sd
->gspca_dev
;
3658 qvga
= gspca_dev
->cam
.cam_mode
[(int) gspca_dev
->curr_mode
].priv
& 1;
3660 /******** Mode (VGA/QVGA) and sensor specific regs ********/
3661 switch (sd
->sensor
) {
3663 i2c_w_mask(sd
, 0x14, qvga
? 0x20 : 0x00, 0x20);
3664 i2c_w_mask(sd
, 0x28, qvga
? 0x00 : 0x20, 0x20);
3665 i2c_w(sd
, 0x24, qvga
? 0x20 : 0x3a);
3666 i2c_w(sd
, 0x25, qvga
? 0x30 : 0x60);
3667 i2c_w_mask(sd
, 0x2d, qvga
? 0x40 : 0x00, 0x40);
3668 i2c_w_mask(sd
, 0x67, qvga
? 0xf0 : 0x90, 0xf0);
3669 i2c_w_mask(sd
, 0x74, qvga
? 0x20 : 0x00, 0x20);
3673 xstart
= (1040 - gspca_dev
->width
) / 2 + (0x1f << 4);
3674 ystart
= (776 - gspca_dev
->height
) / 2;
3676 xstart
= (2076 - gspca_dev
->width
) / 2 + (0x10 << 4);
3677 ystart
= (1544 - gspca_dev
->height
) / 2;
3679 xend
= xstart
+ gspca_dev
->width
;
3680 yend
= ystart
+ gspca_dev
->height
;
3681 /* Writing to the COMH register resets the other windowing regs
3682 to their default values, so we must do this first. */
3683 i2c_w_mask(sd
, 0x12, qvga
? 0x40 : 0x00, 0xf0);
3684 i2c_w_mask(sd
, 0x32,
3685 (((xend
>> 1) & 7) << 3) | ((xstart
>> 1) & 7),
3687 i2c_w_mask(sd
, 0x03,
3688 (((yend
>> 1) & 3) << 2) | ((ystart
>> 1) & 3),
3690 i2c_w(sd
, 0x17, xstart
>> 4);
3691 i2c_w(sd
, 0x18, xend
>> 4);
3692 i2c_w(sd
, 0x19, ystart
>> 3);
3693 i2c_w(sd
, 0x1a, yend
>> 3);
3696 /* For OV8610 qvga means qsvga */
3697 i2c_w_mask(sd
, OV7610_REG_COM_C
, qvga
? (1 << 5) : 0, 1 << 5);
3698 i2c_w_mask(sd
, 0x13, 0x00, 0x20); /* Select 16 bit data bus */
3699 i2c_w_mask(sd
, 0x12, 0x04, 0x06); /* AWB: 1 Test pattern: 0 */
3700 i2c_w_mask(sd
, 0x2d, 0x00, 0x40); /* from windrv 090403 */
3701 i2c_w_mask(sd
, 0x28, 0x20, 0x20); /* progressive mode on */
3704 i2c_w_mask(sd
, 0x14, qvga
? 0x20 : 0x00, 0x20);
3705 i2c_w(sd
, 0x35, qvga
?0x1e:0x9e);
3706 i2c_w_mask(sd
, 0x13, 0x00, 0x20); /* Select 16 bit data bus */
3707 i2c_w_mask(sd
, 0x12, 0x04, 0x06); /* AWB: 1 Test pattern: 0 */
3712 i2c_w_mask(sd
, 0x14, qvga
? 0x20 : 0x00, 0x20);
3713 i2c_w_mask(sd
, 0x28, qvga
? 0x00 : 0x20, 0x20);
3714 i2c_w(sd
, 0x24, qvga
? 0x20 : 0x3a);
3715 i2c_w(sd
, 0x25, qvga
? 0x30 : 0x60);
3716 i2c_w_mask(sd
, 0x2d, qvga
? 0x40 : 0x00, 0x40);
3717 i2c_w_mask(sd
, 0x67, qvga
? 0xb0 : 0x90, 0xf0);
3718 i2c_w_mask(sd
, 0x74, qvga
? 0x20 : 0x00, 0x20);
3719 i2c_w_mask(sd
, 0x13, 0x00, 0x20); /* Select 16 bit data bus */
3720 i2c_w_mask(sd
, 0x12, 0x04, 0x06); /* AWB: 1 Test pattern: 0 */
3721 if (sd
->sensor
== SEN_OV76BE
)
3722 i2c_w(sd
, 0x35, qvga
? 0x1e : 0x9e);
3726 i2c_w_mask(sd
, 0x14, qvga
? 0x20 : 0x00, 0x20);
3727 i2c_w_mask(sd
, 0x28, qvga
? 0x00 : 0x20, 0x20);
3728 /* Setting this undocumented bit in qvga mode removes a very
3729 annoying vertical shaking of the image */
3730 i2c_w_mask(sd
, 0x2d, qvga
? 0x40 : 0x00, 0x40);
3732 i2c_w_mask(sd
, 0x67, qvga
? 0xf0 : 0x90, 0xf0);
3733 /* Allow higher automatic gain (to allow higher framerates) */
3734 i2c_w_mask(sd
, 0x74, qvga
? 0x20 : 0x00, 0x20);
3735 i2c_w_mask(sd
, 0x12, 0x04, 0x04); /* AWB: 1 */
3738 /* set COM7_FMT_VGA or COM7_FMT_QVGA
3739 * do we need to set anything else?
3740 * HSTART etc are set in set_ov_sensor_window itself */
3741 i2c_w_mask(sd
, OV7670_REG_COM7
,
3742 qvga
? OV7670_COM7_FMT_QVGA
: OV7670_COM7_FMT_VGA
,
3743 OV7670_COM7_FMT_MASK
);
3744 i2c_w_mask(sd
, 0x13, 0x00, 0x20); /* Select 16 bit data bus */
3745 i2c_w_mask(sd
, OV7670_REG_COM8
, OV7670_COM8_AWB
,
3747 if (qvga
) { /* QVGA from ov7670.c by
3748 * Jonathan Corbet */
3759 /* OV7670 hardware window registers are split across
3760 * multiple locations */
3761 i2c_w(sd
, OV7670_REG_HSTART
, xstart
>> 3);
3762 i2c_w(sd
, OV7670_REG_HSTOP
, xend
>> 3);
3763 v
= i2c_r(sd
, OV7670_REG_HREF
);
3764 v
= (v
& 0xc0) | ((xend
& 0x7) << 3) | (xstart
& 0x07);
3765 msleep(10); /* need to sleep between read and write to
3767 i2c_w(sd
, OV7670_REG_HREF
, v
);
3769 i2c_w(sd
, OV7670_REG_VSTART
, ystart
>> 2);
3770 i2c_w(sd
, OV7670_REG_VSTOP
, yend
>> 2);
3771 v
= i2c_r(sd
, OV7670_REG_VREF
);
3772 v
= (v
& 0xc0) | ((yend
& 0x3) << 2) | (ystart
& 0x03);
3773 msleep(10); /* need to sleep between read and write to
3775 i2c_w(sd
, OV7670_REG_VREF
, v
);
3778 i2c_w_mask(sd
, 0x14, qvga
? 0x20 : 0x00, 0x20);
3779 i2c_w_mask(sd
, 0x13, 0x00, 0x20); /* Select 16 bit data bus */
3780 i2c_w_mask(sd
, 0x12, 0x04, 0x06); /* AWB: 1 Test pattern: 0 */
3784 i2c_w_mask(sd
, 0x14, qvga
? 0x20 : 0x00, 0x20);
3785 i2c_w_mask(sd
, 0x12, 0x04, 0x06); /* AWB: 1 Test pattern: 0 */
3791 /******** Clock programming ********/
3792 i2c_w(sd
, 0x11, sd
->clockdiv
);
3797 static void sethvflip(struct sd
*sd
)
3799 if (sd
->sensor
!= SEN_OV7670
)
3801 if (sd
->gspca_dev
.streaming
)
3803 i2c_w_mask(sd
, OV7670_REG_MVFP
,
3804 OV7670_MVFP_MIRROR
* sd
->hflip
3805 | OV7670_MVFP_VFLIP
* sd
->vflip
,
3806 OV7670_MVFP_MIRROR
| OV7670_MVFP_VFLIP
);
3807 if (sd
->gspca_dev
.streaming
)
3811 static int set_ov_sensor_window(struct sd
*sd
)
3813 struct gspca_dev
*gspca_dev
;
3815 int hwsbase
, hwebase
, vwsbase
, vwebase
, hwscale
, vwscale
;
3818 /* mode setup is fully handled in mode_init_ov_sensor_regs for these */
3819 if (sd
->sensor
== SEN_OV2610
|| sd
->sensor
== SEN_OV3610
||
3820 sd
->sensor
== SEN_OV7670
)
3821 return mode_init_ov_sensor_regs(sd
);
3823 gspca_dev
= &sd
->gspca_dev
;
3824 qvga
= gspca_dev
->cam
.cam_mode
[(int) gspca_dev
->curr_mode
].priv
& 1;
3825 crop
= gspca_dev
->cam
.cam_mode
[(int) gspca_dev
->curr_mode
].priv
& 2;
3827 /* The different sensor ICs handle setting up of window differently.
3828 * IF YOU SET IT WRONG, YOU WILL GET ALL ZERO ISOC DATA FROM OV51x!! */
3829 switch (sd
->sensor
) {
3840 vwsbase
= vwebase
= 0x05;
3849 if (sd
->sensor
== SEN_OV66308AF
&& qvga
)
3850 /* HDG: this fixes U and V getting swapped */
3861 hwsbase
= 0x2f; /* From 7620.SET (spec is wrong) */
3863 vwsbase
= vwebase
= 0x05;
3869 vwsbase
= vwebase
= 0x03;
3875 switch (sd
->sensor
) {
3879 if (qvga
) { /* QCIF */
3884 vwscale
= 1; /* The datasheet says 0;
3889 if (qvga
) { /* QSVGA */
3897 default: /* SEN_OV7xx0 */
3898 if (qvga
) { /* QVGA */
3907 ret
= mode_init_ov_sensor_regs(sd
);
3911 i2c_w(sd
, 0x17, hwsbase
);
3912 i2c_w(sd
, 0x18, hwebase
+ (sd
->sensor_width
>> hwscale
));
3913 i2c_w(sd
, 0x19, vwsbase
);
3914 i2c_w(sd
, 0x1a, vwebase
+ (sd
->sensor_height
>> vwscale
));
3919 /* -- start the camera -- */
3920 static int sd_start(struct gspca_dev
*gspca_dev
)
3922 struct sd
*sd
= (struct sd
*) gspca_dev
;
3925 /* Default for most bridges, allow bridge_mode_init_regs to override */
3926 sd
->sensor_width
= sd
->gspca_dev
.width
;
3927 sd
->sensor_height
= sd
->gspca_dev
.height
;
3929 switch (sd
->bridge
) {
3931 case BRIDGE_OV511PLUS
:
3932 ret
= ov511_mode_init_regs(sd
);
3935 case BRIDGE_OV518PLUS
:
3936 ret
= ov518_mode_init_regs(sd
);
3939 ret
= ov519_mode_init_regs(sd
);
3941 /* case BRIDGE_OVFX2: nothing to do */
3942 case BRIDGE_W9968CF
:
3943 ret
= w9968cf_mode_init_regs(sd
);
3949 ret
= set_ov_sensor_window(sd
);
3953 setcontrast(gspca_dev
);
3954 setbrightness(gspca_dev
);
3955 setcolors(gspca_dev
);
3957 setautobrightness(sd
);
3960 /* Force clear snapshot state in case the snapshot button was
3961 pressed while we weren't streaming */
3962 sd
->snapshot_needs_reset
= 1;
3963 sd_reset_snapshot(gspca_dev
);
3964 sd
->snapshot_pressed
= 0;
3966 sd
->first_frame
= 3;
3968 ret
= ov51x_restart(sd
);
3971 ov51x_led_control(sd
, 1);
3974 PDEBUG(D_ERR
, "camera start error:%d", ret
);
3978 static void sd_stopN(struct gspca_dev
*gspca_dev
)
3980 struct sd
*sd
= (struct sd
*) gspca_dev
;
3983 ov51x_led_control(sd
, 0);
3986 static void sd_stop0(struct gspca_dev
*gspca_dev
)
3988 struct sd
*sd
= (struct sd
*) gspca_dev
;
3990 if (sd
->bridge
== BRIDGE_W9968CF
)
3994 static void ov51x_handle_button(struct gspca_dev
*gspca_dev
, u8 state
)
3996 struct sd
*sd
= (struct sd
*) gspca_dev
;
3998 if (sd
->snapshot_pressed
!= state
) {
4000 input_report_key(gspca_dev
->input_dev
, KEY_CAMERA
, state
);
4001 input_sync(gspca_dev
->input_dev
);
4004 sd
->snapshot_needs_reset
= 1;
4006 sd
->snapshot_pressed
= state
;
4008 /* On the ov511 / ov519 we need to reset the button state
4009 multiple times, as resetting does not work as long as the
4010 button stays pressed */
4011 switch (sd
->bridge
) {
4013 case BRIDGE_OV511PLUS
:
4016 sd
->snapshot_needs_reset
= 1;
4022 static void ov511_pkt_scan(struct gspca_dev
*gspca_dev
,
4023 u8
*in
, /* isoc packet */
4024 int len
) /* iso packet length */
4026 struct sd
*sd
= (struct sd
*) gspca_dev
;
4028 /* SOF/EOF packets have 1st to 8th bytes zeroed and the 9th
4029 * byte non-zero. The EOF packet has image width/height in the
4030 * 10th and 11th bytes. The 9th byte is given as follows:
4033 * 6: compression enabled
4034 * 5: 422/420/400 modes
4035 * 4: 422/420/400 modes
4037 * 2: snapshot button on
4041 if (!(in
[0] | in
[1] | in
[2] | in
[3] | in
[4] | in
[5] | in
[6] | in
[7]) &&
4043 ov51x_handle_button(gspca_dev
, (in
[8] >> 2) & 1);
4046 if ((in
[9] + 1) * 8 != gspca_dev
->width
||
4047 (in
[10] + 1) * 8 != gspca_dev
->height
) {
4048 PDEBUG(D_ERR
, "Invalid frame size, got: %dx%d,"
4049 " requested: %dx%d\n",
4050 (in
[9] + 1) * 8, (in
[10] + 1) * 8,
4051 gspca_dev
->width
, gspca_dev
->height
);
4052 gspca_dev
->last_packet_type
= DISCARD_PACKET
;
4055 /* Add 11 byte footer to frame, might be usefull */
4056 gspca_frame_add(gspca_dev
, LAST_PACKET
, in
, 11);
4060 gspca_frame_add(gspca_dev
, FIRST_PACKET
, in
, 0);
4065 /* Ignore the packet number */
4068 /* intermediate packet */
4069 gspca_frame_add(gspca_dev
, INTER_PACKET
, in
, len
);
4072 static void ov518_pkt_scan(struct gspca_dev
*gspca_dev
,
4073 u8
*data
, /* isoc packet */
4074 int len
) /* iso packet length */
4076 struct sd
*sd
= (struct sd
*) gspca_dev
;
4078 /* A false positive here is likely, until OVT gives me
4079 * the definitive SOF/EOF format */
4080 if ((!(data
[0] | data
[1] | data
[2] | data
[3] | data
[5])) && data
[6]) {
4081 ov51x_handle_button(gspca_dev
, (data
[6] >> 1) & 1);
4082 gspca_frame_add(gspca_dev
, LAST_PACKET
, NULL
, 0);
4083 gspca_frame_add(gspca_dev
, FIRST_PACKET
, NULL
, 0);
4087 if (gspca_dev
->last_packet_type
== DISCARD_PACKET
)
4090 /* Does this device use packet numbers ? */
4093 if (sd
->packet_nr
== data
[len
])
4095 /* The last few packets of the frame (which are all 0's
4096 except that they may contain part of the footer), are
4098 else if (sd
->packet_nr
== 0 || data
[len
]) {
4099 PDEBUG(D_ERR
, "Invalid packet nr: %d (expect: %d)",
4100 (int)data
[len
], (int)sd
->packet_nr
);
4101 gspca_dev
->last_packet_type
= DISCARD_PACKET
;
4106 /* intermediate packet */
4107 gspca_frame_add(gspca_dev
, INTER_PACKET
, data
, len
);
4110 static void ov519_pkt_scan(struct gspca_dev
*gspca_dev
,
4111 u8
*data
, /* isoc packet */
4112 int len
) /* iso packet length */
4114 /* Header of ov519 is 16 bytes:
4115 * Byte Value Description
4119 * 3 0xXX 0x50 = SOF, 0x51 = EOF
4120 * 9 0xXX 0x01 initial frame without data,
4121 * 0x00 standard frame with image
4122 * 14 Lo in EOF: length of image data / 8
4126 if (data
[0] == 0xff && data
[1] == 0xff && data
[2] == 0xff) {
4128 case 0x50: /* start of frame */
4129 /* Don't check the button state here, as the state
4130 usually (always ?) changes at EOF and checking it
4131 here leads to unnecessary snapshot state resets. */
4136 if (data
[0] == 0xff || data
[1] == 0xd8)
4137 gspca_frame_add(gspca_dev
, FIRST_PACKET
,
4140 gspca_dev
->last_packet_type
= DISCARD_PACKET
;
4142 case 0x51: /* end of frame */
4143 ov51x_handle_button(gspca_dev
, data
[11] & 1);
4145 gspca_dev
->last_packet_type
= DISCARD_PACKET
;
4146 gspca_frame_add(gspca_dev
, LAST_PACKET
,
4152 /* intermediate packet */
4153 gspca_frame_add(gspca_dev
, INTER_PACKET
, data
, len
);
4156 static void ovfx2_pkt_scan(struct gspca_dev
*gspca_dev
,
4157 u8
*data
, /* isoc packet */
4158 int len
) /* iso packet length */
4160 struct sd
*sd
= (struct sd
*) gspca_dev
;
4162 gspca_frame_add(gspca_dev
, INTER_PACKET
, data
, len
);
4164 /* A short read signals EOF */
4165 if (len
< OVFX2_BULK_SIZE
) {
4166 /* If the frame is short, and it is one of the first ones
4167 the sensor and bridge are still syncing, so drop it. */
4168 if (sd
->first_frame
) {
4170 if (gspca_dev
->image_len
<
4171 sd
->gspca_dev
.width
* sd
->gspca_dev
.height
)
4172 gspca_dev
->last_packet_type
= DISCARD_PACKET
;
4174 gspca_frame_add(gspca_dev
, LAST_PACKET
, NULL
, 0);
4175 gspca_frame_add(gspca_dev
, FIRST_PACKET
, NULL
, 0);
4179 static void sd_pkt_scan(struct gspca_dev
*gspca_dev
,
4180 u8
*data
, /* isoc packet */
4181 int len
) /* iso packet length */
4183 struct sd
*sd
= (struct sd
*) gspca_dev
;
4185 switch (sd
->bridge
) {
4187 case BRIDGE_OV511PLUS
:
4188 ov511_pkt_scan(gspca_dev
, data
, len
);
4191 case BRIDGE_OV518PLUS
:
4192 ov518_pkt_scan(gspca_dev
, data
, len
);
4195 ov519_pkt_scan(gspca_dev
, data
, len
);
4198 ovfx2_pkt_scan(gspca_dev
, data
, len
);
4200 case BRIDGE_W9968CF
:
4201 w9968cf_pkt_scan(gspca_dev
, data
, len
);
4206 /* -- management routines -- */
4208 static void setbrightness(struct gspca_dev
*gspca_dev
)
4210 struct sd
*sd
= (struct sd
*) gspca_dev
;
4213 val
= sd
->brightness
;
4214 switch (sd
->sensor
) {
4223 i2c_w(sd
, OV7610_REG_BRT
, val
);
4227 /* 7620 doesn't like manual changes when in auto mode */
4228 if (!sd
->autobrightness
)
4229 i2c_w(sd
, OV7610_REG_BRT
, val
);
4233 * i2c_w_mask(sd, OV7670_REG_COM8, 0, OV7670_COM8_AEC); */
4234 i2c_w(sd
, OV7670_REG_BRIGHT
, ov7670_abs_to_sm(val
));
4239 static void setcontrast(struct gspca_dev
*gspca_dev
)
4241 struct sd
*sd
= (struct sd
*) gspca_dev
;
4245 switch (sd
->sensor
) {
4248 i2c_w(sd
, OV7610_REG_CNT
, val
);
4252 i2c_w_mask(sd
, OV7610_REG_CNT
, val
>> 4, 0x0f);
4255 static const __u8 ctab
[] = {
4256 0x03, 0x09, 0x0b, 0x0f, 0x53, 0x6f, 0x35, 0x7f
4259 /* Use Y gamma control instead. Bit 0 enables it. */
4260 i2c_w(sd
, 0x64, ctab
[val
>> 5]);
4264 case SEN_OV7620AE
: {
4265 static const __u8 ctab
[] = {
4266 0x01, 0x05, 0x09, 0x11, 0x15, 0x35, 0x37, 0x57,
4267 0x5b, 0xa5, 0xa7, 0xc7, 0xc9, 0xcf, 0xef, 0xff
4270 /* Use Y gamma control instead. Bit 0 enables it. */
4271 i2c_w(sd
, 0x64, ctab
[val
>> 4]);
4275 /* check that this isn't just the same as ov7610 */
4276 i2c_w(sd
, OV7670_REG_CONTRAS
, val
>> 1);
4281 static void setcolors(struct gspca_dev
*gspca_dev
)
4283 struct sd
*sd
= (struct sd
*) gspca_dev
;
4287 switch (sd
->sensor
) {
4294 i2c_w(sd
, OV7610_REG_SAT
, val
);
4298 /* Use UV gamma control instead. Bits 0 & 7 are reserved. */
4299 /* rc = ov_i2c_write(sd->dev, 0x62, (val >> 9) & 0x7e);
4302 i2c_w(sd
, OV7610_REG_SAT
, val
);
4306 i2c_w(sd
, OV7610_REG_SAT
, val
& 0xf0);
4309 /* supported later once I work out how to do it
4310 * transparently fail now! */
4311 /* set REG_COM13 values for UV sat auto mode */
4316 static void setautobrightness(struct sd
*sd
)
4318 if (sd
->sensor
== SEN_OV7640
|| sd
->sensor
== SEN_OV7648
||
4319 sd
->sensor
== SEN_OV7670
||
4320 sd
->sensor
== SEN_OV2610
|| sd
->sensor
== SEN_OV3610
)
4323 i2c_w_mask(sd
, 0x2d, sd
->autobrightness
? 0x10 : 0x00, 0x10);
4326 static void setfreq(struct sd
*sd
)
4328 if (sd
->sensor
== SEN_OV2610
|| sd
->sensor
== SEN_OV3610
)
4331 if (sd
->sensor
== SEN_OV7670
) {
4333 case 0: /* Banding filter disabled */
4334 i2c_w_mask(sd
, OV7670_REG_COM8
, 0, OV7670_COM8_BFILT
);
4337 i2c_w_mask(sd
, OV7670_REG_COM8
, OV7670_COM8_BFILT
,
4339 i2c_w_mask(sd
, OV7670_REG_COM11
, 0x08, 0x18);
4342 i2c_w_mask(sd
, OV7670_REG_COM8
, OV7670_COM8_BFILT
,
4344 i2c_w_mask(sd
, OV7670_REG_COM11
, 0x00, 0x18);
4346 case 3: /* Auto hz */
4347 i2c_w_mask(sd
, OV7670_REG_COM8
, OV7670_COM8_BFILT
,
4349 i2c_w_mask(sd
, OV7670_REG_COM11
, OV7670_COM11_HZAUTO
,
4355 case 0: /* Banding filter disabled */
4356 i2c_w_mask(sd
, 0x2d, 0x00, 0x04);
4357 i2c_w_mask(sd
, 0x2a, 0x00, 0x80);
4359 case 1: /* 50 hz (filter on and framerate adj) */
4360 i2c_w_mask(sd
, 0x2d, 0x04, 0x04);
4361 i2c_w_mask(sd
, 0x2a, 0x80, 0x80);
4362 /* 20 fps -> 16.667 fps */
4363 if (sd
->sensor
== SEN_OV6620
||
4364 sd
->sensor
== SEN_OV6630
||
4365 sd
->sensor
== SEN_OV66308AF
)
4366 i2c_w(sd
, 0x2b, 0x5e);
4368 i2c_w(sd
, 0x2b, 0xac);
4370 case 2: /* 60 hz (filter on, ...) */
4371 i2c_w_mask(sd
, 0x2d, 0x04, 0x04);
4372 if (sd
->sensor
== SEN_OV6620
||
4373 sd
->sensor
== SEN_OV6630
||
4374 sd
->sensor
== SEN_OV66308AF
) {
4375 /* 20 fps -> 15 fps */
4376 i2c_w_mask(sd
, 0x2a, 0x80, 0x80);
4377 i2c_w(sd
, 0x2b, 0xa8);
4379 /* no framerate adj. */
4380 i2c_w_mask(sd
, 0x2a, 0x00, 0x80);
4387 static int sd_setbrightness(struct gspca_dev
*gspca_dev
, __s32 val
)
4389 struct sd
*sd
= (struct sd
*) gspca_dev
;
4391 sd
->brightness
= val
;
4392 if (gspca_dev
->streaming
)
4393 setbrightness(gspca_dev
);
4397 static int sd_getbrightness(struct gspca_dev
*gspca_dev
, __s32
*val
)
4399 struct sd
*sd
= (struct sd
*) gspca_dev
;
4401 *val
= sd
->brightness
;
4405 static int sd_setcontrast(struct gspca_dev
*gspca_dev
, __s32 val
)
4407 struct sd
*sd
= (struct sd
*) gspca_dev
;
4410 if (gspca_dev
->streaming
)
4411 setcontrast(gspca_dev
);
4415 static int sd_getcontrast(struct gspca_dev
*gspca_dev
, __s32
*val
)
4417 struct sd
*sd
= (struct sd
*) gspca_dev
;
4419 *val
= sd
->contrast
;
4423 static int sd_setcolors(struct gspca_dev
*gspca_dev
, __s32 val
)
4425 struct sd
*sd
= (struct sd
*) gspca_dev
;
4428 if (gspca_dev
->streaming
)
4429 setcolors(gspca_dev
);
4433 static int sd_getcolors(struct gspca_dev
*gspca_dev
, __s32
*val
)
4435 struct sd
*sd
= (struct sd
*) gspca_dev
;
4441 static int sd_sethflip(struct gspca_dev
*gspca_dev
, __s32 val
)
4443 struct sd
*sd
= (struct sd
*) gspca_dev
;
4446 if (gspca_dev
->streaming
)
4451 static int sd_gethflip(struct gspca_dev
*gspca_dev
, __s32
*val
)
4453 struct sd
*sd
= (struct sd
*) gspca_dev
;
4459 static int sd_setvflip(struct gspca_dev
*gspca_dev
, __s32 val
)
4461 struct sd
*sd
= (struct sd
*) gspca_dev
;
4464 if (gspca_dev
->streaming
)
4469 static int sd_getvflip(struct gspca_dev
*gspca_dev
, __s32
*val
)
4471 struct sd
*sd
= (struct sd
*) gspca_dev
;
4477 static int sd_setautobrightness(struct gspca_dev
*gspca_dev
, __s32 val
)
4479 struct sd
*sd
= (struct sd
*) gspca_dev
;
4481 sd
->autobrightness
= val
;
4482 if (gspca_dev
->streaming
)
4483 setautobrightness(sd
);
4487 static int sd_getautobrightness(struct gspca_dev
*gspca_dev
, __s32
*val
)
4489 struct sd
*sd
= (struct sd
*) gspca_dev
;
4491 *val
= sd
->autobrightness
;
4495 static int sd_setfreq(struct gspca_dev
*gspca_dev
, __s32 val
)
4497 struct sd
*sd
= (struct sd
*) gspca_dev
;
4500 if (gspca_dev
->streaming
) {
4502 /* Ugly but necessary */
4503 if (sd
->bridge
== BRIDGE_W9968CF
)
4504 w9968cf_set_crop_window(sd
);
4509 static int sd_getfreq(struct gspca_dev
*gspca_dev
, __s32
*val
)
4511 struct sd
*sd
= (struct sd
*) gspca_dev
;
4517 static int sd_querymenu(struct gspca_dev
*gspca_dev
,
4518 struct v4l2_querymenu
*menu
)
4520 struct sd
*sd
= (struct sd
*) gspca_dev
;
4523 case V4L2_CID_POWER_LINE_FREQUENCY
:
4524 switch (menu
->index
) {
4525 case 0: /* V4L2_CID_POWER_LINE_FREQUENCY_DISABLED */
4526 strcpy((char *) menu
->name
, "NoFliker");
4528 case 1: /* V4L2_CID_POWER_LINE_FREQUENCY_50HZ */
4529 strcpy((char *) menu
->name
, "50 Hz");
4531 case 2: /* V4L2_CID_POWER_LINE_FREQUENCY_60HZ */
4532 strcpy((char *) menu
->name
, "60 Hz");
4535 if (sd
->sensor
!= SEN_OV7670
)
4538 strcpy((char *) menu
->name
, "Automatic");
4546 static int sd_get_jcomp(struct gspca_dev
*gspca_dev
,
4547 struct v4l2_jpegcompression
*jcomp
)
4549 struct sd
*sd
= (struct sd
*) gspca_dev
;
4551 if (sd
->bridge
!= BRIDGE_W9968CF
)
4554 memset(jcomp
, 0, sizeof *jcomp
);
4555 jcomp
->quality
= sd
->quality
;
4556 jcomp
->jpeg_markers
= V4L2_JPEG_MARKER_DHT
| V4L2_JPEG_MARKER_DQT
|
4557 V4L2_JPEG_MARKER_DRI
;
4561 static int sd_set_jcomp(struct gspca_dev
*gspca_dev
,
4562 struct v4l2_jpegcompression
*jcomp
)
4564 struct sd
*sd
= (struct sd
*) gspca_dev
;
4566 if (sd
->bridge
!= BRIDGE_W9968CF
)
4569 if (gspca_dev
->streaming
)
4572 if (jcomp
->quality
< QUALITY_MIN
)
4573 sd
->quality
= QUALITY_MIN
;
4574 else if (jcomp
->quality
> QUALITY_MAX
)
4575 sd
->quality
= QUALITY_MAX
;
4577 sd
->quality
= jcomp
->quality
;
4579 /* Return resulting jcomp params to app */
4580 sd_get_jcomp(gspca_dev
, jcomp
);
4585 /* sub-driver description */
4586 static const struct sd_desc sd_desc
= {
4587 .name
= MODULE_NAME
,
4589 .nctrls
= ARRAY_SIZE(sd_ctrls
),
4590 .config
= sd_config
,
4595 .pkt_scan
= sd_pkt_scan
,
4596 .dq_callback
= sd_reset_snapshot
,
4597 .querymenu
= sd_querymenu
,
4598 .get_jcomp
= sd_get_jcomp
,
4599 .set_jcomp
= sd_set_jcomp
,
4605 /* -- module initialisation -- */
4606 static const __devinitdata
struct usb_device_id device_table
[] = {
4607 {USB_DEVICE(0x041e, 0x4003), .driver_info
= BRIDGE_W9968CF
},
4608 {USB_DEVICE(0x041e, 0x4052), .driver_info
= BRIDGE_OV519
},
4609 {USB_DEVICE(0x041e, 0x405f), .driver_info
= BRIDGE_OV519
},
4610 {USB_DEVICE(0x041e, 0x4060), .driver_info
= BRIDGE_OV519
},
4611 {USB_DEVICE(0x041e, 0x4061), .driver_info
= BRIDGE_OV519
},
4612 {USB_DEVICE(0x041e, 0x4064),
4613 .driver_info
= BRIDGE_OV519
| BRIDGE_INVERT_LED
},
4614 {USB_DEVICE(0x041e, 0x4067), .driver_info
= BRIDGE_OV519
},
4615 {USB_DEVICE(0x041e, 0x4068),
4616 .driver_info
= BRIDGE_OV519
| BRIDGE_INVERT_LED
},
4617 {USB_DEVICE(0x045e, 0x028c), .driver_info
= BRIDGE_OV519
},
4618 {USB_DEVICE(0x054c, 0x0154), .driver_info
= BRIDGE_OV519
},
4619 {USB_DEVICE(0x054c, 0x0155),
4620 .driver_info
= BRIDGE_OV519
| BRIDGE_INVERT_LED
},
4621 {USB_DEVICE(0x05a9, 0x0511), .driver_info
= BRIDGE_OV511
},
4622 {USB_DEVICE(0x05a9, 0x0518), .driver_info
= BRIDGE_OV518
},
4623 {USB_DEVICE(0x05a9, 0x0519), .driver_info
= BRIDGE_OV519
},
4624 {USB_DEVICE(0x05a9, 0x0530), .driver_info
= BRIDGE_OV519
},
4625 {USB_DEVICE(0x05a9, 0x2800), .driver_info
= BRIDGE_OVFX2
},
4626 {USB_DEVICE(0x05a9, 0x4519), .driver_info
= BRIDGE_OV519
},
4627 {USB_DEVICE(0x05a9, 0x8519), .driver_info
= BRIDGE_OV519
},
4628 {USB_DEVICE(0x05a9, 0xa511), .driver_info
= BRIDGE_OV511PLUS
},
4629 {USB_DEVICE(0x05a9, 0xa518), .driver_info
= BRIDGE_OV518PLUS
},
4630 {USB_DEVICE(0x0813, 0x0002), .driver_info
= BRIDGE_OV511PLUS
},
4631 {USB_DEVICE(0x0b62, 0x0059), .driver_info
= BRIDGE_OVFX2
},
4632 {USB_DEVICE(0x0e96, 0xc001), .driver_info
= BRIDGE_OVFX2
},
4633 {USB_DEVICE(0x1046, 0x9967), .driver_info
= BRIDGE_W9968CF
},
4634 {USB_DEVICE(0x8020, 0xEF04), .driver_info
= BRIDGE_OVFX2
},
4638 MODULE_DEVICE_TABLE(usb
, device_table
);
4640 /* -- device connect -- */
4641 static int sd_probe(struct usb_interface
*intf
,
4642 const struct usb_device_id
*id
)
4644 return gspca_dev_probe(intf
, id
, &sd_desc
, sizeof(struct sd
),
4648 static struct usb_driver sd_driver
= {
4649 .name
= MODULE_NAME
,
4650 .id_table
= device_table
,
4652 .disconnect
= gspca_disconnect
,
4654 .suspend
= gspca_suspend
,
4655 .resume
= gspca_resume
,
4659 /* -- module insert / remove -- */
4660 static int __init
sd_mod_init(void)
4663 ret
= usb_register(&sd_driver
);
4666 PDEBUG(D_PROBE
, "registered");
4669 static void __exit
sd_mod_exit(void)
4671 usb_deregister(&sd_driver
);
4672 PDEBUG(D_PROBE
, "deregistered");
4675 module_init(sd_mod_init
);
4676 module_exit(sd_mod_exit
);
4678 module_param(frame_rate
, int, 0644);
4679 MODULE_PARM_DESC(frame_rate
, "Frame rate (5, 10, 15, 20 or 30 fps)");