[{"id":38221,"web_url":"https://patchwork.libcamera.org/comment/38221/","msgid":"<20260218221957.GD57525@killaraus.ideasonboard.com>","date":"2026-02-18T22:19:57","subject":"Re: [PATCH] gstreamer: Add CSI-2 packed Bayer format mappings","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Wed, Feb 18, 2026 at 09:30:49PM +0000, Frederic Laing wrote:\n> Add SRGGB/SBGGR/SGBRG/SGRBG 10/12/14-bit CSI-2 packed (CSI2P) format\n> entries to both format_map and bayer_map in gstlibcamera-utils.cpp.\n> \n> Many camera sensors (e.g., IMX371, IMX376) natively output\n> CSI-2 packed Bayer formats like SRGGB10_CSI2P. Without mappings for\n> these formats, GStreamer's libcamerasrc cannot negotiate raw Bayer\n> output (video/x-bayer caps) when the sensor only supports CSI2P\n> variants, causing caps negotiation to fail with empty caps.\n> \n> This is particularly important handler where\n> dual-stream (ViewFinder + Raw) capture requires the Raw stream to use\n> the sensor's native CSI2P format. The Software ISP processes only the\n> ViewFinder stream while the Raw stream bypasses it entirely, but\n> GStreamer needs to be able to represent the Raw stream's format in caps.\n> \n> The CSI2P formats are mapped to the same GStreamer Bayer format names\n> as their unpacked counterparts (e.g., SRGGB10_CSI2P -> \"rggb10le\"),\n> since GStreamer's video/x-bayer caps describe the Bayer pattern and\n> bit depth, not the byte packing.\n> \n> Tested on OnePlus 6T (Qualcomm SDM845) with IMX371 front camera:\n> - Single raw stream: 4656x3496 SRGGB10_CSI2P\n> - Dual stream: 640x480 ABGR8888 (ViewFinder) + 4656x3496 SRGGB10_CSI2P\n> \n> Signed-off-by: Frederic Laing <dev@fredfunk.tech>\n> ---\n>  src/gstreamer/gstlibcamera-utils.cpp | 31 +++++++++++++++++++++++++++-\n>  1 file changed, 30 insertions(+), 1 deletion(-)\n> \n> diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp\n> index bfb094c9..fb3a1411 100644\n> --- a/src/gstreamer/gstlibcamera-utils.cpp\n> +++ b/src/gstreamer/gstlibcamera-utils.cpp\n> @@ -22,7 +22,7 @@ static const struct {\n>  \t/* Compressed */\n>  \t{ GST_VIDEO_FORMAT_ENCODED, formats::MJPEG },\n>  \n> -\t/* Bayer formats */\n> +\t/* Bayer formats - unpacked */\n>  \t{ GST_VIDEO_FORMAT_ENCODED, formats::SBGGR8 },\n>  \t{ GST_VIDEO_FORMAT_ENCODED, formats::SGBRG8 },\n>  \t{ GST_VIDEO_FORMAT_ENCODED, formats::SGRBG8 },\n> @@ -44,6 +44,20 @@ static const struct {\n>  \t{ GST_VIDEO_FORMAT_ENCODED, formats::SGRBG16 },\n>  \t{ GST_VIDEO_FORMAT_ENCODED, formats::SRGGB16 },\n>  \n> +\t/* Bayer formats - CSI-2 packed */\n> +\t{ GST_VIDEO_FORMAT_ENCODED, formats::SBGGR10_CSI2P },\n> +\t{ GST_VIDEO_FORMAT_ENCODED, formats::SGBRG10_CSI2P },\n> +\t{ GST_VIDEO_FORMAT_ENCODED, formats::SGRBG10_CSI2P },\n> +\t{ GST_VIDEO_FORMAT_ENCODED, formats::SRGGB10_CSI2P },\n> +\t{ GST_VIDEO_FORMAT_ENCODED, formats::SBGGR12_CSI2P },\n> +\t{ GST_VIDEO_FORMAT_ENCODED, formats::SGBRG12_CSI2P },\n> +\t{ GST_VIDEO_FORMAT_ENCODED, formats::SGRBG12_CSI2P },\n> +\t{ GST_VIDEO_FORMAT_ENCODED, formats::SRGGB12_CSI2P },\n> +\t{ GST_VIDEO_FORMAT_ENCODED, formats::SBGGR14_CSI2P },\n> +\t{ GST_VIDEO_FORMAT_ENCODED, formats::SGBRG14_CSI2P },\n> +\t{ GST_VIDEO_FORMAT_ENCODED, formats::SGRBG14_CSI2P },\n> +\t{ GST_VIDEO_FORMAT_ENCODED, formats::SRGGB14_CSI2P },\n> +\n>  \t/* Monochrome */\n>  \t{ GST_VIDEO_FORMAT_GRAY8, formats::R8 },\n>  \t{ GST_VIDEO_FORMAT_GRAY16_LE, formats::R16 },\n> @@ -265,6 +279,7 @@ static const struct {\n>  \tPixelFormat format;\n>  \tconst gchar *name;\n>  } bayer_map[]{\n> +\t/* Unpacked */\n>  \t{ formats::SBGGR8, \"bggr\" },\n>  \t{ formats::SGBRG8, \"gbrg\" },\n>  \t{ formats::SGRBG8, \"grbg\" },\n> @@ -285,6 +300,20 @@ static const struct {\n>  \t{ formats::SGBRG16, \"gbrg16le\" },\n>  \t{ formats::SGRBG16, \"grbg16le\" },\n>  \t{ formats::SRGGB16, \"rggb16le\" },\n> +\n> +\t/* CSI-2 packed */\n> +\t{ formats::SBGGR10_CSI2P, \"bggr10le\" },\n> +\t{ formats::SGBRG10_CSI2P, \"gbrg10le\" },\n> +\t{ formats::SGRBG10_CSI2P, \"grbg10le\" },\n> +\t{ formats::SRGGB10_CSI2P, \"rggb10le\" },\n> +\t{ formats::SBGGR12_CSI2P, \"bggr12le\" },\n> +\t{ formats::SGBRG12_CSI2P, \"gbrg12le\" },\n> +\t{ formats::SGRBG12_CSI2P, \"grbg12le\" },\n> +\t{ formats::SRGGB12_CSI2P, \"rggb12le\" },\n> +\t{ formats::SBGGR14_CSI2P, \"bggr14le\" },\n> +\t{ formats::SGBRG14_CSI2P, \"gbrg14le\" },\n> +\t{ formats::SGRBG14_CSI2P, \"grbg14le\" },\n> +\t{ formats::SRGGB14_CSI2P, \"rggb14le\" },\n\nThese don't seem right. formats::SBGGR10_CSI2P and formats::SBGGR10\nwould both map to GST_VIDEO_FORMAT_ENCODED + \"bggr10le\", while they are\ndifferent formats. How would GStreamer know they're different ?\n\nGiven that GStreamer's V4L2 support maps e.g. \"bggr10le\" to\nV4L2_PIX_FMT_SBGGR10 and does not implement V4L2_PIX_FMT_SBGGR10P, I\nbelieve that GStreamer may be missing support for CSI-2 packet raw data.\nYou may need to implement that in GStreamer first.\n\n>  };\n>  \n>  static const gchar *","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id DBDE4C0DA4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 18 Feb 2026 22:20:04 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id EAAC86222E;\n\tWed, 18 Feb 2026 23:20:03 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2A07F620FA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 18 Feb 2026 23:20:02 +0100 (CET)","from killaraus.ideasonboard.com (unknown [83.245.237.175])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 1F3F550A;\n\tWed, 18 Feb 2026 23:19:08 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"BHl0/+R2\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1771453149;\n\tbh=1iPVVDIDGKUdBvKSWCmvkm5R0Wur6nQBGz9tlTNAYRM=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=BHl0/+R2nQmICj+6VW/sxq40gO0Qr0P3hf+maVoQG/LH/vDN4A0B9sAnO+/34CW/t\n\taaMcp6CMG8b3W2em8W+qYlVvkkDwqWe3/xDYPyA15xhsh5EeD3h9mRIc4T9o+5YPjg\n\t7qQCetYVEMWyITkE5nCsa+jc9OpUcyOzMVe0tyoA=","Date":"Wed, 18 Feb 2026 23:19:57 +0100","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Frederic Laing <dev@fredfunk.tech>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH] gstreamer: Add CSI-2 packed Bayer format mappings","Message-ID":"<20260218221957.GD57525@killaraus.ideasonboard.com>","References":"<20260218213030.479743-1-dev@fredfunk.tech>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20260218213030.479743-1-dev@fredfunk.tech>","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]