From: Richard Leitner Date: Mon, 16 Nov 2026 14:50:27 +0100 Subject: [PATCH v4 6/8] media: i2c: ov9282: recalculate strobe span on HBLANK change MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261116-ov9282-fixes-v4-6-f78e5d415c6f@linux.dev> References: <20261116-ov9282-fixes-v4-0-f78e5d415c6f@linux.dev> In-Reply-To: <20261116-ov9282-fixes-v4-0-f78e5d415c6f@linux.dev> To: Sakari Ailus , Dave Stevenson , Mauro Carvalho Chehab , Daniele Alessandrelli , "Paul J. Murphy" , Martina Krasteva , Richard Leitner , Hans Verkuil , Bryan O'Donoghue , Jacopo Mondi Cc: Mauro Carvalho Chehab , Gyula Kelemen , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1794837042; l=2105; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=/l5WuxKbk3bXJ+Xikq+YkzOd91d/fG0BrABoO/lILgA=; b=Cy4yJ7dROacvOoCnvd5M+6Mxr8Pl2KmVoLxOli8WAMGqyQRBEtkIL7sIGPr05UPMz/I5K/bxZ VPM/kIq7MAPB7FNZf2PR8VcgZWRFC3Fw0HgOfsGL6JR/HRZ0UqtfPsN X-Developer-Key: i=richard.leitner@linux.dev; a=ed25519; pk=8hZNyyyQFqZ5ruVJsSGBSPIrmJpfDm5HwHU4QVOP1Pk= X-Endpoint-Received: by B4 Relay for richard.leitner@linux.dev/20250225 with auth_id=350 List-Id: B4 Relay Submissions When HBLANK changes the line time changes. This means the time base for the strobe duration calculation changed. This results in the v4l2 strobe_duration control value and the strobe_span register value being out of sync. Fix this by recalculating the strobe_span register value on HBLANK writes using the currently configured strobe_duration. This results in the strobe_duration configured by userspace being kept, but the underlying register value being changed. To ensure the values are applied on the same frame guard the writes with OV9282_REG_HOLD. Fixes: 84ec7597ae1af ("media: i2c: ov9282: add strobe_duration v4l2 control") Cc: stable@vger.kernel.org Reviewed-by: Dave Stevenson Signed-off-by: Richard Leitner --- drivers/media/i2c/ov9282.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index d13a1adc35e85..d18fee6730990 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -625,6 +625,7 @@ static int ov9282_set_ctrl(struct v4l2_ctrl *ctrl) u32 exposure; u32 lpfr; int ret; + int ret_hold; switch (ctrl->id) { case V4L2_CID_VBLANK: @@ -677,8 +678,14 @@ static int ov9282_set_ctrl(struct v4l2_ctrl *ctrl) OV9282_FLIP_BIT, ctrl->val ? OV9282_FLIP_BIT : 0, NULL); break; case V4L2_CID_HBLANK: - ret = cci_write(ov9282->regmap, OV9282_REG_TIMING_HTS, - (ctrl->val + ov9282->cur_mode->width) >> 1, NULL); + ret = cci_write(ov9282->regmap, OV9282_REG_HOLD, 0x01, NULL); + cci_write(ov9282->regmap, OV9282_REG_TIMING_HTS, + (ctrl->val + ov9282->cur_mode->width) >> 1, &ret); + cci_write(ov9282->regmap, OV9282_REG_STROBE_FRAME_SPAN, + ov9282_us_to_lines(ov9282, ov9282->flash_duration->cur.val), + &ret); + ret_hold = cci_write(ov9282->regmap, OV9282_REG_HOLD, 0, NULL); + ret = ret ? ret : ret_hold; break; case V4L2_CID_FLASH_STROBE_OE: ret = cci_update_bits(ov9282->regmap, OV9282_REG_OUTPUT_ENABLE6, -- 2.53.0