summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-06-27 01:47:28 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-11-19 22:37:12 +0200
commit3b133592de9adc7654fa1dc95f69b5ee2b604a1f (patch)
treea27f13ca95091f037459256ce1f186ead2819201
parent75cfd81d0b1fd8a525adea941f8ae025421c4ab8 (diff)
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 <laurent.pinchart@ideasonboard.com>
-rw-r--r--src/libcamera/formats.cpp104
-rw-r--r--src/libcamera/formats.yaml26
-rw-r--r--src/libcamera/v4l2_pixelformat.cpp16
3 files changed, 146 insertions, 0 deletions
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<PixelFormat, PixelFormatInfo> 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<V4L2PixelFormat, V4L2PixelFormat::Info> 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<V4L2PixelFormat, V4L2PixelFormat::Info> 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),