From 1a09644b475fa7f3ebafa1923378a90ab96f9170 Mon Sep 17 00:00:00 2001 From: Zefa Chen Date: Tue, 16 Apr 2019 19:30:21 +0800 Subject: [PATCH] media: i2c: fixed gc2385 gc5025 gc8034 exposure issue. Change-Id: I2db0d30fba278be17dd49c57451f55894d282bc3 Signed-off-by: Zefa Chen --- drivers/media/i2c/gc2385.c | 20 +++++++++----------- drivers/media/i2c/gc5025.c | 12 ++++++------ drivers/media/i2c/gc8034.c | 16 ++++++++-------- 3 files changed, 23 insertions(+), 25 deletions(-) diff --git a/drivers/media/i2c/gc2385.c b/drivers/media/i2c/gc2385.c index 2cb28aedf3a1..b32a59c99add 100644 --- a/drivers/media/i2c/gc2385.c +++ b/drivers/media/i2c/gc2385.c @@ -228,10 +228,10 @@ static const struct gc2385_mode supported_modes[] = { .height = 1200, .max_fps = { .numerator = 10000, - .denominator = 300000, + .denominator = 304472, }, .exp_def = 0x0480, - .hts_def = 0x05E8, + .hts_def = 0x10DC, .vts_def = 0x04E0, .reg_list = gc2385_1600x1200_regs, }, @@ -360,11 +360,10 @@ static int gc2385_set_fmt(struct v4l2_subdev *sd, #endif } else { gc2385->cur_mode = mode; - h_blank = mode->hts_def - - (((mode->width + 16) / 2 + 40) / 2 + 9); + h_blank = mode->hts_def - mode->width; __v4l2_ctrl_modify_range(gc2385->hblank, h_blank, h_blank, 1, h_blank); - vblank_def = mode->vts_def - mode->height - 32; + vblank_def = mode->vts_def - mode->height; __v4l2_ctrl_modify_range(gc2385->vblank, vblank_def, GC2385_VTS_MAX - mode->height, 1, vblank_def); @@ -643,8 +642,7 @@ disable_clk: static void __gc2385_power_off(struct gc2385 *gc2385) { - int ret; - struct device *dev = &gc2385->client->dev; + int ret = 0; if (!IS_ERR(gc2385->pwdn_gpio)) gpiod_set_value_cansleep(gc2385->pwdn_gpio, 1); @@ -655,7 +653,7 @@ static void __gc2385_power_off(struct gc2385 *gc2385) ret = pinctrl_select_state(gc2385->pinctrl, gc2385->pins_sleep); if (ret < 0) - dev_dbg(dev, "could not set pins\n"); + dev_dbg(&gc2385->client->dev, "could not set pins\n"); } regulator_bulk_disable(GC2385_NUM_SUPPLIES, gc2385->supplies); } @@ -869,7 +867,7 @@ static int gc2385_set_ctrl(struct v4l2_ctrl *ctrl) switch (ctrl->id) { case V4L2_CID_VBLANK: /* Update max exposure while meeting expected vblanking */ - max = gc2385->cur_mode->height + ctrl->val + 32 - 4; + max = gc2385->cur_mode->height + ctrl->val - 4; __v4l2_ctrl_modify_range(gc2385->exposure, gc2385->exposure->minimum, max, gc2385->exposure->step, @@ -902,10 +900,10 @@ static int gc2385_set_ctrl(struct v4l2_ctrl *ctrl) GC2385_SET_PAGE_ONE); ret |= gc2385_write_reg(gc2385->client, GC2385_REG_VTS_H, - (ctrl->val >> 8) & 0xff); + ((ctrl->val - 32) >> 8) & 0xff); ret |= gc2385_write_reg(gc2385->client, GC2385_REG_VTS_L, - ctrl->val & 0xff); + (ctrl->val - 32) & 0xff); break; default: dev_warn(&client->dev, "%s Unhandled id:0x%x, val:0x%x\n", diff --git a/drivers/media/i2c/gc5025.c b/drivers/media/i2c/gc5025.c index 4142ecdaa57a..667071d63d68 100644 --- a/drivers/media/i2c/gc5025.c +++ b/drivers/media/i2c/gc5025.c @@ -336,7 +336,7 @@ static const struct gc5025_mode supported_modes[] = { .denominator = 300000, }, .exp_def = 0x07C0, - .hts_def = 0x04B0, + .hts_def = 0x12C0, .vts_def = 0x07D0, .reg_list = gc5025_1600x1200_regs, }, @@ -465,10 +465,10 @@ static int gc5025_set_fmt(struct v4l2_subdev *sd, #endif } else { gc5025->cur_mode = mode; - h_blank = mode->hts_def / 2; + h_blank = mode->hts_def - mode->width; __v4l2_ctrl_modify_range(gc5025->hblank, h_blank, h_blank, 1, h_blank); - vblank_def = mode->vts_def - mode->height - 24; + vblank_def = mode->vts_def - mode->height; __v4l2_ctrl_modify_range(gc5025->vblank, vblank_def, GC5025_VTS_MAX - mode->height, 1, vblank_def); @@ -1527,7 +1527,7 @@ static int gc5025_set_ctrl(struct v4l2_ctrl *ctrl) switch (ctrl->id) { case V4L2_CID_VBLANK: /* Update max exposure while meeting expected vblanking */ - max = gc5025->cur_mode->height + ctrl->val + 32 - 4; + max = gc5025->cur_mode->height + ctrl->val - 4; __v4l2_ctrl_modify_range(gc5025->exposure, gc5025->exposure->minimum, max, gc5025->exposure->step, @@ -1552,10 +1552,10 @@ static int gc5025_set_ctrl(struct v4l2_ctrl *ctrl) GC5025_SET_PAGE_ONE); ret |= gc5025_write_reg(gc5025->client, GC5025_REG_VTS_H, - (ctrl->val >> 8) & 0xff); + ((ctrl->val - 24) >> 8) & 0xff); ret |= gc5025_write_reg(gc5025->client, GC5025_REG_VTS_L, - ctrl->val & 0xff); + (ctrl->val - 24) & 0xff); break; default: dev_warn(&client->dev, "%s Unhandled id:0x%x, val:0x%x\n", diff --git a/drivers/media/i2c/gc8034.c b/drivers/media/i2c/gc8034.c index db7921087312..570ce6efa01c 100644 --- a/drivers/media/i2c/gc8034.c +++ b/drivers/media/i2c/gc8034.c @@ -33,7 +33,7 @@ #define GC8034_BITS_PER_SAMPLE 10 #define GC8034_LINK_FREQ_MHZ 336000000 /* pixel rate = link frequency * 2 * lanes / BITS_PER_SAMPLE */ -#define GC8034_PIXEL_RATE 80000000//268800000 +#define GC8034_PIXEL_RATE 80000000 #define GC8034_XVCLK_FREQ 24000000 #define CHIP_ID 0x8044 @@ -446,10 +446,10 @@ static const struct gc8034_mode supported_modes[] = { .height = 2448, .max_fps = { .numerator = 10000, - .denominator = 300000, + .denominator = 299625, }, .exp_def = 0x08c6, - .hts_def = 0x042c, + .hts_def = 0x10b0, .vts_def = 0x09c4, .reg_list = gc8034_3264x2448_regs, }, @@ -578,10 +578,10 @@ static int gc8034_set_fmt(struct v4l2_subdev *sd, #endif } else { gc8034->cur_mode = mode; - h_blank = mode->hts_def / 2; + h_blank = mode->hts_def - mode->width; __v4l2_ctrl_modify_range(gc8034->hblank, h_blank, h_blank, 1, h_blank); - vblank_def = mode->vts_def - mode->height - 36; + vblank_def = mode->vts_def - mode->height; __v4l2_ctrl_modify_range(gc8034->vblank, vblank_def, GC8034_VTS_MAX - mode->height, 1, vblank_def); @@ -1784,7 +1784,7 @@ static int gc8034_set_ctrl(struct v4l2_ctrl *ctrl) switch (ctrl->id) { case V4L2_CID_VBLANK: /* Update max exposure while meeting expected vblanking */ - max = gc8034->cur_mode->height + ctrl->val + 36 - 4; + max = gc8034->cur_mode->height + ctrl->val - 4; __v4l2_ctrl_modify_range(gc8034->exposure, gc8034->exposure->minimum, max, gc8034->exposure->step, @@ -1809,10 +1809,10 @@ static int gc8034_set_ctrl(struct v4l2_ctrl *ctrl) GC8034_SET_PAGE_ZERO); ret |= gc8034_write_reg(gc8034->client, GC8034_REG_VTS_H, - (ctrl->val >> 8) & 0xff); + ((ctrl->val - 36) >> 8) & 0xff); ret |= gc8034_write_reg(gc8034->client, GC8034_REG_VTS_L, - ctrl->val & 0xff); + (ctrl->val - 36) & 0xff); break; default: dev_warn(&client->dev, "%s Unhandled id:0x%x, val:0x%x\n",