[v3,12/39] libcamera: software_isp: Move DMA Sync code to Debayer base class
diff mbox series

Message ID 20251015012251.17508-13-bryan.odonoghue@linaro.org
State New
Headers show
Series
  • Add GLES 2.0 GPUISP to libcamera
Related show

Commit Message

Bryan O'Donoghue Oct. 15, 2025, 1:22 a.m. UTC
We can reuse the DMA Sync code in the GPUISP. Move the code we need to
the base class.

Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
---
 src/libcamera/software_isp/debayer.cpp     | 13 +++++++++++++
 src/libcamera/software_isp/debayer.h       |  2 ++
 src/libcamera/software_isp/debayer_cpu.cpp |  6 +-----
 3 files changed, 16 insertions(+), 5 deletions(-)

Comments

Kieran Bingham Oct. 15, 2025, 10:05 p.m. UTC | #1
Quoting Bryan O'Donoghue (2025-10-15 02:22:24)
> We can reuse the DMA Sync code in the GPUISP. Move the code we need to
> the base class.
> 
> Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
> ---
>  src/libcamera/software_isp/debayer.cpp     | 13 +++++++++++++
>  src/libcamera/software_isp/debayer.h       |  2 ++
>  src/libcamera/software_isp/debayer_cpu.cpp |  6 +-----
>  3 files changed, 16 insertions(+), 5 deletions(-)
> 
> diff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp
> index cf74b92b..847067aa 100644
> --- a/src/libcamera/software_isp/debayer.cpp
> +++ b/src/libcamera/software_isp/debayer.cpp
> @@ -214,4 +214,17 @@ void Debayer::setParams(DebayerParams &params)
>         gammaLut_ = params.gammaLut;
>  }
>  
> +/**
> + * \fn void Debayer::dmaSyncBegin(DebayerParams &params)

This doesn't match, but also I don't think you need to specify this
line.

> + * \brief Common CPU/GPU Dma Sync Buffer begin

Perhaps:

 * \param[out] dmaSyncers The Sync Operators
 * \param[in] input The input buffer
 * \param[in] output The output buffer

With all that fixed:

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>


> + */
> +void Debayer::dmaSyncBegin(std::vector<DmaSyncer> &dmaSyncers, FrameBuffer *input, FrameBuffer *output)
> +{
> +       for (const FrameBuffer::Plane &plane : input->planes())
> +               dmaSyncers.emplace_back(plane.fd, DmaSyncer::SyncType::Read);
> +
> +       for (const FrameBuffer::Plane &plane : output->planes())
> +               dmaSyncers.emplace_back(plane.fd, DmaSyncer::SyncType::Write);
> +}
> +
>  } /* namespace libcamera */
> diff --git a/src/libcamera/software_isp/debayer.h b/src/libcamera/software_isp/debayer.h
> index c04c289d..98d88fb3 100644
> --- a/src/libcamera/software_isp/debayer.h
> +++ b/src/libcamera/software_isp/debayer.h
> @@ -20,6 +20,7 @@
>  #include <libcamera/geometry.h>
>  #include <libcamera/stream.h>
>  
> +#include "libcamera/internal/dma_buf_allocator.h"
>  #include "libcamera/internal/global_configuration.h"
>  #include "libcamera/internal/software_isp/benchmark.h"
>  #include "libcamera/internal/software_isp/debayer_params.h"
> @@ -96,6 +97,7 @@ private:
>  
>  protected:
>         void setParams(DebayerParams &params);
> +       void dmaSyncBegin(std::vector<DmaSyncer> &dmaSyncers, FrameBuffer *input, FrameBuffer *output);
>  };
>  
>  } /* namespace libcamera */
> diff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp
> index 6be5cdbd..8f1b4e53 100644
> --- a/src/libcamera/software_isp/debayer_cpu.cpp
> +++ b/src/libcamera/software_isp/debayer_cpu.cpp
> @@ -22,7 +22,6 @@
>  #include <libcamera/formats.h>
>  
>  #include "libcamera/internal/bayer_format.h"
> -#include "libcamera/internal/dma_buf_allocator.h"
>  #include "libcamera/internal/framebuffer.h"
>  #include "libcamera/internal/global_configuration.h"
>  #include "libcamera/internal/mapped_framebuffer.h"
> @@ -752,11 +751,8 @@ void DebayerCpu::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output
>         bench_.startFrame();
>  
>         std::vector<DmaSyncer> dmaSyncers;
> -       for (const FrameBuffer::Plane &plane : input->planes())
> -               dmaSyncers.emplace_back(plane.fd, DmaSyncer::SyncType::Read);
>  
> -       for (const FrameBuffer::Plane &plane : output->planes())
> -               dmaSyncers.emplace_back(plane.fd, DmaSyncer::SyncType::Write);
> +       dmaSyncBegin(dmaSyncers, input, output);
>  
>         setParams(params);
>  
> -- 
> 2.51.0
>

