Show a patch.

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

{
    "id": 16280,
    "url": "https://patchwork.libcamera.org/api/patches/16280/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/16280/",
    "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": "<20220620014305.26778-10-laurent.pinchart@ideasonboard.com>",
    "date": "2022-06-20T01:43:02",
    "name": "[libcamera-devel,v4,09/12] ipa: rkisp1: Add YAML tuning file support",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "0c584337d99ccab3d32b2dafa6a06135f4f56c5d",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/16280/mbox/",
    "series": [
        {
            "id": 3191,
            "url": "https://patchwork.libcamera.org/api/series/3191/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3191",
            "date": "2022-06-20T01:42:53",
            "name": "Add tuning file support for the RkISP1 IPA module",
            "version": 4,
            "mbox": "https://patchwork.libcamera.org/series/3191/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/16280/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/16280/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 B7239BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 20 Jun 2022 01:43:39 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 68E3665649;\n\tMon, 20 Jun 2022 03:43:39 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3912665647\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 20 Jun 2022 03:43:29 +0200 (CEST)",
            "from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B9087929;\n\tMon, 20 Jun 2022 03:43:28 +0200 (CEST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1655689419;\n\tbh=cxWIUnrRlxP3K/1kfvgY5SFRsC7hk7Y0HgKsXMiv6hc=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=VgDWoH2hIUhC35KbxYQh3Wm04Gge88UE6VCbgJBgCawziCUWV14ZQdnc20ux7dEIZ\n\tBBAqNje8LN3bnZ32eG14LWxvgIwswjrIG4WEHAIkjmP6PmZnVIQYrLLTy3NhNrYRMe\n\taBH0yE6L74W5YFeu7djfJtepjxmmvznxQ6s1c7WJouJk2so5Nfi4JH8ooFAzFOUwvj\n\tDJJ9v6M0Oqthd+GR07YQCuE66nh5Vs/k8FVueQehBAd1TzZrr1Ezh2pQZLiBhu61JD\n\tlPirOaihmKPb1dbxxudiGDrLPfeItnGROOT+q2EDMyLtTqiN7wWUF8CrLHSWHjU0aS\n\toMVWbK0vyN2xg==",
            "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1655689409;\n\tbh=cxWIUnrRlxP3K/1kfvgY5SFRsC7hk7Y0HgKsXMiv6hc=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=JJyQ/eb4+Hx3EkkTer2ctvVuYn2kaKFj95G3p4iBe490C+2Yjf2ELSN52/DK2Kl7I\n\trcZBDRCfTJuBMZA2rqwhb0lGCxadx/pNpG9/kxld6gKAtBnbd6PxLkiMyUfXjZ7btA\n\teJg0yoo7cu6DLzldUNmND4SxrrckBaCh3AlPo+5c="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"JJyQ/eb4\"; dkim-atps=neutral",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Mon, 20 Jun 2022 04:43:02 +0300",
        "Message-Id": "<20220620014305.26778-10-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.35.1",
        "In-Reply-To": "<20220620014305.26778-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20220620014305.26778-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v4 09/12] ipa: rkisp1: Add YAML tuning\n\tfile support",
        "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>",
        "From": "Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>",
        "Reply-To": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "From: Florian Sylvestre <fsylvestre@baylibre.com>\n\nRetrieve root node in YAML tuning file and provide to\neach algorithm this YamlObject to allow them to grab their default\nparameters by calling init() function.\n\nSigned-off-by: Florian Sylvestre <fsylvestre@baylibre.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\nChanges since v3:\n\n- Instantiate algorithms dynamically from tuning file\n---\n src/ipa/rkisp1/rkisp1.cpp | 54 ++++++++++++++++++++++++++++++---------\n 1 file changed, 42 insertions(+), 12 deletions(-)",
    "diff": "diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\nindex 61a3bab90ccf..d052954e75b5 100644\n--- a/src/ipa/rkisp1/rkisp1.cpp\n+++ b/src/ipa/rkisp1/rkisp1.cpp\n@@ -14,6 +14,7 @@\n #include <linux/rkisp1-config.h>\n #include <linux/v4l2-controls.h>\n \n+#include <libcamera/base/file.h>\n #include <libcamera/base/log.h>\n \n #include <libcamera/control_ids.h>\n@@ -24,6 +25,7 @@\n #include <libcamera/request.h>\n \n #include \"libcamera/internal/mapped_framebuffer.h\"\n+#include \"libcamera/internal/yaml_parser.h\"\n \n #include \"algorithms/agc.h\"\n #include \"algorithms/algorithm.h\"\n@@ -41,7 +43,7 @@ using namespace std::literals::chrono_literals;\n \n namespace ipa::rkisp1 {\n \n-class IPARkISP1 : public IPARkISP1Interface\n+class IPARkISP1 : public IPARkISP1Interface, public Module\n {\n public:\n \tint init(const IPASettings &settings, unsigned int hwRevision) override;\n@@ -58,6 +60,10 @@ public:\n \tvoid fillParamsBuffer(const uint32_t frame, const uint32_t bufferId) override;\n \tvoid processStatsBuffer(const uint32_t frame, const uint32_t bufferId,\n \t\t\t\tconst ControlList &sensorControls) override;\n+\n+protected:\n+\tstd::string logPrefix() const override;\n+\n private:\n \tvoid setControls(unsigned int frame);\n \tvoid prepareMetadata(unsigned int frame, unsigned int aeState);\n@@ -81,11 +87,13 @@ private:\n \n \t/* Local parameter storage */\n \tstruct IPAContext context_;\n-\n-\t/* Maintain the algorithms used by the IPA */\n-\tstd::list<std::unique_ptr<ipa::rkisp1::Algorithm>> algorithms_;\n };\n \n+std::string IPARkISP1::logPrefix() const\n+{\n+\treturn \"rkisp1\";\n+}\n+\n int IPARkISP1::init(const IPASettings &settings, unsigned int hwRevision)\n {\n \t/* \\todo Add support for other revisions */\n@@ -121,12 +129,34 @@ int IPARkISP1::init(const IPASettings &settings, unsigned int hwRevision)\n \t\treturn -ENODEV;\n \t}\n \n-\t/* Construct our Algorithms */\n-\talgorithms_.push_back(std::make_unique<algorithms::Agc>());\n-\talgorithms_.push_back(std::make_unique<algorithms::Awb>());\n-\talgorithms_.push_back(std::make_unique<algorithms::BlackLevelCorrection>());\n+\t/* Load the tuning data file. */\n+\tFile file(settings.configurationFile.c_str());\n+\tif (!file.open(File::OpenModeFlag::ReadOnly)) {\n+\t\tint ret = file.error();\n+\t\tLOG(IPARkISP1, Error)\n+\t\t\t<< \"Failed to open configuration file \"\n+\t\t\t<< settings.configurationFile << \": \" << strerror(-ret);\n+\t\treturn ret;\n+\t}\n \n-\treturn 0;\n+\tstd::unique_ptr<libcamera::YamlObject> data = YamlParser::parse(file);\n+\tif (!data)\n+\t\treturn -EINVAL;\n+\n+\tunsigned int version = (*data)[\"version\"].get<uint32_t>(0);\n+\tif (version != 1) {\n+\t\tLOG(IPARkISP1, Error)\n+\t\t\t<< \"Invalid tuning file version \" << version;\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (!data->contains(\"algorithms\")) {\n+\t\tLOG(IPARkISP1, Error)\n+\t\t\t<< \"Tuning file doesn't contain any algorithm\";\n+\t\treturn -EINVAL;\n+\t}\n+\n+\treturn createAlgorithms(context_, (*data)[\"algorithms\"]);\n }\n \n int IPARkISP1::start()\n@@ -197,7 +227,7 @@ int IPARkISP1::configure([[maybe_unused]] const IPACameraSensorInfo &info,\n \n \tcontext_.frameContext.frameCount = 0;\n \n-\tfor (auto const &algo : algorithms_) {\n+\tfor (auto const &algo : algorithms()) {\n \t\tint ret = algo->configure(context_, info);\n \t\tif (ret)\n \t\t\treturn ret;\n@@ -251,7 +281,7 @@ void IPARkISP1::fillParamsBuffer(const uint32_t frame, const uint32_t bufferId)\n \t/* Prepare parameters buffer. */\n \tmemset(params, 0, sizeof(*params));\n \n-\tfor (auto const &algo : algorithms_)\n+\tfor (auto const &algo : algorithms())\n \t\talgo->prepare(context_, params);\n \n \tparamsBufferReady.emit(frame);\n@@ -272,7 +302,7 @@ void IPARkISP1::processStatsBuffer(const uint32_t frame, const uint32_t bufferId\n \n \tunsigned int aeState = 0;\n \n-\tfor (auto const &algo : algorithms_)\n+\tfor (auto const &algo : algorithms())\n \t\talgo->process(context_, nullptr, stats);\n \n \tsetControls(frame);\n",
    "prefixes": [
        "libcamera-devel",
        "v4",
        "09/12"
    ]
}