diff --git a/drivers/media/i2c/imx335.c b/drivers/media/i2c/imx335.c index 1888622c436e..0d7513fbf34c 100644 --- a/drivers/media/i2c/imx335.c +++ b/drivers/media/i2c/imx335.c @@ -8,6 +8,7 @@ * V0.0X01.0X01 support 10bit DOL3 * V0.0X01.0X02 fix set sensor vertical invert failed * V0.0X01.0X03 add hdr_mode in enum frame interval + * V0.0X01.0X04 fix hdr ae error */ #define DEBUG @@ -30,7 +31,7 @@ #include #include -#define DRIVER_VERSION KERNEL_VERSION(0, 0x01, 0x03) +#define DRIVER_VERSION KERNEL_VERSION(0, 0x01, 0x04) #ifndef V4L2_CID_DIGITAL_GAIN #define V4L2_CID_DIGITAL_GAIN V4L2_CID_GAIN @@ -856,7 +857,7 @@ static int imx335_set_hdrae(struct imx335 *imx335, struct i2c_client *client = imx335->client; u32 l_exp_time, m_exp_time, s_exp_time; u32 l_a_gain, m_a_gain, s_a_gain; - u32 shr1, shr0, rhs1, rhs1_max, rhs1_min; + int shr1, shr0, rhs1, rhs1_max, rhs1_min; static int rhs1_old = IMX335_RHS1_DEFAULT; int ret = 0; u32 fsc; @@ -921,12 +922,19 @@ static int imx335_set_hdrae(struct imx335 *imx335, shr0 = fsc - l_exp_time; rhs1_max = min(RHS1_MAX, shr0 - SHR1_MIN); - rhs1_min = max(SHR1_MIN + 4u, rhs1_old + 2 * BRL - fsc + 2); - rhs1 = clamp(SHR1_MIN + s_exp_time, rhs1_min, rhs1_max); + rhs1_max = (rhs1_max & ~0x7) + 2; + rhs1_min = (SHR1_MIN + 4u + 7u) / 8 * 8 + 2; + + rhs1 = SHR1_MIN + s_exp_time; rhs1 = (rhs1 & ~0x7) + 2; /* shall be 8n + 2 */ + if (rhs1 > rhs1_max) + rhs1 = rhs1_max; + if (rhs1 < rhs1_min) + rhs1 = rhs1_min; + dev_dbg(&client->dev, - "line(%d) rhs1 %d, short time %d rhs1_old %d, rhs1_new %d\n", - __LINE__, rhs1, s_exp_time, rhs1_old, rhs1); + "line(%d) rhs1 %d, short time %d rhs1_old %d, rhs1_new %d, rhs1_min %d rhs1_max %d\n", + __LINE__, rhs1, s_exp_time, rhs1_old, rhs1, rhs1_min, rhs1_max); rhs1_old = rhs1;