{"id":3302,"url":"https://patchwork.libcamera.org/api/patches/3302/?format=json","web_url":"https://patchwork.libcamera.org/patch/3302/","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":"<20200324155145.3896183-4-niklas.soderlund@ragnatech.se>","date":"2020-03-24T15:51:41","name":"[libcamera-devel,3/7,DNI] include: drm_fourcc: Add Bayer FourCC and modifiers","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"30ae65045582554f3e085ece001c27eb14cd7177","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/?format=json","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/3302/mbox/","series":[{"id":770,"url":"https://patchwork.libcamera.org/api/series/770/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=770","date":"2020-03-24T15:51:39","name":"libcamera: Add support for a RAW still capture","version":1,"mbox":"https://patchwork.libcamera.org/series/770/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/3302/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/3302/checks/","tags":{},"headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net\n\t[195.74.38.227])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B775A62BDE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 24 Mar 2020 16:51:54 +0100 (CET)","from bismarck.berto.se (p4fca2392.dip0.t-ipconnect.de\n\t[79.202.35.146]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA\n\tid 5fde019c-6de7-11ea-b7d8-005056917a89;\n\tTue, 24 Mar 2020 16:51:50 +0100 (CET)"],"X-Halon-ID":"5fde019c-6de7-11ea-b7d8-005056917a89","Authorized-sender":"niklas@soderlund.pp.se","From":"=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 24 Mar 2020 16:51:41 +0100","Message-Id":"<20200324155145.3896183-4-niklas.soderlund@ragnatech.se>","X-Mailer":"git-send-email 2.25.1","In-Reply-To":"<20200324155145.3896183-1-niklas.soderlund@ragnatech.se>","References":"<20200324155145.3896183-1-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 3/7] [DNI] include: drm_fourcc: Add Bayer\n\tFourCC and modifiers","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":"Tue, 24 Mar 2020 15:51:55 -0000"},"content":"Add Bayer format and modifiers for patch submitted for upstream\ninclusion. The formats have not been accepted upstream yet so should not\nyet be merged i libcamera.\n\nThe formats is however needed to demonstrate RAW capture on the IPU3\npipeline.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n include/linux/drm_fourcc.h | 94 ++++++++++++++++++++++++++++++++++++++\n 1 file changed, 94 insertions(+)","diff":"diff --git a/include/linux/drm_fourcc.h b/include/linux/drm_fourcc.h\nindex 4bb1bfe93d5f4390..69240dfe1df0df28 100644\n--- a/include/linux/drm_fourcc.h\n+++ b/include/linux/drm_fourcc.h\n@@ -288,6 +288,62 @@ extern \"C\" {\n /* Compressed formats */\n #define DRM_FORMAT_MJPEG\tfourcc_code('M', 'J', 'P', 'G') /* Motion-JPEG */\n \n+/*\n+ * Bayer formats\n+ *\n+ * Bayer formats contain green, red and blue components, with alternating lines\n+ * of red and green, and blue and green pixels in different orders. For each\n+ * block of 2x2 pixels there is one pixel with a red filter, two with a green\n+ * filter, and one with a blue filter. The filters can be arranged in different\n+ * patterns.\n+ *\n+ * For example, RGGB:\n+ *\trow0: RGRGRGRG...\n+ *\trow1: GBGBGBGB...\n+ *\trow3: RGRGRGRG...\n+ *\trow4: GBGBGBGB...\n+ *\t...\n+ *\n+ * Vendors have different methods to pack the sampling formats to increase data\n+ * density. For this reason the fourcc only describes pixel sample size and the\n+ * filter pattern for each block of 2x2 pixels. A modifier is needed to\n+ * describe the memory layout.\n+ *\n+ * In addition to vendor modifiers for memory layout DRM_FORMAT_MOD_LINEAR may\n+ * be used to describe a layout where all samples are placed consecutively in\n+ * memory. If the sample does not fit inside a single byte, the sample storage\n+ * is extended to the minimum number of (little endian) bytes that can hold the\n+ * sample and any unused most-significant bits are defined as padding.\n+ *\n+ * For example, SRGGB10:\n+ * Each 10-bit sample is contained in 2 consecutive little endian bytes, where\n+ * the 6 most-significant bits are unused.\n+ */\n+\n+/* 8-bit Bayer formats */\n+#define DRM_FORMAT_SRGGB8\tfourcc_code('R', 'G', 'G', 'B')\n+#define DRM_FORMAT_SGRBG8\tfourcc_code('G', 'R', 'B', 'G')\n+#define DRM_FORMAT_SGBRG8\tfourcc_code('G', 'B', 'R', 'G')\n+#define DRM_FORMAT_SBGGR8\tfourcc_code('B', 'A', '8', '1')\n+\n+/* 10-bit Bayer formats */\n+#define DRM_FORMAT_SRGGB10\tfourcc_code('R', 'G', '1', '0')\n+#define DRM_FORMAT_SGRBG10\tfourcc_code('B', 'A', '1', '0')\n+#define DRM_FORMAT_SGBRG10\tfourcc_code('G', 'B', '1', '0')\n+#define DRM_FORMAT_SBGGR10\tfourcc_code('B', 'G', '1', '0')\n+\n+/* 12-bit Bayer formats */\n+#define DRM_FORMAT_SRGGB12\tfourcc_code('R', 'G', '1', '2')\n+#define DRM_FORMAT_SGRBG12\tfourcc_code('B', 'A', '1', '2')\n+#define DRM_FORMAT_SGBRG12\tfourcc_code('G', 'B', '1', '2')\n+#define DRM_FORMAT_SBGGR12\tfourcc_code('B', 'G', '1', '2')\n+\n+/* 14-bit Bayer formats */\n+#define DRM_FORMAT_SRGGB14\tfourcc_code('R', 'G', '1', '4')\n+#define DRM_FORMAT_SGRBG14\tfourcc_code('B', 'A', '1', '4')\n+#define DRM_FORMAT_SGBRG14\tfourcc_code('G', 'B', '1', '4')\n+#define DRM_FORMAT_SBGGR14\tfourcc_code('B', 'G', '1', '4')\n+\n /*\n  * Format Modifiers:\n  *\n@@ -311,6 +367,7 @@ extern \"C\" {\n #define DRM_FORMAT_MOD_VENDOR_BROADCOM 0x07\n #define DRM_FORMAT_MOD_VENDOR_ARM     0x08\n #define DRM_FORMAT_MOD_VENDOR_ALLWINNER 0x09\n+#define DRM_FORMAT_MOD_VENDOR_MIPI 0x0a\n \n /* add more to the end as needed */\n \n@@ -412,6 +469,16 @@ extern \"C\" {\n #define I915_FORMAT_MOD_Y_TILED_CCS\tfourcc_mod_code(INTEL, 4)\n #define I915_FORMAT_MOD_Yf_TILED_CCS\tfourcc_mod_code(INTEL, 5)\n \n+/*\n+ * IPU3 Bayer packing layout\n+ *\n+ * The IPU3 raw Bayer formats use a custom packing layout where there are no\n+ * gaps between each 10-bit sample. It packs 25 pixels into 32 bytes leaving\n+ * the 6 most significant bits in the last byte unused. The format is little\n+ * endian.\n+ */\n+#define IPU3_FORMAT_MOD_PACKED fourcc_mod_code(INTEL, 8)\n+\n /*\n  * Tiled, NV12MT, grouped in 64 (pixels) x 32 (lines) -sized macroblocks\n  *\n@@ -758,6 +825,33 @@ extern \"C\" {\n  */\n #define DRM_FORMAT_MOD_ALLWINNER_TILED fourcc_mod_code(ALLWINNER, 1)\n \n+/* Mobile Industry Processor Interface (MIPI) modifiers */\n+\n+/*\n+ * MIPI CSI-2 packing layout\n+ *\n+ * The CSI-2 RAW formats (for example Bayer) use a different packing layout\n+ * depenindg on the sample size.\n+ *\n+ * - 10-bits per sample\n+ *   Every four consecutive samples are packed into 5 bytes. Each of the first 4\n+ *   bytes contain the 8 high order bits of the pixels, and the 5th byte\n+ *   contains the 2 least-significant bits of each pixel, in the same order.\n+ *\n+ * - 12-bits per sample\n+ *   Every two consecutive samples are packed into three bytes. Each of the\n+ *   first two bytes contain the 8 high order bits of the pixels, and the third\n+ *   byte contains the four least-significant bits of each pixel, in the same\n+ *   order.\n+ *\n+ * - 14-bits per sample\n+ *   Every four consecutive samples are packed into seven bytes. Each of the\n+ *   first four bytes contain the eight high order bits of the pixels, and the\n+ *   three following bytes contains the six least-significant bits of each\n+ *   pixel, in the same order.\n+ */\n+#define MIPI_FORMAT_MOD_CSI2_PACKED fourcc_mod_code(MIPI, 1)\n+\n #if defined(__cplusplus)\n }\n #endif\n","prefixes":["libcamera-devel","3/7","DNI"]}