diff options
author | Rui Miguel Silva <rui.silva@linaro.org> | 2018-02-20 23:32:11 +0000 |
---|---|---|
committer | Bryan O'Donoghue <bryan.odonoghue@linaro.org> | 2019-05-01 11:51:25 +0100 |
commit | 0f6dc7cfe9b2a2f4c928e6678aede33e4643fd02 (patch) | |
tree | d3ac6ad6ca120bf2612f2f13a9b1df29a71fb826 | |
parent | e6ba99c4bb3706c4f1269ed8d3e28cfb82bb39e9 (diff) |
media: ov2680: fix exposure set and get in registers
Register writing and reading fix to handle the high, middle and low part
correctly as in datasheet register split.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
-rw-r--r-- | drivers/media/i2c/ov2680.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/drivers/media/i2c/ov2680.c b/drivers/media/i2c/ov2680.c index 2d64f1bdd4de..fd2fda2eaf8e 100644 --- a/drivers/media/i2c/ov2680.c +++ b/drivers/media/i2c/ov2680.c @@ -465,18 +465,17 @@ static int ov2680_exposure_set(struct ov2680_dev *sensor, bool auto_exp) exp = (u32)ctrls->exposure->val; exp <<= 4; - ret = ov2680_write_reg(sensor, OV2680_REG_EXPOSURE_PK_LOW, - (exp << 4) & 0xf0); + ret = ov2680_write_reg(sensor, OV2680_REG_EXPOSURE_PK_LOW, exp & 0xf0); if (ret) return ret; ret = ov2680_write_reg(sensor, OV2680_REG_EXPOSURE_PK_MED, - (exp >> 4) & 0xff); + (exp >> 8) & 0xff); if (ret) return ret; return ov2680_write_reg(sensor, OV2680_REG_EXPOSURE_PK_HIGH, - (exp >> 12) & 0x0f); + (exp >> 16) & 0x0f); } static int ov2680_exposure_get(struct ov2680_dev *sensor) @@ -487,19 +486,19 @@ static int ov2680_exposure_get(struct ov2680_dev *sensor) ret = ov2680_read_reg(sensor, OV2680_REG_EXPOSURE_PK_HIGH, &temp); if (ret) return ret; - exp = ((int)temp & 0x0f) << 12; + exp = ((int)temp & 0x0f) << 16; ret = ov2680_read_reg(sensor, OV2680_REG_EXPOSURE_PK_MED, &temp); if (ret) return ret; - exp |= ((int)temp << 4); + exp |= ((int)temp & 0xff) << 8; ret = ov2680_read_reg(sensor, OV2680_REG_EXPOSURE_PK_LOW, &temp); if (ret) return ret; - exp |= ((int)temp & 0xf0) >> 4; + exp |= ((int)temp & 0xf0); - return exp; + return exp >> 4; } static int ov2680_auto_exposure_enable(struct ov2680_dev *sensor) |