[v1,4/5] pipeline: rpi: Add infrastructure for additional pipeline "stages"
diff mbox series

Message ID 20261203130113.47873-5-david.plowman@raspberrypi.com
State New
Headers show
Series
  • Extra pipeline processing "stages" for Raspberry Pi
Related show

Commit Message

David Plowman Dec. 2, 2026, 4:13 p.m. UTC
A pipeline stage operates on a raw Bayer buffer after the IPA's
prepareIsp and before the main ISP runs.

Stages are configured and controlled like other IPAs, but those
parameters are passed back to the pipeline handler to create the
requested stages, and to run them in a per-camera worker thread.

Most of this commit defines the Stage base class and the StageRunner
that executes them, trying to follow the pattern of the Software
ISP. But we also include the PiSP/vc4 code that allows the pipeline
handler to stay in the "busy" state while those stages are running,
moving on only when the runner signals completion.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
---
 src/libcamera/pipeline/rpi/common/meson.build |   1 +
 .../pipeline/rpi/common/pipeline_base.cpp     |  83 ++++++++++
 .../pipeline/rpi/common/pipeline_base.h       |  36 +++++
 src/libcamera/pipeline/rpi/common/stage.h     |  75 +++++++++
 .../pipeline/rpi/common/stage_runner.cpp      | 149 ++++++++++++++++++
 .../pipeline/rpi/common/stage_runner.h        |  74 +++++++++
 src/libcamera/pipeline/rpi/pisp/pisp.cpp      |  37 ++++-
 src/libcamera/pipeline/rpi/vc4/vc4.cpp        |  34 +++-
 8 files changed, 482 insertions(+), 7 deletions(-)
 create mode 100644 src/libcamera/pipeline/rpi/common/stage.h
 create mode 100644 src/libcamera/pipeline/rpi/common/stage_runner.cpp
 create mode 100644 src/libcamera/pipeline/rpi/common/stage_runner.h

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/rpi/common/meson.build b/src/libcamera/pipeline/rpi/common/meson.build
index b2b1a0a6..5411ae84 100644
--- a/src/libcamera/pipeline/rpi/common/meson.build
+++ b/src/libcamera/pipeline/rpi/common/meson.build
@@ -4,4 +4,5 @@  libcamera_internal_sources += files([
     'delayed_controls.cpp',
     'pipeline_base.cpp',
     'rpi_stream.cpp',
+    'stage_runner.cpp',
 ])
diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp
index 6944d5c4..2c324035 100644
--- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp
+++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp
@@ -559,6 +559,12 @@  int PipelineHandlerBase::configure(Camera *camera, CameraConfiguration *config)
 		return ret;
 	}
 
+	ret = data->configureStages(result.stageConfig);
+	if (ret) {
+		LOG(RPI, Error) << "Failed to configure the pipeline stages: " << ret;
+		return ret;
+	}
+
 	/*
 	 * Update the ScalerCropMaximum to the correct value for this camera mode.
 	 * For us, it's the same as the "analogue crop".
@@ -700,6 +706,8 @@  int PipelineHandlerBase::start(Camera *camera, const ControlList *controls)
 	/* A good moment to add an initial clock sample. */
 	data->wallClockRecovery_.addSample();
 
