From patchwork Thu Feb 19 17:34:34 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frederic Laing X-Patchwork-Id: 26213 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 451CAC0DA4 for ; Thu, 19 Feb 2026 17:34:43 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A9C596225A; Thu, 19 Feb 2026 18:34:42 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=fredfunk.tech header.i=@fredfunk.tech header.b="mat30PXr"; dkim-atps=neutral Received: from mail-4397.protonmail.ch (mail-4397.protonmail.ch [185.70.43.97]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1118A620C9 for ; Thu, 19 Feb 2026 18:34:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fredfunk.tech; s=protonmail; t=1771522478; x=1771781678; bh=o9MtWsiLlSyjJuVdnJWhuV7uepbeppX3vMF270fPFpk=; h=Date:To:From:Cc:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=mat30PXrCigUJ8BYo+J+olR1MKFrgeOZibJXf3wAQvSt1EbLDkuxwMCSUdudc3PzS HeTlXhcavBwbKv2BB9QNNT2BIbA97l5pr1BcJDeBduiZVXGrnRhGoErqjtoh/l0LkX Fw6b2qEdcnMAnsmj7k8xwOOk4HmQws36gnFXZcaQNLe7rfX22gV0rlq5PkLKOC4vQi wxmtanLLEMS4mLKK2t7dfOE+cDEZ7Vvxi9x74CJHBtyLSwIFAWy7FPl1vZXUhjaJkU Y1quCT8PjMzhahbapz9G8zLhxiY+e989mMCmyPVBUk4rrnJ/XFckmRaWr2+T7G0Lc4 IoizNhNXCMDFg== Date: Thu, 19 Feb 2026 17:34:34 +0000 To: libcamera-devel@lists.libcamera.org From: Frederic Laing Cc: Frederic Laing Subject: [PATCH v2] gstreamer: Add CSI-2 packed Bayer format mappings Message-ID: <20260219173423.1028522-1-dev@fredfunk.tech> Feedback-ID: 182542373:user:proton X-Pm-Message-ID: ad1820bcd37e3a4ca8247e7956dfc8dc508f0899 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 SRGGB/SBGGR/SGBRG/SGRBG 10/12/14-bit CSI-2 packed (CSI2P) format entries to both format_map and bayer_map in gstlibcamera-utils.cpp. Many camera sensors (e.g., IMX371, IMX376) natively output CSI-2 packed Bayer formats like SRGGB10_CSI2P. Without mappings for these formats, GStreamer's libcamerasrc cannot negotiate raw Bayer output (video/x-bayer caps) when the sensor only supports CSI2P variants, causing caps negotiation to fail with empty caps. This is particularly important for dual-stream (ViewFinder + Raw) capture where the Raw stream needs to use the sensor's native CSI2P format. The Software ISP processes only the ViewFinder stream while the Raw stream bypasses it entirely, but GStreamer needs to be able to represent the Raw stream's format in caps. The CSI2P formats are mapped to distinct GStreamer Bayer format names using a "p" suffix (e.g., SRGGB10_CSI2P -> "rggb10p") to distinguish them from their unpacked counterparts (e.g., SRGGB10 -> "rggb10le"). This patch depends on the corresponding GStreamer merge request that adds CSI-2 packed Bayer format support to the V4L2 plugin: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/10852 Tested on OnePlus 6T (Qualcomm SDM845) with IMX371 front camera: - Single raw stream: 4656x3496 SRGGB10_CSI2P - Dual stream: 640x480 ABGR8888 (ViewFinder) + 4656x3496 SRGGB10_CSI2P Signed-off-by: Frederic Laing --- src/gstreamer/gstlibcamera-utils.cpp | 31 +++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp index bfb094c9..467e4f71 100644 --- a/src/gstreamer/gstlibcamera-utils.cpp +++ b/src/gstreamer/gstlibcamera-utils.cpp @@ -22,7 +22,7 @@ static const struct { /* Compressed */ { GST_VIDEO_FORMAT_ENCODED, formats::MJPEG }, - /* Bayer formats */ + /* Bayer formats - unpacked */ { GST_VIDEO_FORMAT_ENCODED, formats::SBGGR8 }, { GST_VIDEO_FORMAT_ENCODED, formats::SGBRG8 }, { GST_VIDEO_FORMAT_ENCODED, formats::SGRBG8 }, @@ -44,6 +44,20 @@ static const struct { { GST_VIDEO_FORMAT_ENCODED, formats::SGRBG16 }, { GST_VIDEO_FORMAT_ENCODED, formats::SRGGB16 }, + /* Bayer formats - CSI-2 packed */ + { GST_VIDEO_FORMAT_ENCODED, formats::SBGGR10_CSI2P }, + { GST_VIDEO_FORMAT_ENCODED, formats::SGBRG10_CSI2P }, + { GST_VIDEO_FORMAT_ENCODED, formats::SGRBG10_CSI2P }, + { GST_VIDEO_FORMAT_ENCODED, formats::SRGGB10_CSI2P }, + { GST_VIDEO_FORMAT_ENCODED, formats::SBGGR12_CSI2P }, + { GST_VIDEO_FORMAT_ENCODED, formats::SGBRG12_CSI2P }, + { GST_VIDEO_FORMAT_ENCODED, formats::SGRBG12_CSI2P }, + { GST_VIDEO_FORMAT_ENCODED, formats::SRGGB12_CSI2P }, + { GST_VIDEO_FORMAT_ENCODED, formats::SBGGR14_CSI2P }, + { GST_VIDEO_FORMAT_ENCODED, formats::SGBRG14_CSI2P }, + { GST_VIDEO_FORMAT_ENCODED, formats::SGRBG14_CSI2P }, + { GST_VIDEO_FORMAT_ENCODED, formats::SRGGB14_CSI2P }, + /* Monochrome */ { GST_VIDEO_FORMAT_GRAY8, formats::R8 }, { GST_VIDEO_FORMAT_GRAY16_LE, formats::R16 }, @@ -265,6 +279,7 @@ static const struct { PixelFormat format; const gchar *name; } bayer_map[]{ + /* Unpacked */ { formats::SBGGR8, "bggr" }, { formats::SGBRG8, "gbrg" }, { formats::SGRBG8, "grbg" }, @@ -285,6 +300,20 @@ static const struct { { formats::SGBRG16, "gbrg16le" }, { formats::SGRBG16, "grbg16le" }, { formats::SRGGB16, "rggb16le" }, + + /* CSI-2 packed */ + { formats::SBGGR10_CSI2P, "bggr10p" }, + { formats::SGBRG10_CSI2P, "gbrg10p" }, + { formats::SGRBG10_CSI2P, "grbg10p" }, + { formats::SRGGB10_CSI2P, "rggb10p" }, + { formats::SBGGR12_CSI2P, "bggr12p" }, + { formats::SGBRG12_CSI2P, "gbrg12p" }, + { formats::SGRBG12_CSI2P, "grbg12p" }, + { formats::SRGGB12_CSI2P, "rggb12p" }, + { formats::SBGGR14_CSI2P, "bggr14p" }, + { formats::SGBRG14_CSI2P, "gbrg14p" }, + { formats::SGRBG14_CSI2P, "grbg14p" }, + { formats::SRGGB14_CSI2P, "rggb14p" }, }; static const gchar *