Show a patch.

GET /api/patches/26665/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 26665,
    "url": "https://patchwork.libcamera.org/api/patches/26665/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/26665/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/projects/1/?format=api",
        "name": "libcamera",
        "link_name": "libcamera",
        "list_id": "libcamera_core",
        "list_email": "libcamera-devel@lists.libcamera.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20260506230722.1041596-9-devve.3@gmail.com>",
    "date": "2026-05-06T23:07:20",
    "name": "[v2,08/10] ipa: simple: agc: Read exposure target and gain from YAML",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "f36406881a44b7ff9b571f3833512455d8eac4f1",
    "submitter": {
        "id": 271,
        "url": "https://patchwork.libcamera.org/api/people/271/?format=api",
        "name": "devve",
        "email": "devve.3@gmail.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/26665/mbox/",
    "series": [
        {
            "id": 5915,
            "url": "https://patchwork.libcamera.org/api/series/5915/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5915",
            "date": "2026-05-06T23:07:12",
            "name": "OV01A10 sensor support and simple IPA improvements",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/5915/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/26665/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/26665/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 E1BB0C3305\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  6 May 2026 23:07:41 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1CC5E6302D;\n\tThu,  7 May 2026 01:07:40 +0200 (CEST)",
            "from mail-qk1-x72e.google.com (mail-qk1-x72e.google.com\n\t[IPv6:2607:f8b0:4864:20::72e])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 20D23630BB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  7 May 2026 01:07:36 +0200 (CEST)",
            "by mail-qk1-x72e.google.com with SMTP id\n\taf79cd13be357-8e8c0c2d2bcso34900385a.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 06 May 2026 16:07:36 -0700 (PDT)",
            "from dexps.speedport.ip\n\t(p200300eda74453cf3cf3f7929e513b94.dip0.t-ipconnect.de.\n\t[2003:ed:a744:53cf:3cf3:f792:9e51:3b94])\n\tby smtp.gmail.com with ESMTPSA id\n\taf79cd13be357-8fc2c25324esm2035266385a.23.2026.05.06.16.07.33\n\tfor <libcamera-devel@lists.libcamera.org>\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 06 May 2026 16:07:34 -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=\"hRk4KXZp\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=gmail.com; s=20251104; t=1778108855; x=1778713655;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:to:from:from:to:cc:subject:date:message-id\n\t:reply-to; bh=RzzlD4NGXBC8Ir7lyUZbzdtSSu1wXbM8QJB9JRJvLYY=;\n\tb=hRk4KXZpZVnPg1SVmCl0mjO/SP+PUPGA7FVBqDUgL5lLmVuakqmdST74wUk8zEhtNl\n\tEOyUkF5LaCTsaFukGR584fPHUAmhZtwm7Gux5LcFouhpRjhWFs9ebDCGHPgom/7cvweb\n\t9l7BvgyLQOFXEHLSrEeVOCmHPOniwWY89wNgbLXSTQX6H+FX+9bEjUJlQHjyWHzQaSdn\n\tcwRc2d3NP+hx91lxLgU/jn9DHMtjhk6WrhaTvMEHQzqKTknrWLlZjshgleYXApYHSvlB\n\tKplsHKiY8IBt/zWQKDINQ4F5mOv7t4nfuoiIe/vwA2GNkg+Q4Z6oAG4X0E0hNQAQiJ99\n\tm1ZA==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20251104; t=1778108855; x=1778713655;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to\n\t:cc:subject:date:message-id:reply-to;\n\tbh=RzzlD4NGXBC8Ir7lyUZbzdtSSu1wXbM8QJB9JRJvLYY=;\n\tb=PsfbwYhv6UqfIoRNyH2+MGfVIBVGxJARFE0s5PNQDsVZnGRlhduhwbg/1EYxNcIYxz\n\t+mI61Q98iyckyL6Ocf10HsH8i3ynwTD8ekQN2jsMNFyHQWUynE1uWJxNDK15aK/kBpnR\n\tk9/mVF48jLM4inFQ7DlAj/yi5FpcC/4MVt+WU8+dK4geZxA2DGQUdH22vW1pcTrqDEhr\n\tdbfj/x6CJNFlkqQEqhlcV7vMqLGqR1cqRgwklldHMULL6s3tvyulEMqjbEFKAy3f4afs\n\tbNWKWhELWWnTA5UrQvigJSmdj4ZLz2NgcDYgBN+wF1mZvzNDWMorTzRdIKFqiQfPAT1r\n\tuQfQ==",
        "X-Gm-Message-State": "AOJu0YxUhcs1Uo9POhgtQNInQQqEpoEzvR+w9QNXE3aCQgnI5g2IXSPy\n\tyHVTn3Z704CEDGEOWQV9jYEhepGjZyunFkuoXNAWTVBl9MYSryDpn2340qLUlg==",
        "X-Gm-Gg": "AeBDievbLRQwxWKr1U+YGyw1nnDJduogzCnUZQ/ujTPOF9/4X9NQ7dhw7OHnjSciNbY\n\tzj6eaLDxwqtzd2/AELzHc8CUKaXFGGLndhDMOj7HN3TNuoRlcifmZuptdu75mmtD/l4tn4Nc9Jq\n\t+JK6v94evdjl3XK8FPXuk66F5Qq3g7d7njzee5Q0Jc3wiNIa6lgkqy//fG47X5eP+An6ycLhwKg\n\tpR/flOzw4b3PSXKG8/6wEiH0AfH04a3IqSkLBI8xiHiTs/HFXHJ52ZdxLKwibt+eu/hNt0+VAQo\n\tiwGlvYd2jWUzXtPp+pRWMn+UCj6N3pAvwBgLot7ETg/JiWW+m8pl4htyGOYhBUlJ6Gea+I2Gxxt\n\tXQoHeV5g/bXvPxwnE1m2zbV7XjgT++FajSzJKuerE1I+ltrAXwc6GwNM7q7QCEfAHZegSTawI+Q\n\txnb6uiVzzgRKzoQcq5XVlwa0jhSD1wz/C9UTDZLnYsrAvyaEcyJJwSHCZSJGPBlQdLbxTdsP7SP\n\tZwyD4hYQSzsXJ77UkDogPJycjthzKuY",
        "X-Received": "by 2002:a05:620a:29cc:b0:8ed:d906:a8da with SMTP id\n\taf79cd13be357-904d4a61b92mr784088785a.18.1778108855000; \n\tWed, 06 May 2026 16:07:35 -0700 (PDT)",
        "From": "d3vv3 <devve.3@gmail.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Subject": "[PATCH v2 08/10] ipa: simple: agc: Read exposure target and gain\n\tfrom YAML",
        "Date": "Thu,  7 May 2026 01:07:20 +0200",
        "Message-ID": "<20260506230722.1041596-9-devve.3@gmail.com>",
        "X-Mailer": "git-send-email 2.54.0",
        "In-Reply-To": "<20260506230722.1041596-1-devve.3@gmail.com>",
        "References": "<20260506230722.1041596-1-devve.3@gmail.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "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": "Replace the hardcoded kExposureOptimal, kExposureSatisfactory, and\nkExpProportionalGain constants with member variables read from the\ntuning file as exposureTarget, hysteresis, and proportionalGain.\nDefaults match the previous values (2.5, 0.2, 0.04).\n\nThe constants are renamed to match their YAML keys and to use standard\ncontrol-theory terminology:\n\n- kExposureOptimal -> exposureTarget: \"optimal\" implies a single\n  universally correct value; \"target\" is the conventional ISP/AGC term\n  for the setpoint the controller drives towards and is sensor-dependent.\n\n- kExposureSatisfactory -> hysteresis: the old name described the effect\n  (exposure is satisfactory within this band) rather than the mechanism.\n  \"hysteresis\" is the standard term for a deadband that prevents\n  oscillation around a setpoint.\n\n- kExpProportionalGain -> proportionalGain: drops the redundant kExp\n  prefix and matches the YAML key name directly.\n\nSigned-off-by: d3vv3 <devve.3@gmail.com>\n---\n src/ipa/simple/algorithms/agc.cpp | 33 ++++++++++++++++++++-----------\n src/ipa/simple/algorithms/agc.h   |  8 ++++++++\n 2 files changed, 30 insertions(+), 11 deletions(-)",
    "diff": "diff --git a/src/ipa/simple/algorithms/agc.cpp b/src/ipa/simple/algorithms/agc.cpp\nindex ac977d5f..66618d0f 100644\n--- a/src/ipa/simple/algorithms/agc.cpp\n+++ b/src/ipa/simple/algorithms/agc.cpp\n@@ -28,45 +28,56 @@ static constexpr unsigned int kExposureBinsCount = 5;\n \n /*\n  * The exposure is optimal when the mean sample value of the histogram is\n- * in the middle of the range.\n+ * in the middle of the range. Overridable via YAML exposureTarget.\n  */\n-static constexpr float kExposureOptimal = kExposureBinsCount / 2.0;\n+static constexpr float kExposureTargetDefault = kExposureBinsCount / 2.0;\n \n /*\n  * This implements the hysteresis for the exposure adjustment.\n  * It is small enough to have the exposure close to the optimal, and is big\n  * enough to prevent the exposure from wobbling around the optimal value.\n  */\n-static constexpr float kExposureSatisfactory = 0.2;\n+static constexpr float kHysteresisDefault = 0.2;\n \n /*\n  * Proportional gain for exposure/gain adjustment. Maps the MSV error to a\n  * multiplicative correction factor:\n  *\n- *   factor = 1.0 + kExpProportionalGain * error\n+ *   factor = 1.0 + proportionalGain_ * error\n  *\n- * With kExpProportionalGain = 0.04:\n+ * With proportionalGain_ = 0.04:\n  *   - max error ~2.5 -> factor 1.10 (~10% step, same as before)\n  *   - error 1.0      -> factor 1.04 (~4% step)\n  *   - error 0.3      -> factor 1.012 (~1.2% step)\n  *\n- * This replaces the fixed 10% bang-bang step with a proportional correction\n- * that converges smoothly and avoids overshooting near the target.\n+ * Overridable via YAML proportionalGain.\n  */\n-static constexpr float kExpProportionalGain = 0.04;\n+static constexpr float kProportionalGainDefault = 0.04;\n \n Agc::Agc()\n {\n }\n \n+int Agc::init([[maybe_unused]] IPAContext &context, const ValueNode &tuningData)\n+{\n+\texposureTarget_ = tuningData[\"exposureTarget\"].get<float>()\n+\t\t.value_or(kExposureTargetDefault);\n+\thysteresis_ = tuningData[\"hysteresis\"].get<float>()\n+\t\t.value_or(kHysteresisDefault);\n+\tproportionalGain_ = tuningData[\"proportionalGain\"].get<float>()\n+\t\t.value_or(kProportionalGainDefault);\n+\n+\treturn 0;\n+}\n+\n void Agc::updateExposure(IPAContext &context, IPAFrameContext &frameContext, double exposureMSV)\n {\n \tint32_t &exposure = frameContext.sensor.exposure;\n \tdouble &again = frameContext.sensor.gain;\n \n-\tdouble error = kExposureOptimal - exposureMSV;\n+\tdouble error = exposureTarget_ - exposureMSV;\n \n-\tif (std::abs(error) <= kExposureSatisfactory)\n+\tif (std::abs(error) <= hysteresis_)\n \t\treturn;\n \n \t/*\n@@ -74,7 +85,7 @@ void Agc::updateExposure(IPAContext &context, IPAFrameContext &frameContext, dou\n \t * determines the direction: positive error means too dark (increase),\n \t * negative means too bright (decrease).\n \t */\n-\tfloat factor = 1.0f + static_cast<float>(error) * kExpProportionalGain;\n+\tfloat factor = 1.0f + static_cast<float>(error) * proportionalGain_;\n \n \tif (factor > 1.0f) {\n \t\t/* Scene too dark: increase exposure first, then gain. */\ndiff --git a/src/ipa/simple/algorithms/agc.h b/src/ipa/simple/algorithms/agc.h\nindex 112d9f5a..b8ed542b 100644\n--- a/src/ipa/simple/algorithms/agc.h\n+++ b/src/ipa/simple/algorithms/agc.h\n@@ -7,6 +7,8 @@\n \n #pragma once\n \n+#include <libcamera/internal/yaml_parser.h>\n+\n #include \"algorithm.h\"\n \n namespace libcamera {\n@@ -19,6 +21,8 @@ public:\n \tAgc();\n \t~Agc() = default;\n \n+\tint init(IPAContext &context, const ValueNode &tuningData) override;\n+\n \tvoid process(IPAContext &context, const uint32_t frame,\n \t\t     IPAFrameContext &frameContext,\n \t\t     const SwIspStats *stats,\n@@ -26,6 +30,10 @@ public:\n \n private:\n \tvoid updateExposure(IPAContext &context, IPAFrameContext &frameContext, double exposureMSV);\n+\n+\tfloat exposureTarget_;\n+\tfloat hysteresis_;\n+\tfloat proportionalGain_;\n };\n \n } /* namespace ipa::soft::algorithms */\n",
    "prefixes": [
        "v2",
        "08/10"
    ]
}