From patchwork Thu Feb 15 13:27:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 19502 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 49DB1BDE17 for ; Thu, 15 Feb 2024 13:27:23 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9DB2C6280B; Thu, 15 Feb 2024 14:27:21 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="Ap7554da"; dkim-atps=neutral Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CE27561CB0 for ; Thu, 15 Feb 2024 14:27:19 +0100 (CET) Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-511ac32ff36so956587e87.1 for ; Thu, 15 Feb 2024 05:27:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1708003639; x=1708608439; 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=crpVpPOk2g+hz0+8zRQdstVqUMjcIwP6axfs16ih/z0=; b=Ap7554daavDh0RBLpxEgxuG2K+LB94vUeBduJIqO899D8uQFHQvUsKgX7gvGuu+CET WlqgoosjuX8nq0AZAtwSnxW+dYgD7Q4//T+Jo2PKj9j4wKqWdLBiDn7VEdPeyimiNZwe wvj2ZAQ5VWpUZpBnSitgkQ+pmUBSIRqMX4tTk9LMyYP14B/g7tdI230+IKU2iq3Q1pF7 9p42wuIOZLE4/qRS0ML7VPGS2PQ15H9ooQ+gC6xoEw7u8KiVA0EVekIuG6vCwy75o/yp lWBVCVycgUXDbZ+aYFlJBbYdKODFxBnENDgyyNAd6koXp7q7HQCIKreFjq4kGH/5Bf9M 00CQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708003639; x=1708608439; 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=crpVpPOk2g+hz0+8zRQdstVqUMjcIwP6axfs16ih/z0=; b=SRNM5QbZ48TAT1qad9j5Jk9zkRNB4y81OHubZJUyi5Ki69p5PIPlsdqzGP9MdhjlYm uv2qQyUdgkpscRwxhyZecE1CC3H5ys/WAn/JCrpGIQQyw0g5ClF4ssLnlG84IWEjqh7k 2Kv5A5b8SYwiJ/RENDOjl1lT9ZbWOCjuNVE+nzdIM7ye8lruY8kCNRpMH1cHOLI72m/p 3Ikf/akFgE/QwTfNCmY0Twoh0MkPrp/VeV4VawRsuVNcMdQPp+TGs9NrMi90s/t32Tnn klIPX2QawdeMGbX+6hnrsp9tHqyJVZ8TRvs3ODQlQbTq7FUui7ae5UZno47E3QerR4Dq qiKA== X-Gm-Message-State: AOJu0YxY5cs/6SStreyEzwJyOaG0clg0AnaFFwUdOqphcM1UsvIjc5ez CJ0Oj2RMaKAs9+2iwSPy5XPjWNPyTCHI1xnhjAmdZEmspuTjIV95FY7UjcTmmLgCbpZocAKj28J k X-Google-Smtp-Source: AGHT+IHWcBxPHWmWjMLi3C5mm8AMCm2PqLUqcshTjsj8hpXRPcn/6OBc9+MoHLrWMehX0jTTraGIcw== X-Received: by 2002:a05:6512:124c:b0:511:85ae:8985 with SMTP id fb12-20020a056512124c00b0051185ae8985mr1614890lfb.53.1708003638583; Thu, 15 Feb 2024 05:27:18 -0800 (PST) Received: from localhost.localdomain ([188.39.149.98]) by smtp.gmail.com with ESMTPSA id ew14-20020a056402538e00b005607825b11bsm532283edb.12.2024.02.15.05.27.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 05:27:18 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Subject: [PATCH v1 1/2] libcamera: formats: Add RGB48 formats Date: Thu, 15 Feb 2024 13:27:09 +0000 Message-Id: <20240215132710.810-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215132710.810-1-naush@raspberrypi.com> References: <20240215132710.810-1-naush@raspberrypi.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" Add support for 16-bps (48-bpp) RGB output formats. These new formats are define for the RGB and BGR ordering. Signed-off-by: Naushir Patuck --- include/linux/drm_fourcc.h | 4 ++++ include/linux/videodev2.h | 4 ++++ src/libcamera/formats.cpp | 20 ++++++++++++++++++++ src/libcamera/formats.yaml | 5 +++++ src/libcamera/v4l2_pixelformat.cpp | 4 ++++ 5 files changed, 37 insertions(+) diff --git a/include/linux/drm_fourcc.h b/include/linux/drm_fourcc.h index d6c83d9c49f4..4ee421b95730 100644 --- a/include/linux/drm_fourcc.h +++ b/include/linux/drm_fourcc.h @@ -210,6 +210,10 @@ extern "C" { #define DRM_FORMAT_RGBA1010102 fourcc_code('R', 'A', '3', '0') /* [31:0] R:G:B:A 10:10:10:2 little endian */ #define DRM_FORMAT_BGRA1010102 fourcc_code('B', 'A', '3', '0') /* [31:0] B:G:R:A 10:10:10:2 little endian */ +/* 48 bpp RGB */ +#define DRM_FORMAT_RGB161616 fourcc_code('R', 'G', '4', '8') /* [48:0] R:G:B 16:16:16 little endian */ +#define DRM_FORMAT_BGR161616 fourcc_code('B', 'G', '4', '8') /* [48:0] R:G:B 16:16:16 little endian */ + /* 64 bpp RGB */ #define DRM_FORMAT_XRGB16161616 fourcc_code('X', 'R', '4', '8') /* [63:0] x:R:G:B 16:16:16:16 little endian */ #define DRM_FORMAT_XBGR16161616 fourcc_code('X', 'B', '4', '8') /* [63:0] x:B:G:R 16:16:16:16 little endian */ diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h index 7e556911c9e1..ba48d2c89726 100644 --- a/include/linux/videodev2.h +++ b/include/linux/videodev2.h @@ -557,6 +557,10 @@ struct v4l2_pix_format { #define V4L2_PIX_FMT_BGR48_12 v4l2_fourcc('B', '3', '1', '2') /* 48 BGR 12-bit per component */ #define V4L2_PIX_FMT_ABGR64_12 v4l2_fourcc('B', '4', '1', '2') /* 64 BGRA 12-bit per component */ +/* RGB formats (6 bytes per pixel) */ +#define V4L2_PIX_FMT_BGR48 v4l2_fourcc('B', 'G', 'R', '6') /* 16 BGR-16-16-16 */ +#define V4L2_PIX_FMT_RGB48 v4l2_fourcc('R', 'G', 'B', '6') /* 16 RGB-16-16-16 */ + /* Grey formats */ #define V4L2_PIX_FMT_GREY v4l2_fourcc('G', 'R', 'E', 'Y') /* 8 Greyscale */ #define V4L2_PIX_FMT_Y4 v4l2_fourcc('Y', '0', '4', ' ') /* 4 Greyscale */ diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp index 8a606a7c37f1..a674f4179cc8 100644 --- a/src/libcamera/formats.cpp +++ b/src/libcamera/formats.cpp @@ -270,6 +270,26 @@ const std::map pixelFormatInfo{ .pixelsPerGroup = 1, .planes = {{ { 4, 1 }, { 0, 0 }, { 0, 0 } }}, } }, + { formats::BGR161616, { + .name = "BGR161616", + .format = formats::BGR161616, + .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_RGB48), }, + .bitsPerPixel = 48, + .colourEncoding = PixelFormatInfo::ColourEncodingRGB, + .packed = false, + .pixelsPerGroup = 1, + .planes = {{ { 3, 1 }, { 0, 0 }, { 0, 0 } }}, + } }, + { formats::RGB161616, { + .name = "RGB161616", + .format = formats::RGB161616, + .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_BGR48), }, + .bitsPerPixel = 24, + .colourEncoding = PixelFormatInfo::ColourEncodingRGB, + .packed = false, + .pixelsPerGroup = 1, + .planes = {{ { 3, 1 }, { 0, 0 }, { 0, 0 } }}, + } }, /* YUV packed formats. */ { formats::YUYV, { diff --git a/src/libcamera/formats.yaml b/src/libcamera/formats.yaml index d8a379923b56..bde2cc803b98 100644 --- a/src/libcamera/formats.yaml +++ b/src/libcamera/formats.yaml @@ -43,6 +43,11 @@ formats: - BGRA8888: fourcc: DRM_FORMAT_BGRA8888 + - RGB161616: + fourcc: DRM_FORMAT_RGB161616 + - BGR161616: + fourcc: DRM_FORMAT_BGR161616 + - YUYV: fourcc: DRM_FORMAT_YUYV - YVYU: diff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp index 731dc10f1d73..efb6f2940235 100644 --- a/src/libcamera/v4l2_pixelformat.cpp +++ b/src/libcamera/v4l2_pixelformat.cpp @@ -71,6 +71,10 @@ const std::map vpf2pf{ { formats::BGRA8888, "32-bit ARGB 8-8-8-8" } }, { V4L2PixelFormat(V4L2_PIX_FMT_BGRA32), { formats::RGBA8888, "32-bit ABGR 8-8-8-8" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_RGB48), + { formats::BGR161616, "48-bit RGB 16-16-16" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_BGR48), + { formats::RGB161616, "48-bit BGR 16-16-16" } }, /* YUV packed formats. */ { V4L2PixelFormat(V4L2_PIX_FMT_YUYV), From patchwork Thu Feb 15 13:27:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 19503 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 7521BC3259 for ; Thu, 15 Feb 2024 13:27:24 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6546462809; Thu, 15 Feb 2024 14:27:22 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="o6ESsUsH"; dkim-atps=neutral Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3B64862801 for ; Thu, 15 Feb 2024 14:27:20 +0100 (CET) Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-562178003a1so1081394a12.1 for ; Thu, 15 Feb 2024 05:27:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1708003639; x=1708608439; 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=dK3sYvk+h2g09CZpsWIaT7kzrLDBNhXyidVoRqp0nz0=; b=o6ESsUsHpJR5QlPBWmR/7J2fck6WVVUx99yOYX85hWSCXIqubMsh/NKTNgVah+2mQ8 kiNR2TBklIUUorQVijBAAqytF2P4NHYhxL54n0sMvkIhydTVLni693bGHafieOu3WK90 wcHdxV+U2LQtHI3Veu1Qx+RdcQy7eUN9Sfhlyrrq55iz0litEfJR04IR2TTaEYbhUQSN EOIzgdOpgZqG5sRmqS9e0gCl3MOimTKVF4CkXpvRfcmcV/P93KxOIsOA1N6IZV8E7/+b 688+kb8F7PRprE5yNo6+Z9sScaB/gouj1qou5gaF6r4ilIahYYtQ1G81p3yuk/ZfqAPP opfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708003639; x=1708608439; 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=dK3sYvk+h2g09CZpsWIaT7kzrLDBNhXyidVoRqp0nz0=; b=KRWqaaHRcP/jf0Lr2xyyFw14xd1WH15f43O+EENFUDlHn9ucYZniZerN4qwIHpJrpc i71S6Y2S/BvILLlgbIm9x6YZrk4rS9FuDLkfFJrX3o0uO+cwHYUqpNeiqWUEb8Ct9GiY ZvelxHDEa7UtDJIox6vaDuGXpJYHqrRRc2P5+JAqbkIMr1ZneMRy8a7eUCdD8AeS6kwZ gUrac7DdkuhXj1nk9TBI6yEAveoX3jFLhoZec/yzhH62JrEmATXtvQdsBHJPginLd1Wr r9dAw2xoNS/FIdo6xhUPhCtsF3FzQc+bUdC7QPKFPKrNxCMvC3Dw/rZlcmqJEagDcOMM NOdw== X-Gm-Message-State: AOJu0Yz1bDy5zf6nUr3HheiR39Ia3Oss5wDT4PxglENVQfu00l7UxBND MHCeKy7pHnnB/dnITuTQ72mgyzrdEKWog5OrMIXkG25jCVC1GYrn3/7fq9zPeAR2riq08DyFXJ/ p X-Google-Smtp-Source: AGHT+IHZVCbiQ/vRQP4TvTwhm6/MJsxzyzOGQc8Fc+renLBcXArB9ezi/4OuCb52+qANd88OjVt/rw== X-Received: by 2002:a05:6402:120c:b0:561:adff:6acc with SMTP id c12-20020a056402120c00b00561adff6accmr1257305edw.26.1708003639251; Thu, 15 Feb 2024 05:27:19 -0800 (PST) Received: from localhost.localdomain ([188.39.149.98]) by smtp.gmail.com with ESMTPSA id ew14-20020a056402538e00b005607825b11bsm532283edb.12.2024.02.15.05.27.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 05:27:18 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Subject: [PATCH v1 2/2] libcamera: formats: Add PiSP specific image and config buffer formats Date: Thu, 15 Feb 2024 13:27:10 +0000 Message-Id: <20240215132710.810-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215132710.810-1-naush@raspberrypi.com> References: <20240215132710.810-1-naush@raspberrypi.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" Add the Raspberry Pi 5 PiSP specific compressed Bayer format types 1/2: - V4L2_PIX_FMT_PISP_COMP1_xxx - V4L2_PIX_FMT_PISP_COMP2_xxx Add the Raspberry Pi 5 PiSP Backend config format: - V4L2_META_FMT_RPI_BE_CFG Additionally, we also extend libcamera format handlers to support 16-bit Bayer formats across the media bus. Signed-off-by: Naushir Patuck --- include/libcamera/internal/bayer_format.h | 2 + include/linux/drm_fourcc.h | 4 ++ include/linux/videodev2.h | 15 +++++++ src/libcamera/bayer_format.cpp | 18 ++++++++ src/libcamera/formats.cpp | 51 ++++++++++++++++++++++- src/libcamera/formats.yaml | 16 +++++++ src/libcamera/v4l2_pixelformat.cpp | 10 +++++ src/libcamera/v4l2_subdevice.cpp | 4 ++ 8 files changed, 119 insertions(+), 1 deletion(-) diff --git a/include/libcamera/internal/bayer_format.h b/include/libcamera/internal/bayer_format.h index 78ba3969913d..164743f7e9f6 100644 --- a/include/libcamera/internal/bayer_format.h +++ b/include/libcamera/internal/bayer_format.h @@ -34,6 +34,8 @@ public: None = 0, CSI2 = 1, IPU3 = 2, + PISP1 = 3, + PISP2 = 4, }; constexpr BayerFormat() diff --git a/include/linux/drm_fourcc.h b/include/linux/drm_fourcc.h index 4ee421b95730..eff27fbe5a1e 100644 --- a/include/linux/drm_fourcc.h +++ b/include/linux/drm_fourcc.h @@ -490,6 +490,7 @@ extern "C" { #define DRM_FORMAT_MOD_VENDOR_ALLWINNER 0x09 #define DRM_FORMAT_MOD_VENDOR_AMLOGIC 0x0a #define DRM_FORMAT_MOD_VENDOR_MIPI 0x0b +#define DRM_FORMAT_MOD_VENDOR_RPI 0x0c /* add more to the end as needed */ @@ -1670,6 +1671,9 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier) */ #define MIPI_FORMAT_MOD_CSI2_PACKED fourcc_mod_code(MIPI, 1) +#define PISP_FORMAT_MOD_COMPRESS_MODE1 fourcc_mod_code(RPI, 1) +#define PISP_FORMAT_MOD_COMPRESS_MODE2 fourcc_mod_code(RPI, 2) + #if defined(__cplusplus) } #endif diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h index ba48d2c89726..59af6f794680 100644 --- a/include/linux/videodev2.h +++ b/include/linux/videodev2.h @@ -789,6 +789,18 @@ 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 */ +/* The pixel format for all our buffers (the precise format is found in the config buffer). */ +#define V4L2_PIX_FMT_PISP_COMP1_RGGB v4l2_fourcc('P', 'C', '1', 'R') +#define V4L2_PIX_FMT_PISP_COMP1_GRBG v4l2_fourcc('P', 'C', '1', 'G') +#define V4L2_PIX_FMT_PISP_COMP1_GBRG v4l2_fourcc('P', 'C', '1', 'g') +#define V4L2_PIX_FMT_PISP_COMP1_BGGR v4l2_fourcc('P', 'C', '1', 'B') +#define V4L2_PIX_FMT_PISP_COMP1_MONO v4l2_fourcc('P', 'C', '1', 'M') +#define V4L2_PIX_FMT_PISP_COMP2_RGGB v4l2_fourcc('P', 'C', '2', 'R') +#define V4L2_PIX_FMT_PISP_COMP2_GRBG v4l2_fourcc('P', 'C', '2', 'G') +#define V4L2_PIX_FMT_PISP_COMP2_GBRG v4l2_fourcc('P', 'C', '2', 'g') +#define V4L2_PIX_FMT_PISP_COMP2_BGGR v4l2_fourcc('P', 'C', '2', 'B') +#define V4L2_PIX_FMT_PISP_COMP2_MONO v4l2_fourcc('P', 'C', '2', 'M') + /* SDR formats - used only for Software Defined Radio devices */ #define V4L2_SDR_FMT_CU8 v4l2_fourcc('C', 'U', '0', '8') /* IQ u8 */ #define V4L2_SDR_FMT_CU16LE v4l2_fourcc('C', 'U', '1', '6') /* IQ u16le */ @@ -818,6 +830,9 @@ struct v4l2_pix_format { #define V4L2_META_FMT_RK_ISP1_PARAMS v4l2_fourcc('R', 'K', '1', 'P') /* Rockchip ISP1 3A Parameters */ #define V4L2_META_FMT_RK_ISP1_STAT_3A v4l2_fourcc('R', 'K', '1', 'S') /* Rockchip ISP1 3A Statistics */ +/* Vendor specific - used for RaspberryPi PiSP */ +#define V4L2_META_FMT_RPI_BE_CFG v4l2_fourcc('R', 'P', 'B', 'C') /* PiSP BE configuration */ + /* priv field value to indicates that subsequent fields are valid. */ #define V4L2_PIX_FMT_PRIV_MAGIC 0xfeedcafe diff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp index 20aedfa6d925..333b1117f531 100644 --- a/src/libcamera/bayer_format.cpp +++ b/src/libcamera/bayer_format.cpp @@ -164,6 +164,14 @@ const std::map bayerToFormat{ { formats::SGRBG16, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG16) } }, { { BayerFormat::RGGB, 16, BayerFormat::Packing::None }, { formats::SRGGB16, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB16) } }, + { { BayerFormat::BGGR, 16, BayerFormat::Packing::PISP1 }, + { formats::BGGR16_PISP_COMP1, V4L2PixelFormat(V4L2_PIX_FMT_PISP_COMP1_BGGR) } }, + { { BayerFormat::GBRG, 16, BayerFormat::Packing::PISP1 }, + { formats::GBRG16_PISP_COMP1, V4L2PixelFormat(V4L2_PIX_FMT_PISP_COMP1_GBRG) } }, + { { BayerFormat::GRBG, 16, BayerFormat::Packing::PISP1 }, + { formats::GRBG16_PISP_COMP1, V4L2PixelFormat(V4L2_PIX_FMT_PISP_COMP1_GRBG) } }, + { { BayerFormat::RGGB, 16, BayerFormat::Packing::PISP1 }, + { formats::RGGB16_PISP_COMP1, V4L2PixelFormat(V4L2_PIX_FMT_PISP_COMP1_RGGB) } }, { { BayerFormat::MONO, 8, BayerFormat::Packing::None }, { formats::R8, V4L2PixelFormat(V4L2_PIX_FMT_GREY) } }, { { BayerFormat::MONO, 10, BayerFormat::Packing::None }, @@ -174,6 +182,8 @@ const std::map bayerToFormat{ { formats::R12, V4L2PixelFormat(V4L2_PIX_FMT_Y12) } }, { { BayerFormat::MONO, 16, BayerFormat::Packing::None }, { formats::R16, V4L2PixelFormat(V4L2_PIX_FMT_Y16) } }, + { { BayerFormat::MONO, 16, BayerFormat::Packing::PISP1 }, + { formats::MONO_PISP_COMP1, V4L2PixelFormat(V4L2_PIX_FMT_PISP_COMP1_MONO) } }, }; const std::unordered_map mbusCodeToBayer{ @@ -209,6 +219,10 @@ const std::unordered_map mbusCodeToBayer{ { MEDIA_BUS_FMT_SGBRG16_1X16, { BayerFormat::GBRG, 16, BayerFormat::Packing::None } }, { MEDIA_BUS_FMT_SGRBG16_1X16, { BayerFormat::GRBG, 16, BayerFormat::Packing::None } }, { MEDIA_BUS_FMT_SRGGB16_1X16, { BayerFormat::RGGB, 16, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SBGGR16_1X16, { BayerFormat::BGGR, 16, BayerFormat::Packing::PISP1 } }, + { MEDIA_BUS_FMT_SGBRG16_1X16, { BayerFormat::GBRG, 16, BayerFormat::Packing::PISP1 } }, + { MEDIA_BUS_FMT_SGRBG16_1X16, { BayerFormat::GRBG, 16, BayerFormat::Packing::PISP1 } }, + { MEDIA_BUS_FMT_SRGGB16_1X16, { BayerFormat::RGGB, 16, BayerFormat::Packing::PISP1 } }, { MEDIA_BUS_FMT_Y8_1X8, { BayerFormat::MONO, 8, BayerFormat::Packing::None } }, { MEDIA_BUS_FMT_Y10_1X10, { BayerFormat::MONO, 10, BayerFormat::Packing::None } }, { MEDIA_BUS_FMT_Y12_1X12, { BayerFormat::MONO, 12, BayerFormat::Packing::None } }, @@ -303,6 +317,10 @@ std::ostream &operator<<(std::ostream &out, const BayerFormat &f) out << "-CSI2P"; else if (f.packing == BayerFormat::Packing::IPU3) out << "-IPU3P"; + else if (f.packing == BayerFormat::Packing::PISP1) + out << "-PISP1"; + else if (f.packing == BayerFormat::Packing::PISP2) + out << "-PISP2"; return out; } diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp index a674f4179cc8..e603a7eda579 100644 --- a/src/libcamera/formats.cpp +++ b/src/libcamera/formats.cpp @@ -547,6 +547,16 @@ const std::map pixelFormatInfo{ .pixelsPerGroup = 1, .planes = {{ { 2, 1 }, { 0, 0 }, { 0, 0 } }}, } }, + { formats::MONO_PISP_COMP1, { + .name = "MONO_PISP_COMP1", + .format = formats::MONO_PISP_COMP1, + .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_PISP_COMP1_MONO), }, + .bitsPerPixel = 16, + .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .packed = true, + .pixelsPerGroup = 1, + .planes = {{ { 2, 1 }, { 0, 0 }, { 0, 0 } }}, + } }, /* Bayer formats. */ { formats::SBGGR8, { @@ -910,7 +920,46 @@ const std::map pixelFormatInfo{ .pixelsPerGroup = 25, .planes = {{ { 32, 1 }, { 0, 0 }, { 0, 0 } }}, } }, - + { formats::BGGR16_PISP_COMP1, { + .name = "BGGR16_PISP_COMP1", + .format = formats::BGGR16_PISP_COMP1, + .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_PISP_COMP1_BGGR), }, + .bitsPerPixel = 16, + .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .packed = true, + .pixelsPerGroup = 2, + .planes = {{ { 2, 1 }, { 0, 0 }, { 0, 0 } }}, + } }, + { formats::GBRG16_PISP_COMP1, { + .name = "GBRG16_PISP_COMP1", + .format = formats::GBRG16_PISP_COMP1, + .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_PISP_COMP1_GBRG), }, + .bitsPerPixel = 16, + .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .packed = true, + .pixelsPerGroup = 2, + .planes = {{ { 2, 1 }, { 0, 0 }, { 0, 0 } }}, + } }, + { formats::GRBG16_PISP_COMP1, { + .name = "GRBG16_PISP_COMP1", + .format = formats::GRBG16_PISP_COMP1, + .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_PISP_COMP1_GRBG), }, + .bitsPerPixel = 16, + .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .packed = true, + .pixelsPerGroup = 2, + .planes = {{ { 2, 1 }, { 0, 0 }, { 0, 0 } }}, + } }, + { formats::RGGB16_PISP_COMP1, { + .name = "RGGB16_PISP_COMP1", + .format = formats::RGGB16_PISP_COMP1, + .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_PISP_COMP1_RGGB), }, + .bitsPerPixel = 16, + .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .packed = true, + .pixelsPerGroup = 2, + .planes = {{ { 2, 1 }, { 0, 0 }, { 0, 0 } }}, + } }, /* Compressed formats. */ { formats::MJPEG, { .name = "MJPEG", diff --git a/src/libcamera/formats.yaml b/src/libcamera/formats.yaml index bde2cc803b98..f6df721243d0 100644 --- a/src/libcamera/formats.yaml +++ b/src/libcamera/formats.yaml @@ -190,4 +190,20 @@ formats: - SBGGR10_IPU3: fourcc: DRM_FORMAT_SBGGR10 mod: IPU3_FORMAT_MOD_PACKED + + - RGGB16_PISP_COMP1: + fourcc: DRM_FORMAT_SRGGB16 + mod: PISP_FORMAT_MOD_COMPRESS_MODE1 + - GRBG16_PISP_COMP1: + fourcc: DRM_FORMAT_SGRBG16 + mod: PISP_FORMAT_MOD_COMPRESS_MODE1 + - GBRG16_PISP_COMP1: + fourcc: DRM_FORMAT_SGBRG16 + mod: PISP_FORMAT_MOD_COMPRESS_MODE1 + - BGGR16_PISP_COMP1: + fourcc: DRM_FORMAT_SBGGR16 + mod: PISP_FORMAT_MOD_COMPRESS_MODE1 + - MONO_PISP_COMP1: + fourcc: DRM_FORMAT_R16 + mod: PISP_FORMAT_MOD_COMPRESS_MODE1 ... diff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp index efb6f2940235..47baaf60199d 100644 --- a/src/libcamera/v4l2_pixelformat.cpp +++ b/src/libcamera/v4l2_pixelformat.cpp @@ -207,6 +207,16 @@ const std::map vpf2pf{ { formats::SGRBG16, "16-bit Bayer GRGR/BGBG" } }, { V4L2PixelFormat(V4L2_PIX_FMT_SRGGB16), { formats::SRGGB16, "16-bit Bayer RGRG/GBGB" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_PISP_COMP1_BGGR), + { formats::BGGR16_PISP_COMP1, "16-bit Bayer BGBG/GRGR PiSP Compress Mode 1" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_PISP_COMP1_GBRG), + { formats::GBRG16_PISP_COMP1, "16-bit Bayer GBGB/RGRG PiSP Compress Mode 1" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_PISP_COMP1_GRBG), + { formats::GRBG16_PISP_COMP1, "16-bit Bayer GRGR/BGBG PiSP Compress Mode 1" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_PISP_COMP1_RGGB), + { formats::RGGB16_PISP_COMP1, "16-bit Bayer RGRG/GBGB PiSP Compress Mode 1" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_PISP_COMP1_MONO), + { formats::MONO_PISP_COMP1, "16-bit Mono PiSP Compress Mode 1" } }, /* Compressed formats. */ { V4L2PixelFormat(V4L2_PIX_FMT_MJPEG), diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp index 6d0785b7b484..aea90abaf9ef 100644 --- a/src/libcamera/v4l2_subdevice.cpp +++ b/src/libcamera/v4l2_subdevice.cpp @@ -134,6 +134,10 @@ const std::map formatInfoMap = { { MEDIA_BUS_FMT_SGBRG12_1X12, { 12, "SGBRG12_1X12", PixelFormatInfo::ColourEncodingRAW } }, { MEDIA_BUS_FMT_SGRBG12_1X12, { 12, "SGRBG12_1X12", PixelFormatInfo::ColourEncodingRAW } }, { MEDIA_BUS_FMT_SRGGB12_1X12, { 12, "SRGGB12_1X12", PixelFormatInfo::ColourEncodingRAW } }, + { MEDIA_BUS_FMT_SBGGR16_1X16, { 16, "SBGGR16_1x16", PixelFormatInfo::ColourEncodingRAW } }, + { MEDIA_BUS_FMT_SGBRG16_1X16, { 16, "SGBRG16_1x16", PixelFormatInfo::ColourEncodingRAW } }, + { MEDIA_BUS_FMT_SGRBG16_1X16, { 16, "SGRBG16_1x16", PixelFormatInfo::ColourEncodingRAW } }, + { MEDIA_BUS_FMT_SRGGB16_1X16, { 16, "SRGGB16_1x16", PixelFormatInfo::ColourEncodingRAW } }, /* \todo Clarify colour encoding for HSV formats */ { MEDIA_BUS_FMT_AHSV8888_1X32, { 32, "AHSV8888_1X32", PixelFormatInfo::ColourEncodingRGB } }, { MEDIA_BUS_FMT_JPEG_1X8, { 8, "JPEG_1X8", PixelFormatInfo::ColourEncodingYUV } },