Optimize ov2655 initialization
authorddl <ddl@rock-chips.com>
Mon, 2 Aug 2010 03:05:36 +0000 (11:05 +0800)
committerddl <ddl@rock-chips.com>
Mon, 2 Aug 2010 03:07:23 +0000 (11:07 +0800)
drivers/media/video/ov2655.c

index 7f991473fe33f764f2e0ab5ff95c0f1e844efc20..1b657d6c3e2be542996d1b3a8ac6018d7d6cb1db 100644 (file)
@@ -33,6 +33,7 @@ struct reginfo
 /* init 800X600 SVGA */
 static struct reginfo ov2655_init_data[] =
 {
+#if 0
     {0x308c, 0x80},
     {0x308d, 0x0e},
     {0x360b, 0x00},
@@ -254,6 +255,229 @@ static struct reginfo ov2655_init_data[] =
     {0x3086, 0x00},
 
     {0x0, 0x0},   //end flag
+#else
+    {0x308c, 0x80},
+    {0x308d, 0x0e},
+    {0x360b, 0x00},
+    {0x30b0, 0xff},
+    {0x30b1, 0xff},
+    {0x30b2, 0x24},
+
+    {0x300e, 0x34},
+    {0x300f, 0xa6},
+    {0x3010, 0x81},
+    {0x3082, 0x01},
+    {0x30f4, 0x01},
+    {0x3090, 0x3b},//0x33},
+    {0x3091, 0xc0},
+    {0x30ac, 0x42},
+
+    {0x30d1, 0x08},
+    {0x30a8, 0x56},
+    {0x3015, 0x03},
+    {0x3093, 0x00},
+    {0x307e, 0xe5},
+    {0x3079, 0x00},
+    {0x30aa, 0x42},
+    {0x3017, 0x40},
+    {0x30f3, 0x82},
+    {0x306a, 0x0c},
+    {0x306d, 0x00},
+    {0x336a, 0x3c},
+    {0x3076, 0x6a},
+    {0x30d9, 0x8c},
+    {0x3016, 0x82},
+    {0x3601, 0x30},
+    {0x304e, 0x88},
+    {0x30f1, 0x82},
+    {0x306f, 0x14},
+
+    {0x3012, 0x10},
+    {0x3011, 0x01},
+    {0x302a, 0x02},
+    {0x302b, 0xE6},
+    {0x3028, 0x07},
+    {0x3029, 0x93},
+
+    {0x3391, 0x06},
+    {0x3394, 0x38},
+    {0x3395, 0x38},
+
+    {0x3015, 0x02},
+    {0x302d, 0x00},
+    {0x302e, 0x00},
+
+    {0x3013, 0xf7},
+    {0x3018, 0x80},
+    {0x3019, 0x70},
+    {0x301a, 0xd4},
+
+    {0x30af, 0x00},
+    {0x3048, 0x1f},
+    {0x3049, 0x4e},
+    {0x304a, 0x20},
+    {0x304f, 0x20},
+    {0x304b, 0x02},
+    {0x304c, 0x00},
+    {0x304d, 0x02},
+    {0x304f, 0x20},
+    {0x30a3, 0x10},
+    {0x3013, 0xf7},
+    {0x3014, 0x84},
+    {0x3071, 0x00},
+    {0x3070, 0x5d},
+    {0x3073, 0x00},
+    {0x3072, 0x5d},
+    {0x301c, 0x07},
+    {0x301d, 0x07},
+    {0x304d, 0x42},
+    {0x304a, 0x40},
+    {0x304f, 0x40},
+    {0x3095, 0x07},
+    {0x3096, 0x16},
+    {0x3097, 0x1d},
+
+    {0x3020, 0x01},
+    {0x3021, 0x18},
+    {0x3022, 0x00},
+    {0x3023, 0x06},
+    {0x3024, 0x06},
+    {0x3025, 0x58},
+    {0x3026, 0x02},
+    {0x3027, 0x61},
+    {0x3088, 0x01},
+    {0x3089, 0x68},
+    {0x308a, 0x01},
+    {0x308b, 0x20},
+    {0x3316, 0x64},
+    {0x3317, 0x25},
+    {0x3318, 0x80},
+    {0x3319, 0x08},
+    {0x331a, 0x16},
+    {0x331b, 0x12},
+    {0x331c, 0x08},
+    {0x331d, 0x38},
+    {0x3100, 0x00},
+
+    {0x3320, 0xfa},
+    {0x3321, 0x11},
+    {0x3322, 0x92},
+    {0x3323, 0x01},
+    {0x3324, 0x97},
+    {0x3325, 0x02},
+    {0x3326, 0xff},
+    {0x3327, 0x0c},
+    {0x3328, 0x10},
+    {0x3329, 0x10},
+    {0x332a, 0x58},
+    {0x332b, 0x56},
+    {0x332c, 0xbe},
+    {0x332d, 0xe1},
+    {0x332e, 0x3a},
+    {0x332f, 0x36},
+    {0x3330, 0x4d},
+    {0x3331, 0x44},
+    {0x3332, 0xf8},
+    {0x3333, 0x0a},
+    {0x3334, 0xf0},
+    {0x3335, 0xf0},
+    {0x3336, 0xf0},
+    {0x3337, 0x40},
+    {0x3338, 0x40},
+    {0x3339, 0x40},
+    {0x333a, 0x00},
+    {0x333b, 0x00},
+
+    {0x3380, 0x28},
+    {0x3381, 0x48},
+    {0x3382, 0x10},
+    {0x3383, 0x22},
+    {0x3384, 0xc0},
+    {0x3385, 0xe2},
+    {0x3386, 0xe2},
+    {0x3387, 0xf2},
+    {0x3388, 0x10},
+    {0x3389, 0x98},
+    {0x338a, 0x00},
+
+    {0x3340, 0x04},
+    {0x3341, 0x07},
+    {0x3342, 0x19},
+    {0x3343, 0x34},
+    {0x3344, 0x4a},
+    {0x3345, 0x5a},
+    {0x3346, 0x67},
+    {0x3347, 0x71},
+    {0x3348, 0x7c},
+    {0x3349, 0x8c},
+    {0x334a, 0x9b},
+    {0x334b, 0xa9},
+    {0x334c, 0xc0},
+    {0x334d, 0xd5},
+    {0x334e, 0xe8},
+    {0x334f, 0x20},
+
+    {0x3350, 0x37},//0x33},
+    {0x3351, 0x27},//0x28},
+    {0x3352, 0x00},
+    {0x3353, 0x16},
+    {0x3354, 0x00},
+    {0x3355, 0x85},
+    {0x3356, 0x35},
+    {0x3357, 0x28},
+    {0x3358, 0x00},
+    {0x3359, 0x13},
+    {0x335a, 0x00},
+    {0x335b, 0x85},
+    {0x335c, 0x37},//0x34},
+    {0x335d, 0x28},
+    {0x335e, 0x00},
+    {0x335f, 0x13},
+    {0x3360, 0x00},
+    {0x3361, 0x85},
+    {0x3363, 0x70},
+    {0x3364, 0x7f},
+    {0x3365, 0x00},
+    {0x3366, 0x00},
+    {0x3362, 0x90},
+
+    {0x3301, 0xff},
+    {0x338B, 0x11},
+    {0x338c, 0x10},
+    {0x338d, 0x40},
+
+    {0x3370, 0xd0},
+    {0x3371, 0x00},
+    {0x3372, 0x00},
+    {0x3373, 0x30},
+    {0x3374, 0x10},
+    {0x3375, 0x10},
+    {0x3376, 0x04},
+    {0x3377, 0x00},
+    {0x3378, 0x04},
+    {0x3379, 0x80},
+
+    {0x3069, 0x84},
+    {0x307c, 0x13},//0x10},
+    {0x3087, 0x02},
+
+    {0x3300, 0xfc},
+    {0x3302, 0x11},
+    {0x3400, 0x02},
+    {0x3606, 0x20},
+    {0x3601, 0x30},
+    {0x30f3, 0x83},
+    {0x304e, 0x88},
+
+    {0x30aa, 0x72},
+    {0x30a3, 0x80},
+    {0x30a1, 0x41},
+
+    {0x3086, 0x0f},
+    {0x3086, 0x00},
+
+    {0x0, 0x0},   //end flag
+#endif
 
 };
 
