[libcamera-devel] [PATCH 08/13] libcamera: v4l2_subdevice: Add support for the V4L2 subdev routing API
Tomi Valkeinen
tomi.valkeinen at ideasonboard.com
Tue Aug 2 13:01:34 CEST 2022
On 01/08/2022 03:05, Laurent Pinchart via libcamera-devel wrote:
> From: Jacopo Mondi <jacopo at jmondi.org>
>
> Extend the V4L2Subdevice class to support getting and setting routing
> tables.
>
> Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
> Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> ---
> Changes on top of Jacopo's initial work:
>
> - Turn Routing struct into a class, an inherit from std::vector
> - Drop Routing::numRoutes
> ---
> include/libcamera/internal/v4l2_subdevice.h | 9 ++
> src/libcamera/v4l2_subdevice.cpp | 105 ++++++++++++++++++++
> 2 files changed, 114 insertions(+)
>
> diff --git a/include/libcamera/internal/v4l2_subdevice.h b/include/libcamera/internal/v4l2_subdevice.h
> index a1d3144c6a7f..00be17bb1465 100644
> --- a/include/libcamera/internal/v4l2_subdevice.h
> +++ b/include/libcamera/internal/v4l2_subdevice.h
> @@ -61,6 +61,12 @@ public:
> ActiveFormat = V4L2_SUBDEV_FORMAT_ACTIVE,
> };
>
> + class Routing : public std::vector<struct v4l2_subdev_route>
> + {
> + public:
> + std::string toString() const;
> + };
> +
> explicit V4L2Subdevice(const MediaEntity *entity);
> ~V4L2Subdevice();
>
> @@ -80,6 +86,9 @@ public:
> int setFormat(unsigned int pad, V4L2SubdeviceFormat *format,
> Whence whence = ActiveFormat);
>
> + int getRouting(Routing *routing, Whence whence = ActiveFormat);
> + int setRouting(Routing *routing, Whence whence = ActiveFormat);
> +
> const std::string &model();
> const V4L2SubdeviceCapability &caps() const { return caps_; }
>
> diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp
> index a1672b2365f2..fe8b8e4eae2a 100644
> --- a/src/libcamera/v4l2_subdevice.cpp
> +++ b/src/libcamera/v4l2_subdevice.cpp
> @@ -288,6 +288,32 @@ std::ostream &operator<<(std::ostream &out, const V4L2SubdeviceFormat &f)
> * \brief The format operation applies to TRY formats
> */
>
> +/**
> + * \class V4L2Subdevice::Routing
> + * \brief V4L2 subdevice routing table
> + *
> + * This class stores a subdevice routing table as a vector of routes.
> + */
> +
> +/**
> + * \brief Assemble and return a string describing the routing table
> + * \return A string describing the routing table
> + */
> +std::string V4L2Subdevice::Routing::toString() const
> +{
> + std::stringstream routing;
> +
> + for (const auto &[i, route] : utils::enumerate(*this)) {
> + routing << "[" << i << "] "
> + << route.sink_pad << "/" << route.sink_stream << " -> "
> + << route.source_pad << "/" << route.source_stream;
I would also add the route flags. Even if it's just a hex number in the
print, it may help catching bugs.
Other than that:
Reviewed-by: Tomi Valkeinen <tomi.valkeinen at ideasonboard.com>
Tomi
More information about the libcamera-devel
mailing list