From patchwork Wed Feb 18 21:30:49 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frederic Laing X-Patchwork-Id: 26191 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 B28B0C31E9 for ; Wed, 18 Feb 2026 21:30:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0547662222; Wed, 18 Feb 2026 22:30:58 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=fredfunk.tech header.i=@fredfunk.tech header.b="vzzyy2sm"; dkim-atps=neutral Received: from mail-4396.protonmail.ch (mail-4396.protonmail.ch [185.70.43.96]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id BCFDF620FA for ; Wed, 18 Feb 2026 22:30:55 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fredfunk.tech; s=protonmail; t=1771450255; x=1771709455; bh=zpO7gVGsX63AVmAVEWho4FlkmN6dhm0/JYXPf48IvRI=; h=Date:To:From:Cc:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=vzzyy2smsj6IwPcj2jhyecf3S6QlgLJqTBVh58O5n2AfONMLlQQAJycnHEBDfWEi1 P+IFWqv5M1mceDQrwUnolWRPH0uTrzITMJEEg4l6CjNHgJvpPyNqrRCms66A6LgZoz Itflg3tKQpwp9lJbobhBziMmkA6MhwCsTIo3iFse/APxBeCgz6uKFkdD2KG4xRZUiX V1ze/c2xLX4ST2r4ODpkie2tKtxZtJ5P2xNqq8hXI80JUOvZ6ET2BCDvI2teDj4DzO 7dnq7VI0kqjHij70zV6Z5n/t4xLnXfDd84yMqzYEfB8HwEe2Ch/YpJPEq0GJcXM2OJ ZmS5Qpcz7pnww== Date: Wed, 18 Feb 2026 21:30:49 +0000 To: libcamera-devel@lists.libcamera.org From: Frederic Laing Cc: Frederic Laing Subject: [PATCH] gstreamer: Add CSI-2 packed Bayer format mappings Message-ID: <20260218213030.479743-1-dev@fredfunk.tech> Feedback-ID: 182542373:user:proton X-Pm-Message-ID: e6e57907d17423c87da1ca1491a81de9d84f505f 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 handler where dual-stream (ViewFinder + Raw) capture requires the Raw stream 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 the same GStreamer Bayer format names as their unpacked counterparts (e.g., SRGGB10_CSI2P -> "rggb10le"), since GStreamer's video/x-bayer caps describe the Bayer pattern and bit depth, not the byte packing. 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..fb3a1411 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, "bggr10le" }, + { formats::SGBRG10_CSI2P, "gbrg10le" }, + { formats::SGRBG10_CSI2P, "grbg10le" }, + { formats::SRGGB10_CSI2P, "rggb10le" }, + { formats::SBGGR12_CSI2P, "bggr12le" }, + { formats::SGBRG12_CSI2P, "gbrg12le" }, + { formats::SGRBG12_CSI2P, "grbg12le" }, + { formats::SRGGB12_CSI2P, "rggb12le" }, + { formats::SBGGR14_CSI2P, "bggr14le" }, + { formats::SGBRG14_CSI2P, "gbrg14le" }, + { formats::SGRBG14_CSI2P, "grbg14le" }, + { formats::SRGGB14_CSI2P, "rggb14le" }, }; static const gchar *