{"id":25186,"url":"https://patchwork.libcamera.org/api/1.1/patches/25186/?format=json","web_url":"https://patchwork.libcamera.org/patch/25186/","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":"<20251125162851.2301793-8-stefan.klug@ideasonboard.com>","date":"2025-11-25T16:28:19","name":"[v3,07/29] libcamera: rkisp1: Properly cancel buffers in dewarp case","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"885aae9e5315e294c27013e5856b0e49954d352f","submitter":{"id":184,"url":"https://patchwork.libcamera.org/api/1.1/people/184/?format=json","name":"Stefan Klug","email":"stefan.klug@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/25186/mbox/","series":[{"id":5613,"url":"https://patchwork.libcamera.org/api/1.1/series/5613/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5613","date":"2025-11-25T16:28:12","name":"Full dewarper support on imx8mp","version":3,"mbox":"https://patchwork.libcamera.org/series/5613/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/25186/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/25186/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 45808C333C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 25 Nov 2025 16:29:18 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DED8160AAE;\n\tTue, 25 Nov 2025 17:29:17 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 513F260AAE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 25 Nov 2025 17:29:15 +0100 (CET)","from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:bae1:340c:573c:570b])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 511EFFDB;\n\tTue, 25 Nov 2025 17:27:06 +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=\"iNiECHMZ\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1764088026;\n\tbh=aU5zk8ArWYFA+RK5tVzh9KXDENjW4DmhFkf9a2qozjk=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=iNiECHMZhmdnDNUraa2sPvEwGS2ZHnA+St1tDKFUILOgTihKr7TZdGqWfaCH8xBmB\n\t9eb9OSag5yAERejpysNSShsozYmcKqmMD55K8O7r7XHQb/J9fmN/M5pp2n/bV42I6h\n\t9Th8lHD2Su5eBNIAnEqsM476z6QJEPj75NWuDUcU=","From":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>,\n\tPaul Elder <paul.elder@ideasonboard.com>,\n\tIsaac Scott <isaac.scott@ideasonboard.com>","Subject":"[PATCH v3 07/29] libcamera: rkisp1: Properly cancel buffers in\n\tdewarp case","Date":"Tue, 25 Nov 2025 17:28:19 +0100","Message-ID":"<20251125162851.2301793-8-stefan.klug@ideasonboard.com>","X-Mailer":"git-send-email 2.51.0","In-Reply-To":"<20251125162851.2301793-1-stefan.klug@ideasonboard.com>","References":"<20251125162851.2301793-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>\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\nReviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>\n\n---\n\nChanges in v3:\n- Collected tags\n- Adapted code a bit as the request handling is no longer part of\n  rkisp1, but was moved to the dw100 implementation\n---\n src/libcamera/pipeline/rkisp1/rkisp1.cpp | 51 +++++++++++++++---------\n 1 file changed, 33 insertions(+), 18 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\nindex dbd6bf9673ff..b56b306f1ad1 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n@@ -207,6 +207,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@@ -1499,6 +1500,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@@ -1540,23 +1566,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@@ -1598,10 +1608,15 @@ void PipelineHandlerRkISP1::imageBufferReady(FrameBuffer *buffer)\n \t * by the application.\n \t */\n \tint ret = dewarper_->queueBuffers(buffer, request->buffers());\n-\tif (ret < 0)\n+\tif (ret < 0) {\n \t\tLOG(RkISP1, Error) << \"Cannot queue buffers to dewarper: \"\n \t\t\t\t   << strerror(-ret);\n \n+\t\tcancelDewarpRequest(info);\n+\n+\t\treturn;\n+\t}\n+\n \trequest->metadata().set(controls::ScalerCrop, activeCrop_.value());\n }\n \n","prefixes":["v3","07/29"]}