From 7d212f27264887bdf70a9d31f72c41898b5b0b8b Mon Sep 17 00:00:00 2001 From: ddl Date: Sat, 1 Jan 2011 22:13:28 +0800 Subject: [PATCH] camera:fix switch 720p to other resoultion display error --- drivers/media/video/ov5642.c | 26 ++++++++++++++++++-------- drivers/media/video/ov5642.h | 7 +++++++ 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/drivers/media/video/ov5642.c b/drivers/media/video/ov5642.c index 90daeadcd5c7..5d997e248c35 100755 --- a/drivers/media/video/ov5642.c +++ b/drivers/media/video/ov5642.c @@ -163,7 +163,7 @@ #define StepFocus_Spec_Tag 0x10 #endif -/* init 640X480 SVGA */ +/* init 800X600 SVGA */ static struct reginfo sensor_init_data[] = { {0x3103 , 0x93}, @@ -840,6 +840,7 @@ static struct reginfo sensor_init_data[] = static struct reginfo sensor_720p[]= { + {SEQUENCE_PROPERTY, SEQUENCE_INIT}, {0x3103, 0x93 }, {0x3008, 0x82 }, {0x3017, 0x7f }, @@ -1357,6 +1358,7 @@ static struct reginfo sensor_720p[]= {0x3002, 0x1c }, {0x3819, 0x80 }, {0x5002, 0xe0 }, + {0x0000 ,0x00} }; @@ -1365,6 +1367,7 @@ static struct reginfo sensor_720p[]= static struct reginfo sensor_1080p[]= { + {SEQUENCE_PROPERTY, SEQUENCE_INIT}, { 0x3103, 0x93 }, { 0x3008, 0x82 }, { 0x3017, 0x7f }, @@ -1377,7 +1380,7 @@ static struct reginfo sensor_1080p[]= { 0x3003, 0x00 }, { 0x3004, 0xff }, { 0x3030, 0x2b }, - { 0x3011, 0x08 }, + { 0x3011, 0x05 }, //0x08 { 0x3010, 0x10 }, { 0x3604, 0x60 }, { 0x3622, 0x60 }, @@ -1825,7 +1828,7 @@ static struct reginfo sensor_1080p[]= { 0x5089, 0x00 }, { 0x302b, 0x00 }, { 0x3503, 0x07 }, - { 0x3011, 0x07 }, + { 0x3011, 0x05 }, { 0x350c, 0x04 }, { 0x350d, 0x58 }, { 0x3801, 0x8a }, @@ -1860,7 +1863,6 @@ static struct reginfo sensor_1080p[]= { 0x5687, 0x1c }, { 0x5001, 0x7f }, { 0x3503, 0x00 }, - { 0x3010, 0x10 }, { 0x460c, 0x20 }, @@ -3079,7 +3081,7 @@ typedef struct sensor_info_priv_s int exposure; unsigned char mirror; /* HFLIP */ unsigned char flip; /* VFLIP */ - unsigned int winseqe_cur_addr; + struct reginfo *winseqe_cur_addr; unsigned int pixfmt; unsigned int funmodule_state; } sensor_info_priv_t; @@ -3641,7 +3643,7 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val) 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.winseqe_cur_addr = SENSOR_INIT_WINSEQADR; sensor->info_priv.pixfmt = SENSOR_INIT_PIXFMT; /* sensor sensor information for initialization */ @@ -3935,7 +3937,7 @@ static int sensor_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f) SENSOR_TR("\n %s..%s Format is Invalidate. pix->width = %d.. pix->height = %d\n",SENSOR_NAME_STRING(),__FUNCTION__,pix->width,pix->height); } - if ((int)winseqe_set_addr != sensor->info_priv.winseqe_cur_addr) + if (winseqe_set_addr != sensor->info_priv.winseqe_cur_addr) { if (sensor_fmt_capturechk(sd,f) == true) { /* ddl@rock-chips.com : Capture */ sensor_parameter_record(client); @@ -3946,13 +3948,21 @@ static int sensor_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f) #endif } + if ((sensor->info_priv.winseqe_cur_addr->reg == SEQUENCE_PROPERTY) && (sensor->info_priv.winseqe_cur_addr->val == SEQUENCE_INIT)) { + if (((winseqe_set_addr->reg == SEQUENCE_PROPERTY) && (winseqe_set_addr->val == SEQUENCE_NORMAL)) + || (winseqe_set_addr->reg != SEQUENCE_PROPERTY)) { + ret |= sensor_write_array(client,sensor_init_data); + SENSOR_DG("\n%s reinit ret:0x%x \n",SENSOR_NAME_STRING(), ret); + } + } + ret |= sensor_write_array(client, winseqe_set_addr); if (ret != 0) { SENSOR_TR("%s set format capability failed\n", SENSOR_NAME_STRING()); goto sensor_s_fmt_end; } - sensor->info_priv.winseqe_cur_addr = (int)winseqe_set_addr; + sensor->info_priv.winseqe_cur_addr = winseqe_set_addr; if (sensor_fmt_capturechk(sd,f) == true) { /* ddl@rock-chips.com : Capture */ sensor_ae_transfer(client); diff --git a/drivers/media/video/ov5642.h b/drivers/media/video/ov5642.h index 7c72af1e4f03..cfdb7c6f783c 100644 --- a/drivers/media/video/ov5642.h +++ b/drivers/media/video/ov5642.h @@ -15,5 +15,12 @@ struct reginfo u16 reg; u8 val; }; + +#define SEQUENCE_INIT 0x00 +#define SEQUENCE_NORMAL 0x01 + +#define SEQUENCE_PROPERTY 0xFFFD +#define SEQUENCE_WAIT_MS 0xFFFE +#define SEQUENCE_END 0xFFFF #endif -- 2.34.1