From e6da224926b0d18dc4ad814843f2561e4e16a027 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Thu, 26 Sep 2024 02:59:53 +0300 Subject: libcamera: controls: Handle enum values without a cast When constructing a ControlValue from an enum value, an explicit cast to int32_t is needed as we use int32_t as the underlying type for all enumerated controls. This makes users of ControlValue more complex. To simplify them, specialize the control_type template for enum types, to support construction of ControlValue directly without a cast. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Kieran Bingham --- include/libcamera/controls.h | 6 +++++- src/libcamera/pipeline/ipu3/ipu3.cpp | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index 25f67ed9..c5131870 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -39,7 +39,7 @@ enum ControlType { namespace details { -template +template> struct control_type { }; @@ -102,6 +102,10 @@ struct control_type> : public control_type> { static constexpr std::size_t size = N; }; +template +struct control_type>> : public control_type { +}; + } /* namespace details */ class ControlValue diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 430aa902..29d3c6c1 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -958,7 +958,7 @@ int PipelineHandlerIPU3::updateControls(IPU3CameraData *data) values.reserve(testPatternModes.size()); for (auto pattern : testPatternModes) - values.emplace_back(static_cast(pattern)); + values.emplace_back(pattern); controls[&controls::draft::TestPatternMode] = ControlInfo(values); } -- cgit v1.2.1