From 68b2c69d10522439ac5dddf845eb09028dc49783 Mon Sep 17 00:00:00 2001 From: Daniel Scally Date: Tue, 21 Jul 2026 23:07:51 +0100 Subject: [PATCH] media: i2c: Expand gain values for ov5693 The ov5693 driver currently allows values for the V4L2_CID_ANALOGUE_GAIN control in the range 1-127. The input values are left-shifted 4 bits before being applied to the hardware. The 4 least significant bits are fractional bits, which means that in practice gain can only be applied in steps of 1.0. Update the allowed range to take any value that fits into the 11-bit register and stop masking off the fractional bits. Signed-off-by: Daniel Scally --- drivers/media/i2c/ov5693.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/media/i2c/ov5693.c b/drivers/media/i2c/ov5693.c index 02236f3db19dc..d90f135bc55f4 100644 --- a/drivers/media/i2c/ov5693.c +++ b/drivers/media/i2c/ov5693.c @@ -48,10 +48,10 @@ /* Analogue Gain */ #define OV5693_GAIN_CTRL_REG CCI_REG16(0x350a) -#define OV5693_GAIN_CTRL_MASK GENMASK(10, 4) +#define OV5693_GAIN_CTRL_MASK GENMASK(10, 0) #define OV5693_GAIN_MIN 1 -#define OV5693_GAIN_MAX 127 -#define OV5693_GAIN_DEF 8 +#define OV5693_GAIN_MAX 2047 +#define OV5693_GAIN_DEF 16 #define OV5693_GAIN_STEP 1 /* Digital Gain */ @@ -444,7 +444,7 @@ static int ov5693_analog_gain_configure(struct ov5693_device *ov5693, u32 gain) { int ret = 0; - gain = (gain << 4) & OV5693_GAIN_CTRL_MASK; + gain &= OV5693_GAIN_CTRL_MASK; cci_write(ov5693->regmap, OV5693_GAIN_CTRL_REG, gain, &ret);