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 1/3] media: i2c: ov8865: Fix the VTS high byte mask
Date: Thu, 03 Dec 2026 18:54:59 +0100	[thread overview]
Message-ID: <20261203-ov8865-fixes-v1-1-2bedf7e05579@gmail.com> (raw)
In-Reply-To: <20261203-ov8865-fixes-v1-0-2bedf7e05579@gmail.com>

OV8865_VTS_H() keeps only bits 11:8 of the frame length, while the VBLANK
control allows frame lengths up to 0xffff lines. Any frame length above
4095 lines therefore wraps around: the sensor gets a much shorter frame
than the driver and userspace believe, and an exposure that can be far
longer than the frame. The frame then stretches to the exposure and the
image is black, or the frame ends up shorter than the active lines and
the stream stalls.

libcamera now sets VBLANK on the IPU3 pipeline and its AGC raises the
exposure up to the frame length, so this is hit in practice: on a
Surface Book 2, with the 800x600 mode, VBLANK 14760 (VTS 15360, 0x3c00)
reached the sensor as 0x0c00 (3072 lines) with an exposure of 15352
lines, and the rear camera went black at 3.75 fps. In the 1632x1224
mode, VBLANK 3769 (VTS 4993) reached it as 897 lines, shorter than the
1224 active lines, and the stream stalled with CSI-2 errors.

The VTS register is 15 bits wide (0x380e bits 6:0 and 0x380f). Keep
bits 14:8 in the high byte and limit the frame length to 0x7fff.

Fixes: 9293aafe3745 ("media: i2c: Add vblank control to ov8865")
Reported-by: irishchug <75328733+irishchug@users.noreply.github.com>
Closes: https://github.com/linux-surface/kernel/pull/181#issuecomment-7234331346
Tested-by: irishchug <75328733+irishchug@users.noreply.github.com>
Signed-off-by: Marco Ziliani <rylos78@gmail.com>
---
 drivers/media/i2c/ov8865.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/i2c/ov8865.c b/drivers/media/i2c/ov8865.c
index 5a59cca8e..855da1d04 100644
--- a/drivers/media/i2c/ov8865.c
+++ b/drivers/media/i2c/ov8865.c
@@ -180,10 +180,10 @@
 #define OV8865_HTS_L_REG			0x380d
 #define OV8865_HTS_L(v)				((v) & GENMASK(7, 0))
 #define OV8865_VTS_H_REG			0x380e
-#define OV8865_VTS_H(v)				(((v) & GENMASK(11, 8)) >> 8)
+#define OV8865_VTS_H(v)				(((v) & GENMASK(14, 8)) >> 8)
 #define OV8865_VTS_L_REG			0x380f
 #define OV8865_VTS_L(v)				((v) & GENMASK(7, 0))
-#define OV8865_TIMING_MAX_VTS			0xffff
+#define OV8865_TIMING_MAX_VTS			0x7fff
 #define OV8865_TIMING_MIN_VTS			0x04
 #define OV8865_OFFSET_X_H_REG			0x3810
 #define OV8865_OFFSET_X_H(v)			(((v) & GENMASK(15, 8)) >> 8)

-- 
2.56.1


  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 ` Marco Ziliani [this message]
2026-12-03 17:55 ` [PATCH 2/3] media: i2c: ov8865: Reset VBLANK on mode change Marco Ziliani
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-1-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®