summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNaushir Patuck <naush@raspberrypi.com>2023-01-27 15:43:10 +0000
committerKieran Bingham <kieran.bingham@ideasonboard.com>2023-01-31 16:54:36 +0000
commit375bc787f49ce5b7cc2417615bb49e531e356a4d (patch)
treeeb4fb0adf882124ff411ac06277b3c96419b1701 /src
parentde4aac5abd34a5f5545179d0f74eb58b67f5a855 (diff)
pipeline: raspberrypi: Add a pipeline config structure
Add a configuration structure to store platform specific parameters used by the pipeline handler. Currently, these only store Unicam buffer counts, replacing the hardcoded static values in the source code. In subsequent commits, more parameters will be added to the configuration structure, and parameters will be read in through a config file. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src')
-rw-r--r--src/libcamera/pipeline/raspberrypi/raspberrypi.cpp53
1 files changed, 46 insertions, 7 deletions
diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
index 4323c98a..34b9720d 100644
--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
@@ -200,6 +200,7 @@ public:
int loadIPA(ipa::RPi::IPAInitResult *result);
int configureIPA(const CameraConfiguration *config, ipa::RPi::IPAConfigResult *result);
+ int loadPipelineConfiguration();
void enumerateVideoDevices(MediaLink *link);
@@ -297,6 +298,25 @@ public:
/* Have internal buffers been allocated? */
bool buffersAllocated_;
+ struct Config {
+ /*
+ * The minimum number of internal buffers to be allocated for
+ * the Unicam Image stream.
+ */
+ unsigned int minUnicamBuffers;
+ /*
+ * The minimum total (internal + external) buffer count used for
+ * the Unicam Image stream.
+ *
+ * Note that:
+ * minTotalUnicamBuffers must be >= 1, and
+ * minTotalUnicamBuffers >= minUnicamBuffers
+ */
+ unsigned int minTotalUnicamBuffers;
+ };
+
+ Config config_;
+
private:
void checkRequestCompleted();
void fillRequestMetadata(const ControlList &bufferControls,
@@ -1437,6 +1457,12 @@ int PipelineHandlerRPi::registerCamera(MediaDevice *unicam, MediaDevice *isp, Me
streams.insert(&data->isp_[Isp::Output0]);
streams.insert(&data->isp_[Isp::Output1]);
+ int ret = data->loadPipelineConfiguration();
+ if (ret) {
+ LOG(RPI, Error) << "Unable to load pipeline configuration";
+ return ret;
+ }
+
/* Create and register the camera. */
const std::string &id = data->sensor_->id();
std::shared_ptr<Camera> camera =
@@ -1499,25 +1525,28 @@ int PipelineHandlerRPi::prepareBuffers(Camera *camera)
for (auto const stream : data->streams_) {
unsigned int numBuffers;
/*
- * For Unicam, allocate a minimum of 4 buffers as we want
- * to avoid any frame drops.
+ * For Unicam, allocate a minimum number of buffers for internal
+ * use as we want to avoid any frame drops.
*/
- constexpr unsigned int minBuffers = 4;
+ const unsigned int minBuffers = data->config_.minTotalUnicamBuffers;
if (stream == &data->unicam_[Unicam::Image]) {
/*
* If an application has configured a RAW stream, allocate
* additional buffers to make up the minimum, but ensure
- * we have at least 2 sets of internal buffers to use to
- * minimise frame drops.
+ * we have at least minUnicamBuffers of internal buffers
+ * to use to minimise frame drops.
*/
- numBuffers = std::max<int>(2, minBuffers - numRawBuffers);
+ numBuffers = std::max<int>(data->config_.minUnicamBuffers,
+ minBuffers - numRawBuffers);
} else if (stream == &data->isp_[Isp::Input]) {
/*
* ISP input buffers are imported from Unicam, so follow
* similar logic as above to count all the RAW buffers
* available.
*/
- numBuffers = numRawBuffers + std::max<int>(2, minBuffers - numRawBuffers);
+ numBuffers = numRawBuffers +
+ std::max<int>(data->config_.minUnicamBuffers,
+ minBuffers - numRawBuffers);
} else if (stream == &data->unicam_[Unicam::Embedded]) {
/*
@@ -1682,6 +1711,16 @@ int RPiCameraData::configureIPA(const CameraConfiguration *config, ipa::RPi::IPA
return 0;
}
+int RPiCameraData::loadPipelineConfiguration()
+{
+ config_ = {
+ .minUnicamBuffers = 2,
+ .minTotalUnicamBuffers = 4,
+ };
+
+ return 0;
+}
+
/*
* enumerateVideoDevices() iterates over the Media Controller topology, starting
* at the sensor and finishing at Unicam. For each sensor, RPiCameraData stores