Skip to contentSkip to conversation

drm/blend: Add per-plane pixel blend mode property

PATCH Lowry Li 1 participant 1 message May 30, 2018

Subsystems (3)
lore
Share & tools
lore

Lowry Li

author
#0 lore raw

[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected]
Bcc: [email protected]
Subject: drm/blend: Add per-plane pixel blend mode property
Reply-To:

Signature · 2 lines
Regards,
Lowry
Quoted 1 line

From 7b3b4cae2b0283076b47775efdf5dbbf75a8d859 Mon Sep 17 00:00:00 2001

From: Lowry Li <[email protected]>
Date: Wed, 30 May 2018 15:04:53 +0800
Subject: [PATCH v2 0/2] drm/blend: Add per-plane pixel blend mode property

Hi,

This serie aims at adding the support for pixel blend modes represent the alpha blending equation selection in the driver. It also introduces to use it in the malidp driver.

Let me know what you think,
Lowry

Changes for v2:
- Moves the blending equation into the DOC comment
- Refines the comments of drm_plane_create_blend_mode_property to not enumerate the #defines, but instead the string values
- Uses fg.* instead of pixel.* and plane_alpha instead of plane.alpha
- Introduces to use it in the malidp driver

Changes from v1:
- v1 is just the core changes to request for commments
- Adds a pixel_blend_mode to drm_plane_state and a blend_mode_property to drm_plane, and related support functions
- Defines three blend modes in drm_blend.h
- Rebased on current drm-next

Lowry Li (2):
drm: Add per-plane pixel blend mode property drm/mali-dp: Implement plane alpha and pixel blend on malidp

 drivers/gpu/drm/arm/malidp_planes.c |  65 ++++++++++++++-------
 drivers/gpu/drm/drm_atomic.c        |   4 ++
 drivers/gpu/drm/drm_atomic_helper.c |   1 +
 drivers/gpu/drm/drm_blend.c         | 110 ++++++++++++++++++++++++++++++++++++
 include/drm/drm_blend.h             |   6 ++
 include/drm/drm_plane.h             |   7 +++
 6 files changed, 174 insertions(+), 19 deletions(-)
Signature · 1 line
1.9.1
Quoted 1 line

From 86d2123481c749233afb51d4f651c2b84f8bf225 Mon Sep 17 00:00:00 2001

From: Lowry Li <[email protected]>
Date: Fri, 25 May 2018 19:18:37 +0800
Subject: [PATCH v2 1/2] drm: Add per-plane pixel blend mode property

Pixel blend modes represent the alpha blending equation selection, describing how the pixels from the current plane are composited with the background.

Add a pixel_blend_mode to drm_plane_state and a blend_mode_property to drm_plane, and related support functions.

Defines three blend modes in drm_blend.h.

---
 drivers/gpu/drm/drm_atomic.c        |   4 ++
 drivers/gpu/drm/drm_atomic_helper.c |   1 +
 drivers/gpu/drm/drm_blend.c         | 110 ++++++++++++++++++++++++++++++++++++
 include/drm/drm_blend.h             |   6 ++
 include/drm/drm_plane.h             |   7 +++
 5 files changed, 128 insertions(+)
