Skip to content

Commit 67709b4

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 029eb74 commit 67709b4

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
@@ -1025,15 +1025,18 @@ static int ov5640_set_ctrl_brightness(const struct device *dev, int value)
10251025
{
10261026
const struct ov5640_config *cfg = dev->config;
10271027

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

10321030
if (ret) {
10331031
return ret;
10341032
}
10351033

1036-
return ov5640_write_multi_regs(&cfg->i2c, brightness_params, ARRAY_SIZE(brightness_params));
1034+
ret = ov5640_modify_reg(&cfg->i2c, SDE_CTRL8_REG, BIT(3), value >= 0 ? 0 : BIT(3));
1035+
if (ret) {
1036+
return ret;
1037+
}
1038+
1039+
return ov5640_write_reg(&cfg->i2c, SDE_CTRL7_REG, (abs(value) << 4) & 0xf0);
10371040
}
10381041

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

0 commit comments

Comments
 (0)