From patchwork Mon Sep 23 09:08:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cheng-Hao Yang X-Patchwork-Id: 21329 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 7D5CAC0F1B for ; Mon, 23 Sep 2024 09:11:46 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7435763511; Mon, 23 Sep 2024 11:11:44 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="JQaodWXD"; dkim-atps=neutral Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9F5FC6350A for ; Mon, 23 Sep 2024 11:11:40 +0200 (CEST) Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-206aee40676so32419575ad.0 for ; Mon, 23 Sep 2024 02:11:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1727082699; x=1727687499; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZdysAG/eaEx31Zm3qmrqbQjMX4XQuD/PYuy7eQvhHNg=; b=JQaodWXD9DlZKqf059ZkpoDY+syAROnlvfDFc7mwAhJzN2znPUCZbziVQ/ItOW5MSo 06r11KLcxfawysrlcmnDmW/Y4mMrchDN99ginCUXwPJN6rnX72kOJwUh0pq0yQ2cEfaH vlzCqGeRgVWKdxO8/UFqGe53u3jQ6BFyrgdW0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727082699; x=1727687499; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZdysAG/eaEx31Zm3qmrqbQjMX4XQuD/PYuy7eQvhHNg=; b=CvKW7ac1AX7fK1pxLEhHM2V8l3JIbMDztM+aDlEQwXatIyiAf6TzxMR7emJYHjWTlv 3MxtVrYrC7uiIwehoJ//7zHOzL6N2Rk318etOVlhbWYdoGul7JaGr5bk1Bfka0H/RvSo MA2EDxqJrbK+JuvfPeGgff3thtEkroyTTms964kryzxzO0Dw7Pq8S93XQ5eAXAGyjN7k 1BvU5OGBy69MS6AGBAIl8s2f+VvZALixOeB1UwySjFdfs1P/hzRUd2OskMZRVmrv1c9S cw922M8cC39Jm4BnOwgdQKBWDQ/mi5zJFyGVK/onDM4DokTmP2ekh3yitUkuXYlpPVGn 6xaw== X-Gm-Message-State: AOJu0Yys72EIw8apXcBdO3S6+U8SG63uSj344eeShb3WE9FQ5avw5LGx y9G7PTbBAgsm14tCZOmwQuRb9OBRfPMyd/TpPlz5q9XuJ0x1jL74UoSjqY5oKvhIvhboWS3TV98 = X-Google-Smtp-Source: AGHT+IGXa/YwkoRZKsWFLr+lEZJK8QydJZ4OYtLdgV1zl1ZvheYGeDrw930wXE2c2yLDwv5VDpsu7g== X-Received: by 2002:a17:902:fc84:b0:205:9112:efc7 with SMTP id d9443c01a7336-208d83ac37amr174847715ad.30.1727082698697; Mon, 23 Sep 2024 02:11:38 -0700 (PDT) Received: from chenghaoyang-low.c.googlers.com.com (0.223.81.34.bc.googleusercontent.com. [34.81.223.0]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20794719c14sm129852635ad.223.2024.09.23.02.11.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Sep 2024 02:11:38 -0700 (PDT) From: Harvey Yang X-Google-Original-From: Harvey Yang To: libcamera-devel@lists.libcamera.org Cc: Han-Lin Chen , Xing Gu , Harvey Yang Subject: [PATCH 1/1] libcamera: Add formats introduced by MTK platform Date: Mon, 23 Sep 2024 09:08:53 +0000 Message-ID: <20240923091133.3328208-2-chenghaoyang@google.com> X-Mailer: git-send-email 2.46.0.792.g87dc391469-goog In-Reply-To: <20240923091133.3328208-1-chenghaoyang@google.com> References: <20240923091133.3328208-1-chenghaoyang@google.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Han-Lin Chen The patch adds the following formats. - GREY - SBGGR10_MTISP - SGBRG10_MTISP - SGRBG10_MTISP - SRGGB10_MTISP - NV12_10P_MTISP - NV12_12P_MTISP - MTFP_MTISP - MTFA_MTISP - MTFF_MTISP - MTFD_MTISP - MTFS_MTISP - MTFR_MTISP - MTSR_MTISP - WARP2P_MTISP - Y8_MTISP - Y16_MTISP - Y32_MTISP Signed-off-by: Han-Lin Chen Co-developed-by: Xing Gu Co-developed-by: Harvey Yang --- include/linux/drm_fourcc.h | 26 +++++ include/linux/videodev2.h | 22 ++++ src/libcamera/formats.cpp | 203 +++++++++++++++++++++++++++++++++++++ src/libcamera/formats.yaml | 38 +++++++ 4 files changed, 289 insertions(+) diff --git a/include/linux/drm_fourcc.h b/include/linux/drm_fourcc.h index db679877..ca00a3c7 100644 --- a/include/linux/drm_fourcc.h +++ b/include/linux/drm_fourcc.h @@ -466,6 +466,32 @@ extern "C" { #define DRM_FORMAT_SGBRG16 fourcc_code('G', 'B', '1', '6') #define DRM_FORMAT_SBGGR16 fourcc_code('B', 'Y', 'R', '2') +/* MTK extention */ + +#define DRM_FORMAT_MTISP_SBGGR10 fourcc_code('M', 'B', 'B', 'A') +#define DRM_FORMAT_MTISP_SGBRG10 fourcc_code('M', 'B', 'G', 'A') +#define DRM_FORMAT_MTISP_SGRBG10 fourcc_code('M', 'B', 'g', 'A') +#define DRM_FORMAT_MTISP_SRGGB10 fourcc_code('M', 'B', 'R', 'A') + +#define DRM_FORMAT_MTISP_NV12_10P fourcc_code('1', '2', 'A', 'P') +#define DRM_FORMAT_MTISP_NV12_12P fourcc_code('1', '2', 'C', 'P') + +#define DRM_FORMAT_GREY fourcc_code('G', 'R', 'E', 'Y') + +#define DRM_FORMAT_MTISP_PARAMS fourcc_code('M', 'T', 'f', 'p') +#define DRM_FORMAT_MTISP_3A fourcc_code('M', 'T', 'f', 'a') +#define DRM_FORMAT_MTISP_AF fourcc_code('M', 'T', 'f', 'f') + +#define DRM_FORMAT_MTISP_DESC fourcc_code('M', 'T', 'f', 'd') +#define DRM_FORMAT_MTISP_SD fourcc_code('M', 'T', 'f', 's') +#define DRM_FORMAT_MTISP_DESC_NORM fourcc_code('M', 'T', 'f', 'r') +#define DRM_FORMAT_MTISP_SDNORM fourcc_code('M', 'T', 's', 'r') + +#define DRM_FORMAT_MTISP_WARP2P fourcc_code('M', 'W', '2', 'P') +#define DRM_FORMAT_MTISP_Y8 fourcc_code('M', 'T', '0', '8') +#define DRM_FORMAT_MTISP_Y16 fourcc_code('M', 'T', '1', '6') +#define DRM_FORMAT_MTISP_Y32 fourcc_code('M', 'T', '3', '2') + /* * Format Modifiers: * diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h index 3829c0b6..2cee0b86 100644 --- a/include/linux/videodev2.h +++ b/include/linux/videodev2.h @@ -789,6 +789,28 @@ struct v4l2_pix_format { #define V4L2_PIX_FMT_IPU3_SGRBG10 v4l2_fourcc('i', 'p', '3', 'G') /* IPU3 packed 10-bit GRBG bayer */ #define V4L2_PIX_FMT_IPU3_SRGGB10 v4l2_fourcc('i', 'p', '3', 'r') /* IPU3 packed 10-bit RGGB bayer */ +#define V4L2_PIX_FMT_MTISP_SBGGR10 v4l2_fourcc('M', 'B', 'B', 'A') +#define V4L2_PIX_FMT_MTISP_SGBRG10 v4l2_fourcc('M', 'B', 'G', 'A') +#define V4L2_PIX_FMT_MTISP_SGRBG10 v4l2_fourcc('M', 'B', 'g', 'A') +#define V4L2_PIX_FMT_MTISP_SRGGB10 v4l2_fourcc('M', 'B', 'R', 'A') + +#define V4L2_PIX_FMT_MTISP_NV12_10P v4l2_fourcc('1', '2', 'A', 'P') /* Y/CbCr 4:2:0 10 bits packed */ +#define V4L2_PIX_FMT_MTISP_NV12_12P v4l2_fourcc('1', '2', 'C', 'P') /* Y/CbCr 4:2:0 12 bits packed */ + +#define V4L2_META_FMT_MTISP_PARAMS v4l2_fourcc('M', 'T', 'f', 'p') +#define V4L2_META_FMT_MTISP_3A v4l2_fourcc('M', 'T', 'f', 'a') +#define V4L2_META_FMT_MTISP_AF v4l2_fourcc('M', 'T', 'f', 'f') + +#define V4L2_META_FMT_MTISP_DESC v4l2_fourcc('M', 'T', 'f', 'd') +#define V4L2_META_FMT_MTISP_SD v4l2_fourcc('M', 'T', 'f', 's') +#define V4L2_META_FMT_MTISP_DESCNORM v4l2_fourcc('M', 'T', 'f', 'r') +#define V4L2_META_FMT_MTISP_SDNORM v4l2_fourcc('M', 'T', 's', 'r') + +#define V4L2_PIX_FMT_WARP2P v4l2_fourcc('M', 'W', '2', 'P') +#define V4L2_PIX_FMT_MTISP_Y8 v4l2_fourcc('M', 'T', '0', '8') +#define V4L2_PIX_FMT_MTISP_Y16 v4l2_fourcc('M', 'T', '1', '6') +#define V4L2_PIX_FMT_MTISP_Y32 v4l2_fourcc('M', 'T', '3', '2') + /* Raspberry Pi PiSP compressed formats. */ #define V4L2_PIX_FMT_PISP_COMP1_RGGB v4l2_fourcc('P', 'C', '1', 'R') /* PiSP 8-bit mode 1 compressed RGGB bayer */ #define V4L2_PIX_FMT_PISP_COMP1_GRBG v4l2_fourcc('P', 'C', '1', 'G') /* PiSP 8-bit mode 1 compressed GRBG bayer */ diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp index dbefb094..53ce4e7d 100644 --- a/src/libcamera/formats.cpp +++ b/src/libcamera/formats.cpp @@ -506,6 +506,16 @@ const std::map pixelFormatInfo{ .pixelsPerGroup = 1, .planes = {{ { 1, 1 }, { 0, 0 }, { 0, 0 } }}, } }, + { formats::GREY, { + .name = "GREY", + .format = formats::R8, + .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_GREY), }, + .bitsPerPixel = 8, + .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .packed = false, + .pixelsPerGroup = 1, + .planes = {{ { 1, 1 }, { 0, 0 }, { 0, 0 } }}, + } }, { formats::R10, { .name = "R10", .format = formats::R10, @@ -969,6 +979,199 @@ const std::map pixelFormatInfo{ .pixelsPerGroup = 2, .planes = {{ { 2, 1 }, { 0, 0 }, { 0, 0 } }}, } }, + { formats::SBGGR10_MTISP, { + .name = "SBGGR10_MTISP", + .format = formats::SBGGR10_MTISP, + .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_MTISP_SBGGR10), }, + .bitsPerPixel = 10, + .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .packed = true, + .pixelsPerGroup = 64, + .planes = {{ { 80, 1 }, { 0, 0 }, { 0, 0 } }}, + } }, + { formats::SGBRG10_MTISP, { + .name = "SGBRG10_MTISP", + .format = formats::SGBRG10_MTISP, + .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_MTISP_SGBRG10), }, + .bitsPerPixel = 10, + .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .packed = true, + .pixelsPerGroup = 64, + .planes = {{ { 80, 1 }, { 0, 0 }, { 0, 0 } }}, + } }, + { formats::SGRBG10_MTISP, { + .name = "SGRBG10_MTISP", + .format = formats::SGRBG10_MTISP, + .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_MTISP_SGRBG10), }, + .bitsPerPixel = 10, + .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .packed = true, + .pixelsPerGroup = 64, + .planes = {{ { 80, 1 }, { 0, 0 }, { 0, 0 } }}, + } }, + { formats::SRGGB10_MTISP, { + .name = "SRGGB10_MTISP", + .format = formats::SRGGB10_MTISP, + .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_MTISP_SRGGB10), }, + .bitsPerPixel = 10, + .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .packed = true, + .pixelsPerGroup = 64, + .planes = {{ { 80, 1 }, { 0, 0 }, { 0, 0 } }}, + } }, + { formats::NV12_10P_MTISP, { + .name = "NV12_10P_MTISP", + .format = formats::NV12_10P_MTISP, + .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_MTISP_NV12_10P), }, + .bitsPerPixel = 15, + .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .packed = true, + .pixelsPerGroup = 64, + .planes = {{ { 80, 1 }, { 80, 2 }, { 0, 0 } }}, + } }, + { formats::NV12_12P_MTISP, { + .name = "NV12_12P_MTISP", + .format = formats::NV12_12P_MTISP, + .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_MTISP_NV12_12P), }, + .bitsPerPixel = 12, + .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .packed = true, + .pixelsPerGroup = 64, + .planes = {{ { 96, 1 }, { 96, 2 }, { 0, 0 } }}, + } }, + { formats::MTFP_MTISP, { + .name = "MTFP_MTISP", + .format = formats::MTFP_MTISP, + .v4l2Formats = { + V4L2PixelFormat(V4L2_META_FMT_MTISP_PARAMS), + }, + .bitsPerPixel = 0, + .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .packed = false, + .pixelsPerGroup = 1, + .planes = {{ { 1, 1 }, { 0, 0 }, { 0, 0 } }}, + } }, + { formats::MTFA_MTISP, { + .name = "MTFA_MTISP", + .format = formats::MTFA_MTISP, + .v4l2Formats = { + V4L2PixelFormat(V4L2_META_FMT_MTISP_3A), + }, + .bitsPerPixel = 0, + .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .packed = false, + .pixelsPerGroup = 1, + .planes = {{ { 1, 1 }, { 0, 0 }, { 0, 0 } }}, + } }, + { formats::MTFF_MTISP, { + .name = "MTFF_MTISP", + .format = formats::MTFF_MTISP, + .v4l2Formats = { + V4L2PixelFormat(V4L2_META_FMT_MTISP_AF), + }, + .bitsPerPixel = 0, + .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .packed = false, + .pixelsPerGroup = 1, + .planes = {{ { 1, 1 }, { 0, 0 }, { 0, 0 } }}, + } }, + { formats::MTFD_MTISP, { + .name = "MTFD_MTISP", + .format = formats::MTFD_MTISP, + .v4l2Formats = { + V4L2PixelFormat(V4L2_META_FMT_MTISP_DESC), + }, + .bitsPerPixel = 8, + .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .packed = false, + .pixelsPerGroup = 8, + .planes = {{ { 8, 1 }, { 0, 0 }, { 0, 0 } }}, + } }, + { formats::MTFS_MTISP, { + .name = "MTFS_MTISP", + .format = formats::MTFS_MTISP, + .v4l2Formats = { + V4L2PixelFormat(V4L2_META_FMT_MTISP_SD), + }, + .bitsPerPixel = 8, + .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .packed = false, + .pixelsPerGroup = 8, + .planes = {{ { 8, 1 }, { 0, 0 }, { 0, 0 } }}, + } }, + { formats::MTFR_MTISP, { + .name = "MTFR_MTISP", + .format = formats::MTFR_MTISP, + .v4l2Formats = { + V4L2PixelFormat(V4L2_META_FMT_MTISP_DESCNORM), + }, + .bitsPerPixel = 0, + .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .packed = false, + .pixelsPerGroup = 1, + .planes = {{ { 1, 1 }, { 0, 0 }, { 0, 0 } }}, + } }, + { formats::MTSR_MTISP, { + .name = "MTSR_MTISP", + .format = formats::MTSR_MTISP, + .v4l2Formats = { + V4L2PixelFormat(V4L2_META_FMT_MTISP_SDNORM), + }, + .bitsPerPixel = 0, + .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .packed = false, + .pixelsPerGroup = 1, + .planes = {{ { 1, 1 }, { 0, 0 }, { 0, 0 } }}, + } }, + { formats::WARP2P_MTISP, { + .name = "WARP2P_MTISP", + .format = formats::WARP2P_MTISP, + .v4l2Formats = { + V4L2PixelFormat(V4L2_PIX_FMT_WARP2P), + }, + .bitsPerPixel = 32, + .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .packed = false, + .pixelsPerGroup = 2, + .planes = {{ { 8, 1 }, { 8, 1 }, { 0, 0 } }}, + } }, + { formats::Y8_MTISP, { + .name = "Y8_MTISP", + .format = formats::Y8_MTISP, + .v4l2Formats = { + V4L2PixelFormat(V4L2_PIX_FMT_MTISP_Y8), + }, + .bitsPerPixel = 8, + .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .packed = false, + .pixelsPerGroup = 1, + .planes = {{ { 1, 1 }, { 0, 0 }, { 0, 0 } }}, + } }, + { formats::Y16_MTISP, { + .name = "Y16_MTISP", + .format = formats::Y16_MTISP, + .v4l2Formats = { + V4L2PixelFormat(V4L2_PIX_FMT_MTISP_Y16), + }, + .bitsPerPixel = 16, + .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .packed = false, + .pixelsPerGroup = 1, + .planes = {{ { 2, 1 }, { 0, 0 }, { 0, 0 } }}, + } }, + { formats::Y32_MTISP, { + .name = "Y32_MTISP", + .format = formats::Y32_MTISP, + .v4l2Formats = { + V4L2PixelFormat(V4L2_PIX_FMT_MTISP_Y32), + }, + .bitsPerPixel = 32, + .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .packed = false, + .pixelsPerGroup = 1, + .planes = {{ { 4, 1 }, { 0, 0 }, { 0, 0 } }}, + } }, + /* Compressed formats. */ { formats::MJPEG, { .name = "MJPEG", diff --git a/src/libcamera/formats.yaml b/src/libcamera/formats.yaml index 2d54d391..8c72d706 100644 --- a/src/libcamera/formats.yaml +++ b/src/libcamera/formats.yaml @@ -209,4 +209,42 @@ formats: - MONO_PISP_COMP1: fourcc: DRM_FORMAT_R16 mod: PISP_FORMAT_MOD_COMPRESS_MODE1 + + - GREY: + fourcc: DRM_FORMAT_GREY + - SBGGR10_MTISP: + fourcc: DRM_FORMAT_MTISP_SBGGR10 + - SGBRG10_MTISP: + fourcc: DRM_FORMAT_MTISP_SGBRG10 + - SGRBG10_MTISP: + fourcc: DRM_FORMAT_MTISP_SGRBG10 + - SRGGB10_MTISP: + fourcc: DRM_FORMAT_MTISP_SRGGB10 + - NV12_10P_MTISP: + fourcc: DRM_FORMAT_MTISP_NV12_10P + - NV12_12P_MTISP: + fourcc: DRM_FORMAT_MTISP_NV12_12P + - MTFP_MTISP: + fourcc: DRM_FORMAT_MTISP_PARAMS + - MTFA_MTISP: + fourcc: DRM_FORMAT_MTISP_3A + - MTFF_MTISP: + fourcc: DRM_FORMAT_MTISP_AF + - MTFD_MTISP: + fourcc: DRM_FORMAT_MTISP_DESC + - MTFS_MTISP: + fourcc: DRM_FORMAT_MTISP_SD + - MTFR_MTISP: + fourcc: DRM_FORMAT_MTISP_DESC_NORM + - MTSR_MTISP: + fourcc: DRM_FORMAT_MTISP_SDNORM + - WARP2P_MTISP: + fourcc: DRM_FORMAT_MTISP_WARP2P + - Y8_MTISP: + fourcc: DRM_FORMAT_MTISP_Y8 + - Y16_MTISP: + fourcc: DRM_FORMAT_MTISP_Y16 + - Y32_MTISP: + fourcc: DRM_FORMAT_MTISP_Y32 + ...