V4L/DVB (10427): gspca - sonixj: Sensor sp80708 added for webcam 0c45:6143.
authorJean-Francois Moine <moinejf@free.fr>
Sun, 1 Feb 2009 16:59:42 +0000 (13:59 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Mon, 30 Mar 2009 15:42:37 +0000 (12:42 -0300)
Signed-off-by: Jean-Francois Moine <moinejf@free.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/gspca/sonixj.c

index e4454b5..d9a7d11 100644 (file)
@@ -66,6 +66,7 @@ struct sd {
 #define SENSOR_OV7630 5
 #define SENSOR_OV7648 6
 #define SENSOR_OV7660 7
+#define SENSOR_SP80708 8
        u8 i2c_base;
 };
 
@@ -243,6 +244,8 @@ static __u32 ctrl_dis[] = {
                                                /* SENSOR_OV7648 6 */
        (1 << AUTOGAIN_IDX) | (1 << INFRARED_IDX) | (1 << VFLIP_IDX),
                                                /* SENSOR_OV7660 7 */
+       (1 << AUTOGAIN_IDX) | (1 << INFRARED_IDX) | (1 << VFLIP_IDX),
+                                               /* SENSOR_SP80708 8 */
 };
 
 static const struct v4l2_pix_format vga_mode[] = {
@@ -352,6 +355,17 @@ static const u8 sn_ov7660[0x1c] = {
        0x07,   0x00,   0x00,   0x00
 };
 
+static const u8 sn_sp80708[0x1c] = {
+/*     reg0    reg1    reg2    reg3    reg4    reg5    reg6    reg7 */
+       0x00,   0x63,   0x60,   0x00,   0x1a,   0x20,   0x20,   0x20,
+/*     reg8    reg9    rega    regb    regc    regd    rege    regf */
+       0x81,   0x18,   0x07,   0x00,   0x00,   0x00,   0x00,   0x00,
+/*     reg10   reg11   reg12   reg13   reg14   reg15   reg16   reg17 */
+       0x03,   0x00,   0x00,   0x03,   0x04,   0x28,   0x1e,   0x00,
+/*     reg18   reg19   reg1a   reg1b */
+       0x07,   0x00,   0x00,   0x00
+};
+
 /* sequence specific to the sensors - !! index = SENSOR_xxx */
 static const u8 *sn_tb[] = {
        sn_hv7131,
@@ -361,7 +375,8 @@ static const u8 *sn_tb[] = {
        sn_om6802,
        sn_ov7630,
        sn_ov7648,
-       sn_ov7660
+       sn_ov7660,
+       sn_sp80708
 };
 
 static const u8 gamma_def[17] = {
@@ -740,6 +755,89 @@ static const u8 ov7660_sensor_init[][8] = {
        {}
 };
 
+static const u8 sp80708_sensor_init[][8] = {
+       {0xa1, 0x18, 0x06, 0xf9, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x09, 0x1f, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x0d, 0xc0, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x10, 0x40, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x11, 0x4e, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x12, 0x53, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x15, 0x80, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x19, 0x18, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x1a, 0x10, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x1c, 0x28, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x1d, 0x02, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x1e, 0x10, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x26, 0x04, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x27, 0x1e, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x28, 0x5a, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x29, 0x28, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x2a, 0x78, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x2b, 0x01, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x2c, 0xf7, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x2d, 0x2d, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x2e, 0xd5, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x39, 0x42, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x3a, 0x67, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x3b, 0x87, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x3c, 0xa3, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x3d, 0xb0, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x3e, 0xbc, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x3f, 0xc8, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x40, 0xd4, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x41, 0xdf, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x42, 0xea, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x43, 0xf5, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x45, 0x80, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x46, 0x60, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x47, 0x50, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x48, 0x30, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x49, 0x01, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x4d, 0xae, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x4e, 0x03, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x4f, 0x66, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x50, 0x1c, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x44, 0x10, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x4a, 0x30, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x51, 0x80, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x52, 0x80, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x53, 0x80, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x54, 0x80, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x55, 0x80, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x56, 0x80, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x57, 0xe0, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x58, 0xc0, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x59, 0xab, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x5a, 0xa0, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x5b, 0x99, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x5c, 0x90, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x5e, 0x24, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x60, 0x00, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x61, 0x73, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x63, 0x42, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x64, 0x42, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x65, 0x42, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x66, 0x24, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x67, 0x24, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x68, 0x08, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x2f, 0xc9, 0x00, 0x00, 0x00, 0x10},
+       /********/
+       {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x03, 0x01, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x04, 0xa4, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x14, 0x3f, 0x00, 0x00, 0x00, 0x10},
+       {0xa1, 0x18, 0x5d, 0x80, 0x00, 0x00, 0x00, 0x10},
+       {0xb1, 0x18, 0x11, 0x40, 0x40, 0x00, 0x00, 0x10},
+       {}
+};
+
 static const u8 qtable4[] = {
        0x06, 0x04, 0x04, 0x06, 0x04, 0x04, 0x06, 0x06,
        0x06, 0x06, 0x08, 0x06, 0x06, 0x08, 0x0a, 0x11,
@@ -1014,6 +1112,14 @@ static int configure_gpio(struct gspca_dev *gspca_dev,
                        break;
                }
                /* fall thru */
+       case SENSOR_SP80708:
+               reg_w1(gspca_dev, 0x01, 0x63);
+               reg_w1(gspca_dev, 0x17, 0x20);
+               reg_w1(gspca_dev, 0x01, 0x62);
+               reg_w1(gspca_dev, 0x01, 0x42);
+               mdelay(100);
+               reg_w1(gspca_dev, 0x02, 0x62);
+               break;
        default:
                reg_w1(gspca_dev, 0x01, 0x43);
                reg_w1(gspca_dev, 0x17, 0x61);
@@ -1137,6 +1243,19 @@ static void ov7660_InitSensor(struct gspca_dev *gspca_dev)
        }
 }
 
+static void sp80708_InitSensor(struct gspca_dev *gspca_dev)
+{
+       int i = 0;
+
+       i2c_w8(gspca_dev, sp80708_sensor_init[i]);      /* reset SCCB */
+       i++;
+       msleep(20);
+       while (sp80708_sensor_init[i][0]) {
+               i2c_w8(gspca_dev, sp80708_sensor_init[i]);
+               i++;
+       }
+}
+
 /* this function is called at probe time */
 static int sd_config(struct gspca_dev *gspca_dev,
                        const struct usb_device_id *id)
@@ -1400,6 +1519,7 @@ static void setgamma(struct gspca_dev *gspca_dev)
                0x18, 0x13, 0x10, 0x0e, 0x08, 0x07, 0x04, 0x02, 0x00
        };
 
+
        for (i = 0; i < sizeof gamma; i++)
                gamma[i] = gamma_def[i]
                        + delta[i] * (sd->gamma - GAMMA_DEF) / 32;
@@ -1488,7 +1608,8 @@ static int sd_start(struct gspca_dev *gspca_dev)
        reg_w1(gspca_dev, 0x07, sn9c1xx[7]);    /* green */
        reg_w1(gspca_dev, 0x06, sn9c1xx[6]);    /* blue */
        reg_w1(gspca_dev, 0x14, sn9c1xx[0x14]);
-               setgamma(gspca_dev);
+       setgamma(gspca_dev);
+
        for (i = 0; i < 8; i++)
                reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
        switch (sd->sensor) {
@@ -1500,6 +1621,10 @@ static int sd_start(struct gspca_dev *gspca_dev)
                reg_w1(gspca_dev, 0x9a, 0x0a);
                reg_w1(gspca_dev, 0x99, 0x60);
                break;
+       case SENSOR_SP80708:
+               reg_w1(gspca_dev, 0x9a, 0x05);
+               reg_w1(gspca_dev, 0x99, 0x59);
+               break;
        case SENSOR_OV7660:
                if (sd->bridge == BRIDGE_SN9C120) {
                        reg_w1(gspca_dev, 0x9a, 0x05);
@@ -1559,8 +1684,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
                reg17 = 0x21;
 /*             reg1 = 0x42;             * 42 - 46? */
                break;
-       default:
-/*     case SENSOR_OV7660: */
+       case SENSOR_OV7660:
                ov7660_InitSensor(gspca_dev);
                if (sd->bridge == BRIDGE_SN9C120) {
                        if (mode) {             /* 320x240 - 160x120 */
@@ -1573,6 +1697,17 @@ static int sd_start(struct gspca_dev *gspca_dev)
                                         * inverse power down */
                }
                break;
+       default:
+/*     case SENSOR_SP80708: */
+               sp80708_InitSensor(gspca_dev);
+               if (mode) {
+/*??                   reg1 = 0x04;     * 320 clk 48Mhz */
+                       ;
+               } else {
+                       reg1 = 0x46;     /* 640 clk 48Mz */
+                       reg17 = 0xa2;
+               }
+               break;
        }
        reg_w(gspca_dev, 0xc0, C0, 6);
        reg_w(gspca_dev, 0xca, CA, 4);
@@ -1970,7 +2105,7 @@ static const __devinitdata struct usb_device_id device_table[] = {
        {USB_DEVICE(0x0c45, 0x613c), BSI(SN9C120, HV7131R, 0x11)},
 /*     {USB_DEVICE(0x0c45, 0x613e), BSI(SN9C120, OV7630, 0x??)}, */
 #endif
-       {USB_DEVICE(0x0c45, 0x6143), BSI(SN9C120, MI0360, 0x5d)},
+       {USB_DEVICE(0x0c45, 0x6143), BSI(SN9C120, SP80708, 0x18)},
        {}
 };
 MODULE_DEVICE_TABLE(usb, device_table);