drivers/gpu/drm/drm_atomic.c +4 -0
index a567310..0bb6de1 100644
@@ -764,6 +764,8 @@ int drm_atomic_plane_set_property(struct drm_plane *plane,
 		state->src_w = val;
 	} else if (property == config->prop_src_h) {
 		state->src_h = val;
+	} else if (property == plane->blend_mode_property) {
+		state->pixel_blend_mode = val;
 	} else if (property == plane->rotation_property) {
 		if (!is_power_of_2(val & DRM_ROTATE_MASK))
 			return -EINVAL;
@@ -826,6 +828,8 @@ int drm_atomic_plane_set_property(struct drm_plane *plane,
 		*val = state->src_w;
 	} else if (property == config->prop_src_h) {
 		*val = state->src_h;
+	} else if (property == plane->blend_mode_property) {
+		*val = state->pixel_blend_mode;
 	} else if (property == plane->rotation_property) {
 		*val = state->rotation;
 	} else if (property == plane->zpos_property) {
drivers/gpu/drm/drm_atomic_helper.c +1 -0
index 01d936b..e4377fd 100644
@@ -3133,6 +3133,7 @@ void drm_atomic_helper_plane_reset(struct drm_plane *plane)
 	if (plane->state) {
 		plane->state->plane = plane;
 		plane->state->rotation = DRM_ROTATE_0;
+		plane->state->pixel_blend_mode = DRM_MODE_BLEND_PREMULTI;
 	}
 }
 EXPORT_SYMBOL(drm_atomic_helper_plane_reset);
drivers/gpu/drm/drm_blend.c +110 -0

119 lines not on this page · raw message

include/drm/drm_blend.h +6 -0
index 13221cf..6bf95a4 100644
@@ -26,6 +26,10 @@
 #include <linux/list.h>
 #include <linux/ctype.h>
 
+#define DRM_MODE_BLEND_PIXEL_NONE	0
+#define DRM_MODE_BLEND_PREMULTI		1
+#define DRM_MODE_BLEND_COVERAGE		2
+
 struct drm_device;
 struct drm_atomic_state;
 
@@ -65,4 +69,6 @@ int drm_plane_create_zpos_immutable_property(struct drm_plane *plane,
 					     unsigned int zpos);
 int drm_atomic_normalize_zpos(struct drm_device *dev,
 			      struct drm_atomic_state *state);
+int drm_plane_create_blend_mode_property(struct drm_plane *plane,
+					 unsigned int supported_modes);
 #endif
include/drm/drm_plane.h +7 -0
index 20867b4..f9cbfee 100644
@@ -41,6 +41,8 @@
  *	plane (in 16.16)
  * @src_w: width of visible portion of plane (in 16.16)
  * @src_h: height of visible portion of plane (in 16.16)
+ * @pixel_blend_mode: how the plane's framebuffer alpha channel is used when
+ *	blending with the background colour.
  * @rotation: rotation of the plane
  * @zpos: priority of the given plane on crtc (optional)
  *	Note that multiple active planes on the same crtc can have an identical
@@ -104,6 +106,9 @@ struct drm_plane_state {
 	uint32_t src_x, src_y;
 	uint32_t src_h, src_w;
 
+	/* Plane pixel blend mode */
+	uint16_t pixel_blend_mode;
+
 	/* Plane rotation */
 	unsigned int rotation;
 
@@ -459,6 +464,7 @@ enum drm_plane_type {
  * @state: current atomic state for this plane
  * @zpos_property: zpos property for this plane
  * @rotation_property: rotation property for this plane
+ * @blend_mode_property: blend mode property for this plane
  * @helper_private: mid-layer private data
  */
 struct drm_plane {
@@ -506,6 +512,7 @@ struct drm_plane {
 
 	struct drm_property *zpos_property;
 	struct drm_property *rotation_property;
+	struct drm_property *blend_mode_property;
 };
 
 #define obj_to_plane(x) container_of(x, struct drm_plane, base)
Signature · 1 line
1.9.1
Quoted 1 line

From 7b3b4cae2b0283076b47775efdf5dbbf75a8d859 Mon Sep 17 00:00:00 2001

From: Lowry Li <[email protected]>
Date: Mon, 28 May 2018 18:27:33 +0800
Subject: [PATCH v2 2/2] drm/mali-dp: Implement plane alpha and pixel blend on
malidp

Check the pixel blending mode and plane alpha value when do the plane_check. Mali DP supports blending the current plane with the background either based on the pixel alpha blending mode or by using the layer's alpha value, but not both at the same time. If both case, plane_check will return failed.

Set the HW when doing plane_update accordingly. If plane alpha is the 0xffff, set the PREM bit accordingly. If not we'd set ALPHA bit as zero and layer alpha value.

---
 drivers/gpu/drm/arm/malidp_planes.c | 65 ++++++++++++++++++++++++++-----------
 1 file changed, 46 insertions(+), 19 deletions(-)
drivers/gpu/drm/arm/malidp_planes.c +46 -19

134 lines not on this page · raw message

Signature · 1 line
1.9.1

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