From: ddl Date: Thu, 27 Jan 2011 15:21:58 +0000 (+0800) Subject: camera: fix ov2659 and ov5642 vsync singal havn't output X-Git-Tag: firefly_0821_release~10785^2~6^2 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=78a0f0b9b7383eeb5fa9b605147fc17531ecd330;p=firefly-linux-kernel-4.4.55.git camera: fix ov2659 and ov5642 vsync singal havn't output --- diff --git a/drivers/media/video/ov2659.c b/drivers/media/video/ov2659.c index e44a5d9939a3..ba34ebd8a661 100755 --- a/drivers/media/video/ov2659.c +++ b/drivers/media/video/ov2659.c @@ -68,10 +68,10 @@ module_param(debug, int, S_IRUGO|S_IWUSR); #define CONFIG_SENSOR_Mirror 0 #define CONFIG_SENSOR_Flip 0 -#define CONFIG_SENSOR_I2C_SPEED 100000 /* Hz */ +#define CONFIG_SENSOR_I2C_SPEED 250000 /* Hz */ /* Sensor write register continues by preempt_disable/preempt_enable for current process not be scheduled */ #define CONFIG_SENSOR_I2C_NOSCHED 1 -#define CONFIG_SENSOR_I2C_RDWRCHK 1 +#define CONFIG_SENSOR_I2C_RDWRCHK 0 #define SENSOR_BUS_PARAM (SOCAM_MASTER | SOCAM_PCLK_SAMPLE_FALLING|\ SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW |\ @@ -261,8 +261,6 @@ static struct reginfo sensor_init_data[] = {0x5062, 0x7d}, {0x5063, 0x69}, {0x3004, 0x20}, - {0x0100,0x00}, - {0x0100,0x01}, {0x0000, 0x00} }; @@ -494,6 +492,7 @@ static struct reginfo sensor_sxga[] = /* 800X600 SVGA*/ static struct reginfo sensor_svga[] = { + {0x0100, 0x00}, //software sleep : Sensor vsync singal may not output if haven't sleep the sensor when transfer the array, {0x3800, 0x00}, {0x3801, 0x00}, {0x3802, 0x00}, @@ -539,6 +538,7 @@ static struct reginfo sensor_svga[] = {0x5002, 0x10}, {0x3005, 0x18}, {0x3004, 0x20}, + {0x0100, 0x01}, //software wake {0x0000, 0x00} }; @@ -1506,8 +1506,8 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val) goto sensor_INIT_ERR; } sensor_task_lock(client,0); - icd->user_width = SENSOR_INIT_WIDTH; - icd->user_height = SENSOR_INIT_HEIGHT; + //icd->user_width = SENSOR_INIT_WIDTH; + //icd->user_height = SENSOR_INIT_HEIGHT; sensor->info_priv.winseqe_cur_addr = (int)SENSOR_INIT_WINSEQADR; sensor->info_priv.pixfmt = SENSOR_INIT_PIXFMT; @@ -1572,6 +1572,8 @@ static int sensor_deactivate(struct i2c_client *client) struct soc_camera_device *icd = client->dev.platform_data; u8 reg_val; + SENSOR_DG("\n%s..%s.. Enter\n",SENSOR_NAME_STRING(),__FUNCTION__); + /* ddl@rock-chips.com : all sensor output pin must change to input for other sensor */ sensor_task_lock(client, 1); sensor_read(client,0x3000,®_val); @@ -1580,9 +1582,11 @@ static int sensor_deactivate(struct i2c_client *client) sensor_read(client,0x3002,®_val); sensor_write(client, 0x3002, reg_val&0x1f); sensor_task_lock(client, 0); - sensor_ioctrl(icd, Sensor_PowerDown, 1); + /* ddl@rock-chips.com : sensor config init width , because next open sensor quickly(soc_camera_open -> Try to configure with default parameters) */ + icd->user_width = SENSOR_INIT_WIDTH; + icd->user_height = SENSOR_INIT_HEIGHT; msleep(100); return 0; } diff --git a/drivers/media/video/ov5642.c b/drivers/media/video/ov5642.c index 07863248044e..6386891bf935 100755 --- a/drivers/media/video/ov5642.c +++ b/drivers/media/video/ov5642.c @@ -73,10 +73,10 @@ module_param(debug, int, S_IRUGO|S_IWUSR); #define CONFIG_SENSOR_Focus 0 #endif -#define CONFIG_SENSOR_I2C_SPEED 100000 /* Hz */ +#define CONFIG_SENSOR_I2C_SPEED 250000 /* Hz */ /* Sensor write register continues by preempt_disable/preempt_enable for current process not be scheduled */ #define CONFIG_SENSOR_I2C_NOSCHED 0 -#define CONFIG_SENSOR_I2C_RDWRCHK 1 +#define CONFIG_SENSOR_I2C_RDWRCHK 0 #define SENSOR_BUS_PARAM (SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING |\ @@ -789,11 +789,11 @@ static struct reginfo sensor_init_data[] = {0x5504,0x00}, {0x5505,0x7f}, {0x5025,0x80}, - {0x3a0f,0x30}, - {0x3a10,0x28}, - {0x3a1b,0x30}, - {0x3a1e,0x28}, - {0x3a11,0x61}, + {0x3a0f,0x48},//0x30 + {0x3a10,0x38},//0x28 + {0x3a1b,0x50},//0x30 + {0x3a1e,0x30},//0x28 + {0x3a11,0x71},//0x61 {0x3a1f,0x10}, {0x5688,0xfd}, {0x5689,0xdf}, @@ -841,6 +841,7 @@ static struct reginfo sensor_init_data[] = static struct reginfo sensor_720p[]= { +#if 0 {SEQUENCE_PROPERTY, SEQUENCE_INIT}, {0x3103, 0x93 }, {0x3008, 0x82 }, @@ -1359,7 +1360,90 @@ static struct reginfo sensor_720p[]= {0x3002, 0x1c }, {0x3819, 0x80 }, {0x5002, 0xe0 }, - +#elif 1 + //{0x3008,0x42}, //software sleep : Sensor vsync singal may not output if haven't sleep the sensor when transfer the array, + {0x3819,0x81}, + {0x3000,0xf8}, + {0x3001,0x48}, + {0x3002,0x5c}, + {0x3003,0x02}, + {0x3005,0xb7}, + {0x3006,0x43}, + {0x3007,0x37}, + {0x350c,0x02}, + {0x350d,0xe4}, + {0x3602,0xfc}, + {0x3612,0xff}, + {0x3613,0x00}, + {0x3621,0xc9}, + {0x3622,0x00}, + {0x3623,0x22}, + {0x3604,0x40}, + {0x3705,0xdb}, + {0x370a,0x81}, + {0x3801,0x50}, + {0x3803,0x08}, + {0x3804,0x05}, + {0x3805,0x00}, + {0x3806,0x02}, + {0x3807,0xd0}, + {0x3808,0x05}, + {0x3809,0x00}, + {0x380a,0x02}, + {0x380b,0xd0}, + {0x380c,0x08}, + {0x380d,0x72}, + {0x380e,0x02}, + {0x380f,0xe4}, + {0x3810,0xc0}, + {0x3818,0xc1}, + {0x381c,0x10}, + {0x381d,0xa0}, + {0x381e,0x05}, + {0x381f,0xb0}, + {0x3820,0x00}, + {0x3821,0x00}, + {0x3824,0x11}, + {0x3825,0xb4}, + {0x3826,0x00}, + {0x3827,0x08}, + {0x3011,0x08}, + {0x3c01,0x80}, + {0x3c01,0x00}, + {0x3c00,0x00}, + {0x3a08,0x0d}, + {0x3a09,0xe0}, + {0x3a0a,0x0b}, + {0x3a0b,0x90}, + {0x3a0d,0x04}, + {0x3a0e,0x03}, + {0x3a11,0x70}, + {0x3a10,0x30}, + {0x3a1b,0x3c}, + {0x3a1e,0x30}, + {0x3a1f,0x10}, + {0x401c,0x04}, + {0x5682,0x05}, + {0x5683,0x00}, + {0x5686,0x02}, + {0x5687,0xcc}, + {0x5001,0x7f}, + {0x589b,0x06}, + {0x589a,0xc5}, + {0x3503,0x00}, + {0x3010,0x10}, + {0x460c,0x22}, + {0x460b,0x37}, + {0x471c,0xd0}, + {0x471d,0x05}, + {0x3815,0x01}, + {0x3818,0xc1}, + {0x501f,0x00}, + {0x4300,0x32}, + {0x3002,0x1c}, + {0x3819,0x80}, + //{0x3008,0x02}, //software wake +#endif {0x0000 ,0x00} }; @@ -1368,6 +1452,7 @@ static struct reginfo sensor_720p[]= static struct reginfo sensor_1080p[]= { +#if 0 {SEQUENCE_PROPERTY, SEQUENCE_INIT}, { 0x3103, 0x93 }, { 0x3008, 0x82 }, @@ -1879,13 +1964,97 @@ static struct reginfo sensor_1080p[]= { 0x3002, 0x1c }, { 0x3819, 0x80 }, { 0x5002, 0xe0 }, +#else + //{0x3008,0x42}, //software sleep : Sensor vsync singal may not output if haven't sleep the sensor when transfer the array, + {0x3819,0x81}, + {0x3000,0xf8}, + {0x3001,0x48}, + {0x3002,0x5c}, + {0x3003,0x02}, + {0x3005,0xb7}, + {0x3006,0x43}, + {0x3007,0x37}, + {0x350c,0x04}, + {0x350d,0x58}, + {0x3602,0xe4}, + {0x3612,0xac}, + {0x3613,0x44}, + {0x3621,0x09}, + {0x3622,0x00},//60}, + {0x3623,0x22}, + {0x3604,0x40},//48}, + {0x3705,0xda}, + {0x370a,0x80}, + {0x3801,0x8a}, + {0x3803,0x0a}, + {0x3804,0x07}, + {0x3805,0x80}, + {0x3806,0x04}, + {0x3807,0x39}, + {0x3808,0x07}, + {0x3809,0x80}, + {0x380a,0x04}, + {0x380b,0x38}, + {0x380c,0x09}, + {0x380d,0xd6}, + {0x380e,0x04}, + {0x380f,0x58}, + {0x3810,0xc2}, + {0x3818,0xc0}, + {0x381c,0x11}, + {0x381d,0xba}, + {0x381e,0x04}, + {0x381f,0x48}, + {0x3820,0x04}, + {0x3821,0x18}, + {0x3824,0x11}, + {0x3825,0xac}, + {0x3826,0x00}, + {0x3827,0x0c}, + { 0x3011, 0x07 }, //10 fps 0x05 //15fps 0x08 + { 0x3c01, 0x80 }, + { 0x3c00, 0x04 }, + {0x3a08,0x14}, //0x05 + {0x3a09,0xe0}, //0xf5 + {0x3a0a,0x11}, //0x04 + {0x3a0b,0x60}, //0xf6 + {0x3a0d,0x04}, //0x0b + {0x3a0e,0x03}, //0x0d + {0x3a10,0x30}, + {0x3a1b,0x3c}, + {0x3a1e,0x30}, + {0x3a11,0x70}, + {0x3a1f,0x10}, + {0x401c,0x06}, + {0x5682,0x07}, + {0x5683,0x60}, + {0x5686,0x04}, + {0x5687,0x1c}, + {0x5001,0x7f}, + {0x589b,0x00}, + {0x589a,0xc0}, + {0x3503,0x00}, + {0x3010,0x30}, + {0x460c,0x22}, + {0x460b,0x37}, + {0x471c,0xd0}, + {0x471d,0x05}, + {0x3815,0x01}, + {0x3818,0xc0}, + {0x501f,0x00}, + {0x4300,0x32}, + {0x3002,0x1c}, + {0x3819,0x80}, + //{0x3008,0x02}, //software wake +#endif { 0x0000, 0x00 } }; /* 2592X1944 QSXGA */ static struct reginfo sensor_qsxga[] = { - {0x3503 , 0x7 }, + {0x3008,0x42}, //software sleep : Sensor vsync singal may not output if haven't sleep the sensor when transfer the array, + //{0x3503 , 0x7 }, {0x3000 , 0x0 }, {0x3001 , 0x0 }, {0x3002 , 0x0 }, @@ -1952,12 +2121,14 @@ static struct reginfo sensor_qsxga[] = {0x3010 , 0x10}, {0x3009 , 0x1 }, {0x300a , 0x56}, + {0x3008,0x02}, //software wake {0x0000 ,0x00} }; /* 2048*1536 QXGA */ static struct reginfo sensor_qxga[] = { - {0x3503 , 0x7 }, + {0x3008,0x42}, //software sleep : Sensor vsync singal may not output if haven't sleep the sensor when transfer the array, + //{0x3503 , 0x7 }, {0x3000 , 0x0 }, {0x3001 , 0x0 }, {0x3002 , 0x0 }, @@ -2050,14 +2221,15 @@ static struct reginfo sensor_qxga[] = {0x5685 ,0x0 }, {0x5686 ,0x7 }, {0x5687 ,0x98}, - + {0x3008,0x02}, //software wake {0x0000 ,0x00} }; /* 1600X1200 UXGA */ static struct reginfo sensor_uxga[] = { - {0x3503 , 0x7 }, + {0x3008,0x42}, //software sleep : Sensor vsync singal may not output if haven't sleep the sensor when transfer the array, + //{0x3503 , 0x7 }, {0x3000 , 0x0 }, {0x3001 , 0x0 }, {0x3002 , 0x0 }, @@ -2150,13 +2322,15 @@ static struct reginfo sensor_uxga[] = {0x5685 ,0x0 }, {0x5686 ,0x7 }, {0x5687 ,0x98}, + {0x3008,0x02}, //software wake {0x0000 ,0x00} }; /* 1280X1024 SXGA */ static struct reginfo sensor_sxga[] = { - {0x3503 , 0x7 }, + {0x3008,0x42}, //software sleep : Sensor vsync singal may not output if haven't sleep the sensor when transfer the array, + //{0x3503 , 0x7 }, {0x3000 , 0x0 }, {0x3001 , 0x0 }, {0x3002 , 0x0 }, @@ -2249,107 +2423,100 @@ static struct reginfo sensor_sxga[] = {0x5685 ,0x0 }, {0x5686 ,0x7 }, {0x5687 ,0x98}, - + {0x3008,0x02}, //software wake {0x0000,0x00} }; /* 800X600 SVGA*/ static struct reginfo sensor_svga[] = { -#if 1 - {0x3000,0xf8}, - {0x3001,0x48}, - {0x3002,0x5c}, - {0x3003,0x2}, - {0x3005,0xb7}, - {0x3006,0x43}, - {0x3007,0x37}, - {0x350c,0x07}, - {0x350d,0xd0}, - {0x3602,0xfc}, - {0x3612,0xff}, - {0x3613,0x0}, - {0x3621,0xc7}, - {0x3622,0x00}, - {0x3623,0x22}, - {0x3604,0x40}, - {0x3705,0xdb}, - {0x370a,0x81}, - {0x3801,0x50}, - {0x3803,0x08}, - {0x3804,0x05}, - {0x3805,0x0}, - {0x3806,0x03}, - {0x3807,0xc0}, - {0x3808,0x3}, - {0x3809,0x20}, - {0x380a,0x2}, - {0x380b,0x58}, - {0x380c,0x0c}, - {0x380d,0x80}, - {0x380e,0x03}, - {0x380f,0xe8}, - {0x3810,0xc0}, - {0x3815,0x02}, - {0x3818,0xc1}, - {0x3824,0x11}, - {0x3827,0x08}, - {0x3a00,0x78}, - {0x3a0d,0x8}, - {0x3a0e,0x06}, - {0x3a10,0x72}, - {0x3a1b,0x80}, - {0x3a1e,0x70}, - {0x3a11,0xd0}, - {0x3a1f,0x10}, - {0x460b,0x37}, - {0x471d,0x5}, - {0x4713,0x02}, - {0x471c,0xd0}, - {0x501f,0x00}, - {0x4300,0x32}, - {0x3002,0x5c}, - {0x5682,0x5}, - {0x5683,0x0}, - {0x5686,0x3}, - {0x5687,0xc0}, - {0x5001,0x7f}, - {0x589b,0x4}, - {0x589a,0xc5}, - {0x4407,0x04}, - {0x3002,0x5c}, - {0x3503,0x00}, - {0x3000,0x00}, -#else - {0x3800 ,0x1 }, - {0x3801 ,0x50}, - {0x3802 ,0x0 }, - {0x3803 ,0x8 }, - {0x3804 ,0x5 }, - {0x3805 ,0x0 }, - {0x3806 ,0x3 }, - {0x3807 ,0xc0}, - {0x3808 ,0x3 }, - {0x3809 ,0x20}, - {0x380a ,0x2 }, - {0x380b ,0x58}, - {0x380c ,0xc }, - {0x380d ,0x80}, - {0x380e ,0x3 }, - {0x380f ,0xe8}, - {0x5001 ,0x7f}, - {0x5680 ,0x0 }, - {0x5681 ,0x0 }, - {0x5682 ,0x5 }, - {0x5683 ,0x0 }, - {0x5684 ,0x0 }, - {0x5685 ,0x0 }, - {0x5686 ,0x3 }, - {0x5687 ,0xc0}, - {0x5687 ,0xc0}, - {0x3815 ,0x02}, - {0x3503 ,0x00}, -#endif +{0x3819,0x81}, +{0x3000,0xf8}, +{0x3001,0x48}, +{0x3002,0x5c}, +{0x3003,0x02}, +{0x3005,0xb7}, +{0x3006,0x43}, +{0x3007,0x37}, +{0x350c,0x07},//03 +{0x350d,0xd0},//e8 +{0x3602,0xfc}, +{0x3612,0xff}, +{0x3613,0x00}, +{0x3621,0xc7},//87 +{0x3622,0x00},//60 +{0x3623,0x22},//01 +{0x3604,0x40},//48 +{0x3705,0xdb}, +{0x370a,0x81}, +{0x3801,0x50}, +{0x3803,0x08}, +{0x3804,0x05}, +{0x3805,0x00}, +{0x3806,0x03}, +{0x3807,0xc0}, +{0x3808,0x03}, +{0x3809,0x20}, +{0x380a,0x02}, +{0x380b,0x58}, +{0x380c,0x0c}, +{0x380d,0x80}, +{0x380e,0x03}, +{0x380f,0xe8}, +{0x3810,0x40},//c0 +{0x3815,0x02}, +{0x3818,0xc1}, +{0x381c,0x21}, +{0x381d,0x50}, +{0x381e,0x01}, +{0x381f,0x20}, +{0x3820,0x00}, +{0x3821,0x00}, +{0x3824,0x11}, +{0x3825,0xb4}, +{0x3826,0x00}, +{0x3827,0x08}, +{0x3a00,0x78}, + { 0x3011, 0x08 }, + { 0x3c01, 0x80 }, + { 0x3c00, 0x04 }, +{0x3a08,0x09}, +{0x3a09,0x60}, +{0x3a0a,0x07}, +{0x3a0b,0xd0}, +{0x3a0d,0x08}, +{0x3a0e,0x06}, +{0x3a10,0x30}, +{0x3a1b,0x3c}, +{0x3a1e,0x30}, +{0x3a11,0x70}, +{0x3a1f,0x10}, +{0x3010,0x10}, +{0x460b,0x37}, +{0x471d,0x05}, +{0x4713,0x02}, +{0x471c,0xd0}, +{0x501f,0x00}, +{0x4300,0x32}, +{0x3002,0x5c}, +{0x5682,0x05}, +{0x5683,0x00}, +{0x5686,0x03}, +{0x5687,0xc0}, +{0x5001,0x7f}, +{0x589b,0x04}, +{0x589a,0xc5}, +{0x4407,0x04}, +{0x3002,0x5c}, +{0x460c,0x22}, +{0x3815,0x03}, +{0x3000,0x00}, +{0x3819,0x80}, + {0x3406,0x00}, + {0x5183,0x80}, + {0x5191,0xff}, + {0x5192,0x00}, +{0x3503,0x00}, {0x0000 ,0x00} }; @@ -3144,6 +3311,7 @@ struct sensor_parameter unsigned short int capture_framerate; unsigned short int preview_framerate; + char awb[6]; }; struct sensor @@ -3645,6 +3813,9 @@ int sensor_parameter_record(struct i2c_client *client) u8 tp_l,tp_m,tp_h; struct sensor *sensor = to_sensor(client); + sensor_write(client,0x3503,0x07); //stop AE/AG + sensor_write(client,0x3406,0x01); //stop AWB + sensor_read(client,0x3500,&ret_h); sensor_read(client,0x3501, &ret_m); sensor_read(client,0x3502, &ret_l); @@ -3664,6 +3835,13 @@ int sensor_parameter_record(struct i2c_client *client) sensor->parameter.capture_framerate = 900; sensor->parameter.preview_framerate = 1500; + sensor_read(client,0x3400,&sensor->parameter.awb[0]); //record awb value + sensor_read(client,0x3401,&sensor->parameter.awb[1]); + sensor_read(client,0x3402,&sensor->parameter.awb[2]); + sensor_read(client,0x3403,&sensor->parameter.awb[3]); + sensor_read(client,0x3404,&sensor->parameter.awb[4]); + sensor_read(client,0x3405,&sensor->parameter.awb[5]); + SENSOR_DG(" %s Read 0x350c = 0x%02x 0x350d = 0x%02x 0x350b=0x%02x \n",SENSOR_NAME_STRING(), ret_h, ret_l, sensor->parameter.preview_gain); return 0; } @@ -3771,6 +3949,14 @@ int sensor_ae_transfer(struct i2c_client *client) //¼Ó³¤ÑÓʱ£¬±ÜÃâ°µ´¦ÅÄÕÕʱµÄÃ÷°µ·Ö½çÎÊÌâ //camera_timed_wait(200); //linzhk camera_timed_wait(500); + + sensor_write(client,0x3400,sensor->parameter.awb[0]); // resume awb value + sensor_write(client,0x3401,sensor->parameter.awb[1]); + sensor_write(client,0x3402,sensor->parameter.awb[2]); + sensor_write(client,0x3403,sensor->parameter.awb[3]); + sensor_write(client,0x3404,sensor->parameter.awb[4]); + sensor_write(client,0x3405,sensor->parameter.awb[5]); + SENSOR_DG(" %s Write 0x350b = 0x%02x 0x3502 = 0x%02x 0x3501=0x%02x 0x3500 = 0x%02x\n",SENSOR_NAME_STRING(), Gain, ExposureLow, ExposureMid, ExposureHigh); mdelay(100); return 0; @@ -3881,8 +4067,8 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val) goto sensor_INIT_ERR; } sensor_task_lock(client,0); - icd->user_width = SENSOR_INIT_WIDTH; - icd->user_height = SENSOR_INIT_HEIGHT; + //icd->user_width = SENSOR_INIT_WIDTH; + //icd->user_height = SENSOR_INIT_HEIGHT; sensor->info_priv.winseqe_cur_addr = SENSOR_INIT_WINSEQADR; sensor->info_priv.pixfmt = SENSOR_INIT_PIXFMT; @@ -3939,17 +4125,19 @@ sensor_INIT_ERR: static int sensor_deactivate(struct i2c_client *client) { struct soc_camera_device *icd = client->dev.platform_data; + + SENSOR_DG("\n%s..%s.. Enter\n",SENSOR_NAME_STRING(),__FUNCTION__); + /* ddl@rock-chips.com : all sensor output pin must change to input for other sensor */ sensor_task_lock(client, 1); sensor_write(client, 0x3017, 0x00); // FREX,VSYNC,HREF,PCLK,D9-D6 sensor_write(client, 0x3018, 0x03); // D5-D0 sensor_write(client,0x3019,0X00); // STROBE,SDA - SENSOR_DG("\n%s..%s exit \n",SENSOR_NAME_STRING(),__FUNCTION__); - sensor_task_lock(client, 0); - sensor_ioctrl(icd, Sensor_PowerDown, 1); - + /* ddl@rock-chips.com : sensor config init width , because next open sensor quickly(soc_camera_open -> Try to configure with default parameters) */ + icd->user_width = SENSOR_INIT_WIDTH; + icd->user_height = SENSOR_INIT_HEIGHT; msleep(100); return 0; }