From patchwork Mon Feb 12 15:35:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Scally X-Patchwork-Id: 19480 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 308C7C32C3 for ; Mon, 12 Feb 2024 15:35:49 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DB79A62814; Mon, 12 Feb 2024 16:35:46 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="FBa8t7yv"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2CF67627FE for ; Mon, 12 Feb 2024 16:35:44 +0100 (CET) Received: from mail.ideasonboard.com (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net [86.13.91.161]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 7A64FB53; Mon, 12 Feb 2024 16:35:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1707752142; bh=lrEgDEFU1TFHgIie2eGmD3DqpVXJ2+sJDe+Wy4+dkd8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FBa8t7yvb+ZQ9fM0qrhdt9hRVsp8QVZ5GIzrmYQu+MgTWIIWeMgMwYoCm3CGz5lzF D5UVMm9H+E2JNXygqLEKHoy4CPVNte8NpZ8Z26svvWVH9lXIwxevua/SJGgyXiql2V dvfcEmCPkh462FJnNtfB3v5Hi3U55JQTaSUes7UY= From: Daniel Scally To: libcamera-devel@lists.libcamera.org Subject: [PATCH 3/5] libcamera: rkisp1: Switch IPA slots to use bufferId not frame Date: Mon, 12 Feb 2024 15:35:30 +0000 Message-Id: <20240212153532.179283-4-dan.scally@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240212153532.179283-1-dan.scally@ideasonboard.com> References: <20240212153532.179283-1-dan.scally@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 preparation for removing the RkISP1FrameInfo class we need the RkISP1 IPA to emit bufferIds rather than frame numbers for its slots so that the pipeline handler can find the correct buffer properly. Switch the slots; reconfigure the pipeline handler to obtain the correct buffer first before passing it to RkISP1FrameInfo::find() as before; one of its overloads already works with FrameBuffer *. Signed-off-by: Daniel Scally --- include/libcamera/ipa/rkisp1.mojom | 4 +- src/ipa/rkisp1/rkisp1.cpp | 4 +- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 59 ++++++++++++++++-------- 3 files changed, 44 insertions(+), 23 deletions(-) diff --git a/include/libcamera/ipa/rkisp1.mojom b/include/libcamera/ipa/rkisp1.mojom index 1009e970..4c097622 100644 --- a/include/libcamera/ipa/rkisp1.mojom +++ b/include/libcamera/ipa/rkisp1.mojom @@ -36,7 +36,7 @@ interface IPARkISP1Interface { }; interface IPARkISP1EventInterface { - paramsBufferReady(uint32 frame); + paramsBufferReady(uint32 bufferId); setSensorControls(uint32 frame, libcamera.ControlList sensorControls); - metadataReady(uint32 frame, libcamera.ControlList metadata); + metadataReady(uint32 bufferId, libcamera.ControlList metadata); }; diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index 6544c925..7e01a04d 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -337,7 +337,7 @@ void IPARkISP1::fillParamsBuffer(const uint32_t frame, const uint32_t bufferId) for (auto const &algo : algorithms()) algo->prepare(context_, frame, frameContext, params); - paramsBufferReady.emit(frame); + paramsBufferReady.emit(bufferId); } void IPARkISP1::processStatsBuffer(const uint32_t frame, const uint32_t bufferId, @@ -370,7 +370,7 @@ void IPARkISP1::processStatsBuffer(const uint32_t frame, const uint32_t bufferId setControls(frame); - metadataReady.emit(frame, metadata); + metadataReady.emit(bufferId, metadata); } void IPARkISP1::updateControls(const IPACameraSensorInfo &sensorInfo, diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 22e553fe..d4ed38a4 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -376,23 +376,34 @@ int RkISP1CameraData::loadIPA(unsigned int hwRevision) return 0; } -void RkISP1CameraData::paramFilled(unsigned int frame) +void RkISP1CameraData::paramFilled(unsigned int bufferId) { PipelineHandlerRkISP1 *pipe = RkISP1CameraData::pipe(); - RkISP1FrameInfo *info = frameInfo_.find(frame); - if (!info) - return; - info->paramBuffer->_d()->metadata().planes()[0].bytesused = - sizeof(struct rkisp1_params_cfg); - pipe->param_->queueBuffer(info->paramBuffer); - pipe->stat_->queueBuffer(info->statBuffer); + for (std::unique_ptr ¶mBuffer : pipe->paramBuffers_) { + if (paramBuffer->cookie() != bufferId) + continue; + + RkISP1FrameInfo *info = frameInfo_.find(paramBuffer.get()); + if (!info) + return; + + info->paramBuffer->_d()->metadata().planes()[0].bytesused = + sizeof(struct rkisp1_params_cfg); + pipe->param_->queueBuffer(info->paramBuffer); + pipe->stat_->queueBuffer(info->statBuffer); - if (info->mainPathBuffer) - mainPath_->queueBuffer(info->mainPathBuffer); + if (info->mainPathBuffer) + mainPath_->queueBuffer(info->mainPathBuffer); + + if (selfPath_ && info->selfPathBuffer) + selfPath_->queueBuffer(info->selfPathBuffer); + + return; + } - if (selfPath_ && info->selfPathBuffer) - selfPath_->queueBuffer(info->selfPathBuffer); + LOG(RkISP1, Fatal) << "Can't locate buffer from bufferId"; + return; } void RkISP1CameraData::setSensorControls([[maybe_unused]] unsigned int frame, @@ -401,16 +412,26 @@ void RkISP1CameraData::setSensorControls([[maybe_unused]] unsigned int frame, delayedCtrls_->push(sensorControls); } -void RkISP1CameraData::metadataReady(unsigned int frame, const ControlList &metadata) +void RkISP1CameraData::metadataReady(unsigned int bufferId, + const ControlList &metadata) { - RkISP1FrameInfo *info = frameInfo_.find(frame); - if (!info) - return; + for (std::unique_ptr &statBuffer : pipe()->statBuffers_) { + if (statBuffer->cookie() != bufferId) + continue; + + RkISP1FrameInfo *info = frameInfo_.find(statBuffer.get()); + if (!info) + return; - info->request->metadata().merge(metadata); - info->metadataProcessed = true; + info->request->metadata().merge(metadata); + info->metadataProcessed = true; + + pipe()->tryCompleteRequest(info); + return; + } - pipe()->tryCompleteRequest(info); + LOG(RkISP1, Fatal) << "Can't locate buffer from bufferId"; + return; } /* -----------------------------------------------------------------------------