@@ -658,19 +658,29 @@ associated with immutable values, which represent static characteristics that ca
be used by applications to identify camera devices in the system. Properties can be
registered by inspecting the values of V4L2 controls from the video devices and
camera sensor (for example to retrieve the position and orientation of a camera)
-or to express other immutable characteristics. The example pipeline handler does
-not register any property, but examples are available in the libcamera code
-base.
+or to express other immutable characteristics.
-.. TODO: Add a property example to the pipeline handler. At least the model.
+A required property is ``MinimumRequests``, which indicates how many requests
+need to be queued in the pipeline for capture without frame drops to be
+possible.
+
+In our case, the vivid driver requires two buffers before it'll start streaming
+(can be seen in the ``min_buffers_needed`` property for the ``vid_cap`` queue in
+vivid's driver code). Therefore we will set our ``MinimumRequests`` to two.
+Append the following line to ``init()``:
+
+.. code-block:: cpp
+
+ properties_.set(properties::MinimumRequests, 2);
At this point you need to add the following includes to the top of the file for
-handling controls:
+handling controls and properties:
.. code-block:: cpp
#include <libcamera/controls.h>
#include <libcamera/control_ids.h>
+ #include <libcamera/property_ids.h>
Generating a default configuration
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -18,6 +18,7 @@
#include <libcamera/camera_manager.h>
#include <libcamera/formats.h>
#include <libcamera/geometry.h>
+#include <libcamera/property_ids.h>
#include <libcamera/stream.h>
#include "libcamera/internal/bayer_format.h"
@@ -170,6 +171,7 @@ int ISICameraData::init()
return ret;
properties_ = sensor_->properties();
+ properties_.set(properties::MinimumRequests, 2);
return 0;
}
@@ -169,6 +169,8 @@ private:
MediaDevice *imguMediaDev_;
std::vector<IPABuffer> ipaBuffers_;
+
+ static constexpr unsigned int kMinimumRequests = 3;
};
IPU3CameraConfiguration::IPU3CameraConfiguration(IPU3CameraData *data)
@@ -1126,6 +1128,8 @@ int PipelineHandlerIPU3::registerCameras()
/* Initialize the camera properties. */
data->properties_ = cio2->sensor()->properties();
+ data->properties_.set(properties::MinimumRequests, kMinimumRequests);
+
ret = initControls(data.get());
if (ret)
continue;
@@ -1063,6 +1063,8 @@ int PipelineHandlerRPi::start(Camera *camera, const ControlList *controls)
/* Enable SOF event generation. */
data->unicam_[Unicam::Image].dev()->setFrameStartEnabled(true);
+ data->properties_.set(properties::MinimumRequests, 3);
+
/*
* Reset the delayed controls with the gain and exposure values set by
* the IPA.
@@ -23,6 +23,7 @@
#include <libcamera/control_ids.h>
#include <libcamera/formats.h>
#include <libcamera/framebuffer.h>
+#include <libcamera/property_ids.h>
#include <libcamera/request.h>
#include <libcamera/stream.h>
@@ -1103,6 +1104,7 @@ int PipelineHandlerRkISP1::createCamera(MediaEntity *sensor)
/* Initialize the camera properties. */
data->properties_ = data->sensor_->properties();
+ data->properties_.set(properties::MinimumRequests, 3);
/*
* \todo Read dealy values from the sensor itself or from a
@@ -25,6 +25,7 @@
#include <libcamera/camera.h>
#include <libcamera/control_ids.h>
+#include <libcamera/property_ids.h>
#include <libcamera/request.h>
#include <libcamera/stream.h>
@@ -180,6 +181,10 @@ class SimplePipelineHandler;
struct SimplePipelineInfo {
const char *driver;
+ /*
+ * Minimum number of buffers required by the driver to start streaming.
+ */
+ unsigned int minimumBuffers;
/*
* Each converter in the list contains the name
* and the number of streams it supports.
@@ -190,10 +195,10 @@ struct SimplePipelineInfo {
namespace {
static const SimplePipelineInfo supportedDevices[] = {
- { "imx7-csi", { { "pxp", 1 } } },
- { "mxc-isi", {} },
- { "qcom-camss", {} },
- { "sun6i-csi", {} },
+ { "imx7-csi", 2, { { "pxp", 1 } } },
+ { "mxc-isi", 3, {} },
+ { "qcom-camss", 1, {} },
+ { "sun6i-csi", 3, {} },
};
} /* namespace */
@@ -271,6 +276,8 @@ public:
bool useConverter_;
std::queue<std::map<unsigned int, FrameBuffer *>> converterQueue_;
+ const SimplePipelineInfo *deviceInfo;
+
private:
void tryPipeline(unsigned int code, const Size &size);
static std::vector<const MediaPad *> routedSourcePads(MediaPad *sink);
@@ -1168,6 +1175,29 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c)
inputCfg.stride = captureFormat.planes[0].bpl;
inputCfg.bufferCount = kNumInternalBuffers;
+ /* Set the MinimumRequests property. */
+ unsigned int minimumRequests;
+
+ if (data->useConverter_) {
+ /*
+ * The application will interact only with the capture node of
+ * the converter. Require two buffers for a frame drop free
+ * conversion, plus one extra to account for requeue delays.
+ */
+ minimumRequests = 3;
+ } else {
+ /*
+ * The application will interact directly with the video capture
+ * device. Require the minimum required by the driver, plus one
+ * extra to account for requeue delays. Force at least three
+ * buffers in order to not drop frames.
+ */
+ minimumRequests = std::max(data->deviceInfo->minimumBuffers + 1,
+ 3U);
+ }
+
+ data->properties_.set(properties::MinimumRequests, minimumRequests);
+
return data->converter_->configure(inputCfg, outputCfgs);
}
@@ -1506,6 +1536,8 @@ bool SimplePipelineHandler::match(DeviceEnumerator *enumerator)
bool registered = false;
for (std::unique_ptr<SimpleCameraData> &data : pipelines) {
+ data->deviceInfo = info;
+
int ret = data->init();
if (ret < 0)
continue;
@@ -500,6 +500,8 @@ int UVCCameraData::init(MediaDevice *media)
properties_.set(properties::PixelArraySize, resolution);
properties_.set(properties::PixelArrayActiveAreas, { Rectangle(resolution) });
+ properties_.set(properties::MinimumRequests, 3);
+
/* Initialise the supported controls. */
ControlInfoMap::Map ctrls;
@@ -21,6 +21,7 @@
#include <libcamera/control_ids.h>
#include <libcamera/controls.h>
#include <libcamera/formats.h>
+#include <libcamera/property_ids.h>
#include <libcamera/request.h>
#include <libcamera/stream.h>
@@ -571,6 +572,7 @@ int VimcCameraData::init()
/* Initialize the camera properties. */
properties_ = sensor_->properties();
+ properties_.set(properties::MinimumRequests, 3);
return 0;
}
@@ -690,6 +690,28 @@ controls:
that is twice that of the full resolution mode. This value will be valid
after the configure method has returned successfully.
+ - MinimumRequests:
+ type: int32_t
+ description: |
+ The minimum number of capture requests that the camera pipeline requires
+ to have queued in order to sustain capture operations without frame
+ drops. At this quantity, there's no guarantee that manual per-frame
+ controls will apply correctly. This is also the minimum number of
+ requests that must be queued before capture starts.
+
+ This property is based on the minimum number of memory buffers
+ needed to fill the capture pipeline composed of hardware processing
+ blocks plus as many buffers as needed to take into account propagation
+ delays and avoid dropping frames.
+
+ \todo Should this be a per-stream property?
+
+ \todo Extend this property to expose the different minimum buffer and
+ request counts (the minimum number of buffers to be able to capture at
+ all, the minimum number of buffers to sustain capture without frame
+ drop, and the minimum number of requests to ensure proper operation of
+ per-frame controls).
+
# ----------------------------------------------------------------------------
# Draft properties section