libcamera: rpi: Make the controller min frame duration configurable
The controller min frame duration is used to rate limit how often we run IPAs. Historically this has been set to 33333us, meaning that the algorithms effectively skip frames when the camera is running faster than 30fps. This patch adds a small amount of plumbing that allows this value to be set in the Raspberry Pi configuration file. Some applications or platforms (such as Pi 5) are easily capable of running these more often, should there be a need to do so. Signed-off-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
committed by
Kieran Bingham
parent
71c5c08fcf
commit
cc74afcdbd
@@ -33,6 +33,12 @@ LOG_DEFINE_CATEGORY(RPI)
|
||||
|
||||
using StreamFlag = RPi::Stream::StreamFlag;
|
||||
|
||||
/*
|
||||
* The IPA's algorithms will not be called more often than this many
|
||||
* microseconds. The default corresponds to 30fps.
|
||||
*/
|
||||
constexpr float defaultControllerMinimumFrameDurationUs = 1000000.0 / 30.0;
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr unsigned int defaultRawBitDepth = 12;
|
||||
@@ -800,6 +806,12 @@ int PipelineHandlerBase::registerCamera(std::unique_ptr<RPi::CameraData> &camera
|
||||
if (!data->sensor_)
|
||||
return -EINVAL;
|
||||
|
||||
ret = data->loadPipelineConfiguration();
|
||||
if (ret) {
|
||||
LOG(RPI, Error) << "Unable to load pipeline configuration";
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Populate the map of sensor supported formats and sizes. */
|
||||
for (const auto mbusCode : data->sensor_->mbusCodes())
|
||||
data->sensorFormats_.emplace(mbusCode,
|
||||
@@ -859,12 +871,6 @@ int PipelineHandlerBase::registerCamera(std::unique_ptr<RPi::CameraData> &camera
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = data->loadPipelineConfiguration();
|
||||
if (ret) {
|
||||
LOG(RPI, Error) << "Unable to load pipeline configuration";
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Setup the general IPA signal handlers. */
|
||||
data->frontendDevice()->dequeueTimeout.connect(data, &RPi::CameraData::cameraTimeout);
|
||||
data->frontendDevice()->frameStart.connect(data, &RPi::CameraData::frameStarted);
|
||||
@@ -1095,6 +1101,7 @@ int CameraData::loadPipelineConfiguration()
|
||||
{
|
||||
config_ = {
|
||||
.cameraTimeoutValue = 0,
|
||||
.controllerMinFrameDurationUs = defaultControllerMinimumFrameDurationUs,
|
||||
};
|
||||
|
||||
/* Initial configuration of the platform, in case no config file is present */
|
||||
@@ -1144,6 +1151,9 @@ int CameraData::loadPipelineConfiguration()
|
||||
frontendDevice()->setDequeueTimeout(config_.cameraTimeoutValue * 1ms);
|
||||
}
|
||||
|
||||
config_.controllerMinFrameDurationUs =
|
||||
phConfig["controller_min_frame_duration_us"].get<double>(config_.controllerMinFrameDurationUs);
|
||||
|
||||
return platformPipelineConfigure(root);
|
||||
}
|
||||
|
||||
@@ -1172,6 +1182,8 @@ int CameraData::loadIPA(ipa::RPi::InitResult *result)
|
||||
}
|
||||
|
||||
params.lensPresent = !!sensor_->focusLens();
|
||||
params.controllerMinFrameDurationUs = config_.controllerMinFrameDurationUs;
|
||||
|
||||
ret = platformInitIpa(params);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
@@ -169,6 +169,11 @@ public:
|
||||
* on frame durations.
|
||||
*/
|
||||
unsigned int cameraTimeoutValue;
|
||||
/*
|
||||
* The minimum frame duration between the IPA's calls to the
|
||||
* algorithms themselves (in microseconds).
|
||||
*/
|
||||
float controllerMinFrameDurationUs;
|
||||
};
|
||||
|
||||
Config config_;
|
||||
|
||||
@@ -36,5 +36,11 @@
|
||||
# framebuffers required for its operation.
|
||||
#
|
||||
# "disable_hdr": false,
|
||||
|
||||
# Limits the rate at which IPAs are called. The algorithms will
|
||||
# be skipped until this many microseconds have elapsed since
|
||||
# the last call. The default value represents a 30fps limit.
|
||||
#
|
||||
# "controller_min_frame_duration_us": 33333.333,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,5 +37,11 @@
|
||||
# timeout value.
|
||||
#
|
||||
# "camera_timeout_value_ms": 0,
|
||||
|
||||
# Limits the rate at which IPAs are called. The algorithms will
|
||||
# be skipped until this many microseconds have elapsed since
|
||||
# the last call. The default value represents a 30fps limit.
|
||||
#
|
||||
# "controller_min_frame_duration_us": 33333.333,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user