Message ID | 20240930195915.152187-4-jacopo.mondi@ideasonboard.com |
---|---|
State | Accepted |
Headers | show |
Series |
|
Related | show |
Thanks Jacopo, Reviewed-by: Harvey Yang <chenghaoyang@chromium.org> BR, Harvey On Tue, Oct 1, 2024 at 3:59 AM Jacopo Mondi <jacopo.mondi@ideasonboard.com> wrote: > > From: Yudhistira Erlandinata <yerlandinata@chromium.org> > > 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> > --- > include/libcamera/controls.h | 6 ++++++ > src/libcamera/controls.cpp | 6 ++++++ > 2 files changed, 12 insertions(+) > > diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h > index c5131870d402..ca60bbacad17 100644 > --- a/include/libcamera/controls.h > +++ b/include/libcamera/controls.h > @@ -35,6 +35,7 @@ enum ControlType { > ControlTypeString, > ControlTypeRectangle, > ControlTypeSize, > + ControlTypePoint, > }; > > namespace details { > @@ -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; > diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp > index ea4397302a21..62185d643ecd 100644 > --- a/src/libcamera/controls.cpp > +++ b/src/libcamera/controls.cpp > @@ -60,6 +60,7 @@ static constexpr size_t ControlValueSize[] = { > [ControlTypeString] = sizeof(char), > [ControlTypeRectangle] = sizeof(Rectangle), > [ControlTypeSize] = sizeof(Size), > + [ControlTypePoint] = sizeof(Point), > }; > > } /* namespace */ > @@ -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; > -- > 2.46.1 >
On Mon, Sep 30, 2024 at 09:59:11PM +0200, Jacopo Mondi wrote: > From: Yudhistira Erlandinata <yerlandinata@chromium.org> > > 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: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > --- > include/libcamera/controls.h | 6 ++++++ > src/libcamera/controls.cpp | 6 ++++++ > 2 files changed, 12 insertions(+) > > diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h > index c5131870d402..ca60bbacad17 100644 > --- a/include/libcamera/controls.h > +++ b/include/libcamera/controls.h > @@ -35,6 +35,7 @@ enum ControlType { > ControlTypeString, > ControlTypeRectangle, > ControlTypeSize, > + ControlTypePoint, > }; > > namespace details { > @@ -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; > diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp > index ea4397302a21..62185d643ecd 100644 > --- a/src/libcamera/controls.cpp > +++ b/src/libcamera/controls.cpp > @@ -60,6 +60,7 @@ static constexpr size_t ControlValueSize[] = { > [ControlTypeString] = sizeof(char), > [ControlTypeRectangle] = sizeof(Rectangle), > [ControlTypeSize] = sizeof(Size), > + [ControlTypePoint] = sizeof(Point), > }; > > } /* namespace */ > @@ -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;
diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index c5131870d402..ca60bbacad17 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -35,6 +35,7 @@ enum ControlType { ControlTypeString, ControlTypeRectangle, ControlTypeSize, + ControlTypePoint, }; namespace details { @@ -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; diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp index ea4397302a21..62185d643ecd 100644 --- a/src/libcamera/controls.cpp +++ b/src/libcamera/controls.cpp @@ -60,6 +60,7 @@ static constexpr size_t ControlValueSize[] = { [ControlTypeString] = sizeof(char), [ControlTypeRectangle] = sizeof(Rectangle), [ControlTypeSize] = sizeof(Size), + [ControlTypePoint] = sizeof(Point), }; } /* namespace */ @@ -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;