Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.43 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796320511; b=gezDktfJ/e0y+O63/+xUyyhndM+wSOLTYxt+pN98VfBONUCKtRbCfHjmuD2s2xUghc9Z 79mY3SzG42voelAgG4r+vwiK0klmCR3Cv9bqFip+C9AksoNOW0a0QbNqzxbOn98KEYGgr KYVzBxSF8BYzSm7XmSCTlbeFW7zTkMMdjyh9ckXLP9WKAvx7b9dPYkRGn3qwrjXBNV1HU 2SA1x3k+WM0RusVsg2Kp/HKMn/AgzrLvF0NNf9R5uY4zsLMfozrWuVyhjrFL3mPyE8vTF Yq8/ZvQkhW39btmEW+T97GW2xuLnX4KA0uFYrDYLUp3VDLxVYiPeZJFdswBuUvtVtOA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796320511; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:Date:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key; bh=CCdx6cBLDM5x8KBcKQhgCqt55YtZnJYnpVY/JmnWHLM=; b=ksv+tId/IwoEfCcRoj7I/g+UGDOaJD7WFjZArXAEK/nAl3gCuT1nLdWZzaOlflMSXW1p REPHlmZhNjgsxeiD7S43zvNlr6Osz4LE2jCGQcATH9jokeptyDYKrk4Z5nmDSg0fWRer2 OCH9l8q/XRNC9TcdR0ZHXjikzM7jZ43hbt1QDd7TzerDLxxfDFr6oC1mkZb0/wxR/wbWr 4NEG4eLzq3zvdIT8H3HqZaqD7qh/srrgWQLFUPTmWHRSdAuPtQuDXFp7PBvrA5Pu2z4Jy x0baivX3NqyUCEyIgGu5MlY2fEG9DHaudacD6ExOgmkpkV68YfZ52tO7puUb/hjErMA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=aB4R31z+; arc=none smtp.remote-ip=209.85.128.43 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A899C606A680 for ; Thu, 3 Dec 2026 17:55:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A899C606A680 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=aB4R31z+ Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-4bb64ef5a00so116835e9.3 for ; Thu, 03 Dec 2026 09:55:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796320509; x=1796925309; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=CCdx6cBLDM5x8KBcKQhgCqt55YtZnJYnpVY/JmnWHLM=; b=aB4R31z+LiDOB/KE/d/KW+6l1EcwNXZa3/b+hsTUvgu4VRKiR+nkbgK2Ql+cDbNb0i g0tzLVBgc59N+KY0OWEZ5sHsY5ncCAw0M6PQlHouZ8av8YaZRegLc+7bRg3AIW08id1Y B34bA7Zah7lXG9BkGCHXVVHqtWXbfPat1kHjkZvwmeenfbar92w2JDduM+xtZhLYgzfE 3ZmlEn6ASKG1PxUs+vLrG7+5yenpS8RD9dS9pWidIa1HeQylOh4bXjNKNV7jjtN9/bWP F4VrkgXqtBAx1ElwshKWRqoz6raFMuZY/LPBTXBkhn7M8cj2mwwwJ+WZHcU3QfigD6IZ eDTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796320509; x=1796925309; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=CCdx6cBLDM5x8KBcKQhgCqt55YtZnJYnpVY/JmnWHLM=; b=OV2WaITRkXgK4Cp0wMsASL/GK3tqRb2l++cssbt/n44gBDfq7zoIfyADRgNroMB9/O wnmy1iirsdOWdckdfxhtigoCWTya3gmZnXHoJbMQMyHfVdklmbJzcG7o+pdWx9XvDcU0 OfRclmLI7kSdepIsCMuv4C5gyrnTn4/GRhV4AjttNHRiDMPhml3tHRi3907dZJU3y3uD zt0P4Iu5yNpTliSX7ZM8NZDOPZgS6bnvfqqpTPVBYgPUEJaUv3x96EmdR3hDJPcwv79g MYpzBnwCsQkZmRSTwDRhD9By/ApBWSZd5ZgipH5q1KKJ5JKrw7pxrx9bKkMvNFRRe3x0 Yp/Q== X-Forwarded-Encrypted: i=1; AL+hErF4AAcQMI7Ui6cL675kjcjKASAfAhYvXCcgQ9A+jXynxZ04LMFQjhLz+OqMK23RZhB+tLeROePjcsRs3A==@vger.kernel.org X-Gm-Message-State: APuU4Z+0HVuKI2GL32tOgKA2ACmX+Y5Ay/1kXoIf2Lge6C5XPj32xbSk dCIAtQjG229sK3a3lJZG7gAXLTh2T/8xqeUwpbKmadYeiKLLYmoUCq9M X-Gm-Gg: AZFdTZdzSjzUEdkZqFaw2MIf9ZAEFVMTwMe0FO4GdrMwaa4w3u9WBqCWr26lH4EU3Hx aaBI7r17T5h1zkkMZzu1tL1b7B0gM/w6gQLSwg1X5C/b9fncQ93+oWEssfpr3dK2r7xKVoHKs/A nW6Dht51np16NpQv9iZePZGkNqtDLs7DqBHpgBS/PZ9Lst/zWrW4dgvjezAEhySnVGM655W8OYk EBUUWEwmKKVi+Gr/EBf4nU4NeaURR0o5Fzhw1uQLl3qjT0+LnUy+M3SNO8JLd7zE0varR2gA3HT KJtgVKWlHnn7swrGuUUjmEpHGM5agIZNowgKVp2ANAycnIpt930wbG2gpOc75QQoCeG2t/jaFWp wZl+33vpYBTdA+V1D4w56chuWKsu29uAs2VJZNnCUoxRAnKBDRXGNu9YaK132kqw4pD/oJWmsdH 6looQ/jyksrsm3/e1Ii6Pr5SaUshpWG1oJKkZ94IQILZ7Yd4U3YHfwXUwgL4GDookcPRbhEqRak 5IlyhY+FKB99SQfEecA3OrWOd2yue6FV8CmqIrwz8vZI5A3PIYHgCJaAQHLNrBmxeJkrQQuJ9Qn HUgVcFMwiuzhoXlL7YU/wksJ2mlux5Vq7QUQoWmC/iHr6jVT1poZ9QDMhSaUbSaQzvLaJu1wPZV zTVkzmhbQT3+6OAafj5461YlfuHGUtqXl2mNY9ty4YkUSvjfPifHhMwfkRStByFMtjXrE8w== X-Received: by 2002:a05:600c:848d:b0:4bb:52d8:73ef with SMTP id 5b1f17b1804b1-4bb88940f1bmr863747935e9.34.1796320509043; Thu, 03 Dec 2026 09:55:09 -0800 (PST) Received: from PC-Marco.local ([151.59.145.20]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4d174452809sm486985f8f.53.2026.12.03.09.55.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 09:55:08 -0800 (PST) From: Marco Ziliani Date: Thu, 03 Dec 2026 18:54:59 +0100 Subject: [PATCH 1/3] media: i2c: ov8865: Fix the VTS high byte mask X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261203-ov8865-fixes-v1-1-2bedf7e05579@gmail.com> References: <20261203-ov8865-fixes-v1-0-2bedf7e05579@gmail.com> In-Reply-To: <20261203-ov8865-fixes-v1-0-2bedf7e05579@gmail.com> To: Mauro Carvalho Chehab , Sakari Ailus Cc: Daniel Scally , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1796320506; l=2277; i=rylos78@gmail.com; s=20261027; h=from:subject:message-id; bh=rJOGV2OUNrNIQNWWBjcBZPCgBHsRjSEUOwtB5OMjzSY=; b=oc86Oapze1mpztbRLRAc1S4PMciUI7WSvvfFpZeHCANnIfoVMEVLtcDy+qWUCSSKoLDsf02fW 4IeiA/bybU6CiIuJ6PsU8XIdIpajZj+4ALtnLhGoCGI+Su+eitY7ecW X-Developer-Key: i=rylos78@gmail.com; a=ed25519; pk=nXCfiK5yExPZCMp+lfKif3gdXkfjkUK2qk7bDW+ixMo= 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 --- 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