From: ddl <ddl@rockchip.com>
Date: Wed, 27 Jul 2011 08:17:02 +0000 (+0800)
Subject: camera: update gc0308 sensor driver from 和天创
X-Git-Tag: firefly_0821_release~10075
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=0a8f7464adbb5b7af9bdbfd63c3bafb0c585fcab;p=firefly-linux-kernel-4.4.55.git

camera: update gc0308 sensor driver from 和天创
---

diff --git a/drivers/media/video/gc0308.c b/drivers/media/video/gc0308.c
index a5e939712bae..21acf25f2e7f 100755
--- a/drivers/media/video/gc0308.c
+++ b/drivers/media/video/gc0308.c
@@ -56,12 +56,12 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
 #define SENSOR_INIT_WINSEQADR sensor_vga
 #define SENSOR_INIT_PIXFMT V4L2_PIX_FMT_YUYV
 
-#define CONFIG_SENSOR_WhiteBalance	0
+#define CONFIG_SENSOR_WhiteBalance	1
 #define CONFIG_SENSOR_Brightness	0
 #define CONFIG_SENSOR_Contrast      0
 #define CONFIG_SENSOR_Saturation    0
 #define CONFIG_SENSOR_Effect        1
-#define CONFIG_SENSOR_Scene         0
+#define CONFIG_SENSOR_Scene         1
 #define CONFIG_SENSOR_DigitalZoom   0
 #define CONFIG_SENSOR_Focus         0
 #define CONFIG_SENSOR_Exposure      0
@@ -159,7 +159,7 @@ static struct reginfo sensor_init_data[] =
 	{0x1c , 0xc1},                                  
 	{0x1d , 0x08},                                  
 	{0x1e , 0x60},                                  
-	{0x1f , 0x16},                                  
+	{0x1f , 0x17},                                  
                                                                    
 	                                                                 
 	{0x20 , 0xff},                                  
@@ -536,7 +536,7 @@ static struct reginfo sensor_init_data[] =
 
 
 	//-------------H_V_Switch(4)---------------//
