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

From: Louis Chauvet

Date: Thu Apr 23 2026 - 04:52:46 EST




On 4/22/26 18:52, Ville Syrjälä wrote:
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.


That true, the documentation is not clear.

Take a look at patch 15 [1] for the usage. Is it better if I change the documentation to:

drm_get_rotation_name - Returns the name of a rotation/reflection bitmask (with only one bit set).
@rotation: Bitmask with a single bit set.
Name of the rotation/reflection, or "(unknown)" if invalid.

[1]:https://lore.kernel.org/all/20260422-vkms-all-config-v4-15-dbb52e9aadc3@xxxxxxxxxxx/