Show a patch.

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

{
    "id": 21261,
    "url": "https://patchwork.libcamera.org/api/patches/21261/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/21261/",
    "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": "<20240913103759.2166-3-umang.jain@ideasonboard.com>",
    "date": "2024-09-13T10:37:59",
    "name": "[v2,2/2] pipeline: rkisp1: Filter out sensor sizes not supported by the pipeline",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "79554c9cdfa656e2212f2522a8fc4d3839b1f16c",
    "submitter": {
        "id": 86,
        "url": "https://patchwork.libcamera.org/api/people/86/?format=api",
        "name": "Umang Jain",
        "email": "umang.jain@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/21261/mbox/",
    "series": [
        {
            "id": 4588,
            "url": "https://patchwork.libcamera.org/api/series/4588/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4588",
            "date": "2024-09-13T10:37:57",
            "name": "pipeline: rkisp1: Filter out sensor sizes not supported by the pipeline",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/4588/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/21261/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/21261/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 9B06AC3261\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 13 Sep 2024 10:38:16 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D648E634FE;\n\tFri, 13 Sep 2024 12:38:13 +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 3D8EE634E3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 13 Sep 2024 12:38:09 +0200 (CEST)",
            "from ATX.abc.com (unknown\n\t[IPv6:2405:201:2015:f873:55f8:639e:8e9f:12ec])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C9B2B74C;\n\tFri, 13 Sep 2024 12:36:49 +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=\"eGSXhYon\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1726223810;\n\tbh=6Lxe43CgxArDNTN3+HfUGCc6yqNQW7Ex/SUrgOFP0NI=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=eGSXhYon1/FoDfDKKmy10rkLyeCkGpPvAfD9Iwf14+Cvic5HkAK0++8v2lYWtK22s\n\tCG3iKhXMbgeLYzdnc4JDAe81SuAsLQMWDY7bhIGMcpMNoLELvDBm/y1NK0ZGA4Or5B\n\tZBHB+Qh+shFEA3llzABEFwvjlR0JzV74d2iEIWdc=",
        "From": "Umang Jain <umang.jain@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "Umang Jain <umang.jain@ideasonboard.com>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>",
        "Subject": "[PATCH v2 2/2] pipeline: rkisp1: Filter out sensor sizes not\n\tsupported by the pipeline",
        "Date": "Fri, 13 Sep 2024 16:07:59 +0530",
        "Message-ID": "<20240913103759.2166-3-umang.jain@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.45.0",
        "In-Reply-To": "<20240913103759.2166-1-umang.jain@ideasonboard.com>",
        "References": "<20240913103759.2166-1-umang.jain@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": "It is possible that the maximum sensor size (returned by\nCameraSensor::resolution()) is not supported by the pipeline. In such\ncases, a filter function is required to filter out resolutions of the\ncamera sensor, which cannot be supported by the pipeline.\n\nIntroduce the filter function filterSensorResolution() in RkISP1Path\nclass and use it for validate() and generateConfiguration(). The\nmaximum sensor resolution is picked from that filtered set of\nresolutions instead of CameraSensor::resolution().\n\nSigned-off-by: Umang Jain <umang.jain@ideasonboard.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n src/libcamera/pipeline/rkisp1/rkisp1_path.cpp | 51 ++++++++++++++++++-\n src/libcamera/pipeline/rkisp1/rkisp1_path.h   |  8 +++\n 2 files changed, 57 insertions(+), 2 deletions(-)",
    "diff": "diff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp\nindex 08b39e1e..1d818b32 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp\n@@ -137,12 +137,59 @@ void RkISP1Path::populateFormats()\n \t}\n }\n \n+/**\n+ * \\brief Filter the sensor resolutions that can be supported\n+ * \\param[in] sensor The camera sensor\n+ *\n+ * This function retrieves all the sizes supported by the sensor and\n+ * filters all the resolutions that can be supported on the pipeline.\n+ * It is possible that the sensor's maximum output resolution is higher\n+ * than the ISP maximum input. In that case, this function filters out all\n+ * the resolution incapable of being supported and returns the maximum\n+ * sensor resolution that can be supported by the pipeline.\n+ *\n+ * \\return Maximum sensor size supported on the pipeline\n+ */\n+Size RkISP1Path::filterSensorResolution(const CameraSensor *sensor)\n+{\n+\tauto iter = sensorSizesMap_.find(sensor);\n+\tif (iter != sensorSizesMap_.end() && !iter->second.empty())\n+\t\treturn iter->second.back();\n+\n+\tsensorSizesMap_.emplace(sensor, std::vector<Size>());\n+\n+\tstd::vector<Size> sensorSizes;\n+\tconst std::vector<unsigned int> &mbusCodes = sensor->mbusCodes();\n+\tfor (const auto it : mbusCodes) {\n+\t\tstd::vector<Size> sizes = sensor->sizes(it);\n+\t\tfor (Size sz : sizes)\n+\t\t\tsensorSizes.push_back(sz);\n+\t}\n+\n+\tstd::sort(sensorSizes.begin(), sensorSizes.end());\n+\n+\t/* Remove duplicates. */\n+\tauto last = std::unique(sensorSizes.begin(), sensorSizes.end());\n+\tsensorSizes.erase(last, sensorSizes.end());\n+\n+\t/* Discard any sizes that the pipeline is unable to support. */\n+\tfor (auto sz : sensorSizes) {\n+\t\tif (sz.width > maxResolution_.width ||\n+\t\t    sz.height > maxResolution_.height)\n+\t\t\tcontinue;\n+\n+\t\tsensorSizesMap_[sensor].push_back(sz);\n+\t}\n+\n+\treturn sensorSizesMap_[sensor].back();\n+}\n+\n StreamConfiguration\n RkISP1Path::generateConfiguration(const CameraSensor *sensor, const Size &size,\n \t\t\t\t  StreamRole role)\n {\n \tconst std::vector<unsigned int> &mbusCodes = sensor->mbusCodes();\n-\tconst Size &resolution = sensor->resolution();\n+\tSize resolution = filterSensorResolution(sensor);\n \n \t/* Min and max resolutions to populate the available stream formats. */\n \tSize maxResolution = maxResolution_.boundedToAspectRatio(resolution)\n@@ -231,7 +278,7 @@ CameraConfiguration::Status RkISP1Path::validate(const CameraSensor *sensor,\n \t\t\t\t\t\t StreamConfiguration *cfg)\n {\n \tconst std::vector<unsigned int> &mbusCodes = sensor->mbusCodes();\n-\tconst Size &resolution = sensor->resolution();\n+\tSize resolution = filterSensorResolution(sensor);\n \n \tconst StreamConfiguration reqCfg = *cfg;\n \tCameraConfiguration::Status status = CameraConfiguration::Valid;\ndiff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.h b/src/libcamera/pipeline/rkisp1/rkisp1_path.h\nindex 13ba4b62..457c9ac9 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1_path.h\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.h\n@@ -7,6 +7,7 @@\n \n #pragma once\n \n+#include <map>\n #include <memory>\n #include <set>\n #include <vector>\n@@ -63,6 +64,7 @@ public:\n \n private:\n \tvoid populateFormats();\n+\tSize filterSensorResolution(const CameraSensor *sensor);\n \n \tstatic constexpr unsigned int RKISP1_BUFFER_COUNT = 4;\n \n@@ -77,6 +79,12 @@ private:\n \tstd::unique_ptr<V4L2Subdevice> resizer_;\n \tstd::unique_ptr<V4L2VideoDevice> video_;\n \tMediaLink *link_;\n+\n+\t/*\n+\t * Map from camera sensors to the sizes (in increasing order),\n+\t * which are guaranteed to be supported by the pipeline.\n+\t */\n+\tstd::map<const CameraSensor *, std::vector<Size>> sensorSizesMap_;\n };\n \n class RkISP1MainPath : public RkISP1Path\n",
    "prefixes": [
        "v2",
        "2/2"
    ]
}