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

Message ID 20230127154322.29019-2-naush@raspberrypi.com
State Superseded
Headers show
Series
  • [libcamera-devel,v6,01/15] libcamera: stream: Add stream hints to StreamConfiguration
Related show

Commit Message

Naushir Patuck Jan. 27, 2023, 3:43 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, MandatoryStream, which the application can
set to inform the pipeline handler that a buffer will always be provided on
every Request for a given stream.

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

Comments

Kieran Bingham Jan. 30, 2023, 1:42 p.m. UTC | #1
Quoting Naushir Patuck via libcamera-devel (2023-01-27 15:43:08)
> 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, MandatoryStream, which the application can
> set to inform the pipeline handler that a buffer will always be provided on
> every Request for a given stream.
> 
> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>

Well I think this sounds reasonable now, and I've better understood the
use cases so I'll give this.


Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>


> ---
>  include/libcamera/stream.h |  8 ++++++++
>  src/libcamera/stream.cpp   | 25 +++++++++++++++++++++++++
>  2 files changed, 33 insertions(+)
> 
> diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h
> index 29235ddf0d8a..56e5a74b2aab 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,
> +               MandatoryStream = (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..9b0e8dd548cf 100644
> --- a/src/libcamera/stream.cpp
> +++ b/src/libcamera/stream.cpp
> @@ -349,6 +349,31 @@ 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::MandatoryStream
> + * Informs the pipeline handler that the application will always provide a
> + * buffer for the configured stream in every Request. This may ensure the
> + * pipeline handler does not need any additional stream buffer allocations 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 not allocating additional
> + * buffers for internal use if an application guarantees buffers will be
> + * provided in every Request for a stream.
> + */
> +
>  /**
>   * \fn StreamConfiguration::stream()
>   * \brief Retrieve the stream associated with the configuration
> -- 
> 2.25.1
>

Patch
diff mbox series

diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h
index 29235ddf0d8a..56e5a74b2aab 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,
+		MandatoryStream = (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..9b0e8dd548cf 100644
--- a/src/libcamera/stream.cpp
+++ b/src/libcamera/stream.cpp
@@ -349,6 +349,31 @@  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::MandatoryStream
+ * Informs the pipeline handler that the application will always provide a
+ * buffer for the configured stream in every Request. This may ensure the
+ * pipeline handler does not need any additional stream buffer allocations 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 not allocating additional
+ * buffers for internal use if an application guarantees buffers will be
+ * provided in every Request for a stream.
+ */
+
 /**
  * \fn StreamConfiguration::stream()
  * \brief Retrieve the stream associated with the configuration