Show a patch.

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

{
    "id": 27490,
    "url": "https://patchwork.libcamera.org/api/patches/27490/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/27490/",
    "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": "<20260723154327.1357866-41-barnabas.pocze@ideasonboard.com>",
    "date": "2026-07-23T15:43:23",
    "name": "[RFC,v2,40/43] ipa: simple: Move sensor helper and controls to context",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "35738372efd515558a2dda8808597e716f5c3b6a",
    "submitter": {
        "id": 216,
        "url": "https://patchwork.libcamera.org/api/people/216/?format=api",
        "name": "Barnabás Pőcze",
        "email": "barnabas.pocze@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/27490/mbox/",
    "series": [
        {
            "id": 6075,
            "url": "https://patchwork.libcamera.org/api/series/6075/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=6075",
            "date": "2026-07-23T15:42:43",
            "name": "ipa: libipa: agc rework",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/6075/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/27490/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/27490/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 C95A7C333B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 23 Jul 2026 15:44:27 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 50DE067F7B;\n\tThu, 23 Jul 2026 17:44:27 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9CBDB67ECC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 23 Jul 2026 17:43:40 +0200 (CEST)",
            "from pb-laptop.local (185.182.215.156.nat.pool.zt.hu\n\t[185.182.215.156])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C77D02C0B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 23 Jul 2026 17:42:39 +0200 (CEST)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"Mp+3bVAh\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1784821359;\n\tbh=WrBlfneeoKPFe1wqh6QNu0tcSBpaKix0eDIGnf41kDE=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=Mp+3bVAh9mWzW4/+BnR6Ak3+Ld9ojjRP7SLDvKq8mtCpls5gDEnUjC590l8MxcHSa\n\tET4iC+xxdeuW96FyoV/NCOkyPjsfzy7/bhmt+jQ/aXJL+ORjbAoxZSim8wjvDhD9Vv\n\tovJWSVhKOq7zk5qowPmDgoiUAjVxBjzk2obmOb7U=",
        "From": "=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Subject": "[RFC PATCH v2 40/43] ipa: simple: Move sensor helper and controls to\n\tcontext",
        "Date": "Thu, 23 Jul 2026 17:43:23 +0200",
        "Message-ID": "<20260723154327.1357866-41-barnabas.pocze@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.55.0",
        "In-Reply-To": "<20260723154327.1357866-1-barnabas.pocze@ideasonboard.com>",
        "References": "<20260723154327.1357866-1-barnabas.pocze@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "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": "So that algorithms can access it.\n\nSigned-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n---\n src/ipa/simple/algorithms/blc.cpp | 12 +++++++++++\n src/ipa/simple/ipa_context.h      |  4 ++++\n src/ipa/simple/soft_simple.cpp    | 34 ++++++++++---------------------\n 3 files changed, 27 insertions(+), 23 deletions(-)",
    "diff": "diff --git a/src/ipa/simple/algorithms/blc.cpp b/src/ipa/simple/algorithms/blc.cpp\nindex 677be56ed6..793c6663df 100644\n--- a/src/ipa/simple/algorithms/blc.cpp\n+++ b/src/ipa/simple/algorithms/blc.cpp\n@@ -42,6 +42,18 @@ int BlackLevel::configure(IPAContext &context,\n {\n \tif (definedLevel_.has_value())\n \t\tcontext.configuration.black.level = definedLevel_;\n+\telse if (context.camHelper) {\n+\t\tif (auto bl = context.camHelper->blackLevel()) {\n+\t\t\t/*\n+\t\t\t * The black level from CameraSensorHelper is a 16 bit value, software ISP\n+\t\t\t * works with 8 bit pixel values, both regardless of the actual\n+\t\t\t * sensor pixel width. Hence we obtain the pixel-based black value\n+\t\t\t * by dividing the value from the helper by 256.\n+\t\t\t */\n+\t\t\tcontext.configuration.black.level = *bl / 256;\n+\t\t}\n+\t}\n+\n \tcontext.activeState.blc.level =\n \t\tcontext.configuration.black.level.value_or(16);\n \treturn 0;\ndiff --git a/src/ipa/simple/ipa_context.h b/src/ipa/simple/ipa_context.h\nindex 980dc93cc4..96b3c5b21d 100644\n--- a/src/ipa/simple/ipa_context.h\n+++ b/src/ipa/simple/ipa_context.h\n@@ -8,6 +8,7 @@\n #pragma once\n \n #include <array>\n+#include <memory>\n #include <optional>\n #include <stdint.h>\n \n@@ -16,6 +17,7 @@\n #include \"libcamera/internal/matrix.h\"\n #include \"libcamera/internal/vector.h\"\n \n+#include <libipa/camera_sensor_helper.h>\n #include <libipa/fc_queue.h>\n \n #include \"core_ipa_interface.h\"\n@@ -90,6 +92,8 @@ struct IPAContext {\n \t}\n \n \tIPACameraSensorInfo sensorInfo;\n+\tControlInfoMap sensorControls;\n+\tstd::unique_ptr<CameraSensorHelper> camHelper;\n \tIPASessionConfiguration configuration;\n \tIPAActiveState activeState;\n \tFCQueue<IPAFrameContext> frameContexts;\ndiff --git a/src/ipa/simple/soft_simple.cpp b/src/ipa/simple/soft_simple.cpp\nindex a38fcff7d8..717b44cf6d 100644\n--- a/src/ipa/simple/soft_simple.cpp\n+++ b/src/ipa/simple/soft_simple.cpp\n@@ -77,8 +77,6 @@ private:\n \n \tDebayerParams *params_;\n \tSwIspStats *stats_;\n-\tstd::unique_ptr<CameraSensorHelper> camHelper_;\n-\tControlInfoMap sensorInfoMap_;\n \n \t/* Local parameter storage */\n \tstruct IPAContext context_;\n@@ -100,8 +98,8 @@ int IPASoftSimple::init(const IPASettings &settings,\n \t\t\tControlInfoMap *ipaControls,\n \t\t\tbool *ccmEnabled)\n {\n-\tcamHelper_ = CameraSensorHelperFactoryBase::create(settings.sensorModel);\n-\tif (!camHelper_) {\n+\tcontext_.camHelper = CameraSensorHelperFactoryBase::create(settings.sensorModel);\n+\tif (!context_.camHelper) {\n \t\tLOG(IPASoft, Warning)\n \t\t\t<< \"Failed to create camera sensor helper for \"\n \t\t\t<< settings.sensorModel;\n@@ -202,10 +200,10 @@ int IPASoftSimple::init(const IPASettings &settings,\n \n int IPASoftSimple::configure(const IPAConfigInfo &configInfo)\n {\n-\tsensorInfoMap_ = configInfo.sensorControls;\n+\tcontext_.sensorControls = configInfo.sensorControls;\n \n-\tconst ControlInfo &exposureInfo = sensorInfoMap_.find(V4L2_CID_EXPOSURE)->second;\n-\tconst ControlInfo &gainInfo = sensorInfoMap_.find(V4L2_CID_ANALOGUE_GAIN)->second;\n+\tconst ControlInfo &exposureInfo = context_.sensorControls.find(V4L2_CID_EXPOSURE)->second;\n+\tconst ControlInfo &gainInfo = context_.sensorControls.find(V4L2_CID_ANALOGUE_GAIN)->second;\n \n \t/* Clear the IPA context before the streaming session. */\n \tcontext_.configuration = {};\n@@ -225,24 +223,14 @@ int IPASoftSimple::configure(const IPAConfigInfo &configInfo)\n \tint32_t againMax = gainInfo.max().get<int32_t>();\n \tint32_t againDef = gainInfo.def().get<int32_t>();\n \n-\tif (camHelper_) {\n-\t\tcontext_.configuration.agc.againMin = camHelper_->gain(againMin);\n-\t\tcontext_.configuration.agc.againMax = camHelper_->gain(againMax);\n+\tif (context_.camHelper) {\n+\t\tcontext_.configuration.agc.againMin = context_.camHelper->gain(againMin);\n+\t\tcontext_.configuration.agc.againMax = context_.camHelper->gain(againMax);\n \t\tcontext_.configuration.agc.again10 = std::max(context_.configuration.agc.againMin, 1.0);\n \t\tcontext_.configuration.agc.againMinStep =\n \t\t\t(context_.configuration.agc.againMax -\n \t\t\t context_.configuration.agc.againMin) /\n \t\t\t100.0;\n-\t\tif (camHelper_->blackLevel().has_value()) {\n-\t\t\t/*\n-\t\t\t * The black level from camHelper_ is a 16 bit value, software ISP\n-\t\t\t * works with 8 bit pixel values, both regardless of the actual\n-\t\t\t * sensor pixel width. Hence we obtain the pixel-based black value\n-\t\t\t * by dividing the value from the helper by 256.\n-\t\t\t */\n-\t\t\tcontext_.configuration.black.level =\n-\t\t\t\tcamHelper_->blackLevel().value() / 256;\n-\t\t}\n \t} else {\n \t\tcontext_.configuration.agc.againMax = againMax;\n \t\tcontext_.configuration.agc.again10 = againDef;\n@@ -303,15 +291,15 @@ void IPASoftSimple::processStats(const uint32_t frame,\n \tIPAFrameContext &frameContext = context_.frameContexts.get(frame);\n \n \tstd::tie(frameContext.sensor.exposure, frameContext.sensor.gain)\n-\t\t= agc::extractControls(sensorControls, camHelper_.get());\n+\t\t= agc::extractControls(sensorControls, context_.camHelper.get());\n \n \tControlList metadata(controls::controls);\n \tfor (const auto &algo : algorithms())\n \t\talgo->process(context_, frame, frameContext, stats_, metadata);\n \tmetadataReady.emit(frame, metadata);\n \n-\tControlList ctrls(sensorInfoMap_);\n-\tagc::prepareControls(ctrls, camHelper_.get(), frameContext.agc.exposure, frameContext.agc.gain);\n+\tControlList ctrls(context_.sensorControls);\n+\tagc::prepareControls(ctrls, context_.camHelper.get(), frameContext.agc.exposure, frameContext.agc.gain);\n \tsetSensorControls.emit(ctrls);\n }\n \n",
    "prefixes": [
        "RFC",
        "v2",
        "40/43"
    ]
}