From patchwork Mon Aug 3 12:07:52 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 27544 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id B1F4ABDE4C for ; Mon, 3 Aug 2026 12:30:21 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DF5E368066; Mon, 3 Aug 2026 14:30:20 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="cjreDmfC"; dkim-atps=neutral Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 551E567EE4 for ; Mon, 3 Aug 2026 14:30:19 +0200 (CEST) Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4954a2e73a9so12208185e9.3 for ; Mon, 03 Aug 2026 05:30:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1785760219; x=1786365019; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=NFSuLfdR1m+HCw+72HztqNDyQZp4Oll/4I82jqmyna4=; b=cjreDmfC7HepCD2QsfdAhi5u3mQsiIRaOstPL2jK4Sn+E3gtS8ZyrjCC6NSUZ2ACF9 Vl9lAbSTzdR9Ex0OiD+LRZUU0Ogcrb1b0tUHnyt8GFDB9LWyO3bKsWWgKG4xvCspMGiJ t/jjOJ/KFBu4elSssTkO3NttiSKxN+esrCpm4LwH9JFqn8QeEfQNcuhHmUE6d3l4x6vx JH7/sRd6G4adZ3kaWIrK9W4AM/T1bDvWWqeGDlwgywTPsb6l3ATAW8UVoHFC26xtHnXl mIf5UPVygnZm4DJP/D1A3C+ybdpHLPP+3/bvM+RFfZRzorCDlAolXO0u9yHUcklMK53r slNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785760219; x=1786365019; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=NFSuLfdR1m+HCw+72HztqNDyQZp4Oll/4I82jqmyna4=; b=GbReJN8JMQ8UySlMI1/qi2z5P6X7tW2zCrPT7U5mRh2vfPzRbtNMFuiOzMkcz3r8DG Ms0T7X3bjtE2oxWjcJ2mQKs42/6wGVXOrrq975rIFVZtGRLceXut94iiJbtw+eFTcfax bvB50EaobW5+d4UFTY87Ak+uKILbRZjufriNQPElXUocNhHJ0gwDMKal+TodTlafemlp 9tUv3qQNJaPH9oFvHf6SNEZALObjFvejCb41rgidzMF1Pm7MUvvdIEn+G5LFDOnqDaoo bkNuz0Do+/Pzi5Qt6b+gdKP7O8U7bqzCDb86V7cKmmItGP1rgSpstuqJeJoizuSv3PlE Qu2A== X-Gm-Message-State: AOJu0Yzvpd6B+UvG2MunoN8xjQ+mImWBrDVR8yYITD5tlnI1a05Xt882 H75Z6VZbloOsROpj8zzWctYMJrhF8AdYxvw+B1K+5vKS3HPLL/n8Pq4J5qMYRlqJ6TUNKDYHCzW wNXTV X-Gm-Gg: AR+sD13jTI/NluLOIdw6BIRiVKptFJlYH67uzYUyUkiNTa5AATls0o4mRToEbOvAGj0 qgg43SokKDYCGFcqXpzPi7R3cLHKmmdoREnXis6U0hoZQryW8tsqqCA6JKsqOv38m5MsXCzz2Wa gBeBapz8hgyO7uCCdhHyU4QiAU9Wb11JTVR6pQ3wtQv4y4w+y6eI28CD+WHnSChYj4sLsQwC1Ei jnczGmBE6daeIOVsZ1T8eKdHnl5Qk7C1BEKl3n2iZB/hQIWUVMygHsPU8u8byKd4cm6AyAmIwnb rGGq5IIu2mV+lbkLNHufOAoiUbc8m9LHW8QYJUCaoPAB4FsRDraq+BWm46BO8FJjLlyW8kSgwbw 6X7gBdnQZgculdfXgLUOf5HXPn51oTthjTur6VK7UJ1MVl1RaXA6auuTuh7jDshr0iaqQLuLiWb dx5Z/nHGiXBjtS99l4BUxWMhhYT22SZVxVfJ3JC5lf+45UYq9Ira5mZxCBu4MQv3yOxroPh+BS2 LBgdW4RYj6W1kGci8qLPibh/3z22RXCnheYINfDE79EO5a3hWzdO7kTPTacMGk5O5/OqD6Afdzd IFKD X-Received: by 2002:a05:600c:608e:b0:493:f140:c3fb with SMTP id 5b1f17b1804b1-4980c64a978mr276264775e9.7.1785760218536; Mon, 03 Aug 2026 05:30:18 -0700 (PDT) Received: from davidp-pi5.pitowers.org ([2a00:1098:3142:1f:4706:89ee:c47e:1087]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49808690ffbsm256452635e9.10.2026.08.03.05.30.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2026 05:30:18 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Cc: David Plowman Subject: [PATCH 1/4] ipa: rpi: cam_helper: Increase frameIntegrationDiff for IMX662 Date: Mon, 3 Aug 2026 13:07:52 +0100 Message-ID: <20260803123012.10175-2-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260803123012.10175-1-david.plowman@raspberrypi.com> References: <20260803123012.10175-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" IMX662 can still share its CamHelper with the IMX290 and other sensors, but requires a frameIntegrationDiff of 6 (as opposed to 2 for the others). The value 2 is invalid for the IMX662 and can lead to bad black level values in HCG (High Conversion Gain) mode. The CamHelperImx290 constructor is refactored slightly to allow the IMX662 version to be created with a custom frameIntegrationDiff. Signed-off-by: David Plowman --- src/ipa/rpi/cam_helper/cam_helper_imx290.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/ipa/rpi/cam_helper/cam_helper_imx290.cpp b/src/ipa/rpi/cam_helper/cam_helper_imx290.cpp index b69d38c31..2b9cfee21 100644 --- a/src/ipa/rpi/cam_helper/cam_helper_imx290.cpp +++ b/src/ipa/rpi/cam_helper/cam_helper_imx290.cpp @@ -14,7 +14,7 @@ using namespace RPiController; class CamHelperImx290 : public CamHelper { public: - CamHelperImx290(); + CamHelperImx290(unsigned int frameIntegrationDiff = kFrameIntegrationDiff); uint32_t gainCode(double gain) const override; double gain(uint32_t gainCode) const override; unsigned int hideFramesStartup() const override; @@ -25,10 +25,10 @@ private: * Smallest difference between the frame length and integration time, * in units of lines. */ - static constexpr int frameIntegrationDiff = 2; + static constexpr unsigned int kFrameIntegrationDiff = 2; }; -CamHelperImx290::CamHelperImx290() +CamHelperImx290::CamHelperImx290(unsigned int frameIntegrationDiff) : CamHelper({}, frameIntegrationDiff) { } @@ -61,7 +61,18 @@ static CamHelper *create() return new CamHelperImx290(); } +static CamHelper *createImx662() +{ + /* + * The imx662 requires a frame integration diff of at least 4, + * according to the datasheet, but in practice this didn't prevent + * bad black level values in HCG (high conversion gain) mode. + * So instead, we go with 6 for "safety". + */ + return new CamHelperImx290(6); +} + static RegisterCamHelper reg("imx290", &create); static RegisterCamHelper reg327("imx327", &create); static RegisterCamHelper reg462("imx462", &create); -static RegisterCamHelper reg662("imx662", &create); +static RegisterCamHelper reg662("imx662", &createImx662);