-			{0x14 , 0x11},  //0x10
+			{0x14 , 0x12},  //0x10
 
 	 /*GC0308_H_V_Switch,
 
@@ -612,276 +612,50 @@ static  struct reginfo sensor_ClrFmt_UYVY[]=
 #if CONFIG_SENSOR_WhiteBalance
 static  struct reginfo sensor_WhiteB_Auto[]=
 {
-	{0x84, 0x6C},		//Contrast 4
-	{0x85, 0x78},
-	{0x86, 0x8C},
-	{0x87, 0x9E},
-	{0x88, 0xBB},
-	{0x89, 0xD2},
-	{0x8A, 0xE6},
-	{0x6C, 0x40},
-	{0x6D, 0x30},
-	{0x6E, 0x48},
-	{0x6F, 0x60},
-	{0x70, 0x70},
-	{0x71, 0x70},
-	{0x72, 0x70},
-	{0x73, 0x70},
-	{0x74, 0x60},
-	{0x75, 0x60},
-	{0x76, 0x50},
-	{0x77, 0x48},
-	{0x78, 0x3A},
-	{0x79, 0x2E},
-	{0x7A, 0x28},
-	{0x7B, 0x22},
-
-	{0x0f, 0x4a},		//Saturation 3
-	{0x27, 0x80},
-	{0x28, 0x80},
-	{0x2c, 0x80},
-	{0x62, 0x60},
-	{0x63, 0xe0},
-	{0x64, 0x04},
-	{0x65, 0x00},
-	{0x66, 0x01},
-	{0x24, 0x70},
-	{0x25, 0x64},
-
-	{0x4f, 0x2e},		//Brightness 3
-	{0x50, 0x31},
-	{0x51, 0x02},
-	{0x52, 0x0e},
-	{0x53, 0x1e},
-	{0x54, 0x2d},
-
-	{0x11, 0x80},
-	{0x14, 0x2a},
-	{0x13, 0xe7},
-	{0x66, 0x05},
-
-    {0x00, 0x00}
+	{0x5a, 0x4c}, 
+	{0x5b, 0x40},
+	{0x5c, 0x4a},
+	{0x22, 0x57},
+	{0x00, 0x00}
 };
 /* Cloudy Colour Temperature : 6500K - 8000K  */
 static  struct reginfo sensor_WhiteB_Cloudy[]=
 {
-	{0x7C,0x04},		//Contrast 5
-	{0x7D,0x09},
-	{0x7E,0x13},
-	{0x7F,0x29},
-	{0x80,0x35},
-	{0x81,0x41},
-	{0x82,0x4D},
-	{0x83,0x59},
-	{0x84,0x64},
-	{0x85,0x6F},
-	{0x86,0x85},
-	{0x87,0x97},
-	{0x88,0xB7},
-	{0x89,0xCF},
-	{0x8A,0xE3},
-	{0x6C,0x40},
-	{0x6D,0x50},
-	{0x6E,0x50},
-	{0x6F,0x58},
-	{0x70,0x60},
-	{0x71,0x60},
-	{0x72,0x60},
-	{0x73,0x60},
-	{0x74,0x58},
-	{0x75,0x58},
-	{0x76,0x58},
-	{0x77,0x48},
-	{0x78,0x40},
-	{0x79,0x30},
-	{0x7A,0x28},
-	{0x7B,0x26},
-
-
-
-	{0x4f,0x3a},		//Saturation 4
-	{0x50,0x3d},
-	{0x51,0x03},
-	{0x52,0x12},
-	{0x53,0x26},
-	{0x54,0x38},
-	{0x4f, 0x2e},		//Brightness 3
-	{0x50, 0x31},
-	{0x51, 0x02},
-	{0x52, 0x0e},
-	{0x53, 0x1e},
-	{0x54, 0x2d},
-
-	{0x11,0x80},
-	{0x14,0x0a},
-	{0x13,0xc7},
-	{0x66,0x05},
+	{0x22, 0x55},	// Disable AWB 
+	{0x5a, 0x5a},
+	{0x5b, 0x42},
+	{0x5c, 0x40},
     {0x00, 0x00}
 };
 /* ClearDay Colour Temperature : 5000K - 6500K  */
 static  struct reginfo sensor_WhiteB_ClearDay[]=
 {
     //Sunny
-	{0x7C,0x04},		//Contrast 5
-	{0x7D,0x09},
-	{0x7E,0x13},
-	{0x7F,0x29},
-	{0x80,0x35},
-	{0x81,0x41},
-	{0x82,0x4D},
-	{0x83,0x59},
-	{0x84,0x64},
-	{0x85,0x6F},
-	{0x86,0x85},
-	{0x87,0x97},
-	{0x88,0xB7},
-	{0x89,0xCF},
-	{0x8A,0xE3},
-	{0x6C,0x40},
-	{0x6D,0x50},
-	{0x6E,0x50},
-	{0x6F,0x58},
-	{0x70,0x60},
-	{0x71,0x60},
-	{0x72,0x60},
-	{0x73,0x60},
-	{0x74,0x58},
-	{0x75,0x58},
-	{0x76,0x58},
-	{0x77,0x48},
-	{0x78,0x40},
-	{0x79,0x30},
-	{0x7A,0x28},
-	{0x7B,0x26},
-
-
-
-	{0x4f,0x3a},		//Saturation 4
-	{0x50,0x3d},
-	{0x51,0x03},
-	{0x52,0x12},
-	{0x53,0x26},
-	{0x54,0x38},
-	{0x4f, 0x2e},		//Brightness 3
-	{0x50, 0x31},
-	{0x51, 0x02},
-	{0x52, 0x0e},
-	{0x53, 0x1e},
-	{0x54, 0x2d},
-
-	{0x11,0x80},
-	{0x14,0x0a},
-	{0x13,0xc7},
-	{0x66,0x05},
+	{0x22, 0x55},   // Disable AWB 
+    {0x5a, 0x50},
+    {0x5b, 0x45},
+    {0x5c, 0x40},
     {0x00, 0x00}
 };
 /* Office Colour Temperature : 3500K - 5000K  */
 static  struct reginfo sensor_WhiteB_TungstenLamp1[]=
 {
     //Office
-	{0x84, 0x6C},		//Contrast 4
-	{0x85, 0x78},
-	{0x86, 0x8C},
-	{0x87, 0x9E},
-	{0x88, 0xBB},
-	{0x89, 0xD2},
-	{0x8A, 0xE6},
-	{0x6C, 0x40},
-	{0x6D, 0x30},
-	{0x6E, 0x48},
-	{0x6F, 0x60},
-	{0x70, 0x70},
-	{0x71, 0x70},
-	{0x72, 0x70},
-	{0x73, 0x70},
-	{0x74, 0x60},
-	{0x75, 0x60},
-	{0x76, 0x50},
-	{0x77, 0x48},
-	{0x78, 0x3A},
-	{0x79, 0x2E},
-	{0x7A, 0x28},
-	{0x7B, 0x22},
-
-	{0x0f, 0x4a},		//Saturation 3
-	{0x27, 0x80},
-	{0x28, 0x80},
-	{0x2c, 0x80},
-	{0x62, 0x60},
-	{0x63, 0xe0},
-	{0x64, 0x04},
-	{0x65, 0x00},
-	{0x66, 0x01},
-	{0x24, 0x70},
-	{0x25, 0x64},
-
-	{0x4f, 0x2e},		//Brightness 3
-	{0x50, 0x31},
-	{0x51, 0x02},
-	{0x52, 0x0e},
-	{0x53, 0x1e},
-	{0x54, 0x2d},
-
-	{0x11,0x80},
-	{0x14,0x2a},
-	{0x13,0xe7},
-	{0x66,0x05},
-
+	{0x22, 0x55},	 // Disable AWB 
+	{0x5a, 0x48},
+	{0x5b, 0x40},
+	{0x5c, 0x5c},
     {0x00, 0x00}
 
-
 };
 /* Home Colour Temperature : 2500K - 3500K  */
 static  struct reginfo sensor_WhiteB_TungstenLamp2[]=
 {
     //Home
-	{0x84, 0x6C},		//Contrast 4
-	{0x85, 0x78},
-	{0x86, 0x8C},
-	{0x87, 0x9E},
-	{0x88, 0xBB},
-	{0x89, 0xD2},
-	{0x8A, 0xE6},
-	{0x6C, 0x40},
-	{0x6D, 0x30},
-	{0x6E, 0x48},
-	{0x6F, 0x60},
-	{0x70, 0x70},
-	{0x71, 0x70},
-	{0x72, 0x70},
-	{0x73, 0x70},
-	{0x74, 0x60},
-	{0x75, 0x60},
-	{0x76, 0x50},
-	{0x77, 0x48},
-	{0x78, 0x3A},
-	{0x79, 0x2E},
-	{0x7A, 0x28},
-	{0x7B, 0x22},
-
-	{0x0f, 0x4a},		//Saturation 3
-	{0x27, 0x80},
-	{0x28, 0x80},
-	{0x2c, 0x80},
-	{0x62, 0x60},
-	{0x63, 0xe0},
-	{0x64, 0x04},
-	{0x65, 0x00},
-	{0x66, 0x01},
-	{0x24, 0x70},
-	{0x25, 0x64},
-
-	{0x4f, 0x2e},		//Brightness 3
-	{0x50, 0x31},
-	{0x51, 0x02},
-	{0x52, 0x0e},
-	{0x53, 0x1e},
-	{0x54, 0x2d},
-
-	{0x11, 0x80},
-	{0x14, 0x2a},
-	{0x13, 0xe7},
-	{0x66, 0x05},
+	{0x22, 0x55},   // Disable AWB 
+	{0x5a, 0x40},
+	{0x5b, 0x42}, 
+	{0x5c, 0x50},
     {0x00, 0x00}
 };
 static struct reginfo *sensor_WhiteBalanceSeqe[] = {sensor_WhiteB_Auto, sensor_WhiteB_TungstenLamp1,sensor_WhiteB_TungstenLamp2,
@@ -893,61 +667,43 @@ static struct reginfo *sensor_WhiteBalanceSeqe[] = {sensor_WhiteB_Auto, sensor_W
 static  struct reginfo sensor_Brightness0[]=
 {
     // Brightness -2
-    {0x3301, 0xff},//bit[7]:1, enable SDE
-    {0x3391, 0x04},
-    {0x3390, 0x49},
-    {0x339a, 0x20},
-    {0x0000, 0x00}
+    {0xb5, 0xe0},
+    {0x00, 0x00}
 };
 
 static  struct reginfo sensor_Brightness1[]=
 {
     // Brightness -1
-    {0x3301, 0xff},//bit[7]:1, enable SDE
-    {0x3391, 0x04},
-    {0x3390, 0x49},
-    {0x339a, 0x10},
-    {0x0000, 0x00}
+    {0xb5, 0xf0},
+    {0x00, 0x00}
 };
 
 static  struct reginfo sensor_Brightness2[]=
 {
     //  Brightness 0
-    {0x3301, 0xff},//bit[7]:1, enable SDE
-    {0x3391, 0x00},
-    {0x3390, 0x41},
-    {0x339a, 0x00},
-    {0x0000, 0x00}
+    {0xb5, 0x00},
+    {0x00, 0x00}
 };
 
 static  struct reginfo sensor_Brightness3[]=
 {
     // Brightness +1
-    {0x3301, 0xff},//bit[7]:1, enable SDE
-    {0x3391, 0x04},
-    {0x3390, 0x41},
-    {0x339a, 0x10},
-    {0x0000, 0x00}
+    {0xb5, 0x20},
+    {0x00, 0x00}
 };
 
 static  struct reginfo sensor_Brightness4[]=
 {
     //  Brightness +2
-    {0x3301, 0xff},//bit[7]:1, enable SDE
-    {0x3391, 0x04},
-    {0x3390, 0x41},
-    {0x339a, 0x20},
-    {0x0000, 0x00}
+    {0xb5, 0x30},
+    {0x00, 0x00}
 };
 
 static  struct reginfo sensor_Brightness5[]=
 {
     //  Brightness +3
-    {0x3301, 0xff},//bit[7]:1, enable SDE
-    {0x3391, 0x04}, //bit[2] enable
-    {0x3390, 0x41}, //bit[3] sign of brightness
-    {0x339a, 0x30},
-    {0x0000, 0x00}
+    {0xb5, 0x40},
+    {0x00, 0x00}
 };
 static struct reginfo *sensor_BrightnessSeqe[] = {sensor_Brightness0, sensor_Brightness1, sensor_Brightness2, sensor_Brightness3,
     sensor_Brightness4, sensor_Brightness5,NULL,
@@ -958,52 +714,89 @@ static struct reginfo *sensor_BrightnessSeqe[] = {sensor_Brightness0, sensor_Bri
 #if CONFIG_SENSOR_Effect
 static  struct reginfo sensor_Effect_Normal[] =
 {
-	{0x3a,0x0d},
-	{0x67,0x80},
-	{0x68,0x80},
-    {0x00, 0x00}
+	{0x23,0x00}, 
+	{0x2d,0x0a}, 
+	{0x20,0x7f}, 
+	{0xd2,0x90}, 
+	{0x73,0x00}, 
+	{0x77,0x38},
+	{0xb3,0x40}, 
+	{0xb4,0x80}, 
+	{0xba,0x00}, 
+	{0xbb,0x00},
+    {0x00,0x00}
 };
 
 static  struct reginfo sensor_Effect_WandB[] =
 {
-	{0x3a,0x1d},
-	{0x67,0x80},
-	{0x68,0x80},
-    {0x00, 0x00}
+	{0x23,0x02}, 
+	{0x2d,0x0a}, 
+	{0x20,0x7f}, 
+	{0xd2,0x90}, 
+	{0x73,0x00}, 
+	{0xb3,0x40},
+	{0xb4,0x80}, 
+	{0xba,0x00}, 
+	{0xbb,0x00}, 
+    {0x00,0x00}
 };
 
 static  struct reginfo sensor_Effect_Sepia[] =
 {
-	{0x3a,0x1d},
-	{0x67,0x40},
-	{0x68,0xa0},
-    {0x00, 0x00}
+	{0x23,0x02},
+	{0x2d,0x0a},
+	{0x20,0x7f},
+	{0xd2,0x90},
+	{0x73,0x00},
+	{0xb3,0x40},
+	{0xb4,0x80},
+	{0xba,0xd2},
+	{0xbb,0x28},
+    {0x00,0x00}
 };
 
 static  struct reginfo sensor_Effect_Negative[] =
 {
     //Negative
-	{0x3a,0x2d},
-	{0x67,0x80},
-	{0x68,0x80},
-    {0x00, 0x00}
+	{0x23,0x01},
+	{0x2d,0x0a},
+	{0x20,0x7f},
+	{0xd2,0x90},
+	{0x73,0x00},
+	{0xb3,0x40},
+	{0xb4,0x80},
+	{0xba,0x00},
+	{0xbb,0x00},
+    {0x00,0x00}
 };
 static  struct reginfo sensor_Effect_Bluish[] =
 {
     // Bluish
-	{0x3a,0x1d},
-	{0x67,0xc0},
-	{0x68,0x80},
-    {0x00, 0x00}
+    {0x23,0x02},
+    {0x2d,0x0a},
+    {0x20,0x7f},
+    {0xd2,0x90},
+    {0x73,0x00},
+	{0xb3,0x40},
+	{0xb4,0x80},
+	{0xba,0x50},
+	{0xbb,0xe0},
+    {0x00,0x00}
 };
 
 static  struct reginfo sensor_Effect_Green[] =
 {
     //  Greenish
-	{0x3a,0x1d},
-	{0x67,0x40},
-	{0x68,0x40},
-    {0x00, 0x00}
+    {0x23,0x02},
+    {0x2d,0x0a},
+    {0x20,0x7f},
+    {0xd2,0x90},
+    {0x77,0x88},
+ 	{0xb3,0x40},
+ 	{0xb4,0x80},
+ 	{0xba,0xc0},
+ 	{0xbb,0xc0},
+    {0x00,0x00}
 };
 static struct reginfo *sensor_EffectSeqe[] = {sensor_Effect_Normal, sensor_Effect_WandB, sensor_Effect_Negative,sensor_Effect_Sepia,
     sensor_Effect_Bluish, sensor_Effect_Green,NULL,
@@ -1012,36 +805,43 @@ static struct reginfo *sensor_EffectSeqe[] = {sensor_Effect_Normal, sensor_Effec
 #if CONFIG_SENSOR_Exposure
 static  struct reginfo sensor_Exposure0[]=
 {
+	{0xd3, 0x30},
     {0x00, 0x00}
 };
 
 static  struct reginfo sensor_Exposure1[]=
 {
+	{0xd3, 0x38},
     {0x00, 0x00}
 };
 
 static  struct reginfo sensor_Exposure2[]=
 {
+	{0xd3, 0x40},
     {0x00, 0x00}
 };
 
 static  struct reginfo sensor_Exposure3[]=
 {
+	{0xd3, 0x48},
     {0x00, 0x00}
 };
 
 static  struct reginfo sensor_Exposure4[]=
 {
+	{0xd3, 0x50},
     {0x00, 0x00}
 };
 
 static  struct reginfo sensor_Exposure5[]=
 {
+	{0xd3, 0x58},
     {0x00, 0x00}
 };
 
 static  struct reginfo sensor_Exposure6[]=
 {
+	{0xd3, 0x60},
     {0x00, 0x00}
 };
 
@@ -1070,37 +870,44 @@ static struct reginfo *sensor_SaturationSeqe[] = {sensor_Saturation0, sensor_Sat
 #if CONFIG_SENSOR_Contrast
 static  struct reginfo sensor_Contrast0[]=
 {
+	{0xb3,0x34},
     {0x00, 0x00}
 };
 
 static  struct reginfo sensor_Contrast1[]=
 {
+	{0xb3,0x38},
     {0x00, 0x00}
 };
 
 static  struct reginfo sensor_Contrast2[]=
 {
+	{0xb3,0x3d},
     {0x00, 0x00}
 };
 
 static  struct reginfo sensor_Contrast3[]=
 {
+	{0xb3,0x40},
     {0x00, 0x00}
 };
 
 static  struct reginfo sensor_Contrast4[]=
 {
+	{0xb3,0x44},
     {0x00, 0x00}
 };
 
 
 static  struct reginfo sensor_Contrast5[]=
 {
+	{0xb3,0x48},
     {0x00, 0x00}
 };
 
 static  struct reginfo sensor_Contrast6[]=
 {
+	{0xb3,0x50},
     {0x00, 0x00}
 };
 static struct reginfo *sensor_ContrastSeqe[] = {sensor_Contrast0, sensor_Contrast1, sensor_Contrast2, sensor_Contrast3,
@@ -1136,12 +943,14 @@ static struct reginfo *sensor_FlipSeqe[] = {sensor_FlipOff, sensor_FlipOn,NULL,}
 #if CONFIG_SENSOR_Scene
 static  struct reginfo sensor_SceneAuto[] =
 {
-{0x00, 0x00}
+	{0xec, 0x00},
+	{0x00, 0x00}
 };
 
 static  struct reginfo sensor_SceneNight[] =
 {
-{0x00, 0x00}
+	{0xec, 0x30},
+	{0x00, 0x00}
 };
 static struct reginfo *sensor_SceneSeqe[] = {sensor_SceneAuto, sensor_SceneNight,NULL,};
 
@@ -1555,15 +1364,17 @@ static int sensor_write_array(struct i2c_client *client, struct reginfo *regarra
     int err;
     int i = 0;
 
-    for(i=0; i < sizeof(sensor_init_data) / 2;i++)
-    	{
+    //for(i=0; i < sizeof(sensor_init_data) / 2;i++)
+	while((regarray[i].reg != 0) || (regarray[i].val != 0))
+    {
         err = sensor_write(client, regarray[i].reg, regarray[i].val);
         if (err != 0)
         {
             SENSOR_TR("%s..write failed current i = %d\n", SENSOR_NAME_STRING(),i);
             return err;
         }
-    	}
+		i++;
+    }
     
     return 0;
 }