@@ -794,7 +1018,7 @@ static int ov2655_write(struct i2c_client *client, u16 reg, u8 val)
     msg->flags = client->flags;
     msg->buf = buf;
     msg->len = sizeof(buf);
-    msg->scl_rate = 100*1000;                                        /* ddl@rock-chips.com : 100kHz */
+    msg->scl_rate = 400*1000;                                        /* ddl@rock-chips.com : 100kHz */
     msg->read_type = I2C_NORMAL;
     
     cnt = 3;                                                   
@@ -806,6 +1030,7 @@ static int ov2655_write(struct i2c_client *client, u16 reg, u8 val)
         if (err >= 0) {
             return 0;
         } else {
+            OV2655_TR("\n Write reg failed, write again!\n");
             udelay(10);
         }
     }
@@ -827,7 +1052,7 @@ static int ov2655_read(struct i2c_client *client, u16 reg, u8 *val)
     msg[0].flags = client->flags;
     msg[0].buf = buf;
     msg[0].len = sizeof(buf);
-    msg[0].scl_rate = 100*1000;                                        /* ddl@rock-chips.com : 100kHz */
+    msg[0].scl_rate = 400*1000;                                        /* ddl@rock-chips.com : 100kHz */
     msg[0].read_type = I2C_NO_STOP;                             /*  */
 
     msg[1].addr = client->addr;
