{"id":21205,"url":"https://patchwork.libcamera.org/api/1.1/patches/21205/?format=json","web_url":"https://patchwork.libcamera.org/patch/21205/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20240909163719.267211-3-umang.jain@ideasonboard.com>","date":"2024-09-09T16:37:19","name":"[2/2] pipeline: rkisp1: Filter out sensor sizes not supported by the pipeline","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"3579b7a6d5afd3a73dd666276e51e1f24954517d","submitter":{"id":86,"url":"https://patchwork.libcamera.org/api/1.1/people/86/?format=json","name":"Umang Jain","email":"umang.jain@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/21205/mbox/","series":[{"id":4571,"url":"https://patchwork.libcamera.org/api/1.1/series/4571/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4571","date":"2024-09-09T16:37:17","name":"pipeline: rkisp1: Filter out sensor sizes not supported by the pipeline","version":1,"mbox":"https://patchwork.libcamera.org/series/4571/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/21205/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/21205/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 1BE40C324C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  9 Sep 2024 16:37:42 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 94629634FE;\n\tMon,  9 Sep 2024 18:37:41 +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 ED35C634FA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  9 Sep 2024 18:37:34 +0200 (CEST)","from localhost.localdomain (unknown\n\t[IPv6:2405:201:2015:f873:55f8:639e:8e9f:12ec])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D9EA05A4;\n\tMon,  9 Sep 2024 18:36:17 +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=\"GE7hyPoH\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1725899778;\n\tbh=2fJ4bmFMRq0v73KAaV6CsB9TcX0H3dp13HTMXhjvyCY=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=GE7hyPoHW6sPbtiUXxJazOJvyb4cWpwl3BW7HDt+29K3iMHFd+CdkWs8Qiz3KYq2N\n\terdxK5q2IO0Vf44TtT58N5j8uFwZfcds4RItLrdGOd8znS/iNPyZAbdS4g9th7fx0s\n\te8IVaJORd5eJFU2mtJMl0hsIX+5Unp+biwxGqliE=","From":"Umang Jain <umang.jain@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Umang Jain <umang.jain@ideasonboard.com>","Subject":"[PATCH 2/2] pipeline: rkisp1: Filter out sensor sizes not supported\n\tby the pipeline","Date":"Mon,  9 Sep 2024 22:07:19 +0530","Message-ID":"<20240909163719.267211-3-umang.jain@ideasonboard.com>","X-Mailer":"git-send-email 2.45.0","In-Reply-To":"<20240909163719.267211-1-umang.jain@ideasonboard.com>","References":"<20240909163719.267211-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>\n---\n src/libcamera/pipeline/rkisp1/rkisp1_path.cpp | 48 ++++++++++++++++++-\n src/libcamera/pipeline/rkisp1/rkisp1_path.h   |  3 ++\n 2 files changed, 49 insertions(+), 2 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp\nindex 9053af18..b3b27aa5 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp\n@@ -128,12 +128,56 @@ 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+\tif (!sensorSizes_.empty())\n+\t\treturn sensorSizes_.back();\n+\n+\tstd::vector<Size> sensorSizes;\n+\tconst std::vector<unsigned int> &mbusCodes = sensor->mbusCodes();\n+\tfor (const auto iter : mbusCodes) {\n+\t\tstd::vector<Size> sizes = sensor->sizes(iter);\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\tsensorSizes_.push_back(sz);\n+\t}\n+\n+\treturn sensorSizes_.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@@ -222,7 +266,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..03ff9543 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1_path.h\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.h\n@@ -63,6 +63,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 +78,8 @@ private:\n \tstd::unique_ptr<V4L2Subdevice> resizer_;\n \tstd::unique_ptr<V4L2VideoDevice> video_;\n \tMediaLink *link_;\n+\n+\tstd::vector<Size> sensorSizes_;\n };\n \n class RkISP1MainPath : public RkISP1Path\n","prefixes":["2/2"]}