Not all devices support pre-multiplied blend mode. In these cases, userspace cannot expect this mode to be the default, since the hardware cannot produce it (and could not default to it before a blend mode property existed). Therefore, add a variant of drm_plane_create_blend_mode_property that allows specifying the default.
Signed-off-by: Sean Anderson <[email protected]> --- Changes in v2: - New drivers/gpu/drm/drm_blend.c | 22 ++++++++++------------ include/drm/drm_blend.h | 26 ++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/drm_blend.c b/drivers/gpu/drm/drm_blend.c index 6852d73c931c..fac0f1478385 100644 --- a/drivers/gpu/drm/drm_blend.c +++ b/drivers/gpu/drm/drm_blend.c @@ -546,12 +546,10 @@ int drm_atomic_normalize_zpos(struct drm_device *dev, EXPORT_SYMBOL(drm_atomic_normalize_zpos); /** - * drm_plane_create_blend_mode_property - create a new blend mode property + * drm_plane_create_blend_mode_default - 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, must include BIT(@def) + * @def: Default blend mode * * This creates a new property describing the blend mode. * @@ -571,11 +569,11 @@ EXPORT_SYMBOL(drm_atomic_normalize_zpos); * pre-multiplied and will do so when blending them to the background color * values. * - * RETURNS: - * Zero for success or -errno + * Return: Zero for success or -errno */ -int drm_plane_create_blend_mode_property(struct drm_plane *plane, - unsigned int supported_modes) +int drm_plane_create_blend_mode_default(struct drm_plane *plane, + unsigned int supported_modes, + unsigned int def) { struct drm_device *dev = plane->dev; struct drm_property *prop; @@ -590,7 +588,7 @@ int drm_plane_create_blend_mode_property(struct drm_plane *plane, int i; if (WARN_ON((supported_modes & ~valid_mode_mask) || - ((supported_modes & BIT(DRM_MODE_BLEND_PREMULTI)) == 0))) + !(supported_modes & BIT(def)))) return -EINVAL; prop = drm_property_create(dev, DRM_MODE_PROP_ENUM, @@ -615,9 +613,9 @@ int drm_plane_create_blend_mode_property(struct drm_plane *plane, } } - drm_object_attach_property(&plane->base, prop, DRM_MODE_BLEND_PREMULTI); + drm_object_attach_property(&plane->base, prop, def); plane->blend_mode_property = prop; return 0; } -EXPORT_SYMBOL(drm_plane_create_blend_mode_property); +EXPORT_SYMBOL(drm_plane_create_blend_mode_default); diff --git a/include/drm/drm_blend.h b/include/drm/drm_blend.h index 88bdfec3bd88..244f0694d0a5 100644 --- a/include/drm/drm_blend.h +++ b/include/drm/drm_blend.h @@ -56,6 +56,28 @@ int drm_plane_create_zpos_immutable_property(struct drm_plane *plane, unsigned int zpos); int drm_atomic_normalize_zpos(struct drm_device *dev, struct drm_atomic_state *state); -int drm_plane_create_blend_mode_property(struct drm_plane *plane, - unsigned int supported_modes); +int drm_plane_create_blend_mode_default(struct drm_plane *plane, + unsigned int supported_modes, + unsigned int def); + +/** + * 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. + * + * This creates a new property describing the blend mode. See + * drm_plane_create_blend_mode_default() for details. + * + * Return: Zero for success or -errno + */ +static inline int +drm_plane_create_blend_mode_property(struct drm_plane *plane, + unsigned int supported_modes) +{ + return drm_plane_create_blend_mode_default(plane, supported_modes, + DRM_MODE_BLEND_PREMULTI); +} #endif -- 2.35.1.1320.gc452695387.dirty
