[PATCH v2 12/13] libcamera: software_isp: Make input buffer copying configurable

Milan Zamazal mzamazal at redhat.com
Tue Apr 23 12:30:27 CEST 2024


On some platforms, working directly on the input buffer is very slow due
to disabled caching.  This is why we copy the input buffer into standard
(cached) memory.  This is an unnecessary overhead on platforms with
cached buffers.

Let's make input buffer copying configurable.  The default is still
copying, as it's overhead is much lower than contingent operations on
non-cached memory.  Ideally, we should improve this in future to set the
default to non-copying if we can be sure under observable circumstances
that we are working with cached buffers.

Completes software ISP TODO #6.

Signed-off-by: Milan Zamazal <mzamazal at redhat.com>
---
 Documentation/runtime_configuration.rst    |  2 ++
 src/libcamera/software_isp/TODO            | 11 -----------
 src/libcamera/software_isp/debayer_cpu.cpp |  5 ++++-
 3 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/Documentation/runtime_configuration.rst b/Documentation/runtime_configuration.rst
index d3972363..ed6370bb 100644
--- a/Documentation/runtime_configuration.rst
+++ b/Documentation/runtime_configuration.rst
@@ -48,6 +48,7 @@ file structure:
         config_file: # full path
         tuning_file: # full path
       simple:
+        copy_input_buffer: # true/false
         supported_devices:
         - driver: # driver name, e.g. `mxc-isi`
           software_isp: # true/false
@@ -74,6 +75,7 @@ Configuration file example
        rpi:
          config_file: /usr/local/share/libcamera/pipeline/rpi/vc4/minimal_mem.yaml
        simple:
+         copy_input_buffer: false
          supported_devices:
          - driver: mxc-isi
            software_isp: true
diff --git a/src/libcamera/software_isp/TODO b/src/libcamera/software_isp/TODO
index 4fcee39b..15396322 100644
--- a/src/libcamera/software_isp/TODO
+++ b/src/libcamera/software_isp/TODO
@@ -103,17 +103,6 @@ per-frame buffers like we do for hardware ISPs.
 
 ---
 
-6. Input buffer copying configuration
-
-> DebayerCpu::DebayerCpu(std::unique_ptr<SwStatsCpu> stats)
-> 	: stats_(std::move(stats)), gammaCorrection_(1.0)
-> {
-> 	enableInputMemcpy_ = true;
-
-Set this appropriately and/or make it configurable.
-
----
-
 7. Performance measurement configuration
 
 > void DebayerCpu::process(FrameBuffer *input, FrameBuffer *output, DebayerParams params)
diff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp
index 88d6578b..fa538927 100644
--- a/src/libcamera/software_isp/debayer_cpu.cpp
+++ b/src/libcamera/software_isp/debayer_cpu.cpp
@@ -19,6 +19,7 @@
 
 #include "libcamera/internal/bayer_format.h"
 #include "libcamera/internal/framebuffer.h"
+#include "libcamera/internal/global_configuration.h"
 #include "libcamera/internal/mapped_framebuffer.h"
 
 namespace libcamera {
@@ -45,7 +46,9 @@ DebayerCpu::DebayerCpu(std::unique_ptr<SwStatsCpu> stats)
 	 * always set it to true as the safer choice but this should be changed in
 	 * future.
 	 */
-	enableInputMemcpy_ = true;
+	enableInputMemcpy_ = GlobalConfiguration::option<bool>(
+				     "pipelines.simple.copy_input_buffer")
+				     .value_or(true);
 
 	/* Initialize gamma to 1.0 curve */
 	for (unsigned int i = 0; i < kGammaLookupSize; i++)
-- 
2.42.0



More information about the libcamera-devel mailing list