| Message ID | 20260527081534.20245-5-robert.mader@collabora.com |
|---|---|
| State | New |
| Headers | show |
| Series |
|
| Related | show |
Quoting Robert Mader (2026-05-27 09:15:33) > As the only current user - DebayerEGL::process() - already has the buffer > mapped. Currently this shouldn't impact performance as the kernel should > already avoid remapping the dmabuf - i.e. we implicitly benefit from the > fact that the mentioned function holds its mapping during the runtime of > processFrame(). In a following commit DebayerEGL::process() will change > in a way that would make keeping the mapping counter-intuitive. Thus > this change ensures we'll not accidentally start mapping the buffer > twice per frame. > Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> > Signed-off-by: Robert Mader <robert.mader@collabora.com> > --- > include/libcamera/internal/software_isp/swstats_cpu.h | 2 +- > src/libcamera/software_isp/debayer_egl.cpp | 2 +- > src/libcamera/software_isp/swstats_cpu.cpp | 11 ++--------- > 3 files changed, 4 insertions(+), 11 deletions(-) > > diff --git a/include/libcamera/internal/software_isp/swstats_cpu.h b/include/libcamera/internal/software_isp/swstats_cpu.h > index b5348c6fe..686e3d981 100644 > --- a/include/libcamera/internal/software_isp/swstats_cpu.h > +++ b/include/libcamera/internal/software_isp/swstats_cpu.h > @@ -56,7 +56,7 @@ public: > void setWindow(const Rectangle &window); > void startFrame(uint32_t frame); > void finishFrame(uint32_t frame, uint32_t bufferId); > - void processFrame(uint32_t frame, uint32_t bufferId, FrameBuffer *input); > + void processFrame(uint32_t frame, uint32_t bufferId, MappedFrameBuffer &input); > > void processLine0(uint32_t frame, unsigned int y, const uint8_t *src[], unsigned int statsBufferIndex = 0) > { > diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp > index 696498a58..d08634640 100644 > --- a/src/libcamera/software_isp/debayer_egl.cpp > +++ b/src/libcamera/software_isp/debayer_egl.cpp > @@ -555,7 +555,7 @@ void DebayerEGL::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output > metadata.planes()[0].bytesused = output->planes()[0].length; > > /* Calculate stats for the whole frame */ > - stats_->processFrame(frame, 0, input); > + stats_->processFrame(frame, 0, in); > dmaSyncers.clear(); > > egl_.syncOutput(); > diff --git a/src/libcamera/software_isp/swstats_cpu.cpp b/src/libcamera/software_isp/swstats_cpu.cpp > index 0815ec9a3..fb7a5301d 100644 > --- a/src/libcamera/software_isp/swstats_cpu.cpp > +++ b/src/libcamera/software_isp/swstats_cpu.cpp > @@ -543,7 +543,7 @@ void SwStatsCpu::processBayerFrame2(MappedFrameBuffer &in) > * > * This may only be called after a successful setWindow() call. > */ > -void SwStatsCpu::processFrame(uint32_t frame, uint32_t bufferId, FrameBuffer *input) > +void SwStatsCpu::processFrame(uint32_t frame, uint32_t bufferId, MappedFrameBuffer &input) > { > if (frame % kStatPerNumFrames) { > finishFrame(frame, bufferId); > @@ -552,14 +552,7 @@ void SwStatsCpu::processFrame(uint32_t frame, uint32_t bufferId, FrameBuffer *in > > bench_.startFrame(); > startFrame(frame); > - > - MappedFrameBuffer in(input, MappedFrameBuffer::MapFlag::Read); > - if (!in.isValid()) { > - LOG(SwStatsCpu, Error) << "mmap-ing buffer(s) failed"; > - return; > - } > - > - (this->*processFrame_)(in); > + (this->*processFrame_)(input); > finishFrame(frame, bufferId); > bench_.finishFrame(); > } > -- > 2.54.0 >
diff --git a/include/libcamera/internal/software_isp/swstats_cpu.h b/include/libcamera/internal/software_isp/swstats_cpu.h index b5348c6fe..686e3d981 100644 --- a/include/libcamera/internal/software_isp/swstats_cpu.h +++ b/include/libcamera/internal/software_isp/swstats_cpu.h @@ -56,7 +56,7 @@ public: void setWindow(const Rectangle &window); void startFrame(uint32_t frame); void finishFrame(uint32_t frame, uint32_t bufferId); - void processFrame(uint32_t frame, uint32_t bufferId, FrameBuffer *input); + void processFrame(uint32_t frame, uint32_t bufferId, MappedFrameBuffer &input); void processLine0(uint32_t frame, unsigned int y, const uint8_t *src[], unsigned int statsBufferIndex = 0) { diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp index 696498a58..d08634640 100644 --- a/src/libcamera/software_isp/debayer_egl.cpp +++ b/src/libcamera/software_isp/debayer_egl.cpp @@ -555,7 +555,7 @@ void DebayerEGL::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output metadata.planes()[0].bytesused = output->planes()[0].length; /* Calculate stats for the whole frame */ - stats_->processFrame(frame, 0, input); + stats_->processFrame(frame, 0, in); dmaSyncers.clear(); egl_.syncOutput(); diff --git a/src/libcamera/software_isp/swstats_cpu.cpp b/src/libcamera/software_isp/swstats_cpu.cpp index 0815ec9a3..fb7a5301d 100644 --- a/src/libcamera/software_isp/swstats_cpu.cpp +++ b/src/libcamera/software_isp/swstats_cpu.cpp @@ -543,7 +543,7 @@ void SwStatsCpu::processBayerFrame2(MappedFrameBuffer &in) * * This may only be called after a successful setWindow() call. */ -void SwStatsCpu::processFrame(uint32_t frame, uint32_t bufferId, FrameBuffer *input) +void SwStatsCpu::processFrame(uint32_t frame, uint32_t bufferId, MappedFrameBuffer &input) { if (frame % kStatPerNumFrames) { finishFrame(frame, bufferId); @@ -552,14 +552,7 @@ void SwStatsCpu::processFrame(uint32_t frame, uint32_t bufferId, FrameBuffer *in bench_.startFrame(); startFrame(frame); - - MappedFrameBuffer in(input, MappedFrameBuffer::MapFlag::Read); - if (!in.isValid()) { - LOG(SwStatsCpu, Error) << "mmap-ing buffer(s) failed"; - return; - } - - (this->*processFrame_)(in); + (this->*processFrame_)(input); finishFrame(frame, bufferId); bench_.finishFrame(); }
As the only current user - DebayerEGL::process() - already has the buffer mapped. Currently this shouldn't impact performance as the kernel should already avoid remapping the dmabuf - i.e. we implicitly benefit from the fact that the mentioned function holds its mapping during the runtime of processFrame(). In a following commit DebayerEGL::process() will change in a way that would make keeping the mapping counter-intuitive. Thus this change ensures we'll not accidentally start mapping the buffer twice per frame. Signed-off-by: Robert Mader <robert.mader@collabora.com> --- include/libcamera/internal/software_isp/swstats_cpu.h | 2 +- src/libcamera/software_isp/debayer_egl.cpp | 2 +- src/libcamera/software_isp/swstats_cpu.cpp | 11 ++--------- 3 files changed, 4 insertions(+), 11 deletions(-)