{"id":3846,"url":"https://patchwork.libcamera.org/api/patches/3846/?format=json","web_url":"https://patchwork.libcamera.org/patch/3846/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20200522145459.16836-8-laurent.pinchart@ideasonboard.com>","date":"2020-05-22T14:54:54","name":"[libcamera-devel,PATCH/RFC,06/11] gst: Replace explicit DRM FourCCs with libcamera formats","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"34a9201678bb234ca60341b5a348ad789f6342fe","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/3846/mbox/","series":[{"id":923,"url":"https://patchwork.libcamera.org/api/series/923/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=923","date":"2020-05-22T14:54:47","name":"Introduce formats:: namespace for libcamera pixel formats","version":1,"mbox":"https://patchwork.libcamera.org/series/923/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/3846/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/3846/checks/","tags":{},"headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["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 73F136108A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 22 May 2020 16:55:21 +0200 (CEST)","from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 0FE1D528\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 22 May 2020 16:55:21 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"GDt27NM1\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1590159321;\n\tbh=xu8GOP5HbBM65fpE8v4RrcN9ikFEEfRvQ98iksGeDXg=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=GDt27NM1K4Cw82s4uuInfQ6XWkw65qU86M5OUjo+Zd9cjqi3fXVnlosGxxCcFyIsP\n\tFfXDD1zWnA+20BJhkPs/J/6MxaBYRzKRgvoct+j0NLi48CC5nOmFfY/ZyNKxn0Mbaw\n\tjb0SMkVzydEhBlib8scQWHmxQXYFxfnA1pQuUzbg=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 22 May 2020 17:54:54 +0300","Message-Id":"<20200522145459.16836-8-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.26.2","In-Reply-To":"<20200522145459.16836-1-laurent.pinchart@ideasonboard.com>","References":"<20200522145459.16836-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH/RFC 06/11] gst: Replace explicit DRM\n\tFourCCs with libcamera formats","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>","X-List-Received-Date":"Fri, 22 May 2020 14:55:24 -0000"},"content":"Use the new pixel format constants to replace usage of macros from\ndrm_fourcc.h.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/gstreamer/gstlibcamera-utils.cpp | 62 ++++++++++++++--------------\n 1 file changed, 31 insertions(+), 31 deletions(-)","diff":"diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp\nindex a3cb0746e012..61370d5fad56 100644\n--- a/src/gstreamer/gstlibcamera-utils.cpp\n+++ b/src/gstreamer/gstlibcamera-utils.cpp\n@@ -8,56 +8,56 @@\n \n #include \"gstlibcamera-utils.h\"\n \n-#include <linux/drm_fourcc.h>\n+#include <libcamera/formats.h>\n \n using namespace libcamera;\n \n static struct {\n \tGstVideoFormat gst_format;\n-\tguint drm_fourcc;\n+\tPixelFormat format;\n } format_map[] = {\n-\t{ GST_VIDEO_FORMAT_ENCODED, DRM_FORMAT_MJPEG },\n-\t{ GST_VIDEO_FORMAT_RGB, DRM_FORMAT_BGR888 },\n-\t{ GST_VIDEO_FORMAT_BGR, DRM_FORMAT_RGB888 },\n-\t{ GST_VIDEO_FORMAT_ARGB, DRM_FORMAT_BGRA8888 },\n-\t{ GST_VIDEO_FORMAT_NV12, DRM_FORMAT_NV12 },\n-\t{ GST_VIDEO_FORMAT_NV21, DRM_FORMAT_NV21 },\n-\t{ GST_VIDEO_FORMAT_NV16, DRM_FORMAT_NV16 },\n-\t{ GST_VIDEO_FORMAT_NV61, DRM_FORMAT_NV61 },\n-\t{ GST_VIDEO_FORMAT_NV24, DRM_FORMAT_NV24 },\n-\t{ GST_VIDEO_FORMAT_UYVY, DRM_FORMAT_UYVY },\n-\t{ GST_VIDEO_FORMAT_VYUY, DRM_FORMAT_VYUY },\n-\t{ GST_VIDEO_FORMAT_YUY2, DRM_FORMAT_YUYV },\n-\t{ GST_VIDEO_FORMAT_YVYU, DRM_FORMAT_YVYU },\n+\t{ GST_VIDEO_FORMAT_ENCODED, formats::MJPEG },\n+\t{ GST_VIDEO_FORMAT_RGB, formats::BGR888 },\n+\t{ GST_VIDEO_FORMAT_BGR, formats::RGB888 },\n+\t{ GST_VIDEO_FORMAT_ARGB, formats::BGRA8888 },\n+\t{ GST_VIDEO_FORMAT_NV12, formats::NV12 },\n+\t{ GST_VIDEO_FORMAT_NV21, formats::NV21 },\n+\t{ GST_VIDEO_FORMAT_NV16, formats::NV16 },\n+\t{ GST_VIDEO_FORMAT_NV61, formats::NV61 },\n+\t{ GST_VIDEO_FORMAT_NV24, formats::NV24 },\n+\t{ GST_VIDEO_FORMAT_UYVY, formats::UYVY },\n+\t{ GST_VIDEO_FORMAT_VYUY, formats::VYUY },\n+\t{ GST_VIDEO_FORMAT_YUY2, formats::YUYV },\n+\t{ GST_VIDEO_FORMAT_YVYU, formats::YVYU },\n \t/* \\todo NV42 is used in libcamera but is not mapped in GStreamer yet. */\n };\n \n static GstVideoFormat\n-drm_to_gst_format(guint drm_fourcc)\n+pixel_format_to_gst_format(const PixelFormat &format)\n {\n \tfor (const auto &item : format_map) {\n-\t\tif (item.drm_fourcc == drm_fourcc)\n+\t\tif (item.format == format)\n \t\t\treturn item.gst_format;\n \t}\n \treturn GST_VIDEO_FORMAT_UNKNOWN;\n }\n \n-static guint\n-gst_format_to_drm(GstVideoFormat gst_format)\n+static PixelFormat\n+gst_format_to_pixel_format(GstVideoFormat gst_format)\n {\n \tif (gst_format == GST_VIDEO_FORMAT_ENCODED)\n-\t\treturn DRM_FORMAT_INVALID;\n+\t\treturn PixelFormat{};\n \n \tfor (const auto &item : format_map)\n \t\tif (item.gst_format == gst_format)\n-\t\t\treturn item.drm_fourcc;\n-\treturn DRM_FORMAT_INVALID;\n+\t\t\treturn item.format;\n+\treturn PixelFormat{};\n }\n \n static GstStructure *\n-bare_structure_from_fourcc(guint fourcc)\n+bare_structure_from_format(const PixelFormat &format)\n {\n-\tGstVideoFormat gst_format = drm_to_gst_format(fourcc);\n+\tGstVideoFormat gst_format = pixel_format_to_gst_format(format);\n \n \tif (gst_format == GST_VIDEO_FORMAT_UNKNOWN)\n \t\treturn nullptr;\n@@ -66,8 +66,8 @@ bare_structure_from_fourcc(guint fourcc)\n \t\treturn gst_structure_new(\"video/x-raw\", \"format\", G_TYPE_STRING,\n \t\t\t\t\t gst_video_format_to_string(gst_format), nullptr);\n \n-\tswitch (fourcc) {\n-\tcase DRM_FORMAT_MJPEG:\n+\tswitch (format) {\n+\tcase formats::MJPEG:\n \t\treturn gst_structure_new_empty(\"image/jpeg\");\n \tdefault:\n \t\treturn nullptr;\n@@ -80,7 +80,7 @@ gst_libcamera_stream_formats_to_caps(const StreamFormats &formats)\n \tGstCaps *caps = gst_caps_new_empty();\n \n \tfor (PixelFormat pixelformat : formats.pixelformats()) {\n-\t\tg_autoptr(GstStructure) bare_s = bare_structure_from_fourcc(pixelformat);\n+\t\tg_autoptr(GstStructure) bare_s = bare_structure_from_format(pixelformat);\n \n \t\tif (!bare_s) {\n \t\t\tGST_WARNING(\"Unsupported DRM format %\" GST_FOURCC_FORMAT,\n@@ -120,7 +120,7 @@ GstCaps *\n gst_libcamera_stream_configuration_to_caps(const StreamConfiguration &stream_cfg)\n {\n \tGstCaps *caps = gst_caps_new_empty();\n-\tGstStructure *s = bare_structure_from_fourcc(stream_cfg.pixelFormat);\n+\tGstStructure *s = bare_structure_from_format(stream_cfg.pixelFormat);\n \n \tgst_structure_set(s,\n \t\t\t  \"width\", G_TYPE_INT, stream_cfg.size.width,\n@@ -135,7 +135,7 @@ void\n gst_libcamera_configure_stream_from_caps(StreamConfiguration &stream_cfg,\n \t\t\t\t\t GstCaps *caps)\n {\n-\tGstVideoFormat gst_format = drm_to_gst_format(stream_cfg.pixelFormat);\n+\tGstVideoFormat gst_format = pixel_format_to_gst_format(stream_cfg.pixelFormat);\n \n \t/* First fixate the caps using default configuration value. */\n \tg_assert(gst_caps_is_writable(caps));\n@@ -154,9 +154,9 @@ gst_libcamera_configure_stream_from_caps(StreamConfiguration &stream_cfg,\n \tif (gst_structure_has_name(s, \"video/x-raw\")) {\n \t\tconst gchar *format = gst_structure_get_string(s, \"format\");\n \t\tgst_format = gst_video_format_from_string(format);\n-\t\tstream_cfg.pixelFormat = PixelFormat(gst_format_to_drm(gst_format));\n+\t\tstream_cfg.pixelFormat = gst_format_to_pixel_format(gst_format);\n \t} else if (gst_structure_has_name(s, \"image/jpeg\")) {\n-\t\tstream_cfg.pixelFormat = PixelFormat(DRM_FORMAT_MJPEG);\n+\t\tstream_cfg.pixelFormat = formats::MJPEG;\n \t} else {\n \t\tg_critical(\"Unsupported media type: %s\", gst_structure_get_name(s));\n \t}\n","prefixes":["libcamera-devel","PATCH/RFC","06/11"]}