diff options
author | Paul Elder <paul.elder@ideasonboard.com> | 2021-09-08 16:46:32 +0900 |
---|---|---|
committer | Paul Elder <paul.elder@ideasonboard.com> | 2021-09-10 10:26:39 +0900 |
commit | 67f0def9bae08edc79329e675b21cb87d598b119 (patch) | |
tree | aa13fa0e79b6a066dfca29648234e895bf2ab108 | |
parent | a20d52a35b93bc9eaa21d07dd14e86b670384683 (diff) |
libcamera: v4l2_pixelformat: Add V4L2 description strings
Add V4L2 description strings to the map of V4L2 formats. To achieve
this, create an Info struct to wrap them. Update the one current user of
the old map.
This will be used later in the V4L2 compatibility layer to report the
V4L2 format description.
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>
-rw-r--r-- | include/libcamera/internal/v4l2_pixelformat.h | 5 | ||||
-rw-r--r-- | src/libcamera/v4l2_pixelformat.cpp | 182 |
2 files changed, 130 insertions, 57 deletions
diff --git a/include/libcamera/internal/v4l2_pixelformat.h b/include/libcamera/internal/v4l2_pixelformat.h index 560c5c53..87872542 100644 --- a/include/libcamera/internal/v4l2_pixelformat.h +++ b/include/libcamera/internal/v4l2_pixelformat.h @@ -20,6 +20,11 @@ namespace libcamera { class V4L2PixelFormat { public: + struct Info { + PixelFormat format; + const char *description; + }; + V4L2PixelFormat() : fourcc_(0) { diff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp index d1f3a42f..795da771 100644 --- a/src/libcamera/v4l2_pixelformat.cpp +++ b/src/libcamera/v4l2_pixelformat.cpp @@ -45,78 +45,146 @@ LOG_DECLARE_CATEGORY(V4L2) namespace { -const std::map<V4L2PixelFormat, PixelFormat> vpf2pf{ +const std::map<V4L2PixelFormat, V4L2PixelFormat::Info> vpf2pf{ /* RGB formats. */ - { V4L2PixelFormat(V4L2_PIX_FMT_RGB565), formats::RGB565 }, - { V4L2PixelFormat(V4L2_PIX_FMT_RGB565X), formats::RGB565_BE }, - { V4L2PixelFormat(V4L2_PIX_FMT_RGB24), formats::BGR888 }, - { V4L2PixelFormat(V4L2_PIX_FMT_BGR24), formats::RGB888 }, - { V4L2PixelFormat(V4L2_PIX_FMT_XBGR32), formats::XRGB8888 }, - { V4L2PixelFormat(V4L2_PIX_FMT_XRGB32), formats::BGRX8888 }, - { V4L2PixelFormat(V4L2_PIX_FMT_RGBX32), formats::XBGR8888 }, - { V4L2PixelFormat(V4L2_PIX_FMT_RGBA32), formats::ABGR8888 }, - { V4L2PixelFormat(V4L2_PIX_FMT_ABGR32), formats::ARGB8888 }, - { V4L2PixelFormat(V4L2_PIX_FMT_ARGB32), formats::BGRA8888 }, - { V4L2PixelFormat(V4L2_PIX_FMT_BGRA32), formats::RGBA8888 }, + { V4L2PixelFormat(V4L2_PIX_FMT_RGB565), + { formats::RGB565, "16-bit RGB 5-6-5" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_RGB565X), + { formats::RGB565_BE, "16-bit RGB 5-6-5 BE" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_RGB24), + { formats::BGR888, "24-bit RGB 8-8-8" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_BGR24), + { formats::RGB888, "24-bit BGR 8-8-8" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_XBGR32), + { formats::XRGB8888, "32-bit BGRX 8-8-8-8" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_XRGB32), + { formats::BGRX8888, "32-bit XRGB 8-8-8-8" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_RGBX32), + { formats::XBGR8888, "32-bit RGBX 8-8-8-8" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_RGBA32), + { formats::ABGR8888, "32-bit RGBA 8-8-8-8" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_ABGR32), + { formats::ARGB8888, "32-bit BGRA 8-8-8-8" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_ARGB32), + { formats::BGRA8888, "32-bit ARGB 8-8-8-8" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_BGRA32), + { formats::RGBA8888, "32-bit ABGR 8-8-8-8" } }, /* YUV packed formats. */ - { V4L2PixelFormat(V4L2_PIX_FMT_YUYV), formats::YUYV }, - { V4L2PixelFormat(V4L2_PIX_FMT_YVYU), formats::YVYU }, - { V4L2PixelFormat(V4L2_PIX_FMT_UYVY), formats::UYVY }, - { V4L2PixelFormat(V4L2_PIX_FMT_VYUY), formats::VYUY }, + { V4L2PixelFormat(V4L2_PIX_FMT_YUYV), + { formats::YUYV, "YUYV 4:2:2" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_YVYU), + { formats::YVYU, "YVYU 4:2:2" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_UYVY), + { formats::UYVY, "UYVY 4:2:2" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_VYUY), + { formats::VYUY, "VYUY 4:2:2" } }, /* YUV planar formats. */ - { V4L2PixelFormat(V4L2_PIX_FMT_NV16), formats::NV16 }, - { V4L2PixelFormat(V4L2_PIX_FMT_NV16M), formats::NV16 }, - { V4L2PixelFormat(V4L2_PIX_FMT_NV61), formats::NV61 }, - { V4L2PixelFormat(V4L2_PIX_FMT_NV61M), formats::NV61 }, - { V4L2PixelFormat(V4L2_PIX_FMT_NV12), formats::NV12 }, - { V4L2PixelFormat(V4L2_PIX_FMT_NV12M), formats::NV12 }, - { V4L2PixelFormat(V4L2_PIX_FMT_NV21), formats::NV21 }, - { V4L2PixelFormat(V4L2_PIX_FMT_NV21M), formats::NV21 }, - { V4L2PixelFormat(V4L2_PIX_FMT_YUV420), formats::YUV420 }, - { V4L2PixelFormat(V4L2_PIX_FMT_YUV420M), formats::YUV420 }, - { V4L2PixelFormat(V4L2_PIX_FMT_YVU420), formats::YVU420 }, - { V4L2PixelFormat(V4L2_PIX_FMT_YVU420M), formats::YVU420 }, - { V4L2PixelFormat(V4L2_PIX_FMT_YUV422P), formats::YUV422 }, - { V4L2PixelFormat(V4L2_PIX_FMT_YUV422M), formats::YUV422 }, + { V4L2PixelFormat(V4L2_PIX_FMT_NV16), + { formats::NV16, "Y/CbCr 4:2:2" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_NV16M), + { formats::NV16, "Y/CbCr 4:2:2 (N-C)" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_NV61), + { formats::NV61, "Y/CrCb 4:2:2" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_NV61M), + { formats::NV61, "Y/CrCb 4:2:2 (N-C)" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_NV12), + { formats::NV12, "Y/CbCr 4:2:0" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_NV12M), + { formats::NV12, "Y/CbCr 4:2:0 (N-C)" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_NV21), + { formats::NV21, "Y/CrCb 4:2:0" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_NV21M), + { formats::NV21, "Y/CrCb 4:2:0 (N-C)" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_YUV420), + { formats::YUV420, "Planar YUV 4:2:0" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_YUV420M), + { formats::YUV420, "Planar YUV 4:2:0 (N-C)" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_YVU420), + { formats::YVU420, "Planar YVU 4:2:0" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_YVU420M), + { formats::YVU420, "Planar YVU 4:2:0 (N-C)" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_YUV422P), + { formats::YUV422, "Planar YUV 4:2:2" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_YUV422M), + { formats::YUV422, "Planar YUV 4:2:2 (N-C)" } }, /* Greyscale formats. */ - { V4L2PixelFormat(V4L2_PIX_FMT_GREY), formats::R8 }, + { V4L2PixelFormat(V4L2_PIX_FMT_GREY), + { formats::R8, "8-bit Greyscale" } }, /* Bayer formats. */ - { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR8), formats::SBGGR8 }, - { V4L2PixelFormat(V4L2_PIX_FMT_SGBRG8), formats::SGBRG8 }, - { V4L2PixelFormat(V4L2_PIX_FMT_SGRBG8), formats::SGRBG8 }, - { V4L2PixelFormat(V4L2_PIX_FMT_SRGGB8), formats::SRGGB8 }, - { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10), formats::SBGGR10 }, - { V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10), formats::SGBRG10 }, - { V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10), formats::SGRBG10 }, - { V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10), formats::SRGGB10 }, - { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10P), formats::SBGGR10_CSI2P }, - { V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10P), formats::SGBRG10_CSI2P }, - { V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10P), formats::SGRBG10_CSI2P }, - { V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10P), formats::SRGGB10_CSI2P }, - { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR12), formats::SBGGR12 }, - { V4L2PixelFormat(V4L2_PIX_FMT_SGBRG12), formats::SGBRG12 }, - { V4L2PixelFormat(V4L2_PIX_FMT_SGRBG12), formats::SGRBG12 }, - { V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12), formats::SRGGB12 }, - { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR12P), formats::SBGGR12_CSI2P }, - { V4L2PixelFormat(V4L2_PIX_FMT_SGBRG12P), formats::SGBRG12_CSI2P }, - { V4L2PixelFormat(V4L2_PIX_FMT_SGRBG12P), formats::SGRBG12_CSI2P }, - { V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12P), formats::SRGGB12_CSI2P }, - { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR16), formats::SBGGR16 }, - { V4L2PixelFormat(V4L2_PIX_FMT_SGBRG16), formats::SGBRG16 }, - { V4L2PixelFormat(V4L2_PIX_FMT_SGRBG16), formats::SGRBG16 }, - { V4L2PixelFormat(V4L2_PIX_FMT_SRGGB16), formats::SRGGB16 }, + { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR8), + { formats::SBGGR8, "8-bit Bayer BGBG/GRGR" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_SGBRG8), + { formats::SGBRG8, "8-bit Bayer GBGB/RGRG" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_SGRBG8), + { formats::SGRBG8, "8-bit Bayer GRGR/BGBG" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_SRGGB8), + { formats::SRGGB8, "8-bit Bayer RGRG/GBGB" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10), + { formats::SBGGR10, "10-bit Bayer BGBG/GRGR" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10), + { formats::SGBRG10, "10-bit Bayer GBGB/RGRG" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10), + { formats::SGRBG10, "10-bit Bayer GRGR/BGBG" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10), + { formats::SRGGB10, "10-bit Bayer RGRG/GBGB" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10P), + { formats::SBGGR10_CSI2P, "10-bit Bayer BGBG/GRGR Packed" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10P), + { formats::SGBRG10_CSI2P, "10-bit Bayer GBGB/RGRG Packed" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10P), + { formats::SGRBG10_CSI2P, "10-bit Bayer GRGR/BGBG Packed" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10P), + { formats::SRGGB10_CSI2P, "10-bit Bayer RGRG/GBGB Packed" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR12), + { formats::SBGGR12, "12-bit Bayer BGBG/GRGR" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_SGBRG12), + { formats::SGBRG12, "12-bit Bayer GBGB/RGRG" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_SGRBG12), + { formats::SGRBG12, "12-bit Bayer GRGR/BGBG" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12), + { formats::SRGGB12, "12-bit Bayer RGRG/GBGB" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR12P), + { formats::SBGGR12_CSI2P, "12-bit Bayer BGBG/GRGR Packed" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_SGBRG12P), + { formats::SGBRG12_CSI2P, "12-bit Bayer GBGB/RGRG Packed" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_SGRBG12P), + { formats::SGRBG12_CSI2P, "12-bit Bayer GRGR/BGBG Packed" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12P), + { formats::SRGGB12_CSI2P, "12-bit Bayer RGRG/GBGB Packed" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR16), + { formats::SBGGR16, "16-bit Bayer BGBG/GRGR" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_SGBRG16), + { formats::SGBRG16, "16-bit Bayer GBGB/RGRG" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_SGRBG16), + { formats::SGRBG16, "16-bit Bayer GRGR/BGBG" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_SRGGB16), + { formats::SRGGB16, "16-bit Bayer RGRG/GBGB" } }, /* Compressed formats. */ - { V4L2PixelFormat(V4L2_PIX_FMT_MJPEG), formats::MJPEG }, + { V4L2PixelFormat(V4L2_PIX_FMT_MJPEG), + { formats::MJPEG, "Motion-JPEG" } }, }; } /* namespace */ /** + * \struct V4L2PixelFormat::Info + * \brief Information about a V4L2 pixel format + * + * \var V4L2PixelFormat::Info::format + * \brief The corresponding libcamera PixelFormat + * + * \sa PixelFormat + * + * \var V4L2PixelFormat::Info::description + * \brief The human-readable description of the V4L2 pixel format + */ + +/** * \fn V4L2PixelFormat::V4L2PixelFormat() * \brief Construct a V4L2PixelFormat with an invalid format * @@ -192,7 +260,7 @@ PixelFormat V4L2PixelFormat::toPixelFormat() const return PixelFormat(); } - return iter->second; + return iter->second.format; } /** |