Skip to content

Commit 61eb9ab

Browse files
trunghieulenxpngphibang
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 562891a commit 61eb9ab

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
@@ -971,15 +971,18 @@ static int ov5640_set_ctrl_brightness(const struct device *dev, int value)
971971
return -EINVAL;
972972
}
973973

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

978976
if (ret) {
979977
return ret;
980978
}
981979

982-
return ov5640_write_multi_regs(&cfg->i2c, brightness_params, ARRAY_SIZE(brightness_params));
980+
ret = ov5640_modify_reg(&cfg->i2c, SDE_CTRL8_REG, BIT(3), value >= 0 ? 0 : BIT(3));
981+
if (ret) {
982+
return ret;
983+
}
984+
985+
return ov5640_write_reg(&cfg->i2c, SDE_CTRL7_REG, (abs(value) << 4) & 0xf0);
983986
}
984987

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

0 commit comments

Comments
 (0)