libcamera: controls: Add ControlTypePoint

Add a control_type<> specialization for libcamera::Point to allow
storing data of that type in a ControlValue instance.

The new control type will be used by controls introduced in the
next patches.

Signed-off-by: Yudhistira Erlandinata <yerlandinata@chromium.org>
Co-developed-by: Becker Hsieh <beckerh@chromium.org>
Co-developed-by: Harvey Yang <chenghaoyang@chromium.org>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Harvey Yang <chenghaoyang@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Yudhistira Erlandinata 2024-09-30 16:02:24 +02:00 committed by Jacopo Mondi
parent 724bbf7d25
commit 200d535ca8
2 changed files with 12 additions and 0 deletions

View file

@ -35,6 +35,7 @@ enum ControlType {
ControlTypeString, ControlTypeString,
ControlTypeRectangle, ControlTypeRectangle,
ControlTypeSize, ControlTypeSize,
ControlTypePoint,
}; };
namespace details { namespace details {
@ -97,6 +98,11 @@ struct control_type<Size> {
static constexpr std::size_t size = 0; static constexpr std::size_t size = 0;
}; };
template<>
struct control_type<Point> {
static constexpr ControlType value = ControlTypePoint;
};
template<typename T, std::size_t N> template<typename T, std::size_t N>
struct control_type<Span<T, N>> : public control_type<std::remove_cv_t<T>> { struct control_type<Span<T, N>> : public control_type<std::remove_cv_t<T>> {
static constexpr std::size_t size = N; static constexpr std::size_t size = N;

View file

@ -60,6 +60,7 @@ static constexpr size_t ControlValueSize[] = {
[ControlTypeString] = sizeof(char), [ControlTypeString] = sizeof(char),
[ControlTypeRectangle] = sizeof(Rectangle), [ControlTypeRectangle] = sizeof(Rectangle),
[ControlTypeSize] = sizeof(Size), [ControlTypeSize] = sizeof(Size),
[ControlTypePoint] = sizeof(Point),
}; };
} /* namespace */ } /* namespace */
@ -254,6 +255,11 @@ std::string ControlValue::toString() const
str += value->toString(); str += value->toString();
break; break;
} }
case ControlTypePoint: {
const Point *value = reinterpret_cast<const Point *>(data);
str += value->toString();
break;
}
case ControlTypeNone: case ControlTypeNone:
case ControlTypeString: case ControlTypeString:
break; break;