Patch Detail
Show a patch.
GET /api/patches/19411/?format=api
{ "id": 19411, "url": "https://patchwork.libcamera.org/api/patches/19411/?format=api", "web_url": "https://patchwork.libcamera.org/patch/19411/", "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": "<20240116091754.100654-3-paul.elder@ideasonboard.com>", "date": "2024-01-16T09:17:53", "name": "[libcamera-devel,2/3] pipeline: rkisp1: Fix validation when sensor max is larger than ISP input", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "ff767d9daf0f695132af3af489dfd554b0125977", "submitter": { "id": 17, "url": "https://patchwork.libcamera.org/api/people/17/?format=api", "name": "Paul Elder", "email": "paul.elder@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/19411/mbox/", "series": [ { "id": 4143, "url": "https://patchwork.libcamera.org/api/series/4143/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4143", "date": "2024-01-16T09:17:51", "name": "i.MX8MP support, plus misc fixes", "version": 1, "mbox": "https://patchwork.libcamera.org/series/4143/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/19411/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/19411/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 A50E8C323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 16 Jan 2024 09:18:37 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0460F628DA;\n\tTue, 16 Jan 2024 10:18:36 +0100 (CET)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DBAAC628AD\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 16 Jan 2024 10:18:33 +0100 (CET)", "from pyrite.hamster-moth.ts.net (h175-177-049-156.catv02.itscom.jp\n\t[175.177.49.156])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 440AA3D9;\n\tTue, 16 Jan 2024 10:17:24 +0100 (CET)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1705396716;\n\tbh=WjV4LZEMIYq5SMiBjkSsdtl5PoZahZ4ttfK6GttpLw8=;\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=h7YWLytyDVP1rWl0apmjPLSk0wRWbIA3fjIdA6kJtCvwcAoSmpdGmr5eedfw/tyqM\n\tvY5hMhyg9W5QZovVe7rdnDgLm8VLYluORO9E4Jj8znL0uxKyTXXjezhX0u8uSq4Vbv\n\tUlZmxP4z2vYY3Cian4r3FL/z7B7Es6gKlrANBEdJMFoa9lMrVef/ESZOlkrqgUrXLl\n\tFTwfD9KlRhUR0leQY4gvZl1B2DFXeAuxjOtkwbUB6dg0RWXQZAQJTOnnJb0mGcceNS\n\tTCAFhCMDB6K+nOEsn0q/GojtSeAzhO0p3juyG84ZjEAvaabNRCxY31iYiXdUinYeDz\n\tL6p1u/lPFv05A==", "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1705396645;\n\tbh=WjV4LZEMIYq5SMiBjkSsdtl5PoZahZ4ttfK6GttpLw8=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=lpUHgxsFZWOjwi78ZrJgyR0DV6sEkHdFD7Yti5z+peg6ZRlQ6ByZlU/5P/V3vFFfN\n\tNij79APKGzG4i7deaRcg914tBBmMbMeylCB5PJpLuTexh3mRVACYXDh+/xqiPAlGLV\n\tAuzEKs8X6Kv2IwdmoZ5vhFNwynj8UBSyak1wUWec=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"lpUHgxsF\"; dkim-atps=neutral", "To": "libcamera-devel@lists.libcamera.org", "Date": "Tue, 16 Jan 2024 18:17:53 +0900", "Message-Id": "<20240116091754.100654-3-paul.elder@ideasonboard.com>", "X-Mailer": "git-send-email 2.39.2", "In-Reply-To": "<20240116091754.100654-1-paul.elder@ideasonboard.com>", "References": "<20240116091754.100654-1-paul.elder@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 2/3] pipeline: rkisp1: Fix validation when\n\tsensor max is larger than ISP input", "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": "Paul Elder via libcamera-devel <libcamera-devel@lists.libcamera.org>", "Reply-To": "Paul Elder <paul.elder@ideasonboard.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "If the maximum sensor output size is larger than the maximum ISP input\nsize, the maximum sensor size could be selected and the pipeline would\nfail with an EPIPE. Fix this by clamping the sensor size to the ISP\ninput size at validation time.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n---\n src/libcamera/pipeline/rkisp1/rkisp1.cpp | 17 ++++++++++--\n src/libcamera/pipeline/rkisp1/rkisp1_path.cpp | 26 +++++++++----------\n src/libcamera/pipeline/rkisp1/rkisp1_path.h | 4 ++-\n 3 files changed, 30 insertions(+), 17 deletions(-)", "diff": "diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\nindex 586b46d64..fb67ba8f4 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n@@ -1202,11 +1202,24 @@ bool PipelineHandlerRkISP1::match(DeviceEnumerator *enumerator)\n \tif (param_->open() < 0)\n \t\treturn false;\n \n+\t/*\n+\t * Retrieve ISP maximum input size for config validation in the path\n+\t * classes\n+\t */\n+\tSize ispMaxInSize = { 0, 0 };\n+\tV4L2Subdevice::Formats ispFormats = isp_->formats(0);\n+\tfor (const auto &[mbus, sizes] : ispFormats) {\n+\t\tfor (const auto &size : sizes) {\n+\t\t\tif (ispMaxInSize < size.max)\n+\t\t\t\tispMaxInSize = size.max;\n+\t\t}\n+\t}\n+\n \t/* Locate and open the ISP main and self paths. */\n-\tif (!mainPath_.init(media_))\n+\tif (!mainPath_.init(media_, ispMaxInSize))\n \t\treturn false;\n \n-\tif (hasSelfPath_ && !selfPath_.init(media_))\n+\tif (hasSelfPath_ && !selfPath_.init(media_, ispMaxInSize))\n \t\treturn false;\n \n \tmainPath_.bufferReady().connect(this, &PipelineHandlerRkISP1::bufferReady);\ndiff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp\nindex b62b645ca..eaab7e857 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp\n@@ -62,7 +62,7 @@ RkISP1Path::RkISP1Path(const char *name, const Span<const PixelFormat> &formats,\n {\n }\n \n-bool RkISP1Path::init(MediaDevice *media)\n+bool RkISP1Path::init(MediaDevice *media, const Size &ispMaxInSize)\n {\n \tstd::string resizer = std::string(\"rkisp1_resizer_\") + name_ + \"path\";\n \tstd::string video = std::string(\"rkisp1_\") + name_ + \"path\";\n@@ -76,6 +76,7 @@ bool RkISP1Path::init(MediaDevice *media)\n \t\treturn false;\n \n \tpopulateFormats();\n+\tispMaxInSize_ = ispMaxInSize;\n \n \tlink_ = media->link(\"rkisp1_isp\", 2, resizer, 0);\n \tif (!link_)\n@@ -172,7 +173,9 @@ RkISP1Path::generateConfiguration(const CameraSensor *sensor, const Size &size,\n \t\t/* Add all the RAW sizes the sensor can produce for this code. */\n \t\tfor (const auto &rawSize : sensor->sizes(mbusCode)) {\n \t\t\tif (rawSize.width > maxResolution_.width ||\n-\t\t\t rawSize.height > maxResolution_.height)\n+\t\t\t rawSize.height > maxResolution_.height ||\n+\t\t\t rawSize.width > ispMaxInSize_.width ||\n+\t\t\t rawSize.height > ispMaxInSize_.height)\n \t\t\t\tcontinue;\n \n \t\t\tstreamFormats[format].push_back({ rawSize, rawSize });\n@@ -275,8 +278,9 @@ CameraConfiguration::Status RkISP1Path::validate(const CameraSensor *sensor,\n \tif (!found)\n \t\tcfg->pixelFormat = isRaw ? rawFormat : formats::NV12;\n \n-\tSize minResolution;\n-\tSize maxResolution;\n+\tSize maxResolution = maxResolution_.boundedToAspectRatio(resolution)\n+\t\t\t\t\t .boundedTo(resolution);\n+\tSize minResolution = minResolution_.expandedToAspectRatio(resolution);\n \n \tif (isRaw) {\n \t\t/*\n@@ -287,16 +291,10 @@ CameraConfiguration::Status RkISP1Path::validate(const CameraSensor *sensor,\n \t\tV4L2SubdeviceFormat sensorFormat =\n \t\t\tsensor->getFormat({ mbusCode }, cfg->size);\n \n-\t\tminResolution = sensorFormat.size;\n-\t\tmaxResolution = sensorFormat.size;\n-\t} else {\n-\t\t/*\n-\t\t * Adjust the size based on the sensor resolution and absolute\n-\t\t * limits of the ISP.\n-\t\t */\n-\t\tminResolution = minResolution_.expandedToAspectRatio(resolution);\n-\t\tmaxResolution = maxResolution_.boundedToAspectRatio(resolution)\n-\t\t\t\t\t .boundedTo(resolution);\n+\t\tif (!sensorFormat.size.isNull()) {\n+\t\t\tminResolution = sensorFormat.size.boundedTo(ispMaxInSize_);\n+\t\t\tmaxResolution = sensorFormat.size.boundedTo(ispMaxInSize_);\n+\t\t}\n \t}\n \n \tcfg->size.boundTo(maxResolution);\ndiff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.h b/src/libcamera/pipeline/rkisp1/rkisp1_path.h\nindex cd77957ee..c96bd5557 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1_path.h\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.h\n@@ -35,7 +35,7 @@ public:\n \tRkISP1Path(const char *name, const Span<const PixelFormat> &formats,\n \t\t const Size &minResolution, const Size &maxResolution);\n \n-\tbool init(MediaDevice *media);\n+\tbool init(MediaDevice *media, const Size &ispMaxInSize);\n \n \tint setEnabled(bool enable) { return link_->setEnabled(enable); }\n \tbool isEnabled() const { return link_->flags() & MEDIA_LNK_FL_ENABLED; }\n@@ -77,6 +77,8 @@ private:\n \tstd::unique_ptr<V4L2Subdevice> resizer_;\n \tstd::unique_ptr<V4L2VideoDevice> video_;\n \tMediaLink *link_;\n+\n+\tSize ispMaxInSize_;\n };\n \n class RkISP1MainPath : public RkISP1Path\n", "prefixes": [ "libcamera-devel", "2/3" ] }