[libcamera-devel] [PATCH 1/2] libcamera: controls: Add rectangle and size control types
Niklas Söderlund
niklas.soderlund at ragnatech.se
Tue Apr 28 00:41:38 CEST 2020
Hi Laurent,
Thanks for your work.
On 2020-04-25 23:56:38 +0300, Laurent Pinchart wrote:
> Add two control types to store rectangles and sizes. These will be
> useful for the properties related to the pixel array.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>
> ---
> include/libcamera/controls.h | 13 +++++++++++++
> src/libcamera/controls.cpp | 12 ++++++++++++
> 2 files changed, 25 insertions(+)
>
> diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h
> index 4b2e7e9cdd6c..80944efc133a 100644
> --- a/include/libcamera/controls.h
> +++ b/include/libcamera/controls.h
> @@ -13,6 +13,7 @@
> #include <string>
> #include <unordered_map>
>
> +#include <libcamera/geometry.h>
> #include <libcamera/span.h>
>
> namespace libcamera {
> @@ -27,6 +28,8 @@ enum ControlType {
> ControlTypeInteger64,
> ControlTypeFloat,
> ControlTypeString,
> + ControlTypeRectangle,
> + ControlTypeSize,
> };
>
> namespace details {
> @@ -70,6 +73,16 @@ struct control_type<std::string> {
> static constexpr ControlType value = ControlTypeString;
> };
>
> +template<>
> +struct control_type<Rectangle> {
> + static constexpr ControlType value = ControlTypeRectangle;
> +};
> +
> +template<>
> +struct control_type<Size> {
> + static constexpr ControlType value = ControlTypeSize;
> +};
> +
> template<typename T, std::size_t N>
> struct control_type<Span<T, N>> : public control_type<std::remove_cv_t<T>> {
> };
> diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp
> index 540cc026417a..08df7f29e938 100644
> --- a/src/libcamera/controls.cpp
> +++ b/src/libcamera/controls.cpp
> @@ -58,6 +58,8 @@ static constexpr size_t ControlValueSize[] = {
> [ControlTypeInteger64] = sizeof(int64_t),
> [ControlTypeFloat] = sizeof(float),
> [ControlTypeString] = sizeof(char),
> + [ControlTypeRectangle] = sizeof(Rectangle),
> + [ControlTypeSize] = sizeof(Size),
> };
>
> } /* namespace */
> @@ -242,6 +244,16 @@ std::string ControlValue::toString() const
> str += std::to_string(*value);
> break;
> }
> + case ControlTypeRectangle: {
> + const Rectangle *value = reinterpret_cast<const Rectangle *>(data);
> + str += value->toString();
> + break;
> + }
> + case ControlTypeSize: {
> + const Size *value = reinterpret_cast<const Size *>(data);
> + str += value->toString();
> + break;
> + }
> case ControlTypeNone:
> case ControlTypeString:
> break;
> --
> Regards,
>
> Laurent Pinchart
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel at lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
--
Regards,
Niklas Söderlund
More information about the libcamera-devel
mailing list