drm: Document the alpha blending rules
Subsystems (2)
PATCH 1/1 drm: Document the alpha blending rules
From: Ville Syrjälä <[email protected]>
Document the fact that the use of a framebuffer with alpha implies pre-multipled alpha blending, and that the crtc background color is assumed to be black.
Not sure drm_fourcc.h is the best place for the uapi docs, but couldn't think of anything better really.
--- drivers/gpu/drm/drm_plane.c | 6 ++++++ include/uapi/drm/drm_fourcc.h | 7 +++++++ 2 files changed, 13 insertions(+)
drivers/gpu/drm/drm_plane.c +6 -0
@@ -48,6 +48,12 @@* * The type of a plane is exposed in the immutable "type" enumeration property, * which has one of the following values: "Overlay", "Primary", "Cursor". +* +* Use of a framebuffer with alpha implies that the plane will use +* pre-multiplied alpha blending: Dc = Sc + (1.0 - Sa) * Dc, +* where Sa is source alpha, Sc is source color, and Dc is destination +* color. The crtc background color below all the planes is assumed to +* be black. */ static unsigned int drm_num_planes (struct drm_device *dev)
include/uapi/drm/drm_fourcc.h +7 -0
@@ -35,6 +35,13 @@ extern "C" {#define DRM_FORMAT_BIG_ENDIAN (1<<31)/* format is big endian instead of little endian */ +/* +* Note that using any format with alpha (A) implies pre-multiplied +* alpha blending: Dc = Sc + (1.0 - Sa) * Dc, where Sa is source alpha, +* Sc is source color, and Dc is destination color. The crtc background +* color below all the planes is assumed to be black. +*/ +/* color index */ #define DRM_FORMAT_C8 fourcc_code('C', '8', ' ', ' ')/* [7:0] C */
Signature · 6 lines
2.16.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 8 lines · Ville Syrjala
From: Ville Syrjälä <[email protected]>
Document the fact that the use of a framebuffer with alpha implies pre-multipled alpha blending, and that the crtc background color is assumed to be black.
Not sure
drm_fourcc.his the best place for the uapi docs, but couldn't think of anything better really.
I started to documented the plane blending rules in the docs for atomic properties:
https://dri.freedesktop.org/docs/drm/gpu/drm-kms.html#plane-composition-properties
It already mentions that the background color is black:
"Note that all the property extensions described here apply either to the plane or the CRTC (e.g. for the background color, which currently is not exposed and assumed to be black)."
Iirc the alpha property patches will add more docs in this area and clarify all the blending rules a bit more.
Quoted 16 lines
Cc Mario Kleiner <[email protected]>Cc Stefan Schake <[email protected]>Cc Eric Anholt <[email protected]>Cc Adrian Salido <[email protected]>Cc Sean Paul <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/drm_plane.c | 6 ++++++ include/uapi/drm/drm_fourcc.h | 7 +++++++ 2 files changed, 13 insertions(+)drivers/gpu/drm/drm_plane.c +0
-0
drivers/gpu/drm/drm_plane.c line 56
Quoted 9 lines
drivers/gpu/drm/drm_plane.c +6
-0@@ -48,6 +48,12 @@* * The type of a plane is exposed in the immutable "type" enumeration property, * which has one of the following values: "Overlay", "Primary", "Cursor". +* +* Use of a framebuffer with alpha implies that the plane will use +* pre-multiplied alpha blending: Dc = Sc + (1.0 - Sa) * Dc, +* where Sa is source alpha, Sc is source color, and Dc is destination +* color. The crtc background color below all the planes is assumed to +* be black.
Maybe we just need to add a sphinx link to the plane composition properties section here? Since kerneldoc is just plain rst we can do this.
Quoted 8 lines
drivers/gpu/drm/drm_plane.c +0
-0*/ static unsigned int drm_num_planes (struct drm_device *dev)include/uapi/drm/drm_fourcc.h +0
-0
include/uapi/drm/drm_fourcc.h extern "C" { · line 43
Quoted 9 lines
include/uapi/drm/drm_fourcc.h +6
-0@@ -35,6 +35,13 @@ extern "C" {#define DRM_FORMAT_BIG_ENDIAN (1<<31)/* format is big endian instead of little endian */ +/* +* Note that using any format with alpha (A) implies pre-multiplied +* alpha blending: Dc = Sc + (1.0 - Sa) * Dc, where Sa is source alpha, +* Sc is source color, and Dc is destination color. The crtc background +* color below all the planes is assumed to be black. +*/
This sounds like perfect fodder for a DOC overview section for drm_fourcc.[hc]. We already include the function docs into the overall kerneldoc.
-Daniel
Quoted 11 lines
include/uapi/drm/drm_fourcc.h +1
-0+/* color index */ #define DRM_FORMAT_C8 fourcc_code('C', '8', ' ', ' ')/* [7:0] C */ Signature · 6 lines
2.16.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel