Skip to contentSkip to conversation

drm/fourcc: Add bayer formats and modifiers

PATCH Superseded Niklas Söderlund 4 participants 4 messages Feb 29, 2020 – Mar 4, 2020

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/fourcc: Add bayer formats and modifiers

Bayer formats are used with cameras and contain green, red and blue components, with alternating lines of red and green, and blue and green pixels in different orders. For each block of 2x2 pixels there is one pixel with a red filter, two with a green filter, and one with a blue filter. The filters can be arranged in different patterns.

Add DRM fourcc formats to describe the most common Bayer formats. Also add a modifiers to describe the custom packing layouts used by the Intel IPU3 and in the MIPI (Mobile Industry Processor Interface) CSI-2 specification.

---
 include/uapi/drm/drm_fourcc.h | 95 +++++++++++++++++++++++++++++++++++
 1 file changed, 95 insertions(+)
include/uapi/drm/drm_fourcc.h +95 -0
index 8bc0b31597d80737..561d5a08ffd16b69 100644
@@ -286,6 +286,62 @@ extern "C" {
 #define DRM_FORMAT_YVU444	fourcc_code('Y', 'V', '2', '4') /* non-subsampled Cr (1) and Cb (2) planes */
 
 
+/*
+ * Bayer formats
+ *
+ * Bayer formats contain green, red and blue components, with alternating lines
+ * of red and green, and blue and green pixels in different orders. For each
+ * block of 2x2 pixels there is one pixel with a red filter, two with a green
+ * filter, and one with a blue filter. The filters can be arranged in different
+ * patterns.
+ *
+ * For example, RGGB:
+ *	row0: RGRGRGRG...
+ *	row1: GBGBGBGB...
+ *	row3: RGRGRGRG...
+ *	row4: GBGBGBGB...
+ *	...
+ *
+ * Vendors have different methods to pack the sampling formats to increase data
+ * density. For this reason the fourcc only describes pixel sample size and the
+ * filter pattern for each block of 2x2 pixels. A modifier is needed to
+ * describe the memory layout.
+ *
+ * In addition to vendor modifiers for memory layout DRM_FORMAT_MOD_LINEAR may
+ * be used to describe a layout where all samples are placed consecutively in
+ * memory. If the sample does not fit inside a single byte, the sample storage
+ * is extended to the minimum number of (little endian) bytes that can hold the
+ * sample and any unused most-significant bits are defined as padding.
+ *
+ * For example, SRGGB10:
+ * Each 10-bit sample is contained in 2 consecutive little endian bytes, where
+ * the 6 most-significant bits are unused.
+ */
+
+/* 8-bit Bayer formats */
+#define DRM_FORMAT_SRGGB8	fourcc_code('R', 'G', 'G', 'B')
+#define DRM_FORMAT_SGRBG8	fourcc_code('G', 'R', 'B', 'G')
+#define DRM_FORMAT_SGBRG8	fourcc_code('G', 'B', 'R', 'G')
+#define DRM_FORMAT_SBGGR8	fourcc_code('B', 'A', '8', '1')
+
+/* 10-bit Bayer formats */
+#define DRM_FORMAT_SRGGB10	fourcc_code('R', 'G', '1', '0')
+#define DRM_FORMAT_SGRBG10	fourcc_code('B', 'A', '1', '0')
+#define DRM_FORMAT_SGBRG10	fourcc_code('G', 'B', '1', '0')
+#define DRM_FORMAT_SBGGR10	fourcc_code('B', 'G', '1', '0')
+
+/* 12-bit Bayer formats */
+#define DRM_FORMAT_SRGGB12	fourcc_code('R', 'G', '1', '2')
+#define DRM_FORMAT_SGRBG12	fourcc_code('B', 'A', '1', '2')
+#define DRM_FORMAT_SGBRG12	fourcc_code('G', 'B', '1', '2')
+#define DRM_FORMAT_SBGGR12	fourcc_code('B', 'G', '1', '2')
+
+/* 14-bit Bayer formats */
+#define DRM_FORMAT_SRGGB14	fourcc_code('R', 'G', '1', '4')
+#define DRM_FORMAT_SGRBG14	fourcc_code('B', 'A', '1', '4')
+#define DRM_FORMAT_SGBRG14	fourcc_code('G', 'B', '1', '4')
+#define DRM_FORMAT_SBGGR14	fourcc_code('B', 'G', '1', '4')
+
 /*
  * Format Modifiers:
  *
@@ -309,6 +365,7 @@ extern "C" {
 #define DRM_FORMAT_MOD_VENDOR_BROADCOM 0x07
 #define DRM_FORMAT_MOD_VENDOR_ARM     0x08
 #define DRM_FORMAT_MOD_VENDOR_ALLWINNER 0x09
+#define DRM_FORMAT_MOD_VENDOR_MIPI 0x0a
 
 /* add more to the end as needed */
 
@@ -434,6 +491,17 @@ extern "C" {
  */
 #define I915_FORMAT_MOD_Y_TILED_GEN12_MC_CCS fourcc_mod_code(INTEL, 7)
 
+
+/*
+ * IPU3 Bayer packing layout
+ *
+ * The IPU3 raw Bayer formats use a custom packing layout where there are no
+ * gaps between each 10-bit sample. It packs 25 pixels into 32 bytes leaving
+ * the 6 most significant bits in the last byte unused. The format is little
+ * endian.
+ */
+#define IPU3_FORMAT_MOD_PACKED fourcc_mod_code(INTEL, 8)
+
 /*
  * Tiled, NV12MT, grouped in 64 (pixels) x 32 (lines) -sized macroblocks
  *
@@ -804,6 +872,33 @@ extern "C" {
  */
 #define DRM_FORMAT_MOD_ALLWINNER_TILED fourcc_mod_code(ALLWINNER, 1)
 
+/* Mobile Industry Processor Interface (MIPI) modifiers */
+
+/*
+ * MIPI CSI-2 packing layout
+ *
+ * The CSI-2 RAW formats (for example Bayer) use a different packing layout
+ * depenindg on the sample size.
+ *
+ * - 10-bits per sample
+ *   Every four consecutive samples are packed into 5 bytes. Each of the first 4
+ *   bytes contain the 8 high order bits of the pixels, and the 5th byte
+ *   contains the 2 least-significant bits of each pixel, in the same order.
+ *
+ * - 12-bits per sample
+ *   Every two consecutive samples are packed into three bytes. Each of the
+ *   first two bytes contain the 8 high order bits of the pixels, and the third
+ *   byte contains the four least-significant bits of each pixel, in the same
+ *   order.
+ *
+ * - 14-bits per sample
+ *   Every four consecutive samples are packed into seven bytes. Each of the
+ *   first four bytes contain the eight high order bits of the pixels, and the
+ *   three following bytes contains the six least-significant bits of each
+ *   pixel, in the same order.
+ */
+#define MIPI_FORMAT_MOD_CSI2_PACKED fourcc_mod_code(MIPI, 1)
+
 #if defined(__cplusplus)
 }
 #endif
Signature · 6 lines
2.25.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw
Quoted 11 lines · On Fri, 28 Feb 2020 17:31:35 +0100 Niklas Söderlund…

Bayer formats are used with cameras and contain green, red and blue components, with alternating lines of red and green, and blue and green pixels in different orders. For each block of 2x2 pixels there is one pixel with a red filter, two with a green filter, and one with a blue filter. The filters can be arranged in different patterns.

Add DRM fourcc formats to describe the most common Bayer formats. Also add a modifiers to describe the custom packing layouts used by the Intel IPU3 and in the MIPI (Mobile Industry Processor Interface) CSI-2 specification.

Quoted 4 lines
---
 include/uapi/drm/drm_fourcc.h | 95 +++++++++++++++++++++++++++++++++++
 1 file changed, 95 insertions(+)

Hi,

here are some by-stander comments.

Quoted 25 lines
include/uapi/drm/drm_fourcc.h +16 -0
index 8bc0b31597d80737..561d5a08ffd16b69 100644
@@ -286,6 +286,62 @@ extern "C" {
 #define DRM_FORMAT_YVU444	fourcc_code('Y', 'V', '2', '4') /* non-subsampled Cr (1) and Cb (2) planes */
 
 
+/*
+ * Bayer formats
+ *
+ * Bayer formats contain green, red and blue components, with alternating lines
+ * of red and green, and blue and green pixels in different orders. For each
+ * block of 2x2 pixels there is one pixel with a red filter, two with a green
+ * filter, and one with a blue filter. The filters can be arranged in different
+ * patterns.
+ *
+ * For example, RGGB:
+ *	row0: RGRGRGRG...
+ *	row1: GBGBGBGB...
+ *	row3: RGRGRGRG...
+ *	row4: GBGBGBGB...
+ *	...
+ *

include/uapi/drm/drm_fourcc.h extern "C" { · line 314

Quoted 10 lines
include/uapi/drm/drm_fourcc.h +10 -0
+ * Vendors have different methods to pack the sampling formats to increase data
+ * density. For this reason the fourcc only describes pixel sample size and the
+ * filter pattern for each block of 2x2 pixels. A modifier is needed to
+ * describe the memory layout.
+ *
+ * In addition to vendor modifiers for memory layout DRM_FORMAT_MOD_LINEAR may
+ * be used to describe a layout where all samples are placed consecutively in
+ * memory. If the sample does not fit inside a single byte, the sample storage
+ * is extended to the minimum number of (little endian) bytes that can hold the
+ * sample and any unused most-significant bits are defined as padding.

"Minimum number of (little endian) bytes" is probably not quite right, because you could end up with a 3-byte word for e.g. 18-bit samples, and for those I don't think endianess is even a defined concept. Yes, you don't add any >16 bit formats here, but being careful here avoids having to face the question and confusion when someone does add such formats.

Alternatively, do not even pretend to define any layout for samples > 16 bits, and leave it for the future to be defined if/when the need arises.

include/uapi/drm/drm_fourcc.h extern "C" { · line 318

Quoted 4 lines
include/uapi/drm/drm_fourcc.h +4 -0
+ *
+ * For example, SRGGB10:
+ * Each 10-bit sample is contained in 2 consecutive little endian bytes, where
+ * the 6 most-significant bits are unused.

Nitpick: I think you mean "10-bit sample is contained in a uint16 word (little endian), ..."

"little endian byte" sounds like a strange concept to me, as it seems to delve into the order of bits in a byte, MSB or LSB first. I suspect most people would not even think of this, but I've been scarred by reading the Pixman pixel format definitions.

include/uapi/drm/drm_fourcc.h extern "C" { · line 322

Quoted 4 lines
include/uapi/drm/drm_fourcc.h +4 -0
+ */
+
+/* 8-bit Bayer formats */
+#define DRM_FORMAT_SRGGB8	fourcc_code('R', 'G', 'G', 'B')

The S in SRGGB is quite surprising to me. I saw it mentioned in IRC that it is easy to read as sRGB and I agree. I would not know to associate S with Bayer to begin with.

Why not e.g. DRM_FORMAT_BAYER_RGGB8?

include/uapi/drm/drm_fourcc.h extern "C" { · line 335

Quoted 13 lines
include/uapi/drm/drm_fourcc.h +13 -0
+#define DRM_FORMAT_SGRBG8	fourcc_code('G', 'R', 'B', 'G')
+#define DRM_FORMAT_SGBRG8	fourcc_code('G', 'B', 'R', 'G')
+#define DRM_FORMAT_SBGGR8	fourcc_code('B', 'A', '8', '1')
+
+/* 10-bit Bayer formats */
+#define DRM_FORMAT_SRGGB10	fourcc_code('R', 'G', '1', '0')
+#define DRM_FORMAT_SGRBG10	fourcc_code('B', 'A', '1', '0')
+#define DRM_FORMAT_SGBRG10	fourcc_code('G', 'B', '1', '0')
+#define DRM_FORMAT_SBGGR10	fourcc_code('B', 'G', '1', '0')
+
+/* 12-bit Bayer formats */
+#define DRM_FORMAT_SRGGB12	fourcc_code('R', 'G', '1', '2')
+#define DRM_FORMAT_SGRBG12	fourcc_code('B', 'A', '1', '2')

Conflict:

#define DRM_FORMAT_BGRA4444 fourcc_code('B', 'A', '1', '2') /* [15:0] B:G:R:A 4:4:4:4 little endian */

Does the kernel not have a "self-test" that ensures that all format codes (and why not modifiers as well) are unique?

Quoted 22 lines
include/uapi/drm/drm_fourcc.h +10 -0
+#define DRM_FORMAT_SGBRG12	fourcc_code('G', 'B', '1', '2')
+#define DRM_FORMAT_SBGGR12	fourcc_code('B', 'G', '1', '2')
+
+/* 14-bit Bayer formats */
+#define DRM_FORMAT_SRGGB14	fourcc_code('R', 'G', '1', '4')
+#define DRM_FORMAT_SGRBG14	fourcc_code('B', 'A', '1', '4')
+#define DRM_FORMAT_SGBRG14	fourcc_code('G', 'B', '1', '4')
+#define DRM_FORMAT_SBGGR14	fourcc_code('B', 'G', '1', '4')
+
 /*
  * Format Modifiers:
  *
@@ -309,6 +365,7 @@ extern "C" {
 #define DRM_FORMAT_MOD_VENDOR_BROADCOM 0x07
 #define DRM_FORMAT_MOD_VENDOR_ARM     0x08
 #define DRM_FORMAT_MOD_VENDOR_ALLWINNER 0x09
+#define DRM_FORMAT_MOD_VENDOR_MIPI 0x0a
 
 /* add more to the end as needed */
 
@@ -434,6 +491,17 @@ extern "C" {
  */

include/uapi/drm/drm_fourcc.h extern "C" { · line 501

Quoted 10 lines
include/uapi/drm/drm_fourcc.h +8 -0
 #define I915_FORMAT_MOD_Y_TILED_GEN12_MC_CCS fourcc_mod_code(INTEL, 7)
 
+
+/*
+ * IPU3 Bayer packing layout
+ *
+ * The IPU3 raw Bayer formats use a custom packing layout where there are no
+ * gaps between each 10-bit sample. It packs 25 pixels into 32 bytes leaving
+ * the 6 most significant bits in the last byte unused. The format is little
+ * endian.

Do I understand that right, that the collection of bytes (not words?) represents a stream of bits? In which order do you read the bits of a byte to produce the bits in a 10-bit unit?

I don't think "little endian" specifies that (even less for non-2/4/8-byte units), and Pixman formats prove that the order could be specified either way.

Does the "little endian" mean that in the 32 bytes long unit, one needs to extract in chunks of uint16_t/uint32_t/uint64_t and inspect the bits of those words, or is the 32-byte unit supposed to be read byte by byte in which case endianess plays no role?

If possible, it would be good to reword the definition so that these questions cannot arise.

Quoted 12 lines
include/uapi/drm/drm_fourcc.h +5 -0
+ */
+#define IPU3_FORMAT_MOD_PACKED fourcc_mod_code(INTEL, 8)
+
 /*
  * Tiled, NV12MT, grouped in 64 (pixels) x 32 (lines) -sized macroblocks
  *
@@ -804,6 +872,33 @@ extern "C" {
  */
 #define DRM_FORMAT_MOD_ALLWINNER_TILED fourcc_mod_code(ALLWINNER, 1)
 
+/* Mobile Industry Processor Interface (MIPI) modifiers */
+

include/uapi/drm/drm_fourcc.h extern "C" { · line 886

Quoted 10 lines
include/uapi/drm/drm_fourcc.h +10 -0
+/*
+ * MIPI CSI-2 packing layout
+ *
+ * The CSI-2 RAW formats (for example Bayer) use a different packing layout
+ * depenindg on the sample size.
+ *
+ * - 10-bits per sample
+ *   Every four consecutive samples are packed into 5 bytes. Each of the first 4
+ *   bytes contain the 8 high order bits of the pixels, and the 5th byte
+ *   contains the 2 least-significant bits of each pixel, in the same order.

...in the same order? So bits 0-1 are the bits 0-1 of the 1st sample, bits 2-3 are the bits 0-1 of the 2nd sample, etc?

include/uapi/drm/drm_fourcc.h extern "C" { · line 898

Quoted 12 lines
include/uapi/drm/drm_fourcc.h +12 -0
+ *
+ * - 12-bits per sample
+ *   Every two consecutive samples are packed into three bytes. Each of the
+ *   first two bytes contain the 8 high order bits of the pixels, and the third
+ *   byte contains the four least-significant bits of each pixel, in the same
+ *   order.
+ *
+ * - 14-bits per sample
+ *   Every four consecutive samples are packed into seven bytes. Each of the
+ *   first four bytes contain the eight high order bits of the pixels, and the
+ *   three following bytes contains the six least-significant bits of each
+ *   pixel, in the same order.

How do you count the bits when crossing the byte boundary on the last 3 bytes? Is it an imaginary 24-bit word, or do you take it byte by byte like this:

byte0 bits 0-5: 1st sample bits 0-5
byte0 bits 6-7: 2nd sample bits 0-1
byte1 bits 0-3: 2nd sample bits 2-5
byte1 bits 4-7: 3rd sample bits 0-3
byte2 bits 0-1: 3rd sample bits 4-5
byte2 bits 2-7: 4th sample bits 0-5

include/uapi/drm/drm_fourcc.h extern "C" { · line 904

Quoted 6 lines
include/uapi/drm/drm_fourcc.h +3 -0
+ */
+#define MIPI_FORMAT_MOD_CSI2_PACKED fourcc_mod_code(MIPI, 1)
+
 #if defined(__cplusplus)
 }
 #endif

Thanks,
pq

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw
Quoted 32 lines · Pekka Paalanen
Quoted 11 lines · On Fri, 28 Feb 2020 17:31:35 +0100 Niklas Söderlund…

Bayer formats are used with cameras and contain green, red and blue components, with alternating lines of red and green, and blue and green pixels in different orders. For each block of 2x2 pixels there is one pixel with a red filter, two with a green filter, and one with a blue filter. The filters can be arranged in different patterns.

Add DRM fourcc formats to describe the most common Bayer formats. Also add a modifiers to describe the custom packing layouts used by the Intel IPU3 and in the MIPI (Mobile Industry Processor Interface) CSI-2 specification.

Quoted 4 lines
---
 include/uapi/drm/drm_fourcc.h | 95 +++++++++++++++++++++++++++++++++++
 1 file changed, 95 insertions(+)

Hi,

here are some by-stander comments.

Quoted 9 lines
include/uapi/drm/drm_fourcc.h +0 -0
index 8bc0b31597d80737..561d5a08ffd16b69 100644
@@ -286,6 +286,62 @@ extern "C" {
 #define DRM_FORMAT_YVU444	fourcc_code('Y', 'V', '2', '4') /* non-subsampled Cr (1) and Cb (2) planes */
 
 
Quoted 12 lines

include/uapi/drm/drm_fourcc.h extern "C" { · line 300

Quoted 12 lines
include/uapi/drm/drm_fourcc.h +12 -0
+/*
+ * Bayer formats
+ *
+ * Bayer formats contain green, red and blue components, with alternating lines
+ * of red and green, and blue and green pixels in different orders. For each
+ * block of 2x2 pixels there is one pixel with a red filter, two with a green
+ * filter, and one with a blue filter. The filters can be arranged in different
+ * patterns.
+ *
+ * For example, RGGB:
+ *	row0: RGRGRGRG...
+ *	row1: GBGBGBGB...

Whare is row2?

Quoted 15 lines
Quoted 4 lines
include/uapi/drm/drm_fourcc.h +4 -0
+ *	row3: RGRGRGRG...
+ *	row4: GBGBGBGB...
+ *	...
+ *

include/uapi/drm/drm_fourcc.h extern "C" { · line 314

Quoted 10 lines
include/uapi/drm/drm_fourcc.h +10 -0
+ * Vendors have different methods to pack the sampling formats to increase data
+ * density. For this reason the fourcc only describes pixel sample size and the
+ * filter pattern for each block of 2x2 pixels. A modifier is needed to
+ * describe the memory layout.
+ *
+ * In addition to vendor modifiers for memory layout DRM_FORMAT_MOD_LINEAR may
+ * be used to describe a layout where all samples are placed consecutively in
+ * memory. If the sample does not fit inside a single byte, the sample storage
+ * is extended to the minimum number of (little endian) bytes that can hold the
+ * sample and any unused most-significant bits are defined as padding.
Quoted 3 lines

"Minimum number of (little endian) bytes" is probably not quite right, because you could end up with a 3-byte word for e.g. 18-bit samples, and for those I don't think endianess is even a defined concept.

In my book little-endian == "little end comes first". Nothing in that definition that says the number of bytes per unit has to a power of two.

I guess maybe another way to put it would be to say "each sample is stored as lsb aligned little endian value in minimum number of bytes required". But some visual representation could help more I guess. We try do that for the normal formats.

Though I don't really know what "samples are placed consecutively in memory" is trying to say here. Eg. for the row0-row4 example above would we store this as RGRGRG...GBGBGB... or something more like RGGBRGGBRGGB..., or something else?

Side note:
Since people seem a bit confused by our use of "little endian" in general I was thinking we should maybe update all the definitions to be even more explicit. Something alogned the lines of:
"pixel [31:30 A][29:20 R][19:10 G][9:0 B]
byte [ 3 ][ 2 ][ 1 ][ 0 ]"

Though the mismathed proportions make it rather ugly.

Maybe we should even show the bit numbers for each component along with everything else:
"component [1 A 0][9 R 4..3 R 0][9 G 6..5 G 0][9 B 8..7 B 0]
pixel [31 A 30][29 R 24..23 R 20][19 G 16..15 G 10][9 B 8..7 B 0]
byte [ 3 ][ 2 ][ 1 ][ 0 ]"

Could stretch the bytes to uniform size I guess. But still not entirely readable :(

Anyways, ideas for an actually good way to docuement formats welcome...

Signature · 6 lines
Ville Syrjälä
Intel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#3 lore raw
In reply to Niklas Söderlund

Hi Niklas,

Thank you for the patch.

Quoted 32 lines · Niklas Söderlund

Bayer formats are used with cameras and contain green, red and blue components, with alternating lines of red and green, and blue and green pixels in different orders. For each block of 2x2 pixels there is one pixel with a red filter, two with a green filter, and one with a blue filter. The filters can be arranged in different patterns.

Add DRM fourcc formats to describe the most common Bayer formats. Also add a modifiers to describe the custom packing layouts used by the Intel IPU3 and in the MIPI (Mobile Industry Processor Interface) CSI-2 specification.

---
 include/uapi/drm/drm_fourcc.h | 95 +++++++++++++++++++++++++++++++++++
 1 file changed, 95 insertions(+)
include/uapi/drm/drm_fourcc.h +8 -0
index 8bc0b31597d80737..561d5a08ffd16b69 100644
@@ -286,6 +286,62 @@ extern "C" {
 #define DRM_FORMAT_YVU444	fourcc_code('Y', 'V', '2', '4') /* non-subsampled Cr (1) and Cb (2) planes */
 
 
+/*
+ * Bayer formats
+ *
+ * Bayer formats contain green, red and blue components, with alternating lines
+ * of red and green, and blue and green pixels in different orders. For each
+ * block of 2x2 pixels there is one pixel with a red filter, two with a green
+ * filter, and one with a blue filter. The filters can be arranged in different
+ * patterns.

include/uapi/drm/drm_fourcc.h extern "C" { · line 306

Quoted 10 lines
include/uapi/drm/drm_fourcc.h +10 -0
+ *
+ * For example, RGGB:
+ *	row0: RGRGRGRG...
+ *	row1: GBGBGBGB...
+ *	row3: RGRGRGRG...
+ *	row4: GBGBGBGB...
+ *	...
+ *
+ * Vendors have different methods to pack the sampling formats to increase data
+ * density. For this reason the fourcc only describes pixel sample size and the

This could be for other reasons than data density, such as for less cumbersome memory access. I'd leave out "to increase data density".

include/uapi/drm/drm_fourcc.h extern "C" { · line 314

Quoted 8 lines
include/uapi/drm/drm_fourcc.h +8 -0
+ * filter pattern for each block of 2x2 pixels. A modifier is needed to
+ * describe the memory layout.
+ *
+ * In addition to vendor modifiers for memory layout DRM_FORMAT_MOD_LINEAR may
+ * be used to describe a layout where all samples are placed consecutively in
+ * memory. If the sample does not fit inside a single byte, the sample storage
+ * is extended to the minimum number of (little endian) bytes that can hold the
+ * sample and any unused most-significant bits are defined as padding.

Should it be added here that padding bits are all zero?

Quoted 19 lines
include/uapi/drm/drm_fourcc.h +19 -0
+ *
+ * For example, SRGGB10:
+ * Each 10-bit sample is contained in 2 consecutive little endian bytes, where
+ * the 6 most-significant bits are unused.
+ */
+
+/* 8-bit Bayer formats */
+#define DRM_FORMAT_SRGGB8	fourcc_code('R', 'G', 'G', 'B')
+#define DRM_FORMAT_SGRBG8	fourcc_code('G', 'R', 'B', 'G')
+#define DRM_FORMAT_SGBRG8	fourcc_code('G', 'B', 'R', 'G')
+#define DRM_FORMAT_SBGGR8	fourcc_code('B', 'A', '8', '1')
+
+/* 10-bit Bayer formats */
+#define DRM_FORMAT_SRGGB10	fourcc_code('R', 'G', '1', '0')
+#define DRM_FORMAT_SGRBG10	fourcc_code('B', 'A', '1', '0')
+#define DRM_FORMAT_SGBRG10	fourcc_code('G', 'B', '1', '0')
+#define DRM_FORMAT_SBGGR10	fourcc_code('B', 'G', '1', '0')
+
+/* 12-bit Bayer formats */

include/uapi/drm/drm_fourcc.h extern "C" { · line 343

Quoted 10 lines
include/uapi/drm/drm_fourcc.h +10 -0
+#define DRM_FORMAT_SRGGB12	fourcc_code('R', 'G', '1', '2')
+#define DRM_FORMAT_SGRBG12	fourcc_code('B', 'A', '1', '2')
+#define DRM_FORMAT_SGBRG12	fourcc_code('G', 'B', '1', '2')
+#define DRM_FORMAT_SBGGR12	fourcc_code('B', 'G', '1', '2')
+
+/* 14-bit Bayer formats */
+#define DRM_FORMAT_SRGGB14	fourcc_code('R', 'G', '1', '4')
+#define DRM_FORMAT_SGRBG14	fourcc_code('B', 'A', '1', '4')
+#define DRM_FORMAT_SGBRG14	fourcc_code('G', 'B', '1', '4')
+#define DRM_FORMAT_SBGGR14	fourcc_code('B', 'G', '1', '4')

The 4cc codes seemingly appear to those used in V4L2. Is that intentional? Nothing wrong in that though, but is this a rule that's universally followed?

Quoted 14 lines
include/uapi/drm/drm_fourcc.h +2 -0
+
 /*
  * Format Modifiers:
  *
@@ -309,6 +365,7 @@ extern "C" {
 #define DRM_FORMAT_MOD_VENDOR_BROADCOM 0x07
 #define DRM_FORMAT_MOD_VENDOR_ARM     0x08
 #define DRM_FORMAT_MOD_VENDOR_ALLWINNER 0x09
+#define DRM_FORMAT_MOD_VENDOR_MIPI 0x0a
 
 /* add more to the end as needed */
 
@@ -434,6 +491,17 @@ extern "C" {
  */

include/uapi/drm/drm_fourcc.h extern "C" { · line 501

Quoted 10 lines
include/uapi/drm/drm_fourcc.h +8 -0
 #define I915_FORMAT_MOD_Y_TILED_GEN12_MC_CCS fourcc_mod_code(INTEL, 7)
 
+
+/*
+ * IPU3 Bayer packing layout
+ *
+ * The IPU3 raw Bayer formats use a custom packing layout where there are no
+ * gaps between each 10-bit sample. It packs 25 pixels into 32 bytes leaving
+ * the 6 most significant bits in the last byte unused. The format is little
+ * endian.

Where is endianness really specified? DRM_FORMAT_BIG_ENDIAN would seem independent of that.

I might omit endianness definition here.

Quoted 7 lines
include/uapi/drm/drm_fourcc.h +3 -0
+ */
+#define IPU3_FORMAT_MOD_PACKED fourcc_mod_code(INTEL, 8)
+
 /*
  * Tiled, NV12MT, grouped in 64 (pixels) x 32 (lines) -sized macroblocks
  *

include/uapi/drm/drm_fourcc.h extern "C" { · line 881

Quoted 10 lines
include/uapi/drm/drm_fourcc.h +7 -0
@@ -804,6 +872,33 @@ extern "C" {
  */
 #define DRM_FORMAT_MOD_ALLWINNER_TILED fourcc_mod_code(ALLWINNER, 1)
 
+/* Mobile Industry Processor Interface (MIPI) modifiers */
+
+/*
+ * MIPI CSI-2 packing layout
+ *
+ * The CSI-2 RAW formats (for example Bayer) use a different packing layout
+ * depenindg on the sample size.

"depending"

Quoted 23 lines
include/uapi/drm/drm_fourcc.h +20 -0
+ *
+ * - 10-bits per sample
+ *   Every four consecutive samples are packed into 5 bytes. Each of the first 4
+ *   bytes contain the 8 high order bits of the pixels, and the 5th byte
+ *   contains the 2 least-significant bits of each pixel, in the same order.
+ *
+ * - 12-bits per sample
+ *   Every two consecutive samples are packed into three bytes. Each of the
+ *   first two bytes contain the 8 high order bits of the pixels, and the third
+ *   byte contains the four least-significant bits of each pixel, in the same
+ *   order.
+ *
+ * - 14-bits per sample
+ *   Every four consecutive samples are packed into seven bytes. Each of the
+ *   first four bytes contain the eight high order bits of the pixels, and the
+ *   three following bytes contains the six least-significant bits of each
+ *   pixel, in the same order.
+ */
+#define MIPI_FORMAT_MOD_CSI2_PACKED fourcc_mod_code(MIPI, 1)
+
 #if defined(__cplusplus)
 }
 #endif
Signature · 7 lines
Kind regards,

Sakari Ailus
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel