Skip to contentSkip to conversation

drm: Redefine pixel formats

PATCH New [email protected] 2 participants 5 messages Nov 17, 2011

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 drm: Redefine pixel formats

From: Ville Syrjälä <[email protected]>

Name the formats as DRM_FORMAT_X instead of DRM_FOURCC_X. Use consistent names, especially for the RGB formats. Component order and byte order are now strictly specified for each format.

The RGB format naming follows a convention where the components names and sizes are listed from left to right, matching the order within a single pixel from most significant bit to least significant bit.

The YUV format names vary more. For the 4:2:2 packed formats and 2 plane formats use the fourcc. For the three plane formats the name includes the plane order and subsampling information using the standard subsampling notation. Some of those also happen to match the official fourcc definition.

The fourccs for for all the RGB formats and some of the YUV formats I invented myself. The idea was that looking at just the fourcc you get some idea what the format is about without having to decode it using some external reference.

---
v2:
* Drop the lower case w/ mixed number/letter naming scheme
* Make all formats little endian by default, and add DRM_FORMAT_BIG_ENDIAN flag
* Add 4444 formats with alpha, and AYUV and YUV444/YVU444 formats

 drivers/gpu/drm/drm_crtc.c           |   18 +++---
 drivers/gpu/drm/drm_crtc_helper.c    |   39 +++++++++--
 drivers/gpu/drm/i915/intel_display.c |   18 +++--
 include/drm/drm_fourcc.h             |  121 ++++++++++++++++++++++++++--------
 4 files changed, 146 insertions(+), 50 deletions(-)
drivers/gpu/drm/drm_crtc.c +9 -9
index 30a70a4..49c80df 100644
@@ -1918,28 +1918,28 @@ uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth)
 
 	switch (bpp) {
 	case 8:
-		fmt = DRM_FOURCC_RGB332;
+		fmt = DRM_FORMAT_RGB332;
 		break;
 	case 16:
 		if (depth == 15)
-			fmt = DRM_FOURCC_RGB555;
+			fmt = DRM_FORMAT_XRGB1555;
 		else
-			fmt = DRM_FOURCC_RGB565;
+			fmt = DRM_FORMAT_RGB565;
 		break;
 	case 24:
-		fmt = DRM_FOURCC_RGB24;
+		fmt = DRM_FORMAT_RGB888;
 		break;
 	case 32:
 		if (depth == 24)
-			fmt = DRM_FOURCC_RGB24;
+			fmt = DRM_FORMAT_XRGB8888;
 		else if (depth == 30)
-			fmt = DRM_INTEL_RGB30;
+			fmt = DRM_FORMAT_XRGB2101010;
 		else
-			fmt = DRM_FOURCC_RGB32;
+			fmt = DRM_FORMAT_ARGB8888;
 		break;
 	default:
-		DRM_ERROR("bad bpp, assuming RGB24 pixel format\n");
-		fmt = DRM_FOURCC_RGB24;
+		DRM_ERROR("bad bpp, assuming x8r8g8b8 pixel format\n");
+		fmt = DRM_FORMAT_XRGB8888;
 		break;
 	}
 
drivers/gpu/drm/drm_crtc_helper.c +33 -6
index 3e0645c..6cc0fb5 100644
@@ -816,27 +816,54 @@ void drm_helper_get_fb_bpp_depth(uint32_t format, unsigned int *depth,
 				 int *bpp)
 {
 	switch (format) {
-	case DRM_FOURCC_RGB332:
+	case DRM_FORMAT_RGB332:
+	case DRM_FORMAT_BGR233:
 		*depth = 8;
 		*bpp = 8;
 		break;
-	case DRM_FOURCC_RGB555:
+	case DRM_FORMAT_XRGB1555:
+	case DRM_FORMAT_XBGR1555:
+	case DRM_FORMAT_RGBX5551:
+	case DRM_FORMAT_BGRX5551:
+	case DRM_FORMAT_ARGB1555:
+	case DRM_FORMAT_ABGR1555:
+	case DRM_FORMAT_RGBA5551:
+	case DRM_FORMAT_BGRA5551:
 		*depth = 15;
 		*bpp = 16;
 		break;
-	case DRM_FOURCC_RGB565:
+	case DRM_FORMAT_RGB565:
+	case DRM_FORMAT_BGR565:
 		*depth = 16;
 		*bpp = 16;
 		break;
-	case DRM_FOURCC_RGB24:
+	case DRM_FORMAT_RGB888:
+	case DRM_FORMAT_BGR888:
+		*depth = 24;
+		*bpp = 24;
+		break;
+	case DRM_FORMAT_XRGB8888:
+	case DRM_FORMAT_XBGR8888:
+	case DRM_FORMAT_RGBX8888:
+	case DRM_FORMAT_BGRX8888:
 		*depth = 24;
 		*bpp = 32;
 		break;
-	case DRM_INTEL_RGB30:
+	case DRM_FORMAT_XRGB2101010:
+	case DRM_FORMAT_XBGR2101010:
+	case DRM_FORMAT_RGBX1010102:
+	case DRM_FORMAT_BGRX1010102:
+	case DRM_FORMAT_ARGB2101010:
+	case DRM_FORMAT_ABGR2101010:
+	case DRM_FORMAT_RGBA1010102:
+	case DRM_FORMAT_BGRA1010102:
 		*depth = 30;
 		*bpp = 32;
 		break;
-	case DRM_FOURCC_RGB32:
+	case DRM_FORMAT_ARGB8888:
+	case DRM_FORMAT_ABGR8888:
+	case DRM_FORMAT_RGBA8888:
+	case DRM_FORMAT_BGRA8888:
 		*depth = 32;
 		*bpp = 32;
 		break;
drivers/gpu/drm/i915/intel_display.c +10 -8
index 50ae915..0bc93c3 100644
@@ -7585,16 +7585,18 @@ int intel_framebuffer_init(struct drm_device *dev,
 		return -EINVAL;
 
 	switch (mode_cmd->pixel_format) {
-	case DRM_FOURCC_RGB332:
-	case DRM_FOURCC_RGB565:
-	case DRM_FOURCC_RGB24:
-	case DRM_INTEL_RGB30:
+	case DRM_FORMAT_RGB332:
+	case DRM_FORMAT_RGB565:
+	case DRM_FORMAT_XRGB8888:
+	case DRM_FORMAT_ARGB8888:
+	case DRM_FORMAT_XRGB2101010:
+	case DRM_FORMAT_ARGB2101010:
 		/* RGB formats are common across chipsets */
 		break;
-	case DRM_FOURCC_YUYV:
-	case DRM_FOURCC_UYVY:
-	case DRM_FOURCC_YVYU:
-	case DRM_FOURCC_VYUY:
+	case DRM_FORMAT_YUYV:
+	case DRM_FORMAT_UYVY:
+	case DRM_FORMAT_YVYU:
+	case DRM_FORMAT_VYUY:
 		break;
 	default:
 		DRM_ERROR("unsupported pixel format\n");
include/drm/drm_fourcc.h +94 -27

134 lines not on this page · raw message

Signature · 6 lines
1.7.3.4

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

PATCH 2/2 drop planar YUV format with Y Cr Cb plane ordering

From: Ville Syrjälä <[email protected]>

Swapping the handle/offset indexes is enough to support such formats.

---
Not sure we want this or not, but dropping these wouldn't remove any functionality.

 include/drm/drm_fourcc.h |    8 --------
 1 files changed, 0 insertions(+), 8 deletions(-)
include/drm/drm_fourcc.h +0 -8
index bb75249..1700a7e 100644
@@ -112,19 +112,11 @@
  * index 0: Y plane, [7:0] Y
  * index 1: Cb plane, [7:0] Cb
  * index 2: Cr plane, [7:0] Cr
- * or
- * index 1: Cr plane, [7:0] Cr
- * index 2: Cb plane, [7:0] Cb
  */
 #define DRM_FORMAT_YUV410	fourcc_code('Y', 'U', 'V', '9') /* 4x4 subsampled Cb (1) and Cr (2) planes */
-#define DRM_FORMAT_YVU410	fourcc_code('Y', 'V', 'U', '9') /* 4x4 subsampled Cr (1) and Cb (2) planes */
 #define DRM_FORMAT_YUV411	fourcc_code('Y', 'U', '1', '1') /* 4x1 subsampled Cb (1) and Cr (2) planes */
-#define DRM_FORMAT_YVU411	fourcc_code('Y', 'V', '1', '1') /* 4x1 subsampled Cr (1) and Cb (2) planes */
 #define DRM_FORMAT_YUV420	fourcc_code('Y', 'U', '1', '2') /* 2x2 subsampled Cb (1) and Cr (2) planes */
-#define DRM_FORMAT_YVU420	fourcc_code('Y', 'V', '1', '2') /* 2x2 subsampled Cr (1) and Cb (2) planes */
 #define DRM_FORMAT_YUV422	fourcc_code('Y', 'U', '1', '6') /* 2x1 subsampled Cb (1) and Cr (2) planes */
-#define DRM_FORMAT_YVU422	fourcc_code('Y', 'V', '1', '6') /* 2x1 subsampled Cr (1) and Cb (2) planes */
 #define DRM_FORMAT_YUV444	fourcc_code('Y', 'U', '2', '4') /* non-subsampled Cb (1) and Cr (2) planes */
-#define DRM_FORMAT_YVU444	fourcc_code('Y', 'V', '2', '4') /* non-subsampled Cr (1) and Cb (2) planes */
 
 #endif /* DRM_FOURCC_H */
Signature · 6 lines
1.7.3.4

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw

Re: [PATCH 2/2] drop planar YUV format with Y Cr Cb plane ordering

Quoted 8 lines · On Thu, 17 Nov 2011 18:05:14 +0200 [email protected] wrote:

From: Ville Syrjälä <[email protected]>

Swapping the handle/offset indexes is enough to support such formats.

---
Not sure we want this or not, but dropping these wouldn't remove any functionality.

What if your surfaces are packed into a single bo? It would be a pain to move them around in that case...

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center

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

#3 lore raw

Re: [PATCH 2/2] drop planar YUV format with Y Cr Cb plane ordering

Quoted 7 lines · Jesse Barnes
Quoted 4 lines · On Thu, 17 Nov 2011 18:05:14 +0200 [email protected] wrote:

From: Ville Syrjälä <[email protected]>

Swapping the handle/offset indexes is enough to support such formats.

Quoted 7 lines
Quoted 4 lines

---
Not sure we want this or not, but dropping these wouldn't remove any functionality.

What if your surfaces are packed into a single bo? It would be a pain to move them around in that case...

That's what offset[] is for, no?

Signature · 2 lines
Ville Syrjälä
Intel OTC
#4 lore raw

Re: [PATCH 2/2] drop planar YUV format with Y Cr Cb plane ordering

Quoted 13 lines · On Thu, 17 Nov 2011 19:14:07 +0200 Ville Syrjälä…
Quoted 12 lines · Jesse Barnes
Quoted 8 lines · On Thu, 17 Nov 2011 18:05:14 +0200 [email protected] wrote:

From: Ville Syrjälä <[email protected]>

Swapping the handle/offset indexes is enough to support such formats.

---
Not sure we want this or not, but dropping these wouldn't remove any functionality.

Quoted 4 lines
Quoted 2 lines

What if your surfaces are packed into a single bo? It would be a pain to move them around in that case...

That's what offset[] is for, no?

Oh duh, yes it is. I confused myself by adding both per-plane bits and then multi-object bits. :)

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center

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