From b7ca378b65e8ba936bf3c5631e16534a3376aec9 Mon Sep 17 00:00:00 2001 From: Jacopo Mondi Date: Fri, 29 Jul 2022 12:37:29 +0200 Subject: libcamera: v4l2_pixelformat: Return the list of V4L2 formats Multiple V4L2 formats can be associated with a single PixelFormat. Now that users of V4L2PixelFormat::fromPixelFormat() have been converted to use V4L2VideoDevice::toV4L2PixelFormat(), return the full list of V4L2 formats in order to prepare to match them against the ones supported by the video device. The V4L2 compatibility layer, not having any video device to interact with, is converted to use the first returned format unconditionally. Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart Tested-by: Paul Elder --- src/libcamera/v4l2_pixelformat.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/libcamera/v4l2_pixelformat.cpp') diff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp index 9f74bd37..90c8fa8d 100644 --- a/src/libcamera/v4l2_pixelformat.cpp +++ b/src/libcamera/v4l2_pixelformat.cpp @@ -302,22 +302,24 @@ PixelFormat V4L2PixelFormat::toPixelFormat() const } /** - * \brief Convert \a pixelFormat to its corresponding V4L2PixelFormat + * \brief Retrieve the list of V4L2PixelFormat associated with \a pixelFormat * \param[in] pixelFormat The PixelFormat to convert * * Multiple V4L2 formats may exist for one PixelFormat as V4L2 defines separate * 4CCs for contiguous and non-contiguous versions of the same image format. - * When that is the case, this function returns the contiguous planes format. * - * \return The V4L2PixelFormat corresponding to \a pixelFormat + * \return The list of V4L2PixelFormat corresponding to \a pixelFormat */ -V4L2PixelFormat V4L2PixelFormat::fromPixelFormat(const PixelFormat &pixelFormat) +const std::vector & +V4L2PixelFormat::fromPixelFormat(const PixelFormat &pixelFormat) { + static const std::vector empty; + const PixelFormatInfo &info = PixelFormatInfo::info(pixelFormat); if (!info.isValid()) - return V4L2PixelFormat(); + return empty; - return info.v4l2Formats[0]; + return info.v4l2Formats; } /** -- cgit v1.2.1