{"id":26593,"url":"https://patchwork.libcamera.org/api/patches/26593/?format=json","web_url":"https://patchwork.libcamera.org/patch/26593/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20260501191400.985920-2-devve.3@gmail.com>","date":"2026-05-01T19:13:10","name":"ipa: simple: adjust: Support gamma, contrast, saturation defaults from YAML","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"9c57d3e28eb48e4ce88f46f94eb6ca77db080b2a","submitter":{"id":271,"url":"https://patchwork.libcamera.org/api/people/271/?format=json","name":"devve","email":"devve.3@gmail.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/26593/mbox/","series":[{"id":5894,"url":"https://patchwork.libcamera.org/api/series/5894/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5894","date":"2026-05-01T19:13:10","name":"ipa: simple: adjust: Support gamma, contrast, saturation defaults from YAML","version":1,"mbox":"https://patchwork.libcamera.org/series/5894/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/26593/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/26593/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 8A1C6C32F6\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  1 May 2026 19:55:29 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5A11162FD3;\n\tFri,  1 May 2026 21:55:27 +0200 (CEST)","from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com\n\t[IPv6:2a00:1450:4864:20::32d])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id F2C2C62FD3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  1 May 2026 21:14:23 +0200 (CEST)","by mail-wm1-x32d.google.com with SMTP id\n\t5b1f17b1804b1-48984d29fe3so32436085e9.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 01 May 2026 12:14:23 -0700 (PDT)","from dexps.speedport.ip\n\t(p200300eda74453f7a35e44f7d2f0427a.dip0.t-ipconnect.de.\n\t[2003:ed:a744:53f7:a35e:44f7:d2f0:427a])\n\tby smtp.gmail.com with ESMTPSA id\n\t5b1f17b1804b1-48a8eb69698sm139146305e9.1.2026.05.01.12.14.23\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 01 May 2026 12:14:23 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"GMn5CR8a\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=gmail.com; s=20251104; t=1777662863; x=1778267663;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=aooNctj7aSc+WRfu+RFfQ+bD9FOMO+I2ZoQ+botdJs0=;\n\tb=GMn5CR8aO0FRdiB8vlQRtK6+AlckL9w2i0YK6u/zdm8fx8qj+2jtU196limcUOIzj8\n\tMbpOQYpPUwRrVjswXEeLIwsOZLm8R+vCrWIjvv41xSZ8ckZMwD5EDTX3egWuhJx2I5q8\n\tRmGwsBB7jskVmRlWA0HJ7cklkA7g4ZjZJBQ48yf0XLb3hxhgFhBnJ0MULL4JSp5+tXKr\n\thPDovixLGxxhbowsoUUcZmUOSImgEIJls39XqpW1m7iuwTKbKLfyMbv/q+mZUumIQ/QK\n\tz1+cFdEsUrsGBLtN7BRC6SBXdTaqG3JQ7C3Z9H7ZGdaxvmQY+ZRWtqPskeQBaDXqtR+o\n\t2Oxw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20251104; t=1777662863; x=1778267663;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n\t:to:cc:subject:date:message-id:reply-to;\n\tbh=aooNctj7aSc+WRfu+RFfQ+bD9FOMO+I2ZoQ+botdJs0=;\n\tb=KugcHexns0oCoS7N2UQp4J/RkM2INhMvcWSJPdLPIiWFUyKNlb11VGK+3Lozof+OFf\n\t5a1cq85ZMON65qevIPoO8SZn3GgIn+Jo10Y0V4gLEU//g85w/eZHt7AhJC4cpPkQGdRa\n\t8Pw4MMNCtJwN8mtRn9llSlHi8CoSNg2g2NJ53XLdhIeORXa8s7cZmUQaW8gJEmoTRWTr\n\tCVfOJ2V6JOswn8mcemIH+sNnsV5DuFcgJdQ5N5atUgV+UNcuDafhO7BKmefsQpxZqT2R\n\tZpRfQWMYgt17biVvvZAEzJFkTbAVf/j0evlPnLXrF4rV/l7OnIBJbfNvGo+ajHXxW77w\n\t3JwQ==","X-Gm-Message-State":"AOJu0YxKxIytO3WiYdNjXnFcrD6q+BdE1uEwzduHoHAZOWMMS3b8UKxB\n\t4oWvx1B7m7mNUI+rQWvFAbFa1JZ8ssyfRVZI9lfLjzjcS2AYbDJhv0ehCnCB7w==","X-Gm-Gg":"AeBDiesc+LpELfgGPvpH5VucLVRwwKUvpd/RsOL2HQIoy0iJm7si1cOXANJuWMsRf7W\n\tbL7WcblxQUzsEBLeF17PHJczRHTJ2a3BcaxgGyscysVOmrygJRooV8EazQWtvjlibrQm3L9J5Ef\n\t/OggfXOcU51zHuUeZFK0RTp67gPfACdgRX3Rt3HtcHPVawuYTPU4EgZu3P/HCozl6d+CVRxi2gr\n\tmKe7q5XqmOk62+gMm7jN86d0dXmqHZxWVKq+Fph+Wj9d02srgcK06b72F476975zxjeil+PVN6K\n\tXDUl0n0GisWbF+WT2SObBM1TCILlfpfzCzOltyH0ZvfjX+CYyXXlQfXN/eM198hcgLubD1K0puE\n\trDLhx+SRDaRtoioVsDNRJn5qy+JQw72/z6W2armFg4I+zrGFHPRS/xo3j1BSJwJ9TYHuOfz2O/S\n\tOzCjJt1BXpOegfQ3efhGjCN4VBPsvTjcDKCz1IdTITBkFluB0cW9PlEARTn2sHHT3F42Swf8RH/\n\t+RXZAYhLOFRoy+B+ikMSor5p+6BGKOm","X-Received":"by 2002:a05:600c:444c:b0:488:e7e4:8425 with SMTP id\n\t5b1f17b1804b1-48a9866a6b4mr5539185e9.23.1777662863493; \n\tFri, 01 May 2026 12:14:23 -0700 (PDT)","From":"d3vv3 <devve.3@gmail.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"d3vv3 <devve.3@gmail.com>","Subject":"[PATCH] ipa: simple: adjust: Support gamma, contrast,\n\tsaturation defaults from YAML","Date":"Fri,  1 May 2026 21:13:10 +0200","Message-ID":"<20260501191400.985920-2-devve.3@gmail.com>","X-Mailer":"git-send-email 2.54.0","In-Reply-To":"<20260501191400.985920-1-devve.3@gmail.com>","References":"<20260501191400.985920-1-devve.3@gmail.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-Mailman-Approved-At":"Fri, 01 May 2026 21:55:24 +0200","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Read default values for gamma, contrast, and saturation from the tuning\nfile so sensors can specify different image processing defaults without\ncode changes. Falls back to prior defaults (gamma 2.2, contrast 1.0,\nsaturation 1.0) when not specified in YAML.\n\nSigned-off-by: d3vv3 <devve.3@gmail.com>\n---\n src/ipa/simple/algorithms/adjust.cpp | 26 ++++++++++++++++----------\n src/ipa/simple/algorithms/adjust.h   |  4 ++++\n 2 files changed, 20 insertions(+), 10 deletions(-)","diff":"diff --git a/src/ipa/simple/algorithms/adjust.cpp b/src/ipa/simple/algorithms/adjust.cpp\nindex 8bf39c4c..2f70519c 100644\n--- a/src/ipa/simple/algorithms/adjust.cpp\n+++ b/src/ipa/simple/algorithms/adjust.cpp\n@@ -14,6 +14,7 @@\n #include <libcamera/control_ids.h>\n \n #include \"libcamera/internal/matrix.h\"\n+#include \"libcamera/internal/yaml_parser.h\"\n \n namespace libcamera {\n \n@@ -24,24 +25,29 @@ constexpr float kDefaultSaturation = 1.0f;\n \n LOG_DEFINE_CATEGORY(IPASoftAdjust)\n \n-int Adjust::init(IPAContext &context, [[maybe_unused]] const ValueNode &tuningData)\n+int Adjust::init(IPAContext &context, const ValueNode &tuningData)\n {\n+\tdefaultGamma_ = tuningData[\"gamma\"].get<float>().value_or(kDefaultGamma);\n+\tdefaultContrast_ = tuningData[\"contrast\"].get<float>().value_or(kDefaultContrast);\n+\tdefaultSaturation_ = tuningData[\"saturation\"].get<float>().value_or(kDefaultSaturation);\n+\n \tcontext.ctrlMap[&controls::Gamma] =\n-\t\tControlInfo(0.1f, 10.0f, kDefaultGamma);\n+\t\tControlInfo(0.1f, 10.0f, defaultGamma_);\n \tcontext.ctrlMap[&controls::Contrast] =\n-\t\tControlInfo(0.0f, 2.0f, kDefaultContrast);\n+\t\tControlInfo(0.0f, 2.0f, defaultContrast_);\n \tif (context.ccmEnabled)\n \t\tcontext.ctrlMap[&controls::Saturation] =\n-\t\t\tControlInfo(0.0f, 2.0f, kDefaultSaturation);\n+\t\t\tControlInfo(0.0f, 2.0f, defaultSaturation_);\n+\n \treturn 0;\n }\n \n int Adjust::configure(IPAContext &context,\n \t\t      [[maybe_unused]] const IPAConfigInfo &configInfo)\n {\n-\tcontext.activeState.knobs.gamma = kDefaultGamma;\n-\tcontext.activeState.knobs.contrast = std::optional<float>();\n-\tcontext.activeState.knobs.saturation = std::optional<float>();\n+\tcontext.activeState.knobs.gamma = defaultGamma_;\n+\tcontext.activeState.knobs.contrast = defaultContrast_;\n+\tcontext.activeState.knobs.saturation = defaultSaturation_;\n \n \treturn 0;\n }\n@@ -107,7 +113,7 @@ void Adjust::prepare(IPAContext &context,\n \t}\n \n \tparams->gamma = 1.0 / context.activeState.knobs.gamma;\n-\tconst float contrast = context.activeState.knobs.contrast.value_or(kDefaultContrast);\n+\tconst float contrast = context.activeState.knobs.contrast.value_or(defaultContrast_);\n \tparams->contrastExp = tan(std::clamp(contrast * M_PI_4, 0.0, M_PI_2 - 0.00001));\n }\n \n@@ -121,10 +127,10 @@ void Adjust::process([[maybe_unused]] IPAContext &context,\n \tmetadata.set(controls::Gamma, gamma);\n \n \tconst auto &contrast = frameContext.contrast;\n-\tmetadata.set(controls::Contrast, contrast.value_or(kDefaultContrast));\n+\tmetadata.set(controls::Contrast, contrast.value_or(defaultContrast_));\n \n \tconst auto &saturation = frameContext.saturation;\n-\tmetadata.set(controls::Saturation, saturation.value_or(kDefaultSaturation));\n+\tmetadata.set(controls::Saturation, saturation.value_or(defaultSaturation_));\n }\n \n REGISTER_IPA_ALGORITHM(Adjust, \"Adjust\")\ndiff --git a/src/ipa/simple/algorithms/adjust.h b/src/ipa/simple/algorithms/adjust.h\nindex 49c1f26c..a836b51b 100644\n--- a/src/ipa/simple/algorithms/adjust.h\n+++ b/src/ipa/simple/algorithms/adjust.h\n@@ -43,6 +43,10 @@ public:\n \n private:\n \tvoid applySaturation(Matrix<float, 3, 3> &ccm, float saturation);\n+\n+\tfloat defaultGamma_;\n+\tfloat defaultContrast_;\n+\tfloat defaultSaturation_;\n };\n \n } /* namespace ipa::soft::algorithms */\n","prefixes":[]}