Skip to contentSkip to conversation

drm/amd/display: Attach blend mode property for alpha planes

PATCH In review James Lin 2 participants 2 messages Nov 9 – Nov 12

Subsystems (3)
lore
Share & tools
lore

James Lin

author
#0 lore raw

PATCH 1/1 drm/amd/display: Attach blend mode property for alpha planes

From: James Lin <[email protected]>

drm_mode_config_validate() warns when a plane exposes an alpha-capable pixel format without a blend_mode_property. amdgpu DM only created that property for overlay planes, so PRIMARY and CURSOR triggered the warning on every probe and reload in kernel 7.2.

Create the blend mode property for every plane that advertises an alpha format. Keep overlay-only alpha_property. Cursor advertises only pre-multiplied blend mode because native cursor programming is pre-multiplied.

This re-applies commit 3f3139234c28 ("drm/amd/display: Attach blend mode property for alpha planes"), which was reverted by
commit 07df8cb29c8b ("Revert \"drm/amd/display: Attach blend mode property for alpha planes\""). As that revert log states, it "regresses blend mode handling due to
conflicts in drm-next" - i.e. it was a mechanical conflict resolution
during a drm-next backmerge, not a defect in the fix, and it was never re-applied. The plane registration code therefore still matches the
pre-fix state and the warning persists, so re-apply the original, reviewed change.

---
 .../amd/display/amdgpu_dm/amdgpu_dm_plane.c   | 38 +++++++++++++++----
 1 file changed, 31 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c +31 -7
index 06d9ff2c32c5..d6a51303ffb8 100644
@@ -2204,6 +2204,21 @@ static const struct drm_plane_funcs dm_plane_funcs = {
 #endif
 };
 
+static bool amdgpu_dm_plane_exposes_alpha_format(const struct drm_plane *plane)
+{
+	unsigned int i;
+
+	for (i = 0; i < plane->format_count; i++) {
+		const struct drm_format_info *fmt =
+			drm_format_info(plane->format_types[i]);
+
+		if (fmt && fmt->has_alpha)
+			return true;
+	}
+
+	return false;
+}
+
 int amdgpu_dm_plane_init(struct amdgpu_display_manager *dm,
 				struct drm_plane *plane,
 				unsigned long possible_crtcs,
@@ -2234,14 +2249,8 @@ int amdgpu_dm_plane_init(struct amdgpu_display_manager *dm,
 		return res;
 
 	if (plane->type == DRM_PLANE_TYPE_OVERLAY &&
-	    plane_cap && plane_cap->per_pixel_alpha) {
-		unsigned int blend_caps = BIT(DRM_MODE_BLEND_PIXEL_NONE) |
-					  BIT(DRM_MODE_BLEND_PREMULTI) |
-					  BIT(DRM_MODE_BLEND_COVERAGE);
-
+	    plane_cap && plane_cap->per_pixel_alpha)
 		drm_plane_create_alpha_property(plane);
-		drm_plane_create_blend_mode_property(plane, blend_caps);
-	}
 
 	if (plane->type == DRM_PLANE_TYPE_PRIMARY) {
 		/*
@@ -2261,6 +2270,21 @@ int amdgpu_dm_plane_init(struct amdgpu_display_manager *dm,
 		drm_plane_create_zpos_immutable_property(plane, 255);
 	}
 
+	/*
+	 * drm_mode_config_validate() warns about planes exposing a pixel format
+	 * with alpha but no blend mode property, so attach one to every plane
+	 * advertising such a format.
+	 */
+	if (amdgpu_dm_plane_exposes_alpha_format(plane)) {
+		unsigned int blend_caps = BIT(DRM_MODE_BLEND_PREMULTI);
+
+		if (plane->type != DRM_PLANE_TYPE_CURSOR)
+			blend_caps |= BIT(DRM_MODE_BLEND_PIXEL_NONE) |
+				      BIT(DRM_MODE_BLEND_COVERAGE);
+
+		drm_plane_create_blend_mode_property(plane, blend_caps);
+	}
+
 	if ((plane->type == DRM_PLANE_TYPE_PRIMARY ||
 	     plane->type == DRM_PLANE_TYPE_OVERLAY) &&
 	    plane_cap &&
Signature · 1 line
2.43.0
#1 lore raw
Quoted 3 lines · James Lin

This re-applies commit 3f3139234c28 ("drm/amd/display: Attach blend mode property for alpha planes"), which was reverted by
commit 07df8cb29c8b ("Revert \"drm/amd/display: Attach blend mode property for alpha planes\"").

Hi James,

I think this warning is already fixed in mainline by Melissa Wen's series, which went into 7.3 through drm-misc-fixes:

f0c75da0a6b4 ("drm/amd/display: fix missing blend-mode-prop warning for DCN") 332ad707e38f ("drm/amd/display: advertise PIXEL_NONE and PREMULTI blend mode for DCE")

They change the same block in amdgpu_dm_plane_init(), so I assume they are the drm-next conflict the revert mentions. amd-staging-drm-next (47df73aa49) doesn't have them yet, which is why the warning still shows up there (I get all 8 on a Cezanne laptop). Once the tree picks up 7.3, this patch would create the blend mode property a second time on the same planes.

Would it make more sense to pick up Melissa's two commits instead of re-applying 3f3139234c28?

Thanks,
Eren