[libcamera-devel,v3,01/13] libcamera: stream: Add stream hints to StreamConfiguration
diff mbox series

Message ID 20221206135459.25521-2-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 hints flags field in the StreamConfiguration structure to allow the
application to specify certain intended behavior when driving libcamera.
Pipeline handlers are expected to look at these hint flags and may optimise
internal operations based on them.

Currently, only one flag is listed, MandatoryRequestBuffer, which the
application sets to guarantee that a buffer will be provided in the Request for
each configured stream.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
---
 include/libcamera/stream.h |  8 ++++++++
 src/libcamera/stream.cpp   | 24 ++++++++++++++++++++++++
 2 files changed, 32 insertions(+)

Patch
diff mbox series

diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h
index 29235ddf0d8a..1c5273004297 100644
--- a/include/libcamera/stream.h
+++ b/include/libcamera/stream.h
@@ -13,6 +13,8 @@ 
 #include <string>
 #include <vector>
 
+#include <libcamera/base/flags.h>
+
 #include <libcamera/color_space.h>
 #include <libcamera/framebuffer.h>
 #include <libcamera/geometry.h>
@@ -51,6 +53,12 @@  struct StreamConfiguration {
 
 	std::optional<ColorSpace> colorSpace;
 
+	enum class Hint {
+		None = 0,
+		MandatoryRequestBuffer = (1 << 0),
+	};
+	Flags<Hint> hints;
+
 	Stream *stream() const { return stream_; }
 	void setStream(Stream *stream) { stream_ = stream; }
 	const StreamFormats &formats() const { return formats_; }
diff --git a/src/libcamera/stream.cpp b/src/libcamera/stream.cpp
index 67f308157fbf..504c6d86cd04 100644
--- a/src/libcamera/stream.cpp
+++ b/src/libcamera/stream.cpp
@@ -349,6 +349,30 @@  StreamConfiguration::StreamConfiguration(const StreamFormats &formats)
  * color spaces can be supported and in what combinations.
  */
 
+/**
+ * \enum StreamConfiguration::Hint
+ * \brief List of available hint flags provided by the application for a stream
+ *
+ * \var StreamConfiguration::Hint::None
+ * No hints for this stream.
+ * \var StreamConfiguration::Hint::MandatoryRequestBuffer
+ * Informs the pipeline handler that the application guarantee to provide a
+ * buffer for the configured stream in the Request. This may allow the pipeline
+ * handler to allocate fewer (or no) buffers for internal use.
+ */
+
+/**
+ * \var StreamConfiguration::hints
+ * \brief Application provided StreamConfiguration::Hint flags for specific
+ * stream behavior
+ *
+ * Provides hints from the application to the pipeline handlers on how it
+ * intends on handling a given configured stream. These hints may alter the
+ * behavior of the pipeline handlers, for example, by allocating fewer buffers
+ * for internal use if an application guarantees to always provide a buffer in
+ * the Request for a stream.
+ */
+
 /**
  * \fn StreamConfiguration::stream()
  * \brief Retrieve the stream associated with the configuration