Skip to content

Commit

Permalink
pipeline: raspberrypi: Add a parameter to disable startup drop frames
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: David Plowman <[email protected]>
Reviewed-by: Kieran Bingham <[email protected]>
Reviewed-by: Laurent Pinchart <[email protected]>
Signed-off-by: Kieran Bingham <[email protected]>
  • Loading branch information
naushir authored and kbingham committed Jan 31, 2023
1 parent 8c53b24 commit b47ecac
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/libcamera/pipeline/raspberrypi/data/example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
# 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
}
}
11 changes: 10 additions & 1 deletion src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,11 @@ class RPiCameraData : public Camera::Private
* minTotalUnicamBuffers >= minUnicamBuffers
*/
unsigned int minTotalUnicamBuffers;
/*
* Override any request from the IPA to drop a number of startup
* frames.
*/
bool disableStartupFrameDrops;
};

Config config_;
Expand Down Expand Up @@ -1117,7 +1122,8 @@ 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();
Expand Down Expand Up @@ -1719,6 +1725,7 @@ int RPiCameraData::loadPipelineConfiguration()
config_ = {
.minUnicamBuffers = 2,
.minTotalUnicamBuffers = 4,
.disableStartupFrameDrops = false,
};

char const *configFromEnv = utils::secure_getenv("LIBCAMERA_RPI_CONFIG_FILE");
Expand Down Expand Up @@ -1752,6 +1759,8 @@ int RPiCameraData::loadPipelineConfiguration()
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";
Expand Down

0 comments on commit b47ecac

Please sign in to comment.