From 3bc8844808c5c72f9c83927ec0e93434d9d40e22 Mon Sep 17 00:00:00 2001 From: Jacopo Mondi Date: Fri, 29 Jul 2022 11:40:02 +0200 Subject: libcamera: formats: Merge V4L2 single and multi formats To each libcamera PixelFormat two V4L2 formats are associated, the 'single' and 'multi' format variants. The two versions list plane contiguous and non-contiguous format variants, and an optional argument to V4L2PixelFormat::fromPixelFormat() was used to select which one to pick. In order to prepare to remove V4L2PixelFormat::fromPixelFormat(), and considering that no caller in the codebase uses the non-contiguous format variant, merge the two formats vectors in a single one and default the selection to the first available one, which is functionally equivalent to what is currently implemented. Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart Tested-by: Paul Elder --- src/libcamera/v4l2_pixelformat.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'src/libcamera/v4l2_pixelformat.cpp') diff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp index bdcdc3be..9f74bd37 100644 --- a/src/libcamera/v4l2_pixelformat.cpp +++ b/src/libcamera/v4l2_pixelformat.cpp @@ -304,24 +304,20 @@ PixelFormat V4L2PixelFormat::toPixelFormat() const /** * \brief Convert \a pixelFormat to its corresponding V4L2PixelFormat * \param[in] pixelFormat The PixelFormat to convert - * \param[in] multiplanar V4L2 Multiplanar API support flag * - * Multiple V4L2 formats may exist for one PixelFormat when the format uses - * multiple planes, as V4L2 defines separate 4CCs for contiguous and separate - * planes formats. Set the \a multiplanar parameter to false to select a format - * with contiguous planes, or to true to select a format with non-contiguous - * planes. + * 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 */ -V4L2PixelFormat V4L2PixelFormat::fromPixelFormat(const PixelFormat &pixelFormat, - bool multiplanar) +V4L2PixelFormat V4L2PixelFormat::fromPixelFormat(const PixelFormat &pixelFormat) { const PixelFormatInfo &info = PixelFormatInfo::info(pixelFormat); if (!info.isValid()) return V4L2PixelFormat(); - return multiplanar ? info.v4l2Formats.multi : info.v4l2Formats.single; + return info.v4l2Formats[0]; } /** -- cgit v1.2.1