[PATCH v2 15/15] media: i2c: os05b10: fix negative hblank calculation
From: Tarang Raval
Date: Wed Mar 25 2026 - 08:01:33 EST
Using HTS directly in the hblank calculation results in a negative
value, such as 2592x1944 with HTS set to 1744.
Scale HTS by 2 before subtracting the active width so that hblank is
derived correctly.
The datasheet describes 0x380c/0x380d as HTS, but does not document the
exact unit used for this value.
Signed-off-by: Tarang Raval <tarang.raval@xxxxxxxxxxxxxxxxx>
---
drivers/media/i2c/os05b10.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/media/i2c/os05b10.c b/drivers/media/i2c/os05b10.c
index bdfd203bf672..8acb4d76c90f 100644
--- a/drivers/media/i2c/os05b10.c
+++ b/drivers/media/i2c/os05b10.c
@@ -877,7 +877,16 @@ static int os05b10_set_framing_limits(struct os05b10 *os05b10,
if (ret)
return ret;
- hblank = mode->hts - mode->width;
+ /*
+ * Using HTS directly results in a negative hblank.
+ * (e.g. 2592x1944 with HTS = 1744). Doubling HTS produces a valid
+ * horizontal blanking value.
+ *
+ * The datasheet defines HTS (0x380c/0x380d) as total horizontal
+ * timing size, but does not specify the unit (whether it is
+ * in pixel clocks or requires scaling).
+ */
+ hblank = mode->hts * 2 - mode->width;
ret = __v4l2_ctrl_modify_range(os05b10->hblank, hblank, hblank, 1,
hblank);
if (ret)
--
2.34.1