diff --git a/src/libcamera/pipeline/rpi/common/rpi_stream.h b/src/libcamera/pipeline/rpi/common/rpi_stream.h index 300a352a7..179766851 100644 --- a/src/libcamera/pipeline/rpi/common/rpi_stream.h +++ b/src/libcamera/pipeline/rpi/common/rpi_stream.h @@ -97,14 +97,14 @@ class Stream : public libcamera::Stream using StreamFlags = Flags; Stream() - : flags_(StreamFlag::None), id_(0), swDownscale_(0) + : flags_(StreamFlag::None), id_(0), swDownscale_(0), ispIndex_(-1) { } Stream(const char *name, MediaEntity *dev, StreamFlags flags = StreamFlag::None) : flags_(flags), name_(name), dev_(std::make_unique(dev)), id_(0), - swDownscale_(0) + swDownscale_(0), ispIndex_(-1) { } @@ -125,6 +125,9 @@ class Stream : public libcamera::Stream void setExportedBuffer(FrameBuffer *buffer); + void setIspIndex(int ispIndex) { ispIndex_ = ispIndex; } + int getIspIndex() const { return ispIndex_; } + int allocateBuffers(unsigned int count); int queueBuffer(FrameBuffer *buffer); void returnBuffer(FrameBuffer *buffer); @@ -181,6 +184,9 @@ class Stream : public libcamera::Stream * as the stream needs to maintain ownership of these buffers. */ std::vector> internalBuffers_; + + /* For output streams, the ISP branch for this stream (otherwise -1). */ + int ispIndex_; }; /* diff --git a/src/libcamera/pipeline/rpi/pisp/pisp.cpp b/src/libcamera/pipeline/rpi/pisp/pisp.cpp index c9d89d58b..cde2b225c 100644 --- a/src/libcamera/pipeline/rpi/pisp/pisp.cpp +++ b/src/libcamera/pipeline/rpi/pisp/pisp.cpp @@ -1524,6 +1524,7 @@ int PiSPCameraData::platformConfigure(const RPi::RPiCameraConfiguration *rpiConf beEnables |= PISP_BE_RGB_ENABLE_OUTPUT0; ispIndex = 0; } + stream->setIspIndex(ispIndex); format = outStreams[i].format; bool needs32BitConversion = adjustDeviceFormat(format); @@ -2306,6 +2307,19 @@ void PiSPCameraData::tryRunPipeline() Request *request = requestQueue_.front(); ASSERT(request->metadata().empty()); + /* Pass the plane offsets of any output buffers to the Back End ISP. */ + for (auto const &[stream, buffer] : request->buffers()) { + int ispIndex = static_cast(stream)->getIspIndex(); + if (ispIndex >= 0) { + unsigned int offset = buffer->planes()[0].offset; + unsigned int offset2 = 0; + if (buffer->planes().size() > 1) + offset2 = buffer->planes()[1].offset; + pisp_be_output_format_extra extra{ 0, 0, { offset, offset2 } }; + be_->SetOutputFormatExtra(ispIndex, extra); + } + } + /* See if a new ScalerCrop value needs to be applied. */ applyScalerCrop(request->controls());