From patchwork Thu Jul 24 06:52:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Scally X-Patchwork-Id: 23918 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 DA3B0BDCC1 for ; Thu, 24 Jul 2025 06:53:22 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 43D9B69096; Thu, 24 Jul 2025 08:53:19 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="fc/fA6Sz"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 997486907E for ; Thu, 24 Jul 2025 08:53:14 +0200 (CEST) Received: from mail.ideasonboard.com (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net [86.13.91.161]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id AA29C17D1; Thu, 24 Jul 2025 08:52:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1753339955; bh=7ySlySvu4he2NhT4wsKGPQRgyDjeYJ/JQDThvTHxKtI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fc/fA6SzAjqMx/DmY4jB5CyRUu5cbX2uFyQd+u1ZyqL+rrD5fK09tsAdV0L6P8xfP QX3tcpDmsPFF//PvRHMsQpFSwJJVhBgLaTTRjUF9+J0Sq60GFciupUu4U2q5WUCtOc J520uMAPLUxY0zbK3Pjqi3F2RNHIKC+/vMymaT80= From: Daniel Scally To: libcamera-devel@lists.libcamera.org Cc: Daniel Scally Subject: [PATCH 01/10] include: linux: Add Renesas RZ/G2L CRU Pixel Formats Date: Thu, 24 Jul 2025 07:52:47 +0100 Message-Id: <20250724065256.75175-2-dan.scally@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250724065256.75175-1-dan.scally@ideasonboard.com> References: <20250724065256.75175-1-dan.scally@ideasonboard.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 RZ/G2L's Pixel Formats, which are not yet upstream, to videodev2.h Signed-off-by: Daniel Scally Acked-by: Kieran Bingham --- include/linux/videodev2.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h index 317d063a..defc80ef 100644 --- a/include/linux/videodev2.h +++ b/include/linux/videodev2.h @@ -801,6 +801,12 @@ struct v4l2_pix_format { #define V4L2_PIX_FMT_PISP_COMP2_BGGR v4l2_fourcc('P', 'C', '2', 'B') /* PiSP 8-bit mode 2 compressed BGGR bayer */ #define V4L2_PIX_FMT_PISP_COMP2_MONO v4l2_fourcc('P', 'C', '2', 'M') /* PiSP 8-bit mode 2 compressed monochrome */ +/* Renesas RZ/V2H CRU packed formats. 64-bit units with contiguous pixels */ +#define V4L2_PIX_FMT_RAW_CRU10 v4l2_fourcc('C', 'R', '1', '0') +#define V4L2_PIX_FMT_RAW_CRU12 v4l2_fourcc('C', 'R', '1', '2') +#define V4L2_PIX_FMT_RAW_CRU14 v4l2_fourcc('C', 'R', '1', '4') +#define V4L2_PIX_FMT_RAW_CRU20 v4l2_fourcc('C', 'R', '2', '0') + /* 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 */ From patchwork Thu Jul 24 06:52:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Scally X-Patchwork-Id: 23919 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 0E73FBDCC1 for ; Thu, 24 Jul 2025 06:53:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 395DF69097; Thu, 24 Jul 2025 08:53:20 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="BtFAsGJn"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D48126907F for ; Thu, 24 Jul 2025 08:53:14 +0200 (CEST) Received: from mail.ideasonboard.com (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net [86.13.91.161]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E8CEA190D; Thu, 24 Jul 2025 08:52:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1753339956; bh=ZPQ+ZpDt9xQ1HfY5kYKlZDuS6l9xDcEmSc92qAz76LQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BtFAsGJnM8Wp1mGbqCbKyYeI04PiX2hN3y2Wx7angvvXkJCJZk69wQ1F1IetZWMJT 7fWrOG0eEo6afDOvZi3ndAGUl411OLRMpD1vIbNLXX/vhO+Suj5tFVlCrLAaTJFOZS dLEKOai5OgduDP/f1WNlk6sD8IPn4uibJupNnHEU= From: Daniel Scally To: libcamera-devel@lists.libcamera.org Cc: Daniel Scally Subject: [PATCH 02/10] include: linux: Add RAWnn to drm_fourcc.h Date: Thu, 24 Jul 2025 07:52:48 +0100 Message-Id: <20250724065256.75175-3-dan.scally@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250724065256.75175-1-dan.scally@ideasonboard.com> References: <20250724065256.75175-1-dan.scally@ideasonboard.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 entries to drm_fourcc.h for bayer order agnostic RAW formats at 10, 12, 14 and 20 bits. Add a modifier for the CRU format packing. These will need to be applied upstream, at which stage the script can maintain their presence here. Signed-off-by: Daniel Scally --- include/linux/drm_fourcc.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/linux/drm_fourcc.h b/include/linux/drm_fourcc.h index db679877..7257f623 100644 --- a/include/linux/drm_fourcc.h +++ b/include/linux/drm_fourcc.h @@ -447,18 +447,21 @@ extern "C" { #define DRM_FORMAT_SGRBG10 fourcc_code('B', 'A', '1', '0') #define DRM_FORMAT_SGBRG10 fourcc_code('G', 'B', '1', '0') #define DRM_FORMAT_SBGGR10 fourcc_code('B', 'G', '1', '0') +#define DRM_FORMAT_RAW10 fourcc_code('R', 'W', '1', '0') /* 12-bit Bayer formats */ #define DRM_FORMAT_SRGGB12 fourcc_code('R', 'G', '1', '2') #define DRM_FORMAT_SGRBG12 fourcc_code('B', 'A', '1', '2') #define DRM_FORMAT_SGBRG12 fourcc_code('G', 'B', '1', '2') #define DRM_FORMAT_SBGGR12 fourcc_code('B', 'G', '1', '2') +#define DRM_FORMAT_RAW12 fourcc_code('R', 'W', '1', '2') /* 14-bit Bayer formats */ #define DRM_FORMAT_SRGGB14 fourcc_code('R', 'G', '1', '4') #define DRM_FORMAT_SGRBG14 fourcc_code('B', 'A', '1', '4') #define DRM_FORMAT_SGBRG14 fourcc_code('G', 'B', '1', '4') #define DRM_FORMAT_SBGGR14 fourcc_code('B', 'G', '1', '4') +#define DRM_FORMAT_RAW14 fourcc_code('R', 'W', '1', '4') /* 16-bit Bayer formats */ #define DRM_FORMAT_SRGGB16 fourcc_code('R', 'G', 'B', '6') @@ -466,6 +469,9 @@ extern "C" { #define DRM_FORMAT_SGBRG16 fourcc_code('G', 'B', '1', '6') #define DRM_FORMAT_SBGGR16 fourcc_code('B', 'Y', 'R', '2') +/* 20-bit Bayer formats */ +#define DRM_FORMAT_RAW20 fourcc_code('R', 'W', '2', '0') + /* * Format Modifiers: * @@ -491,6 +497,7 @@ extern "C" { #define DRM_FORMAT_MOD_VENDOR_AMLOGIC 0x0a #define DRM_FORMAT_MOD_VENDOR_MIPI 0x0b #define DRM_FORMAT_MOD_VENDOR_RPI 0x0c +#define DRM_FORMAT_MOD_VENDOR_RENESAS 0x0d /* add more to the end as needed */ @@ -1692,6 +1699,8 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier) #define PISP_FORMAT_MOD_COMPRESS_MODE1 fourcc_mod_code(RPI, 1) #define PISP_FORMAT_MOD_COMPRESS_MODE2 fourcc_mod_code(RPI, 2) +#define RENESAS_CRU_FORMAT_MOD_PACKED fourcc_mod_code(RENESAS, 1) + #if defined(__cplusplus) } #endif From patchwork Thu Jul 24 06:52:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Scally X-Patchwork-Id: 23920 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 B3627C3323 for ; Thu, 24 Jul 2025 06:53:26 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E31AB6908C; Thu, 24 Jul 2025 08:53:20 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="bCswFjzI"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2382169083 for ; Thu, 24 Jul 2025 08:53:15 +0200 (CEST) Received: from mail.ideasonboard.com (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net [86.13.91.161]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 32A7F7F0; Thu, 24 Jul 2025 08:52:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1753339956; bh=5RAKvTIfp8RHT/B2l1kVT4fZU1T6Wk1qqcrv8/GTyvg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bCswFjzIT5llmBXM/+4ZIah7qDC5Fe/T3MTff2+RqVeDplw2mXvs4NqzWl9N9+Xyt QgYeIPYtn3bj6YCj6G2XPtOcBCIs75TuV8yBcwWKOVAq7Rj3cJSQ4+YKDfNnpEst1k JmeMBF3toSSI5muADrw/3gwYrVK0brjvuVcdbbZg= From: Daniel Scally To: libcamera-devel@lists.libcamera.org Cc: Daniel Scally Subject: [PATCH 03/10] libcamera: bayer_format: Add "NONE" to BayerFormat::Order enum Date: Thu, 24 Jul 2025 07:52:49 +0100 Message-Id: <20250724065256.75175-4-dan.scally@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250724065256.75175-1-dan.scally@ideasonboard.com> References: <20250724065256.75175-1-dan.scally@ideasonboard.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 a NONE entry to BayerFormat::Order enumeration to denote pixel formats encoding bayer data but which do not correspond to a specific order. Signed-off-by: Daniel Scally Reviewed-by: Kieran Bingham --- include/libcamera/internal/bayer_format.h | 3 ++- src/libcamera/bayer_format.cpp | 3 +++ src/libcamera/sensor/camera_sensor_legacy.cpp | 6 ++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/libcamera/internal/bayer_format.h b/include/libcamera/internal/bayer_format.h index 5c14bb5f..9b6b5b58 100644 --- a/include/libcamera/internal/bayer_format.h +++ b/include/libcamera/internal/bayer_format.h @@ -27,7 +27,8 @@ public: GBRG = 1, GRBG = 2, RGGB = 3, - MONO = 4 + MONO = 4, + NONE = 5 }; enum class Packing : uint16_t { diff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp index 3dab91fc..89fe10ed 100644 --- a/src/libcamera/bayer_format.cpp +++ b/src/libcamera/bayer_format.cpp @@ -49,6 +49,9 @@ namespace libcamera { * \brief R then G on the first row, G then B on the second row. * \var BayerFormat::MONO * \brief Monochrome image data, there is no colour filter array. + * \var BayerFormat::NONE + * \brief Bayer-formatted data but without a specific order, which will have to + * be discerned through other means. */ /** diff --git a/src/libcamera/sensor/camera_sensor_legacy.cpp b/src/libcamera/sensor/camera_sensor_legacy.cpp index 32989c19..232a8525 100644 --- a/src/libcamera/sensor/camera_sensor_legacy.cpp +++ b/src/libcamera/sensor/camera_sensor_legacy.cpp @@ -641,6 +641,12 @@ int CameraSensorLegacy::initProperties() case BayerFormat::MONO: cfa = properties::draft::MONO; break; + case BayerFormat::NONE: + LOG(CameraSensor, Warning) + << "Sensor declares no CFA pattern. This is extremely unlikely " + << "and should be investigated as a likely error."; + cfa = properties::draft::MONO; + break; } properties_.set(properties::draft::ColorFilterArrangement, cfa); From patchwork Thu Jul 24 06:52:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Scally X-Patchwork-Id: 23921 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 371F0BDCC1 for ; Thu, 24 Jul 2025 06:53:28 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id AF9D069083; Thu, 24 Jul 2025 08:53:21 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="SJp61+2I"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4DBB969085 for ; Thu, 24 Jul 2025 08:53:15 +0200 (CEST) Received: from mail.ideasonboard.com (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net [86.13.91.161]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 71B9F17D1; Thu, 24 Jul 2025 08:52:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1753339956; bh=FxEinBqUtyr9FjPzWxTJO6efCDqgHoSx89eh6ejb5eQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SJp61+2ICAHxVWwEmdjSbL2pi/llIzdP2L5yE5DC0FELMEMVeEb09uApEwAG64kIs /6FtlrgRUqYtaxTnQdbHGJ0pCw5NkxCMOZI+ORsjhb39DLByGssEyc+YARRXvtD5gq jU/lqQHoaCLFyXjzu/TqB703dGf8NcEmqS7ji7N8= From: Daniel Scally To: libcamera-devel@lists.libcamera.org Cc: Daniel Scally Subject: [PATCH 04/10] libcamera: bayer_format: Add CRU packing to BayerFormat Date: Thu, 24 Jul 2025 07:52:50 +0100 Message-Id: <20250724065256.75175-5-dan.scally@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250724065256.75175-1-dan.scally@ideasonboard.com> References: <20250724065256.75175-1-dan.scally@ideasonboard.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 an entry to the BayerFormat::Packing enum to denote pixel formats encoding bayer data and packed following the Renesas RZ/G2L CRU style. Signed-off-by: Daniel Scally --- include/libcamera/internal/bayer_format.h | 1 + src/libcamera/bayer_format.cpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/include/libcamera/internal/bayer_format.h b/include/libcamera/internal/bayer_format.h index 9b6b5b58..4606a691 100644 --- a/include/libcamera/internal/bayer_format.h +++ b/include/libcamera/internal/bayer_format.h @@ -37,6 +37,7 @@ public: IPU3 = 2, PISP1 = 3, PISP2 = 4, + CRU = 5, }; constexpr BayerFormat() diff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp index 89fe10ed..686a5c1e 100644 --- a/src/libcamera/bayer_format.cpp +++ b/src/libcamera/bayer_format.cpp @@ -68,6 +68,8 @@ namespace libcamera { * \brief Format uses PISP mode 1 compression * \var BayerFormat::Packing::PISP2 * \brief Format uses PISP mode 2 compression + * \var BayerFormat::Packing::CRU + * \brief Format uses Renesas RZ/G2L CRU style packing */ namespace { From patchwork Thu Jul 24 06:52:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Scally X-Patchwork-Id: 23922 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 548EFC3323 for ; Thu, 24 Jul 2025 06:53:29 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E73026908F; Thu, 24 Jul 2025 08:53:22 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="J+pouaeY"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 93A0069087 for ; Thu, 24 Jul 2025 08:53:15 +0200 (CEST) Received: from mail.ideasonboard.com (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net [86.13.91.161]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B0BD27F0; Thu, 24 Jul 2025 08:52:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1753339956; bh=aMsaAqBnOPDY+ZSVEHSSg3iL97hs5oE6dyujuZElAPc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J+pouaeYTZybl/sAYtwwMijBney+2y1K4z7VjFC2D2tofIyAMnDisZH38dPJiYb9B cMfDyyf7s+7vz+/j0wRfP63XuWeC3r3CuNQ34Af61zQxBA1PVb9DahEhKMclr829G4 VuDkxvcE/j3ueO4448slta9/GB4OOQVoByO1AlwQ= From: Daniel Scally To: libcamera-devel@lists.libcamera.org Cc: Daniel Scally Subject: [PATCH 05/10] libcamera: formats: Add CRU-packed RAWnn libcamera formats Date: Thu, 24 Jul 2025 07:52:51 +0100 Message-Id: <20250724065256.75175-6-dan.scally@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250724065256.75175-1-dan.scally@ideasonboard.com> References: <20250724065256.75175-1-dan.scally@ideasonboard.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 libcamera formats for the CRU-packed, bayer order agnostic CRU pixel formats that map to the V4L2 Pixel Formats in the kernel header. Signed-off-by: Daniel Scally --- src/libcamera/formats.cpp | 30 ++++++++++++++++++++++++++++++ src/libcamera/formats.yaml | 13 +++++++++++++ 2 files changed, 43 insertions(+) diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp index bfcdfc08..8f10d1ec 100644 --- a/src/libcamera/formats.cpp +++ b/src/libcamera/formats.cpp @@ -969,6 +969,36 @@ const std::map pixelFormatInfo{ .pixelsPerGroup = 2, .planes = {{ { 2, 1 }, { 0, 0 }, { 0, 0 } }}, } }, + { formats::RAW10_CRU, { + .name = "RAW10_CRU", + .format = formats::RAW10_CRU, + .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_RAW_CRU10), }, + .bitsPerPixel = 10, + .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .packed = true, + .pixelsPerGroup = 6, + .planes = {{ { 8, 1 }, { 0, 0 }, { 0, 0 } }}, + } }, + { formats::RAW12_CRU, { + .name = "RAW12_CRU", + .format = formats::RAW12_CRU, + .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_RAW_CRU12), }, + .bitsPerPixel = 12, + .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .packed = true, + .pixelsPerGroup = 5, + .planes = {{ { 8, 1 }, { 0, 0 }, { 0, 0 } }}, + } }, + { formats::RAW14_CRU, { + .name = "RAW14_CRU", + .format = formats::RAW14_CRU, + .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_RAW_CRU14), }, + .bitsPerPixel = 14, + .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .packed = true, + .pixelsPerGroup = 4, + .planes = {{ { 8, 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..47188fc8 100644 --- a/src/libcamera/formats.yaml +++ b/src/libcamera/formats.yaml @@ -209,4 +209,17 @@ formats: - MONO_PISP_COMP1: fourcc: DRM_FORMAT_R16 mod: PISP_FORMAT_MOD_COMPRESS_MODE1 + + - RAW10_CRU: + fourcc: DRM_FORMAT_RAW10 + mod: RENESAS_CRU_FORMAT_MOD_PACKED + - RAW12_CRU: + fourcc: DRM_FORMAT_RAW12 + mod: RENESAS_CRU_FORMAT_MOD_PACKED + - RAW14_CRU: + fourcc: DRM_FORMAT_RAW14 + mod: RENESAS_CRU_FORMAT_MOD_PACKED + - RAW20_CRU: + fourcc: DRM_FORMAT_RAW20 + mod: RENESAS_CRU_FORMAT_MOD_PACKED ... From patchwork Thu Jul 24 06:52:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Scally X-Patchwork-Id: 23923 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 AC258BDCC1 for ; Thu, 24 Jul 2025 06:53:30 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A42DB6909C; Thu, 24 Jul 2025 08:53:24 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="WuLcDOrD"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CFB1E69088 for ; Thu, 24 Jul 2025 08:53:15 +0200 (CEST) Received: from mail.ideasonboard.com (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net [86.13.91.161]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id F00D217D1; Thu, 24 Jul 2025 08:52:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1753339957; bh=4n3jYle+CmvphkdgQmtu+x69MjerzLLzmnADNVwO6iU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WuLcDOrDbfdbzlzvELiDLsU9GdG1fEKoBn5mIXROU1UbRCuf1jZEVbcdFD/eM1zTm CcNBLRaSfcG7vzE29p/Ml9i2DXrdbKW4+1/+8hVtxGG/JVbnOa/csHl7WyvBnAkzUU i4JZ8ucu26UrwTL6VDDQxuw01TKN5fXFtxy853tU= From: Daniel Scally To: libcamera-devel@lists.libcamera.org Cc: Daniel Scally Subject: [PATCH 06/10] libcamera: bayer_format: Add entries for the CRU packed RAWnn formats Date: Thu, 24 Jul 2025 07:52:52 +0100 Message-Id: <20250724065256.75175-7-dan.scally@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250724065256.75175-1-dan.scally@ideasonboard.com> References: <20250724065256.75175-1-dan.scally@ideasonboard.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 entries to bayer_format.pp describing the CRU packed, bayer order agnostic formats. Signed-off-by: Daniel Scally --- src/libcamera/bayer_format.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp index 686a5c1e..1e016a6a 100644 --- a/src/libcamera/bayer_format.cpp +++ b/src/libcamera/bayer_format.cpp @@ -133,6 +133,8 @@ const std::map bayerToFormat{ { formats::SGRBG10_IPU3, V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SGRBG10) } }, { { BayerFormat::RGGB, 10, BayerFormat::Packing::IPU3 }, { formats::SRGGB10_IPU3, V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SRGGB10) } }, + { { BayerFormat::NONE, 10, BayerFormat::Packing::CRU }, + { formats::RAW10_CRU, V4L2PixelFormat(V4L2_PIX_FMT_RAW_CRU10) } }, { { BayerFormat::BGGR, 12, BayerFormat::Packing::None }, { formats::SBGGR12, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR12) } }, { { BayerFormat::GBRG, 12, BayerFormat::Packing::None }, @@ -149,6 +151,8 @@ const std::map bayerToFormat{ { formats::SGRBG12_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG12P) } }, { { BayerFormat::RGGB, 12, BayerFormat::Packing::CSI2 }, { formats::SRGGB12_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12P) } }, + { { BayerFormat::NONE, 12, BayerFormat::Packing::CRU }, + { formats::RAW12_CRU, V4L2PixelFormat(V4L2_PIX_FMT_RAW_CRU12) } }, { { BayerFormat::BGGR, 14, BayerFormat::Packing::None }, { formats::SBGGR14, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR14) } }, { { BayerFormat::GBRG, 14, BayerFormat::Packing::None }, @@ -165,6 +169,8 @@ const std::map bayerToFormat{ { formats::SGRBG14_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG14P) } }, { { BayerFormat::RGGB, 14, BayerFormat::Packing::CSI2 }, { formats::SRGGB14_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB14P) } }, + { { BayerFormat::NONE, 14, BayerFormat::Packing::CRU }, + { formats::RAW14_CRU, V4L2PixelFormat(V4L2_PIX_FMT_RAW_CRU14) } }, { { BayerFormat::BGGR, 16, BayerFormat::Packing::None }, { formats::SBGGR16, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR16) } }, { { BayerFormat::GBRG, 16, BayerFormat::Packing::None }, @@ -195,6 +201,8 @@ const std::map bayerToFormat{ { formats::R16, V4L2PixelFormat(V4L2_PIX_FMT_Y16) } }, { { BayerFormat::MONO, 16, BayerFormat::Packing::PISP1 }, { formats::MONO_PISP_COMP1, V4L2PixelFormat(V4L2_PIX_FMT_PISP_COMP1_MONO) } }, + { { BayerFormat::NONE, 20, BayerFormat::Packing::CRU }, + { formats::RAW20_CRU, V4L2PixelFormat(V4L2_PIX_FMT_RAW_CRU20) } }, }; const std::unordered_map mbusCodeToBayer{ From patchwork Thu Jul 24 06:52:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Scally X-Patchwork-Id: 23924 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 69A79C332A for ; Thu, 24 Jul 2025 06:53:31 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 29AB36909D; Thu, 24 Jul 2025 08:53:26 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="NHFC3GuR"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1BE1F69089 for ; Thu, 24 Jul 2025 08:53:16 +0200 (CEST) Received: from mail.ideasonboard.com (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net [86.13.91.161]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 38EF87F0; Thu, 24 Jul 2025 08:52:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1753339957; bh=TUmc1/BaIxN30HqfOBSAZM2aYtDWn3rqfaw+hbKqZl8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NHFC3GuRz81lyLHjeX+VmsMVmfwBkFrHxJKNAYorho1ziU1017Ra0QYsCXPMyFoIx r9vumg5ECZY7AAT+m+WvD6OL6lXHUxru/ENUmJZ08hAFUIBrp4EO2pZ6HWDHoFBNfE CwE9PERZTcVVZy4lPrfwys7QvGoOaWf5L5d9Aj9s= From: Daniel Scally To: libcamera-devel@lists.libcamera.org Cc: Daniel Scally Subject: [PATCH 07/10] libcamera: mali-c55: Add RZG2LCRU class Date: Thu, 24 Jul 2025 07:52:53 +0100 Message-Id: <20250724065256.75175-8-dan.scally@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250724065256.75175-1-dan.scally@ideasonboard.com> References: <20250724065256.75175-1-dan.scally@ideasonboard.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 a class allowing us to control the RZ/G2L Camera Receiver Unit which is found on the KakiP board. This will allow us to capture buffers from the sensor, which in this configuration is not directly connected to the ISP. As this is not a guaranteed component of a video pipeline involving the Mali-C55 ISP we would ideally use modular pipelines to fill this role, but for now this will let us enable capture on the KakiP. Signed-off-by: Daniel Scally --- .clang-format | 1 - src/libcamera/pipeline/mali-c55/meson.build | 3 +- src/libcamera/pipeline/mali-c55/rzg2l-cru.cpp | 236 ++++++++++++++++++ src/libcamera/pipeline/mali-c55/rzg2l-cru.h | 66 +++++ 4 files changed, 304 insertions(+), 2 deletions(-) create mode 100644 src/libcamera/pipeline/mali-c55/rzg2l-cru.cpp create mode 100644 src/libcamera/pipeline/mali-c55/rzg2l-cru.h diff --git a/.clang-format b/.clang-format index 7fc30f61..c6b3dd24 100644 --- a/.clang-format +++ b/.clang-format @@ -75,7 +75,6 @@ IncludeCategories: Priority: 9 # Qt includes (match before C++ standard library) - Regex: '' - CaseSensitive: true Priority: 9 # Headers in <> with an extension. (+system libraries) - Regex: '<([A-Za-z0-9\-_])+\.h>' diff --git a/src/libcamera/pipeline/mali-c55/meson.build b/src/libcamera/pipeline/mali-c55/meson.build index eba8e5a3..4e768242 100644 --- a/src/libcamera/pipeline/mali-c55/meson.build +++ b/src/libcamera/pipeline/mali-c55/meson.build @@ -1,5 +1,6 @@ # SPDX-License-Identifier: CC0-1.0 libcamera_internal_sources += files([ - 'mali-c55.cpp' + 'mali-c55.cpp', + 'rzg2l-cru.cpp', ]) diff --git a/src/libcamera/pipeline/mali-c55/rzg2l-cru.cpp b/src/libcamera/pipeline/mali-c55/rzg2l-cru.cpp new file mode 100644 index 00000000..6b4e7b91 --- /dev/null +++ b/src/libcamera/pipeline/mali-c55/rzg2l-cru.cpp @@ -0,0 +1,236 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2025, Ideas on Board Oy + * + * Pipine handler element for the Renesas RZ/G2L Camera Receiver Unit + */ + +#include "rzg2l-cru.h" + +#include + +#include +#include + +#include +#include + +#include "libcamera/internal/bayer_format.h" +#include "libcamera/internal/camera_sensor.h" +#include "libcamera/internal/framebuffer.h" +#include "libcamera/internal/media_device.h" +#include "libcamera/internal/request.h" + +namespace libcamera { + +static const std::map bitDepthToFmt { + { 10, formats::RAW10_CRU }, + { 12, formats::RAW12_CRU }, + { 14, formats::RAW14_CRU }, +}; + +LOG_DEFINE_CATEGORY(RZG2LCRU) + +std::vector RZG2LCRU::sizes(unsigned int mbusCode) const +{ + std::vector sensorSizes = sensor_->sizes(mbusCode); + std::vector cruSizes = {}; + + for (auto size : sensorSizes) { + if (size > csi2Resolution_) + continue; + + cruSizes.push_back(size); + } + + return cruSizes; +} + +const Size RZG2LCRU::resolution() const +{ + return sensor_->resolution().boundedTo(csi2Resolution_); +} + +void RZG2LCRU::setSensorAndCSI2Pointers(std::shared_ptr sensor, + std::shared_ptr csi2) +{ + std::vector csi2Sizes; + + sensor_ = sensor; + csi2_ = csi2; + + V4L2Subdevice::Formats formats = csi2_->formats(0); + if (formats.empty()) + return; + + for (const auto &format : formats) { + const std::vector &ranges = format.second; + std::transform(ranges.begin(), ranges.end(), std::back_inserter(csi2Sizes), + [](const SizeRange &range) { return range.max; }); + } + + csi2Resolution_ = csi2Sizes.back(); +} + +FrameBuffer *RZG2LCRU::queueBuffer(Request *request) +{ + FrameBuffer *buffer; + + if (availableBuffers_.empty()) { + LOG(RZG2LCRU, Debug) << "CRU buffer underrun"; + return nullptr; + } + + buffer = availableBuffers_.front(); + + int ret = output_->queueBuffer(buffer); + if (ret) { + LOG(RZG2LCRU, Error) << "Failed to queue buffer to CRU"; + return nullptr; + } + + availableBuffers_.pop(); + buffer->_d()->setRequest(request); + + return buffer; +} + +void RZG2LCRU::cruReturnBuffer(FrameBuffer *buffer) +{ + for (const std::unique_ptr &buf : buffers_) { + if (buf.get() == buffer) { + availableBuffers_.push(buffer); + break; + } + } +} + +int RZG2LCRU::start() +{ + int ret = output_->exportBuffers(kBufferCount, &buffers_); + if (ret < 0) + return ret; + + ret = output_->importBuffers(kBufferCount); + if (ret) + return ret; + + for (std::unique_ptr &buffer : buffers_) + availableBuffers_.push(buffer.get()); + + ret = output_->streamOn(); + if (ret) { + freeBuffers(); + return ret; + } + + return 0; +} + +int RZG2LCRU::stop() +{ + int ret; + + csi2_->setFrameStartEnabled(false); + + ret = output_->streamOff(); + + freeBuffers(); + + return ret; +} + +void RZG2LCRU::freeBuffers() +{ + availableBuffers_ = {}; + buffers_.clear(); + + if (output_->releaseBuffers()) + LOG(RZG2LCRU, Error) << "Failed to release CRU buffers"; +} + +int RZG2LCRU::configure(V4L2SubdeviceFormat *subdevFormat, V4L2DeviceFormat *inputFormat) +{ + int ret; + + /* + * The sensor and CSI-2 rx have already had their format set by the + * CameraData class...all we need to do is propagate it to the remaining + * elements of the CRU graph - the CRU subdevice and output video device + */ + + ret = cru_->setFormat(0, subdevFormat); + if (ret) + return ret; + + ret = cru_->getFormat(1, subdevFormat); + if (ret) + return ret; + + /* + * The capture device needs to be set with a format that can be produced + * from the mbus code of the subdevFormat. The CRU and IVC use bayer + * order agnostic pixel formats, so all we need to do is find the right + * bitdepth and select the appropriate format. + */ + BayerFormat bayerFormat = BayerFormat::fromMbusCode(subdevFormat->code); + if (!bayerFormat.isValid()) + return -EINVAL; + + PixelFormat pixelFormat = bitDepthToFmt.at(bayerFormat.bitDepth); + + V4L2DeviceFormat captureFormat; + captureFormat.fourcc = output_->toV4L2PixelFormat(pixelFormat); + captureFormat.size = subdevFormat->size; + + ret = output_->setFormat(&captureFormat); + if (ret) + return ret; + + /* + * We return the format that we set against the output device, as the + * same format will also need to be set against the Input Video Control + * Block device. + */ + *inputFormat = captureFormat; + + return 0; +} + +int RZG2LCRU::init(const MediaDevice *media, MediaEntity **sensorEntity) +{ + int ret; + + MediaEntity *csi2Entity = media->getEntityByName(std::regex("csi-[0-9a-f]{8}.csi2")); + if (!csi2Entity) + return -ENODEV; + + const std::vector &pads = csi2Entity->pads(); + if (pads.empty()) + return -ENODEV; + + /* The receiver has a single sink pad at index 0 */ + MediaPad *sink = pads[0]; + const std::vector &links = sink->links(); + if (links.empty()) + return -ENODEV; + + MediaLink *link = links[0]; + *sensorEntity = link->source()->entity(); + + /* + * We don't handle the sensor and csi-2 rx subdevice here, as the + * CameraData class does that already. + * + * \todo lose this horrible hack by making modular pipelines. + */ + cru_ = V4L2Subdevice::fromEntityName(media, std::regex("cru-ip-[0-9a-f]{8}.cru[0-9]")); + ret = cru_->open(); + if (ret) + return ret; + + output_ = V4L2VideoDevice::fromEntityName(media, "CRU output"); + return output_->open(); +} + +} /* namespace libcamera */ diff --git a/src/libcamera/pipeline/mali-c55/rzg2l-cru.h b/src/libcamera/pipeline/mali-c55/rzg2l-cru.h new file mode 100644 index 00000000..5beb3a6e --- /dev/null +++ b/src/libcamera/pipeline/mali-c55/rzg2l-cru.h @@ -0,0 +1,66 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2025, Ideas on Board Oy + * + * Pipine handler element for the Renesas RZ/G2L Camera Receiver Unit + */ + +#pragma once + +#include +#include + +#include + +#include "libcamera/internal/v4l2_subdevice.h" +#include "libcamera/internal/v4l2_videodevice.h" + +#include + +namespace libcamera { + +class CameraSensor; +class FrameBuffer; +class MediaDevice; +class PixelFormat; +class Request; +class Size; +class SizeRange; +struct StreamConfiguration; +enum class Transform; + +class RZG2LCRU +{ +public: + static constexpr unsigned int kBufferCount = 4; + + RZG2LCRU() = default; + + std::vector sizes(unsigned int mbusCode) const; + int init(const MediaDevice *media, MediaEntity **sensorEntity); + const Size resolution() const; + void setSensorAndCSI2Pointers(std::shared_ptr sensor, + std::shared_ptr csi2); + int configure(V4L2SubdeviceFormat *subdevFormat, V4L2DeviceFormat *inputFormat); + FrameBuffer *queueBuffer(Request *request); + void cruReturnBuffer(FrameBuffer *buffer); + V4L2VideoDevice *output() { return output_.get(); } + int start(); + int stop(); +private: + void freeBuffers(); + + void cruBufferReady(FrameBuffer *buffer); + + std::shared_ptr sensor_; + std::shared_ptr csi2_; + std::unique_ptr cru_; + std::unique_ptr output_; + + std::vector> buffers_; + std::queue availableBuffers_; + + Size csi2Resolution_; +}; + +} /* namespace libcamera */ From patchwork Thu Jul 24 06:52:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Scally X-Patchwork-Id: 23925 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 D9C66C332B for ; Thu, 24 Jul 2025 06:53:31 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4511569097; Thu, 24 Jul 2025 08:53:28 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="acxyN25+"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 567F16907F for ; Thu, 24 Jul 2025 08:53:16 +0200 (CEST) Received: from mail.ideasonboard.com (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net [86.13.91.161]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 7882817D1; Thu, 24 Jul 2025 08:52:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1753339957; bh=XaSrcH/b1VvHuoduvqs+Vs1M5PeiCb0C1Nftnfe0PQ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=acxyN25+OmjdQwNmR45RE6uYMBR+pJFbqvOBMY5oYEHfJS1N7AuhAgAsJaZSRrTOP wY3IDNvyXY47P/eZL6ZRc6jRSJSDQiIZeBMDuzb+TsJNymE49JniN6I8yVGtqLCFP9 rxRpGgiCbcVlSQQzatt5PcH6zqMVop94jAnGoLjM= From: Daniel Scally To: libcamera-devel@lists.libcamera.org Cc: Daniel Scally Subject: [PATCH 08/10] libcamera: mali-c55: Move entity parameter from constructor to ::init() Date: Thu, 24 Jul 2025 07:52:54 +0100 Message-Id: <20250724065256.75175-9-dan.scally@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250724065256.75175-1-dan.scally@ideasonboard.com> References: <20250724065256.75175-1-dan.scally@ideasonboard.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" The MaliC55CameraData class takes a MediaEntity in its constructor. When we support the memory input mode we won't have that when we want to construct the class, so move the parameter to the init() function instead. Signed-off-by: Daniel Scally --- src/libcamera/pipeline/mali-c55/mali-c55.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/libcamera/pipeline/mali-c55/mali-c55.cpp b/src/libcamera/pipeline/mali-c55/mali-c55.cpp index 25540ba1..5944823d 100644 --- a/src/libcamera/pipeline/mali-c55/mali-c55.cpp +++ b/src/libcamera/pipeline/mali-c55/mali-c55.cpp @@ -92,12 +92,12 @@ struct MaliC55FrameInfo { class MaliC55CameraData : public Camera::Private { public: - MaliC55CameraData(PipelineHandler *pipe, MediaEntity *entity) - : Camera::Private(pipe), entity_(entity) + MaliC55CameraData(PipelineHandler *pipe) + : Camera::Private(pipe) { } - int init(); + int init(MediaEntity *entity); int loadIPA(); /* Deflect these functionalities to either TPG or CameraSensor. */ @@ -134,10 +134,12 @@ private: Size tpgResolution_; }; -int MaliC55CameraData::init() +int MaliC55CameraData::init(MediaEntity *entity) { int ret; + entity_ = entity; + sd_ = std::make_unique(entity_); ret = sd_->open(); if (ret) { @@ -1567,9 +1569,9 @@ bool PipelineHandlerMaliC55::registerTPGCamera(MediaLink *link) } std::unique_ptr data = - std::make_unique(this, link->source()->entity()); + std::make_unique(this); - if (data->init()) + if (data->init(link->source()->entity())) return false; return registerMaliCamera(std::move(data), name); @@ -1594,8 +1596,8 @@ bool PipelineHandlerMaliC55::registerSensorCamera(MediaLink *ispLink) continue; std::unique_ptr data = - std::make_unique(this, sensor); - if (data->init()) + std::make_unique(this); + if (data->init(sensor)) return false; data->properties_ = data->sensor_->properties(); From patchwork Thu Jul 24 06:52:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Scally X-Patchwork-Id: 23926 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 5E613C3323 for ; Thu, 24 Jul 2025 06:53:32 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 32B056909F; Thu, 24 Jul 2025 08:53:29 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="GdueKGGM"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 929B269086 for ; Thu, 24 Jul 2025 08:53:16 +0200 (CEST) Received: from mail.ideasonboard.com (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net [86.13.91.161]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B86ED7F0; Thu, 24 Jul 2025 08:52:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1753339957; bh=Py0ZdPv1jQAnOc+V9n/Y+D6Y4uSbbR6I3rIxip3/9EY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GdueKGGMYpnrQ/kj18TpZNM9Hotb+3wqu10YX/31JQj3WanSS2r0WOTOFvgkR6tl0 WsiwkKn1Iv4QK6sXMbq50BFeVLAPlYpVEyeogllYrNMKF5+Mo3i/KjzkeM12JjQUTD qiz8lE9cvllR02RCLCqxIJMHC/NcVNfcXN17/t/U= From: Daniel Scally To: libcamera-devel@lists.libcamera.org Cc: Daniel Scally Subject: [PATCH 09/10] libcamera: mali-c55: Use the RZG2LCRU class Date: Thu, 24 Jul 2025 07:52:55 +0100 Message-Id: <20250724065256.75175-10-dan.scally@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250724065256.75175-1-dan.scally@ideasonboard.com> References: <20250724065256.75175-1-dan.scally@ideasonboard.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" Use the RZG2LCRU class to add the ability to the mali-c55 pipeline handler to read frames from memory and process them. The data flow is different to an inline configuration; instead of filling the params buffer immediately on queueRequestDevice(), queued requests are parked in a pending queue until a buffer from the CRU device is available to be queued to that device. Once that buffer is filled with image data by the CRU the parameter buffer is filled and the image buffer queued to the ISP. Signed-off-by: Daniel Scally --- src/libcamera/pipeline/mali-c55/mali-c55.cpp | 208 ++++++++++++++++++- 1 file changed, 201 insertions(+), 7 deletions(-) diff --git a/src/libcamera/pipeline/mali-c55/mali-c55.cpp b/src/libcamera/pipeline/mali-c55/mali-c55.cpp index 5944823d..2a396950 100644 --- a/src/libcamera/pipeline/mali-c55/mali-c55.cpp +++ b/src/libcamera/pipeline/mali-c55/mali-c55.cpp @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -42,6 +43,8 @@ #include "libcamera/internal/v4l2_subdevice.h" #include "libcamera/internal/v4l2_videodevice.h" +#include "rzg2l-cru.h" + namespace { bool isFormatRaw(const libcamera::PixelFormat &pixFmt) @@ -84,6 +87,7 @@ struct MaliC55FrameInfo { FrameBuffer *paramBuffer; FrameBuffer *statBuffer; + FrameBuffer *rawBuffer; bool paramsDone; bool statsDone; @@ -112,13 +116,14 @@ public: PixelFormat adjustRawFormat(const PixelFormat &pixFmt) const; Size adjustRawSizes(const PixelFormat &pixFmt, const Size &rawSize) const; - std::unique_ptr sensor_; + std::shared_ptr sensor_; MediaEntity *entity_; - std::unique_ptr csi_; + std::shared_ptr csi_; std::unique_ptr sd_; Stream frStream_; Stream dsStream_; + std::unique_ptr cru_; std::unique_ptr ipa_; std::vector ipaStatBuffers_; @@ -199,6 +204,9 @@ void MaliC55CameraData::setSensorControls(const ControlList &sensorControls) const std::vector MaliC55CameraData::sizes(unsigned int mbusCode) const { + if (cru_) + return cru_->sizes(mbusCode); + if (sensor_) return sensor_->sizes(mbusCode); @@ -222,6 +230,9 @@ const std::vector MaliC55CameraData::sizes(unsigned int mbusCode) const const Size MaliC55CameraData::resolution() const { + if (cru_) + return cru_->resolution(); + if (sensor_) return sensor_->resolution(); @@ -615,11 +626,14 @@ public: int start(Camera *camera, const ControlList *controls) override; void stopDevice(Camera *camera) override; + void queuePendingRequests(); + void cancelPendingRequests(); int queueRequestDevice(Camera *camera, Request *request) override; void imageBufferReady(FrameBuffer *buffer); void paramsBufferReady(FrameBuffer *buffer); void statsBufferReady(FrameBuffer *buffer); + void cruBufferReady(FrameBuffer *buffer); void paramsComputed(unsigned int requestId, uint32_t bytesused); void statsProcessed(unsigned int requestId, const ControlList &metadata); @@ -683,11 +697,15 @@ private: const std::string &name); bool registerTPGCamera(MediaLink *link); bool registerSensorCamera(MediaLink *link); + bool registerMemoryInputCamera(); MediaDevice *media_; + MediaDevice *cruMedia_; std::unique_ptr isp_; std::unique_ptr stats_; std::unique_ptr params_; + std::unique_ptr ivc_; + std::unique_ptr input_; std::vector> statsBuffers_; std::queue availableStatsBuffers_; @@ -697,6 +715,11 @@ private: std::map frameInfoMap_; + /* Requests for which no buffer has been queued to the CRU device yet. */ + std::queue pendingRequests_; + /* Requests queued to the CRU device but not yet processed by the ISP. */ + std::queue processingRequests_; + std::array pipes_; bool dsFitted_; @@ -929,9 +952,16 @@ int PipelineHandlerMaliC55::configure(Camera *camera, /* Link the graph depending if we are operating the TPG or a sensor. */ MaliC55CameraData *data = cameraData(camera); - if (data->csi_) { + if (data->cru_) { + const MediaEntity *ivcEntity = ivc_->entity(); + ret = ivcEntity->getPadByIndex(1)->links()[0]->setEnabled(true); + if (ret) + return ret; + } else if (data->csi_) { const MediaEntity *csiEntity = data->csi_->entity(); ret = csiEntity->getPadByIndex(1)->links()[0]->setEnabled(true); + if (ret) + return ret; } else { ret = data->entity_->getPadByIndex(0)->links()[0]->setEnabled(true); } @@ -952,14 +982,43 @@ int PipelineHandlerMaliC55::configure(Camera *camera, return ret; } + /* + * This could be a CSI receiver directly connected to the ISP, or else + * one in the CRU's graph. + */ if (data->csi_) { ret = data->csi_->setFormat(0, &subdevFormat); if (ret) return ret; - ret = data->csi_->getFormat(1, &subdevFormat); - if (ret) - return ret; + if (data->cru_) { + V4L2DeviceFormat inputFormat; + + ret = data->cru_->configure(&subdevFormat, &inputFormat); + if (ret) + return ret; + + /* + * The IVC video device needs to be configured with the same + * format as the CRU. + */ + + ret = input_->setFormat(&inputFormat); + if (ret) + return ret; + + ret = ivc_->setFormat(0, &subdevFormat); + if (ret) + return ret; + + ret = ivc_->getFormat(1, &subdevFormat); + if (ret) + return ret; + } else { + ret = data->csi_->getFormat(1, &subdevFormat); + if (ret) + return ret; + } } V4L2DeviceFormat statsFormat; @@ -1120,6 +1179,11 @@ void PipelineHandlerMaliC55::freeBuffers(Camera *camera) if (params_->releaseBuffers()) LOG(MaliC55, Error) << "Failed to release params buffers"; + if (data->cru_) { + if (input_->releaseBuffers()) + LOG(MaliC55, Error) << "Failed to release input buffers"; + } + return; } @@ -1135,6 +1199,12 @@ int PipelineHandlerMaliC55::allocateBuffers(Camera *camera) data->dsStream_.configuration().bufferCount, }); + if (input_) { + ret = input_->importBuffers(RZG2LCRU::kBufferCount); + if (ret < 0) + return ret; + } + ret = stats_->allocateBuffers(bufferCount, &statsBuffers_); if (ret < 0) return ret; @@ -1174,6 +1244,24 @@ int PipelineHandlerMaliC55::start(Camera *camera, [[maybe_unused]] const Control if (ret) return ret; + if (data->cru_) { + ret = data->cru_->start(); + if (ret) { + LOG(MaliC55, Error) + << "Failed to start CRU " << camera->id(); + freeBuffers(camera); + return ret; + } + + ret = input_->streamOn(); + if (ret) { + LOG(MaliC55, Error) + << "Failed to start IVC" << camera->id(); + freeBuffers(camera); + return ret; + } + } + if (data->ipa_) { ret = data->ipa_->start(); if (ret) { @@ -1263,6 +1351,12 @@ void PipelineHandlerMaliC55::stopDevice(Camera *camera) pipe.cap->releaseBuffers(); } + if (data->cru_) { + cancelPendingRequests(); + input_->streamOff(); + data->cru_->stop(); + } + stats_->streamOff(); params_->streamOff(); if (data->ipa_) @@ -1366,10 +1460,80 @@ void PipelineHandlerMaliC55::applyScalerCrop(Camera *camera, } } +void PipelineHandlerMaliC55::cancelPendingRequests() +{ + processingRequests_ = {}; + + while (!pendingRequests_.empty()) { + Request *request = pendingRequests_.front(); + + for (auto it : request->buffers()) { + FrameBuffer *buffer = it.second; + buffer->_d()->cancel(); + completeBuffer(request, buffer); + } + + completeRequest(request); + pendingRequests_.pop(); + } +} + +void PipelineHandlerMaliC55::queuePendingRequests() +{ + while (!pendingRequests_.empty()) { + Request *request = pendingRequests_.front(); + + if (availableStatsBuffers_.empty()) { + LOG(MaliC55, Error) << "Stats buffer underrun"; + return; + } + + if (availableParamsBuffers_.empty()) { + LOG(MaliC55, Error) << "Params buffer underrun"; + return; + } + + MaliC55FrameInfo frameInfo; + frameInfo.request = request; + + MaliC55CameraData *data = cameraData(request->_d()->camera()); + frameInfo.rawBuffer = data->cru_->queueBuffer(request); + if (!frameInfo.rawBuffer) + return; + + frameInfo.statBuffer = availableStatsBuffers_.front(); + availableStatsBuffers_.pop(); + frameInfo.paramBuffer = availableParamsBuffers_.front(); + availableParamsBuffers_.pop(); + + frameInfo.paramsDone = false; + frameInfo.statsDone = false; + + frameInfoMap_[request->sequence()] = frameInfo; + + data->ipa_->queueRequest(request->sequence(), request->controls()); + + pendingRequests_.pop(); + processingRequests_.push(request); + } +} + int PipelineHandlerMaliC55::queueRequestDevice(Camera *camera, Request *request) { MaliC55CameraData *data = cameraData(camera); + /* + * If we're in memory input mode, we need to pop the requests onto the + * pending list until a CRU buffer is ready...otherwise we can just do + * everything immediately. + */ + if (data->cru_) { + pendingRequests_.push(request); + queuePendingRequests(); + + return 0; + } + /* Do not run the IPA if the TPG is in use. */ if (!data->ipa_) { MaliC55FrameInfo frameInfo; @@ -1434,7 +1598,8 @@ MaliC55FrameInfo *PipelineHandlerMaliC55::findFrameInfo(FrameBuffer *buffer) { for (auto &[sequence, info] : frameInfoMap_) { if (info.paramBuffer == buffer || - info.statBuffer == buffer) + info.statBuffer == buffer || + info.rawBuffer == buffer) return &info; } @@ -1496,6 +1661,32 @@ void PipelineHandlerMaliC55::statsBufferReady(FrameBuffer *buffer) sensorControls); } +void PipelineHandlerMaliC55::cruBufferReady(FrameBuffer *buffer) +{ + MaliC55FrameInfo *info = findFrameInfo(buffer); + Request *request = info->request; + ASSERT(info); + + if (buffer->metadata().status == FrameMetadata::FrameCancelled) { + for (auto it : request->buffers()) { + FrameBuffer *b = it.second; + b->_d()->cancel(); + completeBuffer(request, b); + } + + frameInfoMap_.erase(request->sequence()); + completeRequest(request); + return; + } + + request->metadata().set(controls::SensorTimestamp, + buffer->metadata().timestamp); + + /* Ought we do something with the sensor's controls here...? */ + MaliC55CameraData *data = cameraData(request->_d()->camera()); + data->ipa_->fillParams(request->sequence(), info->paramBuffer->cookie()); +} + void PipelineHandlerMaliC55::paramsComputed(unsigned int requestId, uint32_t bytesused) { MaliC55FrameInfo &frameInfo = frameInfoMap_[requestId]; @@ -1516,6 +1707,9 @@ void PipelineHandlerMaliC55::paramsComputed(unsigned int requestId, uint32_t byt pipe->cap->queueBuffer(buffer); } + + if (data->cru_) + input_->queueBuffer(frameInfo.rawBuffer); } void PipelineHandlerMaliC55::statsProcessed(unsigned int requestId, From patchwork Thu Jul 24 06:52:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Scally X-Patchwork-Id: 23927 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 B088EC332C for ; Thu, 24 Jul 2025 06:53:32 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 962F06908C; Thu, 24 Jul 2025 08:53:30 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="afxSiS23"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D56E669085 for ; Thu, 24 Jul 2025 08:53:16 +0200 (CEST) Received: from mail.ideasonboard.com (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net [86.13.91.161]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 0081017D1; Thu, 24 Jul 2025 08:52:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1753339958; bh=WWatLoSknEiLUU87NIzW3oSNdF86COOhJbGRZ4QS3ss=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=afxSiS23b5MktkkN7maMhWAPE22cuHD7D/CmVCJjcLFEkPjy+8UT2F2wpIJYpD9EX zYes41mEqzwhX77FEkOjJaHHh2yroG7DcQScdJeVkRnYZ1znNbR3thY5vAyXADdKsa 6JyRgCcqy6SpIVUq81+0+/g//p26qA9ZWPGmgW00= From: Daniel Scally To: libcamera-devel@lists.libcamera.org Cc: Daniel Scally Subject: [PATCH 10/10] libcamera: mali-c55: Match for memory input media entities Date: Thu, 24 Jul 2025 07:52:56 +0100 Message-Id: <20250724065256.75175-11-dan.scally@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250724065256.75175-1-dan.scally@ideasonboard.com> References: <20250724065256.75175-1-dan.scally@ideasonboard.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" Updating the Pipeline Handler's match() function to search for the entities necessary for memory input mode and create a CameraData instance for that camera if one is found. Signed-off-by: Daniel Scally --- src/libcamera/pipeline/mali-c55/mali-c55.cpp | 100 ++++++++++++++++--- 1 file changed, 85 insertions(+), 15 deletions(-) diff --git a/src/libcamera/pipeline/mali-c55/mali-c55.cpp b/src/libcamera/pipeline/mali-c55/mali-c55.cpp index 2a396950..e2f31e77 100644 --- a/src/libcamera/pipeline/mali-c55/mali-c55.cpp +++ b/src/libcamera/pipeline/mali-c55/mali-c55.cpp @@ -1817,6 +1817,45 @@ bool PipelineHandlerMaliC55::registerSensorCamera(MediaLink *ispLink) return true; } +bool PipelineHandlerMaliC55::registerMemoryInputCamera() +{ + MediaEntity *sensorEntity; + int ret; + + std::unique_ptr data = std::make_unique(this); + + data->cru_ = std::make_unique(); + ret = data->cru_->init(cruMedia_, &sensorEntity); + if (ret) + return false; + + if (data->init(sensorEntity)) + return false; + + data->cru_->setSensorAndCSI2Pointers(data->sensor_, data->csi_); + + data->properties_ = data->sensor_->properties(); + + const CameraSensorProperties::SensorDelays &delays = data->sensor_->sensorDelays(); + std::unordered_map params = { + { V4L2_CID_ANALOGUE_GAIN, { delays.gainDelay, false } }, + { V4L2_CID_EXPOSURE, { delays.exposureDelay, false } }, + }; + + data->delayedCtrls_ = + std::make_unique(data->sensor_->device(), + params); + isp_->frameStart.connect(data->delayedCtrls_.get(), + &DelayedControls::applyControls); + data->cru_->output()->bufferReady.connect(this, &PipelineHandlerMaliC55::cruBufferReady); + input_->bufferReady.connect(data->cru_.get(), &RZG2LCRU::cruReturnBuffer); + + if (!registerMaliCamera(std::move(data), sensorEntity->name())) + return false; + + return true; +} + bool PipelineHandlerMaliC55::match(DeviceEnumerator *enumerator) { const MediaPad *ispSink; @@ -1826,14 +1865,14 @@ bool PipelineHandlerMaliC55::match(DeviceEnumerator *enumerator) * The TPG and the downscale pipe are both optional blocks and may not * be fitted. */ - DeviceMatch dm("mali-c55"); - dm.add("mali-c55 isp"); - dm.add("mali-c55 resizer fr"); - dm.add("mali-c55 fr"); - dm.add("mali-c55 3a stats"); - dm.add("mali-c55 3a params"); - - media_ = acquireMediaDevice(enumerator, dm); + DeviceMatch c55_dm("mali-c55"); + c55_dm.add("mali-c55 isp"); + c55_dm.add("mali-c55 resizer fr"); + c55_dm.add("mali-c55 fr"); + c55_dm.add("mali-c55 3a stats"); + c55_dm.add("mali-c55 3a params"); + + media_ = acquireMediaDevice(enumerator, c55_dm); if (!media_) return false; @@ -1893,6 +1932,22 @@ bool PipelineHandlerMaliC55::match(DeviceEnumerator *enumerator) stats_->bufferReady.connect(this, &PipelineHandlerMaliC55::statsBufferReady); params_->bufferReady.connect(this, &PipelineHandlerMaliC55::paramsBufferReady); + /* + * We also need to search for the rzg2l-cru CSI-2 receiver. If we find + * that then we need to work in memory input mode instead of the inline + * mode. The absence of this match is not necessarily a failure at this + * point...it depends on the media links that we investigate momentarily. + * + * This is a bit hacky, because there could be multiple of these media + * devices and we're just taking the first. We need modular pipelines to + * properly solve the issue. + */ + DeviceMatch cru_dm("rzg2l_cru"); + cru_dm.add(std::regex("csi-[0-9a-f]{8}.csi2")); + cru_dm.add(std::regex("cru-ip-[0-9a-f]{8}.cru[0-9]")); + cru_dm.add("CRU output"); + cruMedia_ = acquireMediaDevice(enumerator, cru_dm); + ispSink = isp_->entity()->getPadByIndex(0); if (!ispSink || ispSink->links().empty()) { LOG(MaliC55, Error) << "ISP sink pad error"; @@ -1907,12 +1962,13 @@ bool PipelineHandlerMaliC55::match(DeviceEnumerator *enumerator) * MEDIA_ENT_F_VID_IF_BRIDGE - A CSI-2 receiver * MEDIA_ENT_F_PROC_VIDEO_PIXEL_FORMATTER - An input device * - * The last one will be unsupported for now. The TPG is relatively easy, - * we just register a Camera for it. If we have a CSI-2 receiver we need - * to check its sink pad and register Cameras for anything connected to - * it (probably...there are some complex situations in which that might - * not be true but let's pretend they don't exist until we come across - * them) + * The TPG is relatively easy, we just register a Camera for it. If we + * have a CSI-2 receiver we need to check its sink pad and register + * Cameras for anything connected to it (probably...there are some + * complex situations in which that might not be true but let's pretend + * they don't exist until we come across them). If we have an input + * device then we need to acquire the V4L2 infrastructure for it and + * confirm that we found the rzg2l-cru media device too. */ bool registered; for (MediaLink *link : ispSink->links()) { @@ -1932,7 +1988,21 @@ bool PipelineHandlerMaliC55::match(DeviceEnumerator *enumerator) break; case MEDIA_ENT_F_PROC_VIDEO_PIXEL_FORMATTER: - LOG(MaliC55, Warning) << "Memory input not yet supported"; + if (!cruMedia_) + return false; + + ivc_ = V4L2Subdevice::fromEntityName(media_, "rzv2h ivc block"); + if (ivc_->open() < 0) + return false; + + input_ = V4L2VideoDevice::fromEntityName(media_, "rzv2h-ivc"); + if (input_->open() < 0) + return false; + + registered = registerMemoryInputCamera(); + if (!registered) + return registered; + break; default: LOG(MaliC55, Error) << "Unsupported entity function";