Skip to content

Commit a3c31a5

Browse files
trunghieulenxpkartben
authored andcommitted
drivers: video: ov5640: Fix brightness control register
Fix the sign register for brightness control Signed-off-by: Trung Hieu Le <trunghieu.le@nxp.com> Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
1 parent cc5f550 commit a3c31a5

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

drivers/video/ov5640.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,15 +1021,18 @@ static int ov5640_set_ctrl_brightness(const struct device *dev, int value)
10211021
{
10221022
const struct ov5640_config *cfg = dev->config;
10231023

1024-
struct ov5640_reg brightness_params[] = {{SDE_CTRL8_REG, value >= 0 ? 0x01 : 0x09},
1025-
{SDE_CTRL7_REG, abs(value) & 0xff}};
10261024
int ret = ov5640_modify_reg(&cfg->i2c, SDE_CTRL0_REG, BIT(2), BIT(2));
10271025

10281026
if (ret) {
10291027
return ret;
10301028
}
10311029

1032-
return ov5640_write_multi_regs(&cfg->i2c, brightness_params, ARRAY_SIZE(brightness_params));
1030+
ret = ov5640_modify_reg(&cfg->i2c, SDE_CTRL8_REG, BIT(3), value >= 0 ? 0 : BIT(3));
1031+
if (ret < 0) {
1032+
return ret;
1033+
}
1034+
1035+
return ov5640_write_reg(&cfg->i2c, SDE_CTRL7_REG, (abs(value) << 4) & 0xf0);
10331036
}
10341037

10351038
static int ov5640_set_ctrl_contrast(const struct device *dev, int value)

0 commit comments

Comments
 (0)