diff options
author | Jacopo Mondi <jacopo@jmondi.org> | 2022-07-15 13:47:01 +0200 |
---|---|---|
committer | Jacopo Mondi <jacopo@jmondi.org> | 2022-08-03 15:07:20 +0200 |
commit | d1abe2bdc88393da7bee3f80451636754d572567 (patch) | |
tree | f19886e2edadb09f4615afa7a1cb261cd463f6cc /include | |
parent | 29c09e3ab6c18c649d8510a1faee6c5a2b52c04a (diff) |
libcamera: v4l2_videodevice: Match formats supported by the device
Now that V4L2PixelFormat::fromPixelFormat() returns a list of formats
to chose from, select the one supported by the video device by matching
against the list of supported pixel formats.
The first format found to match one of the device supported ones is
returned.
As the list of pixel formats supported by the video device does not
change at run-time, cache it at device open() time. Maximize the
lookup efficiency by storing the list of supported V4L2PixelFormat in an
std::unordered_set<>.
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Paul Elder <paul.elder@ideasonboard.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/libcamera/internal/v4l2_videodevice.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h index 29fa0bba..ed98a284 100644 --- a/include/libcamera/internal/v4l2_videodevice.h +++ b/include/libcamera/internal/v4l2_videodevice.h @@ -14,6 +14,7 @@ #include <ostream> #include <stdint.h> #include <string> +#include <unordered_set> #include <vector> #include <linux/videodev2.h> @@ -242,6 +243,8 @@ private: Stopped, }; + int initFormats(); + int getFormatMeta(V4L2DeviceFormat *format); int trySetFormatMeta(V4L2DeviceFormat *format, bool set); @@ -268,6 +271,7 @@ private: V4L2Capability caps_; V4L2DeviceFormat format_; const PixelFormatInfo *formatInfo_; + std::unordered_set<V4L2PixelFormat> pixelFormats_; enum v4l2_buf_type bufferType_; enum v4l2_memory memoryType_; |