From patchwork Wed Dec 2 16:13:25 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 29152 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 5F2A8C3304 for ; Thu, 3 Dec 2026 13:01:26 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0257A6AB3D; Thu, 3 Dec 2026 14:01:22 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="djRATo6J"; dkim-atps=neutral Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E3A056AB32 for ; Thu, 3 Dec 2026 14:01:18 +0100 (CET) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-4bbd2c5931bso23944965e9.2 for ; Thu, 03 Dec 2026 05:01:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1796302878; x=1796907678; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=tf0sjbuXggJQ6MhZp0aCZPPG3eNNYUFFT5zYH3bjAXw=; b=djRATo6JFHhOgOZKzjQEIKS/E3m7EHXpspJAsdimhfiIjUtAAEb3h+u91h1hmWe+1Z B+wqBc1bx+2mKoWzYeCTmE/B7FUKqJTC4K5YjDsdBbX8NtSM13lf7sSucjYx1gCMZAv6 IDox9FBcGPZUwKHtnjIDBrEueVpxqki3pezIi53eNdlJWPyX3Y3UGskueIkp3Ox59geq WyR9ny0MWYycYP0NKWorUth3BA+M6gdGTSeVAUSLiVzd/zLaRjsiliv4vSOq/q1QaxL0 YH7CI7706Z9AXv1Kez+Wzk6aJMMTVGaDdbH68VS65uuqTCnklKGcr6Kw8lQf0EPWzxLw 82rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796302878; x=1796907678; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=tf0sjbuXggJQ6MhZp0aCZPPG3eNNYUFFT5zYH3bjAXw=; b=ZszFQ10J+OSi0pUDMCDknZXct6T0Rlmx2bu/k1CZQDExaxj9sUiypo9WN1i12ctxEs /V8my9WXj/5pSoyO3tf2lQNEi6CFYgQlCiFVRuOsoH24eKn9AhDx2vjt8bnOU9knpSri xYsgMeNXaRAd8uPs09SR1vUQN+ogrPExjLACn7vEV4qWOb1YtjtW2Q+MQA3d6TEm9vBV zLr15v9G6UMz0OHUyZgvdVG/0F+3/JkBwsu386KDin7ucbTvAKegGywUM1WU5OZduTEY ukyE81CCxc+2EVGjXDjU0I1Twi0Q8vMfhOUdxzp67y20n+KvnHF2M/cSj06sHkvQwhKD SwLQ== X-Gm-Message-State: APuU4Z8ohIXcDr51NWp5kZZJr1ZTLdy3oIDVtGpuIK0JjA6tCvOSHeap ry0xOsuQ/9ng16CUgO8uGrmCW0QE6mYSW6W74KAE38QsevOj4bV74i26pcVTYfhknG+79PxDl3B 4d9YBz2M= X-Gm-Gg: AZFdTZe2xPRjPj9cw9YJCE/FptUJBA6a++vMXyt4k0PpsEgNUcpi1h1PrpIK80Nljx4 6rUlMSxT/h+ShWvbCH0JgVFMYqIwMmk77c5egzJG61XKJyhDurZo5dunMDvDZpgU3+p5Fst7e/0 0xQ4Ph3V19znSv4Gc9KZuK4g1jVMnE07DYupIPcQBenCIAJZozkM5L09b17j3aLBDgYDe7YFPbF OTJ4hHU2cdBucgDZ+J9YQnhZoHHSJp2xXXuZp7+G/8cOSu+yqZLJhTSQ08Nb8vhNOIv/ef6DvgA t3H7W3ADneC29LDol7IjW9N7VVku8DvHHhpMrBR6Y5cgkEGt0XgwbnjcEiiO0TUSJ3IiLCzn3qw 1SEKfOto3YOVEiMwQlSqfJozwiB4OPhLAHJr05APUdc6xpCxz0tml0AljXYb24wJsJoznnrQgpc NECgAvunHrDYX2+QCBflkzmYcsp4ylnn9w1xbwWzM+aVtHSUt8y5F76D0Wo6zbEY7uFMOZy7K3O 0pbiF5cCY96Q1LxqwcN9/l6qozfSPtHyczKUhuPC4FW7LgBsnuWz1HujFjkwUgQGjjZPs3kWF3L zwap7ushRoh9Lt5Uk3HDLy3kiY6rTSLIaMKCOFA+FJESuQtASGOZkoE2pCFxbOk0WLSBLk9Cghl cBQTWDhpi8h2GgaqJFtkZkM7znSBXiKFn6lk9Bv6LONMOEooI3g== X-Received: by 2002:a05:600c:a085:b0:4bb:7bee:5496 with SMTP id 5b1f17b1804b1-4bb8880f04dmr898335965e9.13.1796302878108; Thu, 03 Dec 2026 05:01:18 -0800 (PST) Received: from davidp-hailo10.pitowers.org ([2a00:1098:3142:1f:9afe:54ff:fe21:ed41]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bbe005543esm81555685e9.5.2026.12.03.05.01.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 05:01:17 -0800 (PST) From: David Plowman To: libcamera-devel@lists.libcamera.org Cc: David Plowman Subject: [PATCH v1 3/5] ipa: rpi: Add StageConfig and StageParams to the IPA interface Date: Wed, 2 Dec 2026 16:13:25 +0000 Message-ID: <20261203130113.47873-4-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261203130113.47873-1-david.plowman@raspberrypi.com> References: <20261203130113.47873-1-david.plowman@raspberrypi.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 The newly proposed pipeline processing "stages" will still be configured and controlled through the existing IPA mechanism. StageConfig is returned by configureIPA to configure stages, and StageParams is returned by every prepareISP call with specific parameters for that frame. We include the boilerplate code for filling the config and params structures to be returned, and update the IPA event callback on the pipeline handler side for the new structures. As we have no real stages currently, the structures have placeholder fields. Signed-off-by: David Plowman --- include/libcamera/ipa/raspberrypi.mojom | 30 +++++++++++++++++---- src/ipa/rpi/common/ipa_base.cpp | 33 ++++++++++++++++++++++-- src/ipa/rpi/common/ipa_base.h | 6 +++++ src/libcamera/pipeline/rpi/pisp/pisp.cpp | 6 +++-- src/libcamera/pipeline/rpi/vc4/vc4.cpp | 6 +++-- 5 files changed, 70 insertions(+), 11 deletions(-) diff --git a/include/libcamera/ipa/raspberrypi.mojom b/include/libcamera/ipa/raspberrypi.mojom index ed048526..eaeb8398 100644 --- a/include/libcamera/ipa/raspberrypi.mojom +++ b/include/libcamera/ipa/raspberrypi.mojom @@ -46,11 +46,28 @@ struct ConfigParams { libcamera.SharedFD lsTableHandle; }; +/* + * Configuration of the pipeline handler "stages", which operate on the raw + * Bayer buffers after prepareIsp() and before the ISP proper. There will be + * one structure per stage type here. + */ +struct StageConfig { + /* Placeholder - remove once we have a stage. */ + bool unused; +}; + +/* Per-frame parameters for the pipeline handler stages, one structure per stage. */ +struct StageParams { + /* Placeholder - remove once we have a stage. */ + bool unused; +}; + struct ConfigResult { float modeSensitivity; libcamera.ControlInfoMap controlInfo; libcamera.ControlList sensorControls; libcamera.ControlList lensControls; + StageConfig stageConfig; }; struct StartResult { @@ -136,8 +153,9 @@ interface IPARPiInterface { * parameters, e.g. the lens shading table memory handle for VC4. * * The \a result parameter returns the available controls for the given - * camera mode, a list of controls to apply to the sensor device, and - * the requested mode's sensitivity characteristics. + * camera mode, a list of controls to apply to the sensor device, the + * requested mode's sensitivity characteristics, and the configuration + * of the pipeline handler extra processing "stages". */ configure(libcamera.IPACameraSensorInfo sensorInfo, ConfigParams params) => (int32 ret, ConfigResult result); @@ -223,13 +241,15 @@ interface IPARPiEventInterface { * \brief Signal completion of \a prepareIsp * \param[in] buffers Bayer and embedded buffers actioned. * \param[in] stitchSwapBuffers Whether the stitch block buffers need to be swapped. + * \param[in] stageParams Parameters for the pipeline handler stages for this frame. * * 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. + * processing the frame. Any pipeline handler stages are run, with the + * \a stageParams, before the ISP. The embedded data buffer may be recycled + * after this event. */ - prepareIspComplete(BufferIds buffers, bool stitchSwapBuffers); + prepareIspComplete(BufferIds buffers, bool stitchSwapBuffers, StageParams stageParams); /** * \fn processStatsComplete() diff --git a/src/ipa/rpi/common/ipa_base.cpp b/src/ipa/rpi/common/ipa_base.cpp index 2ed80d3e..7726a768 100644 --- a/src/ipa/rpi/common/ipa_base.cpp +++ b/src/ipa/rpi/common/ipa_base.cpp @@ -229,6 +229,9 @@ int32_t IpaBase::configure(const IPACameraSensorInfo &sensorInfo, const ConfigPa /* The pipeline handler passes out the mode's sensitivity. */ result->modeSensitivity = mode_.sensitivity; + /* Tell the pipeline handler which stages to run, and their configurations. */ + fillStageConfig(result->stageConfig); + if (firstStart_) { /* Supply initial values for frame durations. */ applyFrameDurations(defaultMinFrameDuration, defaultMaxFrameDuration); @@ -300,6 +303,9 @@ void IpaBase::start(const ControlList &controls, StartResult *result) controller_.switchMode(mode_, &metadata); + /* Extra pipeline "stages" won't want parameters from a before a mode switch. */ + lastStageParams_ = {}; + /* Reset the frame lengths queue state. */ lastTimeout_ = 0s; frameLengths_.clear(); @@ -504,8 +510,11 @@ void IpaBase::prepareIsp(const PrepareParams ¶ms) /* Actually prepare the ISP parameters for the frame. */ platformPrepareIsp(params, rpiMetadata); platformPrepareAgc(rpiMetadata); - } else + prepareStageParams(rpiMetadata); + } else { platformPrepareAgc(rpiMetadata); + repeatStageParams(); + } frameCount_++; @@ -514,7 +523,27 @@ 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_, lastStageParams_); +} + +/* Fill in the configuration for the pipeline handler stages. */ +void IpaBase::fillStageConfig(StageConfig &config) +{ + config = {}; +} + +/* Fill in the parameters for the pipeline handler stages for this frame. */ +void IpaBase::prepareStageParams([[maybe_unused]] const RPiController::Metadata &rpiMetadata) +{ + lastStageParams_ = {}; +} + +/* + * If prepare() was skipped for this frame, send the same stage params again, + * but this method allows for the possibility that some fields may need changing. + */ +void IpaBase::repeatStageParams() +{ } 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 0d7842f1..b9a87cfb 100644 --- a/src/ipa/rpi/common/ipa_base.h +++ b/src/ipa/rpi/common/ipa_base.h @@ -100,6 +100,9 @@ private: virtual void handleControls(const ControlList &controls) = 0; void fillDeviceStatus(const ControlList &sensorControls, unsigned int ipaContext); void reportMetadata(unsigned int ipaContext); + void fillStageConfig(StageConfig &config); + void prepareStageParams(const RPiController::Metadata &rpiMetadata); + void repeatStageParams(); void applyFrameDurations(utils::Duration minFrameDuration, utils::Duration maxFrameDuration); void applyAGC(struct AgcStatus *agcStatus, ControlList &ctrls); @@ -144,6 +147,9 @@ private: bool awbEnabled_; utils::Duration controllerMinFrameDuration_; + + /* If prepare() doesn't run, send the last pipeline "stage" parameters again. */ + StageParams lastStageParams_; }; } /* namespace ipa::RPi */ diff --git a/src/libcamera/pipeline/rpi/pisp/pisp.cpp b/src/libcamera/pipeline/rpi/pisp/pisp.cpp index 159c6b05..40ad91c2 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, + const ipa::RPi::StageParams &stageParams); 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]] const ipa::RPi::StageParams &stageParams) { 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 8b8eb166..4bcaae54 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, + const ipa::RPi::StageParams &stageParams); void setIspControls(const ControlList &controls); void setCameraTimeout(uint32_t maxFrameLengthMs); @@ -864,7 +865,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]] const ipa::RPi::StageParams &stageParams) { unsigned int embeddedId = buffers.embedded & RPi::MaskID; unsigned int bayer = buffers.bayer & RPi::MaskID;