+	data->startStages();
+
 	/*
 	 * Reset the delayed controls with the gain and exposure values set by
 	 * the IPA.
@@ -729,6 +737,10 @@  void PipelineHandlerBase::stopDevice(Camera *camera)
 	CameraData *data = cameraData(camera);
 
 	data->state_ = CameraData::State::Stopped;
+
+	/* Wait for any stages to finish. Any pending completions will be discarded. */
+	data->stopStages();
+
 	data->platformStop();
 
 	for (const auto stream : data->streams_) {
@@ -1265,6 +1277,77 @@  int CameraData::configureIPA(const CameraConfiguration *config, ipa::RPi::Config
 	return 0;
 }
 
+/*
+ * Configure all the pipeline stages enabled in the stage configuration from
+ * the IPA, and make a list of them for the worker to run.
+ */
+int CameraData::configureStages(const ipa::RPi::StageConfig &config)
+{
+	V4L2DeviceFormat format;
+	int ret = frontendDevice()->getFormat(&format);
+	if (ret) {
+		LOG(RPI, Error) << "Failed to get the frontend format";
+		return ret;
+	}
+
+	stageFormat_.pixelFormat = format.fourcc.toPixelFormat();
+	stageFormat_.size = format.size;
+	stageFormat_.stride = format.planes[0].bpl;
+
+	ret = stageRunner_.configure(config, stageFormat_);
+	if (ret)
+		return ret;
+
+	if (stagesActive())
+		LOG(RPI, Debug) << "Pipeline stages active, raw format "
+				<< stageFormat_.pixelFormat << " " << stageFormat_.size
+				<< " stride " << stageFormat_.stride;
+
+	return 0;
+}
+
+bool CameraData::stagesActive() const
+{
+	return stageRunner_.hasActiveStages();
+}
+
+void CameraData::startStages()
+{
+	if (stagesActive())
+		stageRunner_.start();
+}
+
+/* Wait for the stages to finish and stop them. */
+void CameraData::stopStages()
+{
+	stageRunner_.stop();
+}
+
+/* Pass the frame to the stage worker thread, along with all the info it needs. */
+void CameraData::runStages(const ipa::RPi::BufferIds &buffers, const ipa::RPi::StageParams &params,
+			   const BufferObject &bayer)
+{
+	stageBuffers_ = buffers;
+
+	StageJob job;
+	job.params = params;
+	if (bayer.mapped && !bayer.mapped->planes().empty())
+		job.bayerData = bayer.mapped->planes()[0];
+	job.bayerFd = bayer.buffer->planes()[0].fd;
+	job.bayerFormat = stageFormat_;
+
+	stageRunner_.run(job);
+}
+
+/* This is what gets signalled when all the stages finish with a frame. */
+void CameraData::stagesComplete()
+{
+	if (!isRunning())
+		return;
+
+	platformStagesComplete(stageBuffers_);
+}
+
 void CameraData::metadataReady(const ControlList &metadata)
 {
 	if (!isRunning())
diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.h b/src/libcamera/pipeline/rpi/common/pipeline_base.h
index 7b872555..408a4b58 100644
--- a/src/libcamera/pipeline/rpi/common/pipeline_base.h
+++ b/src/libcamera/pipeline/rpi/common/pipeline_base.h
@@ -33,6 +33,8 @@ 
 
 #include "delayed_controls.h"
 #include "rpi_stream.h"
+#include "stage.h"
+#include "stage_runner.h"
 
 using namespace std::chrono_literals;
 
@@ -51,6 +53,12 @@  public:
 		: Camera::Private(pipe), state_(State::Stopped),
 		  startupFrameCount_(0), invalidFrameCount_(0), buffersAllocated_(false)
 	{
+		stageRunner_.stagesComplete.connect(this, &CameraData::stagesComplete);
+
+		/*
+		 * Stages that can run on every platform would be added here:
+		 * e.g. addStage(std::make_unique<ExampleStage>());
+		 */
 	}
 
 	virtual ~CameraData()
@@ -99,6 +107,21 @@  public:
 
 	virtual int platformPipelineConfigure(const std::unique_ptr<ValueNode> &root) = 0;
 
+	/*
+	 * Pipeline handler "stages" (stage.h) operate on the raw Bayer
+	 * buffer after the IPA's prepareIsp, and before the ISP proper. They
+	 * run in a per-camera worker thread, which is all handled here.
+	 */
+	int configureStages(const ipa::RPi::StageConfig &config);
+	void startStages();
+	void stopStages();
+	bool stagesActive() const;
+	void runStages(const ipa::RPi::BufferIds &buffers, const ipa::RPi::StageParams &params,
+		       const BufferObject &bayer);
+	void stagesComplete();
+	/* How the platform carries on with a frame once its stages are done. */
+	virtual void platformStagesComplete(const ipa::RPi::BufferIds &buffers) = 0;
+
 	std::unique_ptr<ipa::RPi::IPAProxyRPi> ipa_;
 
 	std::unique_ptr<CameraSensor> sensor_;
@@ -196,8 +219,21 @@  protected:
 
 	virtual void tryRunPipeline() = 0;
 
+	/* Register a stage. Platforms add their own stages in their constructors. */
+	void addStage(std::unique_ptr<Stage> stage) { stageRunner_.addStage(std::move(stage)); }
+
 private:
 	void checkRequestCompleted();
+
+	/* Owns the stages, and runs them in its worker thread. */
+	StageRunner stageRunner_;
+	/* The raw Bayer format (taken from the frontend device), for the stages. */
+	StageFormat stageFormat_;
+	/*
+	 * The buffers of the frame in the stages, for when they've finished (there's
+	 * only ever a single frame in flight).
+	 */
+	ipa::RPi::BufferIds stageBuffers_;
 };
 
 class PipelineHandlerBase : public PipelineHandler
diff --git a/src/libcamera/pipeline/rpi/common/stage.h b/src/libcamera/pipeline/rpi/common/stage.h
new file mode 100644
index 00000000..d3f1b74f
--- /dev/null
+++ b/src/libcamera/pipeline/rpi/common/stage.h
@@ -0,0 +1,75 @@ 
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2026, Raspberry Pi Ltd
+ *
+ * Base class for pipeline handler "stages"
+ */
+
+#pragma once
+
+#include <span>
+#include <stdint.h>
+
+#include <libcamera/base/shared_fd.h>
+
+#include <libcamera/geometry.h>
+#include <libcamera/pixel_format.h>
+
+#include <libcamera/ipa/raspberrypi_ipa_interface.h>
+
+namespace libcamera {
+
+namespace RPi {
+
+/* The format of the raw Bayer buffers. */
+struct StageFormat {
+	PixelFormat pixelFormat;
+	Size size;
+	unsigned int stride = 0;
+};
+
+/* Everything the stages need to process a frame. */
+struct StageJob {
+	/* Per-frame parameters for all the stages, from the IPA. */
+	ipa::RPi::StageParams params;
+
+	/* The raw Bayer buffer (empty if not mapped) and associated info. */
+	std::span<uint8_t> bayerData;
+	SharedFD bayerFd;
+	StageFormat bayerFormat;
+};
+
+/*
+ * A pipeline handler stage operates on the raw Bayer buffer after the IPA's
+ * prepareIsp and before the ISP proper. To create one, derive from Stage and
+ * implement the functions below. It gets added in the CameraData constructor
+ * (or a platform's derived constructor if it can't run everywhere).
+ *
+ * An IPA algorithm must also be provided to supply the configuration and
+ * per-frame parameters.
+ */
+class Stage
+{
+public:
+	virtual ~Stage() = default;
+
+	virtual const char *name() const = 0;
+
+	/*
+	 * Called when the camera is configured. Return a positive value if
+	 * the stage will run, 0 if it won't, or a negative error code if it
+	 * should run but can't, which causes the camera configuration to fail.
+	 */
+	virtual int configure(const ipa::RPi::StageConfig &config, const StageFormat &format) = 0;
+
+	/* Called when the camera starts and stops, for stages that are enabled. */
+	virtual void start() {}
+	virtual void stop() {}
+
+	/* Runs in the stage worker thread for every frame. */
+	virtual void run(StageJob &job) = 0;
+};
+
+} /* namespace RPi */
+
+} /* namespace libcamera */
diff --git a/src/libcamera/pipeline/rpi/common/stage_runner.cpp b/src/libcamera/pipeline/rpi/common/stage_runner.cpp
new file mode 100644
index 00000000..fb227f3b
--- /dev/null
+++ b/src/libcamera/pipeline/rpi/common/stage_runner.cpp
@@ -0,0 +1,149 @@ 
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2026, Raspberry Pi Ltd
+ *
+ * Worker thread for running pipeline handler stages
+ *
+ * The structure broadly follows the Software ISP (software_isp.cpp): an
+ * object used from the pipeline handler has a worker thread where it runs
+ * its "stages", signalling back to the pipeline handler when they're done.
+ */
+
+#include "stage_runner.h"
+
+#include <libcamera/base/log.h>
+#include <libcamera/base/message.h>
+
+namespace libcamera {
+
+LOG_DECLARE_CATEGORY(RPI)
+
+namespace RPi {
+
+void StageWorker::process(StageJob job)
+{
+	for (Stage *stage : stages_)
+		stage->run(job);
+
+	done.emit();
+}
+
+void StageWorker::stop()
+{
+	/* Nothing to do. A blocking call will wait for everything to finish. */
+}
+
+StageRunner::StageRunner()
+	: stageWorkerThread_("RPiStageWorker"),
+	  worker_(std::make_unique<StageWorker>()), running_(false)
+{
+	/* All the actual work has to be done in the worker thread. */
+	worker_->done.connect(this, &StageRunner::workerDone);
+	worker_->moveToThread(&stageWorkerThread_);
+}
+
+StageRunner::~StageRunner()
+{
+	stop();
+
+	/* Destroy the worker object before its thread goes. */
+	worker_.reset();
+}
+
+/* Register a stage. Stages run in the order they were added. */
+void StageRunner::addStage(std::unique_ptr<Stage> stage)
+{
+	ASSERT(!running_);
+
+	LOG(RPI, Debug) << "Added stage " << stage->name();
+	stages_.push_back(std::move(stage));
+}
+
+/*
+ * Configure all the stages, and make a list of the enabled ones. Fails if any
+ * stage should run but can't, in which case none will run.
+ */
+int StageRunner::configure(const ipa::RPi::StageConfig &config, const StageFormat &format)
+{
+	ASSERT(!running_);
+
+	worker_->stages_.clear();
+
+	for (auto &stage : stages_) {
+		int ret = stage->configure(config, format);
+		if (ret < 0) {
+			LOG(RPI, Error) << "Stage " << stage->name() << " failed to configure: " << ret;
+			worker_->stages_.clear();
+			return ret;
+		}
+		if (ret > 0) {
+			worker_->stages_.push_back(stage.get());
+			LOG(RPI, Debug) << "Stage " << stage->name() << " is active";
+		}
+	}
+
+	return 0;
+}
+
+/* Start the stages, and the worker thread that runs them. */
+void StageRunner::start()
+{
+	if (running_)
+		return;
+
+	for (Stage *stage : worker_->stages_)
+		stage->start();
+
+	stageWorkerThread_.start();
+	running_ = true;
+
+	LOG(RPI, Debug) << "Stage worker thread started with "
+			<< worker_->stages_.size() << " stage(s)";
+}
+
+/*
+ * Wait for any job in progress to finish, and then stop everything
+ * (don't forget to send completion signals).
+ */
+void StageRunner::stop()
+{
+	if (!running_)
+		return;
+
+	stopThread();
+
+	for (Stage *stage : worker_->stages_)
+		stage->stop();
+
+	running_ = false;
+
+	LOG(RPI, Debug) << "Stage worker thread stopped";
+}
+
+void StageRunner::stopThread()
+{
+	if (!stageWorkerThread_.isRunning())
+		return;
+
+	worker_->invokeMethod(&StageWorker::stop, ConnectionTypeBlocking);
+
+	stageWorkerThread_.exit();
+	stageWorkerThread_.wait();
+
+	Thread::current()->dispatchMessages(Message::Type::InvokeMessage, this);
+}
+
+void StageRunner::run(const StageJob &job)
+{
+	ASSERT(running_);
+	worker_->invokeMethod(&StageWorker::process, ConnectionTypeQueued, job);
+}
+
+void StageRunner::workerDone()
+{
+	stagesComplete.emit();
+}
+
+} /* namespace RPi */
+
+} /* namespace libcamera */
diff --git a/src/libcamera/pipeline/rpi/common/stage_runner.h b/src/libcamera/pipeline/rpi/common/stage_runner.h
new file mode 100644
index 00000000..a5c72434
--- /dev/null
+++ b/src/libcamera/pipeline/rpi/common/stage_runner.h
@@ -0,0 +1,74 @@ 
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2026, Raspberry Pi Ltd
+ *
+ * Worker thread for running pipeline handler stages
+ */
+
+#pragma once
+
+#include <memory>
+#include <vector>
+
+#include <libcamera/base/object.h>
+#include <libcamera/base/signal.h>
+#include <libcamera/base/thread.h>
+
+#include "stage.h"
+
+namespace libcamera {
+
+namespace RPi {
+
+/*
+ * The StageWorker runs all the active stages in the worker thread,
+ * and signals when they're done.
+ */
+class StageWorker : public Object
+{
+public:
+	void process(StageJob job);
+	void stop();
+
+	Signal<> done;
+
+	/* The active stages. Only changed while the worker thread isn't running. */
+	std::vector<Stage *> stages_;
+};
+
+/*
+ * The StageRunner owns all the stages, keeps a list of the active ones, and
+ * has the worker thread that runs them.
+ */
+class StageRunner : public Object
+{
+public:
+	StageRunner();
+	~StageRunner();
+
+	void addStage(std::unique_ptr<Stage> stage);
+	int configure(const ipa::RPi::StageConfig &config, const StageFormat &format);
+	bool hasActiveStages() const { return !worker_->stages_.empty(); }
+
+	void start();
+	void stop();
+
+	void run(const StageJob &job);
+
+	Signal<> stagesComplete;
+
+private:
+	void stopThread();
+	void workerDone();
+
+	/* All the stages, in the order they run, whether active or not. */
+	std::vector<std::unique_ptr<Stage>> stages_;
+
+	Thread stageWorkerThread_;
+	std::unique_ptr<StageWorker> worker_;
+	bool running_;
+};
+
+} /* namespace RPi */
+
+} /* namespace libcamera */
diff --git a/src/libcamera/pipeline/rpi/pisp/pisp.cpp b/src/libcamera/pipeline/rpi/pisp/pisp.cpp
index 40ad91c2..fc7b283a 100644
--- a/src/libcamera/pipeline/rpi/pisp/pisp.cpp
+++ b/src/libcamera/pipeline/rpi/pisp/pisp.cpp
@@ -761,6 +761,7 @@  public:
 	void processStatsComplete(const ipa::RPi::BufferIds &buffers);
 	void prepareIspComplete(const ipa::RPi::BufferIds &buffers, bool stitchSwapBuffers,
 				const ipa::RPi::StageParams &stageParams);
+	void finishPrepareIsp(unsigned int bayerId, bool stitchSwapBuffers);
 	void setCameraTimeout(uint32_t maxFrameLengthMs);
 
 	/* Array of CFE and ISP device streams and associated buffers/streams. */
@@ -774,6 +775,12 @@  public:
 	SharedMemObject<BackEnd> be_;
 	bool beEnabled_;
 
+	/*
+	 * The stitch buffer swap flag for the frame in the pipeline stages, for
+	 * when they've finished. Only one frame is ever in the stages at a time.
+	 */
+	bool stagesStitchSwapBuffers_ = false;
+
 	std::unique_ptr<V4L2Subdevice> csi2Subdev_;
 	std::unique_ptr<V4L2Subdevice> feSubdev_;
 
@@ -807,6 +814,8 @@  public:
 private:
 	int platformConfigure(const RPi::RPiCameraConfiguration *rpiConfig) override;
 
+	void platformStagesComplete(const ipa::RPi::BufferIds &buffers) override;
+
 	int platformConfigureIpa([[maybe_unused]] ipa::RPi::ConfigParams &params) override
 	{
 		return 0;
@@ -1887,7 +1896,7 @@  void PiSPCameraData::setCameraTimeout(uint32_t maxFrameLengthMs)
 }
 
 void PiSPCameraData::prepareIspComplete(const ipa::RPi::BufferIds &buffers, bool stitchSwapBuffers,
-					[[maybe_unused]] const ipa::RPi::StageParams &stageParams)
+					const ipa::RPi::StageParams &stageParams)
 {
 	unsigned int embeddedId = buffers.embedded & RPi::MaskID;
 	unsigned int bayerId = buffers.bayer & RPi::MaskID;
@@ -1901,6 +1910,27 @@  void PiSPCameraData::prepareIspComplete(const ipa::RPi::BufferIds &buffers, bool
 		handleStreamBuffer(buffer, &cfe_[Cfe::Embedded]);
 	}
 
+	if (stagesActive()) {
+		/*
+		 * Run stages on the raw buffer asynchronously, this will signal
+		 * back to platformStagesComplete() once it's done.
+		 */
+		const RPi::BufferObject &bayer = cfe_[Cfe::Output0].getBuffers().at(bayerId);
+		stagesStitchSwapBuffers_ = stitchSwapBuffers;
+		runStages(buffers, stageParams, bayer);
+		return;
+	}
+
+	finishPrepareIsp(bayerId, stitchSwapBuffers);
+}
+
+/* Raw buffer is ready for the Back End, either straight from prepareIspComplete
+ * or via runStages signalling back to us.
+ */
+void PiSPCameraData::finishPrepareIsp(unsigned int bayerId, bool stitchSwapBuffers)
+{
+	FrameBuffer *buffer;
+
 	if (!beEnabled_) {
 		/*
 		 * If there is no need to run the Backend, just signal that the
@@ -1915,6 +1945,11 @@  void PiSPCameraData::prepareIspComplete(const ipa::RPi::BufferIds &buffers, bool
 	handleState();
 }
 
+void PiSPCameraData::platformStagesComplete(const ipa::RPi::BufferIds &buffers)
+{
+	finishPrepareIsp(buffers.bayer & RPi::MaskID, stagesStitchSwapBuffers_);
+}
+
 int PiSPCameraData::configureCfe()
 {
 	V4L2DeviceFormat cfeFormat;
diff --git a/src/libcamera/pipeline/rpi/vc4/vc4.cpp b/src/libcamera/pipeline/rpi/vc4/vc4.cpp
index 4bcaae54..7a010cf3 100644
--- a/src/libcamera/pipeline/rpi/vc4/vc4.cpp
+++ b/src/libcamera/pipeline/rpi/vc4/vc4.cpp
@@ -81,6 +81,8 @@  public:
 	void processStatsComplete(const ipa::RPi::BufferIds &buffers);
 	void prepareIspComplete(const ipa::RPi::BufferIds &buffers, bool stitchSwapBuffers,
 				const ipa::RPi::StageParams &stageParams);
+	void queueIspInput(unsigned int bayerId);
+	void platformStagesComplete(const ipa::RPi::BufferIds &buffers) override;
 	void setIspControls(const ControlList &controls);
 	void setCameraTimeout(uint32_t maxFrameLengthMs);
 
@@ -866,7 +868,7 @@  void Vc4CameraData::processStatsComplete(const ipa::RPi::BufferIds &buffers)
 
 void Vc4CameraData::prepareIspComplete(const ipa::RPi::BufferIds &buffers,
 				       [[maybe_unused]] bool stitchSwapBuffers,
-				       [[maybe_unused]] const ipa::RPi::StageParams &stageParams)
+				       const ipa::RPi::StageParams &stageParams)
 {
 	unsigned int embeddedId = buffers.embedded & RPi::MaskID;
 	unsigned int bayer = buffers.bayer & RPi::MaskID;
@@ -875,11 +877,15 @@  void Vc4CameraData::prepareIspComplete(const ipa::RPi::BufferIds &buffers,
 	if (!isRunning())
 		return;
 
-	buffer = unicam_[Unicam::Image].getBuffers().at(bayer & RPi::MaskID).buffer;
-	LOG(RPI, Debug) << "Input re-queue to ISP, buffer id " << (bayer & RPi::MaskID)
-			<< ", timestamp: " << buffer->metadata().timestamp;
-
-	isp_[Isp::Input].queueBuffer(buffer);
+	if (stagesActive()) {
+		/*
+		 * Run stages on the raw buffer asynchronously, this will signal
+		 * back to platformStagesComplete() once it's done.
+		 */
+		const RPi::BufferObject &bayerBuffer = unicam_[Unicam::Image].getBuffers().at(bayer);
+		runStages(buffers, stageParams, bayerBuffer);
+	} else
+		queueIspInput(bayer);
 
 	if (sensorMetadata_ && embeddedId) {
 		buffer = unicam_[Unicam::Embedded].getBuffers().at(embeddedId & RPi::MaskID).buffer;
@@ -889,6 +895,22 @@  void Vc4CameraData::prepareIspComplete(const ipa::RPi::BufferIds &buffers,
 	handleState();
 }
 
+void Vc4CameraData::queueIspInput(unsigned int bayerId)
+{
+	FrameBuffer *buffer = unicam_[Unicam::Image].getBuffers().at(bayerId).buffer;
+
+	LOG(RPI, Debug) << "Input re-queue to ISP, buffer id " << bayerId
+			<< ", timestamp: " << buffer->metadata().timestamp;
+
+	isp_[Isp::Input].queueBuffer(buffer);
+}
+
+void Vc4CameraData::platformStagesComplete(const ipa::RPi::BufferIds &buffers)
+{
+	queueIspInput(buffers.bayer & RPi::MaskID);
+	handleState();
+}
+
 void Vc4CameraData::setIspControls(const ControlList &controls)
 {
 	ControlList ctrls = controls;