Patch
diff mbox series

diff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp
index cf74b92b..847067aa 100644
--- a/src/libcamera/software_isp/debayer.cpp
+++ b/src/libcamera/software_isp/debayer.cpp
@@ -214,4 +214,17 @@  void Debayer::setParams(DebayerParams &params)
 	gammaLut_ = params.gammaLut;
 }
 
+/**
+ * \fn void Debayer::dmaSyncBegin(DebayerParams &params)
+ * \brief Common CPU/GPU Dma Sync Buffer begin
+ */
+void Debayer::dmaSyncBegin(std::vector<DmaSyncer> &dmaSyncers, FrameBuffer *input, FrameBuffer *output)
+{
+	for (const FrameBuffer::Plane &plane : input->planes())
+		dmaSyncers.emplace_back(plane.fd, DmaSyncer::SyncType::Read);
+
+	for (const FrameBuffer::Plane &plane : output->planes())
+		dmaSyncers.emplace_back(plane.fd, DmaSyncer::SyncType::Write);
+}
+
 } /* namespace libcamera */
diff --git a/src/libcamera/software_isp/debayer.h b/src/libcamera/software_isp/debayer.h
index c04c289d..98d88fb3 100644
--- a/src/libcamera/software_isp/debayer.h
+++ b/src/libcamera/software_isp/debayer.h
@@ -20,6 +20,7 @@ 
 #include <libcamera/geometry.h>
 #include <libcamera/stream.h>
 
+#include "libcamera/internal/dma_buf_allocator.h"
 #include "libcamera/internal/global_configuration.h"
 #include "libcamera/internal/software_isp/benchmark.h"
 #include "libcamera/internal/software_isp/debayer_params.h"
@@ -96,6 +97,7 @@  private:
 
 protected:
 	void setParams(DebayerParams &params);
+	void dmaSyncBegin(std::vector<DmaSyncer> &dmaSyncers, FrameBuffer *input, FrameBuffer *output);
 };
 
 } /* namespace libcamera */
diff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp
index 6be5cdbd..8f1b4e53 100644
--- a/src/libcamera/software_isp/debayer_cpu.cpp
+++ b/src/libcamera/software_isp/debayer_cpu.cpp
@@ -22,7 +22,6 @@ 
 #include <libcamera/formats.h>
 
 #include "libcamera/internal/bayer_format.h"
-#include "libcamera/internal/dma_buf_allocator.h"
 #include "libcamera/internal/framebuffer.h"
 #include "libcamera/internal/global_configuration.h"
 #include "libcamera/internal/mapped_framebuffer.h"
@@ -752,11 +751,8 @@  void DebayerCpu::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output
 	bench_.startFrame();
 
 	std::vector<DmaSyncer> dmaSyncers;
-	for (const FrameBuffer::Plane &plane : input->planes())
-		dmaSyncers.emplace_back(plane.fd, DmaSyncer::SyncType::Read);
 
-	for (const FrameBuffer::Plane &plane : output->planes())
-		dmaSyncers.emplace_back(plane.fd, DmaSyncer::SyncType::Write);
+	dmaSyncBegin(dmaSyncers, input, output);
 
 	setParams(params);