Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/libcamera/pipeline/rpi/common/rpi_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,14 @@ class Stream : public libcamera::Stream
using StreamFlags = Flags<StreamFlag>;

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<V4L2VideoDevice>(dev)), id_(0),
swDownscale_(0)
swDownscale_(0), ispIndex_(-1)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe rename to ispOutputIndex_ ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can do. I also note there's an ispIndex in the cropParams, and I wonder if we could remove that if there's an easy route to get to the relevant Stream. But that could always be a later change.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, I forgot that we do have the index in cropParams_!

{
}

Expand All @@ -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);
Expand Down Expand Up @@ -181,6 +184,9 @@ class Stream : public libcamera::Stream
* as the stream needs to maintain ownership of these buffers.
*/
std::vector<std::unique_ptr<FrameBuffer>> internalBuffers_;

/* For output streams, the ISP branch for this stream (otherwise -1). */
int ispIndex_;
};

/*
Expand Down
14 changes: 14 additions & 0 deletions src/libcamera/pipeline/rpi/pisp/pisp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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<const RPi::Stream *>(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());

Expand Down