libcamera: v4l2_device: Adjust colorspace based on pixel format

V4L2 has no "none" YCbCr encoding, and thus reports an encoding for all
formats, including RGB and raw formats. This causes the libcamera
ColorSpace to report incorrect encodings for non-YUV formats. Fix it by
overriding the encoding reported by the kernel to YCbCrEncoding::None
for non-YUV pixel formats and media bus formats.

Similarly, override the quantization range of non-YUV formats to full
range, as limited range isn't used for RGB and raw formats.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
This commit is contained in:
Umang Jain
2022-08-30 13:17:20 +05:30
parent d5ad19bf03
commit e297673e76
4 changed files with 65 additions and 11 deletions
+4 -1
View File
@@ -22,6 +22,8 @@
#include <libcamera/color_space.h>
#include <libcamera/controls.h>
#include "libcamera/internal/formats.h"
namespace libcamera {
class EventNotifier;
@@ -59,7 +61,8 @@ protected:
int fd() const { return fd_.get(); }
template<typename T>
static std::optional<ColorSpace> toColorSpace(const T &v4l2Format);
static std::optional<ColorSpace> toColorSpace(const T &v4l2Format,
PixelFormatInfo::ColourEncoding colourEncoding);
template<typename T>
static int fromColorSpace(const std::optional<ColorSpace> &colorSpace, T &v4l2Format);