From dfa9e526a43086a1b0936b74ec243f23396d5f69 Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Tue, 4 Oct 2022 10:09:53 +0300 Subject: v4l2: add DRMFourCCToPixelFormat Signed-off-by: Tomi Valkeinen --- v4l2++/src/pixelformats.cpp | 15 ++++++++++++++- v4l2++/src/videodevice.cpp | 2 -- 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'v4l2++/src') diff --git a/v4l2++/src/pixelformats.cpp b/v4l2++/src/pixelformats.cpp index 1c8453f..b7ecc7b 100644 --- a/v4l2++/src/pixelformats.cpp +++ b/v4l2++/src/pixelformats.cpp @@ -290,10 +290,23 @@ static const map format_info_array = { } }, }; +PixelFormat DRMFourCCToPixelFormat(const std::string& fourcc) +{ + // Handle the formats which differ between DRM and V4L2 + if (fourcc == "RG16") + return PixelFormat::RGB565; + if (fourcc == "XR24") + return PixelFormat::XRGB8888; + if (fourcc == "RG24") + return PixelFormat::RGB888; + + return FourCCToPixelFormat(fourcc); +} + const struct PixelFormatInfo& get_pixel_format_info(PixelFormat format) { if (!format_info_array.count(format)) - throw invalid_argument("get_pixel_format_info: Unsupported pixelformat"); + throw invalid_argument("v4l2: get_pixel_format_info: Unsupported pixelformat"); return format_info_array.at(format); } diff --git a/v4l2++/src/videodevice.cpp b/v4l2++/src/videodevice.cpp index 5ab7099..858b82b 100644 --- a/v4l2++/src/videodevice.cpp +++ b/v4l2++/src/videodevice.cpp @@ -133,8 +133,6 @@ static void v4l2_set_format(int fd, PixelFormat fmt, uint32_t width, uint32_t he ASSERT(p.sizeimage == p.bytesperline * height / pfpi.ysub); } } else { - ASSERT(pfi.num_planes == 1); - v4lfmt.fmt.pix.pixelformat = (uint32_t)fmt; v4lfmt.fmt.pix.width = width; v4lfmt.fmt.pix.height = height; -- cgit v1.2.3