Show a patch.

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

{
    "id": 25572,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/25572/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/25572/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/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": "<20251217091408.2132770-1-barnabas.pocze@ideasonboard.com>",
    "date": "2025-12-17T09:14:08",
    "name": "[RFC,v2] ipa: rkisp1: Allow algorithms to update `ControlInfoMap`",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "0e479faaeb0dd3dcc661ae396ddfd5f36cb7104c",
    "submitter": {
        "id": 216,
        "url": "https://patchwork.libcamera.org/api/1.1/people/216/?format=api",
        "name": "Barnabás Pőcze",
        "email": "barnabas.pocze@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/25572/mbox/",
    "series": [
        {
            "id": 5668,
            "url": "https://patchwork.libcamera.org/api/1.1/series/5668/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5668",
            "date": "2025-12-17T09:14:08",
            "name": "[RFC,v2] ipa: rkisp1: Allow algorithms to update `ControlInfoMap`",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/5668/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/25572/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/25572/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 B6E8EC3257\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 17 Dec 2025 09:14:16 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id AF77761A37;\n\tWed, 17 Dec 2025 10:14:15 +0100 (CET)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0E724609DE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 17 Dec 2025 10:14:13 +0100 (CET)",
            "from pb-laptop.local (185.221.143.114.nat.pool.zt.hu\n\t[185.221.143.114])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 2D5A2581;\n\tWed, 17 Dec 2025 10:14:06 +0100 (CET)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"X/mcQ7X4\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1765962846;\n\tbh=EUW/1ZuCSGhR+s9m3XejmkVGZtdD2oeFnl24c4weO+0=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=X/mcQ7X4Sqi1CC3OB8U3wzcnUGfxVUZLpnE623hxRw4RGjJvg+QSfmxBJa2n0r+o6\n\tLR+8DAAcq0U7pmgos7pWBWEcLSmMNkvawRzJRapxXECxJNWgGT3bFK6U1IFwBlx6/Z\n\t5JUvjkFnu8AO9NLWcwEc4IK0L69mtfPTp5F/a7J0=",
        "From": "=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "Jacopo Mondi <jacopo.mondi@ideasonboard.com>,\n\tStefan Klug <stefan.klug@ideasonboard.com>",
        "Subject": "[RFC PATCH v2] ipa: rkisp1: Allow algorithms to update\n\t`ControlInfoMap`",
        "Date": "Wed, 17 Dec 2025 10:14:08 +0100",
        "Message-ID": "<20251217091408.2132770-1-barnabas.pocze@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.52.0",
        "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": "In `IPARkISP1::init()`, the `ControlInfoMap` that will be returned\nto the pipeline handler is updated after creating the algorithms;\nnaturally, since otherwise no algorithm could register its own controls.\n\nHowever, in `IPARkISP1::configure()`, the update is done before the\nalgorithms are configured. This is not ideal because this prevents\nalgorithms from correctly updating e.g. the `ControlInfo`s of their\ncontrols.\n\nWhile no algorithm is affected today, during development, it is useful\nfor various debug related controls, whose ranges depend on the exact\nconfiguration.\n\nHowever, `updateControls()` cannot simply be moved to be after the loop\nbecause it updates the limits of `FrameDurationLimits`, which `Agc::configure()`\nneeds to access. Moving it after the loop would lead to stale data\nbeing used.\n\nSo split `updateControls()` into two parts: `addControls()` and\n`updateControls()`.\n\nSigned-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n---\nchanges in v2:\n  * split `updateControls()` -> `addControls()` + `updateControls()`\n\nv1: https://patchwork.libcamera.org/patch/25557/\n---\n src/ipa/rkisp1/rkisp1.cpp | 40 ++++++++++++++++++++-------------------\n 1 file changed, 21 insertions(+), 19 deletions(-)\n\n--\n2.52.0",
    "diff": "diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\nindex fbcc39103..cd83389b8 100644\n--- a/src/ipa/rkisp1/rkisp1.cpp\n+++ b/src/ipa/rkisp1/rkisp1.cpp\n@@ -74,9 +74,9 @@ protected:\n \tstd::string logPrefix() const override;\n\n private:\n-\tvoid updateControls(const IPACameraSensorInfo &sensorInfo,\n-\t\t\t    const ControlInfoMap &sensorControls,\n-\t\t\t    ControlInfoMap *ipaControls);\n+\tvoid addControls(const IPACameraSensorInfo &sensorInfo,\n+\t\t\t const ControlInfoMap &sensorControls);\n+\tvoid updateControls(ControlInfoMap *ipaControls) const;\n \tvoid setControls(unsigned int frame);\n\n \tstd::map<unsigned int, FrameBuffer> buffers_;\n@@ -202,12 +202,14 @@ int IPARkISP1::init(const IPASettings &settings, unsigned int hwRevision,\n \t\treturn -EINVAL;\n \t}\n\n+\t/* Initialize controls. */\n+\taddControls(sensorInfo, sensorControls);\n+\n \tint ret = createAlgorithms(context_, (*data)[\"algorithms\"]);\n \tif (ret)\n \t\treturn ret;\n\n-\t/* Initialize controls. */\n-\tupdateControls(sensorInfo, sensorControls, ipaControls);\n+\tupdateControls(ipaControls);\n\n \treturn 0;\n }\n@@ -254,9 +256,6 @@ int IPARkISP1::configure(const IPAConfigInfo &ipaConfig,\n \tcontext_.configuration.sensor.size = info.outputSize;\n \tcontext_.configuration.sensor.lineDuration = info.minLineLength * 1.0s / info.pixelRate;\n\n-\t/* Update the camera controls using the new sensor settings. */\n-\tupdateControls(info, sensorControls_, ipaControls);\n-\n \t/*\n \t * When the AGC computes the new exposure values for a frame, it needs\n \t * to know the limits for exposure time and analogue gain. As it depends\n@@ -280,6 +279,9 @@ int IPARkISP1::configure(const IPAConfigInfo &ipaConfig,\n \t\t\treturn format.colourEncoding == PixelFormatInfo::ColourEncodingRAW;\n \t\t});\n\n+\t/* Update the camera controls using the new sensor settings. */\n+\taddControls(info, sensorControls_);\n+\n \tfor (auto const &a : algorithms()) {\n \t\tAlgorithm *algo = static_cast<Algorithm *>(a.get());\n\n@@ -293,6 +295,8 @@ int IPARkISP1::configure(const IPAConfigInfo &ipaConfig,\n \t\t\treturn ret;\n \t}\n\n+\tupdateControls(ipaControls);\n+\n \treturn 0;\n }\n\n@@ -386,12 +390,9 @@ void IPARkISP1::processStats(const uint32_t frame, const uint32_t bufferId,\n \tmetadataReady.emit(frame, metadata);\n }\n\n-void IPARkISP1::updateControls(const IPACameraSensorInfo &sensorInfo,\n-\t\t\t       const ControlInfoMap &sensorControls,\n-\t\t\t       ControlInfoMap *ipaControls)\n+void IPARkISP1::addControls(const IPACameraSensorInfo &sensorInfo,\n+\t\t\t    const ControlInfoMap &sensorControls)\n {\n-\tControlInfoMap::Map ctrlMap = rkisp1Controls;\n-\n \t/*\n \t * Compute exposure time limits from the V4L2_CID_EXPOSURE control\n \t * limits and the line duration.\n@@ -401,18 +402,14 @@ void IPARkISP1::updateControls(const IPACameraSensorInfo &sensorInfo,\n \tint32_t minExposure = v4l2Exposure.min().get<int32_t>() * lineDuration;\n \tint32_t maxExposure = v4l2Exposure.max().get<int32_t>() * lineDuration;\n \tint32_t defExposure = v4l2Exposure.def().get<int32_t>() * lineDuration;\n-\tctrlMap.emplace(std::piecewise_construct,\n-\t\t\tstd::forward_as_tuple(&controls::ExposureTime),\n-\t\t\tstd::forward_as_tuple(minExposure, maxExposure, defExposure));\n+\tcontext_.ctrlMap[&controls::ExposureTime] = ControlInfo(minExposure, maxExposure, defExposure);\n\n \t/* Compute the analogue gain limits. */\n \tconst ControlInfo &v4l2Gain = sensorControls.find(V4L2_CID_ANALOGUE_GAIN)->second;\n \tfloat minGain = context_.camHelper->gain(v4l2Gain.min().get<int32_t>());\n \tfloat maxGain = context_.camHelper->gain(v4l2Gain.max().get<int32_t>());\n \tfloat defGain = context_.camHelper->gain(v4l2Gain.def().get<int32_t>());\n-\tctrlMap.emplace(std::piecewise_construct,\n-\t\t\tstd::forward_as_tuple(&controls::AnalogueGain),\n-\t\t\tstd::forward_as_tuple(minGain, maxGain, defGain));\n+\tcontext_.ctrlMap[&controls::AnalogueGain] = ControlInfo(minGain, maxGain, defGain);\n\n \t/*\n \t * Compute the frame duration limits.\n@@ -441,6 +438,11 @@ void IPARkISP1::updateControls(const IPACameraSensorInfo &sensorInfo,\n \tcontext_.ctrlMap[&controls::FrameDurationLimits] =\n \t\tControlInfo(frameDurations[0], frameDurations[1],\n \t\t\t    ControlValue(Span<const int64_t, 2>{ { frameDurations[2], frameDurations[2] } }));\n+}\n+\n+void IPARkISP1::updateControls(ControlInfoMap *ipaControls) const\n+{\n+\tControlInfoMap::Map ctrlMap = rkisp1Controls;\n\n \tctrlMap.insert(context_.ctrlMap.begin(), context_.ctrlMap.end());\n \t*ipaControls = ControlInfoMap(std::move(ctrlMap), controls::controls);\n",
    "prefixes": [
        "RFC",
        "v2"
    ]
}