{"id":18054,"url":"https://patchwork.libcamera.org/api/1.1/patches/18054/?format=json","web_url":"https://patchwork.libcamera.org/patch/18054/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<Y6XkAEC7SOKsKMBk@duo.ucw.cz>","date":"2022-12-23T17:23:12","name":"[libcamera-devel,PATCHv2] gstreamer: Add bayer8 support to libcamerasrc element","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"74292b608c3632a6328ffa658f0f471890a14e4c","submitter":{"id":49,"url":"https://patchwork.libcamera.org/api/1.1/people/49/?format=json","name":"Pavel Machek","email":"pavel@ucw.cz"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/18054/mbox/","series":[{"id":3689,"url":"https://patchwork.libcamera.org/api/1.1/series/3689/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3689","date":"2022-12-23T17:23:12","name":"[libcamera-devel,PATCHv2] gstreamer: Add bayer8 support to libcamerasrc element","version":1,"mbox":"https://patchwork.libcamera.org/series/3689/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/18054/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/18054/checks/","tags":{},"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 933C4C3200\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 23 Dec 2022 17:23:15 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1729A623AF;\n\tFri, 23 Dec 2022 18:23:15 +0100 (CET)","from jabberwock.ucw.cz (jabberwock.ucw.cz [46.255.230.98])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AA6E462398\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 23 Dec 2022 18:23:13 +0100 (CET)","by jabberwock.ucw.cz (Postfix, from userid 1017)\n\tid EF1ED1C09F5; Fri, 23 Dec 2022 18:23:12 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1671816195;\n\tbh=NJdwcD/Nhs6d1VUHMDbiyDP1/ZQ27iEg2jxVjLZO8wk=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=BanDYzFM5ojr2QFMCR3V7S8wJH5OWGkC/YpoKqJ/lwNSOxCQGd33LkfV56V6jn1sV\n\trcGoUITANWuMa8EPFk/IgmdWC4oAVI/2YlHe664/teyB8837/wXLj9sH7FSVLqJmYC\n\tXL5KpXzO0C/r7cRsgOLFRpDP1bzzczAY+7KIhMkYPVa7zkGtuw0H/1qmcXM+D5K9LB\n\tdoUoEi9w58wgE+jFVhtC8EnHhupIiSGm7Rbb2tNc3NO2iviCACes6if0TKPkyN2owt\n\t3NrpkKYuSFGot4LJUGyTfvkgp90md/uVvE66zErY82+wN8j9p5hpJvt5IB6CGlggjL\n\t+pDFiAMt1h7Kg==","v=1; a=rsa-sha256; c=relaxed/relaxed; d=ucw.cz; s=gen1;\n\tt=1671816192;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=LqjRmYUIB4BQ9N6tJ+VX0juUoHz/YTQpoG4nzSSwufE=;\n\tb=ZbZOGb50Ciinq3/w2CQraqRBaBuCDhe0s85nRFwyMm59GioyQ8OoTP5cy+ptwavnsZbF5T\n\tVALe82x01K5lgG5fqTXNUVgiSs7/ecyrsIRy8DymxAl2eaS2F5lVe40YViVPSDWupONlJC\n\tjyx4KzpXPhDHGCrLYk7KrfDaZ0Cfr3I="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ucw.cz header.i=@ucw.cz\n\theader.b=\"ZbZOGb50\"; dkim-atps=neutral","Date":"Fri, 23 Dec 2022 18:23:12 +0100","To":"Nicolas Dufresne <nicolas@ndufresne.ca>","Message-ID":"<Y6XkAEC7SOKsKMBk@duo.ucw.cz>","References":"<Y52jM6iQtzs0Vysm@duo.ucw.cz>\n\t<CAKQmDh9BDUWonGdnOqz4uNPwS+L6cQMh1A2O4Be3Z=z+JqbQTQ@mail.gmail.com>\n\t<Y545RJF0JMWIQUwe@duo.ucw.cz>\n\t<a060b121a53465d2118d8d6194cd866e32ccc238.camel@ndufresne.ca>\n\t<Y6IzhjY3XQZn2oci@duo.ucw.cz>\n\t<167162721688.3944359.738999548555516756@Monstersaurus>\n\t<Y6NFu/O6VDG+WYdN@duo.ucw.cz>\n\t<aeb18f80a76778f99db08d3600036e34257024cc.camel@ndufresne.ca>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha1;\n\tprotocol=\"application/pgp-signature\"; boundary=\"+eEMpQcKJUAFXHVz\"","Content-Disposition":"inline","In-Reply-To":"<aeb18f80a76778f99db08d3600036e34257024cc.camel@ndufresne.ca>","Subject":"[libcamera-devel] [PATCHv2] gstreamer: Add bayer8 support to\n\tlibcamerasrc element","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>","From":"Pavel Machek via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Pavel Machek <pavel@ucw.cz>","Cc":"Dorota Czaplejewicz <dorota.czaplejewicz@puri.sm>,\n\tPavel Machek via libcamera-devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Bayer8 support is useful on hardware such as Librem 5, as GStreamer\nprovides easy solution for debayering and display of the camera\ndata. Add neccessary glue to libcamerasrc element.\n    \nSigned-off-by: Pavel Machek <pavel@ucw.cz>\nReviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>\n\n--\n\nThanks for the review!","diff":"diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp\nindex 36b9564c..b2cc7661 100644\n--- a/src/gstreamer/gstlibcamera-utils.cpp\n+++ b/src/gstreamer/gstlibcamera-utils.cpp\n@@ -20,6 +20,12 @@ static struct {\n \t/* Compressed */\n \t{ GST_VIDEO_FORMAT_ENCODED, formats::MJPEG },\n \n+\t/* Bayer formats, gstreamer only supports 8-bit */\n+\t{ GST_VIDEO_FORMAT_ENCODED, formats::SGRBG8 },\n+\t{ GST_VIDEO_FORMAT_ENCODED, formats::SGBRG8 },\n+\t{ GST_VIDEO_FORMAT_ENCODED, formats::SRGGB8 },\n+\t{ GST_VIDEO_FORMAT_ENCODED, formats::SBGGR8 },\n+\n \t/* RGB16 */\n \t{ GST_VIDEO_FORMAT_RGB16, formats::RGB565 },\n \n@@ -228,6 +234,22 @@ gst_format_to_pixel_format(GstVideoFormat gst_format)\n \treturn PixelFormat{};\n }\n \n+static const gchar *\n+bayer_format_to_string(int format)\n+{\n+\tswitch (format) {\n+\tcase formats::SGRBG8:\n+\t\treturn \"grbg\";\n+\tcase formats::SGBRG8:\n+\t\treturn \"gbrg\";\n+\tcase formats::SRGGB8:\n+\t\treturn \"rggb\";\n+\tcase formats::SBGGR8:\n+\t\treturn \"bggr\";\n+\t}\n+\treturn NULL;\n+}\n+\n static GstStructure *\n bare_structure_from_format(const PixelFormat &format)\n {\n@@ -243,6 +265,12 @@ bare_structure_from_format(const PixelFormat &format)\n \tswitch (format) {\n \tcase formats::MJPEG:\n \t\treturn gst_structure_new_empty(\"image/jpeg\");\n+\tcase formats::SGRBG8:\n+\tcase formats::SGBRG8:\n+\tcase formats::SRGGB8:\n+\tcase formats::SBGGR8:\n+\t\treturn gst_structure_new(\"video/x-bayer\", \"format\", G_TYPE_STRING,\n+\t\t\t\t\t bayer_format_to_string(format), nullptr);\n \tdefault:\n \t\treturn nullptr;\n \t}\ndiff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp\nindex 8d97d7c2..a10cbd4f 100644\n--- a/src/gstreamer/gstlibcamerasrc.cpp\n+++ b/src/gstreamer/gstlibcamerasrc.cpp\n@@ -161,7 +161,7 @@ G_DEFINE_TYPE_WITH_CODE(GstLibcameraSrc, gst_libcamera_src, GST_TYPE_ELEMENT,\n \t\t\tGST_DEBUG_CATEGORY_INIT(source_debug, \"libcamerasrc\", 0,\n \t\t\t\t\t\t\"libcamera Source\"))\n \n-#define TEMPLATE_CAPS GST_STATIC_CAPS(\"video/x-raw; image/jpeg\")\n+#define TEMPLATE_CAPS GST_STATIC_CAPS(\"video/x-raw; image/jpeg; video/x-bayer\")\n \n /* For the simple case, we have a src pad that is always present. */\n GstStaticPadTemplate src_template = {\n","prefixes":["libcamera-devel","PATCHv2"]}