aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/gspca/ov519.c
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2009-10-11 08:49:03 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-12-05 15:40:32 -0500
commit635118d5b19c4ad562d425a3f3491c721d6a8293 (patch)
tree943a00891b568b3e3ec29f75ffb04018b567c05e /drivers/media/video/gspca/ov519.c
parent229bb7dc5181b3264550532a26a9c698be56fcb8 (diff)
V4L/DVB (13144): gspca_ov519: Add support for OV2610 and OV3610 sensors
This patch adds support for the OV2610 and OV3610 sensors to the gspca ov519 subdriver. This is a preparation patch for adding ovfx2 bridge support. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/gspca/ov519.c')
-rw-r--r--drivers/media/video/gspca/ov519.c892
1 files changed, 882 insertions, 10 deletions
diff --git a/drivers/media/video/gspca/ov519.c b/drivers/media/video/gspca/ov519.c
index bb9976dc1e24..bfc88360132d 100644
--- a/drivers/media/video/gspca/ov519.c
+++ b/drivers/media/video/gspca/ov519.c
@@ -58,6 +58,7 @@ struct sd {
58#define BRIDGE_OV518 2 58#define BRIDGE_OV518 2
59#define BRIDGE_OV518PLUS 3 59#define BRIDGE_OV518PLUS 3
60#define BRIDGE_OV519 4 60#define BRIDGE_OV519 4
61#define BRIDGE_OVFX2 5
61#define BRIDGE_MASK 7 62#define BRIDGE_MASK 7
62 63
63 char invert_led; 64 char invert_led;
@@ -81,15 +82,17 @@ struct sd {
81 82
82 char sensor; /* Type of image sensor chip (SEN_*) */ 83 char sensor; /* Type of image sensor chip (SEN_*) */
83#define SEN_UNKNOWN 0 84#define SEN_UNKNOWN 0
84#define SEN_OV6620 1 85#define SEN_OV2610 1
85#define SEN_OV6630 2 86#define SEN_OV3610 2
86#define SEN_OV66308AF 3 87#define SEN_OV6620 3
87#define SEN_OV7610 4 88#define SEN_OV6630 4
88#define SEN_OV7620 5 89#define SEN_OV66308AF 5
89#define SEN_OV7640 6 90#define SEN_OV7610 6
90#define SEN_OV7670 7 91#define SEN_OV7620 7
91#define SEN_OV76BE 8 92#define SEN_OV7640 8
92#define SEN_OV8610 9 93#define SEN_OV7670 9
94#define SEN_OV76BE 10
95#define SEN_OV8610 11
93}; 96};
94 97
95/* V4L2 controls supported by the driver */ 98/* V4L2 controls supported by the driver */
@@ -345,6 +348,70 @@ static const struct v4l2_pix_format ov511_sif_mode[] = {
345 .priv = 0}, 348 .priv = 0},
346}; 349};
347 350
351static const struct v4l2_pix_format ovfx2_vga_mode[] = {
352 {320, 240, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
353 .bytesperline = 320,
354 .sizeimage = 320 * 240,
355 .colorspace = V4L2_COLORSPACE_SRGB,
356 .priv = 1},
357 {640, 480, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
358 .bytesperline = 640,
359 .sizeimage = 640 * 480,
360 .colorspace = V4L2_COLORSPACE_SRGB,
361 .priv = 0},
362};
363static const struct v4l2_pix_format ovfx2_cif_mode[] = {
364 {160, 120, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
365 .bytesperline = 160,
366 .sizeimage = 160 * 120,
367 .colorspace = V4L2_COLORSPACE_SRGB,
368 .priv = 3},
369 {176, 144, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
370 .bytesperline = 176,
371 .sizeimage = 176 * 144,
372 .colorspace = V4L2_COLORSPACE_SRGB,
373 .priv = 1},
374 {320, 240, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
375 .bytesperline = 320,
376 .sizeimage = 320 * 240,
377 .colorspace = V4L2_COLORSPACE_SRGB,
378 .priv = 2},
379 {352, 288, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
380 .bytesperline = 352,
381 .sizeimage = 352 * 288,
382 .colorspace = V4L2_COLORSPACE_SRGB,
383 .priv = 0},
384};
385static const struct v4l2_pix_format ovfx2_ov2610_mode[] = {
386 {1600, 1200, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
387 .bytesperline = 1600,
388 .sizeimage = 1600 * 1200,
389 .colorspace = V4L2_COLORSPACE_SRGB},
390};
391static const struct v4l2_pix_format ovfx2_ov3610_mode[] = {
392 {2080, 1544, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
393 .bytesperline = 2080,
394 .sizeimage = 2080 * 1544,
395 .colorspace = V4L2_COLORSPACE_SRGB},
396 {1600, 1200, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
397 .bytesperline = 1600,
398 .sizeimage = 1600 * 1200,
399 .colorspace = V4L2_COLORSPACE_SRGB},
400 {1024, 768, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
401 .bytesperline = 1024,
402 .sizeimage = 1024 * 768,
403 .colorspace = V4L2_COLORSPACE_SRGB},
404 {800, 600, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
405 .bytesperline = 800,
406 .sizeimage = 800 * 600,
407 .colorspace = V4L2_COLORSPACE_SRGB},
408 {640, 480, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
409 .bytesperline = 640,
410 .sizeimage = 640 * 480,
411 .colorspace = V4L2_COLORSPACE_SRGB},
412};
413
414
348/* Registers common to OV511 / OV518 */ 415/* Registers common to OV511 / OV518 */
349#define R51x_FIFO_PSIZE 0x30 /* 2 bytes wide w/ OV518(+) */ 416#define R51x_FIFO_PSIZE 0x30 /* 2 bytes wide w/ OV518(+) */
350#define R51x_SYS_RESET 0x50 417#define R51x_SYS_RESET 0x50
@@ -509,6 +576,696 @@ struct ov_i2c_regvals {
509 __u8 val; 576 __u8 val;
510}; 577};
511 578
579/* Settings for OV2610 camera chip */
580static const struct ov_i2c_regvals norm_2610[] =
581{
582 { 0x10, 0x80 }, /* reset */
583};
584
585static const struct ov_i2c_regvals norm_3620b[] =
586{
587 /*
588 * From the datasheet: "Note that after writing to register COMH
589 * (0x12) to change the sensor mode, registers related to the
590 * sensor’s cropping window will be reset back to their default
591 * values."
592 *
593 * "wait 4096 external clock ... to make sure the sensor is
594 * stable and ready to access registers" i.e. 160us at 24MHz
595 */
596
597 { 0x12, 0x80 }, /* COMH reset */
598 { 0x12, 0x00 }, /* QXGA, master */
599
600 /*
601 * 11 CLKRC "Clock Rate Control"
602 * [7] internal frequency doublers: on
603 * [6] video port mode: master
604 * [5:0] clock divider: 1
605 */
606 { 0x11, 0x80 },
607
608 /*
609 * 13 COMI "Common Control I"
610 * = 192 (0xC0) 11000000
611 * COMI[7] "AEC speed selection"
612 * = 1 (0x01) 1....... "Faster AEC correction"
613 * COMI[6] "AEC speed step selection"
614 * = 1 (0x01) .1...... "Big steps, fast"
615 * COMI[5] "Banding filter on off"
616 * = 0 (0x00) ..0..... "Off"
617 * COMI[4] "Banding filter option"
618 * = 0 (0x00) ...0.... "Main clock is 48 MHz and
619 * the PLL is ON"
620 * COMI[3] "Reserved"
621 * = 0 (0x00) ....0...
622 * COMI[2] "AGC auto manual control selection"
623 * = 0 (0x00) .....0.. "Manual"
624 * COMI[1] "AWB auto manual control selection"
625 * = 0 (0x00) ......0. "Manual"
626 * COMI[0] "Exposure control"
627 * = 0 (0x00) .......0 "Manual"
628 */
629 { 0x13, 0xC0 },
630
631 /*
632 * 09 COMC "Common Control C"
633 * = 8 (0x08) 00001000
634 * COMC[7:5] "Reserved"
635 * = 0 (0x00) 000.....
636 * COMC[4] "Sleep Mode Enable"
637 * = 0 (0x00) ...0.... "Normal mode"
638 * COMC[3:2] "Sensor sampling reset timing selection"
639 * = 2 (0x02) ....10.. "Longer reset time"
640 * COMC[1:0] "Output drive current select"
641 * = 0 (0x00) ......00 "Weakest"
642 */
643 { 0x09, 0x08 },
644
645 /*
646 * 0C COMD "Common Control D"
647 * = 8 (0x08) 00001000
648 * COMD[7] "Reserved"
649 * = 0 (0x00) 0.......
650 * COMD[6] "Swap MSB and LSB at the output port"
651 * = 0 (0x00) .0...... "False"
652 * COMD[5:3] "Reserved"
653 * = 1 (0x01) ..001...
654 * COMD[2] "Output Average On Off"
655 * = 0 (0x00) .....0.. "Output Normal"
656 * COMD[1] "Sensor precharge voltage selection"
657 * = 0 (0x00) ......0. "Selects internal
658 * reference precharge
659 * voltage"
660 * COMD[0] "Snapshot option"
661 * = 0 (0x00) .......0 "Enable live video output
662 * after snapshot sequence"
663 */
664 { 0x0c, 0x08 },
665
666 /*
667 * 0D COME "Common Control E"
668 * = 161 (0xA1) 10100001
669 * COME[7] "Output average option"
670 * = 1 (0x01) 1....... "Output average of 4 pixels"
671 * COME[6] "Anti-blooming control"
672 * = 0 (0x00) .0...... "Off"
673 * COME[5:3] "Reserved"
674 * = 4 (0x04) ..100...
675 * COME[2] "Clock output power down pin status"
676 * = 0 (0x00) .....0.. "Tri-state data output pin
677 * on power down"
678 * COME[1] "Data output pin status selection at power down"
679 * = 0 (0x00) ......0. "Tri-state VSYNC, PCLK,
680 * HREF, and CHSYNC pins on
681 * power down"
682 * COME[0] "Auto zero circuit select"
683 * = 1 (0x01) .......1 "On"
684 */
685 { 0x0d, 0xA1 },
686
687 /*
688 * 0E COMF "Common Control F"
689 * = 112 (0x70) 01110000
690 * COMF[7] "System clock selection"
691 * = 0 (0x00) 0....... "Use 24 MHz system clock"
692 * COMF[6:4] "Reserved"
693 * = 7 (0x07) .111....
694 * COMF[3] "Manual auto negative offset canceling selection"
695 * = 0 (0x00) ....0... "Auto detect negative
696 * offset and cancel it"
697 * COMF[2:0] "Reserved"
698 * = 0 (0x00) .....000
699 */
700 { 0x0e, 0x70 },
701
702 /*
703 * 0F COMG "Common Control G"
704 * = 66 (0x42) 01000010
705 * COMG[7] "Optical black output selection"
706 * = 0 (0x00) 0....... "Disable"
707 * COMG[6] "Black level calibrate selection"
708 * = 1 (0x01) .1...... "Use optical black pixels
709 * to calibrate"
710 * COMG[5:4] "Reserved"
711 * = 0 (0x00) ..00....
712 * COMG[3] "Channel offset adjustment"
713 * = 0 (0x00) ....0... "Disable offset adjustment"
714 * COMG[2] "ADC black level calibration option"
715 * = 0 (0x00) .....0.. "Use B/G line and G/R
716 * line to calibrate each
717 * channel's black level"
718 * COMG[1] "Reserved"
719 * = 1 (0x01) ......1.
720 * COMG[0] "ADC black level calibration enable"
721 * = 0 (0x00) .......0 "Disable"
722 */
723 { 0x0f, 0x42 },
724
725 /*
726 * 14 COMJ "Common Control J"
727 * = 198 (0xC6) 11000110
728 * COMJ[7:6] "AGC gain ceiling"
729 * = 3 (0x03) 11...... "8x"
730 * COMJ[5:4] "Reserved"
731 * = 0 (0x00) ..00....
732 * COMJ[3] "Auto banding filter"
733 * = 0 (0x00) ....0... "Banding filter is always
734 * on off depending on
735 * COMI[5] setting"
736 * COMJ[2] "VSYNC drop option"
737 * = 1 (0x01) .....1.. "SYNC is dropped if frame
738 * data is dropped"
739 * COMJ[1] "Frame data drop"
740 * = 1 (0x01) ......1. "Drop frame data if
741 * exposure is not within
742 * tolerance. In AEC mode,
743 * data is normally dropped
744 * when data is out of
745 * range."
746 * COMJ[0] "Reserved"
747 * = 0 (0x00) .......0
748 */
749 { 0x14, 0xC6 },
750
751 /*
752 * 15 COMK "Common Control K"
753 * = 2 (0x02) 00000010
754 * COMK[7] "CHSYNC pin output swap"
755 * = 0 (0x00) 0....... "CHSYNC"
756 * COMK[6] "HREF pin output swap"
757 * = 0 (0x00) .0...... "HREF"
758 * COMK[5] "PCLK output selection"
759 * = 0 (0x00) ..0..... "PCLK always output"
760 * COMK[4] "PCLK edge selection"
761 * = 0 (0x00) ...0.... "Data valid on falling edge"
762 * COMK[3] "HREF output polarity"
763 * = 0 (0x00) ....0... "positive"
764 * COMK[2] "Reserved"
765 * = 0 (0x00) .....0..
766 * COMK[1] "VSYNC polarity"
767 * = 1 (0x01) ......1. "negative"
768 * COMK[0] "HSYNC polarity"
769 * = 0 (0x00) .......0 "positive"
770 */
771 { 0x15, 0x02 },
772
773 /*
774 * 33 CHLF "Current Control"
775 * = 9 (0x09) 00001001
776 * CHLF[7:6] "Sensor current control"
777 * = 0 (0x00) 00......
778 * CHLF[5] "Sensor current range control"
779 * = 0 (0x00) ..0..... "normal range"
780 * CHLF[4] "Sensor current"
781 * = 0 (0x00) ...0.... "normal current"
782 * CHLF[3] "Sensor buffer current control"
783 * = 1 (0x01) ....1... "half current"
784 * CHLF[2] "Column buffer current control"
785 * = 0 (0x00) .....0.. "normal current"
786 * CHLF[1] "Analog DSP current control"
787 * = 0 (0x00) ......0. "normal current"
788 * CHLF[1] "ADC current control"
789 * = 0 (0x00) ......0. "normal current"
790 */
791 { 0x33, 0x09 },
792
793 /*
794 * 34 VBLM "Blooming Control"
795 * = 80 (0x50) 01010000
796 * VBLM[7] "Hard soft reset switch"
797 * = 0 (0x00) 0....... "Hard reset"
798 * VBLM[6:4] "Blooming voltage selection"
799 * = 5 (0x05) .101....
800 * VBLM[3:0] "Sensor current control"
801 * = 0 (0x00) ....0000
802 */
803 { 0x34, 0x50 },
804
805 /*
806 * 36 VCHG "Sensor Precharge Voltage Control"
807 * = 0 (0x00) 00000000
808 * VCHG[7] "Reserved"
809 * = 0 (0x00) 0.......
810 * VCHG[6:4] "Sensor precharge voltage control"
811 * = 0 (0x00) .000....
812 * VCHG[3:0] "Sensor array common reference"
813 * = 0 (0x00) ....0000
814 */
815 { 0x36, 0x00 },
816
817 /*
818 * 37 ADC "ADC Reference Control"
819 * = 4 (0x04) 00000100
820 * ADC[7:4] "Reserved"
821 * = 0 (0x00) 0000....
822 * ADC[3] "ADC input signal range"
823 * = 0 (0x00) ....0... "Input signal 1.0x"
824 * ADC[2:0] "ADC range control"
825 * = 4 (0x04) .....100
826 */
827 { 0x37, 0x04 },
828
829 /*
830 * 38 ACOM "Analog Common Ground"
831 * = 82 (0x52) 01010010
832 * ACOM[7] "Analog gain control"
833 * = 0 (0x00) 0....... "Gain 1x"
834 * ACOM[6] "Analog black level calibration"
835 * = 1 (0x01) .1...... "On"
836 * ACOM[5:0] "Reserved"
837 * = 18 (0x12) ..010010
838 */
839 { 0x38, 0x52 },
840
841 /*
842 * 3A FREFA "Internal Reference Adjustment"
843 * = 0 (0x00) 00000000
844 * FREFA[7:0] "Range"
845 * = 0 (0x00) 00000000
846 */
847 { 0x3a, 0x00 },
848
849 /*
850 * 3C FVOPT "Internal Reference Adjustment"
851 * = 31 (0x1F) 00011111
852 * FVOPT[7:0] "Range"
853 * = 31 (0x1F) 00011111
854 */
855 { 0x3c, 0x1F },
856
857 /*
858 * 44 Undocumented = 0 (0x00) 00000000
859 * 44[7:0] "It's a secret"
860 * = 0 (0x00) 00000000
861 */
862 { 0x44, 0x00 },
863
864 /*
865 * 40 Undocumented = 0 (0x00) 00000000
866 * 40[7:0] "It's a secret"
867 * = 0 (0x00) 00000000
868 */
869 { 0x40, 0x00 },
870
871 /*
872 * 41 Undocumented = 0 (0x00) 00000000
873 * 41[7:0] "It's a secret"
874 * = 0 (0x00) 00000000
875 */
876 { 0x41, 0x00 },
877
878 /*
879 * 42 Undocumented = 0 (0x00) 00000000
880 * 42[7:0] "It's a secret"
881 * = 0 (0x00) 00000000
882 */
883 { 0x42, 0x00 },
884
885 /*
886 * 43 Undocumented = 0 (0x00) 00000000
887 * 43[7:0] "It's a secret"
888 * = 0 (0x00) 00000000
889 */
890 { 0x43, 0x00 },
891
892 /*
893 * 45 Undocumented = 128 (0x80) 10000000
894 * 45[7:0] "It's a secret"
895 * = 128 (0x80) 10000000
896 */
897 { 0x45, 0x80 },
898
899 /*
900 * 48 Undocumented = 192 (0xC0) 11000000
901 * 48[7:0] "It's a secret"
902 * = 192 (0xC0) 11000000
903 */
904 { 0x48, 0xC0 },
905
906 /*
907 * 49 Undocumented = 25 (0x19) 00011001
908 * 49[7:0] "It's a secret"
909 * = 25 (0x19) 00011001
910 */
911 { 0x49, 0x19 },
912
913 /*
914 * 4B Undocumented = 128 (0x80) 10000000
915 * 4B[7:0] "It's a secret"
916 * = 128 (0x80) 10000000
917 */
918 { 0x4B, 0x80 },
919
920 /*
921 * 4D Undocumented = 196 (0xC4) 11000100
922 * 4D[7:0] "It's a secret"
923 * = 196 (0xC4) 11000100
924 */
925 { 0x4D, 0xC4 },
926
927 /*
928 * 35 VREF "Reference Voltage Control"
929 * = 76 (0x4C) 01001100
930 * VREF[7:5] "Column high reference control"
931 * = 2 (0x02) 010..... "higher voltage"
932 * VREF[4:2] "Column low reference control"
933 * = 3 (0x03) ...011.. "Highest voltage"
934 * VREF[1:0] "Reserved"
935 * = 0 (0x00) ......00
936 */
937 { 0x35, 0x4C },
938
939 /*
940 * 3D Undocumented = 0 (0x00) 00000000
941 * 3D[7:0] "It's a secret"
942 * = 0 (0x00) 00000000
943 */
944 { 0x3D, 0x00 },
945
946 /*
947 * 3E Undocumented = 0 (0x00) 00000000
948 * 3E[7:0] "It's a secret"
949 * = 0 (0x00) 00000000
950 */
951 { 0x3E, 0x00 },
952
953 /*
954 * 3B FREFB "Internal Reference Adjustment"
955 * = 24 (0x18) 00011000
956 * FREFB[7:0] "Range"
957 * = 24 (0x18) 00011000
958 */
959 { 0x3b, 0x18 },
960
961 /*
962 * 33 CHLF "Current Control"
963 * = 25 (0x19) 00011001
964 * CHLF[7:6] "Sensor current control"
965 * = 0 (0x00) 00......
966 * CHLF[5] "Sensor current range control"
967 * = 0 (0x00) ..0..... "normal range"
968 * CHLF[4] "Sensor current"
969 * = 1 (0x01) ...1.... "double current"
970 * CHLF[3] "Sensor buffer current control"
971 * = 1 (0x01) ....1... "half current"
972 * CHLF[2] "Column buffer current control"
973 * = 0 (0x00) .....0.. "normal current"
974 * CHLF[1] "Analog DSP current control"
975 * = 0 (0x00) ......0. "normal current"
976 * CHLF[1] "ADC current control"
977 * = 0 (0x00) ......0. "normal current"
978 */
979 { 0x33, 0x19 },
980
981 /*
982 * 34 VBLM "Blooming Control"
983 * = 90 (0x5A) 01011010
984 * VBLM[7] "Hard soft reset switch"
985 * = 0 (0x00) 0....... "Hard reset"
986 * VBLM[6:4] "Blooming voltage selection"
987 * = 5 (0x05) .101....
988 * VBLM[3:0] "Sensor current control"
989 * = 10 (0x0A) ....1010
990 */
991 { 0x34, 0x5A },
992
993 /*
994 * 3B FREFB "Internal Reference Adjustment"
995 * = 0 (0x00) 00000000
996 * FREFB[7:0] "Range"
997 * = 0 (0x00) 00000000
998 */
999 { 0x3b, 0x00 },
1000
1001 /*
1002 * 33 CHLF "Current Control"
1003 * = 9 (0x09) 00001001
1004 * CHLF[7:6] "Sensor current control"
1005 * = 0 (0x00) 00......
1006 * CHLF[5] "Sensor current range control"
1007 * = 0 (0x00) ..0..... "normal range"
1008 * CHLF[4] "Sensor current"
1009 * = 0 (0x00) ...0.... "normal current"
1010 * CHLF[3] "Sensor buffer current control"
1011 * = 1 (0x01) ....1... "half current"
1012 * CHLF[2] "Column buffer current control"
1013 * = 0 (0x00) .....0.. "normal current"
1014 * CHLF[1] "Analog DSP current control"
1015 * = 0 (0x00) ......0. "normal current"
1016 * CHLF[1] "ADC current control"
1017 * = 0 (0x00) ......0. "normal current"
1018 */
1019 { 0x33, 0x09 },
1020
1021 /*
1022 * 34 VBLM "Blooming Control"
1023 * = 80 (0x50) 01010000
1024 * VBLM[7] "Hard soft reset switch"
1025 * = 0 (0x00) 0....... "Hard reset"
1026 * VBLM[6:4] "Blooming voltage selection"
1027 * = 5 (0x05) .101....
1028 * VBLM[3:0] "Sensor current control"
1029 * = 0 (0x00) ....0000
1030 */
1031 { 0x34, 0x50 },
1032
1033 /*
1034 * 12 COMH "Common Control H"
1035 * = 64 (0x40) 01000000
1036 * COMH[7] "SRST"
1037 * = 0 (0x00) 0....... "No-op"
1038 * COMH[6:4] "Resolution selection"
1039 * = 4 (0x04) .100.... "XGA"
1040 * COMH[3] "Master slave selection"
1041 * = 0 (0x00) ....0... "Master mode"
1042 * COMH[2] "Internal B/R channel option"
1043 * = 0 (0x00) .....0.. "B/R use same channel"
1044 * COMH[1] "Color bar test pattern"
1045 * = 0 (0x00) ......0. "Off"
1046 * COMH[0] "Reserved"
1047 * = 0 (0x00) .......0
1048 */
1049 { 0x12, 0x40 },
1050
1051 /*
1052 * 17 HREFST "Horizontal window start"
1053 * = 31 (0x1F) 00011111
1054 * HREFST[7:0] "Horizontal window start, 8 MSBs"
1055 * = 31 (0x1F) 00011111
1056 */
1057 { 0x17, 0x1F },
1058
1059 /*
1060 * 18 HREFEND "Horizontal window end"
1061 * = 95 (0x5F) 01011111
1062 * HREFEND[7:0] "Horizontal Window End, 8 MSBs"
1063 * = 95 (0x5F) 01011111
1064 */
1065 { 0x18, 0x5F },
1066
1067 /*
1068 * 19 VSTRT "Vertical window start"
1069 * = 0 (0x00) 00000000
1070 * VSTRT[7:0] "Vertical Window Start, 8 MSBs"
1071 * = 0 (0x00) 00000000
1072 */
1073 { 0x19, 0x00 },
1074
1075 /*
1076 * 1A VEND "Vertical window end"
1077 * = 96 (0x60) 01100000
1078 * VEND[7:0] "Vertical Window End, 8 MSBs"
1079 * = 96 (0x60) 01100000
1080 */
1081 { 0x1a, 0x60 },
1082
1083 /*
1084 * 32 COMM "Common Control M"
1085 * = 18 (0x12) 00010010
1086 * COMM[7:6] "Pixel clock divide option"
1087 * = 0 (0x00) 00...... "/1"
1088 * COMM[5:3] "Horizontal window end position, 3 LSBs"
1089 * = 2 (0x02) ..010...
1090 * COMM[2:0] "Horizontal window start position, 3 LSBs"
1091 * = 2 (0x02) .....010
1092 */
1093 { 0x32, 0x12 },
1094
1095 /*
1096 * 03 COMA "Common Control A"
1097 * = 74 (0x4A) 01001010
1098 * COMA[7:4] "AWB Update Threshold"
1099 * = 4 (0x04) 0100....
1100 * COMA[3:2] "Vertical window end line control 2 LSBs"
1101 * = 2 (0x02) ....10..
1102 * COMA[1:0] "Vertical window start line control 2 LSBs"
1103 * = 2 (0x02) ......10
1104 */
1105 { 0x03, 0x4A },
1106
1107 /*
1108 * 11 CLKRC "Clock Rate Control"
1109 * = 128 (0x80) 10000000
1110 * CLKRC[7] "Internal frequency doublers on off seclection"
1111 * = 1 (0x01) 1....... "On"
1112 * CLKRC[6] "Digital video master slave selection"
1113 * = 0 (0x00) .0...... "Master mode, sensor
1114 * provides PCLK"
1115 * CLKRC[5:0] "Clock divider { CLK = PCLK/(1+CLKRC[5:0]) }"
1116 * = 0 (0x00) ..000000
1117 */
1118 { 0x11, 0x80 },
1119
1120 /*
1121 * 12 COMH "Common Control H"
1122 * = 0 (0x00) 00000000
1123 * COMH[7] "SRST"
1124 * = 0 (0x00) 0....... "No-op"
1125 * COMH[6:4] "Resolution selection"
1126 * = 0 (0x00) .000.... "QXGA"
1127 * COMH[3] "Master slave selection"
1128 * = 0 (0x00) ....0... "Master mode"
1129 * COMH[2] "Internal B/R channel option"
1130 * = 0 (0x00) .....0.. "B/R use same channel"
1131 * COMH[1] "Color bar test pattern"
1132 * = 0 (0x00) ......0. "Off"
1133 * COMH[0] "Reserved"
1134 * = 0 (0x00) .......0
1135 */
1136 { 0x12, 0x00 },
1137
1138 /*
1139 * 12 COMH "Common Control H"
1140 * = 64 (0x40) 01000000
1141 * COMH[7] "SRST"
1142 * = 0 (0x00) 0....... "No-op"
1143 * COMH[6:4] "Resolution selection"
1144 * = 4 (0x04) .100.... "XGA"
1145 * COMH[3] "Master slave selection"
1146 * = 0 (0x00) ....0... "Master mode"
1147 * COMH[2] "Internal B/R channel option"
1148 * = 0 (0x00) .....0.. "B/R use same channel"
1149 * COMH[1] "Color bar test pattern"
1150 * = 0 (0x00) ......0. "Off"
1151 * COMH[0] "Reserved"
1152 * = 0 (0x00) .......0
1153 */
1154 { 0x12, 0x40 },
1155
1156 /*
1157 * 17 HREFST "Horizontal window start"
1158 * = 31 (0x1F) 00011111
1159 * HREFST[7:0] "Horizontal window start, 8 MSBs"
1160 * = 31 (0x1F) 00011111
1161 */
1162 { 0x17, 0x1F },
1163
1164 /*
1165 * 18 HREFEND "Horizontal window end"
1166 * = 95 (0x5F) 01011111
1167 * HREFEND[7:0] "Horizontal Window End, 8 MSBs"
1168 * = 95 (0x5F) 01011111
1169 */
1170 { 0x18, 0x5F },
1171
1172 /*
1173 * 19 VSTRT "Vertical window start"
1174 * = 0 (0x00) 00000000
1175 * VSTRT[7:0] "Vertical Window Start, 8 MSBs"
1176 * = 0 (0x00) 00000000
1177 */
1178 { 0x19, 0x00 },
1179
1180 /*
1181 * 1A VEND "Vertical window end"
1182 * = 96 (0x60) 01100000
1183 * VEND[7:0] "Vertical Window End, 8 MSBs"
1184 * = 96 (0x60) 01100000
1185 */
1186 { 0x1a, 0x60 },
1187
1188 /*
1189 * 32 COMM "Common Control M"
1190 * = 18 (0x12) 00010010
1191 * COMM[7:6] "Pixel clock divide option"
1192 * = 0 (0x00) 00...... "/1"
1193 * COMM[5:3] "Horizontal window end position, 3 LSBs"
1194 * = 2 (0x02) ..010...
1195 * COMM[2:0] "Horizontal window start position, 3 LSBs"
1196 * = 2 (0x02) .....010
1197 */
1198 { 0x32, 0x12 },
1199
1200 /*
1201 * 03 COMA "Common Control A"
1202 * = 74 (0x4A) 01001010
1203 * COMA[7:4] "AWB Update Threshold"
1204 * = 4 (0x04) 0100....
1205 * COMA[3:2] "Vertical window end line control 2 LSBs"
1206 * = 2 (0x02) ....10..
1207 * COMA[1:0] "Vertical window start line control 2 LSBs"
1208 * = 2 (0x02) ......10
1209 */
1210 { 0x03, 0x4A },
1211
1212 /*
1213 * 02 RED "Red Gain Control"
1214 * = 175 (0xAF) 10101111
1215 * RED[7] "Action"
1216 * = 1 (0x01) 1....... "gain = 1/(1+bitrev([6:0]))"
1217 * RED[6:0] "Value"
1218 * = 47 (0x2F) .0101111
1219 */
1220 { 0x02, 0xAF },
1221
1222 /*
1223 * 2D ADDVSL "VSYNC Pulse Width"
1224 * = 210 (0xD2) 11010010
1225 * ADDVSL[7:0] "VSYNC pulse width, LSB"
1226 * = 210 (0xD2) 11010010
1227 */
1228 { 0x2d, 0xD2 },
1229
1230 /*
1231 * 00 GAIN = 24 (0x18) 00011000
1232 * GAIN[7:6] "Reserved"
1233 * = 0 (0x00) 00......
1234 * GAIN[5] "Double"
1235 * = 0 (0x00) ..0..... "False"
1236 * GAIN[4] "Double"
1237 * = 1 (0x01) ...1.... "True"
1238 * GAIN[3:0] "Range"
1239 * = 8 (0x08) ....1000
1240 */
1241 { 0x00, 0x18 },
1242
1243 /*
1244 * 01 BLUE "Blue Gain Control"
1245 * = 240 (0xF0) 11110000
1246 * BLUE[7] "Action"
1247 * = 1 (0x01) 1....... "gain = 1/(1+bitrev([6:0]))"
1248 * BLUE[6:0] "Value"
1249 * = 112 (0x70) .1110000
1250 */
1251 { 0x01, 0xF0 },
1252
1253 /*
1254 * 10 AEC "Automatic Exposure Control"
1255 * = 10 (0x0A) 00001010
1256 * AEC[7:0] "Automatic Exposure Control, 8 MSBs"
1257 * = 10 (0x0A) 00001010
1258 */
1259 { 0x10, 0x0A },
1260
1261 { 0xE1, 0x67 },
1262 { 0xE3, 0x03 },
1263 { 0xE4, 0x26 },
1264 { 0xE5, 0x3E },
1265 { 0xF8, 0x01 },
1266 { 0xFF, 0x01 },
1267};
1268
512static const struct ov_i2c_regvals norm_6x20[] = { 1269static const struct ov_i2c_regvals norm_6x20[] = {
513 { 0x12, 0x80 }, /* reset */ 1270 { 0x12, 0x80 }, /* reset */
514 { 0x11, 0x01 }, 1271 { 0x11, 0x01 },
@@ -1514,6 +2271,39 @@ static int write_i2c_regvals(struct sd *sd,
1514 * 2271 *
1515 ***************************************************************************/ 2272 ***************************************************************************/
1516 2273
2274/* This initializes the OV2x10 / OV3610 / OV3620 */
2275static int ov_hires_configure(struct sd *sd)
2276{
2277 int high, low;
2278
2279 if (sd->bridge != BRIDGE_OVFX2) {
2280 PDEBUG(D_ERR, "error hires sensors only supported with ovfx2");
2281 return -1;
2282 }
2283
2284 PDEBUG(D_PROBE, "starting ov hires configuration");
2285
2286 /* Detect sensor (sub)type */
2287 high = i2c_r(sd, 0x0a);
2288 low = i2c_r(sd, 0x0b);
2289 /* info("%x, %x", high, low); */
2290 if (high == 0x96 && low == 0x40) {
2291 PDEBUG(D_PROBE, "Sensor is an OV2610");
2292 sd->sensor = SEN_OV2610;
2293 } else if (high == 0x36 && (low & 0x0f) == 0x00) {
2294 PDEBUG(D_PROBE, "Sensor is an OV3610");
2295 sd->sensor = SEN_OV3610;
2296 } else {
2297 PDEBUG(D_ERR, "Error unknown sensor type: 0x%02x%02x",
2298 high, low);
2299 return -1;
2300 }
2301
2302 /* Set sensor-specific vars */
2303 return 0;
2304}
2305
2306
1517/* This initializes the OV8110, OV8610 sensor. The OV8110 uses 2307/* This initializes the OV8110, OV8610 sensor. The OV8110 uses
1518 * the same register settings as the OV8610, since they are very similar. 2308 * the same register settings as the OV8610, since they are very similar.
1519 */ 2309 */
@@ -2024,6 +2814,12 @@ static int sd_config(struct gspca_dev *gspca_dev,
2024 PDEBUG(D_ERR, "Failed to configure OV8xx0"); 2814 PDEBUG(D_ERR, "Failed to configure OV8xx0");
2025 goto error; 2815 goto error;
2026 } 2816 }
2817 /* Test for 3xxx / 2xxx */
2818 } else if (init_ov_sensor(sd, OV_HIRES_SID) >= 0) {
2819 if (ov_hires_configure(sd) < 0) {
2820 PDEBUG(D_ERR, "Failed to configure high res OV");
2821 goto error;
2822 }
2027 } else { 2823 } else {
2028 PDEBUG(D_ERR, "Can't determine sensor slave IDs"); 2824 PDEBUG(D_ERR, "Can't determine sensor slave IDs");
2029 goto error; 2825 goto error;
@@ -2060,6 +2856,21 @@ static int sd_config(struct gspca_dev *gspca_dev,
2060 cam->nmodes = ARRAY_SIZE(ov519_sif_mode); 2856 cam->nmodes = ARRAY_SIZE(ov519_sif_mode);
2061 } 2857 }
2062 break; 2858 break;
2859 case BRIDGE_OVFX2:
2860 if (sd->sensor == SEN_OV2610) {
2861 cam->cam_mode = ovfx2_ov2610_mode;
2862 cam->nmodes = ARRAY_SIZE(ovfx2_ov2610_mode);
2863 } else if (sd->sensor == SEN_OV3610) {
2864 cam->cam_mode = ovfx2_ov3610_mode;
2865 cam->nmodes = ARRAY_SIZE(ovfx2_ov3610_mode);
2866 } else if (!sd->sif) {
2867 cam->cam_mode = ov519_vga_mode;
2868 cam->nmodes = ARRAY_SIZE(ov519_vga_mode);
2869 } else {
2870 cam->cam_mode = ov519_sif_mode;
2871 cam->nmodes = ARRAY_SIZE(ov519_sif_mode);
2872 }
2873 break;
2063 } 2874 }
2064 sd->brightness = BRIGHTNESS_DEF; 2875 sd->brightness = BRIGHTNESS_DEF;
2065 if (sd->sensor == SEN_OV6630 || sd->sensor == SEN_OV66308AF) 2876 if (sd->sensor == SEN_OV6630 || sd->sensor == SEN_OV66308AF)
@@ -2083,6 +2894,9 @@ static int sd_config(struct gspca_dev *gspca_dev,
2083 /* OV8610 Frequency filter control should work but needs testing */ 2894 /* OV8610 Frequency filter control should work but needs testing */
2084 if (sd->sensor == SEN_OV8610) 2895 if (sd->sensor == SEN_OV8610)
2085 gspca_dev->ctrl_dis |= 1 << FREQ_IDX; 2896 gspca_dev->ctrl_dis |= 1 << FREQ_IDX;
2897 /* No controls for the OV2610/OV3610 */
2898 if (sd->sensor == SEN_OV2610 || sd->sensor == SEN_OV3610)
2899 gspca_dev->ctrl_dis |= 0xFF;
2086 2900
2087 return 0; 2901 return 0;
2088error: 2902error:
@@ -2097,6 +2911,20 @@ static int sd_init(struct gspca_dev *gspca_dev)
2097 2911
2098 /* initialize the sensor */ 2912 /* initialize the sensor */
2099 switch (sd->sensor) { 2913 switch (sd->sensor) {
2914 case SEN_OV2610:
2915 if (write_i2c_regvals(sd, norm_2610, ARRAY_SIZE(norm_2610)))
2916 return -EIO;
2917 /* Enable autogain, autoexpo, awb, bandfilter */
2918 if (i2c_w_mask(sd, 0x13, 0x27, 0x27) < 0)
2919 return -EIO;
2920 break;
2921 case SEN_OV3610:
2922 if (write_i2c_regvals(sd, norm_3620b, ARRAY_SIZE(norm_3620b)))
2923 return -EIO;
2924 /* Enable autogain, autoexpo, awb, bandfilter */
2925 if (i2c_w_mask(sd, 0x13, 0x27, 0x27) < 0)
2926 return -EIO;
2927 break;
2100 case SEN_OV6620: 2928 case SEN_OV6620:
2101 if (write_i2c_regvals(sd, norm_6x20, ARRAY_SIZE(norm_6x20))) 2929 if (write_i2c_regvals(sd, norm_6x20, ARRAY_SIZE(norm_6x20)))
2102 return -EIO; 2930 return -EIO;
@@ -2546,6 +3374,42 @@ static int mode_init_ov_sensor_regs(struct sd *sd)
2546 3374
2547 /******** Mode (VGA/QVGA) and sensor specific regs ********/ 3375 /******** Mode (VGA/QVGA) and sensor specific regs ********/
2548 switch (sd->sensor) { 3376 switch (sd->sensor) {
3377 case SEN_OV2610:
3378 i2c_w_mask(sd, 0x14, qvga ? 0x20 : 0x00, 0x20);
3379 i2c_w_mask(sd, 0x28, qvga ? 0x00 : 0x20, 0x20);
3380 i2c_w(sd, 0x24, qvga ? 0x20 : 0x3a);
3381 i2c_w(sd, 0x25, qvga ? 0x30 : 0x60);
3382 i2c_w_mask(sd, 0x2d, qvga ? 0x40 : 0x00, 0x40);
3383 i2c_w_mask(sd, 0x67, qvga ? 0xf0 : 0x90, 0xf0);
3384 i2c_w_mask(sd, 0x74, qvga ? 0x20 : 0x00, 0x20);
3385 return 0;
3386 case SEN_OV3610: {
3387 int xstart, xend, ystart, yend;
3388
3389 if (qvga) {
3390 xstart = (1040 - gspca_dev->width) / 2 + (0x1f << 4);
3391 ystart = (772 - gspca_dev->height) / 2;
3392 } else {
3393 xstart = (2080 - gspca_dev->width) / 2 + (0x10 << 4);
3394 ystart = (1544 - gspca_dev->height) / 2;
3395 }
3396 xend = xstart + gspca_dev->width;
3397 yend = ystart + gspca_dev->height;
3398 /* Writing to the COMH register resets the other windowing regs
3399 to their default values, so we must do this first. */
3400 i2c_w_mask(sd, 0x12, qvga ? 0x40 : 0x00, 0xf0);
3401 i2c_w_mask(sd, 0x32,
3402 (((xend >> 1) & 7) << 3) | ((xstart >> 1) & 7),
3403 0x3f);
3404 i2c_w_mask(sd, 0x03,
3405 (((yend >> 1) & 3) << 2) | ((ystart >> 1) & 3),
3406 0x0f);
3407 i2c_w(sd, 0x17, xstart >> 4);
3408 i2c_w(sd, 0x18, xend >> 4);
3409 i2c_w(sd, 0x19, ystart >> 3);
3410 i2c_w(sd, 0x1a, yend >> 3);
3411 return 0;
3412 }
2549 case SEN_OV8610: 3413 case SEN_OV8610:
2550 /* For OV8610 qvga means qsvga */ 3414 /* For OV8610 qvga means qsvga */
2551 i2c_w_mask(sd, OV7610_REG_COM_C, qvga ? (1 << 5) : 0, 1 << 5); 3415 i2c_w_mask(sd, OV7610_REG_COM_C, qvga ? (1 << 5) : 0, 1 << 5);
@@ -2653,6 +3517,10 @@ static int set_ov_sensor_window(struct sd *sd)
2653 int ret, hstart, hstop, vstop, vstart; 3517 int ret, hstart, hstop, vstop, vstart;
2654 __u8 v; 3518 __u8 v;
2655 3519
3520 /* mode setup is fully handled in mode_init_ov_sensor_regs for these */
3521 if (sd->sensor == SEN_OV2610 || sd->sensor == SEN_OV3610)
3522 return mode_init_ov_sensor_regs(sd);
3523
2656 gspca_dev = &sd->gspca_dev; 3524 gspca_dev = &sd->gspca_dev;
2657 qvga = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv & 1; 3525 qvga = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv & 1;
2658 crop = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv & 2; 3526 crop = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv & 2;
@@ -3115,7 +3983,8 @@ static void setcolors(struct gspca_dev *gspca_dev)
3115 3983
3116static void setautobrightness(struct sd *sd) 3984static void setautobrightness(struct sd *sd)
3117{ 3985{
3118 if (sd->sensor == SEN_OV7640 || sd->sensor == SEN_OV7670) 3986 if (sd->sensor == SEN_OV7640 || sd->sensor == SEN_OV7670 ||
3987 sd->sensor == SEN_OV2610 || sd->sensor == SEN_OV3610)
3119 return; 3988 return;
3120 3989
3121 i2c_w_mask(sd, 0x2d, sd->autobrightness ? 0x10 : 0x00, 0x10); 3990 i2c_w_mask(sd, 0x2d, sd->autobrightness ? 0x10 : 0x00, 0x10);
@@ -3123,6 +3992,9 @@ static void setautobrightness(struct sd *sd)
3123 3992
3124static void setfreq(struct sd *sd) 3993static void setfreq(struct sd *sd)
3125{ 3994{
3995 if (sd->sensor == SEN_OV2610 || sd->sensor == SEN_OV3610)
3996 return;
3997
3126 if (sd->sensor == SEN_OV7670) { 3998 if (sd->sensor == SEN_OV7670) {
3127 switch (sd->freq) { 3999 switch (sd->freq) {
3128 case 0: /* Banding filter disabled */ 4000 case 0: /* Banding filter disabled */