[libcamera-devel,v3,11/13] pipeline: raspberrypi: Add a parameter to disable startup drop frames
diff mbox series

Message ID 20221206135459.25521-12-naush@raspberrypi.com
State Superseded
Headers show
Series
  • Raspberry Pi: Platform configuration and buffer allocation improvements
Related show

Commit Message

Naushir Patuck Dec. 6, 2022, 1:54 p.m. UTC
Add a new pipeline config parameter "disable_startup_frame_drops" to disable
any startup drop frames, overriding the IPA request.

When this parameter is set, it allows the pipeline handler to run with no
internally allocated Unicam buffers ("min_unicam_buffers").

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
---
 src/libcamera/pipeline/raspberrypi/data/example.yaml |  6 +++++-
 src/libcamera/pipeline/raspberrypi/raspberrypi.cpp   | 10 +++++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/raspberrypi/data/example.yaml b/src/libcamera/pipeline/raspberrypi/data/example.yaml
index 001a906af528..421f30e62aa3 100644
--- a/src/libcamera/pipeline/raspberrypi/data/example.yaml
+++ b/src/libcamera/pipeline/raspberrypi/data/example.yaml
@@ -15,6 +15,10 @@ 
                 #
                 # internal buffer count = max(min_unicam_buffers,
                 #         min_total_unicam_buffers - external buffer count)
-                "min_total_unicam_buffers": 4
+                "min_total_unicam_buffers": 4,
+
+                # Override any request from the IPA to drop a number of startup
+                # frames.
+                "disable_startup_frame_drops": false
         }
 }
diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
index b18e11bb438f..ffd2ba85182f 100644
--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
@@ -308,6 +308,11 @@  public:
 		 * the Unicam Image stream.
 		 */
 		unsigned int minTotalUnicamBuffers;
+		/*
+		 * Override any request from the IPA to drop a number of startup
+		 * frames.
+		 */
+		bool disableStartupFrameDrops;
 	};
 
 	Config config_;
@@ -1052,7 +1057,7 @@  int PipelineHandlerRPi::start(Camera *camera, const ControlList *controls)
 		data->setSensorControls(startConfig.controls);
 
 	/* Configure the number of dropped frames required on startup. */
-	data->dropFrameCount_ = startConfig.dropFrameCount;
+	data->dropFrameCount_ = data->config_.disableStartupFrameDrops ? 0 : startConfig.dropFrameCount;
 
 	for (auto const stream : data->streams_)
 		stream->resetBuffers();
@@ -1724,6 +1729,7 @@  int RPiCameraData::configurePipeline()
 	config_ = {
 		.minUnicamBuffers = 2,
 		.minTotalUnicamBuffers = 4,
+		.disableStartupFrameDrops = false,
 	};
 
 	char const *configFromEnv = utils::secure_getenv("LIBCAMERA_RPI_CONFIG_FILE");
@@ -1757,6 +1763,8 @@  int RPiCameraData::configurePipeline()
 		phConfig["min_unicam_buffers"].get<unsigned int>(config_.minUnicamBuffers);
 	config_.minTotalUnicamBuffers =
 		phConfig["min_total_unicam_buffers"].get<unsigned int>(config_.minTotalUnicamBuffers);
+	config_.disableStartupFrameDrops =
+		phConfig["disable_startup_frame_drops"].get<bool>(config_.disableStartupFrameDrops);
 
 	if (config_.minTotalUnicamBuffers < config_.minUnicamBuffers) {
 		LOG(RPI, Error) << "Invalid configuration: min_total_unicam_buffers must be >= min_unicam_buffers";