@@ -877,8 +1102,9 @@ static int ov2655_init(struct v4l2_subdev *sd, u32 val)
     struct i2c_client *client = sd->priv;
     struct soc_camera_device *icd = client->dev.platform_data;
     struct ov2655 *ov2655 = to_ov2655(client);
-    int ret,pid=0;
-    char value;
+    int ret;
+
+    OV2655_TR("\n%s..%d..  *** ddl ***\n",__FUNCTION__,__LINE__);
 
     /* soft reset */
     ret = ov2655_write(client, 0x3012, 0x80);
@@ -888,35 +1114,7 @@ static int ov2655_init(struct v4l2_subdev *sd, u32 val)
         return -ENODEV;
     }
 
-    mdelay(5);  //delay 5 microseconds
-    
-     /* check if it is an ov2655 sensor */
-    ret = ov2655_read(client, 0x300a, &value);
-    if (ret != 0) {
-        OV2655_TR("read chip id high byte failed\n");
-        ret = -ENODEV;
-        goto OV2655_INIT_ERR;
-    }
-
-    pid |= (value << 8);
-
-    ret = ov2655_read(client, 0x300b, &value);
-    if (ret != 0) {
-        OV2655_TR("read chip id low byte failed\n");
-        ret = -ENODEV;
-        goto OV2655_INIT_ERR;
-    }
-
-    pid |= (value & 0xff);
-   
-    if (pid == 0x2656) {
-        ov2655->model = V4L2_IDENT_OV2655;
-    } else {
-        OV2655_TR("error: devicr mismatched   pid = 0x%x ********************************\n", pid);
-        mdelay(3000);
-        ret = -ENODEV;
-        goto OV2655_INIT_ERR;
-    }
+    mdelay(5);  //delay 5 microseconds   
 
     ret = ov2655_write_array(client, ov2655_init_data);
     if (ret != 0)
@@ -925,8 +1123,8 @@ static int ov2655_init(struct v4l2_subdev *sd, u32 val)
         return ret;
     }
 
-    icd->user_width = 800;
-    icd->user_height = 600;
+    icd->user_width = 352;
+    icd->user_height = 288;
 
     /* sensor ov2655 information for initialization  */
     ov2655->info_priv.whiteBalance = ov2655_controls[0].default_value;