Skip to contentSkip to conversation

drm/drm_blend: allow blend mode property without PREMULTI

PATCH In review Leandro Ribeiro 6 participants 9 messages May 26 – Aug 4

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v4 cover drm/drm_blend: allow blend mode property without PREMULTI

Some hardware only supports the COVERAGE blend mode and lacks PREMULTI support entirely. DRM currently requires that PREMULTI is present when creating a blend mode property, which prevents such drivers from being properly upstreamed.

This series removes this restriction and allows drivers to create a blend mode property without PREMULTI.

On Weston (userspace), we are working [1] towards adding support for this kind of hardware.

[1] https://gitlab.freedesktop.org/wayland/weston/-/merge_requests/2046

v4:
- Trigger warnings instead of errors when pixel format with alpha is exposed but blend mode is not setup.
- Require blend mode only when plane exposes pixel formats with alpha, not when it supports the alpha property.

v3:
- Changed where we enforce drivers to expose blend mode for planes that support the alpha property or pixel formats with alpha.
- Fixed missing check to forbid calling drm_plane_create_blend_mode_property() with a zero bitmask of supported modes.

v2:
- Force drivers to expose blend mode if plane supports alpha property or pixel format with alpha.

Leandro Ribeiro (2):
drm/drm_blend: allow blend mode property without PREMULTI
drm: ensure blend mode supported if pixel format with alpha exposed

 drivers/gpu/drm/drm_blend.c       | 20 ++++++++++++++------
 drivers/gpu/drm/drm_mode_config.c | 21 +++++++++++++++++++++
 2 files changed, 35 insertions(+), 6 deletions(-)
Signature · 1 line
2.54.0
#1 lore raw

PATCH v4 1/2 drm/drm_blend: allow blend mode property without PREMULTI

Some hardware only supports the COVERAGE blend mode and lacks PREMULTI support entirely. DRM currently requires that PREMULTI is present when creating a blend mode property, which prevents such drivers from being properly upstreamed.

Remove this restriction and allow drivers to create a blend mode property without PREMULTI, enabling support for hardware that implements only COVERAGE blend mode.

This does not introduce a regression, as no existing upstream drivers expose only COVERAGE. However, userspace that wants to support such kind of hardware in the future will have to check the supported blend modes instead of assuming PREMULTI is always supported.

---
 drivers/gpu/drm/drm_blend.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
