* [PATCH] drm/drm_blend: allow blend mode property without PREMULTI
@ 2026-04-24 14:35 Leandro Ribeiro
2026-04-27 12:17 ` Ville Syrjälä
0 siblings, 1 reply; 3+ messages in thread
From: Leandro Ribeiro @ 2026-04-24 14:35 UTC (permalink / raw)
To: dri-devel
Cc: airlied, daniels, maarten.lankhorst, mripard, pekka.paalanen,
simona, tzimmermann, ville.syrjala, linux-kernel, 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.
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.
If the driver does not support the blend mode property, userspace must
assume that only PREMULTI is supported (as was the case before this
patch).
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
---
drivers/gpu/drm/drm_blend.c | 24 +++++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/drm_blend.c b/drivers/gpu/drm/drm_blend.c
index 1f3af27d2418..e5015d0fb219 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.
*
@@ -586,6 +586,9 @@ EXPORT_SYMBOL(drm_atomic_normalize_zpos);
* pre-multiplied and will do so when blending them to the background color
* values.
*
+ * Note: if the blend mode property is not present, userspace must assume that
+ * the driver supports only "Pre-multiplied".
+ *
* RETURNS:
* Zero for success or -errno
*/
@@ -599,13 +602,13 @@ 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)))
+ if (WARN_ON((supported_modes & ~valid_mode_mask)))
return -EINVAL;
prop = drm_property_create(dev, DRM_MODE_PROP_ENUM,
@@ -630,7 +633,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] 3+ messages in thread
* Re: [PATCH] drm/drm_blend: allow blend mode property without PREMULTI
2026-04-24 14:35 [PATCH] drm/drm_blend: allow blend mode property without PREMULTI Leandro Ribeiro
@ 2026-04-27 12:17 ` Ville Syrjälä
2026-04-27 20:36 ` Leandro Ribeiro
0 siblings, 1 reply; 3+ messages in thread
From: Ville Syrjälä @ 2026-04-27 12:17 UTC (permalink / raw)
To: Leandro Ribeiro
Cc: dri-devel, airlied, daniels, maarten.lankhorst, mripard,
pekka.paalanen, simona, tzimmermann, linux-kernel
On Fri, Apr 24, 2026 at 11:35:13AM -0300, Leandro Ribeiro 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.
>
> 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.
>
> If the driver does not support the blend mode property, userspace must
> assume that only PREMULTI is supported (as was the case before this
> patch).
>
> Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
> ---
> drivers/gpu/drm/drm_blend.c | 24 +++++++++++++++++-------
> 1 file changed, 17 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_blend.c b/drivers/gpu/drm/drm_blend.c
> index 1f3af27d2418..e5015d0fb219 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.
> *
> @@ -586,6 +586,9 @@ EXPORT_SYMBOL(drm_atomic_normalize_zpos);
> * pre-multiplied and will do so when blending them to the background color
> * values.
> *
> + * Note: if the blend mode property is not present, userspace must assume that
> + * the driver supports only "Pre-multiplied".
IMO we shouldn't allow drivers to follow that rule anymore.
What we'd need is an assert that any plane that exposes
formats with alpha also exposes the blend mode property.
That would at least force the drivers to get fixed.
> + *
> * RETURNS:
> * Zero for success or -errno
> */
> @@ -599,13 +602,13 @@ 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)))
> + if (WARN_ON((supported_modes & ~valid_mode_mask)))
> return -EINVAL;
>
> prop = drm_property_create(dev, DRM_MODE_PROP_ENUM,
> @@ -630,7 +633,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
--
Ville Syrjälä
Intel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/drm_blend: allow blend mode property without PREMULTI
2026-04-27 12:17 ` Ville Syrjälä
@ 2026-04-27 20:36 ` Leandro Ribeiro
0 siblings, 0 replies; 3+ messages in thread
From: Leandro Ribeiro @ 2026-04-27 20:36 UTC (permalink / raw)
To: Ville Syrjälä
Cc: dri-devel, airlied, daniels, maarten.lankhorst, mripard,
pekka.paalanen, simona, tzimmermann, linux-kernel
On 4/27/26 9:17 AM, Ville Syrjälä wrote:
> On Fri, Apr 24, 2026 at 11:35:13AM -0300, Leandro Ribeiro 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.
>>
>> 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.
>>
>> If the driver does not support the blend mode property, userspace must
>> assume that only PREMULTI is supported (as was the case before this
>> patch).
>>
>> Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
>> ---
>> drivers/gpu/drm/drm_blend.c | 24 +++++++++++++++++-------
>> 1 file changed, 17 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/drm_blend.c b/drivers/gpu/drm/drm_blend.c
>> index 1f3af27d2418..e5015d0fb219 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.
>> *
>> @@ -586,6 +586,9 @@ EXPORT_SYMBOL(drm_atomic_normalize_zpos);
>> * pre-multiplied and will do so when blending them to the background color
>> * values.
>> *
>> + * Note: if the blend mode property is not present, userspace must assume that
>> + * the driver supports only "Pre-multiplied".
>
> IMO we shouldn't allow drivers to follow that rule anymore.
> What we'd need is an assert that any plane that exposes
> formats with alpha also exposes the blend mode property.
> That would at least force the drivers to get fixed.
Sounds good to me. I prefer that instead of relying on assumptions.
Besides pixel formats with alpha, we should also check for planes that
expose the alpha property, right?
Also, I'm wondering where to assert that. I see that before registering
the DRM device, in drm_dev_register(), drm_mode_config_validate() is
called. But it doesn't fail if a check doesn't pass, only WARN. So I'm
wondering if there's a better place.
>
>> + *
>> * RETURNS:
>> * Zero for success or -errno
>> */
>> @@ -599,13 +602,13 @@ 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)))
>> + if (WARN_ON((supported_modes & ~valid_mode_mask)))
>> return -EINVAL;
>>
>> prop = drm_property_create(dev, DRM_MODE_PROP_ENUM,
>> @@ -630,7 +633,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
>
--
Leandro Ribeiro
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-04-27 20:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-24 14:35 [PATCH] drm/drm_blend: allow blend mode property without PREMULTI Leandro Ribeiro
2026-04-27 12:17 ` Ville Syrjälä
2026-04-27 20:36 ` Leandro Ribeiro
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox