diff options
author | Paul Elder <paul.elder@ideasonboard.com> | 2021-09-08 16:48:58 +0900 |
---|---|---|
committer | Paul Elder <paul.elder@ideasonboard.com> | 2021-09-10 10:32:57 +0900 |
commit | 9f9c224c7bb91e0123b75901a7ccf54d1226504d (patch) | |
tree | 6f33ee61438b503bb2d4fabc268677b628fba333 /src | |
parent | ba155eadb9b5e0976338c75aa21d95275f7c649c (diff) |
libcamera: v4l2_pixelformat: Add helper function to get the description
Add a helper function to V4L2PixelFormat for retrieving the V4L2
description string.
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/libcamera/v4l2_pixelformat.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp index 2c8167a7..3649c600 100644 --- a/src/libcamera/v4l2_pixelformat.cpp +++ b/src/libcamera/v4l2_pixelformat.cpp @@ -251,6 +251,28 @@ std::string V4L2PixelFormat::toString() const } /** + * \brief Retrieve the V4L2 description for the format + * + * The description matches the value used by the kernel, as would be reported + * by the VIDIOC_ENUM_FMT ioctl. + * + * \return The V4L2 description corresponding to the V4L2 format, or a + * placeholder description if not found + */ +const char *V4L2PixelFormat::description() const +{ + const auto iter = vpf2pf.find(*this); + if (iter == vpf2pf.end()) { + LOG(V4L2, Warning) + << "Unsupported V4L2 pixel format " + << toString(); + return "Unsupported format"; + } + + return iter->second.description; +} + +/** * \brief Convert the V4L2 pixel format to the corresponding PixelFormat * \return The PixelFormat corresponding to the V4L2 pixel format */ |