drivers/gpu/drm/drm_blend.c +14 -6
index 2f0d1ba285be..d17ae964fb21 100644
@@ -563,10 +563,10 @@ EXPORT_SYMBOL(drm_atomic_normalize_zpos);
 /**
  * drm_plane_create_blend_mode_property - create a new blend mode property
  * @plane: drm plane
- * @supported_modes: bitmask of supported modes, must include
- *		     BIT(DRM_MODE_BLEND_PREMULTI). Current DRM assumption is
- *		     that alpha is premultiplied, and old userspace can break if
- *		     the property defaults to anything else.
+ * @supported_modes: bitmask of supported modes. When
+ *		     BIT(DRM_MODE_BLEND_PREMULTI) is included, it will be used
+ *		     as the default. Otherwise, the default will fallback to one
+ *		     of the supported modes.
  *
  * This creates a new property describing the blend mode.
  *
@@ -599,13 +599,14 @@ int drm_plane_create_blend_mode_property(struct drm_plane *plane,
 		{ DRM_MODE_BLEND_PREMULTI, "Pre-multiplied" },
 		{ DRM_MODE_BLEND_COVERAGE, "Coverage" },
 	};
+	unsigned int default_mode;
 	unsigned int valid_mode_mask = BIT(DRM_MODE_BLEND_PIXEL_NONE) |
 				       BIT(DRM_MODE_BLEND_PREMULTI)   |
 				       BIT(DRM_MODE_BLEND_COVERAGE);
 	int i;
 
 	if (WARN_ON((supported_modes & ~valid_mode_mask) ||
-		    ((supported_modes & BIT(DRM_MODE_BLEND_PREMULTI)) == 0)))
+		    (supported_modes == 0)))
 		return -EINVAL;
 
 	prop = drm_property_create(dev, DRM_MODE_PROP_ENUM,
@@ -630,7 +631,14 @@ int drm_plane_create_blend_mode_property(struct drm_plane *plane,
 		}
 	}
 
-	drm_object_attach_property(&plane->base, prop, DRM_MODE_BLEND_PREMULTI);
+	if (supported_modes & BIT(DRM_MODE_BLEND_PREMULTI))
+		default_mode = DRM_MODE_BLEND_PREMULTI;
+	else if (supported_modes & BIT(DRM_MODE_BLEND_COVERAGE))
+		default_mode = DRM_MODE_BLEND_COVERAGE;
+	else
+		default_mode = DRM_MODE_BLEND_PIXEL_NONE;
+
+	drm_object_attach_property(&plane->base, prop, default_mode);
 	plane->blend_mode_property = prop;
 
 	return 0;
Signature · 1 line
2.54.0
#2 lore raw

PATCH v4 2/2 drm: ensure blend mode supported if pixel format with alpha exposed

In reply to Leandro Ribeiro

Before "drm/drm_blend: allow blend mode property without PREMULTI", userspace would have to assume that only PREMULTI was supported by drivers that didn't expose the blend mode property. But now userspace shouldn't rely on that, as they can't count with drivers always supporting PREMULTI.

Warn if a driver exposes pixel formats with alpha but doesn't expose the blend mode property. This way userspace doesn't have to guess. Drivers triggering this warning must be fixed.

---
 drivers/gpu/drm/drm_mode_config.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
drivers/gpu/drm/drm_mode_config.c +21 -0
index 66f7dc37b597..8cca1dea3b3d 100644
@@ -674,6 +674,25 @@ static void validate_encoder_possible_crtcs(struct drm_encoder *encoder)
 	     encoder->possible_crtcs, crtc_mask);
 }
 
+static void validate_blend_mode_for_alpha_formats(struct drm_plane *plane)
+{
+	const struct drm_format_info *fmt;
+	u32 i;
+
+	/* blend mode property supported, no need to check anything */
+	if (plane->blend_mode_property)
+		return;
+
+	for (i = 0; i < plane->format_count; i++) {
+		fmt = drm_format_info(plane->format_types[i]);
+		if (fmt->has_alpha) {
+			WARN(1, "[PLANE:%d:%s] pixel format with alpha exposed but "
+			     "blend mode not setup", plane->base.id, plane->name);
+			break;
+		}
+	}
+}
+
 void drm_mode_config_validate(struct drm_device *dev)
 {
 	struct drm_encoder *encoder;
@@ -732,6 +751,8 @@ void drm_mode_config_validate(struct drm_device *dev)
 	drm_for_each_plane(plane, dev) {
 		if (plane->type == DRM_PLANE_TYPE_PRIMARY)
 			num_primary++;
+
+		validate_blend_mode_for_alpha_formats(plane);
 	}
 
 	WARN(num_primary != dev->mode_config.num_crtc,
Signature · 1 line
2.54.0
#3 lore raw

Re: [PATCH v4 2/2] drm: ensure blend mode supported if pixel format with alpha exposed

Hi Leandro,

+ ast folks

Quoted 27 lines · Leandro Ribeiro

Before "drm/drm_blend: allow blend mode property without PREMULTI", userspace would have to assume that only PREMULTI was supported by drivers that didn't expose the blend mode property. But now userspace shouldn't rely on that, as they can't count with drivers always supporting PREMULTI.

Warn if a driver exposes pixel formats with alpha but doesn't expose the blend mode property. This way userspace doesn't have to guess. Drivers triggering this warning must be fixed.

---
 drivers/gpu/drm/drm_mode_config.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
drivers/gpu/drm/drm_mode_config.c +4 -0
index 66f7dc37b597..8cca1dea3b3d 100644
@@ -674,6 +674,25 @@ static void validate_encoder_possible_crtcs(struct drm_encoder *encoder)
 	     encoder->possible_crtcs, crtc_mask);
 }
 
+static void validate_blend_mode_for_alpha_formats(struct drm_plane *plane)
+{
+	const struct drm_format_info *fmt;
+	u32 i;

drivers/gpu/drm/drm_mode_config.c static void validate_encoder_possible_crtcs(struct drm_encoder *encoder) · line 690

Quoted 10 lines
drivers/gpu/drm/drm_mode_config.c +10 -0
+
+	/* blend mode property supported, no need to check anything */
+	if (plane->blend_mode_property)
+		return;
+
+	for (i = 0; i < plane->format_count; i++) {
+		fmt = drm_format_info(plane->format_types[i]);
+		if (fmt->has_alpha) {
+			WARN(1, "[PLANE:%d:%s] pixel format with alpha exposed but "
+			     "blend mode not setup", plane->base.id, plane->name);

I am seeing this warning trigger on a few of my machines in -next. A couple of those use amdgpu, which I see has already been reported in a separate thread. Another one uses ast, which I do not see reported (apologies if I missed it).

  [  +0.000137] ------------[ cut here ]------------
  [  +0.000004] [PLANE:37:plane-1] pixel format with alpha exposed but blend mode not setup
  [  +0.000019] WARNING: drivers/gpu/drm/drm_mode_config.c:873 at drm_mode_config_validate+0xa24/0xad0, CPU#0: kworker/0:2/507
  [  +0.000010] Modules linked in: ghash_ce gf128mul nvme ast(+) nvme_core sbsa_gwdt i2c_algo_bit nvme_keyring nvme_auth xgene_hwmon gpio_dwapb fuse scsi_dh_alua scsi_dh_rdac i2c_dev scsi_dh_emc
  [  +0.000014] CPU: 0 UID: 0 PID: 507 Comm: kworker/0:2 Not tainted 7.2.0-rc4-next-20260721-00002-g17fa9b81f4c4 #1 PREEMPT(lazy)
  [  +0.000003] Hardware name: To be filled by O.E.M Ampere Altra Developer Platform/Ampere Altra Developer Platform, BIOS TianoCore 2.10.100.02 (SYS: 2.10.20
  [  +0.000002] Workqueue: sync_wq local_pci_probe_callback
  [  +0.000004] pstate: 60400009 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
  [  +0.000003] pc : drm_mode_config_validate+0xa24/0xad0
  [  +0.000002] lr : drm_mode_config_validate+0xa24/0xad0
  [  +0.000002] sp : ffff800082df3c30
  [  +0.000001] x29: ffff800082df3c60 x28: ffffde7ac3633fc2 x27: 0000000000000001
  [  +0.000004] x26: 0000000000000001 x25: 0000000000000002 x24: 0000000000000000
  [  +0.000003] x23: ffff07ffb54b0290 x22: ffff07ffb54b0be0 x21: ffffde7ac36ebb13
  [  +0.000003] x20: 0000000000000001 x19: ffff07ffb54b0000 x18: ffff800082dd5038
  [  +0.000003] x17: 00000000d949c370 x16: 00000000d949c370 x15: ffffde7ac358f156
  [  +0.000002] x14: 0000000000000386 x13: ffff081eeebf2850 x12: 0000000000000000
  [  +0.000003] x11: 0000000000000000 x10: ffffde7ac44b5850 x9 : 738b2a5f3c615c00
  [  +0.000003] x8 : 738b2a5f3c615c00 x7 : 0000000000000000 x6 : 206c65786970205d
  [  +0.000003] x5 : ffff081f6fcc917b x4 : ffffde7ac36ebb59 x3 : ffffffffffff0a00
  [  +0.000002] x2 : 0000000000000001 x1 : 0000000000000000 x0 : 000000000000004b
  [  +0.000003] Call trace:
  [  +0.000001]  drm_mode_config_validate+0xa24/0xad0 (P)
  [  +0.000003]  drm_dev_register+0x44/0x3d8
  [  +0.000004]  ast_pci_probe+0x330/0x354 [ast]
  [  +0.000016]  local_pci_probe_callback+0x68/0xc0
  [  +0.000002]  process_scheduled_works+0x23c/0x668
  [  +0.000003]  worker_thread+0x218/0x324
  [  +0.000003]  kthread+0x130/0x180
  [  +0.000002]  ret_from_fork+0x10/0x20
  [  +0.000004] ---[ end trace 0000000000000000 ]---

If there is any other information I can provide or patches I can test, I am more than happy to do so.

Signature · 2 lines
Cheers,
Nathan
maintainer
#4 lore raw

Re: [PATCH v4 2/2] drm: ensure blend mode supported if pixel format with alpha exposed

Quoted 71 lines · Nathan Chancellor

Hi Leandro,

+ ast folks

Quoted 27 lines · Leandro Ribeiro

Before "drm/drm_blend: allow blend mode property without PREMULTI", userspace would have to assume that only PREMULTI was supported by drivers that didn't expose the blend mode property. But now userspace shouldn't rely on that, as they can't count with drivers always supporting PREMULTI.

Warn if a driver exposes pixel formats with alpha but doesn't expose the blend mode property. This way userspace doesn't have to guess. Drivers triggering this warning must be fixed.

---
  drivers/gpu/drm/drm_mode_config.c | 21 +++++++++++++++++++++
  1 file changed, 21 insertions(+)
drivers/gpu/drm/drm_mode_config.c +4 -0
index 66f7dc37b597..8cca1dea3b3d 100644
@@ -674,6 +674,25 @@ static void validate_encoder_possible_crtcs(struct drm_encoder *encoder)
  	     encoder->possible_crtcs, crtc_mask);
  }
 
+static void validate_blend_mode_for_alpha_formats(struct drm_plane *plane)
+{
+	const struct drm_format_info *fmt;
+	u32 i;

drivers/gpu/drm/drm_mode_config.c static void validate_encoder_possible_crtcs(struct drm_encoder *encoder) · line 690

Quoted 10 lines
drivers/gpu/drm/drm_mode_config.c +10 -0
+
+	/* blend mode property supported, no need to check anything */
+	if (plane->blend_mode_property)
+		return;
+
+	for (i = 0; i < plane->format_count; i++) {
+		fmt = drm_format_info(plane->format_types[i]);
+		if (fmt->has_alpha) {
+			WARN(1, "[PLANE:%d:%s] pixel format with alpha exposed but "
+			     "blend mode not setup", plane->base.id, plane->name);

I am seeing this warning trigger on a few of my machines in -next. A couple of those use amdgpu, which I see has already been reported in a separate thread. Another one uses ast, which I do not see reported (apologies if I missed it).

   [  +0.000137] ------------[ cut here ]------------
   [  +0.000004] [PLANE:37:plane-1] pixel format with alpha exposed but blend mode not setup
   [  +0.000019] WARNING: drivers/gpu/drm/drm_mode_config.c:873 at drm_mode_config_validate+0xa24/0xad0, CPU#0: kworker/0:2/507
   [  +0.000010] Modules linked in: ghash_ce gf128mul nvme ast(+) nvme_core sbsa_gwdt i2c_algo_bit nvme_keyring nvme_auth xgene_hwmon gpio_dwapb fuse scsi_dh_alua scsi_dh_rdac i2c_dev scsi_dh_emc
   [  +0.000014] CPU: 0 UID: 0 PID: 507 Comm: kworker/0:2 Not tainted 7.2.0-rc4-next-20260721-00002-g17fa9b81f4c4 #1 PREEMPT(lazy)
   [  +0.000003] Hardware name: To be filled by O.E.M Ampere Altra Developer Platform/Ampere Altra Developer Platform, BIOS TianoCore 2.10.100.02 (SYS: 2.10.20
   [  +0.000002] Workqueue: sync_wq local_pci_probe_callback
   [  +0.000004] pstate: 60400009 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
   [  +0.000003] pc : drm_mode_config_validate+0xa24/0xad0
   [  +0.000002] lr : drm_mode_config_validate+0xa24/0xad0
   [  +0.000002] sp : ffff800082df3c30
   [  +0.000001] x29: ffff800082df3c60 x28: ffffde7ac3633fc2 x27: 0000000000000001
   [  +0.000004] x26: 0000000000000001 x25: 0000000000000002 x24: 0000000000000000
   [  +0.000003] x23: ffff07ffb54b0290 x22: ffff07ffb54b0be0 x21: ffffde7ac36ebb13
   [  +0.000003] x20: 0000000000000001 x19: ffff07ffb54b0000 x18: ffff800082dd5038
   [  +0.000003] x17: 00000000d949c370 x16: 00000000d949c370 x15: ffffde7ac358f156
   [  +0.000002] x14: 0000000000000386 x13: ffff081eeebf2850 x12: 0000000000000000
   [  +0.000003] x11: 0000000000000000 x10: ffffde7ac44b5850 x9 : 738b2a5f3c615c00
   [  +0.000003] x8 : 738b2a5f3c615c00 x7 : 0000000000000000 x6 : 206c65786970205d
   [  +0.000003] x5 : ffff081f6fcc917b x4 : ffffde7ac36ebb59 x3 : ffffffffffff0a00
   [  +0.000002] x2 : 0000000000000001 x1 : 0000000000000000 x0 : 000000000000004b
   [  +0.000003] Call trace:
   [  +0.000001]  drm_mode_config_validate+0xa24/0xad0 (P)
Quoted 8 lines
   [  +0.000003]  drm_dev_register+0x44/0x3d8
   [  +0.000004]  ast_pci_probe+0x330/0x354 [ast]
   [  +0.000016]  local_pci_probe_callback+0x68/0xc0
   [  +0.000002]  process_scheduled_works+0x23c/0x668
   [  +0.000003]  worker_thread+0x218/0x324
   [  +0.000003]  kthread+0x130/0x180
   [  +0.000002]  ret_from_fork+0x10/0x20
   [  +0.000004] ---[ end trace 0000000000000000 ]---

I am also seeing the same warning on -next for Tegra194 based devices.

Quoted 2 lines

If there is any other information I can provide or patches I can test, I am more than happy to do so.

Same. Happy to provide any more information or test any other changes.

Jon

Signature · 1 line
nvpublic
#5 lore raw

Re: [PATCH v4 2/2] drm: ensure blend mode supported if pixel format with alpha exposed

Quoted 77 lines · Jon Hunter
Quoted 67 lines · Nathan Chancellor
Quoted 27 lines · Leandro Ribeiro

Before "drm/drm_blend: allow blend mode property without PREMULTI", userspace would have to assume that only PREMULTI was supported by drivers that didn't expose the blend mode property. But now userspace shouldn't rely on that, as they can't count with drivers always supporting PREMULTI.

Warn if a driver exposes pixel formats with alpha but doesn't expose the blend mode property. This way userspace doesn't have to guess. Drivers triggering this warning must be fixed.

---
  drivers/gpu/drm/drm_mode_config.c | 21 +++++++++++++++++++++
  1 file changed, 21 insertions(+)
drivers/gpu/drm/drm_mode_config.c +4 -0
index 66f7dc37b597..8cca1dea3b3d 100644
@@ -674,6 +674,25 @@ static void validate_encoder_possible_crtcs(struct drm_encoder *encoder)
          encoder->possible_crtcs, crtc_mask);
  }
 
+static void validate_blend_mode_for_alpha_formats(struct drm_plane *plane)
+{
+    const struct drm_format_info *fmt;
+    u32 i;

drivers/gpu/drm/drm_mode_config.c static void validate_encoder_possible_crtcs(struct drm_encoder *encoder) · line 690

Quoted 10 lines
drivers/gpu/drm/drm_mode_config.c +10 -0
+
+    /* blend mode property supported, no need to check anything */
+    if (plane->blend_mode_property)
+            return;
+
+    for (i = 0; i < plane->format_count; i++) {
+            fmt = drm_format_info(plane->format_types[i]);
+            if (fmt->has_alpha) {
+                    WARN(1, "[PLANE:%d:%s] pixel format with alpha exposed but "
+                         "blend mode not setup", plane->base.id, plane->name);

I am seeing this warning trigger on a few of my machines in -next. A couple of those use amdgpu, which I see has already been reported in a separate thread. Another one uses ast, which I do not see reported (apologies if I missed it).

   [  +0.000137] ------------[ cut here ]------------
   [  +0.000004] [PLANE:37:plane-1] pixel format with alpha exposed but blend mode not setup
   [  +0.000019] WARNING: drivers/gpu/drm/drm_mode_config.c:873 at drm_mode_config_validate+0xa24/0xad0, CPU#0: kworker/0:2/507
   [  +0.000010] Modules linked in: ghash_ce gf128mul nvme ast(+) nvme_core sbsa_gwdt i2c_algo_bit nvme_keyring nvme_auth xgene_hwmon gpio_dwapb fuse scsi_dh_alua scsi_dh_rdac i2c_dev scsi_dh_emc
   [  +0.000014] CPU: 0 UID: 0 PID: 507 Comm: kworker/0:2 Not tainted 7.2.0-rc4-next-20260721-00002-g17fa9b81f4c4 #1 PREEMPT(lazy)
   [  +0.000003] Hardware name: To be filled by O.E.M Ampere Altra Developer Platform/Ampere Altra Developer Platform, BIOS TianoCore 2.10.100.02 (SYS: 2.10.20
   [  +0.000002] Workqueue: sync_wq local_pci_probe_callback
   [  +0.000004] pstate: 60400009 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
   [  +0.000003] pc : drm_mode_config_validate+0xa24/0xad0
   [  +0.000002] lr : drm_mode_config_validate+0xa24/0xad0
   [  +0.000002] sp : ffff800082df3c30
   [  +0.000001] x29: ffff800082df3c60 x28: ffffde7ac3633fc2 x27: 0000000000000001
   [  +0.000004] x26: 0000000000000001 x25: 0000000000000002 x24: 0000000000000000
   [  +0.000003] x23: ffff07ffb54b0290 x22: ffff07ffb54b0be0 x21: ffffde7ac36ebb13
   [  +0.000003] x20: 0000000000000001 x19: ffff07ffb54b0000 x18: ffff800082dd5038
   [  +0.000003] x17: 00000000d949c370 x16: 00000000d949c370 x15: ffffde7ac358f156
   [  +0.000002] x14: 0000000000000386 x13: ffff081eeebf2850 x12: 0000000000000000
   [  +0.000003] x11: 0000000000000000 x10: ffffde7ac44b5850 x9 : 738b2a5f3c615c00
   [  +0.000003] x8 : 738b2a5f3c615c00 x7 : 0000000000000000 x6 : 206c65786970205d
   [  +0.000003] x5 : ffff081f6fcc917b x4 : ffffde7ac36ebb59 x3 : ffffffffffff0a00
   [  +0.000002] x2 : 0000000000000001 x1 : 0000000000000000 x0 : 000000000000004b
   [  +0.000003] Call trace:
   [  +0.000001]  drm_mode_config_validate+0xa24/0xad0 (P)
Quoted 8 lines
   [  +0.000003]  drm_dev_register+0x44/0x3d8
   [  +0.000004]  ast_pci_probe+0x330/0x354 [ast]
   [  +0.000016]  local_pci_probe_callback+0x68/0xc0
   [  +0.000002]  process_scheduled_works+0x23c/0x668
   [  +0.000003]  worker_thread+0x218/0x324
   [  +0.000003]  kthread+0x130/0x180
   [  +0.000002]  ret_from_fork+0x10/0x20
   [  +0.000004] ---[ end trace 0000000000000000 ]---
Quoted 6 lines

I am also seeing the same warning on -next for Tegra194 based devices.

Quoted 2 lines

If there is any other information I can provide or patches I can test, I am more than happy to do so.

Same. Happy to provide any more information or test any other changes.

Same on R-Car Gen2 (R-Car DU without VSP).

I don't see the warning on R-Car Gen3 and Gen4, but I don't have a display connecting to those boards (meh), and rcar_du_vsp.c does call drm_plane_create_blend_mode_property() (yup ;-).

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#6 lore raw

Re: [PATCH v4 2/2] drm: ensure blend mode supported if pixel format with alpha exposed

Quoted 46 lines · Geert Uytterhoeven
Quoted 45 lines · Jon Hunter
Quoted 44 lines · Nathan Chancellor
Quoted 27 lines · Leandro Ribeiro

Before "drm/drm_blend: allow blend mode property without PREMULTI", userspace would have to assume that only PREMULTI was supported by drivers that didn't expose the blend mode property. But now userspace shouldn't rely on that, as they can't count with drivers always supporting PREMULTI.

Warn if a driver exposes pixel formats with alpha but doesn't expose the blend mode property. This way userspace doesn't have to guess. Drivers triggering this warning must be fixed.

---
  drivers/gpu/drm/drm_mode_config.c | 21 +++++++++++++++++++++
  1 file changed, 21 insertions(+)
drivers/gpu/drm/drm_mode_config.c +4 -0
index 66f7dc37b597..8cca1dea3b3d 100644
@@ -674,6 +674,25 @@ static void validate_encoder_possible_crtcs(struct drm_encoder *encoder)
          encoder->possible_crtcs, crtc_mask);
  }
 
+static void validate_blend_mode_for_alpha_formats(struct drm_plane *plane)
+{
+    const struct drm_format_info *fmt;
+    u32 i;

drivers/gpu/drm/drm_mode_config.c static void validate_encoder_possible_crtcs(struct drm_encoder *encoder) · line 690

Quoted 10 lines
drivers/gpu/drm/drm_mode_config.c +10 -0
+
+    /* blend mode property supported, no need to check anything */
+    if (plane->blend_mode_property)
+            return;
+
+    for (i = 0; i < plane->format_count; i++) {
+            fmt = drm_format_info(plane->format_types[i]);
+            if (fmt->has_alpha) {
+                    WARN(1, "[PLANE:%d:%s] pixel format with alpha exposed but "
+                         "blend mode not setup", plane->base.id, plane->name);

I am seeing this warning trigger on a few of my machines in -next. A couple of those use amdgpu, which I see has already been reported in a separate thread. Another one uses ast, which I do not see reported (apologies if I missed it).

Quoted 4 lines
Quoted 2 lines
Quoted 2 lines

[ +0.000137] ------------[ cut here ]------------
[ +0.000004] [PLANE:37:plane-1] pixel format with alpha exposed but blend mode not setup

Same on R-Car Gen2 (R-Car DU without VSP).

And on R-Mobile A1 (shmob_drm).

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
Acked-by on the v4 series
#7 lore raw
In reply to Leandro Ribeiro
Quoted 5 lines · On Tue, 26 May 2026 15:16:58 -0300 Leandro Ribeiro…

Some hardware only supports the COVERAGE blend mode and lacks PREMULTI support entirely. DRM currently requires that PREMULTI is present when creating a blend mode property, which prevents such drivers from being properly upstreamed.

Quoted 7 lines

This series removes this restriction and allows drivers to create a blend mode property without PREMULTI.

On Weston (userspace), we are working [1] towards adding support for this kind of hardware.

[1] https://gitlab.freedesktop.org/wayland/weston/-/merge_requests/2046

Hi,

the series is:

Thanks.

Quoted 26 lines

v4:
- Trigger warnings instead of errors when pixel format with alpha is exposed but blend mode is not setup.
- Require blend mode only when plane exposes pixel formats with alpha, not when it supports the alpha property.

v3:
- Changed where we enforce drivers to expose blend mode for planes that support the alpha property or pixel formats with alpha.
- Fixed missing check to forbid calling drm_plane_create_blend_mode_property() with a zero bitmask of supported modes.

v2:
- Force drivers to expose blend mode if plane supports alpha property or pixel format with alpha.

Leandro Ribeiro (2):
drm/drm_blend: allow blend mode property without PREMULTI
drm: ensure blend mode supported if pixel format with alpha exposed

 drivers/gpu/drm/drm_blend.c       | 20 ++++++++++++++------
 drivers/gpu/drm/drm_mode_config.c | 21 +++++++++++++++++++++
 2 files changed, 35 insertions(+), 6 deletions(-)
Reviewed-by on the v4 series
#8 lore raw
In reply to Leandro Ribeiro

Hi Leandro,

Quoted 5 lines · Leandro Ribeiro

Some hardware only supports the COVERAGE blend mode and lacks PREMULTI support entirely. DRM currently requires that PREMULTI is present when creating a blend mode property, which prevents such drivers from being properly upstreamed.

Quoted 7 lines

This series removes this restriction and allows drivers to create a blend mode property without PREMULTI.

On Weston (userspace), we are working [1] towards adding support for this kind of hardware.

[1] https://gitlab.freedesktop.org/wayland/weston/-/merge_requests/2046

The series, and the Weston MR, are also:

Thanks!