From patchwork Thu Oct 2 13:26:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 24552 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 42017C328C for ; Thu, 2 Oct 2025 13:35:41 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 985506B615; Thu, 2 Oct 2025 15:35:39 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="ESd4XYu/"; dkim-atps=neutral Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1FF326B5F9 for ; Thu, 2 Oct 2025 15:35:33 +0200 (CEST) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-45a1b0ce15fso690175e9.3 for ; Thu, 02 Oct 2025 06:35:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1759412132; x=1760016932; 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=Xh7vT5smofoDWv6eoWK8ZtPETUG17hmhKYV54w92rXI=; b=ESd4XYu/ae9+XlIMsUGyvWLWi3HEsQZkywbiYMFpp2ID/RTMPKjof3WLJ5MbIgU78N fFhP0oq4emY/t4ao0JUyjFw+FjFax42OLmIJwIzw/gzcwmAVYxDAGqiiBlDzPELlgi2K x0jG46h04bdeN3KsGBXjFr71Qjh9BBq+iGZB28aE4DWGbg7x7nfgJXOYslFACuHCzgOo oNPFZUswgYPO4UXDDHcdUkjSOAwNgaPJXssLqIsoLXH1/Es9bUTzxPEsZ2Ff2bc6Yblo mQMzzW5ptZkotHJCEMfJf5VaOENr/zIUESGevFknZ7Q8bvMQ6nj1tH04vCkRKzwuXAWO /cnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759412132; x=1760016932; 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=Xh7vT5smofoDWv6eoWK8ZtPETUG17hmhKYV54w92rXI=; b=FTCgGHwEX7dKM5TkkroT+U3pRVvmPn+PKFacHdzFIk4WgH3fnl845QXgkTil0ipNrp BWrKYS8VksiHKli6Axd3X+X7MxQ0h4uE/UOH6GjiEBPm7hY45auDAsVe8X1OBE0kE7qV OdVFXjb/fL4pqBWEDJfqt+bl/cYYY5rjERMCBirwATufszXp0A9AGpm4hu4fnWnfMPqO lc7I3roJ+WKmhaG8xy1zoEGHbyxH9JOT7ykuFHSw7JLeh4dTMAMaL4kSESNQhC16ztui ps6E75AVx6sYMJgFgarvwKNBvOJ7ReXgP40t/HLzT8TSI11/5hiNlLAR4egiIk9ArnN1 /KxA== X-Gm-Message-State: AOJu0YwQPiZgQw4aM3QEuS9MY0Ead6zM2eeF6FxiYZk3xzgkcoG6kwRK 9+xn7atu6QnUe4MCe5dtKRbE8QmegKsrYUpOLkRVKxKvRXlH44vgmPzuJBFcda0XynSeU6GRJml X0JDU X-Gm-Gg: ASbGncupirG1jAA+Mhh+bgcr8d79kvpEFJiWzarJcQjZ4BXbJTa4b2//OXq8ZvINIWt Th5WqcWmMA+hcD0xLz8AbLY1zEXZgwlyy2PL7YTWXze5ZP6JYMZZKVLFtGJEZTu7kZw8Vefkp8R SYKOi5By0udTG6ONky7KCYuNNav8cXybGsWUQGn7IKpd9pYHEIqU0fYElCg37KyIJ9dfie0rWWl /fP+y4AXoEbeAyEgLjQUFA9mAJiMA+NF826/nkBCa2sngpenFRmvY52hMp92/bienw0fiNEmR5P BWtAIX2ZwyYJpKKhyDUotBvciM60lcg8T7Xca5Q6doeHi0+H9gNaFIsScuHnM3c2MMzksSz8SiJ OjgQXOQBiqYFA7zYbdAc9VIz1k9Fj6G0DlQjpowwalfhpcfvuQYmz2gMbVFh6XfKX4Q== X-Google-Smtp-Source: AGHT+IESYDyvTST5yH8XdBP+8u4JtabcdFNz3aKpmfK9U+lSFwxjKnlC1CuX1lTzBc4c8WecqC1Bzw== X-Received: by 2002:a05:600c:4fd4:b0:468:7a5a:14cc with SMTP id 5b1f17b1804b1-46e61263eb4mr29697955e9.3.1759412132294; Thu, 02 Oct 2025 06:35:32 -0700 (PDT) Received: from NAUSH-P-DELL.pitowers.org ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46e6918bdebsm40396015e9.9.2025.10.02.06.35.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Oct 2025 06:35:31 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Cc: David Plowman , Nick Hollinghurst , Naushir Patuck Subject: [PATCH v1 4/4] ipa: rpi: pisp: Allow an initial decompand curve to be set on the FE Date: Thu, 2 Oct 2025 14:26:07 +0100 Message-ID: <20251002133523.293413-5-naush@raspberrypi.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251002133523.293413-1-naush@raspberrypi.com> References: <20251002133523.293413-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 --- 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 b450436806e1..2c3bf7ee4d11 100644 --- a/src/ipa/rpi/controller/rpi/decompand.cpp +++ b/src/ipa/rpi/controller/rpi/decompand.cpp @@ -39,6 +39,14 @@ void Decompand::switchMode([[maybe_unused]] 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 321a561ab141..2c44b09e4192 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 03c6c47c1bd9..134fc5aab12d 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; }