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

Ville Syrjälä
2026-04-22T16:52:49Z

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@redhat.com>
> Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
> Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
> ---
> 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