{"id":24738,"url":"https://patchwork.libcamera.org/api/patches/24738/?format=json","web_url":"https://patchwork.libcamera.org/patch/24738/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20251023144841.403689-11-stefan.klug@ideasonboard.com>","date":"2025-10-23T14:48:11","name":"[v2,10/35] libcamera: rkisp1: Properly cancel buffers in dewarp case","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"488e99763d01b731c92cc5f8ab3a9aeae87540e0","submitter":{"id":184,"url":"https://patchwork.libcamera.org/api/people/184/?format=json","name":"Stefan Klug","email":"stefan.klug@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/24738/mbox/","series":[{"id":5520,"url":"https://patchwork.libcamera.org/api/series/5520/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5520","date":"2025-10-23T14:48:01","name":"Full dewarper support on imx8mp","version":2,"mbox":"https://patchwork.libcamera.org/series/5520/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/24738/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/24738/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 A254DC3337\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 23 Oct 2025 14:49:17 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1C14E6080B;\n\tThu, 23 Oct 2025 16:49:17 +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 0CD56607F3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 23 Oct 2025 16:49:16 +0200 (CEST)","from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:7328:357b:4ce1:72b6])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 19EB0177F; \n\tThu, 23 Oct 2025 16:47:31 +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=\"J8jFyfEm\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1761230851;\n\tbh=UPrfQAHB12PnuqPOGB1JyHi3DTC3VkxWf6/NoxilbYQ=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=J8jFyfEmY83ew1jVfXs22k+px7ZwakI50ZDIf1NaFzrB+KS9KRsv7yEjQQnzDz/jy\n\tlTIHr5vS2gxBOJ7ED5znxD4XxVeh59v1MIpjdIdRfH2WA/7Q8zbaVgCIGv0Dc5wQ90\n\tnE4fYY0srhD+/GzefKUeqVeuBws2OV/tBM1R75JY=","From":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>","Subject":"[PATCH v2 10/35] libcamera: rkisp1: Properly cancel buffers in\n\tdewarp case","Date":"Thu, 23 Oct 2025 16:48:11 +0200","Message-ID":"<20251023144841.403689-11-stefan.klug@ideasonboard.com>","X-Mailer":"git-send-email 2.48.1","In-Reply-To":"<20251023144841.403689-1-stefan.klug@ideasonboard.com>","References":"<20251023144841.403689-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":"In case the buffer returned from the ISP was canceled, the upstream\nbuffer was not correctly marked as canceled. Move the cancel\nfunctionality into an own helper function and correctly cancel the\nupstream buffers. Add missing cancellation in case queuing to the\ndewarper fails.\n\nSigned-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n---\n src/libcamera/pipeline/rkisp1/rkisp1.cpp | 48 +++++++++++++++---------\n 1 file changed, 31 insertions(+), 17 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\nindex dd3907e2fb5f..05409bc46ee3 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n@@ -208,6 +208,7 @@ private:\n \tint initLinks(Camera *camera, const RkISP1CameraConfiguration &config);\n \tint createCamera(MediaEntity *sensor);\n \tvoid tryCompleteRequest(RkISP1FrameInfo *info);\n+\tvoid cancelDewarpRequest(RkISP1FrameInfo *info);\n \tvoid imageBufferReady(FrameBuffer *buffer);\n \tvoid paramBufferReady(FrameBuffer *buffer);\n \tvoid statBufferReady(FrameBuffer *buffer);\n@@ -1521,6 +1522,31 @@ void PipelineHandlerRkISP1::tryCompleteRequest(RkISP1FrameInfo *info)\n \tcompleteRequest(request);\n }\n \n+void PipelineHandlerRkISP1::cancelDewarpRequest(RkISP1FrameInfo *info)\n+{\n+\tRkISP1CameraData *data = cameraData(activeCamera_);\n+\tRequest *request = info->request;\n+\t/*\n+\t * i.MX8MP is the only known platform with dewarper. It has\n+\t * no self path. Hence, only main path buffer completion is\n+\t * required.\n+\t *\n+\t * Also, we cannot completeBuffer(request, buffer) as buffer\n+\t * here, is an internal buffer (between ISP and dewarper) and\n+\t * is not associated to the any specific request. The request\n+\t * buffer associated with main path stream is the one that\n+\t * is required to be completed (not the internal buffer).\n+\t */\n+\tfor (auto [stream, buffer] : request->buffers()) {\n+\t\tif (stream == &data->mainPathStream_) {\n+\t\t\tbuffer->_d()->cancel();\n+\t\t\tcompleteBuffer(request, buffer);\n+\t\t}\n+\t}\n+\n+\ttryCompleteRequest(info);\n+}\n+\n void PipelineHandlerRkISP1::imageBufferReady(FrameBuffer *buffer)\n {\n \tASSERT(activeCamera_);\n@@ -1562,23 +1588,7 @@ void PipelineHandlerRkISP1::imageBufferReady(FrameBuffer *buffer)\n \n \t/* Do not queue cancelled frames to dewarper. */\n \tif (metadata.status == FrameMetadata::FrameCancelled) {\n-\t\t/*\n-\t\t * i.MX8MP is the only known platform with dewarper. It has\n-\t\t * no self path. Hence, only main path buffer completion is\n-\t\t * required.\n-\t\t *\n-\t\t * Also, we cannot completeBuffer(request, buffer) as buffer\n-\t\t * here, is an internal buffer (between ISP and dewarper) and\n-\t\t * is not associated to the any specific request. The request\n-\t\t * buffer associated with main path stream is the one that\n-\t\t * is required to be completed (not the internal buffer).\n-\t\t */\n-\t\tfor (auto it : request->buffers()) {\n-\t\t\tif (it.first == &data->mainPathStream_)\n-\t\t\t\tcompleteBuffer(request, it.second);\n-\t\t}\n-\n-\t\ttryCompleteRequest(info);\n+\t\tcancelDewarpRequest(info);\n \t\treturn;\n \t}\n \n@@ -1636,6 +1646,8 @@ void PipelineHandlerRkISP1::imageBufferReady(FrameBuffer *buffer)\n \t\tif (dewarpRequest)\n \t\t\tdewarpRequestReady(dewarpRequest);\n \n+\t\tcancelDewarpRequest(info);\n+\n \t\treturn;\n \t}\n \n@@ -1646,6 +1658,8 @@ void PipelineHandlerRkISP1::imageBufferReady(FrameBuffer *buffer)\n \t\t\t\t\t   << strerror(-ret);\n \t\t\t/* Push it back into the queue. */\n \t\t\tdewarpRequestReady(dewarpRequest);\n+\n+\t\t\tcancelDewarpRequest(info);\n \t\t}\n \t}\n \n","prefixes":["v2","10/35"]}