From patchwork Thu Aug 6 15:19:41 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 27664 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 058BBC3306 for ; Thu, 6 Aug 2026 15:27:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3734168184; Thu, 6 Aug 2026 17:27:10 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="UbywwtBl"; dkim-atps=neutral Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id ED1D16807A for ; Thu, 6 Aug 2026 17:27:05 +0200 (CEST) Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-49802c418b5so22769325e9.1 for ; Thu, 06 Aug 2026 08:27:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1786030025; x=1786634825; 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=9zj0VmNLKpjT+yYACSZDIZZ4CvKkcnncM3GWXkRa3Qw=; b=UbywwtBlfhY5CLSgtRHkZxpigu7c7UVNdA9qJtDStcDiY4AbNse6/erS53MR2EfuDF +nBUbwistNMeTijNDe6n8d6/tvfLNxf6NKDntSxlnrzs9DGkdhJzEc0ag6TGuFkZl/LD DElsc9k9JBqWGiwajB35aKmRaBeLm+cT+4srIJubsx8nuUw+z71eYAD3/jM7p4ygw0aq PsiQVHxqw4oaHNsjgcBhBaKurJaIK7V4BnLYQQDkunsNk0iTibM7ElLAWMVJPrKl0KyI wGUZowlUhNWSvgU9UEEQJfTjxFOTAhypCBkbqxzxs0RNDG6YLKeOlAVE94cZrlQAGjt9 YU6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786030025; x=1786634825; 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=9zj0VmNLKpjT+yYACSZDIZZ4CvKkcnncM3GWXkRa3Qw=; b=Z5TgszVbpRCosLNO40PohXwNuqAxoTSwtcdxMrsC9y4xVgJLLaoThtS7avhDZq4TlV otoVilLj0T28oFXHvh4g+qxY+kOCAXvjOqAnvMDY42Tfvh3rYdYGOlovV4cZzQ6qQV98 GBkwpbTydkmnFrVYBDr2ZjjsPIHrQ+pCimisL8p2s92XiNBfgDMsot4mTiqiwCd+B81F IuVyN5wifaZHWIladAhzoIUGB6qT8qcz/mpCfFNEuNL7b38OO8S+KrAXnNLtUg30I3+0 jtj3+6KgmI0+53uC8dusx9zqV5q4mfDCol2gN76ZxorJuiFUZtUyQ8XIR9mHzTqWEdG0 USKQ== X-Gm-Message-State: AOJu0YzJ8CS7fLPMOTIu/P0vxBPoHnDSH39hvUzsfnR4GtlP2dIf/68O m0f0VuXBq7TJUDs5HvwkTy8uk1+V9Dc2AzLZzN1jhv65VY1FEDszqIWaqfyZPoPfpJ54zAI5Ifs U4Rnp X-Gm-Gg: AR+sD13ACzD4Q9Syd3Wahm3P7RadHfNMdxpEBSqQxLuvEDSp2T0tCYLobPs5GE4VrB1 rPmhW+MzbrObJX8QwTiJt1PcuoAWHHonvrNioxMuS77VLQ4JqAjeCukr4Fcx0PmdkgoMwC1NJkI 5LMaWwxmrRdUfvdYdID/S66ekW8MkIOq8h4q10dqwxFY2C5h57nVcF8W4+LyNYxmgMP6iXuQmAl u0HM7XLhHd8KEUGgxbUORSFSaQgRhIlBXeG6NRSVosNQK6K85y2a3fjsRqW1GVJFQM+MbImjVik pXfbJltbZkKp2M5CFh1huv9fFYKiPb+e6ARclK0k1qKNCu2j+7BeYTydMF6fWLoMrY3/+bizN0D qG0/dU5sPo+GhXqgnwvpg7ITsWI5yc6NvGkasCY2upcGXiKnoQLKJdViu1znLwx1ydwDjqtgDi/ yvvLLorKtQNpf14+ILbM95DAc2PlnO8U85jvQD1lqpFVm9Edmu1lto2q+MYowSNNCt17gea9Yw9 WZBnICHTAZOHKEtSA5ygFPUITM847mK/Ncrn13NiY+rr4AnnS8SUdKamhTiaBa7itkbS/8vk4IW 2zCd X-Received: by 2002:a05:600c:1f86:b0:499:52ab:a50c with SMTP id 5b1f17b1804b1-49952aba5b3mr101058895e9.1.1786030025239; Thu, 06 Aug 2026 08:27:05 -0700 (PDT) Received: from davidp-pi5.pitowers.org ([2a00:1098:3142:1f:4706:89ee:c47e:1087]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4995428f294sm70769235e9.15.2026.08.06.08.27.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Aug 2026 08:27:04 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Cc: David Plowman , Naushir Patuck , Jacopo Mondi Subject: [PATCH v2 1/4] ipa: rpi: cam_helper: Increase frameIntegrationDiff for IMX662 Date: Thu, 6 Aug 2026 16:19:41 +0100 Message-ID: <20260806152701.4179-2-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260806152701.4179-1-david.plowman@raspberrypi.com> References: <20260806152701.4179-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 Reviewed-by: Naushir Patuck Reviewed-by: Jacopo Mondi --- 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); From patchwork Thu Aug 6 15:19:42 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 27665 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 3031CC330A for ; Thu, 6 Aug 2026 15:27:15 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8901968186; Thu, 6 Aug 2026 17:27:11 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="dyPSEAEA"; dkim-atps=neutral Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4BDDA68169 for ; Thu, 6 Aug 2026 17:27:06 +0200 (CEST) Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-495590dde14so26853095e9.0 for ; Thu, 06 Aug 2026 08:27:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1786030026; x=1786634826; 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=LaAYL+469tyiBvmLl9L8gVVPj1Cx8ia1LyQR7+pHpKg=; b=dyPSEAEAT0gZdFSl/AOxfX8V0WgfgSdJXWYV5Tv6y/Ir+Kt/mhHwV9e7bthr59KKNZ KACwFU+lvkiYpDEIrrGk1WZmUPqAo+A4nduCNdTs984zUcDJ/2hqed6c7f1lxCFXofww 8eIF6rOBtwPtD20WAPaffeBtaQ9dxT8QybvPPUbhUNIozazl92yB9xNtDutj7HQaUceU 8/yRdHljQHaSz8I2+vCEurNvqsLouHXRT8u3Ji/NlwW2Kds/bRASsmeKnp2W+rSbauvN vYVOmRoihjf9fSzsfs/2ukI73ehMmh9lKOCnQJZ0Y8qLAOyzArri7uIdIlw5z7iDP9iS 8/hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786030026; x=1786634826; 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=LaAYL+469tyiBvmLl9L8gVVPj1Cx8ia1LyQR7+pHpKg=; b=aDTy5rjd33K5jtbwrrv7zsjnv1OH8DeVPQp9SNA79fzsjdXIhU26BxYkhlRQVrxmyE qAnoHFqMUJbDPsxdt8vS3o2spenvt94MkeQTD/VhBJMZv9+ZI4TKGpWQRV32ADdRuOSF qtuhGno9AhzRKV9qZbuFJh9UTM5dbXEin6CKsPLvIIbfckMKL9FwBxy0JuFiI2Lcu5sm usmhcVB/as2/fBY6b6ZTPtelLs3QnwE5c1yaMixOYnG3145hPVqqAk9iUSkt+0hUw/A+ 7Mjn47d2ARy8eCF8lGvE1jGXNGh1U5FgUR0MXAat28zIZFGtTMAUvwbSf2ku5aMvcDfj hBsQ== X-Gm-Message-State: AOJu0YzK0pe1ubkexG4km4NriSMdgL3k/CiW3vrKCHvpF0MeWP5AmtZ8 fkkVLbBlpM0Cci4W5e2mBMKlX7kt0C4k7PXtlNzCYgtjlaiv3RBWjxLvx7AnUYNlMUN+h9mfZN4 kl9T9 X-Gm-Gg: AR+sD137mQY3/c4qwglbT9e1b/fZYkqUs85ytWGyysR3Ak72H1b/lHGsarxP2U6NxNQ FmoMCBcaD3hdkrNsoWgwGr2qaFIBmVj7RtCDbfip6UoCxhnfS2SOBz3ZZ/Y5oRfvfscUlyfJK55 wjGjuHXpiea7VdcGWLnvAFzGtZyExUwX4y2AwSHg2LDOGCjkRNYCxc7J5h5WiQXtSW7QFiUVbMS /UKpXWnLCJlqq3+X7ZYl6oN8W4xzb7Oi6bQCzzxky+qQfcD5UkSxuF255uNf7XePJ3gvjN32gp1 lwVcv/UqgVsGXQ/kQIt2Gvlu6cRtqmNdK65QA5/jy9bA60t7vYcd9kqM4FpX7riJCc2vKG0x+kk oUY913Y0DAxXRK2i0vbVX48oQHhHF14qMgRDFDs7QpqRo9OXa61Hrm/LpGCrQI38zcjVI2GZhNT yoHe45XplA87oUgxB3ceNqmNkjw05JEzd3kFsKAl2kJINd+IyK3fNbP4u876yvRtUF5F/Cs5RFF X6SPG6VnhDdEST6bCW1zOwktLsKibdm/f7fYMmdKkTt7xiPslZnMeyz9d/u77YyznQISI6QFjLV Rqfa X-Received: by 2002:a05:600c:474a:b0:496:c361:fb96 with SMTP id 5b1f17b1804b1-4994e6db5aemr188185655e9.0.1786030025678; Thu, 06 Aug 2026 08:27:05 -0700 (PDT) Received: from davidp-pi5.pitowers.org ([2a00:1098:3142:1f:4706:89ee:c47e:1087]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4995428f294sm70769235e9.15.2026.08.06.08.27.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Aug 2026 08:27:05 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Cc: David Plowman Subject: [PATCH v2 2/4] ipa: rpi: Allow black levels to vary with analogue gain Date: Thu, 6 Aug 2026 16:19:42 +0100 Message-ID: <20260806152701.4179-3-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260806152701.4179-1-david.plowman@raspberrypi.com> References: <20260806152701.4179-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" Optionally, a PWL (piecewise linear) function can be specified as the black level instead of a constant value. This PWL is evaluated at the current analogue gain for each frame. Tuning files will also accept "black_level_func" as a shorthand for all three channels. Signed-off-by: David Plowman --- src/ipa/rpi/controller/rpi/black_level.cpp | 45 ++++++++++++++++++++-- src/ipa/rpi/controller/rpi/black_level.h | 7 ++++ 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/src/ipa/rpi/controller/rpi/black_level.cpp b/src/ipa/rpi/controller/rpi/black_level.cpp index 42ea15050..92a258048 100644 --- a/src/ipa/rpi/controller/rpi/black_level.cpp +++ b/src/ipa/rpi/controller/rpi/black_level.cpp @@ -41,12 +41,41 @@ int BlackLevel::read(const libcamera::ValueNode ¶ms) << " Read black levels red " << blackLevelR_ << " green " << blackLevelG_ << " blue " << blackLevelB_; + + /* Allow "black_level_func" as a shorthand for all 3 colours. */ + libcamera::ipa::Pwl blackLevelFunc; + blackLevelFunc = params["black_level_func"].get(ipa::Pwl{}); + blackLevelFuncR_ = params["black_level_func_r"].get(blackLevelFunc); + blackLevelFuncG_ = params["black_level_func_g"].get(blackLevelFunc); + blackLevelFuncB_ = params["black_level_func_b"].get(blackLevelFunc); + + /* Warn the user if they've defined constant black levels but which are unused. */ + if (!blackLevelFuncR_.empty() && !blackLevelFuncG_.empty() && + !blackLevelFuncB_.empty() && params.contains("black_level")) + LOG(RPiBlackLevel, Warning) << "\"black_level\" specified but not used"; + + if (!blackLevelFuncR_.empty() && params.contains("black_level_r")) + LOG(RPiBlackLevel, Warning) << "\"black_level_r\" specified but not used"; + if (!blackLevelFuncG_.empty() && params.contains("black_level_g")) + LOG(RPiBlackLevel, Warning) << "\"black_level_g\" specified but not used"; + if (!blackLevelFuncB_.empty() && params.contains("black_level_b")) + LOG(RPiBlackLevel, Warning) << "\"black_level_b\" specified but not used"; + return 0; } void BlackLevel::initialValues(uint16_t &blackLevelR, uint16_t &blackLevelG, uint16_t &blackLevelB) { + if (!blackLevelFuncR_.empty()) + blackLevelR_ = blackLevelFuncR_.eval(blackLevelFuncR_.domain().clamp(1.0)); + + if (!blackLevelFuncG_.empty()) + blackLevelG_ = blackLevelFuncG_.eval(blackLevelFuncG_.domain().clamp(1.0)); + + if (!blackLevelFuncB_.empty()) + blackLevelB_ = blackLevelFuncB_.eval(blackLevelFuncB_.domain().clamp(1.0)); + blackLevelR = blackLevelR_; blackLevelG = blackLevelG_; blackLevelB = blackLevelB_; @@ -54,10 +83,18 @@ void BlackLevel::initialValues(uint16_t &blackLevelR, uint16_t &blackLevelG, void BlackLevel::prepare(Metadata *imageMetadata) { - /* - * Possibly we should think about doing this in a switchMode or - * something? - */ + DeviceStatus deviceStatus; + if (!imageMetadata->get("device.status", deviceStatus)) { + if (!blackLevelFuncR_.empty()) + blackLevelR_ = blackLevelFuncR_.eval(blackLevelFuncR_.domain().clamp(deviceStatus.analogueGain)); + + if (!blackLevelFuncG_.empty()) + blackLevelG_ = blackLevelFuncG_.eval(blackLevelFuncG_.domain().clamp(deviceStatus.analogueGain)); + + if (!blackLevelFuncB_.empty()) + blackLevelB_ = blackLevelFuncB_.eval(blackLevelFuncB_.domain().clamp(deviceStatus.analogueGain)); + } + struct BlackLevelStatus status; status.blackLevelR = blackLevelR_; status.blackLevelG = blackLevelG_; diff --git a/src/ipa/rpi/controller/rpi/black_level.h b/src/ipa/rpi/controller/rpi/black_level.h index dbf29b282..34bb81548 100644 --- a/src/ipa/rpi/controller/rpi/black_level.h +++ b/src/ipa/rpi/controller/rpi/black_level.h @@ -6,6 +6,8 @@ */ #pragma once +#include + #include "../black_level_algorithm.h" #include "../black_level_status.h" @@ -27,6 +29,11 @@ private: double blackLevelR_; double blackLevelG_; double blackLevelB_; + + /* Black levels can vary with analogue gain instead of being constant. */ + libcamera::ipa::Pwl blackLevelFuncR_; + libcamera::ipa::Pwl blackLevelFuncG_; + libcamera::ipa::Pwl blackLevelFuncB_; }; } /* namespace RPiController */ From patchwork Thu Aug 6 15:19:43 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 27666 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 EE090C3306 for ; Thu, 6 Aug 2026 15:27:15 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id F232C68179; Thu, 6 Aug 2026 17:27:12 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="fZ35vceW"; dkim-atps=neutral Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E69EE68171 for ; Thu, 6 Aug 2026 17:27:06 +0200 (CEST) Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-495757ccbc1so25192955e9.2 for ; Thu, 06 Aug 2026 08:27:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1786030026; x=1786634826; 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=In6KRTEPf+Ifx24CfZAVA1q3tf+YfA3zsnu6W8Tc46s=; b=fZ35vceWsfspnKm486oOFwwj2EHdo1jFW9apzG88zOVn3aX6f5Hn+kHjjvtlAtPbpi kJmKc4LRAoUlx4o8aV4JTjprAf5HvHLeXIDV7CxhN9jIKcKtxW9IzWjJrWxXnouThqtm Eme19OFExcxi3oIN7kD9oDLJA9p2xOXQHRpRr4xzy0QkS0CLTIVoQ+qP5nPKecN/wVoH Ji/fGVs0mNmiWDsCSZL/DycvAfHoSOCPBq9L6u+n4DRCi0bPpUMuajevj21YkuHc3aIg cK2ksvW5VA9gtDhgoxPaBWkT9o10EE0F7BS5Vgp+K5SEyBb2vtpA+7lsAIcELHbYyw9k aWHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786030026; x=1786634826; 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=In6KRTEPf+Ifx24CfZAVA1q3tf+YfA3zsnu6W8Tc46s=; b=rRVUqeQtm9qUYZjD4qo6Cr8cDQ+ui0SQ/uUWIJMVi/uIaPr9cReZEbx74wWUOmV7ru GH0Cri1ufCDfYSeJG0J9hAmvqD79Ge1BCMJhDIrNKKCFDwieJhpI9ZTA6+2rgAYEPbHK STmRtRkOX24Ay69qbQL4SAJ7OJMGJo0UwA+YOl38OfneNOdmYI5h/lGwPVdmMro2f6jU 5CaWuNF2GLdQ8LObJf3Fv+Ha0gFbc440oE7KDVqGSDqELP9l5yItUUXlYsMakH+xqBUm bkPHMXP3tvzj5nKmhCVpVpScgkMGqXdmKhC7JeXRmw9YSo3DGGFA6aKLAqnc0fFDbgKE LfeQ== X-Gm-Message-State: AOJu0YwG7JY/MqvnZFn2QTL0nvc2MPEhTCtiGi/dbkTXD3nF+munjDKA /cWmHrSiDkRAMdARVQ+a/cw3bV48ZcAyD+hWrMBoKOX89/nJL+wNJgMax6Ti5+YzYEK+Zo2gx1A eTjKL X-Gm-Gg: AR+sD102+km4OG5RSgBMbGVKnm/4Ga5OxMH5NZx0G0vVUkv/AY7WeZLC4wEPfaFXeNS hUInolLQHjMb8+sTUDo/NHUuLD17OZpGNuTwXDKrsyq06dptqTsIZEbVIoiCcfzzQp/ZR/UkhNd dSvZfCHpF2/IuH5BvObmcLbUvrDXd5x5sxwNkwS+MRXU4taJLE/geHLhlNjfT5Iuict69NgoFn6 5E01FitWH1qxkpzOeMgLXwnXKAP6mBY775COUwCfvAhrvDv4XcAcyzEe7YUxKTi/tQkTUE9FkTZ G13UJyTh5IouodrNpru72vzy77eMRKLAoKAnPOVdml2Mb/o2ZI8Hpdlb9Y4YeZDo+Q3F1seUn6G hkB7KBay1x2b5Pk9xDXMeJkfrCICOAhqP9MQ4I08k19XBbSfJEm38eqGRnGDgM9z7RANw+RS7wd yAyVjwfol9EvqO5HcZQt4jel3H1Ow2vwwV0K5KQwM4K8taSfbEw3ibMH42v6qPaIFM71t72KPM+ uxmIFOf89jXfeBdiQGdpy40dC/P6N2r0gU64xTPyPQPcfmOpH6pwdiNtP2N4nSYMW2WxSljXzlI qhOm X-Received: by 2002:a05:600c:4514:b0:496:bbce:f3 with SMTP id 5b1f17b1804b1-4994e71ed7bmr199187455e9.6.1786030026443; Thu, 06 Aug 2026 08:27:06 -0700 (PDT) Received: from davidp-pi5.pitowers.org ([2a00:1098:3142:1f:4706:89ee:c47e:1087]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4995428f294sm70769235e9.15.2026.08.06.08.27.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Aug 2026 08:27:05 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Cc: David Plowman , Naushir Patuck , Jacopo Mondi Subject: [PATCH v2 3/4] ipa: rpi: Update black level tuning for IMX662 Date: Thu, 6 Aug 2026 16:19:43 +0100 Message-ID: <20260806152701.4179-4-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260806152701.4179-1-david.plowman@raspberrypi.com> References: <20260806152701.4179-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" At very high gains, the measured black level increases noticeably from the nominal value of 3200. Signed-off-by: David Plowman Reviewed-by: Naushir Patuck Acked-by: Jacopo Mondi --- src/ipa/rpi/pisp/data/imx662.json | 11 ++++++++++- src/ipa/rpi/vc4/data/imx662.json | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/ipa/rpi/pisp/data/imx662.json b/src/ipa/rpi/pisp/data/imx662.json index b146d6b59..1aa5cf533 100644 --- a/src/ipa/rpi/pisp/data/imx662.json +++ b/src/ipa/rpi/pisp/data/imx662.json @@ -5,7 +5,16 @@ { "rpi.black_level": { - "black_level": 3200 + "black_level_func": + [ + 1.0, 3200, + 192.0, 3200, + 256.0, 3245, + 320.0, 3331, + 384.0, 3443, + 480.0, 3606, + 512.0, 3623 + ] } }, { diff --git a/src/ipa/rpi/vc4/data/imx662.json b/src/ipa/rpi/vc4/data/imx662.json index cec937d62..dc28b53c4 100644 --- a/src/ipa/rpi/vc4/data/imx662.json +++ b/src/ipa/rpi/vc4/data/imx662.json @@ -5,7 +5,16 @@ { "rpi.black_level": { - "black_level": 3200 + "black_level_func": + [ + 1.0, 3200, + 192.0, 3200, + 256.0, 3245, + 320.0, 3331, + 384.0, 3443, + 480.0, 3606, + 512.0, 3623 + ] } }, { From patchwork Thu Aug 6 15:19:44 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 27667 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 9AE91C330F for ; Thu, 6 Aug 2026 15:27:16 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B99C46817F; Thu, 6 Aug 2026 17:27:13 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="qOc3JXN1"; 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 6A4B768169 for ; Thu, 6 Aug 2026 17:27:07 +0200 (CEST) Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-495590dde14so26853255e9.0 for ; Thu, 06 Aug 2026 08:27:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1786030027; x=1786634827; 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=mp/RCSP/XnkclZU2Pqg6K77RkCgfxALEVVOvYj/fxS4=; b=qOc3JXN1scz8g6Th9scjuzuRbklTWPua7bTC+8N7awHl8OIyEzF0xiwGvkCmyIX228 NnbNDlks7WTVvoblSMRxrD9uZ0tdtQV5adPsvWABajnCe40oyOywvutJxB77wMyU7Jal pcScpzZRppeIBUs6xgBgS/JI1VlYupxn1MPJpe4dEKmwZ8OazI28cSR3h6a+buzONPCN GGYShEEn8zs7lxmRM2ujyzxAQ/XxXX690X1A63I73gOjzM5pEURHoZmLWjxtny2t4QXJ SM8pxVctHUgt0QbUGoMxhajEIRAM6b2yJyKMVXB9SNgvlUgThb8mcqNNwaWmB9f9i8OB HDzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786030027; x=1786634827; 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=mp/RCSP/XnkclZU2Pqg6K77RkCgfxALEVVOvYj/fxS4=; b=sCCz6DJ1+hIfKG73Wru+DJtc6sL7HEGEyINHnHbOpvNwzf2q47Dp2Jk7NRVGhd7U7m WpHhNbgRGsdehNTK3xxZOlgdzJnfU0Hgj0YRa+XfLBxaNBJGUEWgZ7UYKIZTXH5H26Zn Mb8VlLqge8tq7kmYRMBIyjZAsnetggtfl15hFbdQl3WmeiZbrzrn7WvefxSC3Fh4Tkso NQE4FZwTLjK94iKELgMJRXJcv4Z/YA58l+xyfr4jfYjD4P2BVDlC9SBzAKKqpUX9GvOQ 19CCIEMHcIrCqWYFc+EhUp7Th6IIDQE3NWK0dM5eUFkTHBE6jC/oZayDn4Lgz2TexaKm BEOA== X-Gm-Message-State: AOJu0YyX74UR9gyXYaZwwqveXaHa4dlx5tU7pspklnffNU+vJIR+badL L5c+Bvo4fVdkDkpEYwNvL8hWnvGCgWTFDUJHlwRBYAf0WXLG4LH7G+84JNxaVsPm4US+hAI31dr TNr0s X-Gm-Gg: AR+sD11odmyeZAUsvdsIMwMywq9CJAH+bqLJ6LGuABFcMARifPMLpJqtEctJgG6P/hZ V7sFZ+wDgeB707hyxC0sgQBAaGok5qUj+VxoLnwTv8E5at27zGiMy14tK1hEuEfTDui69DwanPe o2AKJ1Nl4zTBjOobXgFDU12C++ly23L/ULU1nmZQwHgcGX5tOB7r3WemG+No7re5OkIF5FejxV+ eCgZkztvrjs4Y9N1r1PYaQ+enurFEXeqcTWRsQTUlNlZYO+RhMmZ7fW5kPvT75BsMAn7VMbKm7Q PMoKI5OumDtrMymZviiEOPUV1tn6XHs+r05hbznH2diJTiD55LCSJR/J2BfiAOjQH0z2Rb6PIYH vSJmWFz1Qd5yCsRboi9HgmNAIw9yFmOA8fo6Igje0B02F9k9ixBHMIASwJifL6OJdSkuYEg0S5n cbRaL/stdI1N8z12bmnq1oUj/0xdDGDdPlw4tctLWKfZvJSAB8POwXNLZ/er/F+YMu+EuN8R/0V w4fCsnPkBsz56bX8JurQhuz65cvxs/ApIlbirTwbMZLTyNY3Z0tP8yrP4GAg6PAFtdUeOnaMy7S PgKzAvGAnPH9DJ4= X-Received: by 2002:a05:600c:8b51:b0:495:6b55:f938 with SMTP id 5b1f17b1804b1-4994e7ba99emr230427055e9.10.1786030026859; Thu, 06 Aug 2026 08:27:06 -0700 (PDT) Received: from davidp-pi5.pitowers.org ([2a00:1098:3142:1f:4706:89ee:c47e:1087]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4995428f294sm70769235e9.15.2026.08.06.08.27.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Aug 2026 08:27:06 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Cc: David Plowman , Naushir Patuck , Jacopo Mondi Subject: [PATCH v2 4/4] ipa: rpi: Update colour temperature curve for IMX662 Date: Thu, 6 Aug 2026 16:19:44 +0100 Message-ID: <20260806152701.4179-5-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260806152701.4179-1-david.plowman@raspberrypi.com> References: <20260806152701.4179-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" The CT (colour temperature) curve is extended at the bottom end, so that low light halogen images are less orange. Signed-off-by: David Plowman Reviewed-by: Naushir Patuck Acked-by: Jacopo Mondi --- src/ipa/rpi/pisp/data/imx662.json | 4 +++- src/ipa/rpi/vc4/data/imx662.json | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/ipa/rpi/pisp/data/imx662.json b/src/ipa/rpi/pisp/data/imx662.json index 1aa5cf533..8491452b1 100644 --- a/src/ipa/rpi/pisp/data/imx662.json +++ b/src/ipa/rpi/pisp/data/imx662.json @@ -155,7 +155,7 @@ { "auto": { - "lo": 2910.0, + "lo": 2500.0, "hi": 5535.0 }, "incandescent": @@ -192,6 +192,7 @@ "bayes": 1, "ct_curve": [ + 2500.0, 0.6632, 0.2893, 2910.0, 0.5579, 0.3553, 3600.0, 0.4693, 0.4364, 4490.0, 0.3855, 0.5469, @@ -250,6 +251,7 @@ "enable_nn": 1, "ct_curve": [ + 2500.0, 0.6632, 0.2893, 2910.0, 0.5579, 0.3553, 3600.0, 0.4693, 0.4364, 4490.0, 0.3855, 0.5469, diff --git a/src/ipa/rpi/vc4/data/imx662.json b/src/ipa/rpi/vc4/data/imx662.json index dc28b53c4..aafccaced 100644 --- a/src/ipa/rpi/vc4/data/imx662.json +++ b/src/ipa/rpi/vc4/data/imx662.json @@ -86,7 +86,7 @@ { "auto": { - "lo": 2910.0, + "lo": 2500.0, "hi": 5535.0 }, "incandescent": @@ -123,6 +123,7 @@ "bayes": 1, "ct_curve": [ + 2500.0, 0.6632, 0.2893, 2910.0, 0.5583, 0.3541, 3600.0, 0.4695, 0.4348, 4490.0, 0.3856, 0.5447,