[v2,10/37] libcamera: software_isp: Move DMA Sync code to Debayer base class
diff mbox series

Message ID 20250824-b4-v0-5-2-gpuisp-v2-a-v2-10-96f4576c814e@linaro.org
State New
Headers show
Series
  • Add GLES 2.0 GPUISP to libcamera
Related show

Commit Message

Bryan O'Donoghue Aug. 24, 2025, 12:48 a.m. UTC
We can reuse the DMA Sync code in the GPUISP. Move the code we need to
the base class.

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

Milan Zamazal Aug. 26, 2025, 11:56 a.m. UTC | #1
Bryan O'Donoghue <bryan.odonoghue@linaro.org> writes:

> We can reuse the DMA Sync code in the GPUISP. Move the code we need to
> the base class.
>
> 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 fc2438c0d0161a36da2769d95836f282836b143d..75e4bffab0f082bdf6e5bdf3030b9f49d4877524 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

The description could be probably improved.

Reviewed-by: Milan Zamazal <mzamazal@redhat.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 5f692bcbdeec1447c596ebbdc984585948a34880..0af66b556bbf8993a66042a3a76cd50582209bce 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/software_isp/benchmark.h"
>  #include "libcamera/internal/software_isp/debayer_params.h"
>  
> @@ -85,6 +86,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 6ed17e9fc144bc7c3472d999b1e9c23236020963..9fce2a143ac9585eadcea41744d680bc9589c507 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/mapped_framebuffer.h"
>  
> @@ -740,11 +739,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);

Patch
diff mbox series

diff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp
index fc2438c0d0161a36da2769d95836f282836b143d..75e4bffab0f082bdf6e5bdf3030b9f49d4877524 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 5f692bcbdeec1447c596ebbdc984585948a34880..0af66b556bbf8993a66042a3a76cd50582209bce 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/software_isp/benchmark.h"
 #include "libcamera/internal/software_isp/debayer_params.h"
 
@@ -85,6 +86,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 6ed17e9fc144bc7c3472d999b1e9c23236020963..9fce2a143ac9585eadcea41744d680bc9589c507 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/mapped_framebuffer.h"
 
@@ -740,11 +739,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);