diff options
author | Eugen Hristev <eugen.hristev@microchip.com> | 2021-12-13 14:49:36 +0100 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@kernel.org> | 2022-01-23 21:18:44 +0100 |
commit | 3f050110617de71c6bc65867fc56bdb30ee07f38 (patch) | |
tree | 569cff4a521113d902b44a3e8873d140b6ea0211 /drivers/media/platform/atmel | |
parent | media: atmel: atmel-isc-base: add wb debug messages (diff) | |
download | linux-3f050110617de71c6bc65867fc56bdb30ee07f38.tar.xz linux-3f050110617de71c6bc65867fc56bdb30ee07f38.zip |
media: atmel: atmel-isc-base: clamp wb gain coefficients
White balance computed gains can overflow above the 13 bits hardware
coefficient that can be used, in some specific scenarios like a subexposure
from the sensor when the image is mostly black.
In this case the computed gain has to be clamped to the maximum value
allowed by the hardware.
Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
Reviewed-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Diffstat (limited to 'drivers/media/platform/atmel')
-rw-r--r-- | drivers/media/platform/atmel/atmel-isc-base.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/media/platform/atmel/atmel-isc-base.c b/drivers/media/platform/atmel/atmel-isc-base.c index d92ffc07418f..db15770d5b88 100644 --- a/drivers/media/platform/atmel/atmel-isc-base.c +++ b/drivers/media/platform/atmel/atmel-isc-base.c @@ -1375,6 +1375,10 @@ static void isc_wb_update(struct isc_ctrls *ctrls) /* multiply both gains and adjust for decimals */ ctrls->gain[c] = s_gain[c] * gw_gain[c]; ctrls->gain[c] >>= 9; + + /* make sure we are not out of range */ + ctrls->gain[c] = clamp_val(ctrls->gain[c], 0, GENMASK(12, 0)); + v4l2_dbg(1, debug, &isc->v4l2_dev, "isc wb: component %d, final gain %u\n", c, ctrls->gain[c]); |