]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: imx258: Limit the max analogue gain to 480
authorUmang Jain <umang.jain@ideasonboard.com>
Fri, 23 Jul 2021 11:22:33 +0000 (13:22 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Wed, 4 Aug 2021 12:43:51 +0000 (14:43 +0200)
The range for analog gain mentioned in the datasheet is [0, 480].
The real gain formula mentioned in the datasheet is:

Gain = 512 / (512 – X)

Hence, values larger than 511 clearly makes no sense. The gain
register field is also documented to be of 9-bits in the datasheet.

Certainly, it is enough to infer that, the kernel driver currently
advertises an arbitrary analog gain max. Fix it by rectifying the
value as per the data sheet i.e. 480.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/i2c/imx258.c

index 4e695096e5d0585f3bd38bf46e47ab1be11ccd72..81cdf37216ca7e48f0070873e1fb62bf5be143dc 100644 (file)
@@ -47,7 +47,7 @@
 /* Analog gain control */
 #define IMX258_REG_ANALOG_GAIN         0x0204
 #define IMX258_ANA_GAIN_MIN            0
-#define IMX258_ANA_GAIN_MAX            0x1fff
+#define IMX258_ANA_GAIN_MAX            480
 #define IMX258_ANA_GAIN_STEP           1
 #define IMX258_ANA_GAIN_DEFAULT                0x0