[{"id":38266,"web_url":"https://patchwork.libcamera.org/comment/38266/","msgid":"<20260220162635.GG1619026@killaraus.ideasonboard.com>","date":"2026-02-20T16:26:35","subject":"Re: [PATCH v2] 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":"Hi Frederic,\n\nThank you for the patch.\n\nOn Thu, Feb 19, 2026 at 05:34:34PM +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.\n\nIt's not a property of the sensor, but of the CSI-2 receiver (or more\nprecisely the DMA engine on the output of the CSI-2 receievr). Same\nCSI-2 receivers will write the packed data to memory, some will unpack\nthe data, and others will even repack them in a different format. I'd\nwrite\n\nMany CSI-2 receivers write raw data in the packed format defined in the\nCSI-2 specification, like SRGGB10_CSI2P.\n\n> 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 for dual-stream (ViewFinder + Raw)\n> capture where the Raw stream needs to use the sensor's native CSI2P\n\ns/sensor's native //\n\n> format. The Software ISP processes only the ViewFinder stream while\n> the Raw stream bypasses it entirely, but GStreamer needs to be able\n> to represent the Raw stream's format in caps.\n> \n> The CSI2P formats are mapped to distinct GStreamer Bayer format names\n> using a \"p\" suffix (e.g., SRGGB10_CSI2P -> \"rggb10p\") to distinguish\n> them from their unpacked counterparts (e.g., SRGGB10 -> \"rggb10le\").\n> \n> This patch depends on the corresponding GStreamer merge request that\n> adds CSI-2 packed Bayer format support to the V4L2 plugin:\n> https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/10852\n\nThe code looks fine. Once the merge request gets appreoved, we can merge\nthis in libcamera.\n\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..467e4f71 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, \"bggr10p\" },\n> +\t{ formats::SGBRG10_CSI2P, \"gbrg10p\" },\n> +\t{ formats::SGRBG10_CSI2P, \"grbg10p\" },\n> +\t{ formats::SRGGB10_CSI2P, \"rggb10p\" },\n> +\t{ formats::SBGGR12_CSI2P, \"bggr12p\" },\n> +\t{ formats::SGBRG12_CSI2P, \"gbrg12p\" },\n> +\t{ formats::SGRBG12_CSI2P, \"grbg12p\" },\n> +\t{ formats::SRGGB12_CSI2P, \"rggb12p\" },\n> +\t{ formats::SBGGR14_CSI2P, \"bggr14p\" },\n> +\t{ formats::SGBRG14_CSI2P, \"gbrg14p\" },\n> +\t{ formats::SGRBG14_CSI2P, \"grbg14p\" },\n> +\t{ formats::SRGGB14_CSI2P, \"rggb14p\" },\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 A656AC0DA4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 20 Feb 2026 16:26:41 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A65D862269;\n\tFri, 20 Feb 2026 17:26:40 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8330761FBF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 20 Feb 2026 17:26:39 +0100 (CET)","from killaraus.ideasonboard.com (unknown [83.245.237.175])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 1953A502;\n\tFri, 20 Feb 2026 17:25:44 +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=\"cXcOsfoa\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1771604745;\n\tbh=y0aT4KHjejDWuSRXzTkc7eN45NoXu5jZsASXDIYjKwM=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=cXcOsfoajpThvjcGr6ykpPL84F5uYxvNWH+p8dDyFvYvg+KAtGsG0VONRgYWDR7Vm\n\ttuEcGeLbAXrA0znja21Nc2YF/UF2gkdYjIHmcfe8Ne0jmVRcHHScquqNazvMIqLXLw\n\tmxgt4lmRrVR44sggMIf8MHkXwtld258I8JBLZmIU=","Date":"Fri, 20 Feb 2026 17:26:35 +0100","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Frederic Laing <dev@fredfunk.tech>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v2] gstreamer: Add CSI-2 packed Bayer format mappings","Message-ID":"<20260220162635.GG1619026@killaraus.ideasonboard.com>","References":"<20260219173423.1028522-1-dev@fredfunk.tech>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20260219173423.1028522-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>"}}]