Show a patch.

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

{
    "id": 22360,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/22360/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/22360/",
    "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": "<20241216154124.203650-15-stefan.klug@ideasonboard.com>",
    "date": "2024-12-16T15:40:54",
    "name": "[v4,14/20] pipeline: rkisp1: Refactor path validation",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "1b7f93524a5fe5119c9e4e0bc12c862975840d23",
    "submitter": {
        "id": 184,
        "url": "https://patchwork.libcamera.org/api/1.1/people/184/?format=api",
        "name": "Stefan Klug",
        "email": "stefan.klug@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/22360/mbox/",
    "series": [
        {
            "id": 4896,
            "url": "https://patchwork.libcamera.org/api/1.1/series/4896/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4896",
            "date": "2024-12-16T15:40:40",
            "name": "rkisp1: Fix aspect ratio and ScalerCrop",
            "version": 4,
            "mbox": "https://patchwork.libcamera.org/series/4896/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/22360/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/22360/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 5975FC32F6\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 16 Dec 2024 15:42:28 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D737667F93;\n\tMon, 16 Dec 2024 16:42:27 +0100 (CET)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 933E467F89\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 16 Dec 2024 16:42:24 +0100 (CET)",
            "from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:bfdf:3a3c:e45:66e3])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 028FC82A;\n\tMon, 16 Dec 2024 16:41:47 +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=\"D562BQ7b\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1734363708;\n\tbh=XQCiSH9/f2fMfG8OC9CGyFb3yQfO39oUFMgZMLC0aYY=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=D562BQ7besMaqT+Q0XwqVrFg+ktXFAM8DOqRmQuUudyFrdbw3miz0mSn4r7u1kM3Z\n\tuwNXH0QncA5y2P8pJChOdR45pQaqDmPajZiNtfTMDGfIhN3LFA7DOK1lnv5ueT4CeA\n\t7KAB/97Ds9GKT2XPRtVhxdCyy4lVi4NFhmyUNMlk=",
        "From": "Stefan Klug <stefan.klug@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "Stefan Klug <stefan.klug@ideasonboard.com>,\n\tJacopo Mondi <jacopo.mondi@ideasonboard.com>,\n\tPaul Elder <paul.elder@ideasonboard.com>",
        "Subject": "[PATCH v4 14/20] pipeline: rkisp1: Refactor path validation",
        "Date": "Mon, 16 Dec 2024 16:40:54 +0100",
        "Message-ID": "<20241216154124.203650-15-stefan.klug@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.43.0",
        "In-Reply-To": "<20241216154124.203650-1-stefan.klug@ideasonboard.com>",
        "References": "<20241216154124.203650-1-stefan.klug@ideasonboard.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": "Refactor validation code to prepare for extensions in the upcoming\npatches. Code duplication is reduced by moving parts of the validation\nlogic into a lambda function. This patch does not include any functional\nchanges.\n\nSigned-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\nSigned-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n---\nChanges in v3:\n- Added this patch\n---\n src/libcamera/pipeline/rkisp1/rkisp1.cpp | 35 +++++++++++++-----------\n 1 file changed, 19 insertions(+), 16 deletions(-)",
    "diff": "diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\nindex abe2dce0024d..18038226912a 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n@@ -558,50 +558,53 @@ CameraConfiguration::Status RkISP1CameraConfiguration::validate()\n \tif (config_.size() == 2 && fitsAllPaths(config_[0]))\n \t\tstd::reverse(order.begin(), order.end());\n \n+\tauto validateConfig = [&](StreamConfiguration &cfg, RkISP1Path *path,\n+\t\t\t\t  Stream *stream, Status expectedStatus) {\n+\t\tStreamConfiguration tryCfg = cfg;\n+\t\tif (path->validate(sensor, sensorConfig, &tryCfg) != expectedStatus)\n+\t\t\treturn false;\n+\n+\t\tcfg = tryCfg;\n+\t\tcfg.setStream(stream);\n+\t\treturn true;\n+\t};\n+\n \tbool mainPathAvailable = true;\n \tbool selfPathAvailable = data_->selfPath_;\n+\tRkISP1Path *mainPath = data_->mainPath_;\n+\tRkISP1Path *selfPath = data_->selfPath_;\n+\tStream *mainPathStream = const_cast<Stream *>(&data_->mainPathStream_);\n+\tStream *selfPathStream = const_cast<Stream *>(&data_->selfPathStream_);\n \tfor (unsigned int index : order) {\n \t\tStreamConfiguration &cfg = config_[index];\n \n \t\t/* Try to match stream without adjusting configuration. */\n \t\tif (mainPathAvailable) {\n-\t\t\tStreamConfiguration tryCfg = cfg;\n-\t\t\tif (data_->mainPath_->validate(sensor, sensorConfig, &tryCfg) == Valid) {\n+\t\t\tif (validateConfig(cfg, mainPath, mainPathStream, Valid)) {\n \t\t\t\tmainPathAvailable = false;\n-\t\t\t\tcfg = tryCfg;\n-\t\t\t\tcfg.setStream(const_cast<Stream *>(&data_->mainPathStream_));\n \t\t\t\tcontinue;\n \t\t\t}\n \t\t}\n \n \t\tif (selfPathAvailable) {\n-\t\t\tStreamConfiguration tryCfg = cfg;\n-\t\t\tif (data_->selfPath_->validate(sensor, sensorConfig, &tryCfg) == Valid) {\n+\t\t\tif (validateConfig(cfg, selfPath, selfPathStream, Valid)) {\n \t\t\t\tselfPathAvailable = false;\n-\t\t\t\tcfg = tryCfg;\n-\t\t\t\tcfg.setStream(const_cast<Stream *>(&data_->selfPathStream_));\n \t\t\t\tcontinue;\n \t\t\t}\n \t\t}\n \n \t\t/* Try to match stream allowing adjusting configuration. */\n \t\tif (mainPathAvailable) {\n-\t\t\tStreamConfiguration tryCfg = cfg;\n-\t\t\tif (data_->mainPath_->validate(sensor, sensorConfig, &tryCfg) == Adjusted) {\n+\t\t\tif (validateConfig(cfg, mainPath, mainPathStream, Adjusted)) {\n \t\t\t\tmainPathAvailable = false;\n-\t\t\t\tcfg = tryCfg;\n-\t\t\t\tcfg.setStream(const_cast<Stream *>(&data_->mainPathStream_));\n \t\t\t\tstatus = Adjusted;\n \t\t\t\tcontinue;\n \t\t\t}\n \t\t}\n \n \t\tif (selfPathAvailable) {\n-\t\t\tStreamConfiguration tryCfg = cfg;\n-\t\t\tif (data_->selfPath_->validate(sensor, sensorConfig, &tryCfg) == Adjusted) {\n+\t\t\tif (validateConfig(cfg, selfPath, selfPathStream, Adjusted)) {\n \t\t\t\tselfPathAvailable = false;\n-\t\t\t\tcfg = tryCfg;\n-\t\t\t\tcfg.setStream(const_cast<Stream *>(&data_->selfPathStream_));\n \t\t\t\tstatus = Adjusted;\n \t\t\t\tcontinue;\n \t\t\t}\n",
    "prefixes": [
        "v4",
        "14/20"
    ]
}