From: ddl Date: Mon, 31 Jan 2011 04:34:12 +0000 (+0800) Subject: camera:fix sensor driver effect and whitebalance is invalidate after capture or video X-Git-Tag: firefly_0821_release~10756^2~19 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=7f874beb11cc442c95a8bb70f67a3e10c2061820;p=firefly-linux-kernel-4.4.55.git camera:fix sensor driver effect and whitebalance is invalidate after capture or video --- diff --git a/drivers/media/video/ov2655.c b/drivers/media/video/ov2655.c index c977cf527829..ab50e9b8b458 100755 --- a/drivers/media/video/ov2655.c +++ b/drivers/media/video/ov2655.c @@ -1382,6 +1382,9 @@ static int sensor_suspend(struct soc_camera_device *icd, pm_message_t pm_msg); static int sensor_resume(struct soc_camera_device *icd); static int sensor_set_bus_param(struct soc_camera_device *icd,unsigned long flags); static unsigned long sensor_query_bus_param(struct soc_camera_device *icd); +static int sensor_set_effect(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value); +static int sensor_set_whiteBalance(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value); +static int sensor_deactivate(struct i2c_client *client); static struct soc_camera_ops sensor_ops = { @@ -1419,6 +1422,8 @@ typedef struct sensor_info_priv_s int focus; int flash; int exposure; + bool snap2preview; + bool video2preview; unsigned char mirror; /* HFLIP */ unsigned char flip; /* VFLIP */ unsigned int winseqe_cur_addr; @@ -1438,8 +1443,6 @@ struct sensor struct rk29camera_platform_data *sensor_io_request; }; -static int sensor_deactivate(struct i2c_client *client); - static struct sensor* to_sensor(const struct i2c_client *client) { return container_of(i2c_get_clientdata(client), struct sensor, subdev); @@ -1878,11 +1881,48 @@ static int sensor_g_fmt(struct v4l2_subdev *sd, struct v4l2_format *f) return 0; } +static bool sensor_fmt_capturechk(struct v4l2_subdev *sd, struct v4l2_format *f) +{ + bool ret = false; + + if ((f->fmt.pix.width == 1024) && (f->fmt.pix.height == 768)) { + ret = true; + } else if ((f->fmt.pix.width == 1280) && (f->fmt.pix.height == 1024)) { + ret = true; + } else if ((f->fmt.pix.width == 1600) && (f->fmt.pix.height == 1200)) { + ret = true; + } else if ((f->fmt.pix.width == 2048) && (f->fmt.pix.height == 1536)) { + ret = true; + } else if ((f->fmt.pix.width == 2592) && (f->fmt.pix.height == 1944)) { + ret = true; + } + + if (ret == true) + SENSOR_DG("%s %dx%d is capture format\n", __FUNCTION__, f->fmt.pix.width, f->fmt.pix.height); + return ret; +} + +static bool sensor_fmt_videochk(struct v4l2_subdev *sd, struct v4l2_format *f) +{ + bool ret = false; + + if ((f->fmt.pix.width == 1280) && (f->fmt.pix.height == 720)) { + ret = true; + } else if ((f->fmt.pix.width == 1920) && (f->fmt.pix.height == 1080)) { + ret = true; + } + + if (ret == true) + SENSOR_DG("%s %dx%d is video format\n", __FUNCTION__, f->fmt.pix.width, f->fmt.pix.height); + return ret; +} static int sensor_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f) { struct i2c_client *client = sd->priv; struct sensor *sensor = to_sensor(client); struct v4l2_pix_format *pix = &f->fmt.pix; + const struct v4l2_queryctrl *qctrl; + struct soc_camera_device *icd = client->dev.platform_data; struct reginfo *winseqe_set_addr=NULL; int ret=0, set_w,set_h; @@ -1976,7 +2016,28 @@ static int sensor_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f) sensor->info_priv.winseqe_cur_addr = (int)winseqe_set_addr; - + if (sensor_fmt_capturechk(sd,f) == true) { /* ddl@rock-chips.com : Capture */ + qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT); + sensor_set_effect(icd, qctrl,sensor->info_priv.effect); + if (sensor->info_priv.whiteBalance != 0) { + qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE); + sensor_set_whiteBalance(icd, qctrl,sensor->info_priv.whiteBalance); + } + sensor->info_priv.snap2preview = true; + } else if (sensor_fmt_videochk(sd,f) == true) { /* ddl@rock-chips.com : Video */ + qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT); + sensor_set_effect(icd, qctrl,sensor->info_priv.effect); + qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE); + sensor_set_whiteBalance(icd, qctrl,sensor->info_priv.whiteBalance); + sensor->info_priv.video2preview = true; + } else if ((sensor->info_priv.snap2preview == true) || (sensor->info_priv.video2preview == true)) { + qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT); + sensor_set_effect(icd, qctrl,sensor->info_priv.effect); + qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE); + sensor_set_whiteBalance(icd, qctrl,sensor->info_priv.whiteBalance); + sensor->info_priv.video2preview = false; + sensor->info_priv.snap2preview = false; + } SENSOR_DG("\n%s..%s.. icd->width = %d.. icd->height %d\n",SENSOR_NAME_STRING(),__FUNCTION__,set_w,set_h); } else diff --git a/drivers/media/video/ov2659.c b/drivers/media/video/ov2659.c index f1fe71fbcb4b..a2e4aa1b8c58 100755 --- a/drivers/media/video/ov2659.c +++ b/drivers/media/video/ov2659.c @@ -20,7 +20,7 @@ o* Driver for MT9M001 CMOS Image Sensor from Micron #include #include #include -#include + static int debug; module_param(debug, int, S_IRUGO|S_IWUSR); @@ -1189,6 +1189,9 @@ static int sensor_suspend(struct soc_camera_device *icd, pm_message_t pm_msg); static int sensor_resume(struct soc_camera_device *icd); static int sensor_set_bus_param(struct soc_camera_device *icd,unsigned long flags); static unsigned long sensor_query_bus_param(struct soc_camera_device *icd); +static int sensor_set_effect(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value); +static int sensor_set_whiteBalance(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value); +static int sensor_deactivate(struct i2c_client *client); static struct soc_camera_ops sensor_ops = { @@ -1226,6 +1229,8 @@ typedef struct sensor_info_priv_s int focus; int flash; int exposure; + bool snap2preview; + bool video2preview; unsigned char mirror; /* HFLIP */ unsigned char flip; /* VFLIP */ unsigned int winseqe_cur_addr; @@ -1245,7 +1250,6 @@ struct sensor struct rk29camera_platform_data *sensor_io_request; }; -static int sensor_deactivate(struct i2c_client *client); static struct sensor* to_sensor(const struct i2c_client *client) { @@ -1687,17 +1691,51 @@ static int sensor_g_fmt(struct v4l2_subdev *sd, struct v4l2_format *f) return 0; } +static bool sensor_fmt_capturechk(struct v4l2_subdev *sd, struct v4l2_format *f) +{ + bool ret = false; + + if ((f->fmt.pix.width == 1024) && (f->fmt.pix.height == 768)) { + ret = true; + } else if ((f->fmt.pix.width == 1280) && (f->fmt.pix.height == 1024)) { + ret = true; + } else if ((f->fmt.pix.width == 1600) && (f->fmt.pix.height == 1200)) { + ret = true; + } else if ((f->fmt.pix.width == 2048) && (f->fmt.pix.height == 1536)) { + ret = true; + } else if ((f->fmt.pix.width == 2592) && (f->fmt.pix.height == 1944)) { + ret = true; + } + + if (ret == true) + SENSOR_DG("%s %dx%d is capture format\n", __FUNCTION__, f->fmt.pix.width, f->fmt.pix.height); + return ret; +} + +static bool sensor_fmt_videochk(struct v4l2_subdev *sd, struct v4l2_format *f) +{ + bool ret = false; + + if ((f->fmt.pix.width == 1280) && (f->fmt.pix.height == 720)) { + ret = true; + } else if ((f->fmt.pix.width == 1920) && (f->fmt.pix.height == 1080)) { + ret = true; + } + + if (ret == true) + SENSOR_DG("%s %dx%d is video format\n", __FUNCTION__, f->fmt.pix.width, f->fmt.pix.height); + return ret; +} static int sensor_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f) { struct i2c_client *client = sd->priv; struct sensor *sensor = to_sensor(client); struct v4l2_pix_format *pix = &f->fmt.pix; + const struct v4l2_queryctrl *qctrl; + struct soc_camera_device *icd = client->dev.platform_data; struct reginfo *winseqe_set_addr=NULL; int ret=0, set_w,set_h; - gpio_direction_output(RK29_PIN6_PB7,1); - gpio_set_value(RK29_PIN6_PB7, 1); - if (sensor->info_priv.pixfmt != pix->pixelformat) { switch (pix->pixelformat) { @@ -1794,6 +1832,28 @@ static int sensor_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f) sensor->info_priv.winseqe_cur_addr = (int)winseqe_set_addr; + if (sensor_fmt_capturechk(sd,f) == true) { /* ddl@rock-chips.com : Capture */ + qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT); + sensor_set_effect(icd, qctrl,sensor->info_priv.effect); + if (sensor->info_priv.whiteBalance != 0) { + qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE); + sensor_set_whiteBalance(icd, qctrl,sensor->info_priv.whiteBalance); + } + sensor->info_priv.snap2preview = true; + } else if (sensor_fmt_videochk(sd,f) == true) { /* ddl@rock-chips.com : Video */ + qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT); + sensor_set_effect(icd, qctrl,sensor->info_priv.effect); + qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE); + sensor_set_whiteBalance(icd, qctrl,sensor->info_priv.whiteBalance); + sensor->info_priv.video2preview = true; + } else if ((sensor->info_priv.snap2preview == true) || (sensor->info_priv.video2preview == true)) { + qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT); + sensor_set_effect(icd, qctrl,sensor->info_priv.effect); + qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE); + sensor_set_whiteBalance(icd, qctrl,sensor->info_priv.whiteBalance); + sensor->info_priv.video2preview = false; + sensor->info_priv.snap2preview = false; + } SENSOR_DG("\n%s..%s.. icd->width = %d.. icd->height %d\n",SENSOR_NAME_STRING(),__FUNCTION__,set_w,set_h); } @@ -1806,8 +1866,6 @@ static int sensor_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f) pix->height = set_h; sensor_s_fmt_end: - gpio_direction_output(RK29_PIN6_PB7,0); - gpio_set_value(RK29_PIN6_PB7, 0); return ret; } diff --git a/drivers/media/video/ov5640.c b/drivers/media/video/ov5640.c index bcbee7f48bb2..553924dc1db7 100755 --- a/drivers/media/video/ov5640.c +++ b/drivers/media/video/ov5640.c @@ -1262,6 +1262,9 @@ static int sensor_suspend(struct soc_camera_device *icd, pm_message_t pm_msg); static int sensor_resume(struct soc_camera_device *icd); static int sensor_set_bus_param(struct soc_camera_device *icd,unsigned long flags); static unsigned long sensor_query_bus_param(struct soc_camera_device *icd); +static int sensor_set_effect(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value); +static int sensor_set_whiteBalance(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value); +static int sensor_deactivate(struct i2c_client *client); static struct soc_camera_ops sensor_ops = { @@ -1312,6 +1315,8 @@ typedef struct sensor_info_priv_s int affm_reinit; int flash; int exposure; + bool snap2preview; + bool video2preview; unsigned char mirror; /* HFLIP */ unsigned char flip; /* VFLIP */ struct reginfo *winseqe_cur_addr; @@ -1350,9 +1355,6 @@ struct sensor struct rk29camera_platform_data *sensor_io_request; }; -static int sensor_deactivate(struct i2c_client *client); - - static struct sensor* to_sensor(const struct i2c_client *client) { return container_of(i2c_get_clientdata(client), struct sensor, subdev); @@ -2262,7 +2264,9 @@ static bool sensor_fmt_capturechk(struct v4l2_subdev *sd, struct v4l2_format *f) { bool ret = false; - if ((f->fmt.pix.width == 1280) && (f->fmt.pix.height == 1024)) { + if ((f->fmt.pix.width == 1024) && (f->fmt.pix.height == 768)) { + ret = true; + } else if ((f->fmt.pix.width == 1280) && (f->fmt.pix.height == 1024)) { ret = true; } else if ((f->fmt.pix.width == 1600) && (f->fmt.pix.height == 1200)) { ret = true; @@ -2276,11 +2280,27 @@ static bool sensor_fmt_capturechk(struct v4l2_subdev *sd, struct v4l2_format *f) SENSOR_DG("%s %dx%d is capture format\n", __FUNCTION__, f->fmt.pix.width, f->fmt.pix.height); return ret; } +static bool sensor_fmt_videochk(struct v4l2_subdev *sd, struct v4l2_format *f) +{ + bool ret = false; + + if ((f->fmt.pix.width == 1280) && (f->fmt.pix.height == 720)) { + ret = true; + } else if ((f->fmt.pix.width == 1920) && (f->fmt.pix.height == 1080)) { + ret = true; + } + + if (ret == true) + SENSOR_DG("%s %dx%d is video format\n", __FUNCTION__, f->fmt.pix.width, f->fmt.pix.height); + return ret; +} static int sensor_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f) { struct i2c_client *client = sd->priv; struct sensor *sensor = to_sensor(client); struct v4l2_pix_format *pix = &f->fmt.pix; + const struct v4l2_queryctrl *qctrl; + struct soc_camera_device *icd = client->dev.platform_data; struct reginfo *winseqe_set_addr=NULL; int ret = 0, set_w,set_h; @@ -2417,6 +2437,27 @@ static int sensor_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f) if (sensor_fmt_capturechk(sd,f) == true) { /* ddl@rock-chips.com : Capture */ sensor_ae_transfer(client); + qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT); + sensor_set_effect(icd, qctrl,sensor->info_priv.effect); + if (sensor->info_priv.whiteBalance != 0) { + qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE); + sensor_set_whiteBalance(icd, qctrl,sensor->info_priv.whiteBalance); + } + sensor->info_priv.snap2preview = true; + } else if (sensor_fmt_videochk(sd,f) == true) { /* ddl@rock-chips.com : Video */ + qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT); + sensor_set_effect(icd, qctrl,sensor->info_priv.effect); + + sensor->info_priv.video2preview = true; + } else if ((sensor->info_priv.snap2preview == true) || (sensor->info_priv.video2preview == true)) { + qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT); + sensor_set_effect(icd, qctrl,sensor->info_priv.effect); + if (sensor->info_priv.snap2preview == true) { + qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE); + sensor_set_whiteBalance(icd, qctrl,sensor->info_priv.whiteBalance); + } + sensor->info_priv.video2preview = false; + sensor->info_priv.snap2preview = false; } SENSOR_DG("\n%s..%s.. icd->width = %d.. icd->height %d\n",SENSOR_NAME_STRING(),__FUNCTION__,set_w,set_h); } diff --git a/drivers/media/video/ov5642.c b/drivers/media/video/ov5642.c index 066f7993c1dc..b440dd012a60 100755 --- a/drivers/media/video/ov5642.c +++ b/drivers/media/video/ov5642.c @@ -2516,10 +2516,6 @@ static struct reginfo sensor_svga[] = {0x3815,0x03}, {0x3000,0x00}, {0x3819,0x80}, - {0x3406,0x00}, - {0x5183,0x80}, - {0x5191,0xff}, - {0x5192,0x00}, {0x3503,0x00}, {0x0000 ,0x00} }; @@ -3245,6 +3241,9 @@ static int sensor_suspend(struct soc_camera_device *icd, pm_message_t pm_msg); static int sensor_resume(struct soc_camera_device *icd); static int sensor_set_bus_param(struct soc_camera_device *icd,unsigned long flags); static unsigned long sensor_query_bus_param(struct soc_camera_device *icd); +static int sensor_set_effect(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value); +static int sensor_set_whiteBalance(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value); +static int sensor_deactivate(struct i2c_client *client); static struct soc_camera_ops sensor_ops = { @@ -3297,6 +3296,8 @@ typedef struct sensor_info_priv_s int exposure; unsigned char mirror; /* HFLIP */ unsigned char flip; /* VFLIP */ + bool snap2preview; + bool video2preview; struct reginfo *winseqe_cur_addr; unsigned int pixfmt; unsigned int enable; @@ -3314,7 +3315,6 @@ struct sensor_parameter unsigned short int capture_framerate; unsigned short int preview_framerate; - char awb[6]; }; struct sensor @@ -3333,9 +3333,6 @@ struct sensor struct rk29camera_platform_data *sensor_io_request; }; -static int sensor_deactivate(struct i2c_client *client); - - static struct sensor* to_sensor(const struct i2c_client *client) { return container_of(i2c_get_clientdata(client), struct sensor, subdev); @@ -3858,13 +3855,6 @@ static 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; } @@ -3973,13 +3963,6 @@ static 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; @@ -4260,11 +4243,28 @@ static bool sensor_fmt_capturechk(struct v4l2_subdev *sd, struct v4l2_format *f) SENSOR_DG("%s %dx%d is capture format\n", __FUNCTION__, f->fmt.pix.width, f->fmt.pix.height); return ret; } + +static bool sensor_fmt_videochk(struct v4l2_subdev *sd, struct v4l2_format *f) +{ + bool ret = false; + + if ((f->fmt.pix.width == 1280) && (f->fmt.pix.height == 720)) { + ret = true; + } else if ((f->fmt.pix.width == 1920) && (f->fmt.pix.height == 1080)) { + ret = true; + } + + if (ret == true) + SENSOR_DG("%s %dx%d is video format\n", __FUNCTION__, f->fmt.pix.width, f->fmt.pix.height); + return ret; +} static int sensor_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f) { struct i2c_client *client = sd->priv; struct sensor *sensor = to_sensor(client); struct v4l2_pix_format *pix = &f->fmt.pix; + const struct v4l2_queryctrl *qctrl; + struct soc_camera_device *icd = client->dev.platform_data; struct reginfo *winseqe_set_addr=NULL; int ret = 0, set_w,set_h; @@ -4407,6 +4407,27 @@ static int sensor_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f) if (sensor_fmt_capturechk(sd,f) == true) { /* ddl@rock-chips.com : Capture */ sensor_ae_transfer(client); + qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT); + sensor_set_effect(icd, qctrl,sensor->info_priv.effect); + if (sensor->info_priv.whiteBalance != 0) { + qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE); + sensor_set_whiteBalance(icd, qctrl,sensor->info_priv.whiteBalance); + } + sensor->info_priv.snap2preview = true; + } else if (sensor_fmt_videochk(sd,f) == true) { /* ddl@rock-chips.com : Video */ + qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT); + sensor_set_effect(icd, qctrl,sensor->info_priv.effect); + + sensor->info_priv.video2preview = true; + } else if ((sensor->info_priv.snap2preview == true) || (sensor->info_priv.video2preview == true)) { + qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT); + sensor_set_effect(icd, qctrl,sensor->info_priv.effect); + if (sensor->info_priv.snap2preview == true) { + qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE); + sensor_set_whiteBalance(icd, qctrl,sensor->info_priv.whiteBalance); + } + sensor->info_priv.video2preview = false; + sensor->info_priv.snap2preview = false; } SENSOR_DG("\n%s..%s.. icd->width = %d.. icd->height %d\n",SENSOR_NAME_STRING(),__FUNCTION__,set_w,set_h); }