From patchwork Fri Oct 3 12:15:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 24561 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 B4EFDC324C for ; Fri, 3 Oct 2025 12:18:41 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1EEBB6B5AA; Fri, 3 Oct 2025 14:18:39 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="QJEDlvE7"; 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 89F9B6B605 for ; Fri, 3 Oct 2025 14:18:33 +0200 (CEST) Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-46e38c21fafso4055545e9.2 for ; Fri, 03 Oct 2025 05:18:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1759493913; x=1760098713; 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; bh=I7DihWxCBk0ycoGsfleZNkucjNC5ge4C2YuX1MZttNY=; b=QJEDlvE7jOKo7IZz96Rybb8xNtDIJ+SzkhsFuDabTDe5aCsZYJjqbnjgiuMG8/l1rf zAq6kJ3+SutCQ5a28AZJm9BI43cWoxxzK9QnWfTUo5U5NXrpB44IFWLOl9wMoZNiaCMc qsd+gEtWSKVzOceYbJflPSlBlStnXMuN1yWnXzkSw66pJYYTJPViowBn6ElCxx59Pvrx 2SF5JI5VMuN03O2BzqPhPb0HMvp3FO26Wc9mrMx00ub5dekcgNsrNsQ6Hp71Dzi1MTH8 PLvG7kVh3XzFbbO/kf3ZI0Z0j+6bLTUzAtPTWRjLWwEUZ8vwptLnx5yxjI+TiMqGs8Ub xNKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759493913; x=1760098713; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=I7DihWxCBk0ycoGsfleZNkucjNC5ge4C2YuX1MZttNY=; b=oWkKGrX8497kGcw/+b9WSuwaJQ0p2FpHMmfmFTUU36ctOIihfwLWFr1PVv1zQrbexk LDMfc22gbvIlohSh641F/NzYbV62DWUfzDjV4ZMOC1PbIAfTNy8oWnTjCEp2Z+ggU3bd +AFKUKAwUq99FCBWQbCkCzOOVslfduEj3tsD5ZSP5kXbUCw15u4JdapVqUWRVA/A9fDn tdstG/nJ/wOHXy6cWBKduvjPv4C7BzuV3wbXzh78UgbWOnLx2YgjYLdfUivbcvcQ2JyZ DsVXzP/jaXmSuDcAVH2wVuFfButWgyhlramLERihhdNJf5k7z0a/gG6w+npgasB1LPF/ kxug== X-Gm-Message-State: AOJu0YwEi7WVE16sRBWn5fe1//lYSHTCrT2hHExiC3zb5dxug29Ojdsb LWSGr7N18TKwbJFzx3nhmjoI7tYLy9oizqWumAb9coiluuoqDU6TLzOSIfUE46qlf0TNljkv18x /epFc X-Gm-Gg: ASbGnctkq056eqRuIU4Os6zKJ6HZdkBeUhdV6OJcJla87PJsw68zXXk3hWIJ4ysTjvD Hdb4ZcYoW4sAcAfBXrqvnm+Wzx9HVJouNr3VBhOGH8OqfUeNiygl78n6Jv7+Fr7r/pO2MvPgQSq F9EEx/9K+1CYdun7skadMNerJ7GOrXppPxZQhWzQNbZb4NN+6dxGVlvCKE5eQ/GmQF9wgnI28UE bK1OAjMTsOjXs1Y4Y11jhxTsznQY4MbSnl2GoKvTGSvEcjZm8H+xuz92+GsaZh59a2Le1a6bfgU ou5yVudVvuF59piYNMyWXmCAzJRcJI9f1LgAk14MyfD9Pj0Eqq/Sohd1OP5ajqWTDkJ3t6X9Saf yfCOJ5Ui6NYaujqRYNb40pUTnF0U7M7abgeUCgxsf8Kx/fALo6omhjMMq30qNTSarQw== X-Google-Smtp-Source: AGHT+IHpQKvzmqrsiedJfORZYzWOTQuFiX20v6FQir53p0Dn0Gro1xjnak3/xHWTcjL463wE6Vl+eg== X-Received: by 2002:a05:600c:3510:b0:45d:f7df:270b with SMTP id 5b1f17b1804b1-46e710b22c1mr11106185e9.0.1759493912657; Fri, 03 Oct 2025 05:18:32 -0700 (PDT) Received: from NAUSH-P-DELL.pitowers.org ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8f02a8sm7812529f8f.39.2025.10.03.05.18.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Oct 2025 05:18:32 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Cc: David Plowman , Nick Hollinghurst , Naushir Patuck Subject: [PATCH v2 4/4] ipa: rpi: pisp: Allow an initial decompand curve to be set on the FE Date: Fri, 3 Oct 2025 13:15:55 +0100 Message-ID: <20251003121821.659081-5-naush@raspberrypi.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251003121821.659081-1-naush@raspberrypi.com> References: <20251003121821.659081-1-naush@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" In the current code, decompand will only set a curve in the prepare phase, which will only run after 1-2 frames pass through the FE. This is fixed by adding an initialValues() member function to the decompand algorithm, which will be called in the IPA before we start the hardware streaming. Signed-off-by: Naushir Patuck Tested-by: Nick Hollinghurst Reviewed-by: David Plowman --- src/ipa/rpi/controller/decompand_algorithm.h | 2 ++ src/ipa/rpi/controller/rpi/decompand.cpp | 8 ++++++++ src/ipa/rpi/controller/rpi/decompand.h | 1 + src/ipa/rpi/pisp/pisp.cpp | 15 +++++++++++++++ 4 files changed, 26 insertions(+) diff --git a/src/ipa/rpi/controller/decompand_algorithm.h b/src/ipa/rpi/controller/decompand_algorithm.h index f19f8c109323..6d2467490106 100644 --- a/src/ipa/rpi/controller/decompand_algorithm.h +++ b/src/ipa/rpi/controller/decompand_algorithm.h @@ -19,6 +19,8 @@ public: : Algorithm(controller) { } + /* A decompand algorithm must provide the following: */ + virtual void initialValues(libcamera::ipa::Pwl &decompandCurve) = 0; }; } /* namespace RPiController */ diff --git a/src/ipa/rpi/controller/rpi/decompand.cpp b/src/ipa/rpi/controller/rpi/decompand.cpp index 5b4c2e5524af..2d457926c060 100644 --- a/src/ipa/rpi/controller/rpi/decompand.cpp +++ b/src/ipa/rpi/controller/rpi/decompand.cpp @@ -39,6 +39,14 @@ void Decompand::switchMode(CameraMode const &cameraMode, mode_ = cameraMode; } +void Decompand::initialValues(libcamera::ipa::Pwl &decompandCurve) +{ + if (config_.bitdepth == 0 || mode_.bitdepth == config_.bitdepth) { + decompandCurve = config_.decompandCurve; + } else + decompandCurve = {}; +} + void Decompand::prepare(Metadata *imageMetadata) { DecompandStatus decompandStatus; diff --git a/src/ipa/rpi/controller/rpi/decompand.h b/src/ipa/rpi/controller/rpi/decompand.h index 0f2a9b3bbdc4..6db779c359a8 100644 --- a/src/ipa/rpi/controller/rpi/decompand.h +++ b/src/ipa/rpi/controller/rpi/decompand.h @@ -20,6 +20,7 @@ public: int read(const libcamera::YamlObject ¶ms) override; void initialise() override; void switchMode(CameraMode const &cameraMode, Metadata *metadata) override; + void initialValues(libcamera::ipa::Pwl &decompandCurve) override; void prepare(Metadata *imageMetadata) override; private: diff --git a/src/ipa/rpi/pisp/pisp.cpp b/src/ipa/rpi/pisp/pisp.cpp index f5be39aca5ee..01baebcd2bb6 100644 --- a/src/ipa/rpi/pisp/pisp.cpp +++ b/src/ipa/rpi/pisp/pisp.cpp @@ -32,6 +32,7 @@ #include "controller/cac_status.h" #include "controller/ccm_status.h" #include "controller/contrast_status.h" +#include "controller/decompand_algorithm.h" #include "controller/decompand_status.h" #include "controller/denoise_algorithm.h" #include "controller/denoise_status.h" @@ -335,6 +336,20 @@ int32_t IpaPiSP::platformStart([[maybe_unused]] const ControlList &controls, /* Cause the stitch block to be reset correctly. */ lastStitchHdrStatus_ = HdrStatus(); + /* Setup a default decompand curve on startup if needed. */ + RPiController::DecompandAlgorithm *decompand = dynamic_cast( + controller_.getAlgorithm("decompand")); + if (decompand) { + std::scoped_lock l(*fe_); + pisp_fe_global_config feGlobal; + DecompandStatus decompandStatus; + + fe_->GetGlobal(feGlobal); + decompand->initialValues(decompandStatus.decompandCurve); + applyDecompand(&decompandStatus, feGlobal); + fe_->SetGlobal(feGlobal); + } + return 0; }