From patchwork Thu Oct 23 14:48:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 24738 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id A254DC3337 for ; Thu, 23 Oct 2025 14:49:17 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1C14E6080B; Thu, 23 Oct 2025 16:49:17 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="J8jFyfEm"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0CD56607F3 for ; Thu, 23 Oct 2025 16:49:16 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:7328:357b:4ce1:72b6]) by perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 19EB0177F; Thu, 23 Oct 2025 16:47:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1761230851; bh=UPrfQAHB12PnuqPOGB1JyHi3DTC3VkxWf6/NoxilbYQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J8jFyfEmY83ew1jVfXs22k+px7ZwakI50ZDIf1NaFzrB+KS9KRsv7yEjQQnzDz/jy lTIHr5vS2gxBOJ7ED5znxD4XxVeh59v1MIpjdIdRfH2WA/7Q8zbaVgCIGv0Dc5wQ90 nE4fYY0srhD+/GzefKUeqVeuBws2OV/tBM1R75JY= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH v2 10/35] libcamera: rkisp1: Properly cancel buffers in dewarp 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 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" In case the buffer returned from the ISP was canceled, the upstream buffer was not correctly marked as canceled. Move the cancel functionality into an own helper function and correctly cancel the upstream buffers. Add missing cancellation in case queuing to the dewarper fails. Signed-off-by: Stefan Klug --- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 48 +++++++++++++++--------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index dd3907e2fb5f..05409bc46ee3 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -208,6 +208,7 @@ private: int initLinks(Camera *camera, const RkISP1CameraConfiguration &config); int createCamera(MediaEntity *sensor); void tryCompleteRequest(RkISP1FrameInfo *info); + void cancelDewarpRequest(RkISP1FrameInfo *info); void imageBufferReady(FrameBuffer *buffer); void paramBufferReady(FrameBuffer *buffer); void statBufferReady(FrameBuffer *buffer); @@ -1521,6 +1522,31 @@ void PipelineHandlerRkISP1::tryCompleteRequest(RkISP1FrameInfo *info) completeRequest(request); } +void PipelineHandlerRkISP1::cancelDewarpRequest(RkISP1FrameInfo *info) +{ + RkISP1CameraData *data = cameraData(activeCamera_); + Request *request = info->request; + /* + * i.MX8MP is the only known platform with dewarper. It has + * no self path. Hence, only main path buffer completion is + * required. + * + * Also, we cannot completeBuffer(request, buffer) as buffer + * here, is an internal buffer (between ISP and dewarper) and + * is not associated to the any specific request. The request + * buffer associated with main path stream is the one that + * is required to be completed (not the internal buffer). + */ + for (auto [stream, buffer] : request->buffers()) { + if (stream == &data->mainPathStream_) { + buffer->_d()->cancel(); + completeBuffer(request, buffer); + } + } + + tryCompleteRequest(info); +} + void PipelineHandlerRkISP1::imageBufferReady(FrameBuffer *buffer) { ASSERT(activeCamera_); @@ -1562,23 +1588,7 @@ void PipelineHandlerRkISP1::imageBufferReady(FrameBuffer *buffer) /* Do not queue cancelled frames to dewarper. */ if (metadata.status == FrameMetadata::FrameCancelled) { - /* - * i.MX8MP is the only known platform with dewarper. It has - * no self path. Hence, only main path buffer completion is - * required. - * - * Also, we cannot completeBuffer(request, buffer) as buffer - * here, is an internal buffer (between ISP and dewarper) and - * is not associated to the any specific request. The request - * buffer associated with main path stream is the one that - * is required to be completed (not the internal buffer). - */ - for (auto it : request->buffers()) { - if (it.first == &data->mainPathStream_) - completeBuffer(request, it.second); - } - - tryCompleteRequest(info); + cancelDewarpRequest(info); return; } @@ -1636,6 +1646,8 @@ void PipelineHandlerRkISP1::imageBufferReady(FrameBuffer *buffer) if (dewarpRequest) dewarpRequestReady(dewarpRequest); + cancelDewarpRequest(info); + return; } @@ -1646,6 +1658,8 @@ void PipelineHandlerRkISP1::imageBufferReady(FrameBuffer *buffer) << strerror(-ret); /* Push it back into the queue. */ dewarpRequestReady(dewarpRequest); + + cancelDewarpRequest(info); } }