]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 18 Sep 2021 11:42:07 +0000 (13:42 +0200)
commitb28a4a67ae434b157425745315c8f87b4f86b8ce
tree2c913284f51751e6b77ef5c90f0376ca5e5bad16
parentdb1e9875b7d9b68f1cdba8b5531c305d815e27d4
media: imx258: Limit the max analogue gain to 480

[ Upstream commit f809665ee75fff3f4ea8907f406a66d380aeb184 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/media/i2c/imx258.c