Skip to content

Commit

Permalink
libcamera: controls: Add ControlTypePoint
Browse files Browse the repository at this point in the history
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 <[email protected]>
Co-developed-by: Becker Hsieh <[email protected]>
Co-developed-by: Harvey Yang <[email protected]>
Reviewed-by: Jacopo Mondi <[email protected]>
Signed-off-by: Jacopo Mondi <[email protected]>
Reviewed-by: Harvey Yang <[email protected]>
Reviewed-by: Laurent Pinchart <[email protected]>
  • Loading branch information
Yudhistira Erlandinata authored and Jacopo Mondi committed Oct 1, 2024
1 parent 724bbf7 commit 200d535
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions include/libcamera/controls.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ enum ControlType {
ControlTypeString,
ControlTypeRectangle,
ControlTypeSize,
ControlTypePoint,
};

namespace details {
Expand Down Expand Up @@ -97,6 +98,11 @@ struct control_type<Size> {
static constexpr std::size_t size = 0;
};

template<>
struct control_type<Point> {
static constexpr ControlType value = ControlTypePoint;
};

template<typename T, std::size_t N>
struct control_type<Span<T, N>> : public control_type<std::remove_cv_t<T>> {
static constexpr std::size_t size = N;
Expand Down
6 changes: 6 additions & 0 deletions src/libcamera/controls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ static constexpr size_t ControlValueSize[] = {
[ControlTypeString] = sizeof(char),
[ControlTypeRectangle] = sizeof(Rectangle),
[ControlTypeSize] = sizeof(Size),
[ControlTypePoint] = sizeof(Point),
};

} /* namespace */
Expand Down Expand Up @@ -254,6 +255,11 @@ std::string ControlValue::toString() const
str += value->toString();
break;
}
case ControlTypePoint: {
const Point *value = reinterpret_cast<const Point *>(data);
str += value->toString();
break;
}
case ControlTypeNone:
case ControlTypeString:
break;
Expand Down

0 comments on commit 200d535

Please sign in to comment.