Re: [PATCH v4 02/37] drm/blend: Get a rotation name from it's bitfield

From: Ville Syrjälä

Date: Wed Apr 22 2026 - 13:01:06 EST


On Wed, Apr 22, 2026 at 06:47:59PM +0200, Louis Chauvet wrote:
> Having the rotation/reflection name from its value can be useful for
> debugging purpose. Extract the rotation property table and implement
> drm_get_rotation_name.
>
> Reviewed-by: José Expósito <jose.exposito@xxxxxxxxxx>
> Reviewed-by: Luca Ceresoli <luca.ceresoli@xxxxxxxxxxx>
> Signed-off-by: Louis Chauvet <louis.chauvet@xxxxxxxxxxx>
> ---
> drivers/gpu/drm/drm_blend.c | 35 ++++++++++++++++++++++++++---------
> include/drm/drm_blend.h | 2 ++
> 2 files changed, 28 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_blend.c b/drivers/gpu/drm/drm_blend.c
> index 1f3af27d2418..11d8e13caea3 100644
> --- a/drivers/gpu/drm/drm_blend.c
> +++ b/drivers/gpu/drm/drm_blend.c
> @@ -256,6 +256,31 @@ int drm_plane_create_alpha_property(struct drm_plane *plane)
> }
> EXPORT_SYMBOL(drm_plane_create_alpha_property);
>
> +static const struct drm_prop_enum_list rotation_props[] = {
> + { __builtin_ffs(DRM_MODE_ROTATE_0) - 1, "rotate-0" },
> + { __builtin_ffs(DRM_MODE_ROTATE_90) - 1, "rotate-90" },
> + { __builtin_ffs(DRM_MODE_ROTATE_180) - 1, "rotate-180" },
> + { __builtin_ffs(DRM_MODE_ROTATE_270) - 1, "rotate-270" },
> + { __builtin_ffs(DRM_MODE_REFLECT_X) - 1, "reflect-x" },
> + { __builtin_ffs(DRM_MODE_REFLECT_Y) - 1, "reflect-y" },
> +};
> +
> +/**
> + * drm_get_rotation_name - Return the name of a rotation
> + * @rotation: The rotation mask (DRM_MODE_ROTATE_* | DRM_MODE_REFLECT_*)
> + *
> + * Returns: the name of the rotation type (unknown) if rotation is not
> + * a known rotation/reflection
> + */
> +const char *drm_get_rotation_name(unsigned int rotation)
> +{
> + if (rotation < ARRAY_SIZE(rotation_props))
> + return rotation_props[rotation].name;

The value is a bitmask. This does not work.

--
Ville Syrjälä
Intel