[{"id":4896,"web_url":"https://patchwork.libcamera.org/comment/4896/","msgid":"<20200525103143.GF7618@paasikivi.fi.intel.com>","date":"2020-05-25T10:31:43","subject":"Re: [libcamera-devel] [PATCH v2] drm/fourcc: Add bayer formats and\n\tmodifiers","submitter":{"id":37,"url":"https://patchwork.libcamera.org/api/people/37/","name":"Sakari Ailus","email":"sakari.ailus@linux.intel.com"},"content":"Hi Niklas,\n\nThank you for the update.\n\nOn Fri, May 22, 2020 at 01:52:01AM +0200, Niklas Söderlund wrote:\n> Bayer formats are used with cameras and contain green, red and blue\n> components, with alternating lines of red and green, and blue and green\n> pixels in different orders. For each block of 2x2 pixels there is one\n> pixel with a red filter, two with a green filter, and one with a blue\n> filter. The filters can be arranged in different patterns.\n> \n> Add DRM fourcc formats to describe the most common Bayer formats. Also\n> add a modifiers to describe the custom packing layouts used by the Intel\n> IPU3 and in the MIPI (Mobile Industry Processor Interface) CSI-2\n> specification.\n> \n> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> ---\n> * Changes since v1\n> - Rename the defines from DRM_FORMAT_SRGGB8 to DRM_FORMAT_BAYER_RGGB8.\n> - Update the fourcc codes passed to fourcc_code() to avoid a conflict.\n> - Add diagrams for all Bayer formats memory layout.\n> - Update documentation.\n> ---\n>  include/uapi/drm/drm_fourcc.h | 205 ++++++++++++++++++++++++++++++++++\n>  1 file changed, 205 insertions(+)\n> \n> diff --git a/include/uapi/drm/drm_fourcc.h b/include/uapi/drm/drm_fourcc.h\n> index 8bc0b31597d80737..d07dd24b49bde6c1 100644\n> --- a/include/uapi/drm/drm_fourcc.h\n> +++ b/include/uapi/drm/drm_fourcc.h\n> @@ -285,6 +285,73 @@ extern \"C\" {\n>  #define DRM_FORMAT_YUV444\tfourcc_code('Y', 'U', '2', '4') /* non-subsampled Cb (1) and Cr (2) planes */\n>  #define DRM_FORMAT_YVU444\tfourcc_code('Y', 'V', '2', '4') /* non-subsampled Cr (1) and Cb (2) planes */\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> + *\trow2: RGRGRGRG...\n> + *\trow3: GBGBGBGB...\n> + *\t...\n> + *\n> + * Vendors have different methods to pack the pixel samples. For this reason the\n> + * fourcc only describes pixel sample size and the filter pattern for each block\n> + * of 2x2 pixels. A modifier is needed to 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 each sample is stored\n> + * in the minimum number of bytes required. Any unused bits in each sample are\n> + * defined as padding bits and set to zero.\n> + *\n> + * For example, DRM_FORMAT_BAYER_RGGB10 with DRM_FORMAT_MOD_LINEAR:\n> + *\n> + *  0                                              row 0 (RGRG)                                            31\n> + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> + *  | r0 r0 r0 r0 r0 r0 r0 r0 |  0  0  0  0  0  0 r0 r0 | g0 g0 g0 g0 g0 g0 g0 g0 |  0  0  0  0  0  0 g0 g0 |\n> + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> + *  | r1 r1 r1 r1 r1 r1 r1 r1 |  0  0  0  0  0  0 r1 r1 | g1 g1 g1 g1 g1 g1 g1 g1 |  0  0  0  0  0  0 g1 g1 |\n> + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> + *\n> + *  0                                              row 1 (GBGB)                                            31\n> + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> + *  | g0 g0 g0 g0 g0 g0 g0 g0 |  0  0  0  0  0  0 g0 g0 | b0 b0 b0 b0 b0 b0 b0 b0 |  0  0  0  0  0  0 b0 b0 |\n> + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> + *  | g1 g1 g1 g1 g1 g1 g1 g1 |  0  0  0  0  0  0 g1 g1 | b1 b1 b1 b1 b1 b1 b1 b1 |  0  0  0  0  0  0 b1 b1 |\n> + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> + */\n> +\n> +/* 8-bits Bayer formats */\n> +#define DRM_FORMAT_BAYER_RGGB8\t\tfourcc_code('R', 'G', 'G', 'B')\n> +#define DRM_FORMAT_BAYER_GRBG8\t\tfourcc_code('G', 'R', 'B', 'G')\n> +#define DRM_FORMAT_BAYER_GBRG8\t\tfourcc_code('G', 'B', 'R', 'G')\n> +#define DRM_FORMAT_BAYER_BGGR8\t\tfourcc_code('B', 'G', 'G', 'R')\n> +\n> +/* 10-bit Bayer formats */\n> +#define DRM_FORMAT_BAYER_RGGB10\t\tfourcc_code('R', 'G', '1', '0')\n> +#define DRM_FORMAT_BAYER_GRBG10\t\tfourcc_code('G', 'R', '1', '0')\n> +#define DRM_FORMAT_BAYER_GBRG10\t\tfourcc_code('G', 'B', '1', '0')\n> +#define DRM_FORMAT_BAYER_BGGR10\t\tfourcc_code('B', 'G', '1', '0')\n> +\n> +/* 12-bit Bayer formats */\n> +#define DRM_FORMAT_BAYER_RGGB12\t\tfourcc_code('R', 'G', '1', '2')\n> +#define DRM_FORMAT_BAYER_GRBG12\t\tfourcc_code('G', 'R', '1', '2')\n> +#define DRM_FORMAT_BAYER_GBRG12\t\tfourcc_code('G', 'B', '1', '2')\n> +#define DRM_FORMAT_BAYER_BGGR12\t\tfourcc_code('B', 'G', '1', '2')\n> +\n> +/* 14-bit Bayer formats */\n> +#define DRM_FORMAT_BAYER_RGGB14\t\tfourcc_code('R', 'G', '1', '4')\n> +#define DRM_FORMAT_BAYER_GRBG14\t\tfourcc_code('G', 'R', '1', '4')\n> +#define DRM_FORMAT_BAYER_GBRG14\t\tfourcc_code('G', 'B', '1', '4')\n> +#define DRM_FORMAT_BAYER_BGGR14\t\tfourcc_code('B', 'G', '1', '4')\n> +\n>  \n>  /*\n>   * Format Modifiers:\n> @@ -309,6 +376,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\nThis is an interesting one. I don't think these formats have originated\nfrom MIPI. The colour pattern itself is from Eastman Kodak apparently\n(named after Bryce Bayer), but the memory format is not, apart from the\nMIPI CSI-2 packed variant.\n\nThe formats are probably unlike the formats used on GPUs as they are\nrelatively similar across a number of vendors and devices.\n\nThere are more raw formats than just the Bayer formats, see e.g.\n\n<URL:https://en.wikipedia.org/wiki/Raw_image_format>\n\nAt the same time, it'd be good to keep the CSI-2 packed variant as a format\nmodifier. I wonder if we could have something like\nDRM_FORMAT_MOD_VENDOR_RAW, albeit a raw format is not a vendor.\n\nCc Daniel and Laurent.\n\n>  \n>  /* add more to the end as needed */\n>  \n> @@ -434,6 +502,56 @@ extern \"C\" {\n>   */\n>  #define I915_FORMAT_MOD_Y_TILED_GEN12_MC_CCS fourcc_mod_code(INTEL, 7)\n>  \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 zero padding bits.\n> + *\n> + * For example, DRM_FORMAT_BAYER_BGGR10 with IPU3_FORMAT_MOD_PACKED:\n> + *\n> + *  0                                   row 0 (BGBGBGBGBGBGBGBGBGBGBGBGB)                                  31\n> + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> + *  | b0 b0 b0 b0 b0 b0 b0 b0 | g0 g0 g0 g0 g0 g0 b0 b0 | b1 b1 b1 b1 g0 g0 g0 g0 | g1 g1 b1 b1 b1 b1 b1 b1 |\n> + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> + *  | g1 g1 g1 g1 g1 g1 g1 g1 | b2 b2 b2 b2 b2 b2 b2 b2 | g2 g2 g2 g2 g2 g2 b2 b2 | b3 b3 b3 b3 g2 g2 g2 g2 |\n> + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> + *  | g3 g3 b3 b3 b3 b3 b3 b3 | g3 g3 g3 g3 g3 g3 g3 g3 | b4 b4 b4 b4 b4 b4 b4 b4 | g4 g4 g4 g4 g4 g4 b4 b4 |\n> + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> + *  | b5 b5 b5 b5 g4 g4 g4 g4 | g5 g5 b5 b5 b5 b5 b5 b5 | g5 g5 g5 g5 g5 g5 g5 g5 | b6 b6 b6 b6 b6 b6 b6 b6 |\n> + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> + *  | g6 g6 g6 g6 g6 g6 b6 b6 | b7 b7 b7 b7 g6 g6 g6 g6 | g7 g7 b7 b7 b7 b7 b7 b7 | g7 g7 g7 g7 g7 g7 g7 g7 |\n> + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> + *  | b8 b8 b8 b8 b8 b8 b8 b8 | g8 g8 g8 g8 g8 g8 b8 b8 | b9 b9 b9 b9 g8 g8 g8 g8 | g9 g9 b9 b9 b9 b9 b9 b9 |\n> + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> + *  | g9 g9 g9 g9 g9 g9 g9 g9 | bA bA bA bA bA bA bA bA | gA gA gA gA gA gA bA bA | bB bB bB bB gA gA gA gA |\n> + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> + *  | gB gB bB bB bB bB bB bB | gB gB gB gB gB gB gB gB | bC bC bC bC bC bC bC bC |  0  0  0  0  0  0 bC bC |\n> + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> + *\n> + *  0                                   row 1 (GRGRGRGRGRGRGRGRGRGRGRGRG)                                  31\n> + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> + *  | g0 g0 g0 g0 g0 g0 g0 g0 | r0 r0 r0 r0 r0 r0 g0 g0 | g1 g1 g1 g1 r0 r0 r0 r0 | r1 r1 g1 g1 g1 g1 g1 g1 |\n> + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> + *  | r1 r1 r1 r1 r1 r1 r1 r1 | g2 g2 g2 g2 g2 g2 g2 g2 | r2 r2 r2 r2 r2 r2 g2 g2 | g3 g3 g3 g3 r2 r2 r2 r2 |\n> + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> + *  | r3 r3 g3 g3 g3 g3 g3 g3 | r3 r3 r3 r3 r3 r3 r3 r3 | g4 g4 g4 g4 g4 g4 g4 g4 | r4 r4 r4 r4 r4 r4 g4 g4 |\n> + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> + *  | g5 g5 g5 g5 r4 r4 r4 r4 | r5 r5 g5 g5 g5 g5 g5 g5 | r5 r5 r5 r5 r5 r5 r5 r5 | g6 g6 g6 g6 g6 g6 g6 g6 |\n> + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> + *  | r6 r6 r6 r6 r6 r6 g6 g6 | g7 g7 g7 g7 r6 r6 r6 r6 | r7 r7 g7 g7 g7 g7 g7 g7 | r7 r7 r7 r7 r7 r7 r7 r7 |\n> + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> + *  | g8 g8 g8 g8 g8 g8 g8 g8 | r8 r8 r8 r8 r8 r8 g8 g8 | g9 g9 g9 g9 r8 r8 r8 r8 | r9 r9 g9 g9 g9 g9 g9 g9 |\n> + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> + *  | r9 r9 r9 r9 r9 r9 r9 r9 | gA gA gA gA gA gA gA gA | rA rA rA rA rA rA gA gA | gB gB gB gB rA rA rA rA |\n> + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> + *  | rB rB gB gB gB gB gB gB | rB rB rB rB rB rB rB rB | gC gC gC gC gC gC gC gC |  0  0  0  0  0  0 gC gC |\n> + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\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> @@ -804,6 +922,93 @@ 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> + * depending 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> + *   For example, DRM_FORMAT_BAYER_BGGR10 with MIPI_FORMAT_MOD_CSI2_PACKED:\n> + *\n> + *    0                                            row 0 (BGBGBGBG)                                          31\n> + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> + *    | b0 b0 b0 b0 b0 b0 b0 b0 | g0 g0 g0 g0 g0 g0 g0 g0 | b1 b1 b1 b1 b1 b1 b1 b1 | g1 g1 g1 g1 g1 g1 g1 g1 |\n> + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> + *    | g1 g1 b1 b1 g0 g0 b0 b0 | b2 b2 b2 b2 b2 b2 b2 b2 | g2 g2 g2 g2 g2 g2 g2 g2 | b3 b3 b3 b3 b3 b3 b3 b3 |\n> + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> + *    | g3 g3 g3 g3 g3 g3 g3 g3 | g3 g3 b3 b3 g2 g2 b2 b2 |\n> + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> + *\n> + *    0                                            row 1 (GRGRGRGR)                                          31\n> + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> + *    | g0 g0 g0 g0 g0 g0 g0 g0 | r0 r0 r0 r0 r0 r0 r0 r0 | g1 g1 g1 g1 g1 g1 g1 g1 | r1 r1 r1 r1 r1 r1 r1 r1 |\n> + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> + *    | r1 r1 g1 g1 r0 r0 g0 g0 | g2 g2 g2 g2 g2 g2 g2 g2 | r2 r2 r2 r2 r2 r2 r2 r2 | g3 g3 g3 g3 g3 g3 g3 g3 |\n> + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> + *    | r3 r3 r3 r3 r3 r3 r3 r3 | r3 r3 g3 g3 r2 r2 g2 g2 |\n> + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\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> + *   For example, DRM_FORMAT_BAYER_GRBG12 with MIPI_FORMAT_MOD_CSI2_PACKED:\n> + *\n> + *    0                                              row 0 (GRGR)                                            31\n> + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> + *    | g0 g0 g0 g0 g0 g0 g0 g0 | r0 r0 r0 r0 r0 r0 r0 r0 | r0 r0 r0 r0 g0 g0 g0 g0 | g1 g1 g1 g1 g1 g1 g1 g1 |\n> + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> + *    | r1 r1 r1 r1 r1 r1 r1 r1 | r1 r1 r1 r1 g1 g1 g1 g1 |\n> + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> + *\n> + *    0                                              row 1 (BGBG)                                            31\n> + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> + *    | b0 b0 b0 b0 b0 b0 b0 b0 | g0 g0 g0 g0 g0 g0 g0 g0 | g0 g0 g0 g0 b0 b0 b0 b0 | b1 b1 b1 b1 b1 b1 b1 b1 |\n> + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> + *    | g1 g1 g1 g1 g1 g1 g1 g1 | g1 g1 g1 g1 b1 b1 b1 b1 |\n> + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\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> + *   For example, DRM_FORMAT_BAYER_GBRG14 with MIPI_FORMAT_MOD_CSI2_PACKED:\n> + *\n> + *    0                                            row 0 (GBGBGBGB)                                          31\n> + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> + *    | g0 g0 g0 g0 g0 g0 g0 g0 | b0 b0 b0 b0 b0 b0 b0 b0 | g1 g1 g1 g1 g1 g1 g1 g1 | b1 b1 b1 b1 b1 b1 b1 b1 |\n> + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> + *    | b0 b0 g0 g0 g0 g0 g0 g0 | g1 g1 g1 g1 b0 b0 b0 b0 | b1 b1 b1 b1 b1 b1 g1 g1 | g2 g2 g2 g2 g2 g2 g2 g2 |\n> + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> + *    | b2 b2 b2 b2 b2 b2 b2 b2 | g3 g3 g3 g3 g3 g3 g3 g3 | b3 b3 b3 b3 b3 b3 b3 b3 | b2 b2 g2 g2 g2 g2 g2 g2 |\n> + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> + *    | g3 g3 g3 g3 b2 b2 b2 b2 | b3 b3 b3 b3 b3 b3 g3 g3 |\n> + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> + *\n> + *    0                                            row 1 (RGRGRGRG)                                          31\n> + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> + *    | r0 r0 r0 r0 r0 r0 r0 r0 | g0 g0 g0 g0 g0 g0 g0 g0 | r1 r1 r1 r1 r1 r1 r1 r1 | g1 g1 g1 g1 g1 g1 g1 g1 |\n> + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> + *    | g0 g0 r0 r0 r0 r0 r0 r0 | r1 r1 r1 r1 g0 g0 g0 g0 | g1 g1 g1 g1 g1 g1 r1 r1 | r2 r2 r2 r2 r2 r2 r2 r2 |\n> + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> + *    | g2 g2 g2 g2 g2 g2 g2 g2 | r3 r3 r3 r3 r3 r3 r3 r3 | g3 g3 g3 g3 g3 g3 g3 g3 | g2 g2 r2 r2 r2 r2 r2 r2 |\n> + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> + *    | r3 r3 r3 r3 g2 g2 g2 g2 | g3 g3 g3 g3 g3 g3 r3 r3 |\n> + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> + */\n> +#define MIPI_FORMAT_MOD_CSI2_PACKED fourcc_mod_code(MIPI, 1)\n> +\n>  #if defined(__cplusplus)\n>  }\n>  #endif","headers":{"Return-Path":"<sakari.ailus@linux.intel.com>","Received":["from mga14.intel.com (mga14.intel.com [192.55.52.115])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2246A603D4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 25 May 2020 12:31:52 +0200 (CEST)","from fmsmga007.fm.intel.com ([10.253.24.52])\n\tby fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; \n\t25 May 2020 03:31:47 -0700","from paasikivi.fi.intel.com ([10.237.72.42])\n\tby fmsmga007-auth.fm.intel.com with\n\tESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 May 2020 03:31:45 -0700","by paasikivi.fi.intel.com (Postfix, from userid 1000)\n\tid 938E120953; Mon, 25 May 2020 13:31:43 +0300 (EEST)"],"IronPort-SDR":["EhemmnWsj52PDqv9SR/68Bt2iFzK4QxrFdy7F4Gbd1RJtZ8hucvf9wbyJl/0KbxtILFzo6r5Dd\n\tDRkco6qE+tVg==","fpRcIT3ZgbJqWnNHi/xrLLC8/GumvLWmSB39fBHAcgOt6vtv1rYqYzkAvYdCW+Zi8VMrDTFuvl\n\tvf24HtvCkr4w=="],"X-Amp-Result":"SKIPPED(no attachment in message)","X-Amp-File-Uploaded":"False","X-IronPort-AV":"E=Sophos;i=\"5.73,433,1583222400\"; d=\"scan'208\";a=\"254873662\"","Date":"Mon, 25 May 2020 13:31:43 +0300","From":"Sakari Ailus <sakari.ailus@linux.intel.com>","To":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","Cc":"dri-devel@lists.freedesktop.org, libcamera-devel@lists.libcamera.org,\n\tDaniel Vetter <daniel@ffwll.ch>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<20200525103143.GF7618@paasikivi.fi.intel.com>","References":"<20200521235201.279642-1-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20200521235201.279642-1-niklas.soderlund@ragnatech.se>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v2] drm/fourcc: Add bayer formats and\n\tmodifiers","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":"Mon, 25 May 2020 10:31:53 -0000"}},{"id":4939,"web_url":"https://patchwork.libcamera.org/comment/4939/","msgid":"<CACvgo50SNourym-gBG1s2UxiD4M96=rMfcd7_y=643BgveRhVg@mail.gmail.com>","date":"2020-05-28T15:36:59","subject":"Re: [libcamera-devel] [PATCH v2] drm/fourcc: Add bayer formats and\n\tmodifiers","submitter":{"id":50,"url":"https://patchwork.libcamera.org/api/people/50/","name":"Emil Velikov","email":"emil.l.velikov@gmail.com"},"content":"Hi Niklas,\n\nOn Fri, 22 May 2020 at 07:56, Niklas Söderlund\n<niklas.soderlund@ragnatech.se> wrote:\n>\n> Bayer formats are used with cameras and contain green, red and blue\n> components, with alternating lines of red and green, and blue and green\n> pixels in different orders. For each block of 2x2 pixels there is one\n> pixel with a red filter, two with a green filter, and one with a blue\n> filter. The filters can be arranged in different patterns.\n>\n> Add DRM fourcc formats to describe the most common Bayer formats. Also\n> add a modifiers to describe the custom packing layouts used by the Intel\n> IPU3 and in the MIPI (Mobile Industry Processor Interface) CSI-2\n> specification.\n>\n> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> ---\n> * Changes since v1\n> - Rename the defines from DRM_FORMAT_SRGGB8 to DRM_FORMAT_BAYER_RGGB8.\n> - Update the fourcc codes passed to fourcc_code() to avoid a conflict.\n> - Add diagrams for all Bayer formats memory layout.\n> - Update documentation.\n> ---\n>  include/uapi/drm/drm_fourcc.h | 205 ++++++++++++++++++++++++++++++++++\n>  1 file changed, 205 insertions(+)\n>\nWhere is the user for these new formats - be that kernel or userspace?\nDid you forget to update the __drm_format_info() in\ndrivers/gpu/drm/drm_fourcc.c?\n\n-Emil","headers":{"Return-Path":"<emil.l.velikov@gmail.com>","Received":["from mail-vs1-xe42.google.com (mail-vs1-xe42.google.com\n\t[IPv6:2607:f8b0:4864:20::e42])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7BAC4603D3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 28 May 2020 17:40:08 +0200 (CEST)","by mail-vs1-xe42.google.com with SMTP id y123so255944vsb.6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 28 May 2020 08:40:08 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"YvS3gvZV\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc:content-transfer-encoding;\n\tbh=GDRa4RFDTWP8hbxoyrpsGnSp7hiJz6RTAPpCucQo+Ss=;\n\tb=YvS3gvZVh552xy2rAQ2BrmAATmPxg+EwB3F1pNEpPTjjX1NVJFy+EB0NbxSgk04VyF\n\tIugWO24iSIrmJkpYdvOCvuzCfqM6iiIkHdpeeRTvFZDa3dqf1CiIKKT1c9FT8tq8f4y7\n\teUsYD62qf+RhBl+ELOIK2W6h7fLnk6zOXrhCPiMddaXAztvrrhK+9nhlZwLXI3DOPvYq\n\tOsRqlmdKQJFLT7vNIUXHFkV6tYLkKYzCRccd2vNmqAiu/U+EMS5oRhnDQ0DpqOKgvCOi\n\tBgVEzHPfdWwU+biIPX1qVzFqd0srFVBdArGherdSJl0AB95Es77EJwvzTvKmGuw4vL1b\n\tt4lw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc:content-transfer-encoding;\n\tbh=GDRa4RFDTWP8hbxoyrpsGnSp7hiJz6RTAPpCucQo+Ss=;\n\tb=CYLOWHrAr7QntW1s6n7bTYzbBwadtJocBxy0CpbogJbsTpTfj1J4ikcQu4zgp4EG9A\n\tyaeAbYHnNyuu3xkMxWHrWSAFHhHgtd+gqDzqgApbabfvwTLJPTJxneBhpvcS9G6HDz9r\n\tQKrDGSQTFgymbLPaJuWMpEQml3JRn38NghwK7b9bQbNdL5W93f4/++P/bZc1gjnN/Xum\n\tImwANATMAAcZwq7JMzmhb8QbFjex2aTFgLJKBREtb4Zpsf65TglN11YT54OSYx1YUGL6\n\tJoIGMIlavieYnd8U+jYs0b32r0ouRCN4Ac5cC0yqBD8WlZKE5xiie7KbcsjHjUBh7P8H\n\tVqyQ==","X-Gm-Message-State":"AOAM530ovkV3yQGCZcZFT+sZA2JJov8iJ1YiRku1bhrJiujygzcj9wfk\n\tKmZDvEcrS64eUXD9gHUOC/urIezaq5fjGTiJxi4=","X-Google-Smtp-Source":"ABdhPJwJbPSa9xbNBiA5RnvLR6pCaUvIFS7NpCDxidbFS+sok/TiB1CTjGS95VncSGeNOrNjVB4u2ea57MJFcW3sK9Y=","X-Received":"by 2002:a67:b149:: with SMTP id z9mr1910559vsl.85.1590680407296; \n\tThu, 28 May 2020 08:40:07 -0700 (PDT)","MIME-Version":"1.0","References":"<20200521235201.279642-1-niklas.soderlund@ragnatech.se>","In-Reply-To":"<20200521235201.279642-1-niklas.soderlund@ragnatech.se>","From":"Emil Velikov <emil.l.velikov@gmail.com>","Date":"Thu, 28 May 2020 16:36:59 +0100","Message-ID":"<CACvgo50SNourym-gBG1s2UxiD4M96=rMfcd7_y=643BgveRhVg@mail.gmail.com>","To":"=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Cc":"ML dri-devel <dri-devel@lists.freedesktop.org>,\n\tlibcamera-devel@lists.libcamera.org, \n\tSakari Ailus <sakari.ailus@linux.intel.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Content-Transfer-Encoding":"quoted-printable","Subject":"Re: [libcamera-devel] [PATCH v2] drm/fourcc: Add bayer formats and\n\tmodifiers","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":"Thu, 28 May 2020 15:40:08 -0000"}},{"id":5285,"web_url":"https://patchwork.libcamera.org/comment/5285/","msgid":"<20200619130655.GB241696@chromium.org>","date":"2020-06-19T13:06:55","subject":"Re: [libcamera-devel] [PATCH v2] drm/fourcc: Add bayer formats and\n\tmodifiers","submitter":{"id":9,"url":"https://patchwork.libcamera.org/api/people/9/","name":"Tomasz Figa","email":"tfiga@chromium.org"},"content":"Hi Niklas,\n\nOn Fri, May 22, 2020 at 01:52:01AM +0200, Niklas Söderlund wrote:\n> Bayer formats are used with cameras and contain green, red and blue\n> components, with alternating lines of red and green, and blue and green\n> pixels in different orders. For each block of 2x2 pixels there is one\n> pixel with a red filter, two with a green filter, and one with a blue\n> filter. The filters can be arranged in different patterns.\n> \n> Add DRM fourcc formats to describe the most common Bayer formats. Also\n> add a modifiers to describe the custom packing layouts used by the Intel\n> IPU3 and in the MIPI (Mobile Industry Processor Interface) CSI-2\n> specification.\n> \n> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> ---\n> * Changes since v1\n> - Rename the defines from DRM_FORMAT_SRGGB8 to DRM_FORMAT_BAYER_RGGB8.\n> - Update the fourcc codes passed to fourcc_code() to avoid a conflict.\n> - Add diagrams for all Bayer formats memory layout.\n> - Update documentation.\n> ---\n>  include/uapi/drm/drm_fourcc.h | 205 ++++++++++++++++++++++++++++++++++\n>  1 file changed, 205 insertions(+)\n> \n> diff --git a/include/uapi/drm/drm_fourcc.h b/include/uapi/drm/drm_fourcc.h\n> index 8bc0b31597d80737..d07dd24b49bde6c1 100644\n> --- a/include/uapi/drm/drm_fourcc.h\n> +++ b/include/uapi/drm/drm_fourcc.h\n> @@ -285,6 +285,73 @@ extern \"C\" {\n>  #define DRM_FORMAT_YUV444\tfourcc_code('Y', 'U', '2', '4') /* non-subsampled Cb (1) and Cr (2) planes */\n>  #define DRM_FORMAT_YVU444\tfourcc_code('Y', 'V', '2', '4') /* non-subsampled Cr (1) and Cb (2) planes */\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> + *\trow2: RGRGRGRG...\n> + *\trow3: GBGBGBGB...\n> + *\t...\n> + *\n\nI wonder if we're operating on the right level of abstraction within this\nproposal.\n\nThe sensor itself transfers only sequential pixels, as read\nout from its matrix. Whether a given pixel corresponds to a red, green\nor blue color filter actually depends on the filter layer, which could\nactually vary between integrations of the same sensor. (See Fujifilm\nX-Trans, which uses regular Sony sensors with their own filter pattern\n[1].)\n\nMoreover, the sensor resolution is specified as the number of pixels\nhorizontally and the number of lines horizontally, without considering\nthe color pattern.\n\nIf we consider that, wouldn't the data stream coming from the sensor be\nessentially DRM_FORMAT_R8/R10/R12/etc.?\n\nThen, on top of that, we would have the packing, which I believe is\ndefined well in this document +/- being entangled with the Bayer\npattern.\n\nWhat do you think?\n\n[1] https://en.wikipedia.org/wiki/Fujifilm_X-Trans_sensor\n\nBest regards,\nTomasz","headers":{"Return-Path":"<tfiga@chromium.org>","Received":["from mail-wr1-x443.google.com (mail-wr1-x443.google.com\n\t[IPv6:2a00:1450:4864:20::443])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DDC3C600FE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 19 Jun 2020 15:06:58 +0200 (CEST)","by mail-wr1-x443.google.com with SMTP id o11so1918941wrv.9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 19 Jun 2020 06:06:58 -0700 (PDT)","from chromium.org (205.215.190.35.bc.googleusercontent.com.\n\t[35.190.215.205]) by smtp.gmail.com with ESMTPSA id\n\tx5sm1585452wmg.2.2020.06.19.06.06.56\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 19 Jun 2020 06:06:56 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=chromium.org\n\theader.i=@chromium.org header.b=\"M3Voe848\"; \n\tdkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to;\n\tbh=6ZcsGijeFBjmFWeyCrYME8fKNYJdrkpJbfctPNEZWTM=;\n\tb=M3Voe848STIMHx22PtbPlsyjMRtGu7vwUDyCTxUf5RjyYaIQw6jwzXL5Ny+sVYsjna\n\t/PhoxB46c7yvxRufeZBzC38JB+0jkjl1eXKYRoc3/AlR9dODi6aROqG22I7ZF9tSIBOK\n\tPXwEY6LuGdlET+y+GyzDTwhSAR4NT1RY4r0CA=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to;\n\tbh=6ZcsGijeFBjmFWeyCrYME8fKNYJdrkpJbfctPNEZWTM=;\n\tb=ohXzJb70f6jpmQ0w3cw+jkuMtZZ0uKHHos6OgAiEkTKcWUwp35HLXkcucXvdHlNuez\n\tkXzJyIVTmE5/mk+9urp67jwO2FY4tWHspYDDBoqp7JTNP7rX3HZY2guCyrQbYAg6jtCP\n\toT39qTz5vmCqEBzjigNWKDih+m5aJTnqLf4kesCR07JGnthRucT+WIKoIGeiHniguHyl\n\tlvYSFp2FudaZxwgRz6U68bRQq5zL/G7Xx+MoEAD7AUPQRce8VFH0rs+9xeIUomEg7awY\n\tbDM03w4qp6M4Fs1HqYsj18k45xKnm07QTJ5fQF2rEElyvgeTZxD3+qbiTxYDb33fl7yd\n\tVSDQ==","X-Gm-Message-State":"AOAM5315XccTtYdzoj6DDEXs64/NiemmNZwsY9I7zwuvqbbLJqaOomIc\n\tnFnSd8Nj9bY6ZrtbP56Ojwpuog==","X-Google-Smtp-Source":"ABdhPJz0s+qIfPiYuc8Lb/5oTgaLOoIzxPjMvqf0zr4zeqAxjxDIqYXqcMBtiIrMcp62Jo53s0zktg==","X-Received":"by 2002:adf:8b18:: with SMTP id\n\tn24mr4251611wra.372.1592572017564; \n\tFri, 19 Jun 2020 06:06:57 -0700 (PDT)","Date":"Fri, 19 Jun 2020 13:06:55 +0000","From":"Tomasz Figa <tfiga@chromium.org>","To":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","Cc":"dri-devel@lists.freedesktop.org, libcamera-devel@lists.libcamera.org,\n\tSakari Ailus <sakari.ailus@linux.intel.com>","Message-ID":"<20200619130655.GB241696@chromium.org>","References":"<20200521235201.279642-1-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20200521235201.279642-1-niklas.soderlund@ragnatech.se>","Subject":"Re: [libcamera-devel] [PATCH v2] drm/fourcc: Add bayer formats and\n\tmodifiers","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, 19 Jun 2020 13:06:59 -0000"}},{"id":11088,"web_url":"https://patchwork.libcamera.org/comment/11088/","msgid":"<20200702215155.GU12562@pendragon.ideasonboard.com>","date":"2020-07-02T21:51:55","subject":"Re: [libcamera-devel] [PATCH v2] drm/fourcc: Add bayer formats and\n\tmodifiers","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Sakari,\n\nOn Mon, May 25, 2020 at 01:31:43PM +0300, Sakari Ailus wrote:\n> On Fri, May 22, 2020 at 01:52:01AM +0200, Niklas Söderlund wrote:\n> > Bayer formats are used with cameras and contain green, red and blue\n> > components, with alternating lines of red and green, and blue and green\n> > pixels in different orders. For each block of 2x2 pixels there is one\n> > pixel with a red filter, two with a green filter, and one with a blue\n> > filter. The filters can be arranged in different patterns.\n> > \n> > Add DRM fourcc formats to describe the most common Bayer formats. Also\n> > add a modifiers to describe the custom packing layouts used by the Intel\n> > IPU3 and in the MIPI (Mobile Industry Processor Interface) CSI-2\n> > specification.\n> > \n> > Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> > ---\n> > * Changes since v1\n> > - Rename the defines from DRM_FORMAT_SRGGB8 to DRM_FORMAT_BAYER_RGGB8.\n> > - Update the fourcc codes passed to fourcc_code() to avoid a conflict.\n> > - Add diagrams for all Bayer formats memory layout.\n> > - Update documentation.\n> > ---\n> >  include/uapi/drm/drm_fourcc.h | 205 ++++++++++++++++++++++++++++++++++\n> >  1 file changed, 205 insertions(+)\n> > \n> > diff --git a/include/uapi/drm/drm_fourcc.h b/include/uapi/drm/drm_fourcc.h\n> > index 8bc0b31597d80737..d07dd24b49bde6c1 100644\n> > --- a/include/uapi/drm/drm_fourcc.h\n> > +++ b/include/uapi/drm/drm_fourcc.h\n> > @@ -285,6 +285,73 @@ extern \"C\" {\n> >  #define DRM_FORMAT_YUV444\tfourcc_code('Y', 'U', '2', '4') /* non-subsampled Cb (1) and Cr (2) planes */\n> >  #define DRM_FORMAT_YVU444\tfourcc_code('Y', 'V', '2', '4') /* non-subsampled Cr (1) and Cb (2) planes */\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> > + *\trow2: RGRGRGRG...\n> > + *\trow3: GBGBGBGB...\n> > + *\t...\n> > + *\n> > + * Vendors have different methods to pack the pixel samples. For this reason the\n> > + * fourcc only describes pixel sample size and the filter pattern for each block\n> > + * of 2x2 pixels. A modifier is needed to 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 each sample is stored\n> > + * in the minimum number of bytes required. Any unused bits in each sample are\n> > + * defined as padding bits and set to zero.\n> > + *\n> > + * For example, DRM_FORMAT_BAYER_RGGB10 with DRM_FORMAT_MOD_LINEAR:\n> > + *\n> > + *  0                                              row 0 (RGRG)                                            31\n> > + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> > + *  | r0 r0 r0 r0 r0 r0 r0 r0 |  0  0  0  0  0  0 r0 r0 | g0 g0 g0 g0 g0 g0 g0 g0 |  0  0  0  0  0  0 g0 g0 |\n> > + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> > + *  | r1 r1 r1 r1 r1 r1 r1 r1 |  0  0  0  0  0  0 r1 r1 | g1 g1 g1 g1 g1 g1 g1 g1 |  0  0  0  0  0  0 g1 g1 |\n> > + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> > + *\n> > + *  0                                              row 1 (GBGB)                                            31\n> > + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> > + *  | g0 g0 g0 g0 g0 g0 g0 g0 |  0  0  0  0  0  0 g0 g0 | b0 b0 b0 b0 b0 b0 b0 b0 |  0  0  0  0  0  0 b0 b0 |\n> > + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> > + *  | g1 g1 g1 g1 g1 g1 g1 g1 |  0  0  0  0  0  0 g1 g1 | b1 b1 b1 b1 b1 b1 b1 b1 |  0  0  0  0  0  0 b1 b1 |\n> > + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> > + */\n> > +\n> > +/* 8-bits Bayer formats */\n> > +#define DRM_FORMAT_BAYER_RGGB8\t\tfourcc_code('R', 'G', 'G', 'B')\n> > +#define DRM_FORMAT_BAYER_GRBG8\t\tfourcc_code('G', 'R', 'B', 'G')\n> > +#define DRM_FORMAT_BAYER_GBRG8\t\tfourcc_code('G', 'B', 'R', 'G')\n> > +#define DRM_FORMAT_BAYER_BGGR8\t\tfourcc_code('B', 'G', 'G', 'R')\n> > +\n> > +/* 10-bit Bayer formats */\n> > +#define DRM_FORMAT_BAYER_RGGB10\t\tfourcc_code('R', 'G', '1', '0')\n> > +#define DRM_FORMAT_BAYER_GRBG10\t\tfourcc_code('G', 'R', '1', '0')\n> > +#define DRM_FORMAT_BAYER_GBRG10\t\tfourcc_code('G', 'B', '1', '0')\n> > +#define DRM_FORMAT_BAYER_BGGR10\t\tfourcc_code('B', 'G', '1', '0')\n> > +\n> > +/* 12-bit Bayer formats */\n> > +#define DRM_FORMAT_BAYER_RGGB12\t\tfourcc_code('R', 'G', '1', '2')\n> > +#define DRM_FORMAT_BAYER_GRBG12\t\tfourcc_code('G', 'R', '1', '2')\n> > +#define DRM_FORMAT_BAYER_GBRG12\t\tfourcc_code('G', 'B', '1', '2')\n> > +#define DRM_FORMAT_BAYER_BGGR12\t\tfourcc_code('B', 'G', '1', '2')\n> > +\n> > +/* 14-bit Bayer formats */\n> > +#define DRM_FORMAT_BAYER_RGGB14\t\tfourcc_code('R', 'G', '1', '4')\n> > +#define DRM_FORMAT_BAYER_GRBG14\t\tfourcc_code('G', 'R', '1', '4')\n> > +#define DRM_FORMAT_BAYER_GBRG14\t\tfourcc_code('G', 'B', '1', '4')\n> > +#define DRM_FORMAT_BAYER_BGGR14\t\tfourcc_code('B', 'G', '1', '4')\n> > +\n> >  \n> >  /*\n> >   * Format Modifiers:\n> > @@ -309,6 +376,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> This is an interesting one. I don't think these formats have originated\n> from MIPI. The colour pattern itself is from Eastman Kodak apparently\n> (named after Bryce Bayer), but the memory format is not, apart from the\n> MIPI CSI-2 packed variant.\n> \n> The formats are probably unlike the formats used on GPUs as they are\n> relatively similar across a number of vendors and devices.\n> \n> There are more raw formats than just the Bayer formats, see e.g.\n> \n> <URL:https://en.wikipedia.org/wiki/Raw_image_format>\n> \n> At the same time, it'd be good to keep the CSI-2 packed variant as a format\n> modifier. I wonder if we could have something like\n> DRM_FORMAT_MOD_VENDOR_RAW, albeit a raw format is not a vendor.\n\nThe modifier defined with DRM_FORMAT_MOD_VENDOR_MIPI is meant to specify\nin-memory packing corresponding to how the RAW data is carried over\nCSI-2. That's why MIPI was picked as a name.\n\n> Cc Daniel and Laurent.\n> \n> >  /* add more to the end as needed */\n> >  \n> > @@ -434,6 +502,56 @@ extern \"C\" {\n> >   */\n> >  #define I915_FORMAT_MOD_Y_TILED_GEN12_MC_CCS fourcc_mod_code(INTEL, 7)\n> >  \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 zero padding bits.\n> > + *\n> > + * For example, DRM_FORMAT_BAYER_BGGR10 with IPU3_FORMAT_MOD_PACKED:\n> > + *\n> > + *  0                                   row 0 (BGBGBGBGBGBGBGBGBGBGBGBGB)                                  31\n> > + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> > + *  | b0 b0 b0 b0 b0 b0 b0 b0 | g0 g0 g0 g0 g0 g0 b0 b0 | b1 b1 b1 b1 g0 g0 g0 g0 | g1 g1 b1 b1 b1 b1 b1 b1 |\n> > + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> > + *  | g1 g1 g1 g1 g1 g1 g1 g1 | b2 b2 b2 b2 b2 b2 b2 b2 | g2 g2 g2 g2 g2 g2 b2 b2 | b3 b3 b3 b3 g2 g2 g2 g2 |\n> > + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> > + *  | g3 g3 b3 b3 b3 b3 b3 b3 | g3 g3 g3 g3 g3 g3 g3 g3 | b4 b4 b4 b4 b4 b4 b4 b4 | g4 g4 g4 g4 g4 g4 b4 b4 |\n> > + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> > + *  | b5 b5 b5 b5 g4 g4 g4 g4 | g5 g5 b5 b5 b5 b5 b5 b5 | g5 g5 g5 g5 g5 g5 g5 g5 | b6 b6 b6 b6 b6 b6 b6 b6 |\n> > + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> > + *  | g6 g6 g6 g6 g6 g6 b6 b6 | b7 b7 b7 b7 g6 g6 g6 g6 | g7 g7 b7 b7 b7 b7 b7 b7 | g7 g7 g7 g7 g7 g7 g7 g7 |\n> > + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> > + *  | b8 b8 b8 b8 b8 b8 b8 b8 | g8 g8 g8 g8 g8 g8 b8 b8 | b9 b9 b9 b9 g8 g8 g8 g8 | g9 g9 b9 b9 b9 b9 b9 b9 |\n> > + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> > + *  | g9 g9 g9 g9 g9 g9 g9 g9 | bA bA bA bA bA bA bA bA | gA gA gA gA gA gA bA bA | bB bB bB bB gA gA gA gA |\n> > + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> > + *  | gB gB bB bB bB bB bB bB | gB gB gB gB gB gB gB gB | bC bC bC bC bC bC bC bC |  0  0  0  0  0  0 bC bC |\n> > + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> > + *\n> > + *  0                                   row 1 (GRGRGRGRGRGRGRGRGRGRGRGRG)                                  31\n> > + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> > + *  | g0 g0 g0 g0 g0 g0 g0 g0 | r0 r0 r0 r0 r0 r0 g0 g0 | g1 g1 g1 g1 r0 r0 r0 r0 | r1 r1 g1 g1 g1 g1 g1 g1 |\n> > + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> > + *  | r1 r1 r1 r1 r1 r1 r1 r1 | g2 g2 g2 g2 g2 g2 g2 g2 | r2 r2 r2 r2 r2 r2 g2 g2 | g3 g3 g3 g3 r2 r2 r2 r2 |\n> > + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> > + *  | r3 r3 g3 g3 g3 g3 g3 g3 | r3 r3 r3 r3 r3 r3 r3 r3 | g4 g4 g4 g4 g4 g4 g4 g4 | r4 r4 r4 r4 r4 r4 g4 g4 |\n> > + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> > + *  | g5 g5 g5 g5 r4 r4 r4 r4 | r5 r5 g5 g5 g5 g5 g5 g5 | r5 r5 r5 r5 r5 r5 r5 r5 | g6 g6 g6 g6 g6 g6 g6 g6 |\n> > + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> > + *  | r6 r6 r6 r6 r6 r6 g6 g6 | g7 g7 g7 g7 r6 r6 r6 r6 | r7 r7 g7 g7 g7 g7 g7 g7 | r7 r7 r7 r7 r7 r7 r7 r7 |\n> > + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> > + *  | g8 g8 g8 g8 g8 g8 g8 g8 | r8 r8 r8 r8 r8 r8 g8 g8 | g9 g9 g9 g9 r8 r8 r8 r8 | r9 r9 g9 g9 g9 g9 g9 g9 |\n> > + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> > + *  | r9 r9 r9 r9 r9 r9 r9 r9 | gA gA gA gA gA gA gA gA | rA rA rA rA rA rA gA gA | gB gB gB gB rA rA rA rA |\n> > + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> > + *  | rB rB gB gB gB gB gB gB | rB rB rB rB rB rB rB rB | gC gC gC gC gC gC gC gC |  0  0  0  0  0  0 gC gC |\n> > + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\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> > @@ -804,6 +922,93 @@ 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> > + * depending 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> > + *   For example, DRM_FORMAT_BAYER_BGGR10 with MIPI_FORMAT_MOD_CSI2_PACKED:\n> > + *\n> > + *    0                                            row 0 (BGBGBGBG)                                          31\n> > + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> > + *    | b0 b0 b0 b0 b0 b0 b0 b0 | g0 g0 g0 g0 g0 g0 g0 g0 | b1 b1 b1 b1 b1 b1 b1 b1 | g1 g1 g1 g1 g1 g1 g1 g1 |\n> > + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> > + *    | g1 g1 b1 b1 g0 g0 b0 b0 | b2 b2 b2 b2 b2 b2 b2 b2 | g2 g2 g2 g2 g2 g2 g2 g2 | b3 b3 b3 b3 b3 b3 b3 b3 |\n> > + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> > + *    | g3 g3 g3 g3 g3 g3 g3 g3 | g3 g3 b3 b3 g2 g2 b2 b2 |\n> > + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> > + *\n> > + *    0                                            row 1 (GRGRGRGR)                                          31\n> > + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> > + *    | g0 g0 g0 g0 g0 g0 g0 g0 | r0 r0 r0 r0 r0 r0 r0 r0 | g1 g1 g1 g1 g1 g1 g1 g1 | r1 r1 r1 r1 r1 r1 r1 r1 |\n> > + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> > + *    | r1 r1 g1 g1 r0 r0 g0 g0 | g2 g2 g2 g2 g2 g2 g2 g2 | r2 r2 r2 r2 r2 r2 r2 r2 | g3 g3 g3 g3 g3 g3 g3 g3 |\n> > + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> > + *    | r3 r3 r3 r3 r3 r3 r3 r3 | r3 r3 g3 g3 r2 r2 g2 g2 |\n> > + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\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> > + *   For example, DRM_FORMAT_BAYER_GRBG12 with MIPI_FORMAT_MOD_CSI2_PACKED:\n> > + *\n> > + *    0                                              row 0 (GRGR)                                            31\n> > + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> > + *    | g0 g0 g0 g0 g0 g0 g0 g0 | r0 r0 r0 r0 r0 r0 r0 r0 | r0 r0 r0 r0 g0 g0 g0 g0 | g1 g1 g1 g1 g1 g1 g1 g1 |\n> > + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> > + *    | r1 r1 r1 r1 r1 r1 r1 r1 | r1 r1 r1 r1 g1 g1 g1 g1 |\n> > + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> > + *\n> > + *    0                                              row 1 (BGBG)                                            31\n> > + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> > + *    | b0 b0 b0 b0 b0 b0 b0 b0 | g0 g0 g0 g0 g0 g0 g0 g0 | g0 g0 g0 g0 b0 b0 b0 b0 | b1 b1 b1 b1 b1 b1 b1 b1 |\n> > + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> > + *    | g1 g1 g1 g1 g1 g1 g1 g1 | g1 g1 g1 g1 b1 b1 b1 b1 |\n> > + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\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> > + *   For example, DRM_FORMAT_BAYER_GBRG14 with MIPI_FORMAT_MOD_CSI2_PACKED:\n> > + *\n> > + *    0                                            row 0 (GBGBGBGB)                                          31\n> > + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> > + *    | g0 g0 g0 g0 g0 g0 g0 g0 | b0 b0 b0 b0 b0 b0 b0 b0 | g1 g1 g1 g1 g1 g1 g1 g1 | b1 b1 b1 b1 b1 b1 b1 b1 |\n> > + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> > + *    | b0 b0 g0 g0 g0 g0 g0 g0 | g1 g1 g1 g1 b0 b0 b0 b0 | b1 b1 b1 b1 b1 b1 g1 g1 | g2 g2 g2 g2 g2 g2 g2 g2 |\n> > + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> > + *    | b2 b2 b2 b2 b2 b2 b2 b2 | g3 g3 g3 g3 g3 g3 g3 g3 | b3 b3 b3 b3 b3 b3 b3 b3 | b2 b2 g2 g2 g2 g2 g2 g2 |\n> > + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> > + *    | g3 g3 g3 g3 b2 b2 b2 b2 | b3 b3 b3 b3 b3 b3 g3 g3 |\n> > + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> > + *\n> > + *    0                                            row 1 (RGRGRGRG)                                          31\n> > + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> > + *    | r0 r0 r0 r0 r0 r0 r0 r0 | g0 g0 g0 g0 g0 g0 g0 g0 | r1 r1 r1 r1 r1 r1 r1 r1 | g1 g1 g1 g1 g1 g1 g1 g1 |\n> > + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> > + *    | g0 g0 r0 r0 r0 r0 r0 r0 | r1 r1 r1 r1 g0 g0 g0 g0 | g1 g1 g1 g1 g1 g1 r1 r1 | r2 r2 r2 r2 r2 r2 r2 r2 |\n> > + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> > + *    | g2 g2 g2 g2 g2 g2 g2 g2 | r3 r3 r3 r3 r3 r3 r3 r3 | g3 g3 g3 g3 g3 g3 g3 g3 | g2 g2 r2 r2 r2 r2 r2 r2 |\n> > + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> > + *    | r3 r3 r3 r3 g2 g2 g2 g2 | g3 g3 g3 g3 g3 g3 r3 r3 |\n> > + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n> > + */\n> > +#define MIPI_FORMAT_MOD_CSI2_PACKED fourcc_mod_code(MIPI, 1)\n> > +\n> >  #if defined(__cplusplus)\n> >  }\n> >  #endif","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 895C1BFFE2\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  2 Jul 2020 21:52:01 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 53E5A60C57;\n\tThu,  2 Jul 2020 23:52:01 +0200 (CEST)","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 A190C603B4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  2 Jul 2020 23:51:59 +0200 (CEST)","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 358DC9CB;\n\tThu,  2 Jul 2020 23:51:59 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"SMVwS38k\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1593726719;\n\tbh=gP2pnif9M8t/dfd9i8/KqkaW+VTDLfEar969iil5DCY=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=SMVwS38kxQqTpm4txhfnWwBXYIeO4TNU2kpVl5cdA1NxMH2xBVOCsFgA9YqORrcIO\n\tBLNtzNR9k+P2iMSJ60F8rJiXLoOHz7d1g9SslnhmQLrJNPbW5HSwZOcJEyZD0rt6Zt\n\tS/E90eLASfShqQw+J4AgV9it/QSDsMKssroA1jaA=","Date":"Fri, 3 Jul 2020 00:51:55 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Sakari Ailus <sakari.ailus@linux.intel.com>","Message-ID":"<20200702215155.GU12562@pendragon.ideasonboard.com>","References":"<20200521235201.279642-1-niklas.soderlund@ragnatech.se>\n\t<20200525103143.GF7618@paasikivi.fi.intel.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20200525103143.GF7618@paasikivi.fi.intel.com>","Subject":"Re: [libcamera-devel] [PATCH v2] drm/fourcc: Add bayer formats and\n\tmodifiers","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>","Cc":"libcamera-devel@lists.libcamera.org, Daniel Vetter <daniel@ffwll.ch>,\n\tdri-devel@lists.freedesktop.org","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":11089,"web_url":"https://patchwork.libcamera.org/comment/11089/","msgid":"<20200702215741.GV12562@pendragon.ideasonboard.com>","date":"2020-07-02T21:57:41","subject":"Re: [libcamera-devel] [PATCH v2] drm/fourcc: Add bayer formats and\n\tmodifiers","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Emil,\n\nOn Thu, May 28, 2020 at 04:36:59PM +0100, Emil Velikov wrote:\n> On Fri, 22 May 2020 at 07:56, Niklas Söderlund wrote:\n> >\n> > Bayer formats are used with cameras and contain green, red and blue\n> > components, with alternating lines of red and green, and blue and green\n> > pixels in different orders. For each block of 2x2 pixels there is one\n> > pixel with a red filter, two with a green filter, and one with a blue\n> > filter. The filters can be arranged in different patterns.\n> >\n> > Add DRM fourcc formats to describe the most common Bayer formats. Also\n> > add a modifiers to describe the custom packing layouts used by the Intel\n> > IPU3 and in the MIPI (Mobile Industry Processor Interface) CSI-2\n> > specification.\n> >\n> > Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> > ---\n> > * Changes since v1\n> > - Rename the defines from DRM_FORMAT_SRGGB8 to DRM_FORMAT_BAYER_RGGB8.\n> > - Update the fourcc codes passed to fourcc_code() to avoid a conflict.\n> > - Add diagrams for all Bayer formats memory layout.\n> > - Update documentation.\n> > ---\n> >  include/uapi/drm/drm_fourcc.h | 205 ++++++++++++++++++++++++++++++++++\n> >  1 file changed, 205 insertions(+)\n>\n> Where is the user for these new formats - be that kernel or userspace?\n> Did you forget to update the __drm_format_info() in\n> drivers/gpu/drm/drm_fourcc.c?\n\nThe userspace user is here: https://git.linuxtv.org/libcamera.git/tree/\n\nThe formats are not used in the DRM subsystem, so I don't think there's\na need to update __drm_format_info().\n\nlibcamera is standardizing on using DRM 4CCs to ease interoperability\nwith display. We thus need to be able to express camera-specific formats\nwith DRM 4CCs, even if they're not used on the display side. The\nalternative would be to have custom 4CCs for those formats, but we would\nthen end up risking a 4CC namespace clash.","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 94B10BE905\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  2 Jul 2020 21:57:48 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2DA9460C55;\n\tThu,  2 Jul 2020 23:57:48 +0200 (CEST)","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 19A67603B4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  2 Jul 2020 23:57:46 +0200 (CEST)","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 71E059CB;\n\tThu,  2 Jul 2020 23:57:45 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"IbIDz0bZ\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1593727065;\n\tbh=0rQwBdNpgVjmUJBgZZ/VHWFP3LetUvl+QI2ELUac7mU=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=IbIDz0bZ+G6GpSGb0py8qpADdYppoK/e5aRindDoi6Hncvsc65zj1F6LjYSjLpAkd\n\tnXAfuCUJNCT8iZntgOafWt14VQhN1Q86UCRl4NjrEiENL4amkvIcPf0bR77Q+VIjk7\n\t/BnuRxkic4L6eyyP9o1MZOR+bbXs/lD8ZpfiJrII=","Date":"Fri, 3 Jul 2020 00:57:41 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Emil Velikov <emil.l.velikov@gmail.com>","Message-ID":"<20200702215741.GV12562@pendragon.ideasonboard.com>","References":"<20200521235201.279642-1-niklas.soderlund@ragnatech.se>\n\t<CACvgo50SNourym-gBG1s2UxiD4M96=rMfcd7_y=643BgveRhVg@mail.gmail.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<CACvgo50SNourym-gBG1s2UxiD4M96=rMfcd7_y=643BgveRhVg@mail.gmail.com>","Subject":"Re: [libcamera-devel] [PATCH v2] drm/fourcc: Add bayer formats and\n\tmodifiers","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>","Cc":"libcamera-devel@lists.libcamera.org,\n\tML dri-devel <dri-devel@lists.freedesktop.org>,\n\tSakari Ailus <sakari.ailus@linux.intel.com>","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":11090,"web_url":"https://patchwork.libcamera.org/comment/11090/","msgid":"<20200702220040.GW12562@pendragon.ideasonboard.com>","date":"2020-07-02T22:00:40","subject":"Re: [libcamera-devel] [PATCH v2] drm/fourcc: Add bayer formats and\n\tmodifiers","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Tomasz,\n\nOn Fri, Jun 19, 2020 at 01:06:55PM +0000, Tomasz Figa wrote:\n> On Fri, May 22, 2020 at 01:52:01AM +0200, Niklas Söderlund wrote:\n> > Bayer formats are used with cameras and contain green, red and blue\n> > components, with alternating lines of red and green, and blue and green\n> > pixels in different orders. For each block of 2x2 pixels there is one\n> > pixel with a red filter, two with a green filter, and one with a blue\n> > filter. The filters can be arranged in different patterns.\n> > \n> > Add DRM fourcc formats to describe the most common Bayer formats. Also\n> > add a modifiers to describe the custom packing layouts used by the Intel\n> > IPU3 and in the MIPI (Mobile Industry Processor Interface) CSI-2\n> > specification.\n> > \n> > Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> > ---\n> > * Changes since v1\n> > - Rename the defines from DRM_FORMAT_SRGGB8 to DRM_FORMAT_BAYER_RGGB8.\n> > - Update the fourcc codes passed to fourcc_code() to avoid a conflict.\n> > - Add diagrams for all Bayer formats memory layout.\n> > - Update documentation.\n> > ---\n> >  include/uapi/drm/drm_fourcc.h | 205 ++++++++++++++++++++++++++++++++++\n> >  1 file changed, 205 insertions(+)\n> > \n> > diff --git a/include/uapi/drm/drm_fourcc.h b/include/uapi/drm/drm_fourcc.h\n> > index 8bc0b31597d80737..d07dd24b49bde6c1 100644\n> > --- a/include/uapi/drm/drm_fourcc.h\n> > +++ b/include/uapi/drm/drm_fourcc.h\n> > @@ -285,6 +285,73 @@ extern \"C\" {\n> >  #define DRM_FORMAT_YUV444\tfourcc_code('Y', 'U', '2', '4') /* non-subsampled Cb (1) and Cr (2) planes */\n> >  #define DRM_FORMAT_YVU444\tfourcc_code('Y', 'V', '2', '4') /* non-subsampled Cr (1) and Cb (2) planes */\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> > + *\trow2: RGRGRGRG...\n> > + *\trow3: GBGBGBGB...\n> > + *\t...\n> > + *\n> \n> I wonder if we're operating on the right level of abstraction within this\n> proposal.\n> \n> The sensor itself transfers only sequential pixels, as read\n> out from its matrix. Whether a given pixel corresponds to a red, green\n> or blue color filter actually depends on the filter layer, which could\n> actually vary between integrations of the same sensor. (See Fujifilm\n> X-Trans, which uses regular Sony sensors with their own filter pattern\n> [1].)\n> \n> Moreover, the sensor resolution is specified as the number of pixels\n> horizontally and the number of lines horizontally, without considering\n> the color pattern.\n> \n> If we consider that, wouldn't the data stream coming from the sensor be\n> essentially DRM_FORMAT_R8/R10/R12/etc.?\n> \n> Then, on top of that, we would have the packing, which I believe is\n> defined well in this document +/- being entangled with the Bayer\n> pattern.\n> \n> What do you think?\n> \n> [1] https://en.wikipedia.org/wiki/Fujifilm_X-Trans_sensor\n\nI think using DRM_FORMAT_R8/R10/R12/... is a good idea. Packing would\nindeed be a modifier, and maybe the CFA could even be expressed\nseparately from the DRM format (4CC + modifier), through a libcamera\nproperty.","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 62342BFFE2\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  2 Jul 2020 22:00:47 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id F06F260C57;\n\tFri,  3 Jul 2020 00:00:46 +0200 (CEST)","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 0C36B609A9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  3 Jul 2020 00:00:45 +0200 (CEST)","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 78A1A9CB;\n\tFri,  3 Jul 2020 00:00:44 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"S1m2ZucY\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1593727244;\n\tbh=sLZBoqu6xJQY3hYmTbjOX0TFnbS1S/r5ZRmrlu4IfDs=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=S1m2ZucYZlK7WGJXmSeULMZxPMlMTGYphjmC68GGWcYMV+EqxfijWeJ+MFlNSj+SW\n\tMz6l+GpHy+0ZmRJBQV+9PLAN3ZgGsCkN7AmWz0OeQpjk4cUi3Cd1eE4s+cIR2/l5x/\n\tw2BMaKfdjF9rUvNFZ1sI8iYV3NGxfa+44P4vAT/Q=","Date":"Fri, 3 Jul 2020 01:00:40 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Tomasz Figa <tfiga@chromium.org>","Message-ID":"<20200702220040.GW12562@pendragon.ideasonboard.com>","References":"<20200521235201.279642-1-niklas.soderlund@ragnatech.se>\n\t<20200619130655.GB241696@chromium.org>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20200619130655.GB241696@chromium.org>","Subject":"Re: [libcamera-devel] [PATCH v2] drm/fourcc: Add bayer formats and\n\tmodifiers","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>","Cc":"libcamera-devel@lists.libcamera.org, dri-devel@lists.freedesktop.org,\n\tSakari Ailus <sakari.ailus@linux.intel.com>","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":11148,"web_url":"https://patchwork.libcamera.org/comment/11148/","msgid":"<48441a19-dbf3-feeb-b00c-78e61fd665dc@baylibre.com>","date":"2020-07-03T08:41:10","subject":"Re: [libcamera-devel] [PATCH v2] drm/fourcc: Add bayer formats and\n\tmodifiers","submitter":{"id":60,"url":"https://patchwork.libcamera.org/api/people/60/","name":"Neil Armstrong","email":"narmstrong@baylibre.com"},"content":"Hi Niklas,\n\nOn 02/07/2020 23:51, Laurent Pinchart wrote:\n> Hi Sakari,\n> \n> On Mon, May 25, 2020 at 01:31:43PM +0300, Sakari Ailus wrote:\n>> On Fri, May 22, 2020 at 01:52:01AM +0200, Niklas Söderlund wrote:\n>>> Bayer formats are used with cameras and contain green, red and blue\n>>> components, with alternating lines of red and green, and blue and green\n>>> pixels in different orders. For each block of 2x2 pixels there is one\n>>> pixel with a red filter, two with a green filter, and one with a blue\n>>> filter. The filters can be arranged in different patterns.\n>>>\n>>> Add DRM fourcc formats to describe the most common Bayer formats. Also\n>>> add a modifiers to describe the custom packing layouts used by the Intel\n>>> IPU3 and in the MIPI (Mobile Industry Processor Interface) CSI-2\n>>> specification.\n>>>\n>>> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n>>> ---\n>>> * Changes since v1\n>>> - Rename the defines from DRM_FORMAT_SRGGB8 to DRM_FORMAT_BAYER_RGGB8.\n>>> - Update the fourcc codes passed to fourcc_code() to avoid a conflict.\n>>> - Add diagrams for all Bayer formats memory layout.\n>>> - Update documentation.\n>>> ---\n>>>  include/uapi/drm/drm_fourcc.h | 205 ++++++++++++++++++++++++++++++++++\n>>>  1 file changed, 205 insertions(+)\n>>>\n>>> diff --git a/include/uapi/drm/drm_fourcc.h b/include/uapi/drm/drm_fourcc.h\n>>> index 8bc0b31597d80737..d07dd24b49bde6c1 100644\n>>> --- a/include/uapi/drm/drm_fourcc.h\n>>> +++ b/include/uapi/drm/drm_fourcc.h\n>>> @@ -285,6 +285,73 @@ extern \"C\" {\n>>>  #define DRM_FORMAT_YUV444\tfourcc_code('Y', 'U', '2', '4') /* non-subsampled Cb (1) and Cr (2) planes */\n>>>  #define DRM_FORMAT_YVU444\tfourcc_code('Y', 'V', '2', '4') /* non-subsampled Cr (1) and Cb (2) planes */\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>>> + *\trow2: RGRGRGRG...\n>>> + *\trow3: GBGBGBGB...\n>>> + *\t...\n>>> + *\n>>> + * Vendors have different methods to pack the pixel samples. For this reason the\n>>> + * fourcc only describes pixel sample size and the filter pattern for each block\n>>> + * of 2x2 pixels. A modifier is needed to 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 each sample is stored\n>>> + * in the minimum number of bytes required. Any unused bits in each sample are\n>>> + * defined as padding bits and set to zero.\n>>> + *\n>>> + * For example, DRM_FORMAT_BAYER_RGGB10 with DRM_FORMAT_MOD_LINEAR:\n>>> + *\n>>> + *  0                                              row 0 (RGRG)                                            31\n>>> + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n>>> + *  | r0 r0 r0 r0 r0 r0 r0 r0 |  0  0  0  0  0  0 r0 r0 | g0 g0 g0 g0 g0 g0 g0 g0 |  0  0  0  0  0  0 g0 g0 |\n>>> + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n>>> + *  | r1 r1 r1 r1 r1 r1 r1 r1 |  0  0  0  0  0  0 r1 r1 | g1 g1 g1 g1 g1 g1 g1 g1 |  0  0  0  0  0  0 g1 g1 |\n>>> + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n>>> + *\n>>> + *  0                                              row 1 (GBGB)                                            31\n>>> + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n>>> + *  | g0 g0 g0 g0 g0 g0 g0 g0 |  0  0  0  0  0  0 g0 g0 | b0 b0 b0 b0 b0 b0 b0 b0 |  0  0  0  0  0  0 b0 b0 |\n>>> + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n>>> + *  | g1 g1 g1 g1 g1 g1 g1 g1 |  0  0  0  0  0  0 g1 g1 | b1 b1 b1 b1 b1 b1 b1 b1 |  0  0  0  0  0  0 b1 b1 |\n>>> + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n>>> + */\n>>> +\n>>> +/* 8-bits Bayer formats */\n>>> +#define DRM_FORMAT_BAYER_RGGB8\t\tfourcc_code('R', 'G', 'G', 'B')\n>>> +#define DRM_FORMAT_BAYER_GRBG8\t\tfourcc_code('G', 'R', 'B', 'G')\n>>> +#define DRM_FORMAT_BAYER_GBRG8\t\tfourcc_code('G', 'B', 'R', 'G')\n>>> +#define DRM_FORMAT_BAYER_BGGR8\t\tfourcc_code('B', 'G', 'G', 'R')\n>>> +\n>>> +/* 10-bit Bayer formats */\n>>> +#define DRM_FORMAT_BAYER_RGGB10\t\tfourcc_code('R', 'G', '1', '0')\n>>> +#define DRM_FORMAT_BAYER_GRBG10\t\tfourcc_code('G', 'R', '1', '0')\n>>> +#define DRM_FORMAT_BAYER_GBRG10\t\tfourcc_code('G', 'B', '1', '0')\n>>> +#define DRM_FORMAT_BAYER_BGGR10\t\tfourcc_code('B', 'G', '1', '0')\n>>> +\n>>> +/* 12-bit Bayer formats */\n>>> +#define DRM_FORMAT_BAYER_RGGB12\t\tfourcc_code('R', 'G', '1', '2')\n>>> +#define DRM_FORMAT_BAYER_GRBG12\t\tfourcc_code('G', 'R', '1', '2')\n>>> +#define DRM_FORMAT_BAYER_GBRG12\t\tfourcc_code('G', 'B', '1', '2')\n>>> +#define DRM_FORMAT_BAYER_BGGR12\t\tfourcc_code('B', 'G', '1', '2')\n>>> +\n>>> +/* 14-bit Bayer formats */\n>>> +#define DRM_FORMAT_BAYER_RGGB14\t\tfourcc_code('R', 'G', '1', '4')\n>>> +#define DRM_FORMAT_BAYER_GRBG14\t\tfourcc_code('G', 'R', '1', '4')\n>>> +#define DRM_FORMAT_BAYER_GBRG14\t\tfourcc_code('G', 'B', '1', '4')\n>>> +#define DRM_FORMAT_BAYER_BGGR14\t\tfourcc_code('B', 'G', '1', '4')\n>>> +\n>>>  \n>>>  /*\n>>>   * Format Modifiers:\n>>> @@ -309,6 +376,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\nI just applied:\n 334 #define DRM_FORMAT_MOD_VENDOR_AMLOGIC 0x0a\n\nSo you'll need to rebase on drm-misc-next.\n\nThanks,\nNeil\n\n>>\n>> This is an interesting one. I don't think these formats have originated\n>> from MIPI. The colour pattern itself is from Eastman Kodak apparently\n>> (named after Bryce Bayer), but the memory format is not, apart from the\n>> MIPI CSI-2 packed variant.\n>>\n>> The formats are probably unlike the formats used on GPUs as they are\n>> relatively similar across a number of vendors and devices.\n>>\n>> There are more raw formats than just the Bayer formats, see e.g.\n>>\n>> <URL:https://en.wikipedia.org/wiki/Raw_image_format>\n>>\n>> At the same time, it'd be good to keep the CSI-2 packed variant as a format\n>> modifier. I wonder if we could have something like\n>> DRM_FORMAT_MOD_VENDOR_RAW, albeit a raw format is not a vendor.\n> \n> The modifier defined with DRM_FORMAT_MOD_VENDOR_MIPI is meant to specify\n> in-memory packing corresponding to how the RAW data is carried over\n> CSI-2. That's why MIPI was picked as a name.\n> \n>> Cc Daniel and Laurent.\n>>\n>>>  /* add more to the end as needed */\n>>>  \n>>> @@ -434,6 +502,56 @@ extern \"C\" {\n>>>   */\n>>>  #define I915_FORMAT_MOD_Y_TILED_GEN12_MC_CCS fourcc_mod_code(INTEL, 7)\n>>>  \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 zero padding bits.\n>>> + *\n>>> + * For example, DRM_FORMAT_BAYER_BGGR10 with IPU3_FORMAT_MOD_PACKED:\n>>> + *\n>>> + *  0                                   row 0 (BGBGBGBGBGBGBGBGBGBGBGBGB)                                  31\n>>> + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n>>> + *  | b0 b0 b0 b0 b0 b0 b0 b0 | g0 g0 g0 g0 g0 g0 b0 b0 | b1 b1 b1 b1 g0 g0 g0 g0 | g1 g1 b1 b1 b1 b1 b1 b1 |\n>>> + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n>>> + *  | g1 g1 g1 g1 g1 g1 g1 g1 | b2 b2 b2 b2 b2 b2 b2 b2 | g2 g2 g2 g2 g2 g2 b2 b2 | b3 b3 b3 b3 g2 g2 g2 g2 |\n>>> + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n>>> + *  | g3 g3 b3 b3 b3 b3 b3 b3 | g3 g3 g3 g3 g3 g3 g3 g3 | b4 b4 b4 b4 b4 b4 b4 b4 | g4 g4 g4 g4 g4 g4 b4 b4 |\n>>> + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n>>> + *  | b5 b5 b5 b5 g4 g4 g4 g4 | g5 g5 b5 b5 b5 b5 b5 b5 | g5 g5 g5 g5 g5 g5 g5 g5 | b6 b6 b6 b6 b6 b6 b6 b6 |\n>>> + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n>>> + *  | g6 g6 g6 g6 g6 g6 b6 b6 | b7 b7 b7 b7 g6 g6 g6 g6 | g7 g7 b7 b7 b7 b7 b7 b7 | g7 g7 g7 g7 g7 g7 g7 g7 |\n>>> + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n>>> + *  | b8 b8 b8 b8 b8 b8 b8 b8 | g8 g8 g8 g8 g8 g8 b8 b8 | b9 b9 b9 b9 g8 g8 g8 g8 | g9 g9 b9 b9 b9 b9 b9 b9 |\n>>> + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n>>> + *  | g9 g9 g9 g9 g9 g9 g9 g9 | bA bA bA bA bA bA bA bA | gA gA gA gA gA gA bA bA | bB bB bB bB gA gA gA gA |\n>>> + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n>>> + *  | gB gB bB bB bB bB bB bB | gB gB gB gB gB gB gB gB | bC bC bC bC bC bC bC bC |  0  0  0  0  0  0 bC bC |\n>>> + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n>>> + *\n>>> + *  0                                   row 1 (GRGRGRGRGRGRGRGRGRGRGRGRG)                                  31\n>>> + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n>>> + *  | g0 g0 g0 g0 g0 g0 g0 g0 | r0 r0 r0 r0 r0 r0 g0 g0 | g1 g1 g1 g1 r0 r0 r0 r0 | r1 r1 g1 g1 g1 g1 g1 g1 |\n>>> + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n>>> + *  | r1 r1 r1 r1 r1 r1 r1 r1 | g2 g2 g2 g2 g2 g2 g2 g2 | r2 r2 r2 r2 r2 r2 g2 g2 | g3 g3 g3 g3 r2 r2 r2 r2 |\n>>> + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n>>> + *  | r3 r3 g3 g3 g3 g3 g3 g3 | r3 r3 r3 r3 r3 r3 r3 r3 | g4 g4 g4 g4 g4 g4 g4 g4 | r4 r4 r4 r4 r4 r4 g4 g4 |\n>>> + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n>>> + *  | g5 g5 g5 g5 r4 r4 r4 r4 | r5 r5 g5 g5 g5 g5 g5 g5 | r5 r5 r5 r5 r5 r5 r5 r5 | g6 g6 g6 g6 g6 g6 g6 g6 |\n>>> + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n>>> + *  | r6 r6 r6 r6 r6 r6 g6 g6 | g7 g7 g7 g7 r6 r6 r6 r6 | r7 r7 g7 g7 g7 g7 g7 g7 | r7 r7 r7 r7 r7 r7 r7 r7 |\n>>> + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n>>> + *  | g8 g8 g8 g8 g8 g8 g8 g8 | r8 r8 r8 r8 r8 r8 g8 g8 | g9 g9 g9 g9 r8 r8 r8 r8 | r9 r9 g9 g9 g9 g9 g9 g9 |\n>>> + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n>>> + *  | r9 r9 r9 r9 r9 r9 r9 r9 | gA gA gA gA gA gA gA gA | rA rA rA rA rA rA gA gA | gB gB gB gB rA rA rA rA |\n>>> + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n>>> + *  | rB rB gB gB gB gB gB gB | rB rB rB rB rB rB rB rB | gC gC gC gC gC gC gC gC |  0  0  0  0  0  0 gC gC |\n>>> + *  +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\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>>> @@ -804,6 +922,93 @@ 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>>> + * depending 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>>> + *   For example, DRM_FORMAT_BAYER_BGGR10 with MIPI_FORMAT_MOD_CSI2_PACKED:\n>>> + *\n>>> + *    0                                            row 0 (BGBGBGBG)                                          31\n>>> + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n>>> + *    | b0 b0 b0 b0 b0 b0 b0 b0 | g0 g0 g0 g0 g0 g0 g0 g0 | b1 b1 b1 b1 b1 b1 b1 b1 | g1 g1 g1 g1 g1 g1 g1 g1 |\n>>> + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n>>> + *    | g1 g1 b1 b1 g0 g0 b0 b0 | b2 b2 b2 b2 b2 b2 b2 b2 | g2 g2 g2 g2 g2 g2 g2 g2 | b3 b3 b3 b3 b3 b3 b3 b3 |\n>>> + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n>>> + *    | g3 g3 g3 g3 g3 g3 g3 g3 | g3 g3 b3 b3 g2 g2 b2 b2 |\n>>> + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n>>> + *\n>>> + *    0                                            row 1 (GRGRGRGR)                                          31\n>>> + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n>>> + *    | g0 g0 g0 g0 g0 g0 g0 g0 | r0 r0 r0 r0 r0 r0 r0 r0 | g1 g1 g1 g1 g1 g1 g1 g1 | r1 r1 r1 r1 r1 r1 r1 r1 |\n>>> + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n>>> + *    | r1 r1 g1 g1 r0 r0 g0 g0 | g2 g2 g2 g2 g2 g2 g2 g2 | r2 r2 r2 r2 r2 r2 r2 r2 | g3 g3 g3 g3 g3 g3 g3 g3 |\n>>> + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n>>> + *    | r3 r3 r3 r3 r3 r3 r3 r3 | r3 r3 g3 g3 r2 r2 g2 g2 |\n>>> + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\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>>> + *   For example, DRM_FORMAT_BAYER_GRBG12 with MIPI_FORMAT_MOD_CSI2_PACKED:\n>>> + *\n>>> + *    0                                              row 0 (GRGR)                                            31\n>>> + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n>>> + *    | g0 g0 g0 g0 g0 g0 g0 g0 | r0 r0 r0 r0 r0 r0 r0 r0 | r0 r0 r0 r0 g0 g0 g0 g0 | g1 g1 g1 g1 g1 g1 g1 g1 |\n>>> + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n>>> + *    | r1 r1 r1 r1 r1 r1 r1 r1 | r1 r1 r1 r1 g1 g1 g1 g1 |\n>>> + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n>>> + *\n>>> + *    0                                              row 1 (BGBG)                                            31\n>>> + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n>>> + *    | b0 b0 b0 b0 b0 b0 b0 b0 | g0 g0 g0 g0 g0 g0 g0 g0 | g0 g0 g0 g0 b0 b0 b0 b0 | b1 b1 b1 b1 b1 b1 b1 b1 |\n>>> + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n>>> + *    | g1 g1 g1 g1 g1 g1 g1 g1 | g1 g1 g1 g1 b1 b1 b1 b1 |\n>>> + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\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>>> + *   For example, DRM_FORMAT_BAYER_GBRG14 with MIPI_FORMAT_MOD_CSI2_PACKED:\n>>> + *\n>>> + *    0                                            row 0 (GBGBGBGB)                                          31\n>>> + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n>>> + *    | g0 g0 g0 g0 g0 g0 g0 g0 | b0 b0 b0 b0 b0 b0 b0 b0 | g1 g1 g1 g1 g1 g1 g1 g1 | b1 b1 b1 b1 b1 b1 b1 b1 |\n>>> + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n>>> + *    | b0 b0 g0 g0 g0 g0 g0 g0 | g1 g1 g1 g1 b0 b0 b0 b0 | b1 b1 b1 b1 b1 b1 g1 g1 | g2 g2 g2 g2 g2 g2 g2 g2 |\n>>> + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n>>> + *    | b2 b2 b2 b2 b2 b2 b2 b2 | g3 g3 g3 g3 g3 g3 g3 g3 | b3 b3 b3 b3 b3 b3 b3 b3 | b2 b2 g2 g2 g2 g2 g2 g2 |\n>>> + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n>>> + *    | g3 g3 g3 g3 b2 b2 b2 b2 | b3 b3 b3 b3 b3 b3 g3 g3 |\n>>> + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n>>> + *\n>>> + *    0                                            row 1 (RGRGRGRG)                                          31\n>>> + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n>>> + *    | r0 r0 r0 r0 r0 r0 r0 r0 | g0 g0 g0 g0 g0 g0 g0 g0 | r1 r1 r1 r1 r1 r1 r1 r1 | g1 g1 g1 g1 g1 g1 g1 g1 |\n>>> + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n>>> + *    | g0 g0 r0 r0 r0 r0 r0 r0 | r1 r1 r1 r1 g0 g0 g0 g0 | g1 g1 g1 g1 g1 g1 r1 r1 | r2 r2 r2 r2 r2 r2 r2 r2 |\n>>> + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n>>> + *    | g2 g2 g2 g2 g2 g2 g2 g2 | r3 r3 r3 r3 r3 r3 r3 r3 | g3 g3 g3 g3 g3 g3 g3 g3 | g2 g2 r2 r2 r2 r2 r2 r2 |\n>>> + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n>>> + *    | r3 r3 r3 r3 g2 g2 g2 g2 | g3 g3 g3 g3 g3 g3 r3 r3 |\n>>> + *    +  -  -  -  -  -  -  -  - +  -  -  -  -  -  -  -  - +\n>>> + */\n>>> +#define MIPI_FORMAT_MOD_CSI2_PACKED fourcc_mod_code(MIPI, 1)\n>>> +\n>>>  #if defined(__cplusplus)\n>>>  }\n>>>  #endif\n>","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 6921CBFFE2\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  3 Jul 2020 10:58:56 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 35F7B60C57;\n\tFri,  3 Jul 2020 12:58:56 +0200 (CEST)","from mail-wm1-x341.google.com (mail-wm1-x341.google.com\n\t[IPv6:2a00:1450:4864:20::341])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 67FAE603AD\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  3 Jul 2020 10:41:12 +0200 (CEST)","by mail-wm1-x341.google.com with SMTP id j18so31246772wmi.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 03 Jul 2020 01:41:12 -0700 (PDT)","from ?IPv6:2a01:e35:2ec0:82b0:6959:e617:6562:cabf?\n\t([2a01:e35:2ec0:82b0:6959:e617:6562:cabf])\n\tby smtp.gmail.com with ESMTPSA id\n\tx5sm13218677wmg.2.2020.07.03.01.41.10\n\t(version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n\tFri, 03 Jul 2020 01:41:11 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=baylibre-com.20150623.gappssmtp.com\n\theader.i=@baylibre-com.20150623.gappssmtp.com\n\theader.b=\"J6YVH3/a\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=baylibre-com.20150623.gappssmtp.com; s=20150623;\n\th=subject:to:cc:references:from:autocrypt:organization:message-id\n\t:date:user-agent:mime-version:in-reply-to:content-language\n\t:content-transfer-encoding;\n\tbh=kt8TSgbgg/MAp+KoxiuXEC1DIHK29TFfF5Yaj2aznOg=;\n\tb=J6YVH3/auHGVcz0zLf39fb1vxgmNRfhXbGOZQWSuzRsO3Ks1GolBdgn1wBH9CJIPS5\n\tV2qpqqLa2sJXdrRYDvPIjUzYFobqFsPPUUv2CDyZM2ZNiEZxSrl1BzGCq09wmgB+F2oA\n\tYmepg0212OvVQalSJ+39ro5qR1QcdxLZAGwCYe+RZ7lchlxcUTVjComJVBJix4gxdp0V\n\tuuUtiwKON4WGvBWZs+3CjFYX4UUPOGty+uf+8/1LMsQj3o67jHCz07DFz9nZw8W0MwpE\n\t77QnBq8Vx23HwMuFsrIcPiKIteSlRcAP3cT2duBAPjbOl4WB5bm2dh1vVjyipxb/ASqz\n\t6Qkg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:subject:to:cc:references:from:autocrypt\n\t:organization:message-id:date:user-agent:mime-version:in-reply-to\n\t:content-language:content-transfer-encoding;\n\tbh=kt8TSgbgg/MAp+KoxiuXEC1DIHK29TFfF5Yaj2aznOg=;\n\tb=sQTt4MuY6ISBOw9s/OceW4zJc72nWMeHP0gnsW29I9Xd9iAYSoSw+BUf4185GJWQOs\n\tCRb5IOwKz8Pr+9yuqCwulL4rvzpAKacBLJMXe7uUe+iDvTzcFNRfGTgNSL4M/oqdNUp8\n\t0oD5RTvS4R5mhgxB3HQalF34VBeKG0Nl/jsxjBqnL2xlK+pSUg3N6fFxeeBhsHgWh2DX\n\t3VAhWbm4qVXfPXoqo84YAfR8SUDGYW70IfBK6clpQHUvkt8NUDSgxF1241hUV0+W8UVW\n\tnhFokl3esiyv+ocMFpa9/nR19piauvART9LxwYQV2UCcBmtxaVHCe4j8Kv059AJhqZT1\n\tDy3w==","X-Gm-Message-State":"AOAM531rUvrQl2pHl3Jt6l+cnmobXlh2O53MtUoxdfrz8PhD0aPhcMbZ\n\th1iIJuJH6pBoQB3QG/+Ix92Nug==","X-Google-Smtp-Source":"ABdhPJwTLwO4M65mjltRy4UKRYarKHDEaC3LPVxu/kbMXNOKIbU+zjGEYK/IWSmUtu4/suL5F+EVcg==","X-Received":"by 2002:a1c:2d83:: with SMTP id\n\tt125mr36497220wmt.187.1593765671825; \n\tFri, 03 Jul 2020 01:41:11 -0700 (PDT)","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tSakari Ailus <sakari.ailus@linux.intel.com>","References":"<20200521235201.279642-1-niklas.soderlund@ragnatech.se>\n\t<20200525103143.GF7618@paasikivi.fi.intel.com>\n\t<20200702215155.GU12562@pendragon.ideasonboard.com>","From":"Neil Armstrong <narmstrong@baylibre.com>","Autocrypt":"addr=narmstrong@baylibre.com; prefer-encrypt=mutual; keydata=\n\txsBNBE1ZBs8BCAD78xVLsXPwV/2qQx2FaO/7mhWL0Qodw8UcQJnkrWmgTFRobtTWxuRx8WWP\n\tGTjuhvbleoQ5Cxjr+v+1ARGCH46MxFP5DwauzPekwJUD5QKZlaw/bURTLmS2id5wWi3lqVH4\n\tBVF2WzvGyyeV1o4RTCYDnZ9VLLylJ9bneEaIs/7cjCEbipGGFlfIML3sfqnIvMAxIMZrvcl9\n\tqPV2k+KQ7q+aXavU5W+yLNn7QtXUB530Zlk/d2ETgzQ5FLYYnUDAaRl+8JUTjc0CNOTpCeik\n\t80TZcE6f8M76Xa6yU8VcNko94Ck7iB4vj70q76P/J7kt98hklrr85/3NU3oti3nrIHmHABEB\n\tAAHNKE5laWwgQXJtc3Ryb25nIDxuYXJtc3Ryb25nQGJheWxpYnJlLmNvbT7CwHsEEwEKACUC\n\tGyMGCwkIBwMCBhUIAgkKCwQWAgMBAh4BAheABQJXDO2CAhkBAAoJEBaat7Gkz/iubGIH/iyk\n\tRqvgB62oKOFlgOTYCMkYpm2aAOZZLf6VKHKc7DoVwuUkjHfIRXdslbrxi4pk5VKU6ZP9AKsN\n\tNtMZntB8WrBTtkAZfZbTF7850uwd3eU5cN/7N1Q6g0JQihE7w4GlIkEpQ8vwSg5W7hkx3yQ6\n\t2YzrUZh/b7QThXbNZ7xOeSEms014QXazx8+txR7jrGF3dYxBsCkotO/8DNtZ1R+aUvRfpKg5\n\tZgABTC0LmAQnuUUf2PHcKFAHZo5KrdO+tyfL+LgTUXIXkK+tenkLsAJ0cagz1EZ5gntuheLD\n\tYJuzS4zN+1Asmb9kVKxhjSQOcIh6g2tw7vaYJgL/OzJtZi6JlIXOwU0EVid/pAEQAND7AFhr\n\t5faf/EhDP9FSgYd/zgmb7JOpFPje3uw7jz9wFb28Cf0Y3CcncdElYoBNbRlesKvjQRL8mozV\n\t9RN+IUMHdUx1akR/A4BPXNdL7StfzKWOCxZHVS+rIQ/fE3Qz/jRmT6t2ZkpplLxVBpdu95qJ\n\tYwSZjuwFXdC+A7MHtQXYi3UfCgKiflj4+/ITcKC6EF32KrmIRqamQwiRsDcUUKlAUjkCLcHL\n\tCQvNsDdm2cxdHxC32AVm3Je8VCsH7/qEPMQ+cEZk47HOR3+Ihfn1LEG5LfwsyWE8/JxsU2a1\n\tq44LQM2lcK/0AKAL20XDd7ERH/FCBKkNVzi+svYJpyvCZCnWT0TRb72mT+XxLWNwfHTeGALE\n\t+1As4jIS72IglvbtONxc2OIid3tR5rX3k2V0iud0P7Hnz/JTdfvSpVj55ZurOl2XAXUpGbq5\n\tXRk5CESFuLQV8oqCxgWAEgFyEapI4GwJsvfl/2Er8kLoucYO1Id4mz6N33+omPhaoXfHyLSy\n\tdxD+CzNJqN2GdavGtobdvv/2V0wukqj86iKF8toLG2/Fia3DxMaGUxqI7GMOuiGZjXPt/et/\n\tqeOySghdQ7Sdpu6fWc8CJXV2mOV6DrSzc6ZVB4SmvdoruBHWWOR6YnMz01ShFE49pPucyU1h\n\tAv4jC62El3pdCrDOnWNFMYbbon3vABEBAAHCwn4EGAECAAkFAlYnf6QCGwICKQkQFpq3saTP\n\t+K7BXSAEGQECAAYFAlYnf6QACgkQd9zb2sjISdGToxAAkOjSfGxp0ulgHboUAtmxaU3viucV\n\te2Hl1BVDtKSKmbIVZmEUvx9D06IijFaEzqtKD34LXD6fjl4HIyDZvwfeaZCbJbO10j3k7FJE\n\tQrBtpdVqkJxme/nYlGOVzcOiKIepNkwvnHVnuVDVPcXyj2wqtsU7VZDDX41z3X4xTQwY3SO1\n\t9nRO+f+i4RmtJcITgregMa2PcB0LvrjJlWroI+KAKCzoTHzSTpCXMJ1U/dEqyc87bFBdc+DI\n\tk8mWkPxsccdbs4t+hH0NoE3Kal9xtAl56RCtO/KgBLAQ5M8oToJVatxAjO1SnRYVN1EaAwrR\n\txkHdd97qw6nbg9BMcAoa2NMc0/9MeiaQfbgW6b0reIz/haHhXZ6oYSCl15Knkr4t1o3I2Bqr\n\tMw623gdiTzotgtId8VfLB2Vsatj35OqIn5lVbi2ua6I0gkI6S7xJhqeyrfhDNgzTHdQVHB9/\n\t7jnM0ERXNy1Ket6aDWZWCvM59dTyu37g3VvYzGis8XzrX1oLBU/tTXqo1IFqqIAmvh7lI0Se\n\tgCrXz7UanxCwUbQBFjzGn6pooEHJYRLuVGLdBuoApl/I4dLqCZij2AGa4CFzrn9W0cwm3HCO\n\tlR43gFyz0dSkMwNUd195FrvfAz7Bjmmi19DnORKnQmlvGe/9xEEfr5zjey1N9+mt3//geDP6\n\tclwKBkq0JggA+RTEAELzkgPYKJ3NutoStUAKZGiLOFMpHY6KpItbbHjF2ZKIU1whaRYkHpB2\n\tuLQXOzZ0d7x60PUdhqG3VmFnzXSztA4vsnDKk7x2xw0pMSTKhMafpxaPQJf494/jGnwBHyi3\n\th3QGG1RjfhQ/OMTX/HKtAUB2ct3Q8/jBfF0hS5GzT6dYtj0Ci7+8LUsB2VoayhNXMnaBfh+Q\n\tpAhaFfRZWTjUFIV4MpDdFDame7PB50s73gF/pfQbjw5Wxtes/0FnqydfId95s+eej+17ldGp\n\tlMv1ok7K0H/WJSdr7UwDAHEYU++p4RRTJP6DHWXcByVlpNQ4SSAiivmWiwOt490+Ac7ATQRN\n\tWQbPAQgAvIoM384ZRFocFXPCOBir5m2J+96R2tI2XxMgMfyDXGJwFilBNs+fpttJlt2995A8\n\t0JwPj8SFdm6FBcxygmxBBCc7i/BVQuY8aC0Z/w9Vzt3Eo561r6pSHr5JGHe8hwBQUcNPd/9l\n\t2ynP57YTSE9XaGJK8gIuTXWo7pzIkTXfN40Wh5jeCCspj4jNsWiYhljjIbrEj300g8RUT2U0\n\tFcEoiV7AjJWWQ5pi8lZJX6nmB0lc69Jw03V6mblgeZ/1oTZmOepkagwy2zLDXxihf0GowUif\n\tGphBDeP8elWBNK+ajl5rmpAMNRoKxpN/xR4NzBg62AjyIvigdywa1RehSTfccQARAQABwsBf\n\tBBgBAgAJBQJNWQbPAhsMAAoJEBaat7Gkz/iuteIH+wZuRDqK0ysAh+czshtG6JJlLW6eXJJR\n\tVi7dIPpgFic2LcbkSlvB8E25Pcfz/+tW+04Urg4PxxFiTFdFCZO+prfd4Mge7/OvUcwoSub7\n\tZIPo8726ZF5/xXzajahoIu9/hZ4iywWPAHRvprXaim5E/vKjcTeBMJIqZtS4u/UK3EpAX59R\n\tXVxVpM8zJPbk535ELUr6I5HQXnihQm8l6rt9TNuf8p2WEDxc8bPAZHLjNyw9a/CdeB97m2Tr\n\tzR8QplXA5kogS4kLe/7/JmlDMO8Zgm9vKLHSUeesLOrjdZ59EcjldNNBszRZQgEhwaarfz46\n\tBSwxi7g3Mu7u5kUByanqHyA=","Organization":"Baylibre","Message-ID":"<48441a19-dbf3-feeb-b00c-78e61fd665dc@baylibre.com>","Date":"Fri, 3 Jul 2020 10:41:10 +0200","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101\n\tThunderbird/68.8.0","MIME-Version":"1.0","In-Reply-To":"<20200702215155.GU12562@pendragon.ideasonboard.com>","Content-Language":"en-US","X-Mailman-Approved-At":"Fri, 03 Jul 2020 12:58:55 +0200","Subject":"Re: [libcamera-devel] [PATCH v2] drm/fourcc: Add bayer formats and\n\tmodifiers","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>","Cc":"libcamera-devel@lists.libcamera.org, dri-devel@lists.freedesktop.org","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]