40 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
42 #define MODULE_NAME "ov519"
44 #include <linux/input.h>
52 MODULE_AUTHOR(
"Jean-Francois Moine <http://moinejf.free.fr>");
57 static int frame_rate;
61 static int i2c_detect_tries = 10;
81 #define BRIDGE_OV511 0
82 #define BRIDGE_OV511PLUS 1
83 #define BRIDGE_OV518 2
84 #define BRIDGE_OV518PLUS 3
85 #define BRIDGE_OV519 4
86 #define BRIDGE_OVFX2 5
87 #define BRIDGE_W9968CF 6
91 #define BRIDGE_INVERT_LED 8
99 #define QUALITY_MIN 50
100 #define QUALITY_MAX 70
101 #define QUALITY_DEF 50
154 static const struct ctrl_valid valid_controls[] = {
253 .sizeimage = 320 * 240 * 3 / 8 + 590,
258 .sizeimage = 640 * 480 * 3 / 8 + 590,
265 .sizeimage = 160 * 120 * 3 / 8 + 590,
270 .sizeimage = 176 * 144 * 3 / 8 + 590,
275 .sizeimage = 320 * 240 * 3 / 8 + 590,
280 .sizeimage = 352 * 288 * 3 / 8 + 590,
294 .sizeimage = 320 * 240 * 3,
299 .sizeimage = 640 * 480 * 2,
316 .sizeimage = 320 * 240 * 3,
321 .sizeimage = 352 * 288 * 3,
329 .sizeimage = 320 * 240 * 3,
334 .sizeimage = 640 * 480 * 2,
351 .sizeimage = 320 * 240 * 3,
356 .sizeimage = 352 * 288 * 3,
364 .sizeimage = 320 * 240,
369 .sizeimage = 640 * 480,
376 .sizeimage = 160 * 120,
381 .sizeimage = 176 * 144,
386 .sizeimage = 320 * 240,
391 .sizeimage = 352 * 288,
398 .sizeimage = 800 * 600,
402 .bytesperline = 1600,
403 .sizeimage = 1600 * 1200,
409 .sizeimage = 640 * 480,
414 .sizeimage = 800 * 600,
418 .bytesperline = 1024,
419 .sizeimage = 1024 * 768,
423 .bytesperline = 1600,
424 .sizeimage = 1600 * 1200,
428 .bytesperline = 2048,
429 .sizeimage = 2048 * 1536,
436 .sizeimage = 640 * 480,
440 .bytesperline = 1280,
441 .sizeimage = 1280 * 1024,
446 #define R51x_FIFO_PSIZE 0x30
447 #define R51x_SYS_RESET 0x50
449 #define OV511_RESET_OMNICE 0x08
450 #define R51x_SYS_INIT 0x53
451 #define R51x_SYS_SNAP 0x52
452 #define R51x_SYS_CUST_ID 0x5f
453 #define R51x_COMP_LUT_BEGIN 0x80
456 #define R511_CAM_DELAY 0x10
457 #define R511_CAM_EDGE 0x11
458 #define R511_CAM_PXCNT 0x12
459 #define R511_CAM_LNCNT 0x13
460 #define R511_CAM_PXDIV 0x14
461 #define R511_CAM_LNDIV 0x15
462 #define R511_CAM_UV_EN 0x16
463 #define R511_CAM_LINE_MODE 0x17
464 #define R511_CAM_OPTS 0x18
466 #define R511_SNAP_FRAME 0x19
467 #define R511_SNAP_PXCNT 0x1a
468 #define R511_SNAP_LNCNT 0x1b
469 #define R511_SNAP_PXDIV 0x1c
470 #define R511_SNAP_LNDIV 0x1d
471 #define R511_SNAP_UV_EN 0x1e
472 #define R511_SNAP_OPTS 0x1f
474 #define R511_DRAM_FLOW_CTL 0x20
475 #define R511_FIFO_OPTS 0x31
476 #define R511_I2C_CTL 0x40
477 #define R511_SYS_LED_CTL 0x55
478 #define R511_COMP_EN 0x78
479 #define R511_COMP_LUT_EN 0x79
482 #define R518_GPIO_OUT 0x56
483 #define R518_GPIO_CTL 0x57
486 #define OV519_R10_H_SIZE 0x10
487 #define OV519_R11_V_SIZE 0x11
488 #define OV519_R12_X_OFFSETL 0x12
489 #define OV519_R13_X_OFFSETH 0x13
490 #define OV519_R14_Y_OFFSETL 0x14
491 #define OV519_R15_Y_OFFSETH 0x15
492 #define OV519_R16_DIVIDER 0x16
493 #define OV519_R20_DFR 0x20
494 #define OV519_R25_FORMAT 0x25
497 #define OV519_R51_RESET1 0x51
498 #define OV519_R54_EN_CLK1 0x54
499 #define OV519_R57_SNAPSHOT 0x57
501 #define OV519_GPIO_DATA_OUT0 0x71
502 #define OV519_GPIO_IO_CTRL0 0x72
529 #define OVFX2_BULK_SIZE (13 * 4096)
532 #define R51x_I2C_W_SID 0x41
533 #define R51x_I2C_SADDR_3 0x42
534 #define R51x_I2C_SADDR_2 0x43
535 #define R51x_I2C_R_SID 0x44
536 #define R51x_I2C_DATA 0x45
537 #define R518_I2C_CTL 0x47
538 #define OVFX2_I2C_ADDR 0x00
541 #define OV7xx0_SID 0x42
542 #define OV_HIRES_SID 0x60
543 #define OV8xx0_SID 0xa0
544 #define OV6xx0_SID 0xc0
547 #define OV7610_REG_GAIN 0x00
548 #define OV7610_REG_BLUE 0x01
549 #define OV7610_REG_RED 0x02
550 #define OV7610_REG_SAT 0x03
551 #define OV8610_REG_HUE 0x04
552 #define OV7610_REG_CNT 0x05
553 #define OV7610_REG_BRT 0x06
554 #define OV7610_REG_COM_C 0x14
555 #define OV7610_REG_ID_HIGH 0x1c
556 #define OV7610_REG_ID_LOW 0x1d
557 #define OV7610_REG_COM_I 0x29
560 #define OV7670_R00_GAIN 0x00
561 #define OV7670_R01_BLUE 0x01
562 #define OV7670_R02_RED 0x02
563 #define OV7670_R03_VREF 0x03
564 #define OV7670_R04_COM1 0x04
566 #define OV7670_R0C_COM3 0x0c
567 #define OV7670_R0D_COM4 0x0d
568 #define OV7670_R0E_COM5 0x0e
569 #define OV7670_R0F_COM6 0x0f
570 #define OV7670_R10_AECH 0x10
571 #define OV7670_R11_CLKRC 0x11
572 #define OV7670_R12_COM7 0x12
573 #define OV7670_COM7_FMT_VGA 0x00
575 #define OV7670_COM7_FMT_QVGA 0x10
576 #define OV7670_COM7_FMT_MASK 0x38
577 #define OV7670_COM7_RESET 0x80
578 #define OV7670_R13_COM8 0x13
579 #define OV7670_COM8_AEC 0x01
580 #define OV7670_COM8_AWB 0x02
581 #define OV7670_COM8_AGC 0x04
582 #define OV7670_COM8_BFILT 0x20
583 #define OV7670_COM8_AECSTEP 0x40
584 #define OV7670_COM8_FASTAEC 0x80
585 #define OV7670_R14_COM9 0x14
586 #define OV7670_R15_COM10 0x15
587 #define OV7670_R17_HSTART 0x17
588 #define OV7670_R18_HSTOP 0x18
589 #define OV7670_R19_VSTART 0x19
590 #define OV7670_R1A_VSTOP 0x1a
591 #define OV7670_R1E_MVFP 0x1e
592 #define OV7670_MVFP_VFLIP 0x10
593 #define OV7670_MVFP_MIRROR 0x20
594 #define OV7670_R24_AEW 0x24
595 #define OV7670_R25_AEB 0x25
596 #define OV7670_R26_VPT 0x26
597 #define OV7670_R32_HREF 0x32
598 #define OV7670_R3A_TSLB 0x3a
599 #define OV7670_R3B_COM11 0x3b
600 #define OV7670_COM11_EXP 0x02
601 #define OV7670_COM11_HZAUTO 0x10
602 #define OV7670_R3C_COM12 0x3c
603 #define OV7670_R3D_COM13 0x3d
604 #define OV7670_COM13_GAMMA 0x80
605 #define OV7670_COM13_UVSAT 0x40
606 #define OV7670_R3E_COM14 0x3e
607 #define OV7670_R3F_EDGE 0x3f
608 #define OV7670_R40_COM15 0x40
610 #define OV7670_R41_COM16 0x41
611 #define OV7670_COM16_AWBGAIN 0x08
613 #define OV7670_R55_BRIGHT 0x55
614 #define OV7670_R56_CONTRAS 0x56
615 #define OV7670_R69_GFIX 0x69
617 #define OV7670_R9F_HAECC1 0x9f
618 #define OV7670_RA0_HAECC2 0xa0
619 #define OV7670_RA5_BD50MAX 0xa5
620 #define OV7670_RA6_HAECC3 0xa6
621 #define OV7670_RA7_HAECC4 0xa7
622 #define OV7670_RA8_HAECC5 0xa8
623 #define OV7670_RA9_HAECC6 0xa9
624 #define OV7670_RAA_HAECC7 0xaa
625 #define OV7670_RAB_BD60MAX 0xab
1583 static const struct ov_regvals init_519_ov7660[] = {
2027 static unsigned char ov7670_abs_to_sm(
unsigned char v)
2031 return (128 - v) | 0x80;
2051 PDEBUG(D_USBO,
"SET %02x %04x %04x",
2057 value, index,
NULL, 0, 500);
2063 PDEBUG(D_USBO,
"SET %02x 0000 %04x %02x",
2074 pr_err(
"reg_w %02x failed %d\n", index, ret);
2082 static int reg_r(
struct sd *sd,
u16 index)
2106 0, index, sd->
gspca_dev.usb_buf, 1, 500);
2110 PDEBUG(D_USBI,
"GET %02x 0000 %04x %02x",
2113 pr_err(
"reg_r %02x failed %d\n", index, ret);
2121 static int reg_r8(
struct sd *sd,
2133 0, index, sd->
gspca_dev.usb_buf, 8, 500);
2138 pr_err(
"reg_r8 %02x failed %d\n", index, ret);
2151 static void reg_w_mask(
struct sd *sd,
2161 ret = reg_r(sd, index);
2165 oldval = ret & ~mask;
2168 reg_w(sd, index, value);
2175 static void ov518_reg_w32(
struct sd *sd,
u16 index,
u32 value,
int n)
2191 pr_err(
"reg_w32 %02x failed %d\n", index, ret);
2196 static void ov511_i2c_w(
struct sd *sd,
u8 reg,
u8 value)
2200 PDEBUG(D_USBO,
"ov511_i2c_w %02x %02x", reg, value);
2203 for (retries = 6; ; ) {
2215 }
while (rc > 0 && ((rc & 1) == 0));
2222 if (--retries < 0) {
2223 PDEBUG(D_USBO,
"i2c write retries exhausted");
2229 static int ov511_i2c_r(
struct sd *sd,
u8 reg)
2234 for (retries = 6; ; ) {
2243 }
while (rc > 0 && ((rc & 1) == 0));
2254 if (--retries < 0) {
2255 PDEBUG(D_USBI,
"i2c write retries exhausted");
2261 for (retries = 6; ; ) {
2267 }
while (rc > 0 && ((rc & 1) == 0));
2278 if (--retries < 0) {
2279 PDEBUG(D_USBI,
"i2c read retries exhausted");
2286 PDEBUG(D_USBI,
"ov511_i2c_r %02x %02x", reg, value);
2299 static void ov518_i2c_w(
struct sd *sd,
2303 PDEBUG(D_USBO,
"ov518_i2c_w %02x %02x", reg, value);
2326 static int ov518_i2c_r(
struct sd *sd,
u8 reg)
2342 PDEBUG(D_USBI,
"ov518_i2c_r %02x %02x", reg, value);
2346 static void ovfx2_i2c_w(
struct sd *sd,
u8 reg,
u8 value)
2360 pr_err(
"ovfx2_i2c_w %02x failed %d\n", reg, ret);
2364 PDEBUG(D_USBO,
"ovfx2_i2c_w %02x %02x", reg, value);
2367 static int ovfx2_i2c_r(
struct sd *sd,
u8 reg)
2382 PDEBUG(D_USBI,
"ovfx2_i2c_r %02x %02x", reg, ret);
2384 pr_err(
"ovfx2_i2c_r %02x failed %d\n", reg, ret);
2391 static void i2c_w(
struct sd *sd,
u8 reg,
u8 value)
2399 ov511_i2c_w(sd, reg, value);
2404 ov518_i2c_w(sd, reg, value);
2407 ovfx2_i2c_w(sd, reg, value);
2410 w9968cf_i2c_w(sd, reg, value);
2416 if (reg == 0x12 && (value & 0x80))
2424 static int i2c_r(
struct sd *sd,
u8 reg)
2434 ret = ov511_i2c_r(sd, reg);
2439 ret = ov518_i2c_r(sd, reg);
2442 ret = ovfx2_i2c_r(sd, reg);
2445 ret = w9968cf_i2c_r(sd, reg);
2460 static void i2c_w_mask(
struct sd *sd,
2469 rc = i2c_r(sd, reg);
2472 oldval = rc & ~mask;
2474 i2c_w(sd, reg, value);
2479 static inline void ov51x_stop(
struct sd *sd)
2481 PDEBUG(D_STREAM,
"stopping");
2495 reg_w(sd, 0x22, 0x00);
2498 reg_w_mask(sd, 0x0f, 0x00, 0x02);
2501 reg_w(sd, 0x3c, 0x0a05);
2508 static inline void ov51x_restart(
struct sd *sd)
2510 PDEBUG(D_STREAM,
"restarting");
2523 reg_w(sd, 0x2f, 0x80);
2529 reg_w(sd, 0x22, 0x1d);
2532 reg_w_mask(sd, 0x0f, 0x02, 0x02);
2535 reg_w(sd, 0x3c, 0x8a05);
2540 static void ov51x_set_slave_ids(
struct sd *sd,
u8 slave);
2545 static int init_ov_sensor(
struct sd *sd,
u8 slave)
2549 ov51x_set_slave_ids(sd, slave);
2552 i2c_w(sd, 0x12, 0x80);
2557 for (i = 0; i < i2c_detect_tries; i++) {
2560 PDEBUG(D_PROBE,
"I2C synced in %d attempt(s)", i);
2565 i2c_w(sd, 0x12, 0x80);
2571 if (i2c_r(sd, 0x00) < 0)
2582 static void ov51x_set_slave_ids(
struct sd *sd,
2598 static void write_regvals(
struct sd *sd,
2603 reg_w(sd, regvals->
reg, regvals->
val);
2608 static void write_i2c_regvals(
struct sd *sd,
2613 i2c_w(sd, regvals->
reg, regvals->
val);
2625 static void ov_hires_configure(
struct sd *sd)
2630 pr_err(
"error hires sensors only supported with ovfx2\n");
2634 PDEBUG(D_PROBE,
"starting ov hires configuration");
2637 high = i2c_r(sd, 0x0a);
2638 low = i2c_r(sd, 0x0b);
2644 PDEBUG(D_PROBE,
"Sensor is a OV2610");
2648 PDEBUG(D_PROBE,
"Sensor is a OV2610AE");
2652 PDEBUG(D_PROBE,
"Sensor is a OV9600");
2658 if ((low & 0x0f) == 0x00) {
2659 PDEBUG(D_PROBE,
"Sensor is a OV3610");
2665 pr_err(
"Error unknown sensor type: %02x%02x\n", high, low);
2671 static void ov8xx0_configure(
struct sd *sd)
2675 PDEBUG(D_PROBE,
"starting ov8xx0 configuration");
2686 pr_err(
"Unknown image sensor version: %d\n", rc & 3);
2692 static void ov7xx0_configure(
struct sd *sd)
2696 PDEBUG(D_PROBE,
"starting OV7xx0 configuration");
2704 pr_err(
"Error detecting sensor type\n");
2707 if ((rc & 3) == 3) {
2709 high = i2c_r(sd, 0x0a);
2710 low = i2c_r(sd, 0x0b);
2712 if (high == 0x76 && (low & 0xf0) == 0x70) {
2713 PDEBUG(D_PROBE,
"Sensor is an OV76%02x", low);
2716 PDEBUG(D_PROBE,
"Sensor is an OV7610");
2719 }
else if ((rc & 3) == 1) {
2721 if (i2c_r(sd, 0x15) & 1) {
2722 PDEBUG(D_PROBE,
"Sensor is an OV7620AE");
2725 PDEBUG(D_PROBE,
"Sensor is an OV76BE");
2728 }
else if ((rc & 3) == 0) {
2730 high = i2c_r(sd, 0x0a);
2732 pr_err(
"Error detecting camera chip PID\n");
2735 low = i2c_r(sd, 0x0b);
2737 pr_err(
"Error detecting camera chip VER\n");
2743 pr_err(
"Sensor is an OV7630/OV7635\n");
2744 pr_err(
"7630 is not supported by this driver\n");
2747 PDEBUG(D_PROBE,
"Sensor is an OV7645");
2751 PDEBUG(D_PROBE,
"Sensor is an OV7645B");
2755 PDEBUG(D_PROBE,
"Sensor is an OV7648");
2759 PDEBUG(D_PROBE,
"Sensor is a OV7660");
2763 pr_err(
"Unknown sensor: 0x76%02x\n", low);
2767 PDEBUG(D_PROBE,
"Sensor is an OV7620");
2771 pr_err(
"Unknown image sensor version: %d\n", rc & 3);
2776 static void ov6xx0_configure(
struct sd *sd)
2779 PDEBUG(D_PROBE,
"starting OV6xx0 configuration");
2784 pr_err(
"Error detecting sensor type\n");
2794 pr_warn(
"WARNING: Sensor is an OV66308. Your camera may have been misdetected in previous driver versions.\n");
2798 PDEBUG(D_PROBE,
"Sensor is an OV6620");
2802 PDEBUG(D_PROBE,
"Sensor is an OV66308AE");
2806 PDEBUG(D_PROBE,
"Sensor is an OV66308AF");
2810 pr_warn(
"WARNING: Sensor is an OV66307. Your camera may have been misdetected in previous driver versions.\n");
2813 pr_err(
"FATAL: Unknown sensor version: 0x%02x\n", rc);
2822 static void ov51x_led_control(
struct sd *sd,
int on)
2844 struct sd *sd = (
struct sd *) gspca_dev;
2872 static void ov51x_upload_quan_tables(
struct sd *sd)
2874 const unsigned char yQuanTable511[] = {
2875 0, 1, 1, 2, 2, 3, 3, 4,
2876 1, 1, 1, 2, 2, 3, 4, 4,
2877 1, 1, 2, 2, 3, 4, 4, 4,
2878 2, 2, 2, 3, 4, 4, 4, 4,
2879 2, 2, 3, 4, 4, 5, 5, 5,
2880 3, 3, 4, 4, 5, 5, 5, 5,
2881 3, 4, 4, 4, 5, 5, 5, 5,
2882 4, 4, 4, 4, 5, 5, 5, 5
2885 const unsigned char uvQuanTable511[] = {
2886 0, 2, 2, 3, 4, 4, 4, 4,
2887 2, 2, 2, 4, 4, 4, 4, 4,
2888 2, 2, 3, 4, 4, 4, 4, 4,
2889 3, 4, 4, 4, 4, 4, 4, 4,
2890 4, 4, 4, 4, 4, 4, 4, 4,
2891 4, 4, 4, 4, 4, 4, 4, 4,
2892 4, 4, 4, 4, 4, 4, 4, 4,
2893 4, 4, 4, 4, 4, 4, 4, 4
2897 const unsigned char yQuanTable518[] = {
2898 5, 4, 5, 6, 6, 7, 7, 7,
2899 5, 5, 5, 5, 6, 7, 7, 7,
2900 6, 6, 6, 6, 7, 7, 7, 8,
2901 7, 7, 6, 7, 7, 7, 8, 8
2903 const unsigned char uvQuanTable518[] = {
2904 6, 6, 6, 7, 7, 7, 7, 7,
2905 6, 6, 6, 7, 7, 7, 7, 7,
2906 6, 6, 6, 7, 7, 7, 7, 8,
2907 7, 7, 7, 7, 7, 7, 8, 8
2910 const unsigned char *pYTable, *pUVTable;
2911 unsigned char val0, val1;
2914 PDEBUG(D_PROBE,
"Uploading quantization tables");
2917 pYTable = yQuanTable511;
2918 pUVTable = uvQuanTable511;
2921 pYTable = yQuanTable518;
2922 pUVTable = uvQuanTable518;
2926 for (i = 0; i <
size; i++) {
2932 reg_w(sd, reg, val0);
2939 reg_w(sd, reg + size, val0);
2946 static void ov511_configure(
struct gspca_dev *gspca_dev)
2948 struct sd *sd = (
struct sd *) gspca_dev;
2994 write_regvals(sd, init_511,
ARRAY_SIZE(init_511));
2998 write_regvals(sd, norm_511,
ARRAY_SIZE(norm_511));
3001 write_regvals(sd, norm_511_p,
ARRAY_SIZE(norm_511_p));
3006 write_regvals(sd, compress_511,
ARRAY_SIZE(compress_511));
3008 ov51x_upload_quan_tables(sd);
3012 static void ov518_configure(
struct gspca_dev *gspca_dev)
3014 struct sd *sd = (
struct sd *) gspca_dev;
3061 PDEBUG(D_PROBE,
"Device revision %d",
3064 write_regvals(sd, init_518,
ARRAY_SIZE(init_518));
3071 write_regvals(sd, norm_518,
ARRAY_SIZE(norm_518));
3074 write_regvals(sd, norm_518_p,
ARRAY_SIZE(norm_518_p));
3078 ov51x_upload_quan_tables(sd);
3080 reg_w(sd, 0x2f, 0x80);
3083 static void ov519_configure(
struct sd *sd)
3085 static const struct ov_regvals init_519[] = {
3101 write_regvals(sd, init_519,
ARRAY_SIZE(init_519));
3104 static void ovfx2_configure(
struct sd *sd)
3106 static const struct ov_regvals init_fx2[] = {
3118 write_regvals(sd, init_fx2,
ARRAY_SIZE(init_fx2));
3123 static void ov519_set_mode(
struct sd *sd)
3125 static const struct ov_regvals bridge_ov7660[2][10] = {
3126 {{0x10, 0x14}, {0x11, 0x1e}, {0x12, 0x00}, {0x13, 0x00},
3127 {0x14, 0x00}, {0x15, 0x00}, {0x16, 0x00}, {0x20, 0x0c},
3128 {0x25, 0x01}, {0x26, 0x00}},
3129 {{0x10, 0x28}, {0x11, 0x3c}, {0x12, 0x00}, {0x13, 0x00},
3130 {0x14, 0x00}, {0x15, 0x00}, {0x16, 0x00}, {0x20, 0x0c},
3131 {0x25, 0x03}, {0x26, 0x00}}
3134 {{0x12, 0x00}, {0x24, 0x00}, {0x0c, 0x0c}},
3135 {{0x12, 0x00}, {0x04, 0x00}, {0x0c, 0x00}}
3150 write_regvals(sd, bridge_ov7660[sd->
gspca_dev.curr_mode],
3152 write_i2c_regvals(sd, sensor_ov7660[sd->
gspca_dev.curr_mode],
3154 write_i2c_regvals(sd, sensor_ov7660_2,
3160 static void ov519_set_fr(
struct sd *sd)
3169 static const u8 fr_tb[2][6][3] = {
3170 {{0x04, 0xff, 0x00},
3175 {0x04, 0x01, 0x00}},
3176 {{0x0c, 0xff, 0x00},
3181 {0x04, 0x1b, 0x01}},
3198 reg_w(sd, 0xa4, fr_tb[sd->
gspca_dev.curr_mode][fr][0]);
3199 reg_w(sd, 0x23, fr_tb[sd->
gspca_dev.curr_mode][fr][1]);
3200 clock = fr_tb[sd->
gspca_dev.curr_mode][fr][2];
3206 static void setautogain(
struct gspca_dev *gspca_dev,
s32 val)
3208 struct sd *sd = (
struct sd *) gspca_dev;
3210 i2c_w_mask(sd, 0x13, val ? 0x05 : 0x00, 0x05);
3214 static int sd_config(
struct gspca_dev *gspca_dev,
3217 struct sd *sd = (
struct sd *) gspca_dev;
3257 static int sd_init(
struct gspca_dev *gspca_dev)
3259 struct sd *sd = (
struct sd *) gspca_dev;
3260 struct cam *cam = &gspca_dev->
cam;
3265 ov511_configure(gspca_dev);
3269 ov518_configure(gspca_dev);
3272 ov519_configure(sd);
3275 ovfx2_configure(sd);
3278 w9968cf_configure(sd);
3289 ov7xx0_configure(sd);
3292 }
else if (init_ov_sensor(sd,
OV6xx0_SID) >= 0) {
3293 ov6xx0_configure(sd);
3296 }
else if (init_ov_sensor(sd,
OV8xx0_SID) >= 0) {
3297 ov8xx0_configure(sd);
3301 ov_hires_configure(sd);
3303 pr_err(
"Can't determine sensor slave IDs\n");
3310 ov51x_led_control(sd, 0);
3368 write_i2c_regvals(sd, norm_2610,
ARRAY_SIZE(norm_2610));
3371 i2c_w_mask(sd, 0x13, 0x27, 0x27);
3374 write_i2c_regvals(sd, norm_2610ae,
ARRAY_SIZE(norm_2610ae));
3377 i2c_w_mask(sd, 0x13, 0x05, 0x05);
3380 write_i2c_regvals(sd, norm_3620b,
ARRAY_SIZE(norm_3620b));
3383 i2c_w_mask(sd, 0x13, 0x27, 0x27);
3386 write_i2c_regvals(sd, norm_6x20,
ARRAY_SIZE(norm_6x20));
3390 write_i2c_regvals(sd, norm_6x30,
ARRAY_SIZE(norm_6x30));
3395 write_i2c_regvals(sd, norm_7610,
ARRAY_SIZE(norm_7610));
3396 i2c_w_mask(sd, 0x0e, 0x00, 0x40);
3400 write_i2c_regvals(sd, norm_7620,
ARRAY_SIZE(norm_7620));
3404 write_i2c_regvals(sd, norm_7640,
ARRAY_SIZE(norm_7640));
3410 write_regvals(sd, init_519_ov7660,
3412 write_i2c_regvals(sd, norm_7660,
ARRAY_SIZE(norm_7660));
3416 sd_reset_snapshot(gspca_dev);
3419 ov51x_led_control(sd, 0);
3422 write_i2c_regvals(sd, norm_7670,
ARRAY_SIZE(norm_7670));
3425 write_i2c_regvals(sd, norm_8610,
ARRAY_SIZE(norm_8610));
3428 write_i2c_regvals(sd, norm_9600,
ARRAY_SIZE(norm_9600));
3441 static int sd_isoc_init(
struct gspca_dev *gspca_dev)
3443 struct sd *sd = (
struct sd *) gspca_dev;
3447 if (gspca_dev->
width != 800)
3450 gspca_dev->
cam.bulk_size = 7 * 4096;
3460 static void ov511_mode_init_regs(
struct sd *sd)
3462 int hsegs, vsegs, packet_size,
fps, needed;
3464 struct usb_host_interface *alt;
3470 pr_err(
"Couldn't get altsetting\n");
3475 packet_size =
le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize);
3486 vsegs = (sd->
gspca_dev.height >> 3) - 1;
3561 fps = (interlaced ? 60 : 30) / (sd->
clockdiv + 1) + 1;
3564 if (needed > 1000 * packet_size) {
3584 static void ov518_mode_init_regs(
struct sd *sd)
3586 int hsegs, vsegs, packet_size;
3587 struct usb_host_interface *alt;
3593 pr_err(
"Couldn't get altsetting\n");
3598 packet_size =
le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize);
3613 reg_w_mask(sd, 0x20, 0x08, 0x08);
3616 reg_w_mask(sd, 0x28, 0x80, 0xf0);
3617 reg_w_mask(sd, 0x38, 0x80, 0xf0);
3619 reg_w(sd, 0x28, 0x80);
3620 reg_w(sd, 0x38, 0x80);
3626 reg_w(sd, 0x29, hsegs);
3627 reg_w(sd, 0x2a, vsegs);
3629 reg_w(sd, 0x39, hsegs);
3630 reg_w(sd, 0x3a, vsegs);
3633 reg_w(sd, 0x2f, 0x80);
3640 reg_w(sd, 0x51, 0x04);
3641 reg_w(sd, 0x22, 0x18);
3642 reg_w(sd, 0x23, 0xff);
3648 reg_w(sd, 0x20, 0x00);
3649 reg_w(sd, 0x21, 0x19);
3651 reg_w(sd, 0x20, 0x60);
3652 reg_w(sd, 0x21, 0x1f);
3656 reg_w(sd, 0x20, 0x00);
3657 reg_w(sd, 0x21, 0x19);
3660 reg_w(sd, 0x21, 0x19);
3663 reg_w(sd, 0x71, 0x17);
3667 i2c_w(sd, 0x54, 0x23);
3669 reg_w(sd, 0x2f, 0x80);
3672 reg_w(sd, 0x24, 0x94);
3673 reg_w(sd, 0x25, 0x90);
3674 ov518_reg_w32(sd, 0xc4, 400, 2);
3675 ov518_reg_w32(sd, 0xc6, 540, 2);
3676 ov518_reg_w32(sd, 0xc7, 540, 2);
3677 ov518_reg_w32(sd, 0xc8, 108, 2);
3678 ov518_reg_w32(sd, 0xca, 131098, 3);
3679 ov518_reg_w32(sd, 0xcb, 532, 2);
3680 ov518_reg_w32(sd, 0xcc, 2400, 2);
3681 ov518_reg_w32(sd, 0xcd, 32, 2);
3682 ov518_reg_w32(sd, 0xce, 608, 2);
3684 reg_w(sd, 0x24, 0x9f);
3685 reg_w(sd, 0x25, 0x90);
3686 ov518_reg_w32(sd, 0xc4, 400, 2);
3687 ov518_reg_w32(sd, 0xc6, 381, 2);
3688 ov518_reg_w32(sd, 0xc7, 381, 2);
3689 ov518_reg_w32(sd, 0xc8, 128, 2);
3690 ov518_reg_w32(sd, 0xca, 183331, 3);
3691 ov518_reg_w32(sd, 0xcb, 746, 2);
3692 ov518_reg_w32(sd, 0xcc, 1750, 2);
3693 ov518_reg_w32(sd, 0xcd, 45, 2);
3694 ov518_reg_w32(sd, 0xce, 851, 2);
3697 reg_w(sd, 0x2f, 0x80);
3707 static void ov519_mode_init_regs(
struct sd *sd)
3709 static const struct ov_regvals mode_init_519_ov7670[] = {
3732 static const struct ov_regvals mode_init_519[] = {
3756 write_regvals(sd, mode_init_519,
ARRAY_SIZE(mode_init_519));
3766 write_regvals(sd, mode_init_519_ov7670,
3786 reg_w(sd, 0x26, 0x00);
3800 reg_w(sd, 0xa4, 0x0c);
3801 reg_w(sd, 0x23, 0xff);
3804 reg_w(sd, 0xa4, 0x0c);
3805 reg_w(sd, 0x23, 0x1f);
3808 reg_w(sd, 0xa4, 0x0c);
3809 reg_w(sd, 0x23, 0x1b);
3812 reg_w(sd, 0xa4, 0x04);
3813 reg_w(sd, 0x23, 0xff);
3817 reg_w(sd, 0xa4, 0x04);
3818 reg_w(sd, 0x23, 0x1f);
3822 reg_w(sd, 0xa4, 0x04);
3823 reg_w(sd, 0x23, 0x1b);
3832 reg_w(sd, 0xa4, 0x06);
3833 reg_w(sd, 0x23, 0xff);
3836 reg_w(sd, 0xa4, 0x06);
3837 reg_w(sd, 0x23, 0x1f);
3840 reg_w(sd, 0xa4, 0x06);
3841 reg_w(sd, 0x23, 0x1b);
3846 PDEBUG(D_STREAM,
"Setting framerate to %d fps",
3848 reg_w(sd, 0xa4, 0x10);
3851 reg_w(sd, 0x23, 0xff);
3854 reg_w(sd, 0x23, 0x1b);
3858 reg_w(sd, 0x23, 0xff);
3866 static void mode_init_ov_sensor_regs(
struct sd *sd)
3868 struct gspca_dev *gspca_dev;
3869 int qvga, xstart, xend, ystart, yend;
3873 qvga = gspca_dev->
cam.cam_mode[gspca_dev->
curr_mode].priv & 1;
3878 i2c_w_mask(sd, 0x14, qvga ? 0x20 : 0x00, 0x20);
3879 i2c_w_mask(sd, 0x28, qvga ? 0x00 : 0x20, 0x20);
3880 i2c_w(sd, 0x24, qvga ? 0x20 : 0x3a);
3881 i2c_w(sd, 0x25, qvga ? 0x30 : 0x60);
3882 i2c_w_mask(sd, 0x2d, qvga ? 0x40 : 0x00, 0x40);
3883 i2c_w_mask(sd, 0x67, qvga ? 0xf0 : 0x90, 0xf0);
3884 i2c_w_mask(sd, 0x74, qvga ? 0x20 : 0x00, 0x20);
3902 i2c_w(sd, 0x12, qvga ? 0x60 : 0x20);
3907 xstart = (1040 - gspca_dev->
width) / 2 + (0x1f << 4);
3908 ystart = (776 - gspca_dev->
height) / 2;
3910 xstart = (2076 - gspca_dev->
width) / 2 + (0x10 << 4);
3911 ystart = (1544 - gspca_dev->
height) / 2;
3913 xend = xstart + gspca_dev->
width;
3914 yend = ystart + gspca_dev->
height;
3917 i2c_w_mask(sd, 0x12, qvga ? 0x40 : 0x00, 0xf0);
3918 i2c_w_mask(sd, 0x32,
3919 (((xend >> 1) & 7) << 3) | ((xstart >> 1) & 7),
3921 i2c_w_mask(sd, 0x03,
3922 (((yend >> 1) & 3) << 2) | ((ystart >> 1) & 3),
3924 i2c_w(sd, 0x17, xstart >> 4);
3925 i2c_w(sd, 0x18, xend >> 4);
3926 i2c_w(sd, 0x19, ystart >> 3);
3927 i2c_w(sd, 0x1a, yend >> 3);
3932 i2c_w_mask(sd, 0x13, 0x00, 0x20);
3933 i2c_w_mask(sd, 0x12, 0x04, 0x06);
3934 i2c_w_mask(sd, 0x2d, 0x00, 0x40);
3935 i2c_w_mask(sd, 0x28, 0x20, 0x20);
3938 i2c_w_mask(sd, 0x14, qvga ? 0x20 : 0x00, 0x20);
3939 i2c_w(sd, 0x35, qvga ? 0x1e : 0x9e);
3940 i2c_w_mask(sd, 0x13, 0x00, 0x20);
3941 i2c_w_mask(sd, 0x12, 0x04, 0x06);
3946 i2c_w_mask(sd, 0x14, qvga ? 0x20 : 0x00, 0x20);
3947 i2c_w_mask(sd, 0x28, qvga ? 0x00 : 0x20, 0x20);
3948 i2c_w(sd, 0x24, qvga ? 0x20 : 0x3a);
3949 i2c_w(sd, 0x25, qvga ? 0x30 : 0x60);
3950 i2c_w_mask(sd, 0x2d, qvga ? 0x40 : 0x00, 0x40);
3951 i2c_w_mask(sd, 0x67, qvga ? 0xb0 : 0x90, 0xf0);
3952 i2c_w_mask(sd, 0x74, qvga ? 0x20 : 0x00, 0x20);
3953 i2c_w_mask(sd, 0x13, 0x00, 0x20);
3954 i2c_w_mask(sd, 0x12, 0x04, 0x06);
3956 i2c_w(sd, 0x35, qvga ? 0x1e : 0x9e);
3960 i2c_w_mask(sd, 0x14, qvga ? 0x20 : 0x00, 0x20);
3961 i2c_w_mask(sd, 0x28, qvga ? 0x00 : 0x20, 0x20);
3964 i2c_w_mask(sd, 0x2d, qvga ? 0x40 : 0x00, 0x40);
3966 i2c_w_mask(sd, 0x67, qvga ? 0xf0 : 0x90, 0xf0);
3968 i2c_w_mask(sd, 0x74, qvga ? 0x20 : 0x00, 0x20);
3969 i2c_w_mask(sd, 0x12, 0x04, 0x04);
3978 i2c_w_mask(sd, 0x13, 0x00, 0x20);
3998 v = (v & 0xc0) | ((xend & 0x7) << 3) | (xstart & 0x07);
4006 v = (v & 0xc0) | ((yend & 0x3) << 2) | (ystart & 0x03);
4012 i2c_w_mask(sd, 0x14, qvga ? 0x20 : 0x00, 0x20);
4013 i2c_w_mask(sd, 0x13, 0x00, 0x20);
4014 i2c_w_mask(sd, 0x12, 0x04, 0x06);
4018 i2c_w_mask(sd, 0x14, qvga ? 0x20 : 0x00, 0x20);
4019 i2c_w_mask(sd, 0x12, 0x04, 0x06);
4024 {0x11, 0x80}, {0x14, 0x3e}, {0x24, 0x85}, {0x25, 0x75}
4027 {0x11, 0x81}, {0x14, 0x3e}, {0x24, 0x85}, {0x25, 0x75}
4030 {0x11, 0x81}, {0x14, 0x7e}, {0x24, 0x70}, {0x25, 0x60}
4033 {0x11, 0x83}, {0x14, 0x3e}, {0x24, 0x80}, {0x25, 0x70}
4040 i2c_w_mask(sd, 0x12, qvga ? 0x40 : 0x00, 0x40);
4042 vals = sd->
frame_rate < 30 ? vga_15 : vga_30;
4044 vals = sd->
frame_rate < 15 ? sxga_7_5 : sxga_15;
4045 write_i2c_regvals(sd, vals,
ARRAY_SIZE(sxga_15));
4057 static void sethvflip(
struct gspca_dev *gspca_dev,
s32 hflip,
s32 vflip)
4059 struct sd *sd = (
struct sd *) gspca_dev;
4070 static void set_ov_sensor_window(
struct sd *sd)
4072 struct gspca_dev *gspca_dev;
4074 int hwsbase, hwebase, vwsbase, vwebase, hwscale, vwscale;
4083 mode_init_ov_sensor_regs(sd);
4092 qvga = gspca_dev->
cam.cam_mode[gspca_dev->
curr_mode].priv & 1;
4093 crop = gspca_dev->
cam.cam_mode[gspca_dev->
curr_mode].priv & 2;
4108 vwsbase = vwebase = 0x05;
4131 vwsbase = vwebase = 0x05;
4137 vwsbase = vwebase = 0x03;
4175 mode_init_ov_sensor_regs(sd);
4177 i2c_w(sd, 0x17, hwsbase);
4178 i2c_w(sd, 0x18, hwebase + (sd->
sensor_width >> hwscale));
4179 i2c_w(sd, 0x19, vwsbase);
4184 static int sd_start(
struct gspca_dev *gspca_dev)
4186 struct sd *sd = (
struct sd *) gspca_dev;
4195 ov511_mode_init_regs(sd);
4199 ov518_mode_init_regs(sd);
4202 ov519_mode_init_regs(sd);
4206 w9968cf_mode_init_regs(sd);
4210 set_ov_sensor_window(sd);
4215 sd_reset_snapshot(gspca_dev);
4220 ov51x_led_control(sd, 1);
4224 static void sd_stopN(
struct gspca_dev *gspca_dev)
4226 struct sd *sd = (
struct sd *) gspca_dev;
4229 ov51x_led_control(sd, 0);
4232 static void sd_stop0(
struct gspca_dev *gspca_dev)
4234 struct sd *sd = (
struct sd *) gspca_dev;
4241 #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
4244 input_report_key(gspca_dev->input_dev,
KEY_CAMERA, 0);
4245 input_sync(gspca_dev->input_dev);
4253 static void ov51x_handle_button(
struct gspca_dev *gspca_dev,
u8 state)
4255 struct sd *sd = (
struct sd *) gspca_dev;
4258 #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
4259 input_report_key(gspca_dev->input_dev,
KEY_CAMERA, state);
4260 input_sync(gspca_dev->input_dev);
4281 static void ov511_pkt_scan(
struct gspca_dev *gspca_dev,
4285 struct sd *sd = (
struct sd *) gspca_dev;
4300 if (!(in[0] | in[1] | in[2] | in[3] | in[4] | in[5] | in[6] | in[7]) &&
4302 ov51x_handle_button(gspca_dev, (in[8] >> 2) & 1);
4305 if ((in[9] + 1) * 8 != gspca_dev->
width ||
4306 (in[10] + 1) * 8 != gspca_dev->
height) {
4308 " requested: %dx%d\n",
4309 (in[9] + 1) * 8, (in[10] + 1) * 8,
4331 static void ov518_pkt_scan(
struct gspca_dev *gspca_dev,
4335 struct sd *sd = (
struct sd *) gspca_dev;
4339 if ((!(data[0] | data[1] | data[2] | data[3] | data[5])) && data[6]) {
4340 ov51x_handle_button(gspca_dev, (data[6] >> 1) & 1);
4357 else if (sd->
packet_nr == 0 || data[len]) {
4358 PDEBUG(
D_ERR,
"Invalid packet nr: %d (expect: %d)",
4369 static void ov519_pkt_scan(
struct gspca_dev *gspca_dev,
4385 if (data[0] == 0xff && data[1] == 0xff && data[2] == 0xff) {
4395 if (data[0] == 0xff || data[1] == 0xd8)
4402 ov51x_handle_button(gspca_dev, data[11] & 1);
4415 static void ovfx2_pkt_scan(
struct gspca_dev *gspca_dev,
4419 struct sd *sd = (
struct sd *) gspca_dev;
4438 static void sd_pkt_scan(
struct gspca_dev *gspca_dev,
4442 struct sd *sd = (
struct sd *) gspca_dev;
4447 ov511_pkt_scan(gspca_dev, data, len);
4451 ov518_pkt_scan(gspca_dev, data, len);
4454 ov519_pkt_scan(gspca_dev, data, len);
4457 ovfx2_pkt_scan(gspca_dev, data, len);
4460 w9968cf_pkt_scan(gspca_dev, data, len);
4467 static void setbrightness(
struct gspca_dev *gspca_dev,
s32 val)
4469 struct sd *sd = (
struct sd *) gspca_dev;
4471 {{0x0f, 0x6a}, {0x24, 0x40}, {0x25, 0x2b}, {0x26, 0x90},
4472 {0x27, 0xe0}, {0x28, 0xe0}, {0x2c, 0xe0}},
4473 {{0x0f, 0x6a}, {0x24, 0x50}, {0x25, 0x40}, {0x26, 0xa1},
4474 {0x27, 0xc0}, {0x28, 0xc0}, {0x2c, 0xc0}},
4475 {{0x0f, 0x6a}, {0x24, 0x68}, {0x25, 0x58}, {0x26, 0xc2},
4476 {0x27, 0xa0}, {0x28, 0xa0}, {0x2c, 0xa0}},
4477 {{0x0f, 0x6a}, {0x24, 0x70}, {0x25, 0x68}, {0x26, 0xd3},
4478 {0x27, 0x80}, {0x28, 0x80}, {0x2c, 0x80}},
4479 {{0x0f, 0x6a}, {0x24, 0x80}, {0x25, 0x70}, {0x26, 0xd3},
4480 {0x27, 0x20}, {0x28, 0x20}, {0x2c, 0x20}},
4481 {{0x0f, 0x6a}, {0x24, 0x88}, {0x25, 0x78}, {0x26, 0xd3},
4482 {0x27, 0x40}, {0x28, 0x40}, {0x2c, 0x40}},
4483 {{0x0f, 0x6a}, {0x24, 0x90}, {0x25, 0x80}, {0x26, 0xd4},
4484 {0x27, 0x60}, {0x28, 0x60}, {0x2c, 0x60}}
4503 write_i2c_regvals(sd, brit_7660[val],
4514 static void setcontrast(
struct gspca_dev *gspca_dev,
s32 val)
4516 struct sd *sd = (
struct sd *) gspca_dev;
4518 {{0x6c, 0xf0}, {0x6d, 0xf0}, {0x6e, 0xf8}, {0x6f, 0xa0},
4519 {0x70, 0x58}, {0x71, 0x38}, {0x72, 0x30}, {0x73, 0x30},
4520 {0x74, 0x28}, {0x75, 0x28}, {0x76, 0x24}, {0x77, 0x24},
4521 {0x78, 0x22}, {0x79, 0x28}, {0x7a, 0x2a}, {0x7b, 0x34},
4522 {0x7c, 0x0f}, {0x7d, 0x1e}, {0x7e, 0x3d}, {0x7f, 0x65},
4523 {0x80, 0x70}, {0x81, 0x77}, {0x82, 0x7d}, {0x83, 0x83},
4524 {0x84, 0x88}, {0x85, 0x8d}, {0x86, 0x96}, {0x87, 0x9f},
4525 {0x88, 0xb0}, {0x89, 0xc4}, {0x8a, 0xd9}},
4526 {{0x6c, 0xf0}, {0x6d, 0xf0}, {0x6e, 0xf8}, {0x6f, 0x94},
4527 {0x70, 0x58}, {0x71, 0x40}, {0x72, 0x30}, {0x73, 0x30},
4528 {0x74, 0x30}, {0x75, 0x30}, {0x76, 0x2c}, {0x77, 0x24},
4529 {0x78, 0x22}, {0x79, 0x28}, {0x7a, 0x2a}, {0x7b, 0x31},
4530 {0x7c, 0x0f}, {0x7d, 0x1e}, {0x7e, 0x3d}, {0x7f, 0x62},
4531 {0x80, 0x6d}, {0x81, 0x75}, {0x82, 0x7b}, {0x83, 0x81},
4532 {0x84, 0x87}, {0x85, 0x8d}, {0x86, 0x98}, {0x87, 0xa1},
4533 {0x88, 0xb2}, {0x89, 0xc6}, {0x8a, 0xdb}},
4534 {{0x6c, 0xf0}, {0x6d, 0xf0}, {0x6e, 0xf0}, {0x6f, 0x84},
4535 {0x70, 0x58}, {0x71, 0x48}, {0x72, 0x40}, {0x73, 0x40},
4536 {0x74, 0x28}, {0x75, 0x28}, {0x76, 0x28}, {0x77, 0x24},
4537 {0x78, 0x26}, {0x79, 0x28}, {0x7a, 0x28}, {0x7b, 0x34},
4538 {0x7c, 0x0f}, {0x7d, 0x1e}, {0x7e, 0x3c}, {0x7f, 0x5d},
4539 {0x80, 0x68}, {0x81, 0x71}, {0x82, 0x79}, {0x83, 0x81},
4540 {0x84, 0x86}, {0x85, 0x8b}, {0x86, 0x95}, {0x87, 0x9e},
4541 {0x88, 0xb1}, {0x89, 0xc5}, {0x8a, 0xd9}},
4542 {{0x6c, 0xf0}, {0x6d, 0xf0}, {0x6e, 0xf0}, {0x6f, 0x70},
4543 {0x70, 0x58}, {0x71, 0x58}, {0x72, 0x48}, {0x73, 0x48},
4544 {0x74, 0x38}, {0x75, 0x40}, {0x76, 0x34}, {0x77, 0x34},
4545 {0x78, 0x2e}, {0x79, 0x28}, {0x7a, 0x24}, {0x7b, 0x22},
4546 {0x7c, 0x0f}, {0x7d, 0x1e}, {0x7e, 0x3c}, {0x7f, 0x58},
4547 {0x80, 0x63}, {0x81, 0x6e}, {0x82, 0x77}, {0x83, 0x80},
4548 {0x84, 0x87}, {0x85, 0x8f}, {0x86, 0x9c}, {0x87, 0xa9},
4549 {0x88, 0xc0}, {0x89, 0xd4}, {0x8a, 0xe6}},
4550 {{0x6c, 0xa0}, {0x6d, 0xf0}, {0x6e, 0x90}, {0x6f, 0x80},
4551 {0x70, 0x70}, {0x71, 0x80}, {0x72, 0x60}, {0x73, 0x60},
4552 {0x74, 0x58}, {0x75, 0x60}, {0x76, 0x4c}, {0x77, 0x38},
4553 {0x78, 0x38}, {0x79, 0x2a}, {0x7a, 0x20}, {0x7b, 0x0e},
4554 {0x7c, 0x0a}, {0x7d, 0x14}, {0x7e, 0x26}, {0x7f, 0x46},
4555 {0x80, 0x54}, {0x81, 0x64}, {0x82, 0x70}, {0x83, 0x7c},
4556 {0x84, 0x87}, {0x85, 0x93}, {0x86, 0xa6}, {0x87, 0xb4},
4557 {0x88, 0xd0}, {0x89, 0xe5}, {0x8a, 0xf5}},
4558 {{0x6c, 0x60}, {0x6d, 0x80}, {0x6e, 0x60}, {0x6f, 0x80},
4559 {0x70, 0x80}, {0x71, 0x80}, {0x72, 0x88}, {0x73, 0x30},
4560 {0x74, 0x70}, {0x75, 0x68}, {0x76, 0x64}, {0x77, 0x50},
4561 {0x78, 0x3c}, {0x79, 0x22}, {0x7a, 0x10}, {0x7b, 0x08},
4562 {0x7c, 0x06}, {0x7d, 0x0e}, {0x7e, 0x1a}, {0x7f, 0x3a},
4563 {0x80, 0x4a}, {0x81, 0x5a}, {0x82, 0x6b}, {0x83, 0x7b},
4564 {0x84, 0x89}, {0x85, 0x96}, {0x86, 0xaf}, {0x87, 0xc3},
4565 {0x88, 0xe1}, {0x89, 0xf2}, {0x8a, 0xfa}},
4566 {{0x6c, 0x20}, {0x6d, 0x40}, {0x6e, 0x20}, {0x6f, 0x60},
4567 {0x70, 0x88}, {0x71, 0xc8}, {0x72, 0xc0}, {0x73, 0xb8},
4568 {0x74, 0xa8}, {0x75, 0xb8}, {0x76, 0x80}, {0x77, 0x5c},
4569 {0x78, 0x26}, {0x79, 0x10}, {0x7a, 0x08}, {0x7b, 0x04},
4570 {0x7c, 0x02}, {0x7d, 0x06}, {0x7e, 0x0a}, {0x7f, 0x22},
4571 {0x80, 0x33}, {0x81, 0x4c}, {0x82, 0x64}, {0x83, 0x7b},
4572 {0x84, 0x90}, {0x85, 0xa7}, {0x86, 0xc7}, {0x87, 0xde},
4573 {0x88, 0xf1}, {0x89, 0xf9}, {0x8a, 0xfd}},
4586 static const u8 ctab[] = {
4587 0x03, 0x09, 0x0b, 0x0f, 0x53, 0x6f, 0x35, 0x7f
4591 i2c_w(sd, 0x64, ctab[val >> 5]);
4596 static const u8 ctab[] = {
4597 0x01, 0x05, 0x09, 0x11, 0x15, 0x35, 0x37, 0x57,
4598 0x5b, 0xa5, 0xa7, 0xc7, 0xc9, 0xcf, 0xef, 0xff
4602 i2c_w(sd, 0x64, ctab[val >> 4]);
4606 write_i2c_regvals(sd, contrast_7660[val],
4616 static void setexposure(
struct gspca_dev *gspca_dev,
s32 val)
4618 struct sd *sd = (
struct sd *) gspca_dev;
4620 i2c_w(sd, 0x10, val);
4623 static void setcolors(
struct gspca_dev *gspca_dev,
s32 val)
4625 struct sd *sd = (
struct sd *) gspca_dev;
4627 {{0x4f, 0x28}, {0x50, 0x2a}, {0x51, 0x02}, {0x52, 0x0a},
4628 {0x53, 0x19}, {0x54, 0x23}},
4629 {{0x4f, 0x47}, {0x50, 0x4a}, {0x51, 0x03}, {0x52, 0x11},
4630 {0x53, 0x2c}, {0x54, 0x3e}},
4631 {{0x4f, 0x66}, {0x50, 0x6b}, {0x51, 0x05}, {0x52, 0x19},
4632 {0x53, 0x40}, {0x54, 0x59}},
4633 {{0x4f, 0x84}, {0x50, 0x8b}, {0x51, 0x06}, {0x52, 0x20},
4634 {0x53, 0x53}, {0x54, 0x73}},
4635 {{0x4f, 0xa3}, {0x50, 0xab}, {0x51, 0x08}, {0x52, 0x28},
4636 {0x53, 0x66}, {0x54, 0x8e}},
4661 write_i2c_regvals(sd, colors_7660[val],
4672 static void setautobright(
struct gspca_dev *gspca_dev,
s32 val)
4674 struct sd *sd = (
struct sd *) gspca_dev;
4676 i2c_w_mask(sd, 0x2d, val ? 0x10 : 0x00, 0x10);
4679 static void setfreq_i(
struct sd *sd,
s32 val)
4707 i2c_w_mask(sd, 0x2d, 0x00, 0x04);
4708 i2c_w_mask(sd, 0x2a, 0x00, 0x80);
4711 i2c_w_mask(sd, 0x2d, 0x04, 0x04);
4712 i2c_w_mask(sd, 0x2a, 0x80, 0x80);
4717 i2c_w(sd, 0x2b, 0x5e);
4719 i2c_w(sd, 0x2b, 0xac);
4722 i2c_w_mask(sd, 0x2d, 0x04, 0x04);
4727 i2c_w_mask(sd, 0x2a, 0x80, 0x80);
4728 i2c_w(sd, 0x2b, 0xa8);
4731 i2c_w_mask(sd, 0x2a, 0x00, 0x80);
4738 static void setfreq(
struct gspca_dev *gspca_dev,
s32 val)
4740 struct sd *sd = (
struct sd *) gspca_dev;
4746 w9968cf_set_crop_window(sd);
4749 static int sd_get_jcomp(
struct gspca_dev *gspca_dev,
4752 struct sd *sd = (
struct sd *) gspca_dev;
4757 memset(jcomp, 0,
sizeof *jcomp);
4764 static int sd_set_jcomp(
struct gspca_dev *gspca_dev,
4767 struct sd *sd = (
struct sd *) gspca_dev;
4778 struct gspca_dev *gspca_dev =
4780 struct sd *sd = (
struct sd *)gspca_dev;
4786 gspca_dev->
exposure->val = i2c_r(sd, 0x10);
4792 static int sd_s_ctrl(
struct v4l2_ctrl *ctrl)
4794 struct gspca_dev *gspca_dev =
4796 struct sd *sd = (
struct sd *)gspca_dev;
4805 setbrightness(gspca_dev, ctrl->
val);
4808 setcontrast(gspca_dev, ctrl->
val);
4811 setfreq(gspca_dev, ctrl->
val);
4815 setautobright(gspca_dev, ctrl->
val);
4817 setbrightness(gspca_dev, sd->
brightness->val);
4820 setcolors(gspca_dev, ctrl->
val);
4823 sethvflip(gspca_dev, ctrl->
val, sd->
vflip->val);
4827 setautogain(gspca_dev, ctrl->
val);
4829 setexposure(gspca_dev, gspca_dev->
exposure->val);
4838 .g_volatile_ctrl = sd_g_volatile_ctrl,
4839 .s_ctrl = sd_s_ctrl,
4842 static int sd_init_controls(
struct gspca_dev *gspca_dev)
4844 struct sd *sd = (
struct sd *)gspca_dev;
4847 gspca_dev->
vdev.ctrl_handler = hdl;
4901 pr_err(
"Could not initialize controls\n");
4916 .config = sd_config,
4918 .init_controls = sd_init_controls,
4919 .isoc_init = sd_isoc_init,
4923 .pkt_scan = sd_pkt_scan,
4924 .dq_callback = sd_reset_snapshot,
4925 .get_jcomp = sd_get_jcomp,
4926 .set_jcomp = sd_set_jcomp,
4927 #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
4935 {USB_DEVICE(0x041e, 0x4052),
4937 {USB_DEVICE(0x041e, 0x405f), .driver_info =
BRIDGE_OV519 },
4938 {USB_DEVICE(0x041e, 0x4060), .driver_info =
BRIDGE_OV519 },
4939 {USB_DEVICE(0x041e, 0x4061), .driver_info =
BRIDGE_OV519 },
4940 {USB_DEVICE(0x041e, 0x4064), .driver_info =
BRIDGE_OV519 },
4941 {USB_DEVICE(0x041e, 0x4067), .driver_info =
BRIDGE_OV519 },
4942 {USB_DEVICE(0x041e, 0x4068), .driver_info =
BRIDGE_OV519 },
4943 {USB_DEVICE(0x045e, 0x028c),
4945 {USB_DEVICE(0x054c, 0x0154), .driver_info =
BRIDGE_OV519 },
4946 {USB_DEVICE(0x054c, 0x0155), .driver_info =
BRIDGE_OV519 },
4947 {USB_DEVICE(0x05a9, 0x0511), .driver_info =
BRIDGE_OV511 },
4948 {USB_DEVICE(0x05a9, 0x0518), .driver_info =
BRIDGE_OV518 },
4949 {USB_DEVICE(0x05a9, 0x0519),
4951 {USB_DEVICE(0x05a9, 0x0530),
4953 {USB_DEVICE(0x05a9, 0x2800), .driver_info =
BRIDGE_OVFX2 },
4954 {USB_DEVICE(0x05a9, 0x4519), .driver_info =
BRIDGE_OV519 },
4955 {USB_DEVICE(0x05a9, 0x8519), .driver_info =
BRIDGE_OV519 },
4959 {USB_DEVICE(0x0b62, 0x0059), .driver_info =
BRIDGE_OVFX2 },
4960 {USB_DEVICE(0x0e96, 0xc001), .driver_info =
BRIDGE_OVFX2 },
4962 {USB_DEVICE(0x8020, 0xef04), .driver_info =
BRIDGE_OVFX2 },
4976 static struct usb_driver sd_driver = {
4978 .id_table = device_table,
4982 .suspend = gspca_suspend,
4983 .resume = gspca_resume,
4984 .reset_resume = gspca_resume,