diff options
Diffstat (limited to 'drivers/media/video/gspca/ov519.c')
| -rw-r--r-- | drivers/media/video/gspca/ov519.c | 1167 |
1 files changed, 608 insertions, 559 deletions
diff --git a/drivers/media/video/gspca/ov519.c b/drivers/media/video/gspca/ov519.c index b4f00ec0885c..4df4eec9f7e7 100644 --- a/drivers/media/video/gspca/ov519.c +++ b/drivers/media/video/gspca/ov519.c | |||
| @@ -63,11 +63,10 @@ struct sd { | |||
| 63 | #define SEN_OV6630 2 | 63 | #define SEN_OV6630 2 |
| 64 | #define SEN_OV7610 3 | 64 | #define SEN_OV7610 3 |
| 65 | #define SEN_OV7620 4 | 65 | #define SEN_OV7620 4 |
| 66 | #define SEN_OV7630 5 | 66 | #define SEN_OV7640 5 |
| 67 | #define SEN_OV7640 6 | 67 | #define SEN_OV7670 6 |
| 68 | #define SEN_OV7670 7 | 68 | #define SEN_OV76BE 7 |
| 69 | #define SEN_OV76BE 8 | 69 | #define SEN_OV8610 8 |
| 70 | #define SEN_OV8610 9 | ||
| 71 | 70 | ||
| 72 | }; | 71 | }; |
| 73 | 72 | ||
| @@ -127,6 +126,7 @@ static struct ctrl sd_ctrls[] = { | |||
| 127 | .get = sd_getcolors, | 126 | .get = sd_getcolors, |
| 128 | }, | 127 | }, |
| 129 | /* next controls work with ov7670 only */ | 128 | /* next controls work with ov7670 only */ |
| 129 | #define HFLIP_IDX 3 | ||
| 130 | { | 130 | { |
| 131 | { | 131 | { |
| 132 | .id = V4L2_CID_HFLIP, | 132 | .id = V4L2_CID_HFLIP, |
| @@ -141,6 +141,7 @@ static struct ctrl sd_ctrls[] = { | |||
| 141 | .set = sd_sethflip, | 141 | .set = sd_sethflip, |
| 142 | .get = sd_gethflip, | 142 | .get = sd_gethflip, |
| 143 | }, | 143 | }, |
| 144 | #define VFLIP_IDX 4 | ||
| 144 | { | 145 | { |
| 145 | { | 146 | { |
| 146 | .id = V4L2_CID_VFLIP, | 147 | .id = V4L2_CID_VFLIP, |
| @@ -293,6 +294,541 @@ static struct v4l2_pix_format sif_mode[] = { | |||
| 293 | #define OV7670_REG_HAECC7 0xaa /* Hist AEC/AGC control 7 */ | 294 | #define OV7670_REG_HAECC7 0xaa /* Hist AEC/AGC control 7 */ |
| 294 | #define OV7670_REG_BD60MAX 0xab /* 60hz banding step limit */ | 295 | #define OV7670_REG_BD60MAX 0xab /* 60hz banding step limit */ |
| 295 | 296 | ||
| 297 | struct ov_regvals { | ||
| 298 | __u8 reg; | ||
| 299 | __u8 val; | ||
| 300 | }; | ||
| 301 | struct ov_i2c_regvals { | ||
| 302 | __u8 reg; | ||
| 303 | __u8 val; | ||
| 304 | }; | ||
| 305 | |||
| 306 | static const struct ov_i2c_regvals norm_6x20[] = { | ||
| 307 | { 0x12, 0x80 }, /* reset */ | ||
| 308 | { 0x11, 0x01 }, | ||
| 309 | { 0x03, 0x60 }, | ||
| 310 | { 0x05, 0x7f }, /* For when autoadjust is off */ | ||
| 311 | { 0x07, 0xa8 }, | ||
| 312 | /* The ratio of 0x0c and 0x0d controls the white point */ | ||
| 313 | { 0x0c, 0x24 }, | ||
| 314 | { 0x0d, 0x24 }, | ||
| 315 | { 0x0f, 0x15 }, /* COMS */ | ||
| 316 | { 0x10, 0x75 }, /* AEC Exposure time */ | ||
| 317 | { 0x12, 0x24 }, /* Enable AGC */ | ||
| 318 | { 0x14, 0x04 }, | ||
| 319 | /* 0x16: 0x06 helps frame stability with moving objects */ | ||
| 320 | { 0x16, 0x06 }, | ||
| 321 | /* { 0x20, 0x30 }, * Aperture correction enable */ | ||
| 322 | { 0x26, 0xb2 }, /* BLC enable */ | ||
| 323 | /* 0x28: 0x05 Selects RGB format if RGB on */ | ||
| 324 | { 0x28, 0x05 }, | ||
| 325 | { 0x2a, 0x04 }, /* Disable framerate adjust */ | ||
| 326 | /* { 0x2b, 0xac }, * Framerate; Set 2a[7] first */ | ||
| 327 | { 0x2d, 0x99 }, | ||
| 328 | { 0x33, 0xa0 }, /* Color Processing Parameter */ | ||
| 329 | { 0x34, 0xd2 }, /* Max A/D range */ | ||
| 330 | { 0x38, 0x8b }, | ||
| 331 | { 0x39, 0x40 }, | ||
| 332 | |||
| 333 | { 0x3c, 0x39 }, /* Enable AEC mode changing */ | ||
| 334 | { 0x3c, 0x3c }, /* Change AEC mode */ | ||
| 335 | { 0x3c, 0x24 }, /* Disable AEC mode changing */ | ||
| 336 | |||
| 337 | { 0x3d, 0x80 }, | ||
| 338 | /* These next two registers (0x4a, 0x4b) are undocumented. | ||
| 339 | * They control the color balance */ | ||
| 340 | { 0x4a, 0x80 }, | ||
| 341 | { 0x4b, 0x80 }, | ||
| 342 | { 0x4d, 0xd2 }, /* This reduces noise a bit */ | ||
| 343 | { 0x4e, 0xc1 }, | ||
| 344 | { 0x4f, 0x04 }, | ||
| 345 | /* Do 50-53 have any effect? */ | ||
| 346 | /* Toggle 0x12[2] off and on here? */ | ||
| 347 | }; | ||
| 348 | |||
| 349 | static const struct ov_i2c_regvals norm_6x30[] = { | ||
| 350 | { 0x12, 0x80 }, /* Reset */ | ||
| 351 | { 0x00, 0x1f }, /* Gain */ | ||
| 352 | { 0x01, 0x99 }, /* Blue gain */ | ||
| 353 | { 0x02, 0x7c }, /* Red gain */ | ||
| 354 | { 0x03, 0xc0 }, /* Saturation */ | ||
| 355 | { 0x05, 0x0a }, /* Contrast */ | ||
| 356 | { 0x06, 0x95 }, /* Brightness */ | ||
| 357 | { 0x07, 0x2d }, /* Sharpness */ | ||
| 358 | { 0x0c, 0x20 }, | ||
| 359 | { 0x0d, 0x20 }, | ||
| 360 | { 0x0e, 0x20 }, | ||
| 361 | { 0x0f, 0x05 }, | ||
| 362 | { 0x10, 0x9a }, | ||
| 363 | { 0x11, 0x00 }, /* Pixel clock = fastest */ | ||
| 364 | { 0x12, 0x24 }, /* Enable AGC and AWB */ | ||
| 365 | { 0x13, 0x21 }, | ||
| 366 | { 0x14, 0x80 }, | ||
| 367 | { 0x15, 0x01 }, | ||
| 368 | { 0x16, 0x03 }, | ||
| 369 | { 0x17, 0x38 }, | ||
| 370 | { 0x18, 0xea }, | ||
| 371 | { 0x19, 0x04 }, | ||
| 372 | { 0x1a, 0x93 }, | ||
| 373 | { 0x1b, 0x00 }, | ||
| 374 | { 0x1e, 0xc4 }, | ||
| 375 | { 0x1f, 0x04 }, | ||
| 376 | { 0x20, 0x20 }, | ||
| 377 | { 0x21, 0x10 }, | ||
| 378 | { 0x22, 0x88 }, | ||
| 379 | { 0x23, 0xc0 }, /* Crystal circuit power level */ | ||
| 380 | { 0x25, 0x9a }, /* Increase AEC black ratio */ | ||
| 381 | { 0x26, 0xb2 }, /* BLC enable */ | ||
| 382 | { 0x27, 0xa2 }, | ||
| 383 | { 0x28, 0x00 }, | ||
| 384 | { 0x29, 0x00 }, | ||
| 385 | { 0x2a, 0x84 }, /* 60 Hz power */ | ||
| 386 | { 0x2b, 0xa8 }, /* 60 Hz power */ | ||
| 387 | { 0x2c, 0xa0 }, | ||
| 388 | { 0x2d, 0x95 }, /* Enable auto-brightness */ | ||
| 389 | { 0x2e, 0x88 }, | ||
| 390 | { 0x33, 0x26 }, | ||
| 391 | { 0x34, 0x03 }, | ||
| 392 | { 0x36, 0x8f }, | ||
| 393 | { 0x37, 0x80 }, | ||
| 394 | { 0x38, 0x83 }, | ||
| 395 | { 0x39, 0x80 }, | ||
| 396 | { 0x3a, 0x0f }, | ||
| 397 | { 0x3b, 0x3c }, | ||
| 398 | { 0x3c, 0x1a }, | ||
| 399 | { 0x3d, 0x80 }, | ||
| 400 | { 0x3e, 0x80 }, | ||
| 401 | { 0x3f, 0x0e }, | ||
| 402 | { 0x40, 0x00 }, /* White bal */ | ||
| 403 | { 0x41, 0x00 }, /* White bal */ | ||
| 404 | { 0x42, 0x80 }, | ||
| 405 | { 0x43, 0x3f }, /* White bal */ | ||
| 406 | { 0x44, 0x80 }, | ||
| 407 | { 0x45, 0x20 }, | ||
| 408 | { 0x46, 0x20 }, | ||
| 409 | { 0x47, 0x80 }, | ||
| 410 | { 0x48, 0x7f }, | ||
| 411 | { 0x49, 0x00 }, | ||
| 412 | { 0x4a, 0x00 }, | ||
| 413 | { 0x4b, 0x80 }, | ||
| 414 | { 0x4c, 0xd0 }, | ||
| 415 | { 0x4d, 0x10 }, /* U = 0.563u, V = 0.714v */ | ||
| 416 | { 0x4e, 0x40 }, | ||
| 417 | { 0x4f, 0x07 }, /* UV avg., col. killer: max */ | ||
| 418 | { 0x50, 0xff }, | ||
| 419 | { 0x54, 0x23 }, /* Max AGC gain: 18dB */ | ||
| 420 | { 0x55, 0xff }, | ||
| 421 | { 0x56, 0x12 }, | ||
| 422 | { 0x57, 0x81 }, | ||
| 423 | { 0x58, 0x75 }, | ||
| 424 | { 0x59, 0x01 }, /* AGC dark current comp.: +1 */ | ||
| 425 | { 0x5a, 0x2c }, | ||
| 426 | { 0x5b, 0x0f }, /* AWB chrominance levels */ | ||
| 427 | { 0x5c, 0x10 }, | ||
| 428 | { 0x3d, 0x80 }, | ||
| 429 | { 0x27, 0xa6 }, | ||
| 430 | { 0x12, 0x20 }, /* Toggle AWB */ | ||
| 431 | { 0x12, 0x24 }, | ||
| 432 | }; | ||
| 433 | |||
| 434 | /* Lawrence Glaister <lg@jfm.bc.ca> reports: | ||
| 435 | * | ||
| 436 | * Register 0x0f in the 7610 has the following effects: | ||
| 437 | * | ||
| 438 | * 0x85 (AEC method 1): Best overall, good contrast range | ||
| 439 | * 0x45 (AEC method 2): Very overexposed | ||
| 440 | * 0xa5 (spec sheet default): Ok, but the black level is | ||
| 441 | * shifted resulting in loss of contrast | ||
| 442 | * 0x05 (old driver setting): very overexposed, too much | ||
| 443 | * contrast | ||
| 444 | */ | ||
| 445 | static const struct ov_i2c_regvals norm_7610[] = { | ||
| 446 | { 0x10, 0xff }, | ||
| 447 | { 0x16, 0x06 }, | ||
| 448 | { 0x28, 0x24 }, | ||
| 449 | { 0x2b, 0xac }, | ||
| 450 | { 0x12, 0x00 }, | ||
| 451 | { 0x38, 0x81 }, | ||
| 452 | { 0x28, 0x24 }, /* 0c */ | ||
| 453 | { 0x0f, 0x85 }, /* lg's setting */ | ||
| 454 | { 0x15, 0x01 }, | ||
| 455 | { 0x20, 0x1c }, | ||
| 456 | { 0x23, 0x2a }, | ||
| 457 | { 0x24, 0x10 }, | ||
| 458 | { 0x25, 0x8a }, | ||
| 459 | { 0x26, 0xa2 }, | ||
| 460 | { 0x27, 0xc2 }, | ||
| 461 | { 0x2a, 0x04 }, | ||
| 462 | { 0x2c, 0xfe }, | ||
| 463 | { 0x2d, 0x93 }, | ||
| 464 | { 0x30, 0x71 }, | ||
| 465 | { 0x31, 0x60 }, | ||
| 466 | { 0x32, 0x26 }, | ||
| 467 | { 0x33, 0x20 }, | ||
| 468 | { 0x34, 0x48 }, | ||
| 469 | { 0x12, 0x24 }, | ||
| 470 | { 0x11, 0x01 }, | ||
| 471 | { 0x0c, 0x24 }, | ||
| 472 | { 0x0d, 0x24 }, | ||
| 473 | }; | ||
| 474 | |||
| 475 | static const struct ov_i2c_regvals norm_7620[] = { | ||
| 476 | { 0x00, 0x00 }, /* gain */ | ||
| 477 | { 0x01, 0x80 }, /* blue gain */ | ||
| 478 | { 0x02, 0x80 }, /* red gain */ | ||
| 479 | { 0x03, 0xc0 }, /* OV7670_REG_VREF */ | ||
| 480 | { 0x06, 0x60 }, | ||
| 481 | { 0x07, 0x00 }, | ||
| 482 | { 0x0c, 0x24 }, | ||
| 483 | { 0x0c, 0x24 }, | ||
| 484 | { 0x0d, 0x24 }, | ||
| 485 | { 0x11, 0x01 }, | ||
| 486 | { 0x12, 0x24 }, | ||
| 487 | { 0x13, 0x01 }, | ||
| 488 | { 0x14, 0x84 }, | ||
| 489 | { 0x15, 0x01 }, | ||
| 490 | { 0x16, 0x03 }, | ||
| 491 | { 0x17, 0x2f }, | ||
| 492 | { 0x18, 0xcf }, | ||
| 493 | { 0x19, 0x06 }, | ||
| 494 | { 0x1a, 0xf5 }, | ||
| 495 | { 0x1b, 0x00 }, | ||
| 496 | { 0x20, 0x18 }, | ||
| 497 | { 0x21, 0x80 }, | ||
| 498 | { 0x22, 0x80 }, | ||
| 499 | { 0x23, 0x00 }, | ||
| 500 | { 0x26, 0xa2 }, | ||
| 501 | { 0x27, 0xea }, | ||
| 502 | { 0x28, 0x20 }, | ||
| 503 | { 0x29, 0x00 }, | ||
| 504 | { 0x2a, 0x10 }, | ||
| 505 | { 0x2b, 0x00 }, | ||
| 506 | { 0x2c, 0x88 }, | ||
| 507 | { 0x2d, 0x91 }, | ||
| 508 | { 0x2e, 0x80 }, | ||
| 509 | { 0x2f, 0x44 }, | ||
| 510 | { 0x60, 0x27 }, | ||
| 511 | { 0x61, 0x02 }, | ||
| 512 | { 0x62, 0x5f }, | ||
| 513 | { 0x63, 0xd5 }, | ||
| 514 | { 0x64, 0x57 }, | ||
| 515 | { 0x65, 0x83 }, | ||
| 516 | { 0x66, 0x55 }, | ||
| 517 | { 0x67, 0x92 }, | ||
| 518 | { 0x68, 0xcf }, | ||
| 519 | { 0x69, 0x76 }, | ||
| 520 | { 0x6a, 0x22 }, | ||
| 521 | { 0x6b, 0x00 }, | ||
| 522 | { 0x6c, 0x02 }, | ||
| 523 | { 0x6d, 0x44 }, | ||
| 524 | { 0x6e, 0x80 }, | ||
| 525 | { 0x6f, 0x1d }, | ||
| 526 | { 0x70, 0x8b }, | ||
| 527 | { 0x71, 0x00 }, | ||
| 528 | { 0x72, 0x14 }, | ||
| 529 | { 0x73, 0x54 }, | ||
| 530 | { 0x74, 0x00 }, | ||
| 531 | { 0x75, 0x8e }, | ||
| 532 | { 0x76, 0x00 }, | ||
| 533 | { 0x77, 0xff }, | ||
| 534 | { 0x78, 0x80 }, | ||
| 535 | { 0x79, 0x80 }, | ||
| 536 | { 0x7a, 0x80 }, | ||
| 537 | { 0x7b, 0xe2 }, | ||
| 538 | { 0x7c, 0x00 }, | ||
| 539 | }; | ||
| 540 | |||
| 541 | /* 7640 and 7648. The defaults should be OK for most registers. */ | ||
| 542 | static const struct ov_i2c_regvals norm_7640[] = { | ||
| 543 | { 0x12, 0x80 }, | ||
| 544 | { 0x12, 0x14 }, | ||
| 545 | }; | ||
| 546 | |||
| 547 | /* 7670. Defaults taken from OmniVision provided data, | ||
| 548 | * as provided by Jonathan Corbet of OLPC */ | ||
| 549 | static const struct ov_i2c_regvals norm_7670[] = { | ||
| 550 | { OV7670_REG_COM7, OV7670_COM7_RESET }, | ||
| 551 | { OV7670_REG_TSLB, 0x04 }, /* OV */ | ||
| 552 | { OV7670_REG_COM7, OV7670_COM7_FMT_VGA }, /* VGA */ | ||
| 553 | { OV7670_REG_CLKRC, 0x01 }, | ||
| 554 | /* | ||
| 555 | * Set the hardware window. These values from OV don't entirely | ||
| 556 | * make sense - hstop is less than hstart. But they work... | ||
| 557 | */ | ||
| 558 | { OV7670_REG_HSTART, 0x13 }, | ||
| 559 | { OV7670_REG_HSTOP, 0x01 }, | ||
| 560 | { OV7670_REG_HREF, 0xb6 }, | ||
| 561 | { OV7670_REG_VSTART, 0x02 }, | ||
| 562 | { OV7670_REG_VSTOP, 0x7a }, | ||
| 563 | { OV7670_REG_VREF, 0x0a }, | ||
| 564 | |||
| 565 | { OV7670_REG_COM3, 0 }, | ||
| 566 | { OV7670_REG_COM14, 0 }, | ||
| 567 | /* Mystery scaling numbers */ | ||
| 568 | { 0x70, 0x3a }, | ||
| 569 | { 0x71, 0x35 }, | ||
| 570 | { 0x72, 0x11 }, | ||
| 571 | { 0x73, 0xf0 }, | ||
| 572 | { 0xa2, 0x02 }, | ||
| 573 | /* { OV7670_REG_COM10, 0x0 }, */ | ||
| 574 | |||
| 575 | /* Gamma curve values */ | ||
| 576 | { 0x7a, 0x20 }, | ||
| 577 | { 0x7b, 0x10 }, | ||
| 578 | { 0x7c, 0x1e }, | ||
| 579 | { 0x7d, 0x35 }, | ||
| 580 | { 0x7e, 0x5a }, | ||
| 581 | { 0x7f, 0x69 }, | ||
| 582 | { 0x80, 0x76 }, | ||
| 583 | { 0x81, 0x80 }, | ||
| 584 | { 0x82, 0x88 }, | ||
| 585 | { 0x83, 0x8f }, | ||
| 586 | { 0x84, 0x96 }, | ||
| 587 | { 0x85, 0xa3 }, | ||
| 588 | { 0x86, 0xaf }, | ||
| 589 | { 0x87, 0xc4 }, | ||
| 590 | { 0x88, 0xd7 }, | ||
| 591 | { 0x89, 0xe8 }, | ||
| 592 | |||
| 593 | /* AGC and AEC parameters. Note we start by disabling those features, | ||
| 594 | then turn them only after tweaking the values. */ | ||
| 595 | { OV7670_REG_COM8, OV7670_COM8_FASTAEC | ||
| 596 | | OV7670_COM8_AECSTEP | ||
| 597 | | OV7670_COM8_BFILT }, | ||
| 598 | { OV7670_REG_GAIN, 0 }, | ||
| 599 | { OV7670_REG_AECH, 0 }, | ||
| 600 | { OV7670_REG_COM4, 0x40 }, /* magic reserved bit */ | ||
| 601 | { OV7670_REG_COM9, 0x18 }, /* 4x gain + magic rsvd bit */ | ||
| 602 | { OV7670_REG_BD50MAX, 0x05 }, | ||
| 603 | { OV7670_REG_BD60MAX, 0x07 }, | ||
| 604 | { OV7670_REG_AEW, 0x95 }, | ||
| 605 | { OV7670_REG_AEB, 0x33 }, | ||
| 606 | { OV7670_REG_VPT, 0xe3 }, | ||
| 607 | { OV7670_REG_HAECC1, 0x78 }, | ||
| 608 | { OV7670_REG_HAECC2, 0x68 }, | ||
| 609 | { 0xa1, 0x03 }, /* magic */ | ||
| 610 | { OV7670_REG_HAECC3, 0xd8 }, | ||
| 611 | { OV7670_REG_HAECC4, 0xd8 }, | ||
| 612 | { OV7670_REG_HAECC5, 0xf0 }, | ||
| 613 | { OV7670_REG_HAECC6, 0x90 }, | ||
| 614 | { OV7670_REG_HAECC7, 0x94 }, | ||
| 615 | { OV7670_REG_COM8, OV7670_COM8_FASTAEC | ||
| 616 | | OV7670_COM8_AECSTEP | ||
| 617 | | OV7670_COM8_BFILT | ||
| 618 | | OV7670_COM8_AGC | ||
| 619 | | OV7670_COM8_AEC }, | ||
| 620 | |||
| 621 | /* Almost all of these are magic "reserved" values. */ | ||
| 622 | { OV7670_REG_COM5, 0x61 }, | ||
| 623 | { OV7670_REG_COM6, 0x4b }, | ||
| 624 | { 0x16, 0x02 }, | ||
| 625 | { OV7670_REG_MVFP, 0x07 }, | ||
| 626 | { 0x21, 0x02 }, | ||
| 627 | { 0x22, 0x91 }, | ||
| 628 | { 0x29, 0x07 }, | ||
| 629 | { 0x33, 0x0b }, | ||
| 630 | { 0x35, 0x0b }, | ||
| 631 | { 0x37, 0x1d }, | ||
| 632 | { 0x38, 0x71 }, | ||
| 633 | { 0x39, 0x2a }, | ||
| 634 | { OV7670_REG_COM12, 0x78 }, | ||
| 635 | { 0x4d, 0x40 }, | ||
| 636 | { 0x4e, 0x20 }, | ||
| 637 | { OV7670_REG_GFIX, 0 }, | ||
| 638 | { 0x6b, 0x4a }, | ||
| 639 | { 0x74, 0x10 }, | ||
| 640 | { 0x8d, 0x4f }, | ||
| 641 | { 0x8e, 0 }, | ||
| 642 | { 0x8f, 0 }, | ||
| 643 | { 0x90, 0 }, | ||
| 644 | { 0x91, 0 }, | ||
| 645 | { 0x96, 0 }, | ||
| 646 | { 0x9a, 0 }, | ||
| 647 | { 0xb0, 0x84 }, | ||
| 648 | { 0xb1, 0x0c }, | ||
| 649 | { 0xb2, 0x0e }, | ||
| 650 | { 0xb3, 0x82 }, | ||
| 651 | { 0xb8, 0x0a }, | ||
| 652 | |||
| 653 | /* More reserved magic, some of which tweaks white balance */ | ||
| 654 | { 0x43, 0x0a }, | ||
| 655 | { 0x44, 0xf0 }, | ||
| 656 | { 0x45, 0x34 }, | ||
| 657 | { 0x46, 0x58 }, | ||
| 658 | { 0x47, 0x28 }, | ||
| 659 | { 0x48, 0x3a }, | ||
| 660 | { 0x59, 0x88 }, | ||
| 661 | { 0x5a, 0x88 }, | ||
| 662 | { 0x5b, 0x44 }, | ||
| 663 | { 0x5c, 0x67 }, | ||
| 664 | { 0x5d, 0x49 }, | ||
| 665 | { 0x5e, 0x0e }, | ||
| 666 | { 0x6c, 0x0a }, | ||
| 667 | { 0x6d, 0x55 }, | ||
| 668 | { 0x6e, 0x11 }, | ||
| 669 | { 0x6f, 0x9f }, | ||
| 670 | /* "9e for advance AWB" */ | ||
| 671 | { 0x6a, 0x40 }, | ||
| 672 | { OV7670_REG_BLUE, 0x40 }, | ||
| 673 | { OV7670_REG_RED, 0x60 }, | ||
| 674 | { OV7670_REG_COM8, OV7670_COM8_FASTAEC | ||
| 675 | | OV7670_COM8_AECSTEP | ||
| 676 | | OV7670_COM8_BFILT | ||
| 677 | | OV7670_COM8_AGC | ||
| 678 | | OV7670_COM8_AEC | ||
| 679 | | OV7670_COM8_AWB }, | ||
| 680 | |||
| 681 | /* Matrix coefficients */ | ||
| 682 | { 0x4f, 0x80 }, | ||
| 683 | { 0x50, 0x80 }, | ||
| 684 | { 0x51, 0 }, | ||
| 685 | { 0x52, 0x22 }, | ||
| 686 | { 0x53, 0x5e }, | ||
| 687 | { 0x54, 0x80 }, | ||
| 688 | { 0x58, 0x9e }, | ||
| 689 | |||
| 690 | { OV7670_REG_COM16, OV7670_COM16_AWBGAIN }, | ||
| 691 | { OV7670_REG_EDGE, 0 }, | ||
| 692 | { 0x75, 0x05 }, | ||
| 693 | { 0x76, 0xe1 }, | ||
| 694 | { 0x4c, 0 }, | ||
| 695 | { 0x77, 0x01 }, | ||
| 696 | { OV7670_REG_COM13, OV7670_COM13_GAMMA | ||
| 697 | | OV7670_COM13_UVSAT | ||
| 698 | | 2}, /* was 3 */ | ||
| 699 | { 0x4b, 0x09 }, | ||
| 700 | { 0xc9, 0x60 }, | ||
| 701 | { OV7670_REG_COM16, 0x38 }, | ||
| 702 | { 0x56, 0x40 }, | ||
| 703 | |||
| 704 | { 0x34, 0x11 }, | ||
| 705 | { OV7670_REG_COM11, OV7670_COM11_EXP|OV7670_COM11_HZAUTO }, | ||
| 706 | { 0xa4, 0x88 }, | ||
| 707 | { 0x96, 0 }, | ||
| 708 | { 0x97, 0x30 }, | ||
| 709 | { 0x98, 0x20 }, | ||
| 710 | { 0x99, 0x30 }, | ||
| 711 | { 0x9a, 0x84 }, | ||
| 712 | { 0x9b, 0x29 }, | ||
| 713 | { 0x9c, 0x03 }, | ||
| 714 | { 0x9d, 0x4c }, | ||
| 715 | { 0x9e, 0x3f }, | ||
| 716 | { 0x78, 0x04 }, | ||
| 717 | |||
| 718 | /* Extra-weird stuff. Some sort of multiplexor register */ | ||
| 719 | { 0x79, 0x01 }, | ||
| 720 | { 0xc8, 0xf0 }, | ||
| 721 | { 0x79, 0x0f }, | ||
| 722 | { 0xc8, 0x00 }, | ||
| 723 | { 0x79, 0x10 }, | ||
| 724 | { 0xc8, 0x7e }, | ||
| 725 | { 0x79, 0x0a }, | ||
| 726 | { 0xc8, 0x80 }, | ||
| 727 | { 0x79, 0x0b }, | ||
| 728 | { 0xc8, 0x01 }, | ||
| 729 | { 0x79, 0x0c }, | ||
| 730 | { 0xc8, 0x0f }, | ||
| 731 | { 0x79, 0x0d }, | ||
| 732 | { 0xc8, 0x20 }, | ||
| 733 | { 0x79, 0x09 }, | ||
| 734 | { 0xc8, 0x80 }, | ||
| 735 | { 0x79, 0x02 }, | ||
| 736 | { 0xc8, 0xc0 }, | ||
| 737 | { 0x79, 0x03 }, | ||
| 738 | { 0xc8, 0x40 }, | ||
| 739 | { 0x79, 0x05 }, | ||
| 740 | { 0xc8, 0x30 }, | ||
| 741 | { 0x79, 0x26 }, | ||
| 742 | }; | ||
| 743 | |||
| 744 | static const struct ov_i2c_regvals norm_8610[] = { | ||
| 745 | { 0x12, 0x80 }, | ||
| 746 | { 0x00, 0x00 }, | ||
| 747 | { 0x01, 0x80 }, | ||
| 748 | { 0x02, 0x80 }, | ||
| 749 | { 0x03, 0xc0 }, | ||
| 750 | { 0x04, 0x30 }, | ||
| 751 | { 0x05, 0x30 }, /* was 0x10, new from windrv 090403 */ | ||
| 752 | { 0x06, 0x70 }, /* was 0x80, new from windrv 090403 */ | ||
| 753 | { 0x0a, 0x86 }, | ||
| 754 | { 0x0b, 0xb0 }, | ||
| 755 | { 0x0c, 0x20 }, | ||
| 756 | { 0x0d, 0x20 }, | ||
| 757 | { 0x11, 0x01 }, | ||
| 758 | { 0x12, 0x25 }, | ||
| 759 | { 0x13, 0x01 }, | ||
| 760 | { 0x14, 0x04 }, | ||
| 761 | { 0x15, 0x01 }, /* Lin and Win think different about UV order */ | ||
| 762 | { 0x16, 0x03 }, | ||
| 763 | { 0x17, 0x38 }, /* was 0x2f, new from windrv 090403 */ | ||
| 764 | { 0x18, 0xea }, /* was 0xcf, new from windrv 090403 */ | ||
| 765 | { 0x19, 0x02 }, /* was 0x06, new from windrv 090403 */ | ||
| 766 | { 0x1a, 0xf5 }, | ||
| 767 | { 0x1b, 0x00 }, | ||
| 768 | { 0x20, 0xd0 }, /* was 0x90, new from windrv 090403 */ | ||
| 769 | { 0x23, 0xc0 }, /* was 0x00, new from windrv 090403 */ | ||
| 770 | { 0x24, 0x30 }, /* was 0x1d, new from windrv 090403 */ | ||
| 771 | { 0x25, 0x50 }, /* was 0x57, new from windrv 090403 */ | ||
| 772 | { 0x26, 0xa2 }, | ||
| 773 | { 0x27, 0xea }, | ||
| 774 | { 0x28, 0x00 }, | ||
| 775 | { 0x29, 0x00 }, | ||
| 776 | { 0x2a, 0x80 }, | ||
| 777 | { 0x2b, 0xc8 }, /* was 0xcc, new from windrv 090403 */ | ||
| 778 | { 0x2c, 0xac }, | ||
| 779 | { 0x2d, 0x45 }, /* was 0xd5, new from windrv 090403 */ | ||
| 780 | { 0x2e, 0x80 }, | ||
| 781 | { 0x2f, 0x14 }, /* was 0x01, new from windrv 090403 */ | ||
| 782 | { 0x4c, 0x00 }, | ||
| 783 | { 0x4d, 0x30 }, /* was 0x10, new from windrv 090403 */ | ||
| 784 | { 0x60, 0x02 }, /* was 0x01, new from windrv 090403 */ | ||
| 785 | { 0x61, 0x00 }, /* was 0x09, new from windrv 090403 */ | ||
| 786 | { 0x62, 0x5f }, /* was 0xd7, new from windrv 090403 */ | ||
| 787 | { 0x63, 0xff }, | ||
| 788 | { 0x64, 0x53 }, /* new windrv 090403 says 0x57, | ||
| 789 | * maybe thats wrong */ | ||
| 790 | { 0x65, 0x00 }, | ||
| 791 | { 0x66, 0x55 }, | ||
| 792 | { 0x67, 0xb0 }, | ||
| 793 | { 0x68, 0xc0 }, /* was 0xaf, new from windrv 090403 */ | ||
| 794 | { 0x69, 0x02 }, | ||
| 795 | { 0x6a, 0x22 }, | ||
| 796 | { 0x6b, 0x00 }, | ||
| 797 | { 0x6c, 0x99 }, /* was 0x80, old windrv says 0x00, but | ||
| 798 | * deleting bit7 colors the first images red */ | ||
| 799 | { 0x6d, 0x11 }, /* was 0x00, new from windrv 090403 */ | ||
| 800 | { 0x6e, 0x11 }, /* was 0x00, new from windrv 090403 */ | ||
| 801 | { 0x6f, 0x01 }, | ||
| 802 | { 0x70, 0x8b }, | ||
| 803 | { 0x71, 0x00 }, | ||
| 804 | { 0x72, 0x14 }, | ||
| 805 | { 0x73, 0x54 }, | ||
| 806 | { 0x74, 0x00 },/* 0x60? - was 0x00, new from windrv 090403 */ | ||
| 807 | { 0x75, 0x0e }, | ||
| 808 | { 0x76, 0x02 }, /* was 0x02, new from windrv 090403 */ | ||
| 809 | { 0x77, 0xff }, | ||
| 810 | { 0x78, 0x80 }, | ||
| 811 | { 0x79, 0x80 }, | ||
| 812 | { 0x7a, 0x80 }, | ||
| 813 | { 0x7b, 0x10 }, /* was 0x13, new from windrv 090403 */ | ||
| 814 | { 0x7c, 0x00 }, | ||
| 815 | { 0x7d, 0x08 }, /* was 0x09, new from windrv 090403 */ | ||
| 816 | { 0x7e, 0x08 }, /* was 0xc0, new from windrv 090403 */ | ||
| 817 | { 0x7f, 0xfb }, | ||
| 818 | { 0x80, 0x28 }, | ||
| 819 | { 0x81, 0x00 }, | ||
| 820 | { 0x82, 0x23 }, | ||
| 821 | { 0x83, 0x0b }, | ||
| 822 | { 0x84, 0x00 }, | ||
| 823 | { 0x85, 0x62 }, /* was 0x61, new from windrv 090403 */ | ||
| 824 | { 0x86, 0xc9 }, | ||
| 825 | { 0x87, 0x00 }, | ||
| 826 | { 0x88, 0x00 }, | ||
| 827 | { 0x89, 0x01 }, | ||
| 828 | { 0x12, 0x20 }, | ||
| 829 | { 0x12, 0x25 }, /* was 0x24, new from windrv 090403 */ | ||
| 830 | }; | ||
| 831 | |||
| 296 | static unsigned char ov7670_abs_to_sm(unsigned char v) | 832 | static unsigned char ov7670_abs_to_sm(unsigned char v) |
| 297 | { | 833 | { |
| 298 | if (v > 127) | 834 | if (v > 127) |
| @@ -537,18 +1073,10 @@ static int ov51x_set_slave_ids(struct sd *sd, | |||
| 537 | rc = reg_w(sd, R51x_I2C_W_SID, slave); | 1073 | rc = reg_w(sd, R51x_I2C_W_SID, slave); |
| 538 | if (rc < 0) | 1074 | if (rc < 0) |
| 539 | return rc; | 1075 | return rc; |
| 1076 | sd->primary_i2c_slave = slave; | ||
| 540 | return reg_w(sd, R51x_I2C_R_SID, slave + 1); | 1077 | return reg_w(sd, R51x_I2C_R_SID, slave + 1); |
| 541 | } | 1078 | } |
| 542 | 1079 | ||
| 543 | struct ov_regvals { | ||
| 544 | __u8 reg; | ||
| 545 | __u8 val; | ||
| 546 | }; | ||
| 547 | struct ov_i2c_regvals { | ||
| 548 | __u8 reg; | ||
| 549 | __u8 val; | ||
| 550 | }; | ||
| 551 | |||
| 552 | static int write_regvals(struct sd *sd, | 1080 | static int write_regvals(struct sd *sd, |
| 553 | const struct ov_regvals *regvals, | 1081 | const struct ov_regvals *regvals, |
| 554 | int n) | 1082 | int n) |
| @@ -591,101 +1119,9 @@ static int write_i2c_regvals(struct sd *sd, | |||
| 591 | static int ov8xx0_configure(struct sd *sd) | 1119 | static int ov8xx0_configure(struct sd *sd) |
| 592 | { | 1120 | { |
| 593 | int rc; | 1121 | int rc; |
| 594 | static const struct ov_i2c_regvals norm_8610[] = { | ||
| 595 | { 0x12, 0x80 }, | ||
| 596 | { 0x00, 0x00 }, | ||
| 597 | { 0x01, 0x80 }, | ||
| 598 | { 0x02, 0x80 }, | ||
| 599 | { 0x03, 0xc0 }, | ||
| 600 | { 0x04, 0x30 }, | ||
| 601 | { 0x05, 0x30 }, /* was 0x10, new from windrv 090403 */ | ||
| 602 | { 0x06, 0x70 }, /* was 0x80, new from windrv 090403 */ | ||
| 603 | { 0x0a, 0x86 }, | ||
| 604 | { 0x0b, 0xb0 }, | ||
| 605 | { 0x0c, 0x20 }, | ||
| 606 | { 0x0d, 0x20 }, | ||
| 607 | { 0x11, 0x01 }, | ||
| 608 | { 0x12, 0x25 }, | ||
| 609 | { 0x13, 0x01 }, | ||
| 610 | { 0x14, 0x04 }, | ||
| 611 | { 0x15, 0x01 }, /* Lin and Win think different about UV order */ | ||
| 612 | { 0x16, 0x03 }, | ||
| 613 | { 0x17, 0x38 }, /* was 0x2f, new from windrv 090403 */ | ||
| 614 | { 0x18, 0xea }, /* was 0xcf, new from windrv 090403 */ | ||
| 615 | { 0x19, 0x02 }, /* was 0x06, new from windrv 090403 */ | ||
| 616 | { 0x1a, 0xf5 }, | ||
| 617 | { 0x1b, 0x00 }, | ||
| 618 | { 0x20, 0xd0 }, /* was 0x90, new from windrv 090403 */ | ||
| 619 | { 0x23, 0xc0 }, /* was 0x00, new from windrv 090403 */ | ||
| 620 | { 0x24, 0x30 }, /* was 0x1d, new from windrv 090403 */ | ||
| 621 | { 0x25, 0x50 }, /* was 0x57, new from windrv 090403 */ | ||
| 622 | { 0x26, 0xa2 }, | ||
| 623 | { 0x27, 0xea }, | ||
| 624 | { 0x28, 0x00 }, | ||
| 625 | { 0x29, 0x00 }, | ||
| 626 | { 0x2a, 0x80 }, | ||
| 627 | { 0x2b, 0xc8 }, /* was 0xcc, new from windrv 090403 */ | ||
| 628 | { 0x2c, 0xac }, | ||
| 629 | { 0x2d, 0x45 }, /* was 0xd5, new from windrv 090403 */ | ||
| 630 | { 0x2e, 0x80 }, | ||
| 631 | { 0x2f, 0x14 }, /* was 0x01, new from windrv 090403 */ | ||
| 632 | { 0x4c, 0x00 }, | ||
| 633 | { 0x4d, 0x30 }, /* was 0x10, new from windrv 090403 */ | ||
| 634 | { 0x60, 0x02 }, /* was 0x01, new from windrv 090403 */ | ||
| 635 | { 0x61, 0x00 }, /* was 0x09, new from windrv 090403 */ | ||
| 636 | { 0x62, 0x5f }, /* was 0xd7, new from windrv 090403 */ | ||
| 637 | { 0x63, 0xff }, | ||
| 638 | { 0x64, 0x53 }, /* new windrv 090403 says 0x57, | ||
| 639 | * maybe thats wrong */ | ||
| 640 | { 0x65, 0x00 }, | ||
| 641 | { 0x66, 0x55 }, | ||
| 642 | { 0x67, 0xb0 }, | ||
| 643 | { 0x68, 0xc0 }, /* was 0xaf, new from windrv 090403 */ | ||
| 644 | { 0x69, 0x02 }, | ||
| 645 | { 0x6a, 0x22 }, | ||
| 646 | { 0x6b, 0x00 }, | ||
| 647 | { 0x6c, 0x99 }, /* was 0x80, old windrv says 0x00, but | ||
| 648 | deleting bit7 colors the first images red */ | ||
| 649 | { 0x6d, 0x11 }, /* was 0x00, new from windrv 090403 */ | ||
| 650 | { 0x6e, 0x11 }, /* was 0x00, new from windrv 090403 */ | ||
| 651 | { 0x6f, 0x01 }, | ||
| 652 | { 0x70, 0x8b }, | ||
| 653 | { 0x71, 0x00 }, | ||
| 654 | { 0x72, 0x14 }, | ||
| 655 | { 0x73, 0x54 }, | ||
| 656 | { 0x74, 0x00 },/* 0x60? - was 0x00, new from windrv 090403 */ | ||
| 657 | { 0x75, 0x0e }, | ||
| 658 | { 0x76, 0x02 }, /* was 0x02, new from windrv 090403 */ | ||
| 659 | { 0x77, 0xff }, | ||
| 660 | { 0x78, 0x80 }, | ||
| 661 | { 0x79, 0x80 }, | ||
| 662 | { 0x7a, 0x80 }, | ||
| 663 | { 0x7b, 0x10 }, /* was 0x13, new from windrv 090403 */ | ||
| 664 | { 0x7c, 0x00 }, | ||
| 665 | { 0x7d, 0x08 }, /* was 0x09, new from windrv 090403 */ | ||
| 666 | { 0x7e, 0x08 }, /* was 0xc0, new from windrv 090403 */ | ||
| 667 | { 0x7f, 0xfb }, | ||
| 668 | { 0x80, 0x28 }, | ||
| 669 | { 0x81, 0x00 }, | ||
| 670 | { 0x82, 0x23 }, | ||
| 671 | { 0x83, 0x0b }, | ||
| 672 | { 0x84, 0x00 }, | ||
| 673 | { 0x85, 0x62 }, /* was 0x61, new from windrv 090403 */ | ||
| 674 | { 0x86, 0xc9 }, | ||
| 675 | { 0x87, 0x00 }, | ||
| 676 | { 0x88, 0x00 }, | ||
| 677 | { 0x89, 0x01 }, | ||
| 678 | { 0x12, 0x20 }, | ||
| 679 | { 0x12, 0x25 }, /* was 0x24, new from windrv 090403 */ | ||
| 680 | }; | ||
| 681 | 1122 | ||
| 682 | PDEBUG(D_PROBE, "starting ov8xx0 configuration"); | 1123 | PDEBUG(D_PROBE, "starting ov8xx0 configuration"); |
| 683 | 1124 | ||
| 684 | if (init_ov_sensor(sd) < 0) | ||
| 685 | PDEBUG(D_ERR|D_PROBE, "Failed to read sensor ID"); | ||
| 686 | else | ||
| 687 | PDEBUG(D_PROBE, "OV86x0 initialized"); | ||
| 688 | |||
| 689 | /* Detect sensor (sub)type */ | 1125 | /* Detect sensor (sub)type */ |
| 690 | rc = i2c_r(sd, OV7610_REG_COM_I); | 1126 | rc = i2c_r(sd, OV7610_REG_COM_I); |
| 691 | if (rc < 0) { | 1127 | if (rc < 0) { |
| @@ -698,9 +1134,6 @@ static int ov8xx0_configure(struct sd *sd) | |||
| 698 | PDEBUG(D_ERR, "Unknown image sensor version: %d", rc & 3); | 1134 | PDEBUG(D_ERR, "Unknown image sensor version: %d", rc & 3); |
| 699 | return -1; | 1135 | return -1; |
| 700 | } | 1136 | } |
| 701 | PDEBUG(D_PROBE, "Writing 8610 registers"); | ||
| 702 | if (write_i2c_regvals(sd, norm_8610, ARRAY_SIZE(norm_8610))) | ||
| 703 | return -1; | ||
| 704 | 1137 | ||
| 705 | /* Set sensor-specific vars */ | 1138 | /* Set sensor-specific vars */ |
| 706 | /* sd->sif = 0; already done */ | 1139 | /* sd->sif = 0; already done */ |
| @@ -714,252 +1147,6 @@ static int ov7xx0_configure(struct sd *sd) | |||
| 714 | { | 1147 | { |
| 715 | int rc, high, low; | 1148 | int rc, high, low; |
| 716 | 1149 | ||
| 717 | /* Lawrence Glaister <lg@jfm.bc.ca> reports: | ||
| 718 | * | ||
| 719 | * Register 0x0f in the 7610 has the following effects: | ||
| 720 | * | ||
| 721 | * 0x85 (AEC method 1): Best overall, good contrast range | ||
| 722 | * 0x45 (AEC method 2): Very overexposed | ||
| 723 | * 0xa5 (spec sheet default): Ok, but the black level is | ||
| 724 | * shifted resulting in loss of contrast | ||
| 725 | * 0x05 (old driver setting): very overexposed, too much | ||
| 726 | * contrast | ||
| 727 | */ | ||
| 728 | static const struct ov_i2c_regvals norm_7610[] = { | ||
| 729 | { 0x10, 0xff }, | ||
| 730 | { 0x16, 0x06 }, | ||
| 731 | { 0x28, 0x24 }, | ||
| 732 | { 0x2b, 0xac }, | ||
| 733 | { 0x12, 0x00 }, | ||
| 734 | { 0x38, 0x81 }, | ||
| 735 | { 0x28, 0x24 }, /* 0c */ | ||
| 736 | { 0x0f, 0x85 }, /* lg's setting */ | ||
| 737 | { 0x15, 0x01 }, | ||
| 738 | { 0x20, 0x1c }, | ||
| 739 | { 0x23, 0x2a }, | ||
| 740 | { 0x24, 0x10 }, | ||
| 741 | { 0x25, 0x8a }, | ||
| 742 | { 0x26, 0xa2 }, | ||
| 743 | { 0x27, 0xc2 }, | ||
| 744 | { 0x2a, 0x04 }, | ||
| 745 | { 0x2c, 0xfe }, | ||
| 746 | { 0x2d, 0x93 }, | ||
| 747 | { 0x30, 0x71 }, | ||
| 748 | { 0x31, 0x60 }, | ||
| 749 | { 0x32, 0x26 }, | ||
| 750 | { 0x33, 0x20 }, | ||
| 751 | { 0x34, 0x48 }, | ||
| 752 | { 0x12, 0x24 }, | ||
| 753 | { 0x11, 0x01 }, | ||
| 754 | { 0x0c, 0x24 }, | ||
| 755 | { 0x0d, 0x24 }, | ||
| 756 | }; | ||
| 757 | |||
| 758 | static const struct ov_i2c_regvals norm_7620[] = { | ||
| 759 | { 0x00, 0x00 }, /* gain */ | ||
| 760 | { 0x01, 0x80 }, /* blue gain */ | ||
| 761 | { 0x02, 0x80 }, /* red gain */ | ||
| 762 | { 0x03, 0xc0 }, /* OV7670_REG_VREF */ | ||
| 763 | { 0x06, 0x60 }, | ||
| 764 | { 0x07, 0x00 }, | ||
| 765 | { 0x0c, 0x24 }, | ||
| 766 | { 0x0c, 0x24 }, | ||
| 767 | { 0x0d, 0x24 }, | ||
| 768 | { 0x11, 0x01 }, | ||
| 769 | { 0x12, 0x24 }, | ||
| 770 | { 0x13, 0x01 }, | ||
| 771 | { 0x14, 0x84 }, | ||
| 772 | { 0x15, 0x01 }, | ||
| 773 | { 0x16, 0x03 }, | ||
| 774 | { 0x17, 0x2f }, | ||
| 775 | { 0x18, 0xcf }, | ||
| 776 | { 0x19, 0x06 }, | ||
| 777 | { 0x1a, 0xf5 }, | ||
| 778 | { 0x1b, 0x00 }, | ||
| 779 | { 0x20, 0x18 }, | ||
| 780 | { 0x21, 0x80 }, | ||
| 781 | { 0x22, 0x80 }, | ||
| 782 | { 0x23, 0x00 }, | ||
| 783 | { 0x26, 0xa2 }, | ||
| 784 | { 0x27, 0xea }, | ||
| 785 | { 0x28, 0x20 }, | ||
| 786 | { 0x29, 0x00 }, | ||
| 787 | { 0x2a, 0x10 }, | ||
| 788 | { 0x2b, 0x00 }, | ||
| 789 | { 0x2c, 0x88 }, | ||
| 790 | { 0x2d, 0x91 }, | ||
| 791 | { 0x2e, 0x80 }, | ||
| 792 | { 0x2f, 0x44 }, | ||
| 793 | { 0x60, 0x27 }, | ||
| 794 | { 0x61, 0x02 }, | ||
| 795 | { 0x62, 0x5f }, | ||
| 796 | { 0x63, 0xd5 }, | ||
| 797 | { 0x64, 0x57 }, | ||
| 798 | { 0x65, 0x83 }, | ||
| 799 | { 0x66, 0x55 }, | ||
| 800 | { 0x67, 0x92 }, | ||
| 801 | { 0x68, 0xcf }, | ||
| 802 | { 0x69, 0x76 }, | ||
| 803 | { 0x6a, 0x22 }, | ||
| 804 | { 0x6b, 0x00 }, | ||
| 805 | { 0x6c, 0x02 }, | ||
| 806 | { 0x6d, 0x44 }, | ||
| 807 | { 0x6e, 0x80 }, | ||
| 808 | { 0x6f, 0x1d }, | ||
| 809 | { 0x70, 0x8b }, | ||
| 810 | { 0x71, 0x00 }, | ||
| 811 | { 0x72, 0x14 }, | ||
| 812 | { 0x73, 0x54 }, | ||
| 813 | { 0x74, 0x00 }, | ||
| 814 | { 0x75, 0x8e }, | ||
| 815 | { 0x76, 0x00 }, | ||
| 816 | { 0x77, 0xff }, | ||
| 817 | { 0x78, 0x80 }, | ||
| 818 | { 0x79, 0x80 }, | ||
| 819 | { 0x7a, 0x80 }, | ||
| 820 | { 0x7b, 0xe2 }, | ||
| 821 | { 0x7c, 0x00 }, | ||
| 822 | }; | ||
| 823 | |||
| 824 | /* 7640 and 7648. The defaults should be OK for most registers. */ | ||
| 825 | static const struct ov_i2c_regvals norm_7640[] = { | ||
| 826 | { 0x12, 0x80 }, | ||
| 827 | { 0x12, 0x14 }, | ||
| 828 | }; | ||
| 829 | |||
| 830 | /* 7670. Defaults taken from OmniVision provided data, | ||
| 831 | * as provided by Jonathan Corbet of OLPC */ | ||
| 832 | static const struct ov_i2c_regvals norm_7670[] = { | ||
| 833 | { OV7670_REG_COM7, OV7670_COM7_RESET }, | ||
| 834 | { OV7670_REG_TSLB, 0x04 }, /* OV */ | ||
| 835 | { OV7670_REG_COM7, OV7670_COM7_FMT_VGA }, /* VGA */ | ||
| 836 | { OV7670_REG_CLKRC, 0x01 }, | ||
| 837 | /* | ||
| 838 | * Set the hardware window. These values from OV don't entirely | ||
| 839 | * make sense - hstop is less than hstart. But they work... | ||
| 840 | */ | ||
| 841 | { OV7670_REG_HSTART, 0x13 }, { OV7670_REG_HSTOP, 0x01 }, | ||
| 842 | { OV7670_REG_HREF, 0xb6 }, { OV7670_REG_VSTART, 0x02 }, | ||
| 843 | { OV7670_REG_VSTOP, 0x7a }, { OV7670_REG_VREF, 0x0a }, | ||
| 844 | |||
| 845 | { OV7670_REG_COM3, 0 }, { OV7670_REG_COM14, 0 }, | ||
| 846 | /* Mystery scaling numbers */ | ||
| 847 | { 0x70, 0x3a }, { 0x71, 0x35 }, | ||
| 848 | { 0x72, 0x11 }, { 0x73, 0xf0 }, | ||
| 849 | { 0xa2, 0x02 }, | ||
| 850 | /* { OV7670_REG_COM10, 0x0 }, */ | ||
| 851 | |||
| 852 | /* Gamma curve values */ | ||
| 853 | { 0x7a, 0x20 }, | ||
| 854 | { 0x7b, 0x10 }, | ||
| 855 | { 0x7c, 0x1e }, | ||
| 856 | { 0x7d, 0x35 }, | ||
| 857 | { 0x7e, 0x5a }, { 0x7f, 0x69 }, | ||
| 858 | { 0x80, 0x76 }, { 0x81, 0x80 }, | ||
| 859 | { 0x82, 0x88 }, { 0x83, 0x8f }, | ||
| 860 | { 0x84, 0x96 }, { 0x85, 0xa3 }, | ||
| 861 | { 0x86, 0xaf }, { 0x87, 0xc4 }, | ||
| 862 | { 0x88, 0xd7 }, { 0x89, 0xe8 }, | ||
| 863 | |||
| 864 | /* AGC and AEC parameters. Note we start by disabling those features, | ||
| 865 | then turn them only after tweaking the values. */ | ||
| 866 | { OV7670_REG_COM8, OV7670_COM8_FASTAEC | ||
| 867 | | OV7670_COM8_AECSTEP | ||
| 868 | | OV7670_COM8_BFILT }, | ||
| 869 | { OV7670_REG_GAIN, 0 }, { OV7670_REG_AECH, 0 }, | ||
| 870 | { OV7670_REG_COM4, 0x40 }, /* magic reserved bit */ | ||
| 871 | { OV7670_REG_COM9, 0x18 }, /* 4x gain + magic rsvd bit */ | ||
| 872 | { OV7670_REG_BD50MAX, 0x05 }, { OV7670_REG_BD60MAX, 0x07 }, | ||
| 873 | { OV7670_REG_AEW, 0x95 }, { OV7670_REG_AEB, 0x33 }, | ||
| 874 | { OV7670_REG_VPT, 0xe3 }, { OV7670_REG_HAECC1, 0x78 }, | ||
| 875 | { OV7670_REG_HAECC2, 0x68 }, | ||
| 876 | { 0xa1, 0x03 }, /* magic */ | ||
| 877 | { OV7670_REG_HAECC3, 0xd8 }, { OV7670_REG_HAECC4, 0xd8 }, | ||
| 878 | { OV7670_REG_HAECC5, 0xf0 }, { OV7670_REG_HAECC6, 0x90 }, | ||
| 879 | { OV7670_REG_HAECC7, 0x94 }, | ||
| 880 | { OV7670_REG_COM8, OV7670_COM8_FASTAEC | ||
| 881 | | OV7670_COM8_AECSTEP | ||
| 882 | | OV7670_COM8_BFILT | ||
| 883 | | OV7670_COM8_AGC | ||
| 884 | | OV7670_COM8_AEC }, | ||
| 885 | |||
| 886 | /* Almost all of these are magic "reserved" values. */ | ||
| 887 | { OV7670_REG_COM5, 0x61 }, { OV7670_REG_COM6, 0x4b }, | ||
| 888 | { 0x16, 0x02 }, | ||
| 889 | { OV7670_REG_MVFP, 0x07 }, | ||
| 890 | { 0x21, 0x02 }, { 0x22, 0x91 }, | ||
| 891 | { 0x29, 0x07 }, { 0x33, 0x0b }, | ||
| 892 | { 0x35, 0x0b }, { 0x37, 0x1d }, | ||
| 893 | { 0x38, 0x71 }, { 0x39, 0x2a }, | ||
| 894 | { OV7670_REG_COM12, 0x78 }, { 0x4d, 0x40 }, | ||
| 895 | { 0x4e, 0x20 }, { OV7670_REG_GFIX, 0 }, | ||
| 896 | { 0x6b, 0x4a }, { 0x74, 0x10 }, | ||
| 897 | { 0x8d, 0x4f }, { 0x8e, 0 }, | ||
| 898 | { 0x8f, 0 }, { 0x90, 0 }, | ||
| 899 | { 0x91, 0 }, { 0x96, 0 }, | ||
| 900 | { 0x9a, 0 }, { 0xb0, 0x84 }, | ||
| 901 | { 0xb1, 0x0c }, { 0xb2, 0x0e }, | ||
| 902 | { 0xb3, 0x82 }, { 0xb8, 0x0a }, | ||
| 903 | |||
| 904 | /* More reserved magic, some of which tweaks white balance */ | ||
| 905 | { 0x43, 0x0a }, { 0x44, 0xf0 }, | ||
| 906 | { 0x45, 0x34 }, { 0x46, 0x58 }, | ||
| 907 | { 0x47, 0x28 }, { 0x48, 0x3a }, | ||
| 908 | { 0x59, 0x88 }, { 0x5a, 0x88 }, | ||
| 909 | { 0x5b, 0x44 }, { 0x5c, 0x67 }, | ||
| 910 | { 0x5d, 0x49 }, { 0x5e, 0x0e }, | ||
| 911 | { 0x6c, 0x0a }, { 0x6d, 0x55 }, | ||
| 912 | { 0x6e, 0x11 }, { 0x6f, 0x9f }, | ||
| 913 | /* "9e for advance AWB" */ | ||
| 914 | { 0x6a, 0x40 }, { OV7670_REG_BLUE, 0x40 }, | ||
| 915 | { OV7670_REG_RED, 0x60 }, | ||
| 916 | { OV7670_REG_COM8, OV7670_COM8_FASTAEC | ||
| 917 | | OV7670_COM8_AECSTEP | ||
| 918 | | OV7670_COM8_BFILT | ||
| 919 | | OV7670_COM8_AGC | ||
| 920 | | OV7670_COM8_AEC | ||
| 921 | | OV7670_COM8_AWB }, | ||
| 922 | |||
| 923 | /* Matrix coefficients */ | ||
| 924 | { 0x4f, 0x80 }, { 0x50, 0x80 }, | ||
| 925 | { 0x51, 0 }, { 0x52, 0x22 }, | ||
| 926 | { 0x53, 0x5e }, { 0x54, 0x80 }, | ||
| 927 | { 0x58, 0x9e }, | ||
| 928 | |||
| 929 | { OV7670_REG_COM16, OV7670_COM16_AWBGAIN }, | ||
| 930 | { OV7670_REG_EDGE, 0 }, | ||
| 931 | { 0x75, 0x05 }, { 0x76, 0xe1 }, | ||
| 932 | { 0x4c, 0 }, { 0x77, 0x01 }, | ||
| 933 | { OV7670_REG_COM13, OV7670_COM13_GAMMA | ||
| 934 | | OV7670_COM13_UVSAT | ||
| 935 | | 2}, /* was 3 */ | ||
| 936 | { 0x4b, 0x09 }, | ||
| 937 | { 0xc9, 0x60 }, { OV7670_REG_COM16, 0x38 }, | ||
| 938 | { 0x56, 0x40 }, | ||
| 939 | |||
| 940 | { 0x34, 0x11 }, | ||
| 941 | { OV7670_REG_COM11, OV7670_COM11_EXP|OV7670_COM11_HZAUTO }, | ||
| 942 | { 0xa4, 0x88 }, { 0x96, 0 }, | ||
| 943 | { 0x97, 0x30 }, { 0x98, 0x20 }, | ||
| 944 | { 0x99, 0x30 }, { 0x9a, 0x84 }, | ||
| 945 | { 0x9b, 0x29 }, { 0x9c, 0x03 }, | ||
| 946 | { 0x9d, 0x4c }, { 0x9e, 0x3f }, | ||
| 947 | { 0x78, 0x04 }, | ||
| 948 | |||
| 949 | /* Extra-weird stuff. Some sort of multiplexor register */ | ||
| 950 | { 0x79, 0x01 }, { 0xc8, 0xf0 }, | ||
| 951 | { 0x79, 0x0f }, { 0xc8, 0x00 }, | ||
| 952 | { 0x79, 0x10 }, { 0xc8, 0x7e }, | ||
| 953 | { 0x79, 0x0a }, { 0xc8, 0x80 }, | ||
| 954 | { 0x79, 0x0b }, { 0xc8, 0x01 }, | ||
| 955 | { 0x79, 0x0c }, { 0xc8, 0x0f }, | ||
| 956 | { 0x79, 0x0d }, { 0xc8, 0x20 }, | ||
| 957 | { 0x79, 0x09 }, { 0xc8, 0x80 }, | ||
| 958 | { 0x79, 0x02 }, { 0xc8, 0xc0 }, | ||
| 959 | { 0x79, 0x03 }, { 0xc8, 0x40 }, | ||
| 960 | { 0x79, 0x05 }, { 0xc8, 0x30 }, | ||
| 961 | { 0x79, 0x26 }, | ||
| 962 | }; | ||
| 963 | 1150 | ||
| 964 | PDEBUG(D_PROBE, "starting OV7xx0 configuration"); | 1151 | PDEBUG(D_PROBE, "starting OV7xx0 configuration"); |
| 965 | 1152 | ||
| @@ -1011,8 +1198,9 @@ static int ov7xx0_configure(struct sd *sd) | |||
| 1011 | switch (low) { | 1198 | switch (low) { |
| 1012 | case 0x30: | 1199 | case 0x30: |
| 1013 | PDEBUG(D_PROBE, "Sensor is an OV7630/OV7635"); | 1200 | PDEBUG(D_PROBE, "Sensor is an OV7630/OV7635"); |
| 1014 | sd->sensor = SEN_OV7630; | 1201 | PDEBUG(D_ERR, |
| 1015 | break; | 1202 | "7630 is not supported by this driver"); |
| 1203 | return -1; | ||
| 1016 | case 0x40: | 1204 | case 0x40: |
| 1017 | PDEBUG(D_PROBE, "Sensor is an OV7645"); | 1205 | PDEBUG(D_PROBE, "Sensor is an OV7645"); |
| 1018 | sd->sensor = SEN_OV7640; /* FIXME */ | 1206 | sd->sensor = SEN_OV7640; /* FIXME */ |
| @@ -1038,32 +1226,6 @@ static int ov7xx0_configure(struct sd *sd) | |||
| 1038 | return -1; | 1226 | return -1; |
| 1039 | } | 1227 | } |
| 1040 | 1228 | ||
| 1041 | switch (sd->sensor) { | ||
| 1042 | case SEN_OV7620: | ||
| 1043 | PDEBUG(D_PROBE, "Writing 7620 registers"); | ||
| 1044 | if (write_i2c_regvals(sd, norm_7620, ARRAY_SIZE(norm_7620))) | ||
| 1045 | return -1; | ||
| 1046 | break; | ||
| 1047 | case SEN_OV7630: | ||
| 1048 | PDEBUG(D_ERR, "7630 is not supported by this driver version"); | ||
| 1049 | return -1; | ||
| 1050 | case SEN_OV7640: | ||
| 1051 | PDEBUG(D_PROBE, "Writing 7640 registers"); | ||
| 1052 | if (write_i2c_regvals(sd, norm_7640, ARRAY_SIZE(norm_7640))) | ||
| 1053 | return -1; | ||
| 1054 | break; | ||
| 1055 | case SEN_OV7670: | ||
| 1056 | PDEBUG(D_PROBE, "Writing 7670 registers"); | ||
| 1057 | if (write_i2c_regvals(sd, norm_7670, ARRAY_SIZE(norm_7670))) | ||
| 1058 | return -1; | ||
| 1059 | break; | ||
| 1060 | default: | ||
| 1061 | PDEBUG(D_PROBE, "Writing 7610 registers"); | ||
| 1062 | if (write_i2c_regvals(sd, norm_7610, ARRAY_SIZE(norm_7610))) | ||
| 1063 | return -1; | ||
| 1064 | break; | ||
| 1065 | } | ||
| 1066 | |||
| 1067 | /* Set sensor-specific vars */ | 1229 | /* Set sensor-specific vars */ |
| 1068 | /* sd->sif = 0; already done */ | 1230 | /* sd->sif = 0; already done */ |
| 1069 | return 0; | 1231 | return 0; |
| @@ -1073,141 +1235,7 @@ static int ov7xx0_configure(struct sd *sd) | |||
| 1073 | static int ov6xx0_configure(struct sd *sd) | 1235 | static int ov6xx0_configure(struct sd *sd) |
| 1074 | { | 1236 | { |
| 1075 | int rc; | 1237 | int rc; |
| 1076 | static const struct ov_i2c_regvals norm_6x20[] = { | 1238 | PDEBUG(D_PROBE, "starting OV6xx0 configuration"); |
| 1077 | { 0x12, 0x80 }, /* reset */ | ||
| 1078 | { 0x11, 0x01 }, | ||
| 1079 | { 0x03, 0x60 }, | ||
| 1080 | { 0x05, 0x7f }, /* For when autoadjust is off */ | ||
| 1081 | { 0x07, 0xa8 }, | ||
| 1082 | /* The ratio of 0x0c and 0x0d controls the white point */ | ||
| 1083 | { 0x0c, 0x24 }, | ||
| 1084 | { 0x0d, 0x24 }, | ||
| 1085 | { 0x0f, 0x15 }, /* COMS */ | ||
| 1086 | { 0x10, 0x75 }, /* AEC Exposure time */ | ||
| 1087 | { 0x12, 0x24 }, /* Enable AGC */ | ||
| 1088 | { 0x14, 0x04 }, | ||
| 1089 | /* 0x16: 0x06 helps frame stability with moving objects */ | ||
| 1090 | { 0x16, 0x06 }, | ||
| 1091 | /* { 0x20, 0x30 }, * Aperture correction enable */ | ||
| 1092 | { 0x26, 0xb2 }, /* BLC enable */ | ||
| 1093 | /* 0x28: 0x05 Selects RGB format if RGB on */ | ||
| 1094 | { 0x28, 0x05 }, | ||
| 1095 | { 0x2a, 0x04 }, /* Disable framerate adjust */ | ||
| 1096 | /* { 0x2b, 0xac }, * Framerate; Set 2a[7] first */ | ||
| 1097 | { 0x2d, 0x99 }, | ||
| 1098 | { 0x33, 0xa0 }, /* Color Processing Parameter */ | ||
| 1099 | { 0x34, 0xd2 }, /* Max A/D range */ | ||
| 1100 | { 0x38, 0x8b }, | ||
| 1101 | { 0x39, 0x40 }, | ||
| 1102 | |||
| 1103 | { 0x3c, 0x39 }, /* Enable AEC mode changing */ | ||
| 1104 | { 0x3c, 0x3c }, /* Change AEC mode */ | ||
| 1105 | { 0x3c, 0x24 }, /* Disable AEC mode changing */ | ||
| 1106 | |||
| 1107 | { 0x3d, 0x80 }, | ||
| 1108 | /* These next two registers (0x4a, 0x4b) are undocumented. | ||
| 1109 | * They control the color balance */ | ||
| 1110 | { 0x4a, 0x80 }, | ||
| 1111 | { 0x4b, 0x80 }, | ||
| 1112 | { 0x4d, 0xd2 }, /* This reduces noise a bit */ | ||
| 1113 | { 0x4e, 0xc1 }, | ||
| 1114 | { 0x4f, 0x04 }, | ||
| 1115 | /* Do 50-53 have any effect? */ | ||
| 1116 | /* Toggle 0x12[2] off and on here? */ | ||
| 1117 | }; | ||
| 1118 | |||
| 1119 | static const struct ov_i2c_regvals norm_6x30[] = { | ||
| 1120 | { 0x12, 0x80 }, /* Reset */ | ||
| 1121 | { 0x00, 0x1f }, /* Gain */ | ||
| 1122 | { 0x01, 0x99 }, /* Blue gain */ | ||
| 1123 | { 0x02, 0x7c }, /* Red gain */ | ||
| 1124 | { 0x03, 0xc0 }, /* Saturation */ | ||
| 1125 | { 0x05, 0x0a }, /* Contrast */ | ||
| 1126 | { 0x06, 0x95 }, /* Brightness */ | ||
| 1127 | { 0x07, 0x2d }, /* Sharpness */ | ||
| 1128 | { 0x0c, 0x20 }, | ||
| 1129 | { 0x0d, 0x20 }, | ||
| 1130 | { 0x0e, 0x20 }, | ||
| 1131 | { 0x0f, 0x05 }, | ||
| 1132 | { 0x10, 0x9a }, | ||
| 1133 | { 0x11, 0x00 }, /* Pixel clock = fastest */ | ||
| 1134 | { 0x12, 0x24 }, /* Enable AGC and AWB */ | ||
| 1135 | { 0x13, 0x21 }, | ||
| 1136 | { 0x14, 0x80 }, | ||
| 1137 | { 0x15, 0x01 }, | ||
| 1138 | { 0x16, 0x03 }, | ||
| 1139 | { 0x17, 0x38 }, | ||
| 1140 | { 0x18, 0xea }, | ||
| 1141 | { 0x19, 0x04 }, | ||
| 1142 | { 0x1a, 0x93 }, | ||
| 1143 | { 0x1b, 0x00 }, | ||
| 1144 | { 0x1e, 0xc4 }, | ||
| 1145 | { 0x1f, 0x04 }, | ||
| 1146 | { 0x20, 0x20 }, | ||
| 1147 | { 0x21, 0x10 }, | ||
| 1148 | { 0x22, 0x88 }, | ||
| 1149 | { 0x23, 0xc0 }, /* Crystal circuit power level */ | ||
| 1150 | { 0x25, 0x9a }, /* Increase AEC black ratio */ | ||
| 1151 | { 0x26, 0xb2 }, /* BLC enable */ | ||
| 1152 | { 0x27, 0xa2 }, | ||
| 1153 | { 0x28, 0x00 }, | ||
| 1154 | { 0x29, 0x00 }, | ||
| 1155 | { 0x2a, 0x84 }, /* 60 Hz power */ | ||
| 1156 | { 0x2b, 0xa8 }, /* 60 Hz power */ | ||
| 1157 | { 0x2c, 0xa0 }, | ||
| 1158 | { 0x2d, 0x95 }, /* Enable auto-brightness */ | ||
| 1159 | { 0x2e, 0x88 }, | ||
| 1160 | { 0x33, 0x26 }, | ||
| 1161 | { 0x34, 0x03 }, | ||
| 1162 | { 0x36, 0x8f }, | ||
| 1163 | { 0x37, 0x80 }, | ||
| 1164 | { 0x38, 0x83 }, | ||
| 1165 | { 0x39, 0x80 }, | ||
| 1166 | { 0x3a, 0x0f }, | ||
| 1167 | { 0x3b, 0x3c }, | ||
| 1168 | { 0x3c, 0x1a }, | ||
| 1169 | { 0x3d, 0x80 }, | ||
| 1170 | { 0x3e, 0x80 }, | ||
| 1171 | { 0x3f, 0x0e }, | ||
| 1172 | { 0x40, 0x00 }, /* White bal */ | ||
| 1173 | { 0x41, 0x00 }, /* White bal */ | ||
| 1174 | { 0x42, 0x80 }, | ||
| 1175 | { 0x43, 0x3f }, /* White bal */ | ||
| 1176 | { 0x44, 0x80 }, | ||
| 1177 | { 0x45, 0x20 }, | ||
| 1178 | { 0x46, 0x20 }, | ||
| 1179 | { 0x47, 0x80 }, | ||
| 1180 | { 0x48, 0x7f }, | ||
| 1181 | { 0x49, 0x00 }, | ||
| 1182 | { 0x4a, 0x00 }, | ||
| 1183 | { 0x4b, 0x80 }, | ||
| 1184 | { 0x4c, 0xd0 }, | ||
| 1185 | { 0x4d, 0x10 }, /* U = 0.563u, V = 0.714v */ | ||
| 1186 | { 0x4e, 0x40 }, | ||
| 1187 | { 0x4f, 0x07 }, /* UV avg., col. killer: max */ | ||
| 1188 | { 0x50, 0xff }, | ||
| 1189 | { 0x54, 0x23 }, /* Max AGC gain: 18dB */ | ||
| 1190 | { 0x55, 0xff }, | ||
| 1191 | { 0x56, 0x12 }, | ||
| 1192 | { 0x57, 0x81 }, | ||
| 1193 | { 0x58, 0x75 }, | ||
| 1194 | { 0x59, 0x01 }, /* AGC dark current comp.: +1 */ | ||
| 1195 | { 0x5a, 0x2c }, | ||
| 1196 | { 0x5b, 0x0f }, /* AWB chrominance levels */ | ||
| 1197 | { 0x5c, 0x10 }, | ||
| 1198 | { 0x3d, 0x80 }, | ||
| 1199 | { 0x27, 0xa6 }, | ||
| 1200 | { 0x12, 0x20 }, /* Toggle AWB */ | ||
| 1201 | { 0x12, 0x24 }, | ||
| 1202 | }; | ||
| 1203 | |||
| 1204 | PDEBUG(D_PROBE, "starting sensor configuration"); | ||
| 1205 | |||
| 1206 | if (init_ov_sensor(sd) < 0) { | ||
| 1207 | PDEBUG(D_ERR, "Failed to read sensor ID."); | ||
| 1208 | return -1; | ||
| 1209 | } | ||
| 1210 | PDEBUG(D_PROBE, "OV6xx0 sensor detected"); | ||
| 1211 | 1239 | ||
| 1212 | /* Detect sensor (sub)type */ | 1240 | /* Detect sensor (sub)type */ |
| 1213 | rc = i2c_r(sd, OV7610_REG_COM_I); | 1241 | rc = i2c_r(sd, OV7610_REG_COM_I); |
| @@ -1251,15 +1279,6 @@ static int ov6xx0_configure(struct sd *sd) | |||
| 1251 | /* Set sensor-specific vars */ | 1279 | /* Set sensor-specific vars */ |
| 1252 | sd->sif = 1; | 1280 | sd->sif = 1; |
| 1253 | 1281 | ||
| 1254 | if (sd->sensor == SEN_OV6620) { | ||
| 1255 | PDEBUG(D_PROBE, "Writing 6x20 registers"); | ||
| 1256 | if (write_i2c_regvals(sd, norm_6x20, ARRAY_SIZE(norm_6x20))) | ||
| 1257 | return -1; | ||
| 1258 | } else { | ||
| 1259 | PDEBUG(D_PROBE, "Writing 6x30 registers"); | ||
| 1260 | if (write_i2c_regvals(sd, norm_6x30, ARRAY_SIZE(norm_6x30))) | ||
| 1261 | return -1; | ||
| 1262 | } | ||
| 1263 | return 0; | 1282 | return 0; |
| 1264 | } | 1283 | } |
| 1265 | 1284 | ||
| @@ -1298,22 +1317,31 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
| 1298 | ov51x_led_control(sd, 0); /* turn LED off */ | 1317 | ov51x_led_control(sd, 0); /* turn LED off */ |
| 1299 | 1318 | ||
| 1300 | /* Test for 76xx */ | 1319 | /* Test for 76xx */ |
| 1301 | sd->primary_i2c_slave = OV7xx0_SID; | ||
| 1302 | if (ov51x_set_slave_ids(sd, OV7xx0_SID) < 0) | 1320 | if (ov51x_set_slave_ids(sd, OV7xx0_SID) < 0) |
| 1303 | goto error; | 1321 | goto error; |
| 1304 | 1322 | ||
| 1305 | /* The OV519 must be more aggressive about sensor detection since | 1323 | /* The OV519 must be more aggressive about sensor detection since |
| 1306 | * I2C write will never fail if the sensor is not present. We have | 1324 | * I2C write will never fail if the sensor is not present. We have |
| 1307 | * to try to initialize the sensor to detect its presence */ | 1325 | * to try to initialize the sensor to detect its presence */ |
| 1308 | if (init_ov_sensor(sd) < 0) { | 1326 | if (init_ov_sensor(sd) >= 0) { |
| 1327 | if (ov7xx0_configure(sd) < 0) { | ||
| 1328 | PDEBUG(D_ERR, "Failed to configure OV7xx0"); | ||
| 1329 | goto error; | ||
| 1330 | } | ||
| 1331 | } else { | ||
| 1332 | |||
| 1309 | /* Test for 6xx0 */ | 1333 | /* Test for 6xx0 */ |
| 1310 | sd->primary_i2c_slave = OV6xx0_SID; | ||
| 1311 | if (ov51x_set_slave_ids(sd, OV6xx0_SID) < 0) | 1334 | if (ov51x_set_slave_ids(sd, OV6xx0_SID) < 0) |
| 1312 | goto error; | 1335 | goto error; |
| 1313 | 1336 | ||
| 1314 | if (init_ov_sensor(sd) < 0) { | 1337 | if (init_ov_sensor(sd) >= 0) { |
| 1338 | if (ov6xx0_configure(sd) < 0) { | ||
| 1339 | PDEBUG(D_ERR, "Failed to configure OV6xx0"); | ||
| 1340 | goto error; | ||
| 1341 | } | ||
| 1342 | } else { | ||
| 1343 | |||
| 1315 | /* Test for 8xx0 */ | 1344 | /* Test for 8xx0 */ |
| 1316 | sd->primary_i2c_slave = OV8xx0_SID; | ||
| 1317 | if (ov51x_set_slave_ids(sd, OV8xx0_SID) < 0) | 1345 | if (ov51x_set_slave_ids(sd, OV8xx0_SID) < 0) |
| 1318 | goto error; | 1346 | goto error; |
| 1319 | 1347 | ||
| @@ -1321,24 +1349,13 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
| 1321 | PDEBUG(D_ERR, | 1349 | PDEBUG(D_ERR, |
| 1322 | "Can't determine sensor slave IDs"); | 1350 | "Can't determine sensor slave IDs"); |
| 1323 | goto error; | 1351 | goto error; |
| 1324 | } else { | ||
| 1325 | if (ov8xx0_configure(sd) < 0) { | ||
| 1326 | PDEBUG(D_ERR, | ||
| 1327 | "Failed to configure OV8xx0 sensor"); | ||
| 1328 | goto error; | ||
| 1329 | } | ||
| 1330 | } | 1352 | } |
| 1331 | } else { | 1353 | if (ov8xx0_configure(sd) < 0) { |
| 1332 | if (ov6xx0_configure(sd) < 0) { | 1354 | PDEBUG(D_ERR, |
| 1333 | PDEBUG(D_ERR, "Failed to configure OV6xx0"); | 1355 | "Failed to configure OV8xx0 sensor"); |
| 1334 | goto error; | 1356 | goto error; |
| 1335 | } | 1357 | } |
| 1336 | } | 1358 | } |
| 1337 | } else { | ||
| 1338 | if (ov7xx0_configure(sd) < 0) { | ||
| 1339 | PDEBUG(D_ERR, "Failed to configure OV7xx0"); | ||
| 1340 | goto error; | ||
| 1341 | } | ||
| 1342 | } | 1359 | } |
| 1343 | 1360 | ||
| 1344 | cam = &gspca_dev->cam; | 1361 | cam = &gspca_dev->cam; |
| @@ -1355,15 +1372,53 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
| 1355 | sd->colors = COLOR_DEF; | 1372 | sd->colors = COLOR_DEF; |
| 1356 | sd->hflip = HFLIP_DEF; | 1373 | sd->hflip = HFLIP_DEF; |
| 1357 | sd->vflip = VFLIP_DEF; | 1374 | sd->vflip = VFLIP_DEF; |
| 1375 | if (sd->sensor != SEN_OV7670) | ||
| 1376 | gspca_dev->ctrl_dis = (1 << HFLIP_IDX) | ||
| 1377 | | (1 << VFLIP_IDX); | ||
| 1358 | return 0; | 1378 | return 0; |
| 1359 | error: | 1379 | error: |
| 1360 | PDEBUG(D_ERR, "OV519 Config failed"); | 1380 | PDEBUG(D_ERR, "OV519 Config failed"); |
| 1361 | return -EBUSY; | 1381 | return -EBUSY; |
| 1362 | } | 1382 | } |
| 1363 | 1383 | ||
| 1364 | /* this function is called at open time */ | 1384 | /* this function is called at probe and resume time */ |
| 1365 | static int sd_open(struct gspca_dev *gspca_dev) | 1385 | static int sd_init(struct gspca_dev *gspca_dev) |
| 1366 | { | 1386 | { |
| 1387 | struct sd *sd = (struct sd *) gspca_dev; | ||
| 1388 | |||
| 1389 | /* initialize the sensor */ | ||
| 1390 | switch (sd->sensor) { | ||
| 1391 | case SEN_OV6620: | ||
| 1392 | if (write_i2c_regvals(sd, norm_6x20, ARRAY_SIZE(norm_6x20))) | ||
| 1393 | return -EIO; | ||
| 1394 | break; | ||
| 1395 | case SEN_OV6630: | ||
| 1396 | if (write_i2c_regvals(sd, norm_6x30, ARRAY_SIZE(norm_6x30))) | ||
| 1397 | return -EIO; | ||
| 1398 | break; | ||
| 1399 | default: | ||
| 1400 | /* case SEN_OV7610: */ | ||
| 1401 | /* case SEN_OV76BE: */ | ||
| 1402 | if (write_i2c_regvals(sd, norm_7610, ARRAY_SIZE(norm_7610))) | ||
| 1403 | return -EIO; | ||
| 1404 | break; | ||
| 1405 | case SEN_OV7620: | ||
| 1406 | if (write_i2c_regvals(sd, norm_7620, ARRAY_SIZE(norm_7620))) | ||
| 1407 | return -EIO; | ||
| 1408 | break; | ||
| 1409 | case SEN_OV7640: | ||
| 1410 | if (write_i2c_regvals(sd, norm_7640, ARRAY_SIZE(norm_7640))) | ||
| 1411 | return -EIO; | ||
| 1412 | break; | ||
| 1413 | case SEN_OV7670: | ||
| 1414 | if (write_i2c_regvals(sd, norm_7670, ARRAY_SIZE(norm_7670))) | ||
| 1415 | return -EIO; | ||
| 1416 | break; | ||
| 1417 | case SEN_OV8610: | ||
| 1418 | if (write_i2c_regvals(sd, norm_8610, ARRAY_SIZE(norm_8610))) | ||
| 1419 | return -EIO; | ||
| 1420 | break; | ||
| 1421 | } | ||
| 1367 | return 0; | 1422 | return 0; |
| 1368 | } | 1423 | } |
| 1369 | 1424 | ||
| @@ -1827,14 +1882,6 @@ static void sd_stopN(struct gspca_dev *gspca_dev) | |||
| 1827 | ov51x_led_control((struct sd *) gspca_dev, 0); | 1882 | ov51x_led_control((struct sd *) gspca_dev, 0); |
| 1828 | } | 1883 | } |
| 1829 | 1884 | ||
| 1830 | static void sd_stop0(struct gspca_dev *gspca_dev) | ||
| 1831 | { | ||
| 1832 | } | ||
| 1833 | |||
| 1834 | static void sd_close(struct gspca_dev *gspca_dev) | ||
| 1835 | { | ||
| 1836 | } | ||
| 1837 | |||
| 1838 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, | 1885 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, |
| 1839 | struct gspca_frame *frame, /* target */ | 1886 | struct gspca_frame *frame, /* target */ |
| 1840 | __u8 *data, /* isoc packet */ | 1887 | __u8 *data, /* isoc packet */ |
| @@ -2091,11 +2138,9 @@ static const struct sd_desc sd_desc = { | |||
| 2091 | .ctrls = sd_ctrls, | 2138 | .ctrls = sd_ctrls, |
| 2092 | .nctrls = ARRAY_SIZE(sd_ctrls), | 2139 | .nctrls = ARRAY_SIZE(sd_ctrls), |
| 2093 | .config = sd_config, | 2140 | .config = sd_config, |
| 2094 | .open = sd_open, | 2141 | .init = sd_init, |
| 2095 | .start = sd_start, | 2142 | .start = sd_start, |
| 2096 | .stopN = sd_stopN, | 2143 | .stopN = sd_stopN, |
| 2097 | .stop0 = sd_stop0, | ||
| 2098 | .close = sd_close, | ||
| 2099 | .pkt_scan = sd_pkt_scan, | 2144 | .pkt_scan = sd_pkt_scan, |
| 2100 | }; | 2145 | }; |
| 2101 | 2146 | ||
| @@ -2132,6 +2177,10 @@ static struct usb_driver sd_driver = { | |||
| 2132 | .id_table = device_table, | 2177 | .id_table = device_table, |
| 2133 | .probe = sd_probe, | 2178 | .probe = sd_probe, |
| 2134 | .disconnect = gspca_disconnect, | 2179 | .disconnect = gspca_disconnect, |
| 2180 | #ifdef CONFIG_PM | ||
| 2181 | .suspend = gspca_suspend, | ||
| 2182 | .resume = gspca_resume, | ||
| 2183 | #endif | ||
| 2135 | }; | 2184 | }; |
| 2136 | 2185 | ||
| 2137 | /* -- module insert / remove -- */ | 2186 | /* -- module insert / remove -- */ |
