summaryrefslogtreecommitdiff
path: root/src/libcamera/formats.cpp
diff options
context:
space:
mode:
authorJacopo Mondi <jacopo@jmondi.org>2022-08-08 14:36:19 +0200
committerJacopo Mondi <jacopo@jmondi.org>2022-08-10 09:33:30 +0200
commit434edb7b4480a34521aa8741dea02615e9dd714d (patch)
tree2b8fc0ac47cc39a79e36b31e02ac8ad00212df92 /src/libcamera/formats.cpp
parente1ca213609abb99cc1b6e6f16214bf5a0936f3b7 (diff)
libcamera: formats: Fix warning for unknown V4L2 pixfmt
Commit f25ad4a2b16b ("libcamera: formats: Reimplement V4L2 PixelFormatInfo::info()") changed the PixelFormatInfo::info(const V4L2PixelFormat &format) function overload to: return info(format.toPixelFormat()); As part of the series that contains such commit, the PixelFormatInfo for the pixel format applied to a video device is now retrieved at V4L2VideoDevice::open() time. Some video devices register formats not available to applications, for example metadata formats or, in the case of ISP devices, formats to describe the ISP statistics and parameters. This causes the format.toPixelFormat() call to output a WARN message, which spams the log and unnecessarily alerts the users. Augment V4L2PixelFormat::toPixelFormat() with an optional argument to suppress warnings in the case a V4L2 pixel format is not known, to restore the behaviour preceding commit f25ad4a2b16b and returns an invalid PixelFormatInfo without outputting any unnecessary warning message. Fixes: f25ad4a2b16b ("libcamera: formats: Reimplement V4L2 PixelFormatInfo::info()") Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Diffstat (limited to 'src/libcamera/formats.cpp')
-rw-r--r--src/libcamera/formats.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp
index 0bd0e09a..f5769c48 100644
--- a/src/libcamera/formats.cpp
+++ b/src/libcamera/formats.cpp
@@ -852,7 +852,15 @@ const PixelFormatInfo &PixelFormatInfo::info(const PixelFormat &format)
*/
const PixelFormatInfo &PixelFormatInfo::info(const V4L2PixelFormat &format)
{
- return info(format.toPixelFormat());
+ PixelFormat pixelFormat = format.toPixelFormat(false);
+ if (!pixelFormat.isValid())
+ return pixelFormatInfoInvalid;
+
+ const auto iter = pixelFormatInfo.find(pixelFormat);
+ if (iter == pixelFormatInfo.end())
+ return pixelFormatInfoInvalid;
+
+ return iter->second;
}
/**