libcamera: video_device: Convert between ColorSpace class and V4L2 formats
Add functions to the V4L2Device class to convert to and from libcamera ColorSpace. These functions are added to the base V4L2Device class so that they can be shared both by the video device class and subdevices. With the ColorSpace class, the color space and related other fields are stored together, corresponding to a number of fields in the various different V4L2 format structures. Template functions are therefore a convenient implementation, and we must explicitly instantiate the templates that will be needed. Note that unset color spaces are converted to requests for the device's "default" color space. Signed-off-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
committed by
Laurent Pinchart
parent
96f990ea6c
commit
e86aed6166
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
#include <linux/videodev2.h>
|
||||
@@ -18,6 +19,7 @@
|
||||
#include <libcamera/base/span.h>
|
||||
#include <libcamera/base/unique_fd.h>
|
||||
|
||||
#include <libcamera/color_space.h>
|
||||
#include <libcamera/controls.h>
|
||||
|
||||
namespace libcamera {
|
||||
@@ -56,6 +58,12 @@ protected:
|
||||
|
||||
int fd() const { return fd_.get(); }
|
||||
|
||||
template<typename T>
|
||||
static std::optional<ColorSpace> toColorSpace(const T &v4l2Format);
|
||||
|
||||
template<typename T>
|
||||
static int fromColorSpace(const std::optional<ColorSpace> &colorSpace, T &v4l2Format);
|
||||
|
||||
private:
|
||||
static ControlType v4l2CtrlType(uint32_t ctrlType);
|
||||
static std::unique_ptr<ControlId> v4l2ControlId(const v4l2_query_ext_ctrl &ctrl);
|
||||
|
||||
Reference in New Issue
Block a user