mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-13 07:19:45 +03:00
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 <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
parent
4cb3380f4d
commit
e6da224926
2 changed files with 6 additions and 2 deletions
|
@ -39,7 +39,7 @@ enum ControlType {
|
|||
|
||||
namespace details {
|
||||
|
||||
template<typename T>
|
||||
template<typename T, typename = std::void_t<>>
|
||||
struct control_type {
|
||||
};
|
||||
|
||||
|
@ -102,6 +102,10 @@ struct control_type<Span<T, N>> : public control_type<std::remove_cv_t<T>> {
|
|||
static constexpr std::size_t size = N;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct control_type<T, std::enable_if_t<std::is_enum_v<T>>> : public control_type<int32_t> {
|
||||
};
|
||||
|
||||
} /* namespace details */
|
||||
|
||||
class ControlValue
|
||||
|
|
|
@ -958,7 +958,7 @@ int PipelineHandlerIPU3::updateControls(IPU3CameraData *data)
|
|||
values.reserve(testPatternModes.size());
|
||||
|
||||
for (auto pattern : testPatternModes)
|
||||
values.emplace_back(static_cast<int32_t>(pattern));
|
||||
values.emplace_back(pattern);
|
||||
|
||||
controls[&controls::draft::TestPatternMode] = ControlInfo(values);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue