* [PATCH v4 0/2] drm/drm_blend: allow blend mode property without PREMULTI
@ 2026-05-26 18:16 Leandro Ribeiro
2026-05-26 18:16 ` [PATCH v4 1/2] " Leandro Ribeiro
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Leandro Ribeiro @ 2026-05-26 18:16 UTC (permalink / raw)
To: dri-devel
Cc: airlied, daniels, jani.nikula, maarten.lankhorst, mripard,
pekka.paalanen, simona, tzimmermann, ville.syrjala, linux-kernel
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(-)
--
2.54.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v4 1/2] drm/drm_blend: allow blend mode property without PREMULTI
2026-05-26 18:16 [PATCH v4 0/2] drm/drm_blend: allow blend mode property without PREMULTI Leandro Ribeiro
@ 2026-05-26 18:16 ` Leandro Ribeiro
2026-05-26 18:17 ` [PATCH v4 2/2] drm: ensure blend mode supported if pixel format with alpha exposed Leandro Ribeiro
2026-06-16 10:16 ` [PATCH v4 0/2] drm/drm_blend: allow blend mode property without PREMULTI Pekka Paalanen
2 siblings, 0 replies; 4+ messages in thread
From: Leandro Ribeiro @ 2026-05-26 18:16 UTC (permalink / raw)
To: dri-devel
Cc: airlied, daniels, jani.nikula, maarten.lankhorst, mripard,
pekka.paalanen, simona, tzimmermann, ville.syrjala, linux-kernel
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.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
---
drivers/gpu/drm/drm_blend.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/drm_blend.c b/drivers/gpu/drm/drm_blend.c
index 2f0d1ba285be..d17ae964fb21 100644
--- a/drivers/gpu/drm/drm_blend.c
+++ b/drivers/gpu/drm/drm_blend.c
@@ -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;
--
2.54.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v4 2/2] drm: ensure blend mode supported if pixel format with alpha exposed
2026-05-26 18:16 [PATCH v4 0/2] drm/drm_blend: allow blend mode property without PREMULTI Leandro Ribeiro
2026-05-26 18:16 ` [PATCH v4 1/2] " Leandro Ribeiro
@ 2026-05-26 18:17 ` Leandro Ribeiro
2026-06-16 10:16 ` [PATCH v4 0/2] drm/drm_blend: allow blend mode property without PREMULTI Pekka Paalanen
2 siblings, 0 replies; 4+ messages in thread
From: Leandro Ribeiro @ 2026-05-26 18:17 UTC (permalink / raw)
To: dri-devel
Cc: airlied, daniels, jani.nikula, maarten.lankhorst, mripard,
pekka.paalanen, simona, tzimmermann, ville.syrjala, linux-kernel
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.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
---
drivers/gpu/drm/drm_mode_config.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
index 66f7dc37b597..8cca1dea3b3d 100644
--- a/drivers/gpu/drm/drm_mode_config.c
+++ b/drivers/gpu/drm/drm_mode_config.c
@@ -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,
--
2.54.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v4 0/2] drm/drm_blend: allow blend mode property without PREMULTI
2026-05-26 18:16 [PATCH v4 0/2] drm/drm_blend: allow blend mode property without PREMULTI Leandro Ribeiro
2026-05-26 18:16 ` [PATCH v4 1/2] " Leandro Ribeiro
2026-05-26 18:17 ` [PATCH v4 2/2] drm: ensure blend mode supported if pixel format with alpha exposed Leandro Ribeiro
@ 2026-06-16 10:16 ` Pekka Paalanen
2 siblings, 0 replies; 4+ messages in thread
From: Pekka Paalanen @ 2026-06-16 10:16 UTC (permalink / raw)
To: Leandro Ribeiro
Cc: dri-devel, airlied, daniels, jani.nikula, maarten.lankhorst,
mripard, simona, tzimmermann, ville.syrjala, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1732 bytes --]
On Tue, 26 May 2026 15:16:58 -0300
Leandro Ribeiro <leandro.ribeiro@collabora.com> wrote:
> 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
Hi,
the series is:
Acked-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Thanks.
>
> 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(-)
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-06-16 10:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-26 18:16 [PATCH v4 0/2] drm/drm_blend: allow blend mode property without PREMULTI Leandro Ribeiro
2026-05-26 18:16 ` [PATCH v4 1/2] " Leandro Ribeiro
2026-05-26 18:17 ` [PATCH v4 2/2] drm: ensure blend mode supported if pixel format with alpha exposed Leandro Ribeiro
2026-06-16 10:16 ` [PATCH v4 0/2] drm/drm_blend: allow blend mode property without PREMULTI Pekka Paalanen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox