Skip to contentSkip to conversation

drm/amd/display: Fix direct scanout alpha on some DRM_FORMATs

PATCH In review [email protected] 2 participants 2 messages Sep 30

Subsystems (4)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 1/1 drm/amd/display: Fix direct scanout alpha on some DRM_FORMATs

From: Leo Li <[email protected]>

[Why]

DM was declaring it's own list of has_alpha DRM formats to check against for enabling alpha blending, when the format->has_alpha already does that for us.

The self-declared list missed some has_alpha formats, causing direct-scanout planes with such formats to appear opaque.

[How]

Drop the self-declared list, instead use the format->has_alpha field directly.

---
 .../amd/display/amdgpu_dm/amdgpu_dm_plane.c   | 20 +------------------
 1 file changed, 1 insertion(+), 19 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c +1 -19
index 0b5c4be1b3ec1..df6784d58c382 100644
@@ -113,25 +113,7 @@ void amdgpu_dm_plane_fill_blending_from_plane_state(const struct drm_plane_state
 
 	if (plane_state->pixel_blend_mode == DRM_MODE_BLEND_PREMULTI ||
 		plane_state->pixel_blend_mode == DRM_MODE_BLEND_COVERAGE) {
-		static const uint32_t alpha_formats[] = {
-			DRM_FORMAT_ARGB8888,
-			DRM_FORMAT_RGBA8888,
-			DRM_FORMAT_ABGR8888,
-			DRM_FORMAT_ARGB2101010,
-			DRM_FORMAT_ABGR2101010,
-			DRM_FORMAT_ARGB16161616,
-			DRM_FORMAT_ABGR16161616,
-			DRM_FORMAT_ARGB16161616F,
-		};
-		uint32_t format = plane_state->fb->format->format;
-		unsigned int i;
-
-		for (i = 0; i < ARRAY_SIZE(alpha_formats); ++i) {
-			if (format == alpha_formats[i]) {
-				*per_pixel_alpha = true;
-				break;
-			}
-		}
+		*per_pixel_alpha = plane_state->fb->format->has_alpha;
 
 		if (*per_pixel_alpha && plane_state->pixel_blend_mode == DRM_MODE_BLEND_COVERAGE)
 			*pre_multiplied_alpha = false;
Signature · 1 line
2.55.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · On 2026-09-30 12:25, [email protected] wrote:

From: Leo Li <[email protected]>

[Why]

DM was declaring it's own list of has_alpha DRM formats to check against for enabling alpha blending, when the format->has_alpha already does that for us.

The self-declared list missed some has_alpha formats, causing direct-scanout planes with such formats to appear opaque.

Quoted 7 lines

[How]

Drop the self-declared list, instead use the format->has_alpha field directly.

Harry

Quoted 35 lines
---
  .../amd/display/amdgpu_dm/amdgpu_dm_plane.c   | 20 +------------------
  1 file changed, 1 insertion(+), 19 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c +1 -19
index 0b5c4be1b3ec1..df6784d58c382 100644
@@ -113,25 +113,7 @@ void amdgpu_dm_plane_fill_blending_from_plane_state(const struct drm_plane_state
 
  	if (plane_state->pixel_blend_mode == DRM_MODE_BLEND_PREMULTI ||
  		plane_state->pixel_blend_mode == DRM_MODE_BLEND_COVERAGE) {
-		static const uint32_t alpha_formats[] = {
-			DRM_FORMAT_ARGB8888,
-			DRM_FORMAT_RGBA8888,
-			DRM_FORMAT_ABGR8888,
-			DRM_FORMAT_ARGB2101010,
-			DRM_FORMAT_ABGR2101010,
-			DRM_FORMAT_ARGB16161616,
-			DRM_FORMAT_ABGR16161616,
-			DRM_FORMAT_ARGB16161616F,
-		};
-		uint32_t format = plane_state->fb->format->format;
-		unsigned int i;
-
-		for (i = 0; i < ARRAY_SIZE(alpha_formats); ++i) {
-			if (format == alpha_formats[i]) {
-				*per_pixel_alpha = true;
-				break;
-			}
-		}
+		*per_pixel_alpha = plane_state->fb->format->has_alpha;
 
  		if (*per_pixel_alpha && plane_state->pixel_blend_mode == DRM_MODE_BLEND_COVERAGE)
  			*pre_multiplied_alpha = false;