[v6,13/16] libcamera: software_isp: Make input buffer copying configurable
diff mbox series

Message ID 20241206171148.1189292-14-mzamazal@redhat.com
State New
Headers show
Series
  • Add global configuration file
Related show

Commit Message

Milan Zamazal Dec. 6, 2024, 5:11 p.m. UTC
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@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(-)

Patch
diff mbox series

diff --git a/Documentation/runtime_configuration.rst b/Documentation/runtime_configuration.rst
index 3f7a104f..4a34a3f5 100644
--- a/Documentation/runtime_configuration.rst
+++ b/Documentation/runtime_configuration.rst
@@ -55,6 +55,7 @@  file structure:
         - CAMERA-ID:
           tuning-file: # full path
       simple:
+        copy_input_buffer: # true/false
         supported_devices:
         - driver: # driver name, e.g. `mxc-isi`
           software_isp: # true/false
@@ -93,6 +94,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 a50db668..2c919f44 100644
--- a/src/libcamera/software_isp/TODO
+++ b/src/libcamera/software_isp/TODO
@@ -71,17 +71,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 31ab96ab..ce5141e8 100644
--- a/src/libcamera/software_isp/debayer_cpu.cpp
+++ b/src/libcamera/software_isp/debayer_cpu.cpp
@@ -22,6 +22,7 @@ 
 #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"
 
 namespace libcamera {
@@ -48,7 +49,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 color lookup tables */
 	for (unsigned int i = 0; i < DebayerParams::kRGBLookupSize; i++)