* [PATCH 0/3] media: i2c: ov08d10: fix some controls
@ 2026-12-02 8:39 Matthias Fend
2026-12-02 8:40 ` [PATCH 1/3] media: i2c: ov08d10: fix exposure Matthias Fend
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Matthias Fend @ 2026-12-02 8:39 UTC (permalink / raw)
To: Sakari Ailus, Jimmy Su, Mauro Carvalho Chehab
Cc: linux-media, linux-kernel, Matthias Fend
Some fixes and adjustments for the OV08D10 sensor controls. The
calculations used wrong formulas and constants, but happened to produce
quite suitable results for some (standard) operating modes. This was
probably also the reason why the issues remained undiscovered until now.
The necessary information was primarily taken from the datasheet. Some
details were obtained by reading back status registers (especially
HTS/VTS) and by systematic measurements.
Signed-off-by: Matthias Fend <matthias.fend@emfend.at>
---
Matthias Fend (3):
media: i2c: ov08d10: fix exposure
media: i2c: ov08d10: fix vertical blanking
media: i2c: ov08d10: fix analogue gain step
drivers/media/i2c/ov08d10.c | 37 +++++++++++++++----------------------
1 file changed, 15 insertions(+), 22 deletions(-)
---
base-commit: 50d38f9c1359c0bd13963cc6bc09f4323ee212a2
change-id: 20261201-ov08d10-ctrl-fixes-0c36957718d2
Best regards,
--
Matthias Fend <matthias.fend@emfend.at>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/3] media: i2c: ov08d10: fix exposure
2026-12-02 8:39 [PATCH 0/3] media: i2c: ov08d10: fix some controls Matthias Fend
@ 2026-12-02 8:40 ` Matthias Fend
2026-12-02 8:40 ` [PATCH 2/3] media: i2c: ov08d10: fix vertical blanking Matthias Fend
2026-12-02 8:40 ` [PATCH 3/3] media: i2c: ov08d10: fix analogue gain step Matthias Fend
2 siblings, 0 replies; 4+ messages in thread
From: Matthias Fend @ 2026-12-02 8:40 UTC (permalink / raw)
To: Sakari Ailus, Jimmy Su, Mauro Carvalho Chehab
Cc: linux-media, linux-kernel, Matthias Fend
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@emfend.at>
---
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/3] media: i2c: ov08d10: fix vertical blanking
2026-12-02 8:39 [PATCH 0/3] media: i2c: ov08d10: fix some controls Matthias Fend
2026-12-02 8:40 ` [PATCH 1/3] media: i2c: ov08d10: fix exposure Matthias Fend
@ 2026-12-02 8:40 ` Matthias Fend
2026-12-02 8:40 ` [PATCH 3/3] media: i2c: ov08d10: fix analogue gain step Matthias Fend
2 siblings, 0 replies; 4+ messages in thread
From: Matthias Fend @ 2026-12-02 8:40 UTC (permalink / raw)
To: Sakari Ailus, Jimmy Su, Mauro Carvalho Chehab
Cc: linux-media, linux-kernel, Matthias Fend
Previously, the vblank value was written unchanged to the dummy line
registers. But according to the datasheet, these registers are in units of
half lines and are added to the minimum VTS of the mode. Measurements and
register readouts show that the sensor applies them in steps of 4 lines
only.
As a result, the frame rates were wrong. For example, a frame duration of
33333 us resulted in 30.38 fps at 3280x2460, and the default VTS of 3736
lines in the 1632x1224 mode resulted in 30.03 fps instead of 20.16 fps.
As vts_min was equal to vts_def, the 1632x1224 mode was also limited to
30 fps instead of 60 fps.
Set vts_min to the actual minimum VTS of each mode, set the dummy line
registers correctly and set the VBLANK step to 4, to which OV08D10_VTS_MAX
is aligned as well. Set the default VTS of the 1632x1224 mode to 2508,
which keeps its previous default frame rate of ~30 fps.
Fixes: 7be91e02ed57 ("media: i2c: Add ov08d10 camera sensor driver")
Signed-off-by: Matthias Fend <matthias.fend@emfend.at>
---
drivers/media/i2c/ov08d10.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/drivers/media/i2c/ov08d10.c b/drivers/media/i2c/ov08d10.c
index 22eee655b52628f162810c1b38607b6b25e7f0e6..4a6ec91d0b9f60501882a4458ca15d3ef90df996 100644
--- a/drivers/media/i2c/ov08d10.c
+++ b/drivers/media/i2c/ov08d10.c
@@ -31,7 +31,8 @@
/* vertical-timings from sensor */
#define OV08D10_REG_VTS_H 0x05
#define OV08D10_REG_VTS_L 0x06
-#define OV08D10_VTS_MAX 0x7fff
+#define OV08D10_VTS_MAX 0x7ffc
+#define OV08D10_VBLANK_STEP 4
/* Exposure controls from sensor */
#define OV08D10_REG_EXPOSURE_H 0x02
@@ -654,8 +655,8 @@ static const struct ov08d10_lane_cfg lane_cfg_2 = {
.width = 1632,
.height = 1224,
.hts = 1912,
- .vts_def = 3736,
- .vts_min = 3736,
+ .vts_def = 2508,
+ .vts_min = 1252,
.reg_list = {
.num_of_regs = ARRAY_SIZE(lane_2_mode_1632x1224),
.regs = lane_2_mode_1632x1224,
@@ -827,9 +828,12 @@ static int ov08d10_set_exposure(struct ov08d10 *ov08d10, u32 exposure)
static int ov08d10_set_vblank(struct ov08d10 *ov08d10, u32 vblank)
{
struct i2c_client *client = v4l2_get_subdevdata(&ov08d10->sd);
+ const struct ov08d10_mode *mode = ov08d10_get_mode(ov08d10);
u8 val;
int ret;
+ vblank = (mode->height + vblank - mode->vts_min) * 2;
+
/* CIS control registers */
ret = i2c_smbus_write_byte_data(client, OV08D10_REG_PAGE, 0x01);
if (ret < 0)
@@ -1016,8 +1020,8 @@ static int ov08d10_init_controls(struct ov08d10 *ov08d10)
ov08d10->vblank =
v4l2_ctrl_new_std(ctrl_hdlr, &ov08d10_ctrl_ops,
V4L2_CID_VBLANK, vblank_min,
- OV08D10_VTS_MAX - mode->height, 1,
- vblank_def);
+ OV08D10_VTS_MAX - mode->height,
+ OV08D10_VBLANK_STEP, vblank_def);
h_blank = to_pixels_per_line(ov08d10->priv_lane->link_freq_menu,
mode->hts, mode->link_freq_index,
@@ -1225,8 +1229,8 @@ static int ov08d10_set_format(struct v4l2_subdev *sd,
vblank_def = mode->vts_def - mode->height;
__v4l2_ctrl_modify_range(ov08d10->vblank,
mode->vts_min - mode->height,
- OV08D10_VTS_MAX - mode->height, 1,
- vblank_def);
+ OV08D10_VTS_MAX - mode->height,
+ OV08D10_VBLANK_STEP, vblank_def);
__v4l2_ctrl_s_ctrl(ov08d10->vblank, vblank_def);
h_blank = to_pixels_per_line(ov08d10->priv_lane->link_freq_menu,
mode->hts,
--
2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 3/3] media: i2c: ov08d10: fix analogue gain step
2026-12-02 8:39 [PATCH 0/3] media: i2c: ov08d10: fix some controls Matthias Fend
2026-12-02 8:40 ` [PATCH 1/3] media: i2c: ov08d10: fix exposure Matthias Fend
2026-12-02 8:40 ` [PATCH 2/3] media: i2c: ov08d10: fix vertical blanking Matthias Fend
@ 2026-12-02 8:40 ` Matthias Fend
2 siblings, 0 replies; 4+ messages in thread
From: Matthias Fend @ 2026-12-02 8:40 UTC (permalink / raw)
To: Sakari Ailus, Jimmy Su, Mauro Carvalho Chehab
Cc: linux-media, linux-kernel, Matthias Fend
The gain value is down-shifted by 3 when written to the gain register, so
the effective granularity is 8. Respect this by reporting a step size of 8
instead of 1 and adjust the maximum value accordingly.
Fixes: 7be91e02ed57 ("media: i2c: Add ov08d10 camera sensor driver")
Signed-off-by: Matthias Fend <matthias.fend@emfend.at>
---
drivers/media/i2c/ov08d10.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/media/i2c/ov08d10.c b/drivers/media/i2c/ov08d10.c
index 4a6ec91d0b9f60501882a4458ca15d3ef90df996..d2213719909ad0c660bf9de8cbaf122958d56e61 100644
--- a/drivers/media/i2c/ov08d10.c
+++ b/drivers/media/i2c/ov08d10.c
@@ -45,8 +45,8 @@
/* Analog gain controls from sensor */
#define OV08D10_REG_ANALOG_GAIN 0x24
#define OV08D10_ANAL_GAIN_MIN 128
-#define OV08D10_ANAL_GAIN_MAX 2047
-#define OV08D10_ANAL_GAIN_STEP 1
+#define OV08D10_ANAL_GAIN_MAX 2040
+#define OV08D10_ANAL_GAIN_STEP 8
/* Digital gain controls from sensor */
#define OV08D10_REG_MWB_DGAIN_C 0x21
--
2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-12-02 8:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-02 8:39 [PATCH 0/3] media: i2c: ov08d10: fix some controls Matthias Fend
2026-12-02 8:40 ` [PATCH 1/3] media: i2c: ov08d10: fix exposure Matthias Fend
2026-12-02 8:40 ` [PATCH 2/3] media: i2c: ov08d10: fix vertical blanking Matthias Fend
2026-12-02 8:40 ` [PATCH 3/3] media: i2c: ov08d10: fix analogue gain step Matthias Fend
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®