[{"id":4332,"web_url":"https://patchwork.libcamera.org/comment/4332/","msgid":"<20200327085153.6mzkg7n5txnzei5i@uno.localdomain>","date":"2020-03-27T08:51:53","subject":"Re: [libcamera-devel] [PATCH v2 3/7] include: drm_fourcc: Add Bayer\n\tFourCC and modifiers","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Niklas,\n\nOn Thu, Mar 26, 2020 at 11:58:40PM +0100, Niklas Söderlund wrote:\n> Add Bayer format and modifiers for patch submitted for upstream\n> inclusion. The formats have not been accepted upstream yet but is needed\n> to progress with RAW capture support in libcamera.\n>\n> Intention is to merge this in libcamera and update the header file the\n> upstream patch is picked up upstream.\n>\n\nJust wondering if this needs a notice somewhere that this is a\ntemporary version.\n\nWith or without this\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\nThanks\n   j\n> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> ---\n> * Changes since v1\n> - Removed DNI label\n> ---\n>  include/linux/drm_fourcc.h | 94 ++++++++++++++++++++++++++++++++++++++\n>  1 file changed, 94 insertions(+)\n>\n> diff --git a/include/linux/drm_fourcc.h b/include/linux/drm_fourcc.h\n> index 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> --\n> 2.25.1\n>\n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net\n\t[217.70.183.198])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 64C186040E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 27 Mar 2020 09:48:54 +0100 (CET)","from uno.localdomain (2-224-242-101.ip172.fastwebnet.it\n\t[2.224.242.101]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay6-d.mail.gandi.net (Postfix) with ESMTPSA id CDDF5C0009;\n\tFri, 27 Mar 2020 08:48:53 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","Date":"Fri, 27 Mar 2020 09:51:53 +0100","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200327085153.6mzkg7n5txnzei5i@uno.localdomain>","References":"<20200326225844.4117712-1-niklas.soderlund@ragnatech.se>\n\t<20200326225844.4117712-4-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20200326225844.4117712-4-niklas.soderlund@ragnatech.se>","Subject":"Re: [libcamera-devel] [PATCH v2 3/7] 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":"Fri, 27 Mar 2020 08:48:54 -0000"}},{"id":4333,"web_url":"https://patchwork.libcamera.org/comment/4333/","msgid":"<20200327093537.GB5040@pendragon.ideasonboard.com>","date":"2020-03-27T09:35:37","subject":"Re: [libcamera-devel] [PATCH v2 3/7] include: drm_fourcc: Add Bayer\n\tFourCC and modifiers","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nOn Fri, Mar 27, 2020 at 09:51:53AM +0100, Jacopo Mondi wrote:\n> On Thu, Mar 26, 2020 at 11:58:40PM +0100, Niklas Söderlund wrote:\n> > Add Bayer format and modifiers for patch submitted for upstream\n> > inclusion. The formats have not been accepted upstream yet but is needed\n> > to progress with RAW capture support in libcamera.\n> >\n> > Intention is to merge this in libcamera and update the header file the\n> > upstream patch is picked up upstream.\n> \n> Just wondering if this needs a notice somewhere that this is a\n> temporary version.\n\nI'm fine keeping that in the git history, as otherwise it would remind\nme of the amazing coding style I've seen way too often where developers\ntag lines of code with comments stating who changed them last :-)\n\n> With or without this\n> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\nAcked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> > Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> > ---\n> > * Changes since v1\n> > - Removed DNI label\n> > ---\n> >  include/linux/drm_fourcc.h | 94 ++++++++++++++++++++++++++++++++++++++\n> >  1 file changed, 94 insertions(+)\n> >\n> > diff --git a/include/linux/drm_fourcc.h b/include/linux/drm_fourcc.h\n> > index 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","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 5E4FB6040E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 27 Mar 2020 10:35:41 +0100 (CET)","from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C6C502DC;\n\tFri, 27 Mar 2020 10:35:40 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"BXxyzMT7\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1585301741;\n\tbh=PgtED/yXwdA3ZpTJ1JdTqMLeQUpT6PhD/Zq9f+oYqfc=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=BXxyzMT7ss/O6tY5Ykbf4yuUj8isEa2j9+J3yS18sW1yAxmxjSoP2kSbb0PEqX9qO\n\tw+B6K/ysH0cHcLmGXTQjTzQp7o3jGxXGFZRLO5LZ/ziZE4eKQ/FOS0A2GyiPaQ4ubh\n\ts4c0wraO989cRxjZz0xG8ns6kx+0cIXnUPeWU+48=","Date":"Fri, 27 Mar 2020 11:35:37 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>,\n\tlibcamera-devel@lists.libcamera.org","Message-ID":"<20200327093537.GB5040@pendragon.ideasonboard.com>","References":"<20200326225844.4117712-1-niklas.soderlund@ragnatech.se>\n\t<20200326225844.4117712-4-niklas.soderlund@ragnatech.se>\n\t<20200327085153.6mzkg7n5txnzei5i@uno.localdomain>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20200327085153.6mzkg7n5txnzei5i@uno.localdomain>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v2 3/7] 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":"Fri, 27 Mar 2020 09:35:41 -0000"}}]