From patchwork Sun Aug 16 20:42:57 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Alexander X-Patchwork-Id: 27775 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 CD8C9C3308 for ; Mon, 17 Aug 2026 07:30:14 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7C4396819F; Mon, 17 Aug 2026 09:30:10 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=inspiredexperts.com header.i=@inspiredexperts.com header.b="B5Adp4Zc"; dkim-atps=neutral Received: from s1.inspiredexperts.com (s1.inspiredexperts.com [162.243.156.162]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 75AEC6819C for ; Sun, 16 Aug 2026 22:43:03 +0200 (CEST) Received: from localhost (s1.inspiredexperts.com [127.0.0.1]) by s1.inspiredexperts.com (Postfix) with ESMTP id 55209D2D699 for ; Sun, 16 Aug 2026 14:43:00 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inspiredexperts.com; s=default; t=1786912981; bh=QwIf2eZbr8ya+vN+Juvm2CPrjnVewplyNOaJdXWnhfg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=B5Adp4ZcjcTG11uL7o8HdY7DXOa/cW26achuGIjICjH7b+bilpoKxpXdfGwLO+qGd uj4S1TiA8ap30zVkiSpzbxkKJnu3Ex+PTLoXrqIZpy92clDGkL9CvzBXPMs5b3uawM AxmdUL3mO2+278XQit5zlKA7F8xy1MUH+m+BDB/A= From: James Alexander To: libcamera-devel@lists.libcamera.org Subject: [PATCH 1/3] ipa: simple: adjust: Read defaults from tuning Date: Sun, 16 Aug 2026 14:42:57 -0600 Message-ID: <20260816204259.2845517-2-opensource@inspiredexperts.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260816204259.2845517-1-opensource@inspiredexperts.com> References: <20260816204259.2845517-1-opensource@inspiredexperts.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on s1.inspiredexperts.com X-Mailman-Approved-At: Mon, 17 Aug 2026 09:30:05 +0200 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" Simple IPA tuning files can enable Adjust, but they cannot choose the starting gamma, contrast or saturation. That leaves sensor-specific tuning unable to set useful defaults without application controls. Read optional values from the Adjust section, clamp them to the existing control ranges and use them as both control defaults and initial state. Existing tuning files keep the current defaults. Build-tested against libcamera base b8910c9a4961 and hardware-tested as part of the complete patch set on the target HP Spectre. Signed-off-by: James Alexander diff --git a/src/ipa/simple/algorithms/adjust.cpp b/src/ipa/simple/algorithms/adjust.cpp index 8bf39c4..be29127 100644 --- a/src/ipa/simple/algorithms/adjust.cpp +++ b/src/ipa/simple/algorithms/adjust.cpp @@ -24,24 +24,38 @@ constexpr float kDefaultSaturation = 1.0f; LOG_DEFINE_CATEGORY(IPASoftAdjust) -int Adjust::init(IPAContext &context, [[maybe_unused]] const ValueNode &tuningData) +int Adjust::init(IPAContext &context, const ValueNode &tuningData) { + auto gamma = tuningData["gamma"].get(); + if (gamma.has_value()) + defaultGamma_ = std::clamp(gamma.value(), 0.1f, 10.0f); + + auto contrast = tuningData["contrast"].get(); + if (contrast.has_value()) + defaultContrast_ = std::clamp(contrast.value(), 0.0f, 2.0f); + + auto saturation = tuningData["saturation"].get(); + if (saturation.has_value()) + defaultSaturation_ = std::clamp(saturation.value(), 0.0f, 2.0f); + context.ctrlMap[&controls::Gamma] = - ControlInfo(0.1f, 10.0f, kDefaultGamma); + ControlInfo(0.1f, 10.0f, defaultGamma_); context.ctrlMap[&controls::Contrast] = - ControlInfo(0.0f, 2.0f, kDefaultContrast); + ControlInfo(0.0f, 2.0f, defaultContrast_); if (context.ccmEnabled) context.ctrlMap[&controls::Saturation] = - ControlInfo(0.0f, 2.0f, kDefaultSaturation); + ControlInfo(0.0f, 2.0f, defaultSaturation_); return 0; } int Adjust::configure(IPAContext &context, [[maybe_unused]] const IPAConfigInfo &configInfo) { - context.activeState.knobs.gamma = kDefaultGamma; - context.activeState.knobs.contrast = std::optional(); + context.activeState.knobs.gamma = defaultGamma_; + context.activeState.knobs.contrast = defaultContrast_; context.activeState.knobs.saturation = std::optional(); + if (context.ccmEnabled) + context.activeState.knobs.saturation = defaultSaturation_; return 0; } diff --git a/src/ipa/simple/algorithms/adjust.h b/src/ipa/simple/algorithms/adjust.h index 49c1f26..1968b7c 100644 --- a/src/ipa/simple/algorithms/adjust.h +++ b/src/ipa/simple/algorithms/adjust.h @@ -7,6 +7,8 @@ #pragma once +#include + #include "libcamera/internal/matrix.h" #include @@ -43,6 +45,10 @@ public: private: void applySaturation(Matrix &ccm, float saturation); + + float defaultGamma_ = kDefaultGamma; + float defaultContrast_ = 1.0f; + float defaultSaturation_ = 1.0f; }; } /* namespace ipa::soft::algorithms */