4 * Copyright (C) 2008-2011 Jean-François Moine <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.
36 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
38 #define MODULE_NAME "ov519"
40 #include <linux/input.h>
43 /* The jpeg_hdr is used by w996Xcf only */
44 /* The CONEX_CAM define for jpeg.h needs renaming, now its used here too */
48 MODULE_AUTHOR("Jean-Francois Moine <http://moinejf.free.fr>");
49 MODULE_DESCRIPTION("OV519 USB Camera Driver");
50 MODULE_LICENSE("GPL");
52 /* global parameters */
53 static int frame_rate
;
55 /* Number of times to retry a failed I2C transaction. Increase this if you
56 * are getting "Failed to read sensor ID..." */
57 static int i2c_detect_tries
= 10;
59 /* ov519 device descriptor */
61 struct gspca_dev gspca_dev
; /* !! must be the first item */
63 struct v4l2_ctrl
*jpegqual
;
64 struct v4l2_ctrl
*freq
;
65 struct { /* h/vflip control cluster */
66 struct v4l2_ctrl
*hflip
;
67 struct v4l2_ctrl
*vflip
;
69 struct { /* autobrightness/brightness control cluster */
70 struct v4l2_ctrl
*autobright
;
71 struct v4l2_ctrl
*brightness
;
79 #define BRIDGE_OV511 0
80 #define BRIDGE_OV511PLUS 1
81 #define BRIDGE_OV518 2
82 #define BRIDGE_OV518PLUS 3
83 #define BRIDGE_OV519 4 /* = ov530 */
84 #define BRIDGE_OVFX2 5
85 #define BRIDGE_W9968CF 6
89 #define BRIDGE_INVERT_LED 8
91 char snapshot_pressed
;
92 char snapshot_needs_reset
;
94 /* Determined by sensor type */
97 #define QUALITY_MIN 50
98 #define QUALITY_MAX 70
99 #define QUALITY_DEF 50
101 u8 stopped
; /* Streaming is temporarily paused */
104 u8 frame_rate
; /* current Framerate */
105 u8 clockdiv
; /* clockdiv override */
107 s8 sensor
; /* Type of image sensor chip (SEN_*) */
112 s16 sensor_reg_cache
[256];
114 u8 jpeg_hdr
[JPEG_HDR_SZ
];
135 /* Note this is a bit of a hack, but the w9968cf driver needs the code for all
136 the ov sensors which is already present here. When we have the time we
137 really should move the sensor drivers to v4l2 sub drivers. */
140 /* table of the disabled controls */
142 unsigned int has_brightness
:1;
143 unsigned int has_contrast
:1;
144 unsigned int has_exposure
:1;
145 unsigned int has_autogain
:1;
146 unsigned int has_sat
:1;
147 unsigned int has_hvflip
:1;
148 unsigned int has_autobright
:1;
149 unsigned int has_freq
:1;
152 static const struct ctrl_valid valid_controls
[] = {
248 static const struct v4l2_pix_format ov519_vga_mode
[] = {
249 {320, 240, V4L2_PIX_FMT_JPEG
, V4L2_FIELD_NONE
,
251 .sizeimage
= 320 * 240 * 3 / 8 + 590,
252 .colorspace
= V4L2_COLORSPACE_JPEG
,
254 {640, 480, V4L2_PIX_FMT_JPEG
, V4L2_FIELD_NONE
,
256 .sizeimage
= 640 * 480 * 3 / 8 + 590,
257 .colorspace
= V4L2_COLORSPACE_JPEG
,
260 static const struct v4l2_pix_format ov519_sif_mode
[] = {
261 {160, 120, V4L2_PIX_FMT_JPEG
, V4L2_FIELD_NONE
,
263 .sizeimage
= 160 * 120 * 3 / 8 + 590,
264 .colorspace
= V4L2_COLORSPACE_JPEG
,
266 {176, 144, V4L2_PIX_FMT_JPEG
, V4L2_FIELD_NONE
,
268 .sizeimage
= 176 * 144 * 3 / 8 + 590,
269 .colorspace
= V4L2_COLORSPACE_JPEG
,
271 {320, 240, V4L2_PIX_FMT_JPEG
, V4L2_FIELD_NONE
,
273 .sizeimage
= 320 * 240 * 3 / 8 + 590,
274 .colorspace
= V4L2_COLORSPACE_JPEG
,
276 {352, 288, V4L2_PIX_FMT_JPEG
, V4L2_FIELD_NONE
,
278 .sizeimage
= 352 * 288 * 3 / 8 + 590,
279 .colorspace
= V4L2_COLORSPACE_JPEG
,
283 /* Note some of the sizeimage values for the ov511 / ov518 may seem
284 larger then necessary, however they need to be this big as the ov511 /
285 ov518 always fills the entire isoc frame, using 0 padding bytes when
286 it doesn't have any data. So with low framerates the amount of data
287 transferred can become quite large (libv4l will remove all the 0 padding
289 static const struct v4l2_pix_format ov518_vga_mode
[] = {
290 {320, 240, V4L2_PIX_FMT_OV518
, V4L2_FIELD_NONE
,
292 .sizeimage
= 320 * 240 * 3,
293 .colorspace
= V4L2_COLORSPACE_JPEG
,
295 {640, 480, V4L2_PIX_FMT_OV518
, V4L2_FIELD_NONE
,
297 .sizeimage
= 640 * 480 * 2,
298 .colorspace
= V4L2_COLORSPACE_JPEG
,
301 static const struct v4l2_pix_format ov518_sif_mode
[] = {
302 {160, 120, V4L2_PIX_FMT_OV518
, V4L2_FIELD_NONE
,
305 .colorspace
= V4L2_COLORSPACE_JPEG
,
307 {176, 144, V4L2_PIX_FMT_OV518
, V4L2_FIELD_NONE
,
310 .colorspace
= V4L2_COLORSPACE_JPEG
,
312 {320, 240, V4L2_PIX_FMT_OV518
, V4L2_FIELD_NONE
,
314 .sizeimage
= 320 * 240 * 3,
315 .colorspace
= V4L2_COLORSPACE_JPEG
,
317 {352, 288, V4L2_PIX_FMT_OV518
, V4L2_FIELD_NONE
,
319 .sizeimage
= 352 * 288 * 3,
320 .colorspace
= V4L2_COLORSPACE_JPEG
,
324 static const struct v4l2_pix_format ov511_vga_mode
[] = {
325 {320, 240, V4L2_PIX_FMT_OV511
, V4L2_FIELD_NONE
,
327 .sizeimage
= 320 * 240 * 3,
328 .colorspace
= V4L2_COLORSPACE_JPEG
,
330 {640, 480, V4L2_PIX_FMT_OV511
, V4L2_FIELD_NONE
,
332 .sizeimage
= 640 * 480 * 2,
333 .colorspace
= V4L2_COLORSPACE_JPEG
,
336 static const struct v4l2_pix_format ov511_sif_mode
[] = {
337 {160, 120, V4L2_PIX_FMT_OV511
, V4L2_FIELD_NONE
,
340 .colorspace
= V4L2_COLORSPACE_JPEG
,
342 {176, 144, V4L2_PIX_FMT_OV511
, V4L2_FIELD_NONE
,
345 .colorspace
= V4L2_COLORSPACE_JPEG
,
347 {320, 240, V4L2_PIX_FMT_OV511
, V4L2_FIELD_NONE
,
349 .sizeimage
= 320 * 240 * 3,
350 .colorspace
= V4L2_COLORSPACE_JPEG
,
352 {352, 288, V4L2_PIX_FMT_OV511
, V4L2_FIELD_NONE
,
354 .sizeimage
= 352 * 288 * 3,
355 .colorspace
= V4L2_COLORSPACE_JPEG
,
359 static const struct v4l2_pix_format ovfx2_ov2610_mode
[] = {
360 {800, 600, V4L2_PIX_FMT_SBGGR8
, V4L2_FIELD_NONE
,
362 .sizeimage
= 800 * 600,
363 .colorspace
= V4L2_COLORSPACE_SRGB
,
365 {1600, 1200, V4L2_PIX_FMT_SBGGR8
, V4L2_FIELD_NONE
,
366 .bytesperline
= 1600,
367 .sizeimage
= 1600 * 1200,
368 .colorspace
= V4L2_COLORSPACE_SRGB
},
370 static const struct v4l2_pix_format ovfx2_ov3610_mode
[] = {
371 {640, 480, V4L2_PIX_FMT_SBGGR8
, V4L2_FIELD_NONE
,
373 .sizeimage
= 640 * 480,
374 .colorspace
= V4L2_COLORSPACE_SRGB
,
376 {800, 600, V4L2_PIX_FMT_SBGGR8
, V4L2_FIELD_NONE
,
378 .sizeimage
= 800 * 600,
379 .colorspace
= V4L2_COLORSPACE_SRGB
,
381 {1024, 768, V4L2_PIX_FMT_SBGGR8
, V4L2_FIELD_NONE
,
382 .bytesperline
= 1024,
383 .sizeimage
= 1024 * 768,
384 .colorspace
= V4L2_COLORSPACE_SRGB
,
386 {1600, 1200, V4L2_PIX_FMT_SBGGR8
, V4L2_FIELD_NONE
,
387 .bytesperline
= 1600,
388 .sizeimage
= 1600 * 1200,
389 .colorspace
= V4L2_COLORSPACE_SRGB
,
391 {2048, 1536, V4L2_PIX_FMT_SBGGR8
, V4L2_FIELD_NONE
,
392 .bytesperline
= 2048,
393 .sizeimage
= 2048 * 1536,
394 .colorspace
= V4L2_COLORSPACE_SRGB
,
397 static const struct v4l2_pix_format ovfx2_ov9600_mode
[] = {
398 {640, 480, V4L2_PIX_FMT_SBGGR8
, V4L2_FIELD_NONE
,
400 .sizeimage
= 640 * 480,
401 .colorspace
= V4L2_COLORSPACE_SRGB
,
403 {1280, 1024, V4L2_PIX_FMT_SBGGR8
, V4L2_FIELD_NONE
,
404 .bytesperline
= 1280,
405 .sizeimage
= 1280 * 1024,
406 .colorspace
= V4L2_COLORSPACE_SRGB
},
409 /* Registers common to OV511 / OV518 */
410 #define R51x_FIFO_PSIZE 0x30 /* 2 bytes wide w/ OV518(+) */
411 #define R51x_SYS_RESET 0x50
412 /* Reset type flags */
413 #define OV511_RESET_OMNICE 0x08
414 #define R51x_SYS_INIT 0x53
415 #define R51x_SYS_SNAP 0x52
416 #define R51x_SYS_CUST_ID 0x5f
417 #define R51x_COMP_LUT_BEGIN 0x80
419 /* OV511 Camera interface register numbers */
420 #define R511_CAM_DELAY 0x10
421 #define R511_CAM_EDGE 0x11
422 #define R511_CAM_PXCNT 0x12
423 #define R511_CAM_LNCNT 0x13
424 #define R511_CAM_PXDIV 0x14
425 #define R511_CAM_LNDIV 0x15
426 #define R511_CAM_UV_EN 0x16
427 #define R511_CAM_LINE_MODE 0x17
428 #define R511_CAM_OPTS 0x18
430 #define R511_SNAP_FRAME 0x19
431 #define R511_SNAP_PXCNT 0x1a
432 #define R511_SNAP_LNCNT 0x1b
433 #define R511_SNAP_PXDIV 0x1c
434 #define R511_SNAP_LNDIV 0x1d
435 #define R511_SNAP_UV_EN 0x1e
436 #define R511_SNAP_OPTS 0x1f
438 #define R511_DRAM_FLOW_CTL 0x20
439 #define R511_FIFO_OPTS 0x31
440 #define R511_I2C_CTL 0x40
441 #define R511_SYS_LED_CTL 0x55 /* OV511+ only */
442 #define R511_COMP_EN 0x78
443 #define R511_COMP_LUT_EN 0x79
445 /* OV518 Camera interface register numbers */
446 #define R518_GPIO_OUT 0x56 /* OV518(+) only */
447 #define R518_GPIO_CTL 0x57 /* OV518(+) only */
449 /* OV519 Camera interface register numbers */
450 #define OV519_R10_H_SIZE 0x10
451 #define OV519_R11_V_SIZE 0x11
452 #define OV519_R12_X_OFFSETL 0x12
453 #define OV519_R13_X_OFFSETH 0x13
454 #define OV519_R14_Y_OFFSETL 0x14
455 #define OV519_R15_Y_OFFSETH 0x15
456 #define OV519_R16_DIVIDER 0x16
457 #define OV519_R20_DFR 0x20
458 #define OV519_R25_FORMAT 0x25
460 /* OV519 System Controller register numbers */
461 #define OV519_R51_RESET1 0x51
462 #define OV519_R54_EN_CLK1 0x54
463 #define OV519_R57_SNAPSHOT 0x57
465 #define OV519_GPIO_DATA_OUT0 0x71
466 #define OV519_GPIO_IO_CTRL0 0x72
468 /*#define OV511_ENDPOINT_ADDRESS 1 * Isoc endpoint number */
471 * The FX2 chip does not give us a zero length read at end of frame.
472 * It does, however, give a short read at the end of a frame, if
473 * necessary, rather than run two frames together.
475 * By choosing the right bulk transfer size, we are guaranteed to always
476 * get a short read for the last read of each frame. Frame sizes are
477 * always a composite number (width * height, or a multiple) so if we
478 * choose a prime number, we are guaranteed that the last read of a
479 * frame will be short.
481 * But it isn't that easy: the 2.6 kernel requires a multiple of 4KB,
482 * otherwise EOVERFLOW "babbling" errors occur. I have not been able
483 * to figure out why. [PMiller]
485 * The constant (13 * 4096) is the largest "prime enough" number less than 64KB.
487 * It isn't enough to know the number of bytes per frame, in case we
488 * have data dropouts or buffer overruns (even though the FX2 double
489 * buffers, there are some pretty strict real time constraints for
490 * isochronous transfer for larger frame sizes).
492 /*jfm: this value does not work for 800x600 - see isoc_init */
493 #define OVFX2_BULK_SIZE (13 * 4096)
496 #define R51x_I2C_W_SID 0x41
497 #define R51x_I2C_SADDR_3 0x42
498 #define R51x_I2C_SADDR_2 0x43
499 #define R51x_I2C_R_SID 0x44
500 #define R51x_I2C_DATA 0x45
501 #define R518_I2C_CTL 0x47 /* OV518(+) only */
502 #define OVFX2_I2C_ADDR 0x00
505 #define OV7xx0_SID 0x42
506 #define OV_HIRES_SID 0x60 /* OV9xxx / OV2xxx / OV3xxx */
507 #define OV8xx0_SID 0xa0
508 #define OV6xx0_SID 0xc0
510 /* OV7610 registers */
511 #define OV7610_REG_GAIN 0x00 /* gain setting (5:0) */
512 #define OV7610_REG_BLUE 0x01 /* blue channel balance */
513 #define OV7610_REG_RED 0x02 /* red channel balance */
514 #define OV7610_REG_SAT 0x03 /* saturation */
515 #define OV8610_REG_HUE 0x04 /* 04 reserved */
516 #define OV7610_REG_CNT 0x05 /* Y contrast */
517 #define OV7610_REG_BRT 0x06 /* Y brightness */
518 #define OV7610_REG_COM_C 0x14 /* misc common regs */
519 #define OV7610_REG_ID_HIGH 0x1c /* manufacturer ID MSB */
520 #define OV7610_REG_ID_LOW 0x1d /* manufacturer ID LSB */
521 #define OV7610_REG_COM_I 0x29 /* misc settings */
523 /* OV7660 and OV7670 registers */
524 #define OV7670_R00_GAIN 0x00 /* Gain lower 8 bits (rest in vref) */
525 #define OV7670_R01_BLUE 0x01 /* blue gain */
526 #define OV7670_R02_RED 0x02 /* red gain */
527 #define OV7670_R03_VREF 0x03 /* Pieces of GAIN, VSTART, VSTOP */
528 #define OV7670_R04_COM1 0x04 /* Control 1 */
529 /*#define OV7670_R07_AECHH 0x07 * AEC MS 5 bits */
530 #define OV7670_R0C_COM3 0x0c /* Control 3 */
531 #define OV7670_R0D_COM4 0x0d /* Control 4 */
532 #define OV7670_R0E_COM5 0x0e /* All "reserved" */
533 #define OV7670_R0F_COM6 0x0f /* Control 6 */
534 #define OV7670_R10_AECH 0x10 /* More bits of AEC value */
535 #define OV7670_R11_CLKRC 0x11 /* Clock control */
536 #define OV7670_R12_COM7 0x12 /* Control 7 */
537 #define OV7670_COM7_FMT_VGA 0x00
538 /*#define OV7670_COM7_YUV 0x00 * YUV */
539 #define OV7670_COM7_FMT_QVGA 0x10 /* QVGA format */
540 #define OV7670_COM7_FMT_MASK 0x38
541 #define OV7670_COM7_RESET 0x80 /* Register reset */
542 #define OV7670_R13_COM8 0x13 /* Control 8 */
543 #define OV7670_COM8_AEC 0x01 /* Auto exposure enable */
544 #define OV7670_COM8_AWB 0x02 /* White balance enable */
545 #define OV7670_COM8_AGC 0x04 /* Auto gain enable */
546 #define OV7670_COM8_BFILT 0x20 /* Band filter enable */
547 #define OV7670_COM8_AECSTEP 0x40 /* Unlimited AEC step size */
548 #define OV7670_COM8_FASTAEC 0x80 /* Enable fast AGC/AEC */
549 #define OV7670_R14_COM9 0x14 /* Control 9 - gain ceiling */
550 #define OV7670_R15_COM10 0x15 /* Control 10 */
551 #define OV7670_R17_HSTART 0x17 /* Horiz start high bits */
552 #define OV7670_R18_HSTOP 0x18 /* Horiz stop high bits */
553 #define OV7670_R19_VSTART 0x19 /* Vert start high bits */
554 #define OV7670_R1A_VSTOP 0x1a /* Vert stop high bits */
555 #define OV7670_R1E_MVFP 0x1e /* Mirror / vflip */
556 #define OV7670_MVFP_VFLIP 0x10 /* vertical flip */
557 #define OV7670_MVFP_MIRROR 0x20 /* Mirror image */
558 #define OV7670_R24_AEW 0x24 /* AGC upper limit */
559 #define OV7670_R25_AEB 0x25 /* AGC lower limit */
560 #define OV7670_R26_VPT 0x26 /* AGC/AEC fast mode op region */
561 #define OV7670_R32_HREF 0x32 /* HREF pieces */
562 #define OV7670_R3A_TSLB 0x3a /* lots of stuff */
563 #define OV7670_R3B_COM11 0x3b /* Control 11 */
564 #define OV7670_COM11_EXP 0x02
565 #define OV7670_COM11_HZAUTO 0x10 /* Auto detect 50/60 Hz */
566 #define OV7670_R3C_COM12 0x3c /* Control 12 */
567 #define OV7670_R3D_COM13 0x3d /* Control 13 */
568 #define OV7670_COM13_GAMMA 0x80 /* Gamma enable */
569 #define OV7670_COM13_UVSAT 0x40 /* UV saturation auto adjustment */
570 #define OV7670_R3E_COM14 0x3e /* Control 14 */
571 #define OV7670_R3F_EDGE 0x3f /* Edge enhancement factor */
572 #define OV7670_R40_COM15 0x40 /* Control 15 */
573 /*#define OV7670_COM15_R00FF 0xc0 * 00 to FF */
574 #define OV7670_R41_COM16 0x41 /* Control 16 */
575 #define OV7670_COM16_AWBGAIN 0x08 /* AWB gain enable */
576 /* end of ov7660 common registers */
577 #define OV7670_R55_BRIGHT 0x55 /* Brightness */
578 #define OV7670_R56_CONTRAS 0x56 /* Contrast control */
579 #define OV7670_R69_GFIX 0x69 /* Fix gain control */
580 /*#define OV7670_R8C_RGB444 0x8c * RGB 444 control */
581 #define OV7670_R9F_HAECC1 0x9f /* Hist AEC/AGC control 1 */
582 #define OV7670_RA0_HAECC2 0xa0 /* Hist AEC/AGC control 2 */
583 #define OV7670_RA5_BD50MAX 0xa5 /* 50hz banding step limit */
584 #define OV7670_RA6_HAECC3 0xa6 /* Hist AEC/AGC control 3 */
585 #define OV7670_RA7_HAECC4 0xa7 /* Hist AEC/AGC control 4 */
586 #define OV7670_RA8_HAECC5 0xa8 /* Hist AEC/AGC control 5 */
587 #define OV7670_RA9_HAECC6 0xa9 /* Hist AEC/AGC control 6 */
588 #define OV7670_RAA_HAECC7 0xaa /* Hist AEC/AGC control 7 */
589 #define OV7670_RAB_BD60MAX 0xab /* 60hz banding step limit */
595 struct ov_i2c_regvals
{
600 /* Settings for OV2610 camera chip */
601 static const struct ov_i2c_regvals norm_2610
[] = {
602 { 0x12, 0x80 }, /* reset */
605 static const struct ov_i2c_regvals norm_2610ae
[] = {
606 {0x12, 0x80}, /* reset */
611 {0x12, 0x20}, /* 1600x1200 */
616 {0x11, 0x83}, /* clock / 3 ? */
617 {0x2d, 0x00}, /* 60 Hz filter */
618 {0x24, 0xb0}, /* normal colors */
623 static const struct ov_i2c_regvals norm_3620b
[] = {
625 * From the datasheet: "Note that after writing to register COMH
626 * (0x12) to change the sensor mode, registers related to the
627 * sensor’s cropping window will be reset back to their default
630 * "wait 4096 external clock ... to make sure the sensor is
631 * stable and ready to access registers" i.e. 160us at 24MHz
633 { 0x12, 0x80 }, /* COMH reset */
634 { 0x12, 0x00 }, /* QXGA, master */
637 * 11 CLKRC "Clock Rate Control"
638 * [7] internal frequency doublers: on
639 * [6] video port mode: master
640 * [5:0] clock divider: 1
645 * 13 COMI "Common Control I"
646 * = 192 (0xC0) 11000000
647 * COMI[7] "AEC speed selection"
648 * = 1 (0x01) 1....... "Faster AEC correction"
649 * COMI[6] "AEC speed step selection"
650 * = 1 (0x01) .1...... "Big steps, fast"
651 * COMI[5] "Banding filter on off"
652 * = 0 (0x00) ..0..... "Off"
653 * COMI[4] "Banding filter option"
654 * = 0 (0x00) ...0.... "Main clock is 48 MHz and
657 * = 0 (0x00) ....0...
658 * COMI[2] "AGC auto manual control selection"
659 * = 0 (0x00) .....0.. "Manual"
660 * COMI[1] "AWB auto manual control selection"
661 * = 0 (0x00) ......0. "Manual"
662 * COMI[0] "Exposure control"
663 * = 0 (0x00) .......0 "Manual"
668 * 09 COMC "Common Control C"
669 * = 8 (0x08) 00001000
670 * COMC[7:5] "Reserved"
671 * = 0 (0x00) 000.....
672 * COMC[4] "Sleep Mode Enable"
673 * = 0 (0x00) ...0.... "Normal mode"
674 * COMC[3:2] "Sensor sampling reset timing selection"
675 * = 2 (0x02) ....10.. "Longer reset time"
676 * COMC[1:0] "Output drive current select"
677 * = 0 (0x00) ......00 "Weakest"
682 * 0C COMD "Common Control D"
683 * = 8 (0x08) 00001000
685 * = 0 (0x00) 0.......
686 * COMD[6] "Swap MSB and LSB at the output port"
687 * = 0 (0x00) .0...... "False"
688 * COMD[5:3] "Reserved"
689 * = 1 (0x01) ..001...
690 * COMD[2] "Output Average On Off"
691 * = 0 (0x00) .....0.. "Output Normal"
692 * COMD[1] "Sensor precharge voltage selection"
693 * = 0 (0x00) ......0. "Selects internal
694 * reference precharge
696 * COMD[0] "Snapshot option"
697 * = 0 (0x00) .......0 "Enable live video output
698 * after snapshot sequence"
703 * 0D COME "Common Control E"
704 * = 161 (0xA1) 10100001
705 * COME[7] "Output average option"
706 * = 1 (0x01) 1....... "Output average of 4 pixels"
707 * COME[6] "Anti-blooming control"
708 * = 0 (0x00) .0...... "Off"
709 * COME[5:3] "Reserved"
710 * = 4 (0x04) ..100...
711 * COME[2] "Clock output power down pin status"
712 * = 0 (0x00) .....0.. "Tri-state data output pin
714 * COME[1] "Data output pin status selection at power down"
715 * = 0 (0x00) ......0. "Tri-state VSYNC, PCLK,
716 * HREF, and CHSYNC pins on
718 * COME[0] "Auto zero circuit select"
719 * = 1 (0x01) .......1 "On"
724 * 0E COMF "Common Control F"
725 * = 112 (0x70) 01110000
726 * COMF[7] "System clock selection"
727 * = 0 (0x00) 0....... "Use 24 MHz system clock"
728 * COMF[6:4] "Reserved"
729 * = 7 (0x07) .111....
730 * COMF[3] "Manual auto negative offset canceling selection"
731 * = 0 (0x00) ....0... "Auto detect negative
732 * offset and cancel it"
733 * COMF[2:0] "Reserved"
734 * = 0 (0x00) .....000
739 * 0F COMG "Common Control G"
740 * = 66 (0x42) 01000010
741 * COMG[7] "Optical black output selection"
742 * = 0 (0x00) 0....... "Disable"
743 * COMG[6] "Black level calibrate selection"
744 * = 1 (0x01) .1...... "Use optical black pixels
746 * COMG[5:4] "Reserved"
747 * = 0 (0x00) ..00....
748 * COMG[3] "Channel offset adjustment"
749 * = 0 (0x00) ....0... "Disable offset adjustment"
750 * COMG[2] "ADC black level calibration option"
751 * = 0 (0x00) .....0.. "Use B/G line and G/R
752 * line to calibrate each
753 * channel's black level"
755 * = 1 (0x01) ......1.
756 * COMG[0] "ADC black level calibration enable"
757 * = 0 (0x00) .......0 "Disable"
762 * 14 COMJ "Common Control J"
763 * = 198 (0xC6) 11000110
764 * COMJ[7:6] "AGC gain ceiling"
765 * = 3 (0x03) 11...... "8x"
766 * COMJ[5:4] "Reserved"
767 * = 0 (0x00) ..00....
768 * COMJ[3] "Auto banding filter"
769 * = 0 (0x00) ....0... "Banding filter is always
770 * on off depending on
772 * COMJ[2] "VSYNC drop option"
773 * = 1 (0x01) .....1.. "SYNC is dropped if frame
775 * COMJ[1] "Frame data drop"
776 * = 1 (0x01) ......1. "Drop frame data if
777 * exposure is not within
778 * tolerance. In AEC mode,
779 * data is normally dropped
780 * when data is out of
783 * = 0 (0x00) .......0
788 * 15 COMK "Common Control K"
789 * = 2 (0x02) 00000010
790 * COMK[7] "CHSYNC pin output swap"
791 * = 0 (0x00) 0....... "CHSYNC"
792 * COMK[6] "HREF pin output swap"
793 * = 0 (0x00) .0...... "HREF"
794 * COMK[5] "PCLK output selection"
795 * = 0 (0x00) ..0..... "PCLK always output"
796 * COMK[4] "PCLK edge selection"
797 * = 0 (0x00) ...0.... "Data valid on falling edge"
798 * COMK[3] "HREF output polarity"
799 * = 0 (0x00) ....0... "positive"
801 * = 0 (0x00) .....0..
802 * COMK[1] "VSYNC polarity"
803 * = 1 (0x01) ......1. "negative"
804 * COMK[0] "HSYNC polarity"
805 * = 0 (0x00) .......0 "positive"
810 * 33 CHLF "Current Control"
811 * = 9 (0x09) 00001001
812 * CHLF[7:6] "Sensor current control"
813 * = 0 (0x00) 00......
814 * CHLF[5] "Sensor current range control"
815 * = 0 (0x00) ..0..... "normal range"
816 * CHLF[4] "Sensor current"
817 * = 0 (0x00) ...0.... "normal current"
818 * CHLF[3] "Sensor buffer current control"
819 * = 1 (0x01) ....1... "half current"
820 * CHLF[2] "Column buffer current control"
821 * = 0 (0x00) .....0.. "normal current"
822 * CHLF[1] "Analog DSP current control"
823 * = 0 (0x00) ......0. "normal current"
824 * CHLF[1] "ADC current control"
825 * = 0 (0x00) ......0. "normal current"
830 * 34 VBLM "Blooming Control"
831 * = 80 (0x50) 01010000
832 * VBLM[7] "Hard soft reset switch"
833 * = 0 (0x00) 0....... "Hard reset"
834 * VBLM[6:4] "Blooming voltage selection"
835 * = 5 (0x05) .101....
836 * VBLM[3:0] "Sensor current control"
837 * = 0 (0x00) ....0000
842 * 36 VCHG "Sensor Precharge Voltage Control"
843 * = 0 (0x00) 00000000
845 * = 0 (0x00) 0.......
846 * VCHG[6:4] "Sensor precharge voltage control"
847 * = 0 (0x00) .000....
848 * VCHG[3:0] "Sensor array common reference"
849 * = 0 (0x00) ....0000
854 * 37 ADC "ADC Reference Control"
855 * = 4 (0x04) 00000100
856 * ADC[7:4] "Reserved"
857 * = 0 (0x00) 0000....
858 * ADC[3] "ADC input signal range"
859 * = 0 (0x00) ....0... "Input signal 1.0x"
860 * ADC[2:0] "ADC range control"
861 * = 4 (0x04) .....100
866 * 38 ACOM "Analog Common Ground"
867 * = 82 (0x52) 01010010
868 * ACOM[7] "Analog gain control"
869 * = 0 (0x00) 0....... "Gain 1x"
870 * ACOM[6] "Analog black level calibration"
871 * = 1 (0x01) .1...... "On"
872 * ACOM[5:0] "Reserved"
873 * = 18 (0x12) ..010010
878 * 3A FREFA "Internal Reference Adjustment"
879 * = 0 (0x00) 00000000
881 * = 0 (0x00) 00000000
886 * 3C FVOPT "Internal Reference Adjustment"
887 * = 31 (0x1F) 00011111
889 * = 31 (0x1F) 00011111
894 * 44 Undocumented = 0 (0x00) 00000000
895 * 44[7:0] "It's a secret"
896 * = 0 (0x00) 00000000
901 * 40 Undocumented = 0 (0x00) 00000000
902 * 40[7:0] "It's a secret"
903 * = 0 (0x00) 00000000
908 * 41 Undocumented = 0 (0x00) 00000000
909 * 41[7:0] "It's a secret"
910 * = 0 (0x00) 00000000
915 * 42 Undocumented = 0 (0x00) 00000000
916 * 42[7:0] "It's a secret"
917 * = 0 (0x00) 00000000
922 * 43 Undocumented = 0 (0x00) 00000000
923 * 43[7:0] "It's a secret"
924 * = 0 (0x00) 00000000
929 * 45 Undocumented = 128 (0x80) 10000000
930 * 45[7:0] "It's a secret"
931 * = 128 (0x80) 10000000
936 * 48 Undocumented = 192 (0xC0) 11000000
937 * 48[7:0] "It's a secret"
938 * = 192 (0xC0) 11000000
943 * 49 Undocumented = 25 (0x19) 00011001
944 * 49[7:0] "It's a secret"
945 * = 25 (0x19) 00011001
950 * 4B Undocumented = 128 (0x80) 10000000
951 * 4B[7:0] "It's a secret"
952 * = 128 (0x80) 10000000
957 * 4D Undocumented = 196 (0xC4) 11000100
958 * 4D[7:0] "It's a secret"
959 * = 196 (0xC4) 11000100
964 * 35 VREF "Reference Voltage Control"
965 * = 76 (0x4c) 01001100
966 * VREF[7:5] "Column high reference control"
967 * = 2 (0x02) 010..... "higher voltage"
968 * VREF[4:2] "Column low reference control"
969 * = 3 (0x03) ...011.. "Highest voltage"
970 * VREF[1:0] "Reserved"
971 * = 0 (0x00) ......00
976 * 3D Undocumented = 0 (0x00) 00000000
977 * 3D[7:0] "It's a secret"
978 * = 0 (0x00) 00000000
983 * 3E Undocumented = 0 (0x00) 00000000
984 * 3E[7:0] "It's a secret"
985 * = 0 (0x00) 00000000
990 * 3B FREFB "Internal Reference Adjustment"
991 * = 24 (0x18) 00011000
993 * = 24 (0x18) 00011000
998 * 33 CHLF "Current Control"
999 * = 25 (0x19) 00011001
1000 * CHLF[7:6] "Sensor current control"
1001 * = 0 (0x00) 00......
1002 * CHLF[5] "Sensor current range control"
1003 * = 0 (0x00) ..0..... "normal range"
1004 * CHLF[4] "Sensor current"
1005 * = 1 (0x01) ...1.... "double current"
1006 * CHLF[3] "Sensor buffer current control"
1007 * = 1 (0x01) ....1... "half current"
1008 * CHLF[2] "Column buffer current control"
1009 * = 0 (0x00) .....0.. "normal current"
1010 * CHLF[1] "Analog DSP current control"
1011 * = 0 (0x00) ......0. "normal current"
1012 * CHLF[1] "ADC current control"
1013 * = 0 (0x00) ......0. "normal current"
1018 * 34 VBLM "Blooming Control"
1019 * = 90 (0x5A) 01011010
1020 * VBLM[7] "Hard soft reset switch"
1021 * = 0 (0x00) 0....... "Hard reset"
1022 * VBLM[6:4] "Blooming voltage selection"
1023 * = 5 (0x05) .101....
1024 * VBLM[3:0] "Sensor current control"
1025 * = 10 (0x0A) ....1010
1030 * 3B FREFB "Internal Reference Adjustment"
1031 * = 0 (0x00) 00000000
1032 * FREFB[7:0] "Range"
1033 * = 0 (0x00) 00000000
1038 * 33 CHLF "Current Control"
1039 * = 9 (0x09) 00001001
1040 * CHLF[7:6] "Sensor current control"
1041 * = 0 (0x00) 00......
1042 * CHLF[5] "Sensor current range control"
1043 * = 0 (0x00) ..0..... "normal range"
1044 * CHLF[4] "Sensor current"
1045 * = 0 (0x00) ...0.... "normal current"
1046 * CHLF[3] "Sensor buffer current control"
1047 * = 1 (0x01) ....1... "half current"
1048 * CHLF[2] "Column buffer current control"
1049 * = 0 (0x00) .....0.. "normal current"
1050 * CHLF[1] "Analog DSP current control"
1051 * = 0 (0x00) ......0. "normal current"
1052 * CHLF[1] "ADC current control"
1053 * = 0 (0x00) ......0. "normal current"
1058 * 34 VBLM "Blooming Control"
1059 * = 80 (0x50) 01010000
1060 * VBLM[7] "Hard soft reset switch"
1061 * = 0 (0x00) 0....... "Hard reset"
1062 * VBLM[6:4] "Blooming voltage selection"
1063 * = 5 (0x05) .101....
1064 * VBLM[3:0] "Sensor current control"
1065 * = 0 (0x00) ....0000
1070 * 12 COMH "Common Control H"
1071 * = 64 (0x40) 01000000
1073 * = 0 (0x00) 0....... "No-op"
1074 * COMH[6:4] "Resolution selection"
1075 * = 4 (0x04) .100.... "XGA"
1076 * COMH[3] "Master slave selection"
1077 * = 0 (0x00) ....0... "Master mode"
1078 * COMH[2] "Internal B/R channel option"
1079 * = 0 (0x00) .....0.. "B/R use same channel"
1080 * COMH[1] "Color bar test pattern"
1081 * = 0 (0x00) ......0. "Off"
1082 * COMH[0] "Reserved"
1083 * = 0 (0x00) .......0
1088 * 17 HREFST "Horizontal window start"
1089 * = 31 (0x1F) 00011111
1090 * HREFST[7:0] "Horizontal window start, 8 MSBs"
1091 * = 31 (0x1F) 00011111
1096 * 18 HREFEND "Horizontal window end"
1097 * = 95 (0x5F) 01011111
1098 * HREFEND[7:0] "Horizontal Window End, 8 MSBs"
1099 * = 95 (0x5F) 01011111
1104 * 19 VSTRT "Vertical window start"
1105 * = 0 (0x00) 00000000
1106 * VSTRT[7:0] "Vertical Window Start, 8 MSBs"
1107 * = 0 (0x00) 00000000
1112 * 1A VEND "Vertical window end"
1113 * = 96 (0x60) 01100000
1114 * VEND[7:0] "Vertical Window End, 8 MSBs"
1115 * = 96 (0x60) 01100000
1120 * 32 COMM "Common Control M"
1121 * = 18 (0x12) 00010010
1122 * COMM[7:6] "Pixel clock divide option"
1123 * = 0 (0x00) 00...... "/1"
1124 * COMM[5:3] "Horizontal window end position, 3 LSBs"
1125 * = 2 (0x02) ..010...
1126 * COMM[2:0] "Horizontal window start position, 3 LSBs"
1127 * = 2 (0x02) .....010
1132 * 03 COMA "Common Control A"
1133 * = 74 (0x4A) 01001010
1134 * COMA[7:4] "AWB Update Threshold"
1135 * = 4 (0x04) 0100....
1136 * COMA[3:2] "Vertical window end line control 2 LSBs"
1137 * = 2 (0x02) ....10..
1138 * COMA[1:0] "Vertical window start line control 2 LSBs"
1139 * = 2 (0x02) ......10
1144 * 11 CLKRC "Clock Rate Control"
1145 * = 128 (0x80) 10000000
1146 * CLKRC[7] "Internal frequency doublers on off seclection"
1147 * = 1 (0x01) 1....... "On"
1148 * CLKRC[6] "Digital video master slave selection"
1149 * = 0 (0x00) .0...... "Master mode, sensor
1151 * CLKRC[5:0] "Clock divider { CLK = PCLK/(1+CLKRC[5:0]) }"
1152 * = 0 (0x00) ..000000
1157 * 12 COMH "Common Control H"
1158 * = 0 (0x00) 00000000
1160 * = 0 (0x00) 0....... "No-op"
1161 * COMH[6:4] "Resolution selection"
1162 * = 0 (0x00) .000.... "QXGA"
1163 * COMH[3] "Master slave selection"
1164 * = 0 (0x00) ....0... "Master mode"
1165 * COMH[2] "Internal B/R channel option"
1166 * = 0 (0x00) .....0.. "B/R use same channel"
1167 * COMH[1] "Color bar test pattern"
1168 * = 0 (0x00) ......0. "Off"
1169 * COMH[0] "Reserved"
1170 * = 0 (0x00) .......0
1175 * 12 COMH "Common Control H"
1176 * = 64 (0x40) 01000000
1178 * = 0 (0x00) 0....... "No-op"
1179 * COMH[6:4] "Resolution selection"
1180 * = 4 (0x04) .100.... "XGA"
1181 * COMH[3] "Master slave selection"
1182 * = 0 (0x00) ....0... "Master mode"
1183 * COMH[2] "Internal B/R channel option"
1184 * = 0 (0x00) .....0.. "B/R use same channel"
1185 * COMH[1] "Color bar test pattern"
1186 * = 0 (0x00) ......0. "Off"
1187 * COMH[0] "Reserved"
1188 * = 0 (0x00) .......0
1193 * 17 HREFST "Horizontal window start"
1194 * = 31 (0x1F) 00011111
1195 * HREFST[7:0] "Horizontal window start, 8 MSBs"
1196 * = 31 (0x1F) 00011111
1201 * 18 HREFEND "Horizontal window end"
1202 * = 95 (0x5F) 01011111
1203 * HREFEND[7:0] "Horizontal Window End, 8 MSBs"
1204 * = 95 (0x5F) 01011111
1209 * 19 VSTRT "Vertical window start"
1210 * = 0 (0x00) 00000000
1211 * VSTRT[7:0] "Vertical Window Start, 8 MSBs"
1212 * = 0 (0x00) 00000000
1217 * 1A VEND "Vertical window end"
1218 * = 96 (0x60) 01100000
1219 * VEND[7:0] "Vertical Window End, 8 MSBs"
1220 * = 96 (0x60) 01100000
1225 * 32 COMM "Common Control M"
1226 * = 18 (0x12) 00010010
1227 * COMM[7:6] "Pixel clock divide option"
1228 * = 0 (0x00) 00...... "/1"
1229 * COMM[5:3] "Horizontal window end position, 3 LSBs"
1230 * = 2 (0x02) ..010...
1231 * COMM[2:0] "Horizontal window start position, 3 LSBs"
1232 * = 2 (0x02) .....010
1237 * 03 COMA "Common Control A"
1238 * = 74 (0x4A) 01001010
1239 * COMA[7:4] "AWB Update Threshold"
1240 * = 4 (0x04) 0100....
1241 * COMA[3:2] "Vertical window end line control 2 LSBs"
1242 * = 2 (0x02) ....10..
1243 * COMA[1:0] "Vertical window start line control 2 LSBs"
1244 * = 2 (0x02) ......10
1249 * 02 RED "Red Gain Control"
1250 * = 175 (0xAF) 10101111
1252 * = 1 (0x01) 1....... "gain = 1/(1+bitrev([6:0]))"
1254 * = 47 (0x2F) .0101111
1259 * 2D ADDVSL "VSYNC Pulse Width"
1260 * = 210 (0xD2) 11010010
1261 * ADDVSL[7:0] "VSYNC pulse width, LSB"
1262 * = 210 (0xD2) 11010010
1267 * 00 GAIN = 24 (0x18) 00011000
1268 * GAIN[7:6] "Reserved"
1269 * = 0 (0x00) 00......
1271 * = 0 (0x00) ..0..... "False"
1273 * = 1 (0x01) ...1.... "True"
1275 * = 8 (0x08) ....1000
1280 * 01 BLUE "Blue Gain Control"
1281 * = 240 (0xF0) 11110000
1283 * = 1 (0x01) 1....... "gain = 1/(1+bitrev([6:0]))"
1285 * = 112 (0x70) .1110000
1290 * 10 AEC "Automatic Exposure Control"
1291 * = 10 (0x0A) 00001010
1292 * AEC[7:0] "Automatic Exposure Control, 8 MSBs"
1293 * = 10 (0x0A) 00001010
1305 static const struct ov_i2c_regvals norm_6x20
[] = {
1306 { 0x12, 0x80 }, /* reset */
1309 { 0x05, 0x7f }, /* For when autoadjust is off */
1311 /* The ratio of 0x0c and 0x0d controls the white point */
1314 { 0x0f, 0x15 }, /* COMS */
1315 { 0x10, 0x75 }, /* AEC Exposure time */
1316 { 0x12, 0x24 }, /* Enable AGC */
1318 /* 0x16: 0x06 helps frame stability with moving objects */
1320 /* { 0x20, 0x30 }, * Aperture correction enable */
1321 { 0x26, 0xb2 }, /* BLC enable */
1322 /* 0x28: 0x05 Selects RGB format if RGB on */
1324 { 0x2a, 0x04 }, /* Disable framerate adjust */
1325 /* { 0x2b, 0xac }, * Framerate; Set 2a[7] first */
1327 { 0x33, 0xa0 }, /* Color Processing Parameter */
1328 { 0x34, 0xd2 }, /* Max A/D range */
1332 { 0x3c, 0x39 }, /* Enable AEC mode changing */
1333 { 0x3c, 0x3c }, /* Change AEC mode */
1334 { 0x3c, 0x24 }, /* Disable AEC mode changing */
1337 /* These next two registers (0x4a, 0x4b) are undocumented.
1338 * They control the color balance */
1341 { 0x4d, 0xd2 }, /* This reduces noise a bit */
1344 /* Do 50-53 have any effect? */
1345 /* Toggle 0x12[2] off and on here? */
1348 static const struct ov_i2c_regvals norm_6x30
[] = {
1349 { 0x12, 0x80 }, /* Reset */
1350 { 0x00, 0x1f }, /* Gain */
1351 { 0x01, 0x99 }, /* Blue gain */
1352 { 0x02, 0x7c }, /* Red gain */
1353 { 0x03, 0xc0 }, /* Saturation */
1354 { 0x05, 0x0a }, /* Contrast */
1355 { 0x06, 0x95 }, /* Brightness */
1356 { 0x07, 0x2d }, /* Sharpness */
1359 { 0x0e, 0xa0 }, /* Was 0x20, bit7 enables a 2x gain which we need */
1362 { 0x11, 0x00 }, /* Pixel clock = fastest */
1363 { 0x12, 0x24 }, /* Enable AGC and AWB */
1378 { 0x23, 0xc0 }, /* Crystal circuit power level */
1379 { 0x25, 0x9a }, /* Increase AEC black ratio */
1380 { 0x26, 0xb2 }, /* BLC enable */
1384 { 0x2a, 0x84 }, /* 60 Hz power */
1385 { 0x2b, 0xa8 }, /* 60 Hz power */
1387 { 0x2d, 0x95 }, /* Enable auto-brightness */
1401 { 0x40, 0x00 }, /* White bal */
1402 { 0x41, 0x00 }, /* White bal */
1404 { 0x43, 0x3f }, /* White bal */
1414 { 0x4d, 0x10 }, /* U = 0.563u, V = 0.714v */
1416 { 0x4f, 0x07 }, /* UV avg., col. killer: max */
1418 { 0x54, 0x23 }, /* Max AGC gain: 18dB */
1423 { 0x59, 0x01 }, /* AGC dark current comp.: +1 */
1425 { 0x5b, 0x0f }, /* AWB chrominance levels */
1429 { 0x12, 0x20 }, /* Toggle AWB */
1433 /* Lawrence Glaister <lg@jfm.bc.ca> reports:
1435 * Register 0x0f in the 7610 has the following effects:
1437 * 0x85 (AEC method 1): Best overall, good contrast range
1438 * 0x45 (AEC method 2): Very overexposed
1439 * 0xa5 (spec sheet default): Ok, but the black level is
1440 * shifted resulting in loss of contrast
1441 * 0x05 (old driver setting): very overexposed, too much
1444 static const struct ov_i2c_regvals norm_7610
[] = {
1451 { 0x28, 0x24 }, /* 0c */
1452 { 0x0f, 0x85 }, /* lg's setting */
1474 static const struct ov_i2c_regvals norm_7620
[] = {
1475 { 0x12, 0x80 }, /* reset */
1476 { 0x00, 0x00 }, /* gain */
1477 { 0x01, 0x80 }, /* blue gain */
1478 { 0x02, 0x80 }, /* red gain */
1479 { 0x03, 0xc0 }, /* OV7670_R03_VREF */
1502 { 0x28, 0x22 }, /* Was 0x20, bit1 enables a 2x gain which we need */
1541 /* 7640 and 7648. The defaults should be OK for most registers. */
1542 static const struct ov_i2c_regvals norm_7640
[] = {
1547 static const struct ov_regvals init_519_ov7660
[] = {
1548 { 0x5d, 0x03 }, /* Turn off suspend mode */
1549 { 0x53, 0x9b }, /* 0x9f enables the (unused) microcontroller */
1550 { 0x54, 0x0f }, /* bit2 (jpeg enable) */
1551 { 0xa2, 0x20 }, /* a2-a5 are undocumented */
1555 { 0x37, 0x00 }, /* SetUsbInit */
1556 { 0x55, 0x02 }, /* 4.096 Mhz audio clock */
1557 /* Enable both fields, YUV Input, disable defect comp (why?) */
1558 { 0x20, 0x0c }, /* 0x0d does U <-> V swap */
1561 { 0x17, 0x50 }, /* undocumented */
1562 { 0x37, 0x00 }, /* undocumented */
1563 { 0x40, 0xff }, /* I2C timeout counter */
1564 { 0x46, 0x00 }, /* I2C clock prescaler */
1566 static const struct ov_i2c_regvals norm_7660
[] = {
1567 {OV7670_R12_COM7
, OV7670_COM7_RESET
},
1568 {OV7670_R11_CLKRC
, 0x81},
1569 {0x92, 0x00}, /* DM_LNL */
1570 {0x93, 0x00}, /* DM_LNH */
1571 {0x9d, 0x4c}, /* BD50ST */
1572 {0x9e, 0x3f}, /* BD60ST */
1573 {OV7670_R3B_COM11
, 0x02},
1574 {OV7670_R13_COM8
, 0xf5},
1575 {OV7670_R10_AECH
, 0x00},
1576 {OV7670_R00_GAIN
, 0x00},
1577 {OV7670_R01_BLUE
, 0x7c},
1578 {OV7670_R02_RED
, 0x9d},
1579 {OV7670_R12_COM7
, 0x00},
1580 {OV7670_R04_COM1
, 00},
1581 {OV7670_R18_HSTOP
, 0x01},
1582 {OV7670_R17_HSTART
, 0x13},
1583 {OV7670_R32_HREF
, 0x92},
1584 {OV7670_R19_VSTART
, 0x02},
1585 {OV7670_R1A_VSTOP
, 0x7a},
1586 {OV7670_R03_VREF
, 0x00},
1587 {OV7670_R0E_COM5
, 0x04},
1588 {OV7670_R0F_COM6
, 0x62},
1589 {OV7670_R15_COM10
, 0x00},
1590 {0x16, 0x02}, /* RSVD */
1591 {0x1b, 0x00}, /* PSHFT */
1592 {OV7670_R1E_MVFP
, 0x01},
1593 {0x29, 0x3c}, /* RSVD */
1594 {0x33, 0x00}, /* CHLF */
1595 {0x34, 0x07}, /* ARBLM */
1596 {0x35, 0x84}, /* RSVD */
1597 {0x36, 0x00}, /* RSVD */
1598 {0x37, 0x04}, /* ADC */
1599 {0x39, 0x43}, /* OFON */
1600 {OV7670_R3A_TSLB
, 0x00},
1601 {OV7670_R3C_COM12
, 0x6c},
1602 {OV7670_R3D_COM13
, 0x98},
1603 {OV7670_R3F_EDGE
, 0x23},
1604 {OV7670_R40_COM15
, 0xc1},
1605 {OV7670_R41_COM16
, 0x22},
1606 {0x6b, 0x0a}, /* DBLV */
1607 {0xa1, 0x08}, /* RSVD */
1608 {0x69, 0x80}, /* HV */
1609 {0x43, 0xf0}, /* RSVD.. */
1624 {0x9f, 0x9d}, /* RSVD */
1625 {0xa0, 0xa0}, /* DSPC2 */
1626 {0x4f, 0x60}, /* matrix */
1635 {0x58, 0x0d}, /* matrix sign */
1636 {0x8b, 0xcc}, /* RSVD */
1639 {0x6c, 0x40}, /* gamma curve */
1655 {0x7c, 0x04}, /* gamma curve */
1670 {OV7670_R14_COM9
, 0x1e},
1671 {OV7670_R24_AEW
, 0x80},
1672 {OV7670_R25_AEB
, 0x72},
1673 {OV7670_R26_VPT
, 0xb3},
1674 {0x62, 0x80}, /* LCC1 */
1675 {0x63, 0x80}, /* LCC2 */
1676 {0x64, 0x06}, /* LCC3 */
1677 {0x65, 0x00}, /* LCC4 */
1678 {0x66, 0x01}, /* LCC5 */
1679 {0x94, 0x0e}, /* RSVD.. */
1681 {OV7670_R13_COM8
, OV7670_COM8_FASTAEC
1682 | OV7670_COM8_AECSTEP
1690 static const struct ov_i2c_regvals norm_9600
[] = {
1707 /* 7670. Defaults taken from OmniVision provided data,
1708 * as provided by Jonathan Corbet of OLPC */
1709 static const struct ov_i2c_regvals norm_7670
[] = {
1710 { OV7670_R12_COM7
, OV7670_COM7_RESET
},
1711 { OV7670_R3A_TSLB
, 0x04 }, /* OV */
1712 { OV7670_R12_COM7
, OV7670_COM7_FMT_VGA
}, /* VGA */
1713 { OV7670_R11_CLKRC
, 0x01 },
1715 * Set the hardware window. These values from OV don't entirely
1716 * make sense - hstop is less than hstart. But they work...
1718 { OV7670_R17_HSTART
, 0x13 },
1719 { OV7670_R18_HSTOP
, 0x01 },
1720 { OV7670_R32_HREF
, 0xb6 },
1721 { OV7670_R19_VSTART
, 0x02 },
1722 { OV7670_R1A_VSTOP
, 0x7a },
1723 { OV7670_R03_VREF
, 0x0a },
1725 { OV7670_R0C_COM3
, 0x00 },
1726 { OV7670_R3E_COM14
, 0x00 },
1727 /* Mystery scaling numbers */
1733 /* { OV7670_R15_COM10, 0x0 }, */
1735 /* Gamma curve values */
1753 /* AGC and AEC parameters. Note we start by disabling those features,
1754 then turn them only after tweaking the values. */
1755 { OV7670_R13_COM8
, OV7670_COM8_FASTAEC
1756 | OV7670_COM8_AECSTEP
1757 | OV7670_COM8_BFILT
},
1758 { OV7670_R00_GAIN
, 0x00 },
1759 { OV7670_R10_AECH
, 0x00 },
1760 { OV7670_R0D_COM4
, 0x40 }, /* magic reserved bit */
1761 { OV7670_R14_COM9
, 0x18 }, /* 4x gain + magic rsvd bit */
1762 { OV7670_RA5_BD50MAX
, 0x05 },
1763 { OV7670_RAB_BD60MAX
, 0x07 },
1764 { OV7670_R24_AEW
, 0x95 },
1765 { OV7670_R25_AEB
, 0x33 },
1766 { OV7670_R26_VPT
, 0xe3 },
1767 { OV7670_R9F_HAECC1
, 0x78 },
1768 { OV7670_RA0_HAECC2
, 0x68 },
1769 { 0xa1, 0x03 }, /* magic */
1770 { OV7670_RA6_HAECC3
, 0xd8 },
1771 { OV7670_RA7_HAECC4
, 0xd8 },
1772 { OV7670_RA8_HAECC5
, 0xf0 },
1773 { OV7670_RA9_HAECC6
, 0x90 },
1774 { OV7670_RAA_HAECC7
, 0x94 },
1775 { OV7670_R13_COM8
, OV7670_COM8_FASTAEC
1776 | OV7670_COM8_AECSTEP
1779 | OV7670_COM8_AEC
},
1781 /* Almost all of these are magic "reserved" values. */
1782 { OV7670_R0E_COM5
, 0x61 },
1783 { OV7670_R0F_COM6
, 0x4b },
1785 { OV7670_R1E_MVFP
, 0x07 },
1794 { OV7670_R3C_COM12
, 0x78 },
1797 { OV7670_R69_GFIX
, 0x00 },
1813 /* More reserved magic, some of which tweaks white balance */
1829 { 0x6f, 0x9f }, /* "9e for advance AWB" */
1831 { OV7670_R01_BLUE
, 0x40 },
1832 { OV7670_R02_RED
, 0x60 },
1833 { OV7670_R13_COM8
, OV7670_COM8_FASTAEC
1834 | OV7670_COM8_AECSTEP
1838 | OV7670_COM8_AWB
},
1840 /* Matrix coefficients */
1849 { OV7670_R41_COM16
, OV7670_COM16_AWBGAIN
},
1850 { OV7670_R3F_EDGE
, 0x00 },
1855 { OV7670_R3D_COM13
, OV7670_COM13_GAMMA
1856 | OV7670_COM13_UVSAT
1860 { OV7670_R41_COM16
, 0x38 },
1864 { OV7670_R3B_COM11
, OV7670_COM11_EXP
|OV7670_COM11_HZAUTO
},
1877 /* Extra-weird stuff. Some sort of multiplexor register */
1903 static const struct ov_i2c_regvals norm_8610
[] = {
1910 { 0x05, 0x30 }, /* was 0x10, new from windrv 090403 */
1911 { 0x06, 0x70 }, /* was 0x80, new from windrv 090403 */
1920 { 0x15, 0x01 }, /* Lin and Win think different about UV order */
1922 { 0x17, 0x38 }, /* was 0x2f, new from windrv 090403 */
1923 { 0x18, 0xea }, /* was 0xcf, new from windrv 090403 */
1924 { 0x19, 0x02 }, /* was 0x06, new from windrv 090403 */
1927 { 0x20, 0xd0 }, /* was 0x90, new from windrv 090403 */
1928 { 0x23, 0xc0 }, /* was 0x00, new from windrv 090403 */
1929 { 0x24, 0x30 }, /* was 0x1d, new from windrv 090403 */
1930 { 0x25, 0x50 }, /* was 0x57, new from windrv 090403 */
1936 { 0x2b, 0xc8 }, /* was 0xcc, new from windrv 090403 */
1938 { 0x2d, 0x45 }, /* was 0xd5, new from windrv 090403 */
1940 { 0x2f, 0x14 }, /* was 0x01, new from windrv 090403 */
1942 { 0x4d, 0x30 }, /* was 0x10, new from windrv 090403 */
1943 { 0x60, 0x02 }, /* was 0x01, new from windrv 090403 */
1944 { 0x61, 0x00 }, /* was 0x09, new from windrv 090403 */
1945 { 0x62, 0x5f }, /* was 0xd7, new from windrv 090403 */
1947 { 0x64, 0x53 }, /* new windrv 090403 says 0x57,
1948 * maybe thats wrong */
1952 { 0x68, 0xc0 }, /* was 0xaf, new from windrv 090403 */
1956 { 0x6c, 0x99 }, /* was 0x80, old windrv says 0x00, but
1957 * deleting bit7 colors the first images red */
1958 { 0x6d, 0x11 }, /* was 0x00, new from windrv 090403 */
1959 { 0x6e, 0x11 }, /* was 0x00, new from windrv 090403 */
1965 { 0x74, 0x00 },/* 0x60? - was 0x00, new from windrv 090403 */
1967 { 0x76, 0x02 }, /* was 0x02, new from windrv 090403 */
1972 { 0x7b, 0x10 }, /* was 0x13, new from windrv 090403 */
1974 { 0x7d, 0x08 }, /* was 0x09, new from windrv 090403 */
1975 { 0x7e, 0x08 }, /* was 0xc0, new from windrv 090403 */
1982 { 0x85, 0x62 }, /* was 0x61, new from windrv 090403 */
1988 { 0x12, 0x25 }, /* was 0x24, new from windrv 090403 */
1991 static unsigned char ov7670_abs_to_sm(unsigned char v
)
1995 return (128 - v
) | 0x80;
1998 /* Write a OV519 register */
1999 static void reg_w(struct sd
*sd
, u16 index
, u16 value
)
2001 struct gspca_dev
*gspca_dev
= (struct gspca_dev
*)sd
;
2004 if (sd
->gspca_dev
.usb_err
< 0)
2007 /* Avoid things going to fast for the bridge with a xhci host */
2010 switch (sd
->bridge
) {
2012 case BRIDGE_OV511PLUS
:
2018 case BRIDGE_W9968CF
:
2019 gspca_dbg(gspca_dev
, D_USBO
, "SET %02x %04x %04x\n",
2021 ret
= usb_control_msg(sd
->gspca_dev
.dev
,
2022 usb_sndctrlpipe(sd
->gspca_dev
.dev
, 0),
2024 USB_DIR_OUT
| USB_TYPE_VENDOR
| USB_RECIP_DEVICE
,
2025 value
, index
, NULL
, 0, 500);
2031 gspca_dbg(gspca_dev
, D_USBO
, "SET %02x 0000 %04x %02x\n",
2033 sd
->gspca_dev
.usb_buf
[0] = value
;
2034 ret
= usb_control_msg(sd
->gspca_dev
.dev
,
2035 usb_sndctrlpipe(sd
->gspca_dev
.dev
, 0),
2037 USB_DIR_OUT
| USB_TYPE_VENDOR
| USB_RECIP_DEVICE
,
2039 sd
->gspca_dev
.usb_buf
, 1, 500);
2042 gspca_err(gspca_dev
, "reg_w %02x failed %d\n", index
, ret
);
2043 sd
->gspca_dev
.usb_err
= ret
;
2048 /* Read from a OV519 register, note not valid for the w9968cf!! */
2049 /* returns: negative is error, pos or zero is data */
2050 static int reg_r(struct sd
*sd
, u16 index
)
2052 struct gspca_dev
*gspca_dev
= (struct gspca_dev
*)sd
;
2056 if (sd
->gspca_dev
.usb_err
< 0)
2059 switch (sd
->bridge
) {
2061 case BRIDGE_OV511PLUS
:
2071 /* Avoid things going to fast for the bridge with a xhci host */
2073 ret
= usb_control_msg(sd
->gspca_dev
.dev
,
2074 usb_rcvctrlpipe(sd
->gspca_dev
.dev
, 0),
2076 USB_DIR_IN
| USB_TYPE_VENDOR
| USB_RECIP_DEVICE
,
2077 0, index
, sd
->gspca_dev
.usb_buf
, 1, 500);
2080 ret
= sd
->gspca_dev
.usb_buf
[0];
2081 gspca_dbg(gspca_dev
, D_USBI
, "GET %02x 0000 %04x %02x\n",
2084 gspca_err(gspca_dev
, "reg_r %02x failed %d\n", index
, ret
);
2085 sd
->gspca_dev
.usb_err
= ret
;
2087 * Make sure the result is zeroed to avoid uninitialized
2090 gspca_dev
->usb_buf
[0] = 0;
2096 /* Read 8 values from a OV519 register */
2097 static int reg_r8(struct sd
*sd
,
2100 struct gspca_dev
*gspca_dev
= (struct gspca_dev
*)sd
;
2103 if (sd
->gspca_dev
.usb_err
< 0)
2106 /* Avoid things going to fast for the bridge with a xhci host */
2108 ret
= usb_control_msg(sd
->gspca_dev
.dev
,
2109 usb_rcvctrlpipe(sd
->gspca_dev
.dev
, 0),
2111 USB_DIR_IN
| USB_TYPE_VENDOR
| USB_RECIP_DEVICE
,
2112 0, index
, sd
->gspca_dev
.usb_buf
, 8, 500);
2115 ret
= sd
->gspca_dev
.usb_buf
[0];
2117 gspca_err(gspca_dev
, "reg_r8 %02x failed %d\n", index
, ret
);
2118 sd
->gspca_dev
.usb_err
= ret
;
2120 * Make sure the buffer is zeroed to avoid uninitialized
2123 memset(gspca_dev
->usb_buf
, 0, 8);
2130 * Writes bits at positions specified by mask to an OV51x reg. Bits that are in
2131 * the same position as 1's in "mask" are cleared and set to "value". Bits
2132 * that are in the same position as 0's in "mask" are preserved, regardless
2133 * of their respective state in "value".
2135 static void reg_w_mask(struct sd
*sd
,
2144 value
&= mask
; /* Enforce mask on value */
2145 ret
= reg_r(sd
, index
);
2149 oldval
= ret
& ~mask
; /* Clear the masked bits */
2150 value
|= oldval
; /* Set the desired bits */
2152 reg_w(sd
, index
, value
);
2156 * Writes multiple (n) byte value to a single register. Only valid with certain
2157 * registers (0x30 and 0xc4 - 0xce).
2159 static void ov518_reg_w32(struct sd
*sd
, u16 index
, u32 value
, int n
)
2161 struct gspca_dev
*gspca_dev
= (struct gspca_dev
*)sd
;
2164 if (sd
->gspca_dev
.usb_err
< 0)
2167 *((__le32
*) sd
->gspca_dev
.usb_buf
) = __cpu_to_le32(value
);
2169 /* Avoid things going to fast for the bridge with a xhci host */
2171 ret
= usb_control_msg(sd
->gspca_dev
.dev
,
2172 usb_sndctrlpipe(sd
->gspca_dev
.dev
, 0),
2174 USB_DIR_OUT
| USB_TYPE_VENDOR
| USB_RECIP_DEVICE
,
2176 sd
->gspca_dev
.usb_buf
, n
, 500);
2178 gspca_err(gspca_dev
, "reg_w32 %02x failed %d\n", index
, ret
);
2179 sd
->gspca_dev
.usb_err
= ret
;
2183 static void ov511_i2c_w(struct sd
*sd
, u8 reg
, u8 value
)
2185 struct gspca_dev
*gspca_dev
= (struct gspca_dev
*)sd
;
2188 gspca_dbg(gspca_dev
, D_USBO
, "ov511_i2c_w %02x %02x\n", reg
, value
);
2190 /* Three byte write cycle */
2191 for (retries
= 6; ; ) {
2192 /* Select camera register */
2193 reg_w(sd
, R51x_I2C_SADDR_3
, reg
);
2195 /* Write "value" to I2C data port of OV511 */
2196 reg_w(sd
, R51x_I2C_DATA
, value
);
2198 /* Initiate 3-byte write cycle */
2199 reg_w(sd
, R511_I2C_CTL
, 0x01);
2202 rc
= reg_r(sd
, R511_I2C_CTL
);
2203 } while (rc
> 0 && ((rc
& 1) == 0)); /* Retry until idle */
2208 if ((rc
& 2) == 0) /* Ack? */
2210 if (--retries
< 0) {
2211 gspca_dbg(gspca_dev
, D_USBO
, "i2c write retries exhausted\n");
2217 static int ov511_i2c_r(struct sd
*sd
, u8 reg
)
2219 struct gspca_dev
*gspca_dev
= (struct gspca_dev
*)sd
;
2220 int rc
, value
, retries
;
2222 /* Two byte write cycle */
2223 for (retries
= 6; ; ) {
2224 /* Select camera register */
2225 reg_w(sd
, R51x_I2C_SADDR_2
, reg
);
2227 /* Initiate 2-byte write cycle */
2228 reg_w(sd
, R511_I2C_CTL
, 0x03);
2231 rc
= reg_r(sd
, R511_I2C_CTL
);
2232 } while (rc
> 0 && ((rc
& 1) == 0)); /* Retry until idle */
2237 if ((rc
& 2) == 0) /* Ack? */
2241 reg_w(sd
, R511_I2C_CTL
, 0x10);
2243 if (--retries
< 0) {
2244 gspca_dbg(gspca_dev
, D_USBI
, "i2c write retries exhausted\n");
2249 /* Two byte read cycle */
2250 for (retries
= 6; ; ) {
2251 /* Initiate 2-byte read cycle */
2252 reg_w(sd
, R511_I2C_CTL
, 0x05);
2255 rc
= reg_r(sd
, R511_I2C_CTL
);
2256 } while (rc
> 0 && ((rc
& 1) == 0)); /* Retry until idle */
2261 if ((rc
& 2) == 0) /* Ack? */
2265 reg_w(sd
, R511_I2C_CTL
, 0x10);
2267 if (--retries
< 0) {
2268 gspca_dbg(gspca_dev
, D_USBI
, "i2c read retries exhausted\n");
2273 value
= reg_r(sd
, R51x_I2C_DATA
);
2275 gspca_dbg(gspca_dev
, D_USBI
, "ov511_i2c_r %02x %02x\n", reg
, value
);
2277 /* This is needed to make i2c_w() work */
2278 reg_w(sd
, R511_I2C_CTL
, 0x05);
2284 * The OV518 I2C I/O procedure is different, hence, this function.
2285 * This is normally only called from i2c_w(). Note that this function
2286 * always succeeds regardless of whether the sensor is present and working.
2288 static void ov518_i2c_w(struct sd
*sd
,
2292 struct gspca_dev
*gspca_dev
= (struct gspca_dev
*)sd
;
2294 gspca_dbg(gspca_dev
, D_USBO
, "ov518_i2c_w %02x %02x\n", reg
, value
);
2296 /* Select camera register */
2297 reg_w(sd
, R51x_I2C_SADDR_3
, reg
);
2299 /* Write "value" to I2C data port of OV511 */
2300 reg_w(sd
, R51x_I2C_DATA
, value
);
2302 /* Initiate 3-byte write cycle */
2303 reg_w(sd
, R518_I2C_CTL
, 0x01);
2305 /* wait for write complete */
2307 reg_r8(sd
, R518_I2C_CTL
);
2311 * returns: negative is error, pos or zero is data
2313 * The OV518 I2C I/O procedure is different, hence, this function.
2314 * This is normally only called from i2c_r(). Note that this function
2315 * always succeeds regardless of whether the sensor is present and working.
2317 static int ov518_i2c_r(struct sd
*sd
, u8 reg
)
2319 struct gspca_dev
*gspca_dev
= (struct gspca_dev
*)sd
;
2322 /* Select camera register */
2323 reg_w(sd
, R51x_I2C_SADDR_2
, reg
);
2325 /* Initiate 2-byte write cycle */
2326 reg_w(sd
, R518_I2C_CTL
, 0x03);
2327 reg_r8(sd
, R518_I2C_CTL
);
2329 /* Initiate 2-byte read cycle */
2330 reg_w(sd
, R518_I2C_CTL
, 0x05);
2331 reg_r8(sd
, R518_I2C_CTL
);
2333 value
= reg_r(sd
, R51x_I2C_DATA
);
2334 gspca_dbg(gspca_dev
, D_USBI
, "ov518_i2c_r %02x %02x\n", reg
, value
);
2338 static void ovfx2_i2c_w(struct sd
*sd
, u8 reg
, u8 value
)
2340 struct gspca_dev
*gspca_dev
= (struct gspca_dev
*)sd
;
2343 if (sd
->gspca_dev
.usb_err
< 0)
2346 ret
= usb_control_msg(sd
->gspca_dev
.dev
,
2347 usb_sndctrlpipe(sd
->gspca_dev
.dev
, 0),
2349 USB_DIR_OUT
| USB_TYPE_VENDOR
| USB_RECIP_DEVICE
,
2350 (u16
) value
, (u16
) reg
, NULL
, 0, 500);
2353 gspca_err(gspca_dev
, "ovfx2_i2c_w %02x failed %d\n", reg
, ret
);
2354 sd
->gspca_dev
.usb_err
= ret
;
2357 gspca_dbg(gspca_dev
, D_USBO
, "ovfx2_i2c_w %02x %02x\n", reg
, value
);
2360 static int ovfx2_i2c_r(struct sd
*sd
, u8 reg
)
2362 struct gspca_dev
*gspca_dev
= (struct gspca_dev
*)sd
;
2365 if (sd
->gspca_dev
.usb_err
< 0)
2368 ret
= usb_control_msg(sd
->gspca_dev
.dev
,
2369 usb_rcvctrlpipe(sd
->gspca_dev
.dev
, 0),
2371 USB_DIR_IN
| USB_TYPE_VENDOR
| USB_RECIP_DEVICE
,
2372 0, (u16
) reg
, sd
->gspca_dev
.usb_buf
, 1, 500);
2375 ret
= sd
->gspca_dev
.usb_buf
[0];
2376 gspca_dbg(gspca_dev
, D_USBI
, "ovfx2_i2c_r %02x %02x\n",
2379 gspca_err(gspca_dev
, "ovfx2_i2c_r %02x failed %d\n", reg
, ret
);
2380 sd
->gspca_dev
.usb_err
= ret
;
2386 static void i2c_w(struct sd
*sd
, u8 reg
, u8 value
)
2388 if (sd
->sensor_reg_cache
[reg
] == value
)
2391 switch (sd
->bridge
) {
2393 case BRIDGE_OV511PLUS
:
2394 ov511_i2c_w(sd
, reg
, value
);
2397 case BRIDGE_OV518PLUS
:
2399 ov518_i2c_w(sd
, reg
, value
);
2402 ovfx2_i2c_w(sd
, reg
, value
);
2404 case BRIDGE_W9968CF
:
2405 w9968cf_i2c_w(sd
, reg
, value
);
2409 if (sd
->gspca_dev
.usb_err
>= 0) {
2410 /* Up on sensor reset empty the register cache */
2411 if (reg
== 0x12 && (value
& 0x80))
2412 memset(sd
->sensor_reg_cache
, -1,
2413 sizeof(sd
->sensor_reg_cache
));
2415 sd
->sensor_reg_cache
[reg
] = value
;
2419 static int i2c_r(struct sd
*sd
, u8 reg
)
2423 if (sd
->sensor_reg_cache
[reg
] != -1)
2424 return sd
->sensor_reg_cache
[reg
];
2426 switch (sd
->bridge
) {
2428 case BRIDGE_OV511PLUS
:
2429 ret
= ov511_i2c_r(sd
, reg
);
2432 case BRIDGE_OV518PLUS
:
2434 ret
= ov518_i2c_r(sd
, reg
);
2437 ret
= ovfx2_i2c_r(sd
, reg
);
2439 case BRIDGE_W9968CF
:
2440 ret
= w9968cf_i2c_r(sd
, reg
);
2445 sd
->sensor_reg_cache
[reg
] = ret
;
2450 /* Writes bits at positions specified by mask to an I2C reg. Bits that are in
2451 * the same position as 1's in "mask" are cleared and set to "value". Bits
2452 * that are in the same position as 0's in "mask" are preserved, regardless
2453 * of their respective state in "value".
2455 static void i2c_w_mask(struct sd
*sd
,
2463 value
&= mask
; /* Enforce mask on value */
2464 rc
= i2c_r(sd
, reg
);
2467 oldval
= rc
& ~mask
; /* Clear the masked bits */
2468 value
|= oldval
; /* Set the desired bits */
2469 i2c_w(sd
, reg
, value
);
2472 /* Temporarily stops OV511 from functioning. Must do this before changing
2473 * registers while the camera is streaming */
2474 static inline void ov51x_stop(struct sd
*sd
)
2476 struct gspca_dev
*gspca_dev
= (struct gspca_dev
*)sd
;
2478 gspca_dbg(gspca_dev
, D_STREAM
, "stopping\n");
2480 switch (sd
->bridge
) {
2482 case BRIDGE_OV511PLUS
:
2483 reg_w(sd
, R51x_SYS_RESET
, 0x3d);
2486 case BRIDGE_OV518PLUS
:
2487 reg_w_mask(sd
, R51x_SYS_RESET
, 0x3a, 0x3a);
2490 reg_w(sd
, OV519_R51_RESET1
, 0x0f);
2491 reg_w(sd
, OV519_R51_RESET1
, 0x00);
2492 reg_w(sd
, 0x22, 0x00); /* FRAR */
2495 reg_w_mask(sd
, 0x0f, 0x00, 0x02);
2497 case BRIDGE_W9968CF
:
2498 reg_w(sd
, 0x3c, 0x0a05); /* stop USB transfer */
2503 /* Restarts OV511 after ov511_stop() is called. Has no effect if it is not
2504 * actually stopped (for performance). */
2505 static inline void ov51x_restart(struct sd
*sd
)
2507 struct gspca_dev
*gspca_dev
= (struct gspca_dev
*)sd
;
2509 gspca_dbg(gspca_dev
, D_STREAM
, "restarting\n");
2514 /* Reinitialize the stream */
2515 switch (sd
->bridge
) {
2517 case BRIDGE_OV511PLUS
:
2518 reg_w(sd
, R51x_SYS_RESET
, 0x00);
2521 case BRIDGE_OV518PLUS
:
2522 reg_w(sd
, 0x2f, 0x80);
2523 reg_w(sd
, R51x_SYS_RESET
, 0x00);
2526 reg_w(sd
, OV519_R51_RESET1
, 0x0f);
2527 reg_w(sd
, OV519_R51_RESET1
, 0x00);
2528 reg_w(sd
, 0x22, 0x1d); /* FRAR */
2531 reg_w_mask(sd
, 0x0f, 0x02, 0x02);
2533 case BRIDGE_W9968CF
:
2534 reg_w(sd
, 0x3c, 0x8a05); /* USB FIFO enable */
2539 static void ov51x_set_slave_ids(struct sd
*sd
, u8 slave
);
2541 /* This does an initial reset of an OmniVision sensor and ensures that I2C
2542 * is synchronized. Returns <0 on failure.
2544 static int init_ov_sensor(struct sd
*sd
, u8 slave
)
2547 struct gspca_dev
*gspca_dev
= (struct gspca_dev
*)sd
;
2549 ov51x_set_slave_ids(sd
, slave
);
2551 /* Reset the sensor */
2552 i2c_w(sd
, 0x12, 0x80);
2554 /* Wait for it to initialize */
2557 for (i
= 0; i
< i2c_detect_tries
; i
++) {
2558 if (i2c_r(sd
, OV7610_REG_ID_HIGH
) == 0x7f &&
2559 i2c_r(sd
, OV7610_REG_ID_LOW
) == 0xa2) {
2560 gspca_dbg(gspca_dev
, D_PROBE
, "I2C synced in %d attempt(s)\n",
2565 /* Reset the sensor */
2566 i2c_w(sd
, 0x12, 0x80);
2568 /* Wait for it to initialize */
2571 /* Dummy read to sync I2C */
2572 if (i2c_r(sd
, 0x00) < 0)
2578 /* Set the read and write slave IDs. The "slave" argument is the write slave,
2579 * and the read slave will be set to (slave + 1).
2580 * This should not be called from outside the i2c I/O functions.
2581 * Sets I2C read and write slave IDs. Returns <0 for error
2583 static void ov51x_set_slave_ids(struct sd
*sd
,
2586 switch (sd
->bridge
) {
2588 reg_w(sd
, OVFX2_I2C_ADDR
, slave
);
2590 case BRIDGE_W9968CF
:
2591 sd
->sensor_addr
= slave
;
2595 reg_w(sd
, R51x_I2C_W_SID
, slave
);
2596 reg_w(sd
, R51x_I2C_R_SID
, slave
+ 1);
2599 static void write_regvals(struct sd
*sd
,
2600 const struct ov_regvals
*regvals
,
2604 reg_w(sd
, regvals
->reg
, regvals
->val
);
2609 static void write_i2c_regvals(struct sd
*sd
,
2610 const struct ov_i2c_regvals
*regvals
,
2614 i2c_w(sd
, regvals
->reg
, regvals
->val
);
2619 /****************************************************************************
2621 * OV511 and sensor configuration
2623 ***************************************************************************/
2625 /* This initializes the OV2x10 / OV3610 / OV3620 / OV9600 */
2626 static void ov_hires_configure(struct sd
*sd
)
2628 struct gspca_dev
*gspca_dev
= (struct gspca_dev
*)sd
;
2631 if (sd
->bridge
!= BRIDGE_OVFX2
) {
2632 gspca_err(gspca_dev
, "error hires sensors only supported with ovfx2\n");
2636 gspca_dbg(gspca_dev
, D_PROBE
, "starting ov hires configuration\n");
2638 /* Detect sensor (sub)type */
2639 high
= i2c_r(sd
, 0x0a);
2640 low
= i2c_r(sd
, 0x0b);
2641 /* info("%x, %x", high, low); */
2646 gspca_dbg(gspca_dev
, D_PROBE
, "Sensor is a OV2610\n");
2647 sd
->sensor
= SEN_OV2610
;
2650 gspca_dbg(gspca_dev
, D_PROBE
, "Sensor is a OV2610AE\n");
2651 sd
->sensor
= SEN_OV2610AE
;
2654 gspca_dbg(gspca_dev
, D_PROBE
, "Sensor is a OV9600\n");
2655 sd
->sensor
= SEN_OV9600
;
2660 if ((low
& 0x0f) == 0x00) {
2661 gspca_dbg(gspca_dev
, D_PROBE
, "Sensor is a OV3610\n");
2662 sd
->sensor
= SEN_OV3610
;
2667 gspca_err(gspca_dev
, "Error unknown sensor type: %02x%02x\n",
2671 /* This initializes the OV8110, OV8610 sensor. The OV8110 uses
2672 * the same register settings as the OV8610, since they are very similar.
2674 static void ov8xx0_configure(struct sd
*sd
)
2676 struct gspca_dev
*gspca_dev
= (struct gspca_dev
*)sd
;
2679 gspca_dbg(gspca_dev
, D_PROBE
, "starting ov8xx0 configuration\n");
2681 /* Detect sensor (sub)type */
2682 rc
= i2c_r(sd
, OV7610_REG_COM_I
);
2684 gspca_err(gspca_dev
, "Error detecting sensor type\n");
2688 sd
->sensor
= SEN_OV8610
;
2690 gspca_err(gspca_dev
, "Unknown image sensor version: %d\n",
2694 /* This initializes the OV7610, OV7620, or OV76BE sensor. The OV76BE uses
2695 * the same register settings as the OV7610, since they are very similar.
2697 static void ov7xx0_configure(struct sd
*sd
)
2699 struct gspca_dev
*gspca_dev
= (struct gspca_dev
*)sd
;
2702 gspca_dbg(gspca_dev
, D_PROBE
, "starting OV7xx0 configuration\n");
2704 /* Detect sensor (sub)type */
2705 rc
= i2c_r(sd
, OV7610_REG_COM_I
);
2708 * it appears to be wrongly detected as a 7610 by default */
2710 gspca_err(gspca_dev
, "Error detecting sensor type\n");
2713 if ((rc
& 3) == 3) {
2714 /* quick hack to make OV7670s work */
2715 high
= i2c_r(sd
, 0x0a);
2716 low
= i2c_r(sd
, 0x0b);
2717 /* info("%x, %x", high, low); */
2718 if (high
== 0x76 && (low
& 0xf0) == 0x70) {
2719 gspca_dbg(gspca_dev
, D_PROBE
, "Sensor is an OV76%02x\n",
2721 sd
->sensor
= SEN_OV7670
;
2723 gspca_dbg(gspca_dev
, D_PROBE
, "Sensor is an OV7610\n");
2724 sd
->sensor
= SEN_OV7610
;
2726 } else if ((rc
& 3) == 1) {
2727 /* I don't know what's different about the 76BE yet. */
2728 if (i2c_r(sd
, 0x15) & 1) {
2729 gspca_dbg(gspca_dev
, D_PROBE
, "Sensor is an OV7620AE\n");
2730 sd
->sensor
= SEN_OV7620AE
;
2732 gspca_dbg(gspca_dev
, D_PROBE
, "Sensor is an OV76BE\n");
2733 sd
->sensor
= SEN_OV76BE
;
2735 } else if ((rc
& 3) == 0) {
2736 /* try to read product id registers */
2737 high
= i2c_r(sd
, 0x0a);
2739 gspca_err(gspca_dev
, "Error detecting camera chip PID\n");
2742 low
= i2c_r(sd
, 0x0b);
2744 gspca_err(gspca_dev
, "Error detecting camera chip VER\n");
2750 gspca_err(gspca_dev
, "Sensor is an OV7630/OV7635\n");
2751 gspca_err(gspca_dev
, "7630 is not supported by this driver\n");
2754 gspca_dbg(gspca_dev
, D_PROBE
, "Sensor is an OV7645\n");
2755 sd
->sensor
= SEN_OV7640
; /* FIXME */
2758 gspca_dbg(gspca_dev
, D_PROBE
, "Sensor is an OV7645B\n");
2759 sd
->sensor
= SEN_OV7640
; /* FIXME */
2762 gspca_dbg(gspca_dev
, D_PROBE
, "Sensor is an OV7648\n");
2763 sd
->sensor
= SEN_OV7648
;
2766 gspca_dbg(gspca_dev
, D_PROBE
, "Sensor is a OV7660\n");
2767 sd
->sensor
= SEN_OV7660
;
2770 gspca_err(gspca_dev
, "Unknown sensor: 0x76%02x\n",
2775 gspca_dbg(gspca_dev
, D_PROBE
, "Sensor is an OV7620\n");
2776 sd
->sensor
= SEN_OV7620
;
2779 gspca_err(gspca_dev
, "Unknown image sensor version: %d\n",
2784 /* This initializes the OV6620, OV6630, OV6630AE, or OV6630AF sensor. */
2785 static void ov6xx0_configure(struct sd
*sd
)
2787 struct gspca_dev
*gspca_dev
= (struct gspca_dev
*)sd
;
2790 gspca_dbg(gspca_dev
, D_PROBE
, "starting OV6xx0 configuration\n");
2792 /* Detect sensor (sub)type */
2793 rc
= i2c_r(sd
, OV7610_REG_COM_I
);
2795 gspca_err(gspca_dev
, "Error detecting sensor type\n");
2799 /* Ugh. The first two bits are the version bits, but
2800 * the entire register value must be used. I guess OVT
2801 * underestimated how many variants they would make. */
2804 sd
->sensor
= SEN_OV6630
;
2805 pr_warn("WARNING: Sensor is an OV66308. Your camera may have been misdetected in previous driver versions.\n");
2808 sd
->sensor
= SEN_OV6620
;
2809 gspca_dbg(gspca_dev
, D_PROBE
, "Sensor is an OV6620\n");
2812 sd
->sensor
= SEN_OV6630
;
2813 gspca_dbg(gspca_dev
, D_PROBE
, "Sensor is an OV66308AE\n");
2816 sd
->sensor
= SEN_OV66308AF
;
2817 gspca_dbg(gspca_dev
, D_PROBE
, "Sensor is an OV66308AF\n");
2820 sd
->sensor
= SEN_OV6630
;
2821 pr_warn("WARNING: Sensor is an OV66307. Your camera may have been misdetected in previous driver versions.\n");
2824 gspca_err(gspca_dev
, "FATAL: Unknown sensor version: 0x%02x\n",
2829 /* Set sensor-specific vars */
2833 /* Turns on or off the LED. Only has an effect with OV511+/OV518(+)/OV519 */
2834 static void ov51x_led_control(struct sd
*sd
, int on
)
2839 switch (sd
->bridge
) {
2840 /* OV511 has no LED control */
2841 case BRIDGE_OV511PLUS
:
2842 reg_w(sd
, R511_SYS_LED_CTL
, on
);
2845 case BRIDGE_OV518PLUS
:
2846 reg_w_mask(sd
, R518_GPIO_OUT
, 0x02 * on
, 0x02);
2849 reg_w_mask(sd
, OV519_GPIO_DATA_OUT0
, on
, 1);
2854 static void sd_reset_snapshot(struct gspca_dev
*gspca_dev
)
2856 struct sd
*sd
= (struct sd
*) gspca_dev
;
2858 if (!sd
->snapshot_needs_reset
)
2861 /* Note it is important that we clear sd->snapshot_needs_reset,
2862 before actually clearing the snapshot state in the bridge
2863 otherwise we might race with the pkt_scan interrupt handler */
2864 sd
->snapshot_needs_reset
= 0;
2866 switch (sd
->bridge
) {
2868 case BRIDGE_OV511PLUS
:
2869 reg_w(sd
, R51x_SYS_SNAP
, 0x02);
2870 reg_w(sd
, R51x_SYS_SNAP
, 0x00);
2873 case BRIDGE_OV518PLUS
:
2874 reg_w(sd
, R51x_SYS_SNAP
, 0x02); /* Reset */
2875 reg_w(sd
, R51x_SYS_SNAP
, 0x01); /* Enable */
2878 reg_w(sd
, R51x_SYS_RESET
, 0x40);
2879 reg_w(sd
, R51x_SYS_RESET
, 0x00);
2884 static void ov51x_upload_quan_tables(struct sd
*sd
)
2886 static const unsigned char yQuanTable511
[] = {
2887 0, 1, 1, 2, 2, 3, 3, 4,
2888 1, 1, 1, 2, 2, 3, 4, 4,
2889 1, 1, 2, 2, 3, 4, 4, 4,
2890 2, 2, 2, 3, 4, 4, 4, 4,
2891 2, 2, 3, 4, 4, 5, 5, 5,
2892 3, 3, 4, 4, 5, 5, 5, 5,
2893 3, 4, 4, 4, 5, 5, 5, 5,
2894 4, 4, 4, 4, 5, 5, 5, 5
2897 static const unsigned char uvQuanTable511
[] = {
2898 0, 2, 2, 3, 4, 4, 4, 4,
2899 2, 2, 2, 4, 4, 4, 4, 4,
2900 2, 2, 3, 4, 4, 4, 4, 4,
2901 3, 4, 4, 4, 4, 4, 4, 4,
2902 4, 4, 4, 4, 4, 4, 4, 4,
2903 4, 4, 4, 4, 4, 4, 4, 4,
2904 4, 4, 4, 4, 4, 4, 4, 4,
2905 4, 4, 4, 4, 4, 4, 4, 4
2908 /* OV518 quantization tables are 8x4 (instead of 8x8) */
2909 static const unsigned char yQuanTable518
[] = {
2910 5, 4, 5, 6, 6, 7, 7, 7,
2911 5, 5, 5, 5, 6, 7, 7, 7,
2912 6, 6, 6, 6, 7, 7, 7, 8,
2913 7, 7, 6, 7, 7, 7, 8, 8
2915 static const unsigned char uvQuanTable518
[] = {
2916 6, 6, 6, 7, 7, 7, 7, 7,
2917 6, 6, 6, 7, 7, 7, 7, 7,
2918 6, 6, 6, 7, 7, 7, 7, 8,
2919 7, 7, 7, 7, 7, 7, 8, 8
2922 struct gspca_dev
*gspca_dev
= (struct gspca_dev
*)sd
;
2923 const unsigned char *pYTable
, *pUVTable
;
2924 unsigned char val0
, val1
;
2925 int i
, size
, reg
= R51x_COMP_LUT_BEGIN
;
2927 gspca_dbg(gspca_dev
, D_PROBE
, "Uploading quantization tables\n");
2929 if (sd
->bridge
== BRIDGE_OV511
|| sd
->bridge
== BRIDGE_OV511PLUS
) {
2930 pYTable
= yQuanTable511
;
2931 pUVTable
= uvQuanTable511
;
2934 pYTable
= yQuanTable518
;
2935 pUVTable
= uvQuanTable518
;
2939 for (i
= 0; i
< size
; i
++) {
2945 reg_w(sd
, reg
, val0
);
2952 reg_w(sd
, reg
+ size
, val0
);
2958 /* This initializes the OV511/OV511+ and the sensor */
2959 static void ov511_configure(struct gspca_dev
*gspca_dev
)
2961 struct sd
*sd
= (struct sd
*) gspca_dev
;
2963 /* For 511 and 511+ */
2964 static const struct ov_regvals init_511
[] = {
2965 { R51x_SYS_RESET
, 0x7f },
2966 { R51x_SYS_INIT
, 0x01 },
2967 { R51x_SYS_RESET
, 0x7f },
2968 { R51x_SYS_INIT
, 0x01 },
2969 { R51x_SYS_RESET
, 0x3f },
2970 { R51x_SYS_INIT
, 0x01 },
2971 { R51x_SYS_RESET
, 0x3d },
2974 static const struct ov_regvals norm_511
[] = {
2975 { R511_DRAM_FLOW_CTL
, 0x01 },
2976 { R51x_SYS_SNAP
, 0x00 },
2977 { R51x_SYS_SNAP
, 0x02 },
2978 { R51x_SYS_SNAP
, 0x00 },
2979 { R511_FIFO_OPTS
, 0x1f },
2980 { R511_COMP_EN
, 0x00 },
2981 { R511_COMP_LUT_EN
, 0x03 },
2984 static const struct ov_regvals norm_511_p
[] = {
2985 { R511_DRAM_FLOW_CTL
, 0xff },
2986 { R51x_SYS_SNAP
, 0x00 },
2987 { R51x_SYS_SNAP
, 0x02 },
2988 { R51x_SYS_SNAP
, 0x00 },
2989 { R511_FIFO_OPTS
, 0xff },
2990 { R511_COMP_EN
, 0x00 },
2991 { R511_COMP_LUT_EN
, 0x03 },
2994 static const struct ov_regvals compress_511
[] = {
3005 gspca_dbg(gspca_dev
, D_PROBE
, "Device custom id %x\n",
3006 reg_r(sd
, R51x_SYS_CUST_ID
));
3008 write_regvals(sd
, init_511
, ARRAY_SIZE(init_511
));
3010 switch (sd
->bridge
) {
3012 write_regvals(sd
, norm_511
, ARRAY_SIZE(norm_511
));
3014 case BRIDGE_OV511PLUS
:
3015 write_regvals(sd
, norm_511_p
, ARRAY_SIZE(norm_511_p
));
3019 /* Init compression */
3020 write_regvals(sd
, compress_511
, ARRAY_SIZE(compress_511
));
3022 ov51x_upload_quan_tables(sd
);
3025 /* This initializes the OV518/OV518+ and the sensor */
3026 static void ov518_configure(struct gspca_dev
*gspca_dev
)
3028 struct sd
*sd
= (struct sd
*) gspca_dev
;
3030 /* For 518 and 518+ */
3031 static const struct ov_regvals init_518
[] = {
3032 { R51x_SYS_RESET
, 0x40 },
3033 { R51x_SYS_INIT
, 0xe1 },
3034 { R51x_SYS_RESET
, 0x3e },
3035 { R51x_SYS_INIT
, 0xe1 },
3036 { R51x_SYS_RESET
, 0x00 },
3037 { R51x_SYS_INIT
, 0xe1 },
3042 static const struct ov_regvals norm_518
[] = {
3043 { R51x_SYS_SNAP
, 0x02 }, /* Reset */
3044 { R51x_SYS_SNAP
, 0x01 }, /* Enable */
3055 static const struct ov_regvals norm_518_p
[] = {
3056 { R51x_SYS_SNAP
, 0x02 }, /* Reset */
3057 { R51x_SYS_SNAP
, 0x01 }, /* Enable */
3074 /* First 5 bits of custom ID reg are a revision ID on OV518 */
3075 sd
->revision
= reg_r(sd
, R51x_SYS_CUST_ID
) & 0x1f;
3076 gspca_dbg(gspca_dev
, D_PROBE
, "Device revision %d\n", sd
->revision
);
3078 write_regvals(sd
, init_518
, ARRAY_SIZE(init_518
));
3080 /* Set LED GPIO pin to output mode */
3081 reg_w_mask(sd
, R518_GPIO_CTL
, 0x00, 0x02);
3083 switch (sd
->bridge
) {
3085 write_regvals(sd
, norm_518
, ARRAY_SIZE(norm_518
));
3087 case BRIDGE_OV518PLUS
:
3088 write_regvals(sd
, norm_518_p
, ARRAY_SIZE(norm_518_p
));
3092 ov51x_upload_quan_tables(sd
);
3094 reg_w(sd
, 0x2f, 0x80);
3097 static void ov519_configure(struct sd
*sd
)
3099 static const struct ov_regvals init_519
[] = {
3100 { 0x5a, 0x6d }, /* EnableSystem */
3101 { 0x53, 0x9b }, /* don't enable the microcontroller */
3102 { OV519_R54_EN_CLK1
, 0xff }, /* set bit2 to enable jpeg */
3106 /* Set LED pin to output mode. Bit 4 must be cleared or sensor
3107 * detection will fail. This deserves further investigation. */
3108 { OV519_GPIO_IO_CTRL0
, 0xee },
3109 { OV519_R51_RESET1
, 0x0f },
3110 { OV519_R51_RESET1
, 0x00 },
3112 /* windows reads 0x55 at this point*/
3115 write_regvals(sd
, init_519
, ARRAY_SIZE(init_519
));
3118 static void ovfx2_configure(struct sd
*sd
)
3120 static const struct ov_regvals init_fx2
[] = {
3132 write_regvals(sd
, init_fx2
, ARRAY_SIZE(init_fx2
));
3136 /* This function works for ov7660 only */
3137 static void ov519_set_mode(struct sd
*sd
)
3139 static const struct ov_regvals bridge_ov7660
[2][10] = {
3140 {{0x10, 0x14}, {0x11, 0x1e}, {0x12, 0x00}, {0x13, 0x00},
3141 {0x14, 0x00}, {0x15, 0x00}, {0x16, 0x00}, {0x20, 0x0c},
3142 {0x25, 0x01}, {0x26, 0x00}},
3143 {{0x10, 0x28}, {0x11, 0x3c}, {0x12, 0x00}, {0x13, 0x00},
3144 {0x14, 0x00}, {0x15, 0x00}, {0x16, 0x00}, {0x20, 0x0c},
3145 {0x25, 0x03}, {0x26, 0x00}}
3147 static const struct ov_i2c_regvals sensor_ov7660
[2][3] = {
3148 {{0x12, 0x00}, {0x24, 0x00}, {0x0c, 0x0c}},
3149 {{0x12, 0x00}, {0x04, 0x00}, {0x0c, 0x00}}
3151 static const struct ov_i2c_regvals sensor_ov7660_2
[] = {
3152 {OV7670_R17_HSTART
, 0x13},
3153 {OV7670_R18_HSTOP
, 0x01},
3154 {OV7670_R32_HREF
, 0x92},
3155 {OV7670_R19_VSTART
, 0x02},
3156 {OV7670_R1A_VSTOP
, 0x7a},
3157 {OV7670_R03_VREF
, 0x00},
3164 write_regvals(sd
, bridge_ov7660
[sd
->gspca_dev
.curr_mode
],
3165 ARRAY_SIZE(bridge_ov7660
[0]));
3166 write_i2c_regvals(sd
, sensor_ov7660
[sd
->gspca_dev
.curr_mode
],
3167 ARRAY_SIZE(sensor_ov7660
[0]));
3168 write_i2c_regvals(sd
, sensor_ov7660_2
,
3169 ARRAY_SIZE(sensor_ov7660_2
));
3172 /* set the frame rate */
3173 /* This function works for sensors ov7640, ov7648 ov7660 and ov7670 only */
3174 static void ov519_set_fr(struct sd
*sd
)
3178 /* frame rate table with indices:
3179 * - mode = 0: 320x240, 1: 640x480
3180 * - fr rate = 0: 30, 1: 25, 2: 20, 3: 15, 4: 10, 5: 5
3181 * - reg = 0: bridge a4, 1: bridge 23, 2: sensor 11 (clock)
3183 static const u8 fr_tb
[2][6][3] = {
3184 {{0x04, 0xff, 0x00},
3189 {0x04, 0x01, 0x00}},
3190 {{0x0c, 0xff, 0x00},
3195 {0x04, 0x1b, 0x01}},
3199 sd
->frame_rate
= frame_rate
;
3200 if (sd
->frame_rate
>= 30)
3202 else if (sd
->frame_rate
>= 25)
3204 else if (sd
->frame_rate
>= 20)
3206 else if (sd
->frame_rate
>= 15)
3208 else if (sd
->frame_rate
>= 10)
3212 reg_w(sd
, 0xa4, fr_tb
[sd
->gspca_dev
.curr_mode
][fr
][0]);
3213 reg_w(sd
, 0x23, fr_tb
[sd
->gspca_dev
.curr_mode
][fr
][1]);
3214 clock
= fr_tb
[sd
->gspca_dev
.curr_mode
][fr
][2];
3215 if (sd
->sensor
== SEN_OV7660
)
3216 clock
|= 0x80; /* enable double clock */
3217 ov518_i2c_w(sd
, OV7670_R11_CLKRC
, clock
);
3220 static void setautogain(struct gspca_dev
*gspca_dev
, s32 val
)
3222 struct sd
*sd
= (struct sd
*) gspca_dev
;
3224 i2c_w_mask(sd
, 0x13, val
? 0x05 : 0x00, 0x05);
3227 /* this function is called at probe time */
3228 static int sd_config(struct gspca_dev
*gspca_dev
,
3229 const struct usb_device_id
*id
)
3231 struct sd
*sd
= (struct sd
*) gspca_dev
;
3232 struct cam
*cam
= &gspca_dev
->cam
;
3234 sd
->bridge
= id
->driver_info
& BRIDGE_MASK
;
3235 sd
->invert_led
= (id
->driver_info
& BRIDGE_INVERT_LED
) != 0;
3237 switch (sd
->bridge
) {
3239 case BRIDGE_OV511PLUS
:
3240 cam
->cam_mode
= ov511_vga_mode
;
3241 cam
->nmodes
= ARRAY_SIZE(ov511_vga_mode
);
3244 case BRIDGE_OV518PLUS
:
3245 cam
->cam_mode
= ov518_vga_mode
;
3246 cam
->nmodes
= ARRAY_SIZE(ov518_vga_mode
);
3249 cam
->cam_mode
= ov519_vga_mode
;
3250 cam
->nmodes
= ARRAY_SIZE(ov519_vga_mode
);
3253 cam
->cam_mode
= ov519_vga_mode
;
3254 cam
->nmodes
= ARRAY_SIZE(ov519_vga_mode
);
3255 cam
->bulk_size
= OVFX2_BULK_SIZE
;
3256 cam
->bulk_nurbs
= MAX_NURBS
;
3259 case BRIDGE_W9968CF
:
3260 cam
->cam_mode
= w9968cf_vga_mode
;
3261 cam
->nmodes
= ARRAY_SIZE(w9968cf_vga_mode
);
3265 sd
->frame_rate
= 15;
3270 /* this function is called at probe and resume time */
3271 static int sd_init(struct gspca_dev
*gspca_dev
)
3273 struct sd
*sd
= (struct sd
*) gspca_dev
;
3274 struct cam
*cam
= &gspca_dev
->cam
;
3276 switch (sd
->bridge
) {
3278 case BRIDGE_OV511PLUS
:
3279 ov511_configure(gspca_dev
);
3282 case BRIDGE_OV518PLUS
:
3283 ov518_configure(gspca_dev
);
3286 ov519_configure(sd
);
3289 ovfx2_configure(sd
);
3291 case BRIDGE_W9968CF
:
3292 w9968cf_configure(sd
);
3296 /* The OV519 must be more aggressive about sensor detection since
3297 * I2C write will never fail if the sensor is not present. We have
3298 * to try to initialize the sensor to detect its presence */
3302 if (init_ov_sensor(sd
, OV7xx0_SID
) >= 0) {
3303 ov7xx0_configure(sd
);
3306 } else if (init_ov_sensor(sd
, OV6xx0_SID
) >= 0) {
3307 ov6xx0_configure(sd
);
3310 } else if (init_ov_sensor(sd
, OV8xx0_SID
) >= 0) {
3311 ov8xx0_configure(sd
);
3313 /* Test for 3xxx / 2xxx */
3314 } else if (init_ov_sensor(sd
, OV_HIRES_SID
) >= 0) {
3315 ov_hires_configure(sd
);
3317 gspca_err(gspca_dev
, "Can't determine sensor slave IDs\n");
3324 ov51x_led_control(sd
, 0); /* turn LED off */
3326 switch (sd
->bridge
) {
3328 case BRIDGE_OV511PLUS
:
3330 cam
->cam_mode
= ov511_sif_mode
;
3331 cam
->nmodes
= ARRAY_SIZE(ov511_sif_mode
);
3335 case BRIDGE_OV518PLUS
:
3337 cam
->cam_mode
= ov518_sif_mode
;
3338 cam
->nmodes
= ARRAY_SIZE(ov518_sif_mode
);
3343 cam
->cam_mode
= ov519_sif_mode
;
3344 cam
->nmodes
= ARRAY_SIZE(ov519_sif_mode
);
3348 switch (sd
->sensor
) {
3351 cam
->cam_mode
= ovfx2_ov2610_mode
;
3352 cam
->nmodes
= ARRAY_SIZE(ovfx2_ov2610_mode
);
3355 cam
->cam_mode
= ovfx2_ov3610_mode
;
3356 cam
->nmodes
= ARRAY_SIZE(ovfx2_ov3610_mode
);
3359 cam
->cam_mode
= ovfx2_ov9600_mode
;
3360 cam
->nmodes
= ARRAY_SIZE(ovfx2_ov9600_mode
);
3364 cam
->cam_mode
= ov519_sif_mode
;
3365 cam
->nmodes
= ARRAY_SIZE(ov519_sif_mode
);
3370 case BRIDGE_W9968CF
:
3372 cam
->nmodes
= ARRAY_SIZE(w9968cf_vga_mode
) - 1;
3374 /* w9968cf needs initialisation once the sensor is known */
3379 /* initialize the sensor */
3380 switch (sd
->sensor
) {
3382 write_i2c_regvals(sd
, norm_2610
, ARRAY_SIZE(norm_2610
));
3384 /* Enable autogain, autoexpo, awb, bandfilter */
3385 i2c_w_mask(sd
, 0x13, 0x27, 0x27);
3388 write_i2c_regvals(sd
, norm_2610ae
, ARRAY_SIZE(norm_2610ae
));
3390 /* enable autoexpo */
3391 i2c_w_mask(sd
, 0x13, 0x05, 0x05);
3394 write_i2c_regvals(sd
, norm_3620b
, ARRAY_SIZE(norm_3620b
));
3396 /* Enable autogain, autoexpo, awb, bandfilter */
3397 i2c_w_mask(sd
, 0x13, 0x27, 0x27);
3400 write_i2c_regvals(sd
, norm_6x20
, ARRAY_SIZE(norm_6x20
));
3404 write_i2c_regvals(sd
, norm_6x30
, ARRAY_SIZE(norm_6x30
));
3407 /* case SEN_OV7610: */
3408 /* case SEN_OV76BE: */
3409 write_i2c_regvals(sd
, norm_7610
, ARRAY_SIZE(norm_7610
));
3410 i2c_w_mask(sd
, 0x0e, 0x00, 0x40);
3414 write_i2c_regvals(sd
, norm_7620
, ARRAY_SIZE(norm_7620
));
3418 write_i2c_regvals(sd
, norm_7640
, ARRAY_SIZE(norm_7640
));
3421 i2c_w(sd
, OV7670_R12_COM7
, OV7670_COM7_RESET
);
3423 reg_w(sd
, OV519_R57_SNAPSHOT
, 0x23);
3424 write_regvals(sd
, init_519_ov7660
,
3425 ARRAY_SIZE(init_519_ov7660
));
3426 write_i2c_regvals(sd
, norm_7660
, ARRAY_SIZE(norm_7660
));
3427 sd
->gspca_dev
.curr_mode
= 1; /* 640x480 */
3430 sd_reset_snapshot(gspca_dev
);
3432 ov51x_stop(sd
); /* not in win traces */
3433 ov51x_led_control(sd
, 0);
3436 write_i2c_regvals(sd
, norm_7670
, ARRAY_SIZE(norm_7670
));
3439 write_i2c_regvals(sd
, norm_8610
, ARRAY_SIZE(norm_8610
));
3442 write_i2c_regvals(sd
, norm_9600
, ARRAY_SIZE(norm_9600
));
3444 /* enable autoexpo */
3445 /* i2c_w_mask(sd, 0x13, 0x05, 0x05); */
3448 return gspca_dev
->usb_err
;
3450 gspca_err(gspca_dev
, "OV519 Config failed\n");
3454 /* function called at start time before URB creation */
3455 static int sd_isoc_init(struct gspca_dev
*gspca_dev
)
3457 struct sd
*sd
= (struct sd
*) gspca_dev
;
3459 switch (sd
->bridge
) {
3461 if (gspca_dev
->pixfmt
.width
!= 800)
3462 gspca_dev
->cam
.bulk_size
= OVFX2_BULK_SIZE
;
3464 gspca_dev
->cam
.bulk_size
= 7 * 4096;
3470 /* Set up the OV511/OV511+ with the given image parameters.
3472 * Do not put any sensor-specific code in here (including I2C I/O functions)
3474 static void ov511_mode_init_regs(struct sd
*sd
)
3476 struct gspca_dev
*gspca_dev
= (struct gspca_dev
*)sd
;
3477 int hsegs
, vsegs
, packet_size
, fps
, needed
;
3479 struct usb_host_interface
*alt
;
3480 struct usb_interface
*intf
;
3482 intf
= usb_ifnum_to_if(sd
->gspca_dev
.dev
, sd
->gspca_dev
.iface
);
3483 alt
= usb_altnum_to_altsetting(intf
, sd
->gspca_dev
.alt
);
3485 gspca_err(gspca_dev
, "Couldn't get altsetting\n");
3486 sd
->gspca_dev
.usb_err
= -EIO
;
3490 if (alt
->desc
.bNumEndpoints
< 1) {
3491 sd
->gspca_dev
.usb_err
= -ENODEV
;
3495 packet_size
= le16_to_cpu(alt
->endpoint
[0].desc
.wMaxPacketSize
);
3496 reg_w(sd
, R51x_FIFO_PSIZE
, packet_size
>> 5);
3498 reg_w(sd
, R511_CAM_UV_EN
, 0x01);
3499 reg_w(sd
, R511_SNAP_UV_EN
, 0x01);
3500 reg_w(sd
, R511_SNAP_OPTS
, 0x03);
3502 /* Here I'm assuming that snapshot size == image size.
3503 * I hope that's always true. --claudio
3505 hsegs
= (sd
->gspca_dev
.pixfmt
.width
>> 3) - 1;
3506 vsegs
= (sd
->gspca_dev
.pixfmt
.height
>> 3) - 1;
3508 reg_w(sd
, R511_CAM_PXCNT
, hsegs
);
3509 reg_w(sd
, R511_CAM_LNCNT
, vsegs
);
3510 reg_w(sd
, R511_CAM_PXDIV
, 0x00);
3511 reg_w(sd
, R511_CAM_LNDIV
, 0x00);
3513 /* YUV420, low pass filter on */
3514 reg_w(sd
, R511_CAM_OPTS
, 0x03);
3516 /* Snapshot additions */
3517 reg_w(sd
, R511_SNAP_PXCNT
, hsegs
);
3518 reg_w(sd
, R511_SNAP_LNCNT
, vsegs
);
3519 reg_w(sd
, R511_SNAP_PXDIV
, 0x00);
3520 reg_w(sd
, R511_SNAP_LNDIV
, 0x00);
3522 /******** Set the framerate ********/
3524 sd
->frame_rate
= frame_rate
;
3526 switch (sd
->sensor
) {
3528 /* No framerate control, doesn't like higher rates yet */
3532 /* Note once the FIXME's in mode_init_ov_sensor_regs() are fixed
3533 for more sensors we need to do this for them too */
3539 if (sd
->gspca_dev
.pixfmt
.width
== 320)
3545 switch (sd
->frame_rate
) {
3548 /* Not enough bandwidth to do 640x480 @ 30 fps */
3549 if (sd
->gspca_dev
.pixfmt
.width
!= 640) {
3553 /* For 640x480 case */
3568 sd
->clockdiv
= (sd
->clockdiv
+ 1) * 2 - 1;
3569 /* Higher then 10 does not work */
3570 if (sd
->clockdiv
> 10)
3576 /* No framerate control ?? */
3581 /* Check if we have enough bandwidth to disable compression */
3582 fps
= (interlaced
? 60 : 30) / (sd
->clockdiv
+ 1) + 1;
3583 needed
= fps
* sd
->gspca_dev
.pixfmt
.width
*
3584 sd
->gspca_dev
.pixfmt
.height
* 3 / 2;
3585 /* 1000 isoc packets/sec */
3586 if (needed
> 1000 * packet_size
) {
3587 /* Enable Y and UV quantization and compression */
3588 reg_w(sd
, R511_COMP_EN
, 0x07);
3589 reg_w(sd
, R511_COMP_LUT_EN
, 0x03);
3591 reg_w(sd
, R511_COMP_EN
, 0x06);
3592 reg_w(sd
, R511_COMP_LUT_EN
, 0x00);
3595 reg_w(sd
, R51x_SYS_RESET
, OV511_RESET_OMNICE
);
3596 reg_w(sd
, R51x_SYS_RESET
, 0);
3599 /* Sets up the OV518/OV518+ with the given image parameters
3601 * OV518 needs a completely different approach, until we can figure out what
3602 * the individual registers do. Also, only 15 FPS is supported now.
3604 * Do not put any sensor-specific code in here (including I2C I/O functions)
3606 static void ov518_mode_init_regs(struct sd
*sd
)
3608 struct gspca_dev
*gspca_dev
= (struct gspca_dev
*)sd
;
3609 int hsegs
, vsegs
, packet_size
;
3610 struct usb_host_interface
*alt
;
3611 struct usb_interface
*intf
;
3613 intf
= usb_ifnum_to_if(sd
->gspca_dev
.dev
, sd
->gspca_dev
.iface
);
3614 alt
= usb_altnum_to_altsetting(intf
, sd
->gspca_dev
.alt
);
3616 gspca_err(gspca_dev
, "Couldn't get altsetting\n");
3617 sd
->gspca_dev
.usb_err
= -EIO
;
3621 if (alt
->desc
.bNumEndpoints
< 1) {
3622 sd
->gspca_dev
.usb_err
= -ENODEV
;
3626 packet_size
= le16_to_cpu(alt
->endpoint
[0].desc
.wMaxPacketSize
);
3627 ov518_reg_w32(sd
, R51x_FIFO_PSIZE
, packet_size
& ~7, 2);
3629 /******** Set the mode ********/
3639 if (sd
->bridge
== BRIDGE_OV518
) {
3640 /* Set 8-bit (YVYU) input format */
3641 reg_w_mask(sd
, 0x20, 0x08, 0x08);
3643 /* Set 12-bit (4:2:0) output format */
3644 reg_w_mask(sd
, 0x28, 0x80, 0xf0);
3645 reg_w_mask(sd
, 0x38, 0x80, 0xf0);
3647 reg_w(sd
, 0x28, 0x80);
3648 reg_w(sd
, 0x38, 0x80);
3651 hsegs
= sd
->gspca_dev
.pixfmt
.width
/ 16;
3652 vsegs
= sd
->gspca_dev
.pixfmt
.height
/ 4;
3654 reg_w(sd
, 0x29, hsegs
);
3655 reg_w(sd
, 0x2a, vsegs
);
3657 reg_w(sd
, 0x39, hsegs
);
3658 reg_w(sd
, 0x3a, vsegs
);
3660 /* Windows driver does this here; who knows why */
3661 reg_w(sd
, 0x2f, 0x80);
3663 /******** Set the framerate ********/
3664 if (sd
->bridge
== BRIDGE_OV518PLUS
&& sd
->revision
== 0 &&
3665 sd
->sensor
== SEN_OV7620AE
)
3670 /* Mode independent, but framerate dependent, regs */
3671 /* 0x51: Clock divider; Only works on some cams which use 2 crystals */
3672 reg_w(sd
, 0x51, 0x04);
3673 reg_w(sd
, 0x22, 0x18);
3674 reg_w(sd
, 0x23, 0xff);
3676 if (sd
->bridge
== BRIDGE_OV518PLUS
) {
3677 switch (sd
->sensor
) {
3680 * HdG: 640x480 needs special handling on device
3681 * revision 2, we check for device revison > 0 to
3682 * avoid regressions, as we don't know the correct
3683 * thing todo for revision 1.
3685 * Also this likely means we don't need to
3686 * differentiate between the OV7620 and OV7620AE,
3687 * earlier testing hitting this same problem likely
3688 * happened to be with revision < 2 cams using an
3689 * OV7620 and revision 2 cams using an OV7620AE.
3691 if (sd
->revision
> 0 &&
3692 sd
->gspca_dev
.pixfmt
.width
== 640) {
3693 reg_w(sd
, 0x20, 0x60);
3694 reg_w(sd
, 0x21, 0x1f);
3696 reg_w(sd
, 0x20, 0x00);
3697 reg_w(sd
, 0x21, 0x19);
3701 reg_w(sd
, 0x20, 0x00);
3702 reg_w(sd
, 0x21, 0x19);
3705 reg_w(sd
, 0x21, 0x19);
3708 reg_w(sd
, 0x71, 0x17); /* Compression-related? */
3710 /* FIXME: Sensor-specific */
3711 /* Bit 5 is what matters here. Of course, it is "reserved" */
3712 i2c_w(sd
, 0x54, 0x23);
3714 reg_w(sd
, 0x2f, 0x80);
3716 if (sd
->bridge
== BRIDGE_OV518PLUS
) {
3717 reg_w(sd
, 0x24, 0x94);
3718 reg_w(sd
, 0x25, 0x90);
3719 ov518_reg_w32(sd
, 0xc4, 400, 2); /* 190h */
3720 ov518_reg_w32(sd
, 0xc6, 540, 2); /* 21ch */
3721 ov518_reg_w32(sd
, 0xc7, 540, 2); /* 21ch */
3722 ov518_reg_w32(sd
, 0xc8, 108, 2); /* 6ch */
3723 ov518_reg_w32(sd
, 0xca, 131098, 3); /* 2001ah */
3724 ov518_reg_w32(sd
, 0xcb, 532, 2); /* 214h */
3725 ov518_reg_w32(sd
, 0xcc, 2400, 2); /* 960h */
3726 ov518_reg_w32(sd
, 0xcd, 32, 2); /* 20h */
3727 ov518_reg_w32(sd
, 0xce, 608, 2); /* 260h */
3729 reg_w(sd
, 0x24, 0x9f);
3730 reg_w(sd
, 0x25, 0x90);
3731 ov518_reg_w32(sd
, 0xc4, 400, 2); /* 190h */
3732 ov518_reg_w32(sd
, 0xc6, 381, 2); /* 17dh */
3733 ov518_reg_w32(sd
, 0xc7, 381, 2); /* 17dh */
3734 ov518_reg_w32(sd
, 0xc8, 128, 2); /* 80h */
3735 ov518_reg_w32(sd
, 0xca, 183331, 3); /* 2cc23h */
3736 ov518_reg_w32(sd
, 0xcb, 746, 2); /* 2eah */
3737 ov518_reg_w32(sd
, 0xcc, 1750, 2); /* 6d6h */
3738 ov518_reg_w32(sd
, 0xcd, 45, 2); /* 2dh */
3739 ov518_reg_w32(sd
, 0xce, 851, 2); /* 353h */
3742 reg_w(sd
, 0x2f, 0x80);
3745 /* Sets up the OV519 with the given image parameters
3747 * OV519 needs a completely different approach, until we can figure out what
3748 * the individual registers do.
3750 * Do not put any sensor-specific code in here (including I2C I/O functions)
3752 static void ov519_mode_init_regs(struct sd
*sd
)
3754 static const struct ov_regvals mode_init_519_ov7670
[] = {
3755 { 0x5d, 0x03 }, /* Turn off suspend mode */
3756 { 0x53, 0x9f }, /* was 9b in 1.65-1.08 */
3757 { OV519_R54_EN_CLK1
, 0x0f }, /* bit2 (jpeg enable) */
3758 { 0xa2, 0x20 }, /* a2-a5 are undocumented */
3762 { 0x37, 0x00 }, /* SetUsbInit */
3763 { 0x55, 0x02 }, /* 4.096 Mhz audio clock */
3764 /* Enable both fields, YUV Input, disable defect comp (why?) */
3768 { 0x17, 0x50 }, /* undocumented */
3769 { 0x37, 0x00 }, /* undocumented */
3770 { 0x40, 0xff }, /* I2C timeout counter */
3771 { 0x46, 0x00 }, /* I2C clock prescaler */
3772 { 0x59, 0x04 }, /* new from windrv 090403 */
3773 { 0xff, 0x00 }, /* undocumented */
3774 /* windows reads 0x55 at this point, why? */
3777 static const struct ov_regvals mode_init_519
[] = {
3778 { 0x5d, 0x03 }, /* Turn off suspend mode */
3779 { 0x53, 0x9f }, /* was 9b in 1.65-1.08 */
3780 { OV519_R54_EN_CLK1
, 0x0f }, /* bit2 (jpeg enable) */
3781 { 0xa2, 0x20 }, /* a2-a5 are undocumented */
3785 { 0x37, 0x00 }, /* SetUsbInit */
3786 { 0x55, 0x02 }, /* 4.096 Mhz audio clock */
3787 /* Enable both fields, YUV Input, disable defect comp (why?) */
3789 { 0x17, 0x50 }, /* undocumented */
3790 { 0x37, 0x00 }, /* undocumented */
3791 { 0x40, 0xff }, /* I2C timeout counter */
3792 { 0x46, 0x00 }, /* I2C clock prescaler */
3793 { 0x59, 0x04 }, /* new from windrv 090403 */
3794 { 0xff, 0x00 }, /* undocumented */
3795 /* windows reads 0x55 at this point, why? */
3798 struct gspca_dev
*gspca_dev
= (struct gspca_dev
*)sd
;
3800 /******** Set the mode ********/
3801 switch (sd
->sensor
) {
3803 write_regvals(sd
, mode_init_519
, ARRAY_SIZE(mode_init_519
));
3804 if (sd
->sensor
== SEN_OV7640
||
3805 sd
->sensor
== SEN_OV7648
) {
3806 /* Select 8-bit input mode */
3807 reg_w_mask(sd
, OV519_R20_DFR
, 0x10, 0x10);
3811 return; /* done by ov519_set_mode/fr() */
3813 write_regvals(sd
, mode_init_519_ov7670
,
3814 ARRAY_SIZE(mode_init_519_ov7670
));
3818 reg_w(sd
, OV519_R10_H_SIZE
, sd
->gspca_dev
.pixfmt
.width
>> 4);
3819 reg_w(sd
, OV519_R11_V_SIZE
, sd
->gspca_dev
.pixfmt
.height
>> 3);
3820 if (sd
->sensor
== SEN_OV7670
&&
3821 sd
->gspca_dev
.cam
.cam_mode
[sd
->gspca_dev
.curr_mode
].priv
)
3822 reg_w(sd
, OV519_R12_X_OFFSETL
, 0x04);
3823 else if (sd
->sensor
== SEN_OV7648
&&
3824 sd
->gspca_dev
.cam
.cam_mode
[sd
->gspca_dev
.curr_mode
].priv
)
3825 reg_w(sd
, OV519_R12_X_OFFSETL
, 0x01);
3827 reg_w(sd
, OV519_R12_X_OFFSETL
, 0x00);
3828 reg_w(sd
, OV519_R13_X_OFFSETH
, 0x00);
3829 reg_w(sd
, OV519_R14_Y_OFFSETL
, 0x00);
3830 reg_w(sd
, OV519_R15_Y_OFFSETH
, 0x00);
3831 reg_w(sd
, OV519_R16_DIVIDER
, 0x00);
3832 reg_w(sd
, OV519_R25_FORMAT
, 0x03); /* YUV422 */
3833 reg_w(sd
, 0x26, 0x00); /* Undocumented */
3835 /******** Set the framerate ********/
3837 sd
->frame_rate
= frame_rate
;
3839 /* FIXME: These are only valid at the max resolution. */
3841 switch (sd
->sensor
) {
3844 switch (sd
->frame_rate
) {
3847 reg_w(sd
, 0xa4, 0x0c);
3848 reg_w(sd
, 0x23, 0xff);
3851 reg_w(sd
, 0xa4, 0x0c);
3852 reg_w(sd
, 0x23, 0x1f);
3855 reg_w(sd
, 0xa4, 0x0c);
3856 reg_w(sd
, 0x23, 0x1b);
3859 reg_w(sd
, 0xa4, 0x04);
3860 reg_w(sd
, 0x23, 0xff);
3864 reg_w(sd
, 0xa4, 0x04);
3865 reg_w(sd
, 0x23, 0x1f);
3869 reg_w(sd
, 0xa4, 0x04);
3870 reg_w(sd
, 0x23, 0x1b);
3876 switch (sd
->frame_rate
) {
3877 default: /* 15 fps */
3879 reg_w(sd
, 0xa4, 0x06);
3880 reg_w(sd
, 0x23, 0xff);
3883 reg_w(sd
, 0xa4, 0x06);
3884 reg_w(sd
, 0x23, 0x1f);
3887 reg_w(sd
, 0xa4, 0x06);
3888 reg_w(sd
, 0x23, 0x1b);
3892 case SEN_OV7670
: /* guesses, based on 7640 */
3893 gspca_dbg(gspca_dev
, D_STREAM
, "Setting framerate to %d fps\n",
3894 (sd
->frame_rate
== 0) ? 15 : sd
->frame_rate
);
3895 reg_w(sd
, 0xa4, 0x10);
3896 switch (sd
->frame_rate
) {
3898 reg_w(sd
, 0x23, 0xff);
3901 reg_w(sd
, 0x23, 0x1b);
3905 reg_w(sd
, 0x23, 0xff);
3913 static void mode_init_ov_sensor_regs(struct sd
*sd
)
3915 struct gspca_dev
*gspca_dev
= (struct gspca_dev
*)sd
;
3916 int qvga
, xstart
, xend
, ystart
, yend
;
3919 qvga
= gspca_dev
->cam
.cam_mode
[gspca_dev
->curr_mode
].priv
& 1;
3921 /******** Mode (VGA/QVGA) and sensor specific regs ********/
3922 switch (sd
->sensor
) {
3924 i2c_w_mask(sd
, 0x14, qvga
? 0x20 : 0x00, 0x20);
3925 i2c_w_mask(sd
, 0x28, qvga
? 0x00 : 0x20, 0x20);
3926 i2c_w(sd
, 0x24, qvga
? 0x20 : 0x3a);
3927 i2c_w(sd
, 0x25, qvga
? 0x30 : 0x60);
3928 i2c_w_mask(sd
, 0x2d, qvga
? 0x40 : 0x00, 0x40);
3929 i2c_w_mask(sd
, 0x67, qvga
? 0xf0 : 0x90, 0xf0);
3930 i2c_w_mask(sd
, 0x74, qvga
? 0x20 : 0x00, 0x20);
3932 case SEN_OV2610AE
: {
3936 * 10fps / 5 fps for 1600x1200
3937 * 40fps / 20fps for 800x600
3941 if (sd
->frame_rate
< 25)
3944 if (sd
->frame_rate
< 10)
3948 i2c_w(sd
, 0x12, qvga
? 0x60 : 0x20);
3953 xstart
= (1040 - gspca_dev
->pixfmt
.width
) / 2 +
3955 ystart
= (776 - gspca_dev
->pixfmt
.height
) / 2;
3957 xstart
= (2076 - gspca_dev
->pixfmt
.width
) / 2 +
3959 ystart
= (1544 - gspca_dev
->pixfmt
.height
) / 2;
3961 xend
= xstart
+ gspca_dev
->pixfmt
.width
;
3962 yend
= ystart
+ gspca_dev
->pixfmt
.height
;
3963 /* Writing to the COMH register resets the other windowing regs
3964 to their default values, so we must do this first. */
3965 i2c_w_mask(sd
, 0x12, qvga
? 0x40 : 0x00, 0xf0);
3966 i2c_w_mask(sd
, 0x32,
3967 (((xend
>> 1) & 7) << 3) | ((xstart
>> 1) & 7),
3969 i2c_w_mask(sd
, 0x03,
3970 (((yend
>> 1) & 3) << 2) | ((ystart
>> 1) & 3),
3972 i2c_w(sd
, 0x17, xstart
>> 4);
3973 i2c_w(sd
, 0x18, xend
>> 4);
3974 i2c_w(sd
, 0x19, ystart
>> 3);
3975 i2c_w(sd
, 0x1a, yend
>> 3);
3978 /* For OV8610 qvga means qsvga */
3979 i2c_w_mask(sd
, OV7610_REG_COM_C
, qvga
? (1 << 5) : 0, 1 << 5);
3980 i2c_w_mask(sd
, 0x13, 0x00, 0x20); /* Select 16 bit data bus */
3981 i2c_w_mask(sd
, 0x12, 0x04, 0x06); /* AWB: 1 Test pattern: 0 */
3982 i2c_w_mask(sd
, 0x2d, 0x00, 0x40); /* from windrv 090403 */
3983 i2c_w_mask(sd
, 0x28, 0x20, 0x20); /* progressive mode on */
3986 i2c_w_mask(sd
, 0x14, qvga
? 0x20 : 0x00, 0x20);
3987 i2c_w(sd
, 0x35, qvga
? 0x1e : 0x9e);
3988 i2c_w_mask(sd
, 0x13, 0x00, 0x20); /* Select 16 bit data bus */
3989 i2c_w_mask(sd
, 0x12, 0x04, 0x06); /* AWB: 1 Test pattern: 0 */
3994 i2c_w_mask(sd
, 0x14, qvga
? 0x20 : 0x00, 0x20);
3995 i2c_w_mask(sd
, 0x28, qvga
? 0x00 : 0x20, 0x20);
3996 i2c_w(sd
, 0x24, qvga
? 0x20 : 0x3a);
3997 i2c_w(sd
, 0x25, qvga
? 0x30 : 0x60);
3998 i2c_w_mask(sd
, 0x2d, qvga
? 0x40 : 0x00, 0x40);
3999 i2c_w_mask(sd
, 0x67, qvga
? 0xb0 : 0x90, 0xf0);
4000 i2c_w_mask(sd
, 0x74, qvga
? 0x20 : 0x00, 0x20);
4001 i2c_w_mask(sd
, 0x13, 0x00, 0x20); /* Select 16 bit data bus */
4002 i2c_w_mask(sd
, 0x12, 0x04, 0x06); /* AWB: 1 Test pattern: 0 */
4003 if (sd
->sensor
== SEN_OV76BE
)
4004 i2c_w(sd
, 0x35, qvga
? 0x1e : 0x9e);
4008 i2c_w_mask(sd
, 0x14, qvga
? 0x20 : 0x00, 0x20);
4009 i2c_w_mask(sd
, 0x28, qvga
? 0x00 : 0x20, 0x20);
4010 /* Setting this undocumented bit in qvga mode removes a very
4011 annoying vertical shaking of the image */
4012 i2c_w_mask(sd
, 0x2d, qvga
? 0x40 : 0x00, 0x40);
4014 i2c_w_mask(sd
, 0x67, qvga
? 0xf0 : 0x90, 0xf0);
4015 /* Allow higher automatic gain (to allow higher framerates) */
4016 i2c_w_mask(sd
, 0x74, qvga
? 0x20 : 0x00, 0x20);
4017 i2c_w_mask(sd
, 0x12, 0x04, 0x04); /* AWB: 1 */
4020 /* set COM7_FMT_VGA or COM7_FMT_QVGA
4021 * do we need to set anything else?
4022 * HSTART etc are set in set_ov_sensor_window itself */
4023 i2c_w_mask(sd
, OV7670_R12_COM7
,
4024 qvga
? OV7670_COM7_FMT_QVGA
: OV7670_COM7_FMT_VGA
,
4025 OV7670_COM7_FMT_MASK
);
4026 i2c_w_mask(sd
, 0x13, 0x00, 0x20); /* Select 16 bit data bus */
4027 i2c_w_mask(sd
, OV7670_R13_COM8
, OV7670_COM8_AWB
,
4029 if (qvga
) { /* QVGA from ov7670.c by
4030 * Jonathan Corbet */
4041 /* OV7670 hardware window registers are split across
4042 * multiple locations */
4043 i2c_w(sd
, OV7670_R17_HSTART
, xstart
>> 3);
4044 i2c_w(sd
, OV7670_R18_HSTOP
, xend
>> 3);
4045 v
= i2c_r(sd
, OV7670_R32_HREF
);
4046 v
= (v
& 0xc0) | ((xend
& 0x7) << 3) | (xstart
& 0x07);
4047 msleep(10); /* need to sleep between read and write to
4049 i2c_w(sd
, OV7670_R32_HREF
, v
);
4051 i2c_w(sd
, OV7670_R19_VSTART
, ystart
>> 2);
4052 i2c_w(sd
, OV7670_R1A_VSTOP
, yend
>> 2);
4053 v
= i2c_r(sd
, OV7670_R03_VREF
);
4054 v
= (v
& 0xc0) | ((yend
& 0x3) << 2) | (ystart
& 0x03);
4055 msleep(10); /* need to sleep between read and write to
4057 i2c_w(sd
, OV7670_R03_VREF
, v
);
4060 i2c_w_mask(sd
, 0x14, qvga
? 0x20 : 0x00, 0x20);
4061 i2c_w_mask(sd
, 0x13, 0x00, 0x20); /* Select 16 bit data bus */
4062 i2c_w_mask(sd
, 0x12, 0x04, 0x06); /* AWB: 1 Test pattern: 0 */
4066 i2c_w_mask(sd
, 0x14, qvga
? 0x20 : 0x00, 0x20);
4067 i2c_w_mask(sd
, 0x12, 0x04, 0x06); /* AWB: 1 Test pattern: 0 */
4070 const struct ov_i2c_regvals
*vals
;
4071 static const struct ov_i2c_regvals sxga_15
[] = {
4072 {0x11, 0x80}, {0x14, 0x3e}, {0x24, 0x85}, {0x25, 0x75}
4074 static const struct ov_i2c_regvals sxga_7_5
[] = {
4075 {0x11, 0x81}, {0x14, 0x3e}, {0x24, 0x85}, {0x25, 0x75}
4077 static const struct ov_i2c_regvals vga_30
[] = {
4078 {0x11, 0x81}, {0x14, 0x7e}, {0x24, 0x70}, {0x25, 0x60}
4080 static const struct ov_i2c_regvals vga_15
[] = {
4081 {0x11, 0x83}, {0x14, 0x3e}, {0x24, 0x80}, {0x25, 0x70}
4085 * 15fps / 7.5 fps for 1280x1024
4086 * 30fps / 15fps for 640x480
4088 i2c_w_mask(sd
, 0x12, qvga
? 0x40 : 0x00, 0x40);
4090 vals
= sd
->frame_rate
< 30 ? vga_15
: vga_30
;
4092 vals
= sd
->frame_rate
< 15 ? sxga_7_5
: sxga_15
;
4093 write_i2c_regvals(sd
, vals
, ARRAY_SIZE(sxga_15
));
4100 /******** Clock programming ********/
4101 i2c_w(sd
, 0x11, sd
->clockdiv
);
4104 /* this function works for bridge ov519 and sensors ov7660 and ov7670 only */
4105 static void sethvflip(struct gspca_dev
*gspca_dev
, s32 hflip
, s32 vflip
)
4107 struct sd
*sd
= (struct sd
*) gspca_dev
;
4109 if (sd
->gspca_dev
.streaming
)
4110 reg_w(sd
, OV519_R51_RESET1
, 0x0f); /* block stream */
4111 i2c_w_mask(sd
, OV7670_R1E_MVFP
,
4112 OV7670_MVFP_MIRROR
* hflip
| OV7670_MVFP_VFLIP
* vflip
,
4113 OV7670_MVFP_MIRROR
| OV7670_MVFP_VFLIP
);
4114 if (sd
->gspca_dev
.streaming
)
4115 reg_w(sd
, OV519_R51_RESET1
, 0x00); /* restart stream */
4118 static void set_ov_sensor_window(struct sd
*sd
)
4120 struct gspca_dev
*gspca_dev
;
4122 int hwsbase
, hwebase
, vwsbase
, vwebase
, hwscale
, vwscale
;
4124 /* mode setup is fully handled in mode_init_ov_sensor_regs for these */
4125 switch (sd
->sensor
) {
4131 mode_init_ov_sensor_regs(sd
);
4139 gspca_dev
= &sd
->gspca_dev
;
4140 qvga
= gspca_dev
->cam
.cam_mode
[gspca_dev
->curr_mode
].priv
& 1;
4141 crop
= gspca_dev
->cam
.cam_mode
[gspca_dev
->curr_mode
].priv
& 2;
4143 /* The different sensor ICs handle setting up of window differently.
4144 * IF YOU SET IT WRONG, YOU WILL GET ALL ZERO ISOC DATA FROM OV51x!! */
4145 switch (sd
->sensor
) {
4156 vwsbase
= vwebase
= 0x05;
4165 if (sd
->sensor
== SEN_OV66308AF
&& qvga
)
4166 /* HDG: this fixes U and V getting swapped */
4177 hwsbase
= 0x2f; /* From 7620.SET (spec is wrong) */
4179 vwsbase
= vwebase
= 0x05;
4185 vwsbase
= vwebase
= 0x03;
4191 switch (sd
->sensor
) {
4195 if (qvga
) { /* QCIF */
4200 vwscale
= 1; /* The datasheet says 0;
4205 if (qvga
) { /* QSVGA */
4213 default: /* SEN_OV7xx0 */
4214 if (qvga
) { /* QVGA */
4223 mode_init_ov_sensor_regs(sd
);
4225 i2c_w(sd
, 0x17, hwsbase
);
4226 i2c_w(sd
, 0x18, hwebase
+ (sd
->sensor_width
>> hwscale
));
4227 i2c_w(sd
, 0x19, vwsbase
);
4228 i2c_w(sd
, 0x1a, vwebase
+ (sd
->sensor_height
>> vwscale
));
4231 /* -- start the camera -- */
4232 static int sd_start(struct gspca_dev
*gspca_dev
)
4234 struct sd
*sd
= (struct sd
*) gspca_dev
;
4236 /* Default for most bridges, allow bridge_mode_init_regs to override */
4237 sd
->sensor_width
= sd
->gspca_dev
.pixfmt
.width
;
4238 sd
->sensor_height
= sd
->gspca_dev
.pixfmt
.height
;
4240 switch (sd
->bridge
) {
4242 case BRIDGE_OV511PLUS
:
4243 ov511_mode_init_regs(sd
);
4246 case BRIDGE_OV518PLUS
:
4247 ov518_mode_init_regs(sd
);
4250 ov519_mode_init_regs(sd
);
4252 /* case BRIDGE_OVFX2: nothing to do */
4253 case BRIDGE_W9968CF
:
4254 w9968cf_mode_init_regs(sd
);
4258 set_ov_sensor_window(sd
);
4260 /* Force clear snapshot state in case the snapshot button was
4261 pressed while we weren't streaming */
4262 sd
->snapshot_needs_reset
= 1;
4263 sd_reset_snapshot(gspca_dev
);
4265 sd
->first_frame
= 3;
4268 ov51x_led_control(sd
, 1);
4269 return gspca_dev
->usb_err
;
4272 static void sd_stopN(struct gspca_dev
*gspca_dev
)
4274 struct sd
*sd
= (struct sd
*) gspca_dev
;
4277 ov51x_led_control(sd
, 0);
4280 static void sd_stop0(struct gspca_dev
*gspca_dev
)
4282 struct sd
*sd
= (struct sd
*) gspca_dev
;
4284 if (!sd
->gspca_dev
.present
)
4286 if (sd
->bridge
== BRIDGE_W9968CF
)
4289 #if IS_ENABLED(CONFIG_INPUT)
4290 /* If the last button state is pressed, release it now! */
4291 if (sd
->snapshot_pressed
) {
4292 input_report_key(gspca_dev
->input_dev
, KEY_CAMERA
, 0);
4293 input_sync(gspca_dev
->input_dev
);
4294 sd
->snapshot_pressed
= 0;
4297 if (sd
->bridge
== BRIDGE_OV519
)
4298 reg_w(sd
, OV519_R57_SNAPSHOT
, 0x23);
4301 static void ov51x_handle_button(struct gspca_dev
*gspca_dev
, u8 state
)
4303 struct sd
*sd
= (struct sd
*) gspca_dev
;
4305 if (sd
->snapshot_pressed
!= state
) {
4306 #if IS_ENABLED(CONFIG_INPUT)
4307 input_report_key(gspca_dev
->input_dev
, KEY_CAMERA
, state
);
4308 input_sync(gspca_dev
->input_dev
);
4311 sd
->snapshot_needs_reset
= 1;
4313 sd
->snapshot_pressed
= state
;
4315 /* On the ov511 / ov519 we need to reset the button state
4316 multiple times, as resetting does not work as long as the
4317 button stays pressed */
4318 switch (sd
->bridge
) {
4320 case BRIDGE_OV511PLUS
:
4323 sd
->snapshot_needs_reset
= 1;
4329 static void ov511_pkt_scan(struct gspca_dev
*gspca_dev
,
4330 u8
*in
, /* isoc packet */
4331 int len
) /* iso packet length */
4333 struct sd
*sd
= (struct sd
*) gspca_dev
;
4335 /* SOF/EOF packets have 1st to 8th bytes zeroed and the 9th
4336 * byte non-zero. The EOF packet has image width/height in the
4337 * 10th and 11th bytes. The 9th byte is given as follows:
4340 * 6: compression enabled
4341 * 5: 422/420/400 modes
4342 * 4: 422/420/400 modes
4344 * 2: snapshot button on
4348 if (!(in
[0] | in
[1] | in
[2] | in
[3] | in
[4] | in
[5] | in
[6] | in
[7]) &&
4350 ov51x_handle_button(gspca_dev
, (in
[8] >> 2) & 1);
4353 if ((in
[9] + 1) * 8 != gspca_dev
->pixfmt
.width
||
4354 (in
[10] + 1) * 8 != gspca_dev
->pixfmt
.height
) {
4355 gspca_err(gspca_dev
, "Invalid frame size, got: %dx%d, requested: %dx%d\n",
4356 (in
[9] + 1) * 8, (in
[10] + 1) * 8,
4357 gspca_dev
->pixfmt
.width
,
4358 gspca_dev
->pixfmt
.height
);
4359 gspca_dev
->last_packet_type
= DISCARD_PACKET
;
4362 /* Add 11 byte footer to frame, might be useful */
4363 gspca_frame_add(gspca_dev
, LAST_PACKET
, in
, 11);
4367 gspca_frame_add(gspca_dev
, FIRST_PACKET
, in
, 0);
4372 /* Ignore the packet number */
4375 /* intermediate packet */
4376 gspca_frame_add(gspca_dev
, INTER_PACKET
, in
, len
);
4379 static void ov518_pkt_scan(struct gspca_dev
*gspca_dev
,
4380 u8
*data
, /* isoc packet */
4381 int len
) /* iso packet length */
4383 struct sd
*sd
= (struct sd
*) gspca_dev
;
4385 /* A false positive here is likely, until OVT gives me
4386 * the definitive SOF/EOF format */
4387 if ((!(data
[0] | data
[1] | data
[2] | data
[3] | data
[5])) && data
[6]) {
4388 ov51x_handle_button(gspca_dev
, (data
[6] >> 1) & 1);
4389 gspca_frame_add(gspca_dev
, LAST_PACKET
, NULL
, 0);
4390 gspca_frame_add(gspca_dev
, FIRST_PACKET
, NULL
, 0);
4394 if (gspca_dev
->last_packet_type
== DISCARD_PACKET
)
4397 /* Does this device use packet numbers ? */
4400 if (sd
->packet_nr
== data
[len
])
4402 /* The last few packets of the frame (which are all 0's
4403 except that they may contain part of the footer), are
4405 else if (sd
->packet_nr
== 0 || data
[len
]) {
4406 gspca_err(gspca_dev
, "Invalid packet nr: %d (expect: %d)\n",
4407 (int)data
[len
], (int)sd
->packet_nr
);
4408 gspca_dev
->last_packet_type
= DISCARD_PACKET
;
4413 /* intermediate packet */
4414 gspca_frame_add(gspca_dev
, INTER_PACKET
, data
, len
);
4417 static void ov519_pkt_scan(struct gspca_dev
*gspca_dev
,
4418 u8
*data
, /* isoc packet */
4419 int len
) /* iso packet length */
4421 /* Header of ov519 is 16 bytes:
4422 * Byte Value Description
4426 * 3 0xXX 0x50 = SOF, 0x51 = EOF
4427 * 9 0xXX 0x01 initial frame without data,
4428 * 0x00 standard frame with image
4429 * 14 Lo in EOF: length of image data / 8
4433 if (data
[0] == 0xff && data
[1] == 0xff && data
[2] == 0xff) {
4435 case 0x50: /* start of frame */
4436 /* Don't check the button state here, as the state
4437 usually (always ?) changes at EOF and checking it
4438 here leads to unnecessary snapshot state resets. */
4443 if (data
[0] == 0xff || data
[1] == 0xd8)
4444 gspca_frame_add(gspca_dev
, FIRST_PACKET
,
4447 gspca_dev
->last_packet_type
= DISCARD_PACKET
;
4449 case 0x51: /* end of frame */
4450 ov51x_handle_button(gspca_dev
, data
[11] & 1);
4452 gspca_dev
->last_packet_type
= DISCARD_PACKET
;
4453 gspca_frame_add(gspca_dev
, LAST_PACKET
,
4459 /* intermediate packet */
4460 gspca_frame_add(gspca_dev
, INTER_PACKET
, data
, len
);
4463 static void ovfx2_pkt_scan(struct gspca_dev
*gspca_dev
,
4464 u8
*data
, /* isoc packet */
4465 int len
) /* iso packet length */
4467 struct sd
*sd
= (struct sd
*) gspca_dev
;
4469 gspca_frame_add(gspca_dev
, INTER_PACKET
, data
, len
);
4471 /* A short read signals EOF */
4472 if (len
< gspca_dev
->cam
.bulk_size
) {
4473 /* If the frame is short, and it is one of the first ones
4474 the sensor and bridge are still syncing, so drop it. */
4475 if (sd
->first_frame
) {
4477 if (gspca_dev
->image_len
<
4478 sd
->gspca_dev
.pixfmt
.width
*
4479 sd
->gspca_dev
.pixfmt
.height
)
4480 gspca_dev
->last_packet_type
= DISCARD_PACKET
;
4482 gspca_frame_add(gspca_dev
, LAST_PACKET
, NULL
, 0);
4483 gspca_frame_add(gspca_dev
, FIRST_PACKET
, NULL
, 0);
4487 static void sd_pkt_scan(struct gspca_dev
*gspca_dev
,
4488 u8
*data
, /* isoc packet */
4489 int len
) /* iso packet length */
4491 struct sd
*sd
= (struct sd
*) gspca_dev
;
4493 switch (sd
->bridge
) {
4495 case BRIDGE_OV511PLUS
:
4496 ov511_pkt_scan(gspca_dev
, data
, len
);
4499 case BRIDGE_OV518PLUS
:
4500 ov518_pkt_scan(gspca_dev
, data
, len
);
4503 ov519_pkt_scan(gspca_dev
, data
, len
);
4506 ovfx2_pkt_scan(gspca_dev
, data
, len
);
4508 case BRIDGE_W9968CF
:
4509 w9968cf_pkt_scan(gspca_dev
, data
, len
);
4514 /* -- management routines -- */
4516 static void setbrightness(struct gspca_dev
*gspca_dev
, s32 val
)
4518 struct sd
*sd
= (struct sd
*) gspca_dev
;
4519 static const struct ov_i2c_regvals brit_7660
[][7] = {
4520 {{0x0f, 0x6a}, {0x24, 0x40}, {0x25, 0x2b}, {0x26, 0x90},
4521 {0x27, 0xe0}, {0x28, 0xe0}, {0x2c, 0xe0}},
4522 {{0x0f, 0x6a}, {0x24, 0x50}, {0x25, 0x40}, {0x26, 0xa1},
4523 {0x27, 0xc0}, {0x28, 0xc0}, {0x2c, 0xc0}},
4524 {{0x0f, 0x6a}, {0x24, 0x68}, {0x25, 0x58}, {0x26, 0xc2},
4525 {0x27, 0xa0}, {0x28, 0xa0}, {0x2c, 0xa0}},
4526 {{0x0f, 0x6a}, {0x24, 0x70}, {0x25, 0x68}, {0x26, 0xd3},
4527 {0x27, 0x80}, {0x28, 0x80}, {0x2c, 0x80}},
4528 {{0x0f, 0x6a}, {0x24, 0x80}, {0x25, 0x70}, {0x26, 0xd3},
4529 {0x27, 0x20}, {0x28, 0x20}, {0x2c, 0x20}},
4530 {{0x0f, 0x6a}, {0x24, 0x88}, {0x25, 0x78}, {0x26, 0xd3},
4531 {0x27, 0x40}, {0x28, 0x40}, {0x2c, 0x40}},
4532 {{0x0f, 0x6a}, {0x24, 0x90}, {0x25, 0x80}, {0x26, 0xd4},
4533 {0x27, 0x60}, {0x28, 0x60}, {0x2c, 0x60}}
4536 switch (sd
->sensor
) {
4545 i2c_w(sd
, OV7610_REG_BRT
, val
);
4549 i2c_w(sd
, OV7610_REG_BRT
, val
);
4552 write_i2c_regvals(sd
, brit_7660
[val
],
4553 ARRAY_SIZE(brit_7660
[0]));
4557 * i2c_w_mask(sd, OV7670_R13_COM8, 0, OV7670_COM8_AEC); */
4558 i2c_w(sd
, OV7670_R55_BRIGHT
, ov7670_abs_to_sm(val
));
4563 static void setcontrast(struct gspca_dev
*gspca_dev
, s32 val
)
4565 struct sd
*sd
= (struct sd
*) gspca_dev
;
4566 static const struct ov_i2c_regvals contrast_7660
[][31] = {
4567 {{0x6c, 0xf0}, {0x6d, 0xf0}, {0x6e, 0xf8}, {0x6f, 0xa0},
4568 {0x70, 0x58}, {0x71, 0x38}, {0x72, 0x30}, {0x73, 0x30},
4569 {0x74, 0x28}, {0x75, 0x28}, {0x76, 0x24}, {0x77, 0x24},
4570 {0x78, 0x22}, {0x79, 0x28}, {0x7a, 0x2a}, {0x7b, 0x34},
4571 {0x7c, 0x0f}, {0x7d, 0x1e}, {0x7e, 0x3d}, {0x7f, 0x65},
4572 {0x80, 0x70}, {0x81, 0x77}, {0x82, 0x7d}, {0x83, 0x83},
4573 {0x84, 0x88}, {0x85, 0x8d}, {0x86, 0x96}, {0x87, 0x9f},
4574 {0x88, 0xb0}, {0x89, 0xc4}, {0x8a, 0xd9}},
4575 {{0x6c, 0xf0}, {0x6d, 0xf0}, {0x6e, 0xf8}, {0x6f, 0x94},
4576 {0x70, 0x58}, {0x71, 0x40}, {0x72, 0x30}, {0x73, 0x30},
4577 {0x74, 0x30}, {0x75, 0x30}, {0x76, 0x2c}, {0x77, 0x24},
4578 {0x78, 0x22}, {0x79, 0x28}, {0x7a, 0x2a}, {0x7b, 0x31},
4579 {0x7c, 0x0f}, {0x7d, 0x1e}, {0x7e, 0x3d}, {0x7f, 0x62},
4580 {0x80, 0x6d}, {0x81, 0x75}, {0x82, 0x7b}, {0x83, 0x81},
4581 {0x84, 0x87}, {0x85, 0x8d}, {0x86, 0x98}, {0x87, 0xa1},
4582 {0x88, 0xb2}, {0x89, 0xc6}, {0x8a, 0xdb}},
4583 {{0x6c, 0xf0}, {0x6d, 0xf0}, {0x6e, 0xf0}, {0x6f, 0x84},
4584 {0x70, 0x58}, {0x71, 0x48}, {0x72, 0x40}, {0x73, 0x40},
4585 {0x74, 0x28}, {0x75, 0x28}, {0x76, 0x28}, {0x77, 0x24},
4586 {0x78, 0x26}, {0x79, 0x28}, {0x7a, 0x28}, {0x7b, 0x34},
4587 {0x7c, 0x0f}, {0x7d, 0x1e}, {0x7e, 0x3c}, {0x7f, 0x5d},
4588 {0x80, 0x68}, {0x81, 0x71}, {0x82, 0x79}, {0x83, 0x81},
4589 {0x84, 0x86}, {0x85, 0x8b}, {0x86, 0x95}, {0x87, 0x9e},
4590 {0x88, 0xb1}, {0x89, 0xc5}, {0x8a, 0xd9}},
4591 {{0x6c, 0xf0}, {0x6d, 0xf0}, {0x6e, 0xf0}, {0x6f, 0x70},
4592 {0x70, 0x58}, {0x71, 0x58}, {0x72, 0x48}, {0x73, 0x48},
4593 {0x74, 0x38}, {0x75, 0x40}, {0x76, 0x34}, {0x77, 0x34},
4594 {0x78, 0x2e}, {0x79, 0x28}, {0x7a, 0x24}, {0x7b, 0x22},
4595 {0x7c, 0x0f}, {0x7d, 0x1e}, {0x7e, 0x3c}, {0x7f, 0x58},
4596 {0x80, 0x63}, {0x81, 0x6e}, {0x82, 0x77}, {0x83, 0x80},
4597 {0x84, 0x87}, {0x85, 0x8f}, {0x86, 0x9c}, {0x87, 0xa9},
4598 {0x88, 0xc0}, {0x89, 0xd4}, {0x8a, 0xe6}},
4599 {{0x6c, 0xa0}, {0x6d, 0xf0}, {0x6e, 0x90}, {0x6f, 0x80},
4600 {0x70, 0x70}, {0x71, 0x80}, {0x72, 0x60}, {0x73, 0x60},
4601 {0x74, 0x58}, {0x75, 0x60}, {0x76, 0x4c}, {0x77, 0x38},
4602 {0x78, 0x38}, {0x79, 0x2a}, {0x7a, 0x20}, {0x7b, 0x0e},
4603 {0x7c, 0x0a}, {0x7d, 0x14}, {0x7e, 0x26}, {0x7f, 0x46},
4604 {0x80, 0x54}, {0x81, 0x64}, {0x82, 0x70}, {0x83, 0x7c},
4605 {0x84, 0x87}, {0x85, 0x93}, {0x86, 0xa6}, {0x87, 0xb4},
4606 {0x88, 0xd0}, {0x89, 0xe5}, {0x8a, 0xf5}},
4607 {{0x6c, 0x60}, {0x6d, 0x80}, {0x6e, 0x60}, {0x6f, 0x80},
4608 {0x70, 0x80}, {0x71, 0x80}, {0x72, 0x88}, {0x73, 0x30},
4609 {0x74, 0x70}, {0x75, 0x68}, {0x76, 0x64}, {0x77, 0x50},
4610 {0x78, 0x3c}, {0x79, 0x22}, {0x7a, 0x10}, {0x7b, 0x08},
4611 {0x7c, 0x06}, {0x7d, 0x0e}, {0x7e, 0x1a}, {0x7f, 0x3a},
4612 {0x80, 0x4a}, {0x81, 0x5a}, {0x82, 0x6b}, {0x83, 0x7b},
4613 {0x84, 0x89}, {0x85, 0x96}, {0x86, 0xaf}, {0x87, 0xc3},
4614 {0x88, 0xe1}, {0x89, 0xf2}, {0x8a, 0xfa}},
4615 {{0x6c, 0x20}, {0x6d, 0x40}, {0x6e, 0x20}, {0x6f, 0x60},
4616 {0x70, 0x88}, {0x71, 0xc8}, {0x72, 0xc0}, {0x73, 0xb8},
4617 {0x74, 0xa8}, {0x75, 0xb8}, {0x76, 0x80}, {0x77, 0x5c},
4618 {0x78, 0x26}, {0x79, 0x10}, {0x7a, 0x08}, {0x7b, 0x04},
4619 {0x7c, 0x02}, {0x7d, 0x06}, {0x7e, 0x0a}, {0x7f, 0x22},
4620 {0x80, 0x33}, {0x81, 0x4c}, {0x82, 0x64}, {0x83, 0x7b},
4621 {0x84, 0x90}, {0x85, 0xa7}, {0x86, 0xc7}, {0x87, 0xde},
4622 {0x88, 0xf1}, {0x89, 0xf9}, {0x8a, 0xfd}},
4625 switch (sd
->sensor
) {
4628 i2c_w(sd
, OV7610_REG_CNT
, val
);
4632 i2c_w_mask(sd
, OV7610_REG_CNT
, val
>> 4, 0x0f);
4635 static const u8 ctab
[] = {
4636 0x03, 0x09, 0x0b, 0x0f, 0x53, 0x6f, 0x35, 0x7f
4639 /* Use Y gamma control instead. Bit 0 enables it. */
4640 i2c_w(sd
, 0x64, ctab
[val
>> 5]);
4644 case SEN_OV7620AE
: {
4645 static const u8 ctab
[] = {
4646 0x01, 0x05, 0x09, 0x11, 0x15, 0x35, 0x37, 0x57,
4647 0x5b, 0xa5, 0xa7, 0xc7, 0xc9, 0xcf, 0xef, 0xff
4650 /* Use Y gamma control instead. Bit 0 enables it. */
4651 i2c_w(sd
, 0x64, ctab
[val
>> 4]);
4655 write_i2c_regvals(sd
, contrast_7660
[val
],
4656 ARRAY_SIZE(contrast_7660
[0]));
4659 /* check that this isn't just the same as ov7610 */
4660 i2c_w(sd
, OV7670_R56_CONTRAS
, val
>> 1);
4665 static void setexposure(struct gspca_dev
*gspca_dev
, s32 val
)
4667 struct sd
*sd
= (struct sd
*) gspca_dev
;
4669 i2c_w(sd
, 0x10, val
);
4672 static void setcolors(struct gspca_dev
*gspca_dev
, s32 val
)
4674 struct sd
*sd
= (struct sd
*) gspca_dev
;
4675 static const struct ov_i2c_regvals colors_7660
[][6] = {
4676 {{0x4f, 0x28}, {0x50, 0x2a}, {0x51, 0x02}, {0x52, 0x0a},
4677 {0x53, 0x19}, {0x54, 0x23}},
4678 {{0x4f, 0x47}, {0x50, 0x4a}, {0x51, 0x03}, {0x52, 0x11},
4679 {0x53, 0x2c}, {0x54, 0x3e}},
4680 {{0x4f, 0x66}, {0x50, 0x6b}, {0x51, 0x05}, {0x52, 0x19},
4681 {0x53, 0x40}, {0x54, 0x59}},
4682 {{0x4f, 0x84}, {0x50, 0x8b}, {0x51, 0x06}, {0x52, 0x20},
4683 {0x53, 0x53}, {0x54, 0x73}},
4684 {{0x4f, 0xa3}, {0x50, 0xab}, {0x51, 0x08}, {0x52, 0x28},
4685 {0x53, 0x66}, {0x54, 0x8e}},
4688 switch (sd
->sensor
) {
4695 i2c_w(sd
, OV7610_REG_SAT
, val
);
4699 /* Use UV gamma control instead. Bits 0 & 7 are reserved. */
4700 /* rc = ov_i2c_write(sd->dev, 0x62, (val >> 9) & 0x7e);
4703 i2c_w(sd
, OV7610_REG_SAT
, val
);
4707 i2c_w(sd
, OV7610_REG_SAT
, val
& 0xf0);
4710 write_i2c_regvals(sd
, colors_7660
[val
],
4711 ARRAY_SIZE(colors_7660
[0]));
4714 /* supported later once I work out how to do it
4715 * transparently fail now! */
4716 /* set REG_COM13 values for UV sat auto mode */
4721 static void setautobright(struct gspca_dev
*gspca_dev
, s32 val
)
4723 struct sd
*sd
= (struct sd
*) gspca_dev
;
4725 i2c_w_mask(sd
, 0x2d, val
? 0x10 : 0x00, 0x10);
4728 static void setfreq_i(struct sd
*sd
, s32 val
)
4730 if (sd
->sensor
== SEN_OV7660
4731 || sd
->sensor
== SEN_OV7670
) {
4733 case 0: /* Banding filter disabled */
4734 i2c_w_mask(sd
, OV7670_R13_COM8
, 0, OV7670_COM8_BFILT
);
4737 i2c_w_mask(sd
, OV7670_R13_COM8
, OV7670_COM8_BFILT
,
4739 i2c_w_mask(sd
, OV7670_R3B_COM11
, 0x08, 0x18);
4742 i2c_w_mask(sd
, OV7670_R13_COM8
, OV7670_COM8_BFILT
,
4744 i2c_w_mask(sd
, OV7670_R3B_COM11
, 0x00, 0x18);
4746 case 3: /* Auto hz - ov7670 only */
4747 i2c_w_mask(sd
, OV7670_R13_COM8
, OV7670_COM8_BFILT
,
4749 i2c_w_mask(sd
, OV7670_R3B_COM11
, OV7670_COM11_HZAUTO
,
4755 case 0: /* Banding filter disabled */
4756 i2c_w_mask(sd
, 0x2d, 0x00, 0x04);
4757 i2c_w_mask(sd
, 0x2a, 0x00, 0x80);
4759 case 1: /* 50 hz (filter on and framerate adj) */
4760 i2c_w_mask(sd
, 0x2d, 0x04, 0x04);
4761 i2c_w_mask(sd
, 0x2a, 0x80, 0x80);
4762 /* 20 fps -> 16.667 fps */
4763 if (sd
->sensor
== SEN_OV6620
||
4764 sd
->sensor
== SEN_OV6630
||
4765 sd
->sensor
== SEN_OV66308AF
)
4766 i2c_w(sd
, 0x2b, 0x5e);
4768 i2c_w(sd
, 0x2b, 0xac);
4770 case 2: /* 60 hz (filter on, ...) */
4771 i2c_w_mask(sd
, 0x2d, 0x04, 0x04);
4772 if (sd
->sensor
== SEN_OV6620
||
4773 sd
->sensor
== SEN_OV6630
||
4774 sd
->sensor
== SEN_OV66308AF
) {
4775 /* 20 fps -> 15 fps */
4776 i2c_w_mask(sd
, 0x2a, 0x80, 0x80);
4777 i2c_w(sd
, 0x2b, 0xa8);
4779 /* no framerate adj. */
4780 i2c_w_mask(sd
, 0x2a, 0x00, 0x80);
4787 static void setfreq(struct gspca_dev
*gspca_dev
, s32 val
)
4789 struct sd
*sd
= (struct sd
*) gspca_dev
;
4793 /* Ugly but necessary */
4794 if (sd
->bridge
== BRIDGE_W9968CF
)
4795 w9968cf_set_crop_window(sd
);
4798 static int sd_get_jcomp(struct gspca_dev
*gspca_dev
,
4799 struct v4l2_jpegcompression
*jcomp
)
4801 struct sd
*sd
= (struct sd
*) gspca_dev
;
4803 if (sd
->bridge
!= BRIDGE_W9968CF
)
4806 memset(jcomp
, 0, sizeof *jcomp
);
4807 jcomp
->quality
= v4l2_ctrl_g_ctrl(sd
->jpegqual
);
4808 jcomp
->jpeg_markers
= V4L2_JPEG_MARKER_DHT
| V4L2_JPEG_MARKER_DQT
|
4809 V4L2_JPEG_MARKER_DRI
;
4813 static int sd_set_jcomp(struct gspca_dev
*gspca_dev
,
4814 const struct v4l2_jpegcompression
*jcomp
)
4816 struct sd
*sd
= (struct sd
*) gspca_dev
;
4818 if (sd
->bridge
!= BRIDGE_W9968CF
)
4821 v4l2_ctrl_s_ctrl(sd
->jpegqual
, jcomp
->quality
);
4825 static int sd_g_volatile_ctrl(struct v4l2_ctrl
*ctrl
)
4827 struct gspca_dev
*gspca_dev
=
4828 container_of(ctrl
->handler
, struct gspca_dev
, ctrl_handler
);
4829 struct sd
*sd
= (struct sd
*)gspca_dev
;
4831 gspca_dev
->usb_err
= 0;
4834 case V4L2_CID_AUTOGAIN
:
4835 gspca_dev
->exposure
->val
= i2c_r(sd
, 0x10);
4841 static int sd_s_ctrl(struct v4l2_ctrl
*ctrl
)
4843 struct gspca_dev
*gspca_dev
=
4844 container_of(ctrl
->handler
, struct gspca_dev
, ctrl_handler
);
4845 struct sd
*sd
= (struct sd
*)gspca_dev
;
4847 gspca_dev
->usb_err
= 0;
4849 if (!gspca_dev
->streaming
)
4853 case V4L2_CID_BRIGHTNESS
:
4854 setbrightness(gspca_dev
, ctrl
->val
);
4856 case V4L2_CID_CONTRAST
:
4857 setcontrast(gspca_dev
, ctrl
->val
);
4859 case V4L2_CID_POWER_LINE_FREQUENCY
:
4860 setfreq(gspca_dev
, ctrl
->val
);
4862 case V4L2_CID_AUTOBRIGHTNESS
:
4864 setautobright(gspca_dev
, ctrl
->val
);
4865 if (!ctrl
->val
&& sd
->brightness
->is_new
)
4866 setbrightness(gspca_dev
, sd
->brightness
->val
);
4868 case V4L2_CID_SATURATION
:
4869 setcolors(gspca_dev
, ctrl
->val
);
4871 case V4L2_CID_HFLIP
:
4872 sethvflip(gspca_dev
, ctrl
->val
, sd
->vflip
->val
);
4874 case V4L2_CID_AUTOGAIN
:
4876 setautogain(gspca_dev
, ctrl
->val
);
4877 if (!ctrl
->val
&& gspca_dev
->exposure
->is_new
)
4878 setexposure(gspca_dev
, gspca_dev
->exposure
->val
);
4880 case V4L2_CID_JPEG_COMPRESSION_QUALITY
:
4881 return -EBUSY
; /* Should never happen, as we grab the ctrl */
4883 return gspca_dev
->usb_err
;
4886 static const struct v4l2_ctrl_ops sd_ctrl_ops
= {
4887 .g_volatile_ctrl
= sd_g_volatile_ctrl
,
4888 .s_ctrl
= sd_s_ctrl
,
4891 static int sd_init_controls(struct gspca_dev
*gspca_dev
)
4893 struct sd
*sd
= (struct sd
*)gspca_dev
;
4894 struct v4l2_ctrl_handler
*hdl
= &gspca_dev
->ctrl_handler
;
4896 gspca_dev
->vdev
.ctrl_handler
= hdl
;
4897 v4l2_ctrl_handler_init(hdl
, 10);
4898 if (valid_controls
[sd
->sensor
].has_brightness
)
4899 sd
->brightness
= v4l2_ctrl_new_std(hdl
, &sd_ctrl_ops
,
4900 V4L2_CID_BRIGHTNESS
, 0,
4901 sd
->sensor
== SEN_OV7660
? 6 : 255, 1,
4902 sd
->sensor
== SEN_OV7660
? 3 : 127);
4903 if (valid_controls
[sd
->sensor
].has_contrast
) {
4904 if (sd
->sensor
== SEN_OV7660
)
4905 v4l2_ctrl_new_std(hdl
, &sd_ctrl_ops
,
4906 V4L2_CID_CONTRAST
, 0, 6, 1, 3);
4908 v4l2_ctrl_new_std(hdl
, &sd_ctrl_ops
,
4909 V4L2_CID_CONTRAST
, 0, 255, 1,
4910 (sd
->sensor
== SEN_OV6630
||
4911 sd
->sensor
== SEN_OV66308AF
) ? 200 : 127);
4913 if (valid_controls
[sd
->sensor
].has_sat
)
4914 v4l2_ctrl_new_std(hdl
, &sd_ctrl_ops
,
4915 V4L2_CID_SATURATION
, 0,
4916 sd
->sensor
== SEN_OV7660
? 4 : 255, 1,
4917 sd
->sensor
== SEN_OV7660
? 2 : 127);
4918 if (valid_controls
[sd
->sensor
].has_exposure
)
4919 gspca_dev
->exposure
= v4l2_ctrl_new_std(hdl
, &sd_ctrl_ops
,
4920 V4L2_CID_EXPOSURE
, 0, 255, 1, 127);
4921 if (valid_controls
[sd
->sensor
].has_hvflip
) {
4922 sd
->hflip
= v4l2_ctrl_new_std(hdl
, &sd_ctrl_ops
,
4923 V4L2_CID_HFLIP
, 0, 1, 1, 0);
4924 sd
->vflip
= v4l2_ctrl_new_std(hdl
, &sd_ctrl_ops
,
4925 V4L2_CID_VFLIP
, 0, 1, 1, 0);
4927 if (valid_controls
[sd
->sensor
].has_autobright
)
4928 sd
->autobright
= v4l2_ctrl_new_std(hdl
, &sd_ctrl_ops
,
4929 V4L2_CID_AUTOBRIGHTNESS
, 0, 1, 1, 1);
4930 if (valid_controls
[sd
->sensor
].has_autogain
)
4931 gspca_dev
->autogain
= v4l2_ctrl_new_std(hdl
, &sd_ctrl_ops
,
4932 V4L2_CID_AUTOGAIN
, 0, 1, 1, 1);
4933 if (valid_controls
[sd
->sensor
].has_freq
) {
4934 if (sd
->sensor
== SEN_OV7670
)
4935 sd
->freq
= v4l2_ctrl_new_std_menu(hdl
, &sd_ctrl_ops
,
4936 V4L2_CID_POWER_LINE_FREQUENCY
,
4937 V4L2_CID_POWER_LINE_FREQUENCY_AUTO
, 0,
4938 V4L2_CID_POWER_LINE_FREQUENCY_AUTO
);
4940 sd
->freq
= v4l2_ctrl_new_std_menu(hdl
, &sd_ctrl_ops
,
4941 V4L2_CID_POWER_LINE_FREQUENCY
,
4942 V4L2_CID_POWER_LINE_FREQUENCY_60HZ
, 0, 0);
4944 if (sd
->bridge
== BRIDGE_W9968CF
)
4945 sd
->jpegqual
= v4l2_ctrl_new_std(hdl
, &sd_ctrl_ops
,
4946 V4L2_CID_JPEG_COMPRESSION_QUALITY
,
4947 QUALITY_MIN
, QUALITY_MAX
, 1, QUALITY_DEF
);
4950 gspca_err(gspca_dev
, "Could not initialize controls\n");
4953 if (gspca_dev
->autogain
)
4954 v4l2_ctrl_auto_cluster(3, &gspca_dev
->autogain
, 0, true);
4956 v4l2_ctrl_auto_cluster(2, &sd
->autobright
, 0, false);
4958 v4l2_ctrl_cluster(2, &sd
->hflip
);
4962 /* sub-driver description */
4963 static const struct sd_desc sd_desc
= {
4964 .name
= MODULE_NAME
,
4965 .config
= sd_config
,
4967 .init_controls
= sd_init_controls
,
4968 .isoc_init
= sd_isoc_init
,
4972 .pkt_scan
= sd_pkt_scan
,
4973 .dq_callback
= sd_reset_snapshot
,
4974 .get_jcomp
= sd_get_jcomp
,
4975 .set_jcomp
= sd_set_jcomp
,
4976 #if IS_ENABLED(CONFIG_INPUT)
4981 /* -- module initialisation -- */
4982 static const struct usb_device_id device_table
[] = {
4983 {USB_DEVICE(0x041e, 0x4003), .driver_info
= BRIDGE_W9968CF
},
4984 {USB_DEVICE(0x041e, 0x4052),
4985 .driver_info
= BRIDGE_OV519
| BRIDGE_INVERT_LED
},
4986 {USB_DEVICE(0x041e, 0x405f), .driver_info
= BRIDGE_OV519
},
4987 {USB_DEVICE(0x041e, 0x4060), .driver_info
= BRIDGE_OV519
},
4988 {USB_DEVICE(0x041e, 0x4061), .driver_info
= BRIDGE_OV519
},
4989 {USB_DEVICE(0x041e, 0x4064), .driver_info
= BRIDGE_OV519
},
4990 {USB_DEVICE(0x041e, 0x4067), .driver_info
= BRIDGE_OV519
},
4991 {USB_DEVICE(0x041e, 0x4068), .driver_info
= BRIDGE_OV519
},
4992 {USB_DEVICE(0x045e, 0x028c),
4993 .driver_info
= BRIDGE_OV519
| BRIDGE_INVERT_LED
},
4994 {USB_DEVICE(0x054c, 0x0154), .driver_info
= BRIDGE_OV519
},
4995 {USB_DEVICE(0x054c, 0x0155), .driver_info
= BRIDGE_OV519
},
4996 {USB_DEVICE(0x05a9, 0x0511), .driver_info
= BRIDGE_OV511
},
4997 {USB_DEVICE(0x05a9, 0x0518), .driver_info
= BRIDGE_OV518
},
4998 {USB_DEVICE(0x05a9, 0x0519),
4999 .driver_info
= BRIDGE_OV519
| BRIDGE_INVERT_LED
},
5000 {USB_DEVICE(0x05a9, 0x0530),
5001 .driver_info
= BRIDGE_OV519
| BRIDGE_INVERT_LED
},
5002 {USB_DEVICE(0x05a9, 0x2800), .driver_info
= BRIDGE_OVFX2
},
5003 {USB_DEVICE(0x05a9, 0x4519), .driver_info
= BRIDGE_OV519
},
5004 {USB_DEVICE(0x05a9, 0x8519), .driver_info
= BRIDGE_OV519
},
5005 {USB_DEVICE(0x05a9, 0xa511), .driver_info
= BRIDGE_OV511PLUS
},
5006 {USB_DEVICE(0x05a9, 0xa518), .driver_info
= BRIDGE_OV518PLUS
},
5007 {USB_DEVICE(0x0813, 0x0002), .driver_info
= BRIDGE_OV511PLUS
},
5008 {USB_DEVICE(0x0b62, 0x0059), .driver_info
= BRIDGE_OVFX2
},
5009 {USB_DEVICE(0x0e96, 0xc001), .driver_info
= BRIDGE_OVFX2
},
5010 {USB_DEVICE(0x1046, 0x9967), .driver_info
= BRIDGE_W9968CF
},
5011 {USB_DEVICE(0x8020, 0xef04), .driver_info
= BRIDGE_OVFX2
},
5015 MODULE_DEVICE_TABLE(usb
, device_table
);
5017 /* -- device connect -- */
5018 static int sd_probe(struct usb_interface
*intf
,
5019 const struct usb_device_id
*id
)
5021 return gspca_dev_probe(intf
, id
, &sd_desc
, sizeof(struct sd
),
5025 static struct usb_driver sd_driver
= {
5026 .name
= MODULE_NAME
,
5027 .id_table
= device_table
,
5029 .disconnect
= gspca_disconnect
,
5031 .suspend
= gspca_suspend
,
5032 .resume
= gspca_resume
,
5033 .reset_resume
= gspca_resume
,
5037 module_usb_driver(sd_driver
);
5039 module_param(frame_rate
, int, 0644);
5040 MODULE_PARM_DESC(frame_rate
, "Frame rate (5, 10, 15, 20 or 30 fps)");