libcamera: Replace explicit DRM FourCCs with libcamera formats
Use the new pixel format constants to replace usage of macros from drm_fourcc.h. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
This commit is contained in:
parent
56c99424ed
commit
8b7e073e6e
4 changed files with 116 additions and 124 deletions
|
@ -11,8 +11,6 @@
|
|||
#include <stdint.h>
|
||||
#include <string>
|
||||
|
||||
#include <linux/drm_fourcc.h>
|
||||
|
||||
namespace libcamera {
|
||||
|
||||
class PixelFormat
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <vector>
|
||||
|
||||
#include <libcamera/controls.h>
|
||||
#include <libcamera/formats.h>
|
||||
#include <libcamera/property_ids.h>
|
||||
|
||||
#include "libcamera/internal/log.h"
|
||||
|
@ -58,13 +59,13 @@ struct Camera3Format {
|
|||
const std::map<int, const Camera3Format> camera3FormatsMap = {
|
||||
{
|
||||
HAL_PIXEL_FORMAT_BLOB, {
|
||||
{ PixelFormat(DRM_FORMAT_MJPEG) },
|
||||
{ formats::MJPEG },
|
||||
ANDROID_SCALER_AVAILABLE_FORMATS_BLOB,
|
||||
"BLOB"
|
||||
}
|
||||
}, {
|
||||
HAL_PIXEL_FORMAT_YCbCr_420_888, {
|
||||
{ PixelFormat(DRM_FORMAT_NV12), PixelFormat(DRM_FORMAT_NV21) },
|
||||
{ formats::NV12, formats::NV21 },
|
||||
ANDROID_SCALER_AVAILABLE_FORMATS_YCbCr_420_888,
|
||||
"YCbCr_420_888"
|
||||
}
|
||||
|
@ -74,7 +75,7 @@ const std::map<int, const Camera3Format> camera3FormatsMap = {
|
|||
* usage flag. For now, copy the YCbCr_420 configuration.
|
||||
*/
|
||||
HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, {
|
||||
{ PixelFormat(DRM_FORMAT_NV12), PixelFormat(DRM_FORMAT_NV21) },
|
||||
{ formats::NV12, formats::NV21 },
|
||||
ANDROID_SCALER_AVAILABLE_FORMATS_IMPLEMENTATION_DEFINED,
|
||||
"IMPLEMENTATION_DEFINED"
|
||||
}
|
||||
|
@ -264,7 +265,7 @@ int CameraDevice::initializeStreamConfigurations()
|
|||
for (const PixelFormat &pixelFormat : libcameraFormats) {
|
||||
/* \todo Fixed mapping for JPEG. */
|
||||
if (androidFormat == HAL_PIXEL_FORMAT_BLOB) {
|
||||
mappedFormat = PixelFormat(DRM_FORMAT_MJPEG);
|
||||
mappedFormat = formats::MJPEG;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
#include <errno.h>
|
||||
|
||||
#include <libcamera/formats.h>
|
||||
|
||||
#include "libcamera/internal/log.h"
|
||||
|
||||
/**
|
||||
|
@ -166,43 +168,43 @@ namespace {
|
|||
|
||||
const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{
|
||||
/* RGB formats. */
|
||||
{ PixelFormat(DRM_FORMAT_BGR888), {
|
||||
.format = PixelFormat(DRM_FORMAT_BGR888),
|
||||
{ formats::BGR888, {
|
||||
.format = formats::BGR888,
|
||||
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_RGB24),
|
||||
.bitsPerPixel = 24,
|
||||
.colourEncoding = PixelFormatInfo::ColourEncodingRGB,
|
||||
.packed = false,
|
||||
} },
|
||||
{ PixelFormat(DRM_FORMAT_RGB888), {
|
||||
.format = PixelFormat(DRM_FORMAT_RGB888),
|
||||
{ formats::RGB888, {
|
||||
.format = formats::RGB888,
|
||||
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_BGR24),
|
||||
.bitsPerPixel = 24,
|
||||
.colourEncoding = PixelFormatInfo::ColourEncodingRGB,
|
||||
.packed = false,
|
||||
} },
|
||||
{ PixelFormat(DRM_FORMAT_ABGR8888), {
|
||||
.format = PixelFormat(DRM_FORMAT_ABGR8888),
|
||||
{ formats::ABGR8888, {
|
||||
.format = formats::ABGR8888,
|
||||
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_RGBA32),
|
||||
.bitsPerPixel = 32,
|
||||
.colourEncoding = PixelFormatInfo::ColourEncodingRGB,
|
||||
.packed = false,
|
||||
} },
|
||||
{ PixelFormat(DRM_FORMAT_ARGB8888), {
|
||||
.format = PixelFormat(DRM_FORMAT_ARGB8888),
|
||||
{ formats::ARGB8888, {
|
||||
.format = formats::ARGB8888,
|
||||
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_ABGR32),
|
||||
.bitsPerPixel = 32,
|
||||
.colourEncoding = PixelFormatInfo::ColourEncodingRGB,
|
||||
.packed = false,
|
||||
} },
|
||||
{ PixelFormat(DRM_FORMAT_BGRA8888), {
|
||||
.format = PixelFormat(DRM_FORMAT_BGRA8888),
|
||||
{ formats::BGRA8888, {
|
||||
.format = formats::BGRA8888,
|
||||
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_ARGB32),
|
||||
.bitsPerPixel = 32,
|
||||
.colourEncoding = PixelFormatInfo::ColourEncodingRGB,
|
||||
.packed = false,
|
||||
} },
|
||||
{ PixelFormat(DRM_FORMAT_RGBA8888), {
|
||||
.format = PixelFormat(DRM_FORMAT_RGBA8888),
|
||||
{ formats::RGBA8888, {
|
||||
.format = formats::RGBA8888,
|
||||
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_BGRA32),
|
||||
.bitsPerPixel = 32,
|
||||
.colourEncoding = PixelFormatInfo::ColourEncodingRGB,
|
||||
|
@ -210,29 +212,29 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{
|
|||
} },
|
||||
|
||||
/* YUV packed formats. */
|
||||
{ PixelFormat(DRM_FORMAT_YUYV), {
|
||||
.format = PixelFormat(DRM_FORMAT_YUYV),
|
||||
{ formats::YUYV, {
|
||||
.format = formats::YUYV,
|
||||
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_YUYV),
|
||||
.bitsPerPixel = 16,
|
||||
.colourEncoding = PixelFormatInfo::ColourEncodingYUV,
|
||||
.packed = false,
|
||||
} },
|
||||
{ PixelFormat(DRM_FORMAT_YVYU), {
|
||||
.format = PixelFormat(DRM_FORMAT_YVYU),
|
||||
{ formats::YVYU, {
|
||||
.format = formats::YVYU,
|
||||
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_YVYU),
|
||||
.bitsPerPixel = 16,
|
||||
.colourEncoding = PixelFormatInfo::ColourEncodingYUV,
|
||||
.packed = false,
|
||||
} },
|
||||
{ PixelFormat(DRM_FORMAT_UYVY), {
|
||||
.format = PixelFormat(DRM_FORMAT_UYVY),
|
||||
{ formats::UYVY, {
|
||||
.format = formats::UYVY,
|
||||
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_UYVY),
|
||||
.bitsPerPixel = 16,
|
||||
.colourEncoding = PixelFormatInfo::ColourEncodingYUV,
|
||||
.packed = false,
|
||||
} },
|
||||
{ PixelFormat(DRM_FORMAT_VYUY), {
|
||||
.format = PixelFormat(DRM_FORMAT_VYUY),
|
||||
{ formats::VYUY, {
|
||||
.format = formats::VYUY,
|
||||
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_VYUY),
|
||||
.bitsPerPixel = 16,
|
||||
.colourEncoding = PixelFormatInfo::ColourEncodingYUV,
|
||||
|
@ -240,29 +242,29 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{
|
|||
} },
|
||||
|
||||
/* YUV planar formats. */
|
||||
{ PixelFormat(DRM_FORMAT_NV16), {
|
||||
.format = PixelFormat(DRM_FORMAT_NV16),
|
||||
{ formats::NV16, {
|
||||
.format = formats::NV16,
|
||||
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_NV16),
|
||||
.bitsPerPixel = 16,
|
||||
.colourEncoding = PixelFormatInfo::ColourEncodingYUV,
|
||||
.packed = false,
|
||||
} },
|
||||
{ PixelFormat(DRM_FORMAT_NV61), {
|
||||
.format = PixelFormat(DRM_FORMAT_NV61),
|
||||
{ formats::NV61, {
|
||||
.format = formats::NV61,
|
||||
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_NV61),
|
||||
.bitsPerPixel = 16,
|
||||
.colourEncoding = PixelFormatInfo::ColourEncodingYUV,
|
||||
.packed = false,
|
||||
} },
|
||||
{ PixelFormat(DRM_FORMAT_NV12), {
|
||||
.format = PixelFormat(DRM_FORMAT_NV12),
|
||||
{ formats::NV12, {
|
||||
.format = formats::NV12,
|
||||
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_NV12),
|
||||
.bitsPerPixel = 12,
|
||||
.colourEncoding = PixelFormatInfo::ColourEncodingYUV,
|
||||
.packed = false,
|
||||
} },
|
||||
{ PixelFormat(DRM_FORMAT_NV21), {
|
||||
.format = PixelFormat(DRM_FORMAT_NV21),
|
||||
{ formats::NV21, {
|
||||
.format = formats::NV21,
|
||||
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_NV21),
|
||||
.bitsPerPixel = 12,
|
||||
.colourEncoding = PixelFormatInfo::ColourEncodingYUV,
|
||||
|
@ -270,8 +272,8 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{
|
|||
} },
|
||||
|
||||
/* Greyscale formats. */
|
||||
{ PixelFormat(DRM_FORMAT_R8), {
|
||||
.format = PixelFormat(DRM_FORMAT_R8),
|
||||
{ formats::R8, {
|
||||
.format = formats::R8,
|
||||
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_GREY),
|
||||
.bitsPerPixel = 8,
|
||||
.colourEncoding = PixelFormatInfo::ColourEncodingYUV,
|
||||
|
@ -279,141 +281,141 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{
|
|||
} },
|
||||
|
||||
/* Bayer formats. */
|
||||
{ PixelFormat(DRM_FORMAT_SBGGR8), {
|
||||
.format = PixelFormat(DRM_FORMAT_SBGGR8),
|
||||
{ formats::SBGGR8, {
|
||||
.format = formats::SBGGR8,
|
||||
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SBGGR8),
|
||||
.bitsPerPixel = 8,
|
||||
.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
|
||||
.packed = false,
|
||||
} },
|
||||
{ PixelFormat(DRM_FORMAT_SGBRG8), {
|
||||
.format = PixelFormat(DRM_FORMAT_SGBRG8),
|
||||
{ formats::SGBRG8, {
|
||||
.format = formats::SGBRG8,
|
||||
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SGBRG8),
|
||||
.bitsPerPixel = 8,
|
||||
.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
|
||||
.packed = false,
|
||||
} },
|
||||
{ PixelFormat(DRM_FORMAT_SGRBG8), {
|
||||
.format = PixelFormat(DRM_FORMAT_SGRBG8),
|
||||
{ formats::SGRBG8, {
|
||||
.format = formats::SGRBG8,
|
||||
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SGRBG8),
|
||||
.bitsPerPixel = 8,
|
||||
.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
|
||||
.packed = false,
|
||||
} },
|
||||
{ PixelFormat(DRM_FORMAT_SRGGB8), {
|
||||
.format = PixelFormat(DRM_FORMAT_SRGGB8),
|
||||
{ formats::SRGGB8, {
|
||||
.format = formats::SRGGB8,
|
||||
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SRGGB8),
|
||||
.bitsPerPixel = 8,
|
||||
.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
|
||||
.packed = false,
|
||||
} },
|
||||
{ PixelFormat(DRM_FORMAT_SBGGR10), {
|
||||
.format = PixelFormat(DRM_FORMAT_SBGGR10),
|
||||
{ formats::SBGGR10, {
|
||||
.format = formats::SBGGR10,
|
||||
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10),
|
||||
.bitsPerPixel = 10,
|
||||
.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
|
||||
.packed = false,
|
||||
} },
|
||||
{ PixelFormat(DRM_FORMAT_SGBRG10), {
|
||||
.format = PixelFormat(DRM_FORMAT_SGBRG10),
|
||||
{ formats::SGBRG10, {
|
||||
.format = formats::SGBRG10,
|
||||
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10),
|
||||
.bitsPerPixel = 10,
|
||||
.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
|
||||
.packed = false,
|
||||
} },
|
||||
{ PixelFormat(DRM_FORMAT_SGRBG10), {
|
||||
.format = PixelFormat(DRM_FORMAT_SGRBG10),
|
||||
{ formats::SGRBG10, {
|
||||
.format = formats::SGRBG10,
|
||||
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10),
|
||||
.bitsPerPixel = 10,
|
||||
.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
|
||||
.packed = false,
|
||||
} },
|
||||
{ PixelFormat(DRM_FORMAT_SRGGB10), {
|
||||
.format = PixelFormat(DRM_FORMAT_SRGGB10),
|
||||
{ formats::SRGGB10, {
|
||||
.format = formats::SRGGB10,
|
||||
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10),
|
||||
.bitsPerPixel = 10,
|
||||
.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
|
||||
.packed = false,
|
||||
} },
|
||||
{ PixelFormat(DRM_FORMAT_SBGGR10, MIPI_FORMAT_MOD_CSI2_PACKED), {
|
||||
.format = PixelFormat(DRM_FORMAT_SBGGR10, MIPI_FORMAT_MOD_CSI2_PACKED),
|
||||
{ formats::SBGGR10_CSI2P, {
|
||||
.format = formats::SBGGR10_CSI2P,
|
||||
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10P),
|
||||
.bitsPerPixel = 10,
|
||||
.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
|
||||
.packed = true,
|
||||
} },
|
||||
{ PixelFormat(DRM_FORMAT_SGBRG10, MIPI_FORMAT_MOD_CSI2_PACKED), {
|
||||
.format = PixelFormat(DRM_FORMAT_SGBRG10, MIPI_FORMAT_MOD_CSI2_PACKED),
|
||||
{ formats::SGBRG10_CSI2P, {
|
||||
.format = formats::SGBRG10_CSI2P,
|
||||
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10P),
|
||||
.bitsPerPixel = 10,
|
||||
.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
|
||||
.packed = true,
|
||||
} },
|
||||
{ PixelFormat(DRM_FORMAT_SGRBG10, MIPI_FORMAT_MOD_CSI2_PACKED), {
|
||||
.format = PixelFormat(DRM_FORMAT_SGRBG10, MIPI_FORMAT_MOD_CSI2_PACKED),
|
||||
{ formats::SGRBG10_CSI2P, {
|
||||
.format = formats::SGRBG10_CSI2P,
|
||||
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10P),
|
||||
.bitsPerPixel = 10,
|
||||
.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
|
||||
.packed = true,
|
||||
} },
|
||||
{ PixelFormat(DRM_FORMAT_SRGGB10, MIPI_FORMAT_MOD_CSI2_PACKED), {
|
||||
.format = PixelFormat(DRM_FORMAT_SRGGB10, MIPI_FORMAT_MOD_CSI2_PACKED),
|
||||
{ formats::SRGGB10_CSI2P, {
|
||||
.format = formats::SRGGB10_CSI2P,
|
||||
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10P),
|
||||
.bitsPerPixel = 10,
|
||||
.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
|
||||
.packed = true,
|
||||
} },
|
||||
{ PixelFormat(DRM_FORMAT_SBGGR12), {
|
||||
.format = PixelFormat(DRM_FORMAT_SBGGR12),
|
||||
{ formats::SBGGR12, {
|
||||
.format = formats::SBGGR12,
|
||||
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SBGGR12),
|
||||
.bitsPerPixel = 12,
|
||||
.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
|
||||
.packed = false,
|
||||
} },
|
||||
{ PixelFormat(DRM_FORMAT_SGBRG12), {
|
||||
.format = PixelFormat(DRM_FORMAT_SGBRG12),
|
||||
{ formats::SGBRG12, {
|
||||
.format = formats::SGBRG12,
|
||||
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SGBRG12),
|
||||
.bitsPerPixel = 12,
|
||||
.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
|
||||
.packed = false,
|
||||
} },
|
||||
{ PixelFormat(DRM_FORMAT_SGRBG12), {
|
||||
.format = PixelFormat(DRM_FORMAT_SGRBG12),
|
||||
{ formats::SGRBG12, {
|
||||
.format = formats::SGRBG12,
|
||||
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SGRBG12),
|
||||
.bitsPerPixel = 12,
|
||||
.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
|
||||
.packed = false,
|
||||
} },
|
||||
{ PixelFormat(DRM_FORMAT_SRGGB12), {
|
||||
.format = PixelFormat(DRM_FORMAT_SRGGB12),
|
||||
{ formats::SRGGB12, {
|
||||
.format = formats::SRGGB12,
|
||||
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12),
|
||||
.bitsPerPixel = 12,
|
||||
.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
|
||||
.packed = false,
|
||||
} },
|
||||
{ PixelFormat(DRM_FORMAT_SBGGR12, MIPI_FORMAT_MOD_CSI2_PACKED), {
|
||||
.format = PixelFormat(DRM_FORMAT_SBGGR12, MIPI_FORMAT_MOD_CSI2_PACKED),
|
||||
{ formats::SBGGR12_CSI2P, {
|
||||
.format = formats::SBGGR12_CSI2P,
|
||||
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SBGGR12P),
|
||||
.bitsPerPixel = 12,
|
||||
.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
|
||||
.packed = true,
|
||||
} },
|
||||
{ PixelFormat(DRM_FORMAT_SGBRG12, MIPI_FORMAT_MOD_CSI2_PACKED), {
|
||||
.format = PixelFormat(DRM_FORMAT_SGBRG12, MIPI_FORMAT_MOD_CSI2_PACKED),
|
||||
{ formats::SGBRG12_CSI2P, {
|
||||
.format = formats::SGBRG12_CSI2P,
|
||||
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SGBRG12P),
|
||||
.bitsPerPixel = 12,
|
||||
.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
|
||||
.packed = true,
|
||||
} },
|
||||
{ PixelFormat(DRM_FORMAT_SGRBG12, MIPI_FORMAT_MOD_CSI2_PACKED), {
|
||||
.format = PixelFormat(DRM_FORMAT_SGRBG12, MIPI_FORMAT_MOD_CSI2_PACKED),
|
||||
{ formats::SGRBG12_CSI2P, {
|
||||
.format = formats::SGRBG12_CSI2P,
|
||||
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SGRBG12P),
|
||||
.bitsPerPixel = 12,
|
||||
.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
|
||||
.packed = true,
|
||||
} },
|
||||
{ PixelFormat(DRM_FORMAT_SRGGB12, MIPI_FORMAT_MOD_CSI2_PACKED), {
|
||||
.format = PixelFormat(DRM_FORMAT_SRGGB12, MIPI_FORMAT_MOD_CSI2_PACKED),
|
||||
{ formats::SRGGB12_CSI2P, {
|
||||
.format = formats::SRGGB12_CSI2P,
|
||||
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12P),
|
||||
.bitsPerPixel = 12,
|
||||
.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
|
||||
|
@ -421,8 +423,8 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{
|
|||
} },
|
||||
|
||||
/* Compressed formats. */
|
||||
{ PixelFormat(DRM_FORMAT_MJPEG), {
|
||||
.format = PixelFormat(DRM_FORMAT_MJPEG),
|
||||
{ formats::MJPEG, {
|
||||
.format = formats::MJPEG,
|
||||
.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_MJPEG),
|
||||
.bitsPerPixel = 0,
|
||||
.colourEncoding = PixelFormatInfo::ColourEncodingYUV,
|
||||
|
|
|
@ -12,8 +12,7 @@
|
|||
#include <map>
|
||||
#include <string.h>
|
||||
|
||||
#include <linux/drm_fourcc.h>
|
||||
|
||||
#include <libcamera/formats.h>
|
||||
#include <libcamera/pixel_format.h>
|
||||
|
||||
#include "libcamera/internal/formats.h"
|
||||
|
@ -46,60 +45,52 @@ namespace {
|
|||
|
||||
const std::map<V4L2PixelFormat, PixelFormat> vpf2pf{
|
||||
/* RGB formats. */
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_RGB24), PixelFormat(DRM_FORMAT_BGR888) },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_BGR24), PixelFormat(DRM_FORMAT_RGB888) },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_RGBA32), PixelFormat(DRM_FORMAT_ABGR8888) },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_ABGR32), PixelFormat(DRM_FORMAT_ARGB8888) },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_ARGB32), PixelFormat(DRM_FORMAT_BGRA8888) },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_BGRA32), PixelFormat(DRM_FORMAT_RGBA8888) },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_RGB24), formats::BGR888 },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_BGR24), formats::RGB888 },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_RGBA32), formats::ABGR8888 },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_ABGR32), formats::ARGB8888 },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_ARGB32), formats::BGRA8888 },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_BGRA32), formats::RGBA8888 },
|
||||
|
||||
/* YUV packed formats. */
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_YUYV), PixelFormat(DRM_FORMAT_YUYV) },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_YVYU), PixelFormat(DRM_FORMAT_YVYU) },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_UYVY), PixelFormat(DRM_FORMAT_UYVY) },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_VYUY), PixelFormat(DRM_FORMAT_VYUY) },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_YUYV), formats::YUYV },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_YVYU), formats::YVYU },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_UYVY), formats::UYVY },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_VYUY), formats::VYUY },
|
||||
|
||||
/* YUV planar formats. */
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_NV16), PixelFormat(DRM_FORMAT_NV16) },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_NV61), PixelFormat(DRM_FORMAT_NV61) },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_NV12), PixelFormat(DRM_FORMAT_NV12) },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_NV21), PixelFormat(DRM_FORMAT_NV21) },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_NV16), formats::NV16 },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_NV61), formats::NV61 },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_NV12), formats::NV12 },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_NV21), formats::NV21 },
|
||||
|
||||
/* Greyscale formats. */
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_GREY), PixelFormat(DRM_FORMAT_R8) },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_GREY), formats::R8 },
|
||||
|
||||
/* Bayer formats. */
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_SBGGR8), PixelFormat(DRM_FORMAT_SBGGR8) },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_SGBRG8), PixelFormat(DRM_FORMAT_SGBRG8) },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_SGRBG8), PixelFormat(DRM_FORMAT_SGRBG8) },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_SRGGB8), PixelFormat(DRM_FORMAT_SRGGB8) },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10), PixelFormat(DRM_FORMAT_SBGGR10) },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10), PixelFormat(DRM_FORMAT_SGBRG10) },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10), PixelFormat(DRM_FORMAT_SGRBG10) },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10), PixelFormat(DRM_FORMAT_SRGGB10) },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10P),
|
||||
PixelFormat(DRM_FORMAT_SBGGR10, MIPI_FORMAT_MOD_CSI2_PACKED) },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10P),
|
||||
PixelFormat(DRM_FORMAT_SGBRG10, MIPI_FORMAT_MOD_CSI2_PACKED) },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10P),
|
||||
PixelFormat(DRM_FORMAT_SGRBG10, MIPI_FORMAT_MOD_CSI2_PACKED) },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10P),
|
||||
PixelFormat(DRM_FORMAT_SRGGB10, MIPI_FORMAT_MOD_CSI2_PACKED) },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_SBGGR12), PixelFormat(DRM_FORMAT_SBGGR12) },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_SGBRG12), PixelFormat(DRM_FORMAT_SGBRG12) },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_SGRBG12), PixelFormat(DRM_FORMAT_SGRBG12) },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12), PixelFormat(DRM_FORMAT_SRGGB12) },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_SBGGR12P),
|
||||
PixelFormat(DRM_FORMAT_SBGGR12, MIPI_FORMAT_MOD_CSI2_PACKED) },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_SGBRG12P),
|
||||
PixelFormat(DRM_FORMAT_SGBRG12, MIPI_FORMAT_MOD_CSI2_PACKED) },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_SGRBG12P),
|
||||
PixelFormat(DRM_FORMAT_SGRBG12, MIPI_FORMAT_MOD_CSI2_PACKED) },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12P),
|
||||
PixelFormat(DRM_FORMAT_SRGGB12, MIPI_FORMAT_MOD_CSI2_PACKED) },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_SBGGR8), formats::SBGGR8 },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_SGBRG8), formats::SGBRG8 },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_SGRBG8), formats::SGRBG8 },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_SRGGB8), formats::SRGGB8 },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10), formats::SBGGR10 },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10), formats::SGBRG10 },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10), formats::SGRBG10 },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10), formats::SRGGB10 },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10P), formats::SBGGR10_CSI2P },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10P), formats::SGBRG10_CSI2P },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10P), formats::SGRBG10_CSI2P },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10P), formats::SRGGB10_CSI2P },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_SBGGR12), formats::SBGGR12 },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_SGBRG12), formats::SGBRG12 },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_SGRBG12), formats::SGRBG12 },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12), formats::SRGGB12 },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_SBGGR12P), formats::SBGGR12_CSI2P },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_SGBRG12P), formats::SGBRG12_CSI2P },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_SGRBG12P), formats::SGRBG12_CSI2P },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12P), formats::SRGGB12_CSI2P },
|
||||
|
||||
/* Compressed formats. */
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_MJPEG), PixelFormat(DRM_FORMAT_MJPEG) },
|
||||
{ V4L2PixelFormat(V4L2_PIX_FMT_MJPEG), formats::MJPEG },
|
||||
};
|
||||
|
||||
} /* namespace */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue