From 238b38e51adda217397bee44f496b7560507ed2e Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Wed, 11 Apr 2018 10:19:04 +0100 Subject: [PATCH 1/2] docs/wayland-drm: Note wl_drm is deprecated Encourage people to use the standard linux-dmabuf extension, since wl_drm is a private implementation detail of Mesa. --- docs/wayland_drm.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/wayland_drm.md b/docs/wayland_drm.md index 515b4e1..2b7da99 100644 --- a/docs/wayland_drm.md +++ b/docs/wayland_drm.md @@ -1,5 +1,10 @@ # Wayland-drm pixel formats +This page describes the formats used by the private `wl_drm` extension, +implemented by Mesa. This extension has been superseded by the linux-dmabuf +extension, which provides a generic buffer-exchange protocol using the [DRM +pixel format](drm.md) descriptors. + The wayland-drm pixel formats follow the scheme: WL_DRM_FORMAT_{component-format} From bd5f04bd105bdbdafd100924746f4bd78f51f40d Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Wed, 11 Apr 2018 10:20:25 +0100 Subject: [PATCH 2/2] doc/drm, pfg/drm: Expand DRM formats to cover GBM GBM format tokens are redundant aliases of DRM formats, conveying the exact same meaning with the same names and token values. GBM's ABI requires they be identical. Extend the DRM format guide descriptor to also discuss GBM formats, whilst consistently capitalising DRM. Also include the two inexplicable special cases of XRGB8888/ARGB8888, which have duplicate token values. --- docs/drm.md | 27 +++++++++++++++++++++++++-- docs/index.md | 2 +- pfg/drm.py | 7 ++++++- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/docs/drm.md b/docs/drm.md index 951da6c..081fbb4 100644 --- a/docs/drm.md +++ b/docs/drm.md @@ -1,6 +1,6 @@ # DRM pixel formats -The drm pixel formats follow the scheme: +The DRM pixel formats follow the scheme: DRM_FORMAT_{component-format} @@ -8,7 +8,15 @@ The `component-format` part specifies the order and sizes of the components. All the components are listed first, optionally followed by their corresponding sizes in bits (e.g., `RGB888`, `YUVY`). -There are a few categories of drm formats: +The GBM pixel formats follow the scheme: + + GBM_FORMAT_{component-format} + +GBM formats have the same names, enumeration values, interpretation, and meaning +as DRM formats; this document uses DRM names, however the descriptions equally +apply to GBM. There are however two special cases, described below. + +There are a few categories of DRM formats: * RGBA formats: `DRM_FORMAT_{rgba-componenent-format}` @@ -54,6 +62,21 @@ There are a few categories of drm formats: Always stored as Y₀, U, Y₁, V in memory (Y₀ at lowest address, V at the highest) +* GBM BO formats: `GBM_BO_FORMAT_{rgba-component-format}` + + GBM specifies two 'BO formats', as aliases for the equivalent + `GBM_FORMAT_{rgba-component-format}` tokens. These format tokens are accepted + as input parameters to GBM buffer allocation entrypoints, however are never + returned as output from the API, e.g. via `gbm_bo_get_format`. + + **`GBM_BO_FORMAT_ARGB8888`** + + This is an alias for `GBM_FORMAT_ARGB8888`, and carries the same meaning. + + **`GBM_BO_FORMAT_XRGB8888`** + + This is an alias for `GBM_FORMAT_XRGB8888`, and carries the same meaning. + * Multi-plane formats: We won't describe these in detail in this guide. diff --git a/docs/index.md b/docs/index.md index 394161b..e837cec 100644 --- a/docs/index.md +++ b/docs/index.md @@ -50,7 +50,7 @@ help you understand the conventions used by the various pixel format families. * [BGRABitmap pixel formats](bgrabitmap.md) * [Cairo pixel formats](cairo.md) * [DirectFB pixel formats](directfb.md) -* [DRM pixel formats](drm.md) +* [DRM/GBM pixel formats](drm.md) * [OpenGL pixel formats](opengl.md) * [Pixman pixel formats](pixman.md) * [Qt pixel formats](qt.md) diff --git a/pfg/drm.py b/pfg/drm.py index 9a9d93f..0dafd6e 100644 --- a/pfg/drm.py +++ b/pfg/drm.py @@ -22,7 +22,7 @@ from . import util import re -drm_re = re.compile("DRM_FORMAT_(?P.*)") +drm_re = re.compile("(DRM|GBM)_FORMAT_(?P.*)") drm_formats = [ "DRM_FORMAT_C8", @@ -84,6 +84,11 @@ def yuv_bits_to_memory(components): return util.split_bytes(components) def describe(format_str): + if format_str == "GBM_BO_FORMAT_XRGB8888": + format_str = "GBM_FORMAT_XRGB8888" + elif format_str == "GBM_BO_FORMAT_ARGB8888": + format_str = "GBM_FORMAT_ARGB8888" + match = drm_re.match(format_str) if not match: