From patchwork Wed Nov 18 18:16:54 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 29032 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 CE372C3355 for ; Wed, 18 Nov 2026 18:18:13 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7D0D36A918; Wed, 18 Nov 2026 19:18:13 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="tMvgiicA"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7477B6A8C7 for ; Wed, 18 Nov 2026 19:18:12 +0100 (CET) Received: from mail.ideasonboard.com (unknown [IPv6:2401:4900:1c67:cdf:7464:6c04:36e4:ee87]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 933EC34; Wed, 18 Nov 2026 19:15:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1795025744; bh=zrOcQaNDBrjAZcspdtsp3YwMSGcSU2gDuwqm5/A3S68=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=tMvgiicACFrVztsWpFKzflgHnz1ojMyXMtTIJ5Ull7ipv3Qd641YBzycMH4Gvq6tQ +kjHCp1pRdXx04WpoUZIamT4PXupt326hx7gRSBx1M+7JMso/It8YhM53ahQ9jEltS vX/2FVMH0UYwSXthMBWI6iwR0vy1npb/Sb/Zkx+w= From: Jai Luthra Date: Wed, 18 Nov 2026 23:46:54 +0530 Subject: [PATCH v4 4/8] ipa: rpi: Allow sharing params buffer to the IPA MIME-Version: 1.0 Message-Id: <20261118-pi4-upstream-v4-4-93bdc7d925ba@ideasonboard.com> References: <20261118-pi4-upstream-v4-0-93bdc7d925ba@ideasonboard.com> In-Reply-To: <20261118-pi4-upstream-v4-0-93bdc7d925ba@ideasonboard.com> To: libcamera-devel@lists.libcamera.org Cc: Naushir Patuck , David Plowman , Laurent Pinchart , Kieran Bingham , Paul Elder , Jacopo Mondi , Jai Luthra X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=7108; i=jai.luthra@ideasonboard.com; h=from:subject:message-id; bh=zrOcQaNDBrjAZcspdtsp3YwMSGcSU2gDuwqm5/A3S68=; b=owEBbQKS/ZANAwAKAUPekfkkmnFFAcsmYgBq/evHYdWgAjUtI2Q79f2z27po57W3gWEWiDpFA KIXb+YAjMWJAjMEAAEKAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCav3rxwAKCRBD3pH5JJpx RaEWD/0edsSSOsUPfOVgeIthpe/5ZrYmvkSt9o560ly53yrWto99XZwZKpV2hmc0NWF/Yz7b4sp 0eQ+5ycBUyuPkfF0GQ2eT9Crej5odsT5LzFhOPhHww11CKVeHRJGokWmB+5Z9KVq+2BX5X3T5v6 GMqsSop6UHoQ8hxPRabTZhJVkoNn+cDIS9zdvGKqlBpFVmILbOJUcHxgKNZ7w0XbPzOk4qeNfrR h0EFXWH7dcOcFqCRskW8MfRlp6f7YNiMAnl08mRuQwgKZRuEqqIT6Mv71MwDvmBKE8RTe71TYLn RcFF4IOcRz9NWakdlw71rsxhdNm4pyh6kZ8f7mFjW8ionJRINRuzrdjzkUE3tvYUWCmtL/h28FR 1LBF/0sD3AKHOIrwtTxzzTIqYd/Q9fGCgFIwUwPPiBfDmGyUZxQT6HR5MBhRmazgv3HfVxMNH9e FvRa+CGouHY1R5JtJtiCvkIR0d/TQUMH0QO0WaDY3DRGeaCl08DMozGlGnIhQ+yb8c/fiFADvix 4j6Yua8iwHenyI3WjBtxYc24xNTcfueUJ7mbSgWZawW0TppMGnuXlMrpwwqlzFXVULORQY822/h FlOp69oUKsel2dWNLA1g1NLuARxQ8d17phlI+KJky5ks39AXR0DWFWTMOWIHReMl8T828fgQZBp O36A4LvaIGxu+yQ== X-Developer-Key: i=jai.luthra@ideasonboard.com; a=openpgp; fpr=4DE0D818E5D575E8D45AAFC543DE91F9249A7145 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" While the VC4 IPA currently writes control values for configuration, the mainline driver expects a parameter buffer. In preparation for the migration, add plumbing to pass the parameter buffer to the IPA, while reporting back how many bytes were filled through the prepareIspComplete() callback. This is unused for now, VC4 will use it in subsequent commits. Reviewed-by: Paul Elder Tested-by: Paul Elder Signed-off-by: Jai Luthra --- include/libcamera/ipa/raspberrypi.mojom | 6 ++++-- src/ipa/rpi/common/ipa_base.cpp | 11 ++++++++++- src/ipa/rpi/common/ipa_base.h | 4 ++++ src/libcamera/pipeline/rpi/pisp/pisp.cpp | 6 ++++-- src/libcamera/pipeline/rpi/vc4/vc4.cpp | 6 ++++-- 5 files changed, 26 insertions(+), 7 deletions(-) diff --git a/include/libcamera/ipa/raspberrypi.mojom b/include/libcamera/ipa/raspberrypi.mojom index 1b7e03582e0e..84566648d213 100644 --- a/include/libcamera/ipa/raspberrypi.mojom +++ b/include/libcamera/ipa/raspberrypi.mojom @@ -33,6 +33,7 @@ struct BufferIds { uint32 bayer; uint32 embedded; uint32 stats; + uint32 params; }; struct ConfigParams { @@ -219,15 +220,16 @@ interface IPARPiEventInterface { /** * \fn prepareIspComplete() * \brief Signal completion of \a prepareIsp - * \param[in] buffers Bayer and embedded buffers actioned. + * \param[in] buffers Bayer, embedded and parameter buffers actioned. * \param[in] stitchSwapBuffers Whether the stitch block buffers need to be swapped. + * \param[in] paramsBytesUsed Number of bytes used in the parameter buffer * * This asynchronous event is signalled to the pipeline handler once * the \a prepareIsp signal has completed, and the ISP is ready to start * processing the frame. The embedded data buffer may be recycled after * this event. */ - prepareIspComplete(BufferIds buffers, bool stitchSwapBuffers); + prepareIspComplete(BufferIds buffers, bool stitchSwapBuffers, uint32 paramsBytesUsed); /** * \fn processStatsComplete() diff --git a/src/ipa/rpi/common/ipa_base.cpp b/src/ipa/rpi/common/ipa_base.cpp index 2ee28c9a5005..c23d9b28e258 100644 --- a/src/ipa/rpi/common/ipa_base.cpp +++ b/src/ipa/rpi/common/ipa_base.cpp @@ -418,6 +418,7 @@ void IpaBase::prepareIsp(const PrepareParams ¶ms) unsigned int ipaContext = params.ipaContext % rpiMetadata_.size(); RPiController::Metadata &rpiMetadata = rpiMetadata_[ipaContext]; std::span embeddedBuffer; + std::span paramsBuffer; rpiMetadata.clear(); fillDeviceStatus(params.sensorControls, ipaContext); @@ -441,6 +442,13 @@ void IpaBase::prepareIsp(const PrepareParams ¶ms) embeddedBuffer = it->second.planes()[0]; } + if (params.buffers.params) { + auto it = buffers_.find(params.buffers.params); + ASSERT(it != buffers_.end()); + paramsBuffer = it->second.planes()[0]; + platformParamsBufferInit(paramsBuffer); + } + /* * AGC wants to know the algorithm status from the time it actioned the * sensor exposure/gain changes. So fetch it from the metadata list @@ -513,7 +521,8 @@ void IpaBase::prepareIsp(const PrepareParams ¶ms) reportMetadata(ipaContext); /* Ready to push the input buffer into the ISP. */ - prepareIspComplete.emit(params.buffers, stitchSwapBuffers_); + prepareIspComplete.emit(params.buffers, stitchSwapBuffers_, + platformParamsBytesUsed()); } void IpaBase::processStats(const ProcessParams ¶ms) diff --git a/src/ipa/rpi/common/ipa_base.h b/src/ipa/rpi/common/ipa_base.h index 1c375669c9f7..88773e1ac759 100644 --- a/src/ipa/rpi/common/ipa_base.h +++ b/src/ipa/rpi/common/ipa_base.h @@ -79,6 +79,8 @@ protected: /* Whether the stitch block (if available) needs to swap buffers. */ bool stitchSwapBuffers_; + virtual size_t platformParamsBytesUsed() const { return 0; } + private: /* Number of metadata objects available in the context list. */ static constexpr unsigned int numMetadataContexts = 16; @@ -87,7 +89,9 @@ private: virtual int32_t platformStart(const ControlList &controls, StartResult *result) = 0; virtual int32_t platformConfigure(const ConfigParams ¶ms, ConfigResult *result) = 0; + virtual void platformParamsBufferInit([[maybe_unused]] std::span paramsBuffer) {} virtual void platformPrepareIsp(RPiController::Metadata &rpiMetadata) = 0; + virtual void platformPrepareAgc(RPiController::Metadata &rpiMetadata) = 0; virtual RPiController::StatisticsPtr platformProcessStats(std::span mem) = 0; diff --git a/src/libcamera/pipeline/rpi/pisp/pisp.cpp b/src/libcamera/pipeline/rpi/pisp/pisp.cpp index 159c6b05ee7b..d0103adbe17c 100644 --- a/src/libcamera/pipeline/rpi/pisp/pisp.cpp +++ b/src/libcamera/pipeline/rpi/pisp/pisp.cpp @@ -759,7 +759,8 @@ public: void beOutputDequeue(FrameBuffer *buffer); void processStatsComplete(const ipa::RPi::BufferIds &buffers); - void prepareIspComplete(const ipa::RPi::BufferIds &buffers, bool stitchSwapBuffers); + void prepareIspComplete(const ipa::RPi::BufferIds &buffers, bool stitchSwapBuffers, + unsigned int paramsBytesUsed); void setCameraTimeout(uint32_t maxFrameLengthMs); /* Array of CFE and ISP device streams and associated buffers/streams. */ @@ -1885,7 +1886,8 @@ void PiSPCameraData::setCameraTimeout(uint32_t maxFrameLengthMs) cfe_[Cfe::Output0].dev()->setDequeueTimeout(timeout); } -void PiSPCameraData::prepareIspComplete(const ipa::RPi::BufferIds &buffers, bool stitchSwapBuffers) +void PiSPCameraData::prepareIspComplete(const ipa::RPi::BufferIds &buffers, bool stitchSwapBuffers, + [[maybe_unused]] unsigned int paramsBytesUsed) { unsigned int embeddedId = buffers.embedded & RPi::MaskID; unsigned int bayerId = buffers.bayer & RPi::MaskID; diff --git a/src/libcamera/pipeline/rpi/vc4/vc4.cpp b/src/libcamera/pipeline/rpi/vc4/vc4.cpp index 200e3b58724a..dca2c1c12549 100644 --- a/src/libcamera/pipeline/rpi/vc4/vc4.cpp +++ b/src/libcamera/pipeline/rpi/vc4/vc4.cpp @@ -79,7 +79,8 @@ public: void ispOutputDequeue(FrameBuffer *buffer); void processStatsComplete(const ipa::RPi::BufferIds &buffers); - void prepareIspComplete(const ipa::RPi::BufferIds &buffers, bool stitchSwapBuffers); + void prepareIspComplete(const ipa::RPi::BufferIds &buffers, bool stitchSwapBuffers, + unsigned int paramsBytesUsed); void setIspControls(const ControlList &controls); void setCameraTimeout(uint32_t maxFrameLengthMs); @@ -863,7 +864,8 @@ void Vc4CameraData::processStatsComplete(const ipa::RPi::BufferIds &buffers) } void Vc4CameraData::prepareIspComplete(const ipa::RPi::BufferIds &buffers, - [[maybe_unused]] bool stitchSwapBuffers) + [[maybe_unused]] bool stitchSwapBuffers, + [[maybe_unused]] unsigned int paramsBytesUsed) { unsigned int embeddedId = buffers.embedded & RPi::MaskID; unsigned int bayer = buffers.bayer & RPi::MaskID;