[PATCH v2] drm/radeon: Create the primary plane in the driver

From: oushixiong1025

Date: Thu Sep 03 2026 - 03:20:09 EST


From: Shixiong Ou <oushixiong@xxxxxxxxxx>

drm_crtc_init() creates the primary plane from a fixed format list
without a "pixel blend mode" property, so drm_mode_config_validate()
warns although the display engine does support per-pixel alpha on the
primary surface.

Replace it with a driver-owned primary plane advertising XRGB8888 and
ARGB8888, allocated by drmm_universal_plane_alloc(), with the blend
mode property set to the PREMULTI mode userspace has always assumed
when the property was absent.

Signed-off-by: Shixiong Ou <oushixiong@xxxxxxxxxx>
---
v1->v2:
- Open-code DRM_PLANE_NON_ATOMIC_FUNCS without .destroy, which
drmm_universal_plane_alloc() rejects
- Use drmm_universal_plane_alloc() for automatic cleanup
- Move the formats comment above the array

drivers/gpu/drm/radeon/radeon_display.c | 38 ++++++++++++++++++++++++-
1 file changed, 37 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
index aac6733ddd82..6427feb5a5c5 100644
--- a/drivers/gpu/drm/radeon/radeon_display.c
+++ b/drivers/gpu/drm/radeon/radeon_display.c
@@ -30,6 +30,7 @@

#include <asm/div64.h>

+#include <drm/drm_blend.h>
#include <drm/drm_crtc_helper.h>
#include <drm/drm_device.h>
#include <drm/drm_drv.h>
@@ -38,6 +39,8 @@
#include <drm/drm_framebuffer.h>
#include <drm/drm_gem_framebuffer_helper.h>
#include <drm/drm_modeset_helper.h>
+#include <drm/drm_plane.h>
+#include <drm/drm_plane_helper.h>
#include <drm/drm_probe_helper.h>
#include <drm/drm_vblank.h>
#include <drm/radeon_drm.h>
@@ -664,6 +667,20 @@ radeon_crtc_set_config(struct drm_mode_set *set,
return ret;
}

+/*
+ * The display engine programs an ARGB8888 surface format for both
+ * XRGB8888 and ARGB8888 framebuffers.
+ */
+static const uint32_t radeon_primary_formats[] = {
+ DRM_FORMAT_XRGB8888,
+ DRM_FORMAT_ARGB8888,
+};
+
+static const struct drm_plane_funcs radeon_primary_plane_funcs = {
+ .update_plane = drm_plane_helper_update_primary,
+ .disable_plane = drm_plane_helper_disable_primary,
+};
+
static const struct drm_crtc_funcs radeon_crtc_funcs = {
.cursor_set2 = radeon_crtc_cursor_set2,
.cursor_move = radeon_crtc_cursor_move,
@@ -681,6 +698,7 @@ static void radeon_crtc_init(struct drm_device *dev, int index)
{
struct radeon_device *rdev = dev->dev_private;
struct radeon_crtc *radeon_crtc;
+ struct drm_plane *primary;

radeon_crtc = kzalloc_obj(*radeon_crtc);
if (radeon_crtc == NULL)
@@ -693,7 +711,20 @@ static void radeon_crtc_init(struct drm_device *dev, int index)
return;
}

- drm_crtc_init(dev, &radeon_crtc->base, &radeon_crtc_funcs);
+ primary = drmm_universal_plane_alloc(dev, struct drm_plane, dev, 0,
+ &radeon_primary_plane_funcs,
+ radeon_primary_formats,
+ ARRAY_SIZE(radeon_primary_formats),
+ NULL, DRM_PLANE_TYPE_PRIMARY, NULL);
+ if (IS_ERR(primary))
+ goto err_free_crtc;
+
+ if (drm_crtc_init_with_planes(dev, &radeon_crtc->base, primary, NULL,
+ &radeon_crtc_funcs, NULL))
+ goto err_free_crtc;
+
+ drm_plane_create_blend_mode_property(primary,
+ BIT(DRM_MODE_BLEND_PREMULTI));

drm_mode_crtc_set_gamma_size(&radeon_crtc->base, 256);
radeon_crtc->crtc_id = index;
@@ -713,6 +744,11 @@ static void radeon_crtc_init(struct drm_device *dev, int index)
radeon_atombios_init_crtc(dev, radeon_crtc);
else
radeon_legacy_init_crtc(dev, radeon_crtc);
+ return;
+
+err_free_crtc:
+ destroy_workqueue(radeon_crtc->flip_queue);
+ kfree(radeon_crtc);
}

static const char *encoder_names[38] = {
--
2.25.1


No virus found
Checked by Hillstone Network AntiVirus