mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Marco Ziliani <rylos78@gmail.com>
To: Mauro Carvalho Chehab <mchehab@kernel.org>,
	 Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Daniel Scally <dan.scally@ideasonboard.com>,
	 linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/3] media: i2c: ov8865: Reset VBLANK on mode change
Date: Thu, 03 Dec 2026 18:55:00 +0100	[thread overview]
Message-ID: <20261203-ov8865-fixes-v1-2-2bedf7e05579@gmail.com> (raw)
In-Reply-To: <20261203-ov8865-fixes-v1-0-2bedf7e05579@gmail.com>

set_fmt() updates the VBLANK range and default for the new mode but
keeps the current value when it is still in range. A value left over
from the previous mode then keeps that mode's frame length: after the
full-size mode (VBLANK 22) the 800x600 mode runs faster than its nominal
90 fps, and the VTS a previous user set stays on the sensor for users
that never set VBLANK themselves. On a Surface Book 2, after one run of
libcamera master, which sets VBLANK, a libcamera 0.7.2 run kept that
frame length and ran at 18.8 fps instead of 91 fps.

Set VBLANK to the mode default on every format change on the active
state, as other sensor drivers do.

Fixes: 9293aafe3745 ("media: i2c: Add vblank control to ov8865")
Link: https://github.com/linux-surface/kernel/pull/181#issuecomment-7234331346
Signed-off-by: Marco Ziliani <rylos78@gmail.com>
---
 drivers/media/i2c/ov8865.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/media/i2c/ov8865.c b/drivers/media/i2c/ov8865.c
index 855da1d04..e85e4c974 100644
--- a/drivers/media/i2c/ov8865.c
+++ b/drivers/media/i2c/ov8865.c
@@ -2756,6 +2756,14 @@ static int ov8865_set_fmt(struct v4l2_subdev *subdev,
 				 OV8865_TIMING_MAX_VTS - mode->output_size_y,
 				 1, mode->vts - mode->output_size_y);
 
+	/*
+	 * Start every mode from its default frame length: a VBLANK value left
+	 * over from the previous mode would keep that mode's timing.
+	 */
+	if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE)
+		__v4l2_ctrl_s_ctrl(sensor->ctrls.vblank,
+				   mode->vts - mode->output_size_y);
+
 	hblank = mode->hts - mode->output_size_x;
 	__v4l2_ctrl_modify_range(sensor->ctrls.hblank, hblank, hblank, 1,
 				 hblank);

-- 
2.56.1


  parent reply	other threads:[~2026-12-03 17:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 17:54 [PATCH 0/3] media: i2c: ov8865: Fix long frame lengths, VBLANK on mode change and gain steps Marco Ziliani
2026-12-03 17:54 ` [PATCH 1/3] media: i2c: ov8865: Fix the VTS high byte mask Marco Ziliani
2026-12-03 17:55 ` Marco Ziliani [this message]
2026-12-03 17:55 ` [PATCH 3/3] media: i2c: ov8865: Allow fine analogue gain steps Marco Ziliani

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261203-ov8865-fixes-v1-2-2bedf7e05579@gmail.com \
    --to=rylos78@gmail.com \
    --cc=dan.scally@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®