From 19c55f55266e35257a98c5bc64a6ca77e3ea46e4 Mon Sep 17 00:00:00 2001 From: Zefa Chen Date: Tue, 13 Jul 2021 09:50:57 +0800 Subject: [PATCH] media: i2c: gc02m2 fixes the base value of digital gain to avoid purple in the light Signed-off-by: Zefa Chen Change-Id: I524ba475291fd6d0e154b9276e099f81c1fae301 --- drivers/media/i2c/gc02m2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/gc02m2.c b/drivers/media/i2c/gc02m2.c index 6187c3bd2c84..01d02dd55788 100644 --- a/drivers/media/i2c/gc02m2.c +++ b/drivers/media/i2c/gc02m2.c @@ -1046,6 +1046,7 @@ static const struct v4l2_subdev_ops gc02m2_subdev_ops = { .pad = &gc02m2_pad_ops, }; +#define DIGITAL_GAIN_BASE 1024 static int gc02m2_set_gain_reg(struct gc02m2 *gc02m2, u32 total_gain) { struct device *dev = &gc02m2->client->dev; @@ -1065,7 +1066,7 @@ static int gc02m2_set_gain_reg(struct gc02m2 *gc02m2, u32 total_gain) GC02M2_PAGE_SELECT, 0x00); ret |= gc02m2_write_reg(gc02m2->client, GC02M2_ANALOG_GAIN_REG, GC02M2_AGC_Param[i][1]); - dgain = total_gain * 256 / GC02M2_AGC_Param[i][0]; + dgain = total_gain * DIGITAL_GAIN_BASE / GC02M2_AGC_Param[i][0]; dev_dbg(dev, "AGC_Param[%d][0] = %d dgain = 0x%04x!\n", i, GC02M2_AGC_Param[i][0], dgain);