[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aRXp0rfAoXxJ8PEh@fedora>
Date: Thu, 13 Nov 2025 15:23:14 +0100
From: José Expósito <jose.exposito89@...il.com>
To: Louis Chauvet <louis.chauvet@...tlin.com>
Cc: Haneen Mohammed <hamohammed.sa@...il.com>,
Simona Vetter <simona@...ll.ch>,
Melissa Wen <melissa.srw@...il.com>,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Maxime Ripard <mripard@...nel.org>,
Thomas Zimmermann <tzimmermann@...e.de>,
David Airlie <airlied@...il.com>, Jonathan Corbet <corbet@....net>,
victoria@...tem76.com, sebastian.wick@...hat.com,
thomas.petazzoni@...tlin.com, dri-devel@...ts.freedesktop.org,
linux-kernel@...r.kernel.org, linux-doc@...r.kernel.org
Subject: Re: [PATCH RESEND v2 07/32] drm/blend: Get a rotation name from it's
bitfield
On Wed, Oct 29, 2025 at 03:36:44PM +0100, 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@...hat.com>
> Signed-off-by: Louis Chauvet <louis.chauvet@...tlin.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 6852d73c931c..bc7c05e20242 100644
> --- a/drivers/gpu/drm/drm_blend.c
> +++ b/drivers/gpu/drm/drm_blend.c
> @@ -241,6 +241,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;
> +
> + return "(unknown)";
> +}
> +EXPORT_SYMBOL(drm_get_rotation_name);
> +
> /**
> * drm_plane_create_rotation_property - create a new rotation property
> * @plane: drm plane
> @@ -279,14 +304,6 @@ int drm_plane_create_rotation_property(struct drm_plane *plane,
> unsigned int rotation,
> unsigned int supported_rotations)
> {
> - static const struct drm_prop_enum_list 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" },
> - };
> struct drm_property *prop;
>
> WARN_ON((supported_rotations & DRM_MODE_ROTATE_MASK) == 0);
> @@ -294,7 +311,7 @@ int drm_plane_create_rotation_property(struct drm_plane *plane,
> WARN_ON(rotation & ~supported_rotations);
>
> prop = drm_property_create_bitmask(plane->dev, 0, "rotation",
> - props, ARRAY_SIZE(props),
> + rotation_props, ARRAY_SIZE(rotation_props),
> supported_rotations);
> if (!prop)
> return -ENOMEM;
> diff --git a/include/drm/drm_blend.h b/include/drm/drm_blend.h
> index 88bdfec3bd88..381d1f8d815b 100644
> --- a/include/drm/drm_blend.h
> +++ b/include/drm/drm_blend.h
> @@ -42,6 +42,8 @@ static inline bool drm_rotation_90_or_270(unsigned int rotation)
>
> #define DRM_BLEND_ALPHA_OPAQUE 0xffff
>
> +const char *drm_get_rotation_name(unsigned int rotation);
> +
> int drm_plane_create_alpha_property(struct drm_plane *plane);
> int drm_plane_create_rotation_property(struct drm_plane *plane,
> unsigned int rotation,
>
> --
> 2.51.0
>
Powered by blists - more mailing lists