{"id":3845,"url":"https://patchwork.libcamera.org/api/1.1/patches/3845/?format=json","web_url":"https://patchwork.libcamera.org/patch/3845/","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":"<20200522145459.16836-7-laurent.pinchart@ideasonboard.com>","date":"2020-05-22T14:54:53","name":"[libcamera-devel,PATCH/RFC,05/11] libcamera: Define constants for pixel formats in the public API","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"e3d07e40e666293571199cca7276df4c57b61a5a","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/3845/mbox/","series":[{"id":923,"url":"https://patchwork.libcamera.org/api/1.1/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/3845/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/3845/checks/","tags":{},"headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1AD156109B\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 B664624D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 22 May 2020 16:55:20 +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=\"ctUN9YJq\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1590159320;\n\tbh=o0cFGE0QnKfZi5QmFcBBYOTZoLQkGPzfoafuTZJGCE4=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=ctUN9YJqjIZqufbZ+EC81McZAGsYfa5jOV4xhIgm0mvEFHTbjJ8mmdXV7yZm4VuFC\n\tPzyGeWxC+tctG/mg1lZckWqClhiyKpAXfjhpdFmU7hhdBOzvB3PXLRQVI3MEAC2C/v\n\tkvfc54LitJ1TTETRnnY7H0sopw5dRmjD3ElpyYD4=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 22 May 2020 17:54:53 +0300","Message-Id":"<20200522145459.16836-7-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 05/11] libcamera: Define constants for\n\tpixel formats in the public API","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":"libcamera uses pixel format FourCC and modifier values from DRM. This\nrequires inclusion of drm_fourcc.h, creating a dependency on a header\nthat is packaged differently between distributions, and causing possible\nissues with third-party applications.\n\nDefine constants for the supported pixel formats in the public API, in\norder to remove the dependency on drm_fourcc.h. The numerical values are\nstill identical to the DRM pixel formats, keeping the direct\ninteroperability.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/formats.h    | 94 ++++++++++++++++++++++++++++++++++\n include/libcamera/meson.build  |  1 +\n src/libcamera/formats.cpp      |  2 +-\n src/libcamera/pixel_format.cpp |  1 +\n 4 files changed, 97 insertions(+), 1 deletion(-)\n create mode 100644 include/libcamera/formats.h","diff":"diff --git a/include/libcamera/formats.h b/include/libcamera/formats.h\nnew file mode 100644\nindex 000000000000..bd164226d712\n--- /dev/null\n+++ b/include/libcamera/formats.h\n@@ -0,0 +1,94 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2020, Google Inc.\n+ *\n+ * formats.h - Formats\n+ */\n+#ifndef __LIBCAMERA_FORMATS_H__\n+#define __LIBCAMERA_FORMATS_H__\n+\n+#include <stdint.h>\n+\n+#include <libcamera/pixel_format.h>\n+\n+namespace libcamera {\n+\n+namespace formats {\n+\n+namespace {\n+\n+constexpr uint32_t __fourcc(char a, char b, char c, char d)\n+{\n+\treturn (static_cast<uint32_t>(a) <<  0) |\n+\t       (static_cast<uint32_t>(b) <<  8) |\n+\t       (static_cast<uint32_t>(c) << 16) |\n+\t       (static_cast<uint32_t>(d) << 24);\n+}\n+\n+constexpr uint64_t __mod(unsigned int vendor, unsigned int mod)\n+{\n+\treturn (static_cast<uint64_t>(vendor) << 56) |\n+\t       (static_cast<uint64_t>(mod) << 0);\n+}\n+\n+} /* namespace */\n+\n+constexpr PixelFormat R8{ __fourcc('R', '8', ' ', ' ') };\n+\n+constexpr PixelFormat RGB888{ __fourcc('R', 'G', '2', '4') };\n+constexpr PixelFormat BGR888{ __fourcc('B', 'G', '2', '4') };\n+\n+constexpr PixelFormat XRGB8888{ __fourcc('X', 'R', '2', '4') };\n+constexpr PixelFormat XBGR8888{ __fourcc('X', 'B', '2', '4') };\n+constexpr PixelFormat RGBX8888{ __fourcc('R', 'X', '2', '4') };\n+constexpr PixelFormat BGRX8888{ __fourcc('B', 'X', '2', '4') };\n+\n+constexpr PixelFormat ARGB8888{ __fourcc('A', 'R', '2', '4') };\n+constexpr PixelFormat ABGR8888{ __fourcc('A', 'B', '2', '4') };\n+constexpr PixelFormat RGBA8888{ __fourcc('R', 'A', '2', '4') };\n+constexpr PixelFormat BGRA8888{ __fourcc('B', 'A', '2', '4') };\n+\n+constexpr PixelFormat YUYV{ __fourcc('Y', 'U', 'Y', 'V') };\n+constexpr PixelFormat YVYU{ __fourcc('Y', 'V', 'Y', 'U') };\n+constexpr PixelFormat UYVY{ __fourcc('U', 'Y', 'V', 'Y') };\n+constexpr PixelFormat VYUY{ __fourcc('V', 'Y', 'U', 'Y') };\n+\n+constexpr PixelFormat NV12{ __fourcc('N', 'V', '1', '2') };\n+constexpr PixelFormat NV21{ __fourcc('N', 'V', '2', '1') };\n+constexpr PixelFormat NV16{ __fourcc('N', 'V', '1', '6') };\n+constexpr PixelFormat NV61{ __fourcc('N', 'V', '6', '1') };\n+constexpr PixelFormat NV24{ __fourcc('N', 'V', '2', '4') };\n+constexpr PixelFormat NV42{ __fourcc('N', 'V', '4', '2') };\n+\n+constexpr PixelFormat MJPEG{ __fourcc('M', 'J', 'P', 'G') };\n+\n+constexpr PixelFormat SRGGB8{ __fourcc('R', 'G', 'G', 'B') };\n+constexpr PixelFormat SGRBG8{ __fourcc('G', 'R', 'B', 'G') };\n+constexpr PixelFormat SGBRG8{ __fourcc('G', 'B', 'R', 'G') };\n+constexpr PixelFormat SBGGR8{ __fourcc('B', 'A', '8', '1') };\n+\n+constexpr PixelFormat SRGGB10{ __fourcc('R', 'G', '1', '0') };\n+constexpr PixelFormat SGRBG10{ __fourcc('B', 'A', '1', '0') };\n+constexpr PixelFormat SGBRG10{ __fourcc('G', 'B', '1', '0') };\n+constexpr PixelFormat SBGGR10{ __fourcc('B', 'G', '1', '0') };\n+\n+constexpr PixelFormat SRGGB12{ __fourcc('R', 'G', '1', '2') };\n+constexpr PixelFormat SGRBG12{ __fourcc('B', 'A', '1', '2') };\n+constexpr PixelFormat SGBRG12{ __fourcc('G', 'B', '1', '2') };\n+constexpr PixelFormat SBGGR12{ __fourcc('B', 'G', '1', '2') };\n+\n+constexpr PixelFormat SRGGB10_CSI2P{ __fourcc('R', 'G', '1', '0'), __mod(10, 1) };\n+constexpr PixelFormat SGRBG10_CSI2P{ __fourcc('B', 'A', '1', '0'), __mod(10, 1) };\n+constexpr PixelFormat SGBRG10_CSI2P{ __fourcc('G', 'B', '1', '0'), __mod(10, 1) };\n+constexpr PixelFormat SBGGR10_CSI2P{ __fourcc('B', 'G', '1', '0'), __mod(10, 1) };\n+\n+constexpr PixelFormat SRGGB12_CSI2P{ __fourcc('R', 'G', '1', '2'), __mod(10, 1) };\n+constexpr PixelFormat SGRBG12_CSI2P{ __fourcc('B', 'A', '1', '2'), __mod(10, 1) };\n+constexpr PixelFormat SGBRG12_CSI2P{ __fourcc('G', 'B', '1', '2'), __mod(10, 1) };\n+constexpr PixelFormat SBGGR12_CSI2P{ __fourcc('B', 'G', '1', '2'), __mod(10, 1) };\n+\n+} /* namespace formats */\n+\n+} /* namespace libcamera */\n+\n+#endif /* __LIBCAMERA_FORMATS_H__ */\ndiff --git a/include/libcamera/meson.build b/include/libcamera/meson.build\nindex 73c5b999acf4..170744d0fbbc 100644\n--- a/include/libcamera/meson.build\n+++ b/include/libcamera/meson.build\n@@ -9,6 +9,7 @@ libcamera_public_headers = files([\n     'event_dispatcher.h',\n     'event_notifier.h',\n     'file_descriptor.h',\n+    'formats.h',\n     'framebuffer_allocator.h',\n     'geometry.h',\n     'logging.h',\ndiff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp\nindex 2ac3b412ecdb..74c239a5e710 100644\n--- a/src/libcamera/formats.cpp\n+++ b/src/libcamera/formats.cpp\n@@ -12,7 +12,7 @@\n #include \"libcamera/internal/log.h\"\n \n /**\n- * \\file formats.h\n+ * \\file internal/formats.h\n  * \\brief Types and helper methods to handle libcamera image formats\n  */\n \ndiff --git a/src/libcamera/pixel_format.cpp b/src/libcamera/pixel_format.cpp\nindex d501c5f09c6b..0709d1526b82 100644\n--- a/src/libcamera/pixel_format.cpp\n+++ b/src/libcamera/pixel_format.cpp\n@@ -5,6 +5,7 @@\n  * pixel_format.cpp - libcamera Pixel Format\n  */\n \n+#include <libcamera/formats.h>\n #include <libcamera/pixel_format.h>\n \n /**\n","prefixes":["libcamera-devel","PATCH/RFC","05/11"]}