From 3b133592de9adc7654fa1dc95f69b5ee2b604a1f Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sat, 27 Jun 2020 01:47:28 +0300 Subject: libcamera: Add support for MediaTek packed Bayer formats The MediaTek MT8183 camera hardware stores 10- and 12-bit Bayer data in a vendor-specific packed format. Support it in libcamera. The 14-bit version is left out for the time being as its alignment constraints are not clear yet. Signed-off-by: Laurent Pinchart --- src/libcamera/formats.cpp | 104 +++++++++++++++++++++++++++++++++++++ src/libcamera/formats.yaml | 26 ++++++++++ src/libcamera/v4l2_pixelformat.cpp | 16 ++++++ 3 files changed, 146 insertions(+) diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp index afcaabc5..472ec142 100644 --- a/src/libcamera/formats.cpp +++ b/src/libcamera/formats.cpp @@ -890,6 +890,110 @@ const std::map pixelFormatInfo{ .pixelsPerGroup = 25, .planes = {{ { 32, 1 }, { 0, 0 }, { 0, 0 } }}, } }, + { formats::SBGGR10_MTK, { + .name = "SBGGR10_MTK", + .format = formats::SBGGR10_MTK, + .v4l2Formats = { + .single = V4L2PixelFormat(V4L2_PIX_FMT_MTISP_SBGGR10), + .multi = V4L2PixelFormat(), + }, + .bitsPerPixel = 10, + .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .packed = true, + .pixelsPerGroup = 4, + .planes = {{ { 5, 1 }, { 0, 0 }, { 0, 0 } }}, + } }, + { formats::SGBRG10_MTK, { + .name = "SGBRG10_MTK", + .format = formats::SGBRG10_MTK, + .v4l2Formats = { + .single = V4L2PixelFormat(V4L2_PIX_FMT_MTISP_SGBRG10), + .multi = V4L2PixelFormat(), + }, + .bitsPerPixel = 10, + .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .packed = true, + .pixelsPerGroup = 4, + .planes = {{ { 5, 1 }, { 0, 0 }, { 0, 0 } }}, + } }, + { formats::SGRBG10_MTK, { + .name = "SGRBG10_MTK", + .format = formats::SGRBG10_MTK, + .v4l2Formats = { + .single = V4L2PixelFormat(V4L2_PIX_FMT_MTISP_SGRBG10), + .multi = V4L2PixelFormat(), + }, + .bitsPerPixel = 10, + .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .packed = true, + .pixelsPerGroup = 4, + .planes = {{ { 5, 1 }, { 0, 0 }, { 0, 0 } }}, + } }, + { formats::SRGGB10_MTK, { + .name = "SRGGB10_MTK", + .format = formats::SRGGB10_MTK, + .v4l2Formats = { + .single = V4L2PixelFormat(V4L2_PIX_FMT_MTISP_SRGGB10), + .multi = V4L2PixelFormat(), + }, + .bitsPerPixel = 10, + .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .packed = true, + .pixelsPerGroup = 4, + .planes = {{ { 5, 1 }, { 0, 0 }, { 0, 0 } }}, + } }, + { formats::SBGGR12_MTK, { + .name = "SBGGR12_MTK", + .format = formats::SBGGR12_MTK, + .v4l2Formats = { + .single = V4L2PixelFormat(V4L2_PIX_FMT_MTISP_SBGGR12), + .multi = V4L2PixelFormat(), + }, + .bitsPerPixel = 12, + .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .packed = true, + .pixelsPerGroup = 2, + .planes = {{ { 3, 1 }, { 0, 0 }, { 0, 0 } }}, + } }, + { formats::SGBRG12_MTK, { + .name = "SGBRG12_MTK", + .format = formats::SGBRG12_MTK, + .v4l2Formats = { + .single = V4L2PixelFormat(V4L2_PIX_FMT_MTISP_SGBRG12), + .multi = V4L2PixelFormat(), + }, + .bitsPerPixel = 12, + .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .packed = true, + .pixelsPerGroup = 2, + .planes = {{ { 3, 1 }, { 0, 0 }, { 0, 0 } }}, + } }, + { formats::SGRBG12_MTK, { + .name = "SGRBG12_MTK", + .format = formats::SGRBG12_MTK, + .v4l2Formats = { + .single = V4L2PixelFormat(V4L2_PIX_FMT_MTISP_SGRBG12), + .multi = V4L2PixelFormat(), + }, + .bitsPerPixel = 12, + .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .packed = true, + .pixelsPerGroup = 2, + .planes = {{ { 3, 1 }, { 0, 0 }, { 0, 0 } }}, + } }, + { formats::SRGGB12_MTK, { + .name = "SRGGB12_MTK", + .format = formats::SRGGB12_MTK, + .v4l2Formats = { + .single = V4L2PixelFormat(V4L2_PIX_FMT_MTISP_SRGGB12), + .multi = V4L2PixelFormat(), + }, + .bitsPerPixel = 12, + .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .packed = true, + .pixelsPerGroup = 2, + .planes = {{ { 3, 1 }, { 0, 0 }, { 0, 0 } }}, + } }, /* Compressed formats. */ { formats::MJPEG, { diff --git a/src/libcamera/formats.yaml b/src/libcamera/formats.yaml index 1f3f0433..d2bff5e1 100644 --- a/src/libcamera/formats.yaml +++ b/src/libcamera/formats.yaml @@ -151,4 +151,30 @@ formats: - SBGGR10_IPU3: fourcc: DRM_FORMAT_SBGGR10 mod: IPU3_FORMAT_MOD_PACKED + + - SRGGB10_MTK: + fourcc: DRM_FORMAT_SRGGB10 + mod: MEDIATEK_FORMAT_MOD_BAYER_PACKED + - SGRBG10_MTK: + fourcc: DRM_FORMAT_SGRBG10 + mod: MEDIATEK_FORMAT_MOD_BAYER_PACKED + - SGBRG10_MTK: + fourcc: DRM_FORMAT_SGBRG10 + mod: MEDIATEK_FORMAT_MOD_BAYER_PACKED + - SBGGR10_MTK: + fourcc: DRM_FORMAT_SBGGR10 + mod: MEDIATEK_FORMAT_MOD_BAYER_PACKED + + - SRGGB12_MTK: + fourcc: DRM_FORMAT_SRGGB12 + mod: MEDIATEK_FORMAT_MOD_BAYER_PACKED + - SGRBG12_MTK: + fourcc: DRM_FORMAT_SGRBG12 + mod: MEDIATEK_FORMAT_MOD_BAYER_PACKED + - SGBRG12_MTK: + fourcc: DRM_FORMAT_SGBRG12 + mod: MEDIATEK_FORMAT_MOD_BAYER_PACKED + - SBGGR12_MTK: + fourcc: DRM_FORMAT_SBGGR12 + mod: MEDIATEK_FORMAT_MOD_BAYER_PACKED ... diff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp index 0e0da3f0..c0fc38ea 100644 --- a/src/libcamera/v4l2_pixelformat.cpp +++ b/src/libcamera/v4l2_pixelformat.cpp @@ -147,6 +147,14 @@ const std::map vpf2pf{ { formats::SGRBG10_CSI2P, "10-bit Bayer GRGR/BGBG Packed" } }, { V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10P), { formats::SRGGB10_CSI2P, "10-bit Bayer RGRG/GBGB Packed" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_MTISP_SBGGR10), + { formats::SBGGR10_MTK, "10-bit Bayer BGGR MTISP Packed" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_MTISP_SGBRG10), + { formats::SGBRG10_MTK, "10-bit Bayer GBRG MTISP Packed" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_MTISP_SGRBG10), + { formats::SGRBG10_MTK, "10-bit Bayer GRBG MTISP Packed" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_MTISP_SRGGB10), + { formats::SRGGB10_MTK, "10-bit Bayer RGGB MTISP Packed" } }, { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR12), { formats::SBGGR12, "12-bit Bayer BGBG/GRGR" } }, { V4L2PixelFormat(V4L2_PIX_FMT_SGBRG12), @@ -163,6 +171,14 @@ const std::map vpf2pf{ { formats::SGRBG12_CSI2P, "12-bit Bayer GRGR/BGBG Packed" } }, { V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12P), { formats::SRGGB12_CSI2P, "12-bit Bayer RGRG/GBGB Packed" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_MTISP_SBGGR12), + { formats::SBGGR12_MTK, "12-bit Bayer BGGR MTISP Packed" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_MTISP_SGBRG12), + { formats::SGBRG12_MTK, "12-bit Bayer GBRG MTISP Packed" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_MTISP_SGRBG12), + { formats::SGRBG12_MTK, "12-bit Bayer GRBG MTISP Packed" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_MTISP_SRGGB12), + { formats::SRGGB12_MTK, "12-bit Bayer RGGB MTISP Packed" } }, { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR16), { formats::SBGGR16, "16-bit Bayer BGBG/GRGR" } }, { V4L2PixelFormat(V4L2_PIX_FMT_SGBRG16), -- cgit v1.2.1