[PATCH 1/3] media: i2c: ov08d10: fix exposure

From: Matthias Fend

Date: Wed Dec 02 2026 - 03:40:27 EST


According to the datasheet, the exposure register is simply in units of
half lines. The previous, more complex calculation was only approximately
correct in the full resolution modes (+3.4%) and far off in the binning
mode (-33%).

Furthermore, the sensor prolongs the frame if the exposure reaches or
exceeds VTS - 20 lines, so the previous margin of 6 lines allowed exposures
that lowered the frame rate.

Write 2 * exposure to the register and set the margin to 20 + 1 lines.

Fixes: 7be91e02ed57 ("media: i2c: Add ov08d10 camera sensor driver")
Signed-off-by: Matthias Fend <matthias.fend@xxxxxxxxx>
---
drivers/media/i2c/ov08d10.c | 15 ++-------------
1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/drivers/media/i2c/ov08d10.c b/drivers/media/i2c/ov08d10.c
index a83317da3d92dcb9693053cc6824bf43fd22308c..22eee655b52628f162810c1b38607b6b25e7f0e6 100644
--- a/drivers/media/i2c/ov08d10.c
+++ b/drivers/media/i2c/ov08d10.c
@@ -14,7 +14,6 @@
#include <media/v4l2-fwnode.h>

#define OV08D10_SCLK 144000000ULL
-#define OV08D10_ROWCLK 36000
#define OV08D10_DATA_LANES 2
#define OV08D10_RGB_DEPTH 10

@@ -39,7 +38,7 @@
#define OV08D10_REG_EXPOSURE_M 0x03
#define OV08D10_REG_EXPOSURE_L 0x04
#define OV08D10_EXPOSURE_MIN 6
-#define OV08D10_EXPOSURE_MAX_MARGIN 6
+#define OV08D10_EXPOSURE_MAX_MARGIN (20 + 1)
#define OV08D10_EXPOSURE_STEP 1

/* Analog gain controls from sensor */
@@ -796,20 +795,10 @@ static int ov08d10_set_exposure(struct ov08d10 *ov08d10, u32 exposure)
{
struct i2c_client *client = v4l2_get_subdevdata(&ov08d10->sd);
u8 val;
- u8 hts_h, hts_l;
- u32 hts, cur_vts, exp_cal;
int ret;

- cur_vts = ov08d10_get_mode(ov08d10)->vts_def;
- ret = i2c_smbus_write_byte_data(client, OV08D10_REG_PAGE, 0x01);
- if (ret < 0)
- return ret;
+ exposure *= 2;

- hts_h = i2c_smbus_read_byte_data(client, 0x37);
- hts_l = i2c_smbus_read_byte_data(client, 0x38);
- hts = ((hts_h << 8) | (hts_l));
- exp_cal = 66 * OV08D10_ROWCLK / hts;
- exposure = exposure * exp_cal / (cur_vts - OV08D10_EXPOSURE_MAX_MARGIN);
/* CIS control registers */
ret = i2c_smbus_write_byte_data(client, OV08D10_REG_PAGE, 0x01);
if (ret < 0)

--
2.34.1