[PATCH RESEND v2 01/32] drm/drm_mode_config: Add helper to get plane type name

Louis Chauvet posted 32 patches 3 months, 1 week ago
There is a newer version of this series
[PATCH RESEND v2 01/32] drm/drm_mode_config: Add helper to get plane type name
Posted by Louis Chauvet 3 months, 1 week ago
Create and export an helper to display plane type using the
property string. This could be used to display debug
information in VKMS.

Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
 drivers/gpu/drm/drm_mode_config.c | 13 +++++++++++++
 include/drm/drm_mode_config.h     |  3 +++
 2 files changed, 16 insertions(+)

diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
index 25f376869b3a..1a1a3f43db4d 100644
--- a/drivers/gpu/drm/drm_mode_config.c
+++ b/drivers/gpu/drm/drm_mode_config.c
@@ -226,6 +226,19 @@ static const struct drm_prop_enum_list drm_plane_type_enum_list[] = {
 	{ DRM_PLANE_TYPE_CURSOR, "Cursor" },
 };
 
+/**
+ * drm_get_plane_type_name - return a string for plane name
+ * @type: plane type to compute name of
+ */
+const char *drm_get_plane_type_name(enum drm_plane_type type)
+{
+	if (type < ARRAY_SIZE(drm_plane_type_enum_list))
+		return drm_plane_type_enum_list[type].name;
+	else
+		return "(unknown)";
+}
+EXPORT_SYMBOL(drm_get_plane_type_name);
+
 static int drm_mode_create_standard_properties(struct drm_device *dev)
 {
 	struct drm_property *prop;
diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
index 2e848b816218..89f3dd46178d 100644
--- a/include/drm/drm_mode_config.h
+++ b/include/drm/drm_mode_config.h
@@ -30,6 +30,7 @@
 #include <linux/llist.h>
 
 #include <drm/drm_modeset_lock.h>
+#include <drm/drm_plane.h>
 
 struct drm_file;
 struct drm_device;
@@ -983,4 +984,6 @@ static inline int drm_mode_config_init(struct drm_device *dev)
 void drm_mode_config_reset(struct drm_device *dev);
 void drm_mode_config_cleanup(struct drm_device *dev);
 
+const char *drm_get_plane_type_name(enum drm_plane_type type);
+
 #endif

-- 
2.51.0
Re: [PATCH RESEND v2 01/32] drm/drm_mode_config: Add helper to get plane type name
Posted by Luca Ceresoli 1 month, 3 weeks ago
Hi Louis,

On Wed Oct 29, 2025 at 3:36 PM CET, Louis Chauvet wrote:
> Create and export an helper to display plane type using the
> property string. This could be used to display debug
> information in VKMS.
>
> Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
> ---
>  drivers/gpu/drm/drm_mode_config.c | 13 +++++++++++++
>  include/drm/drm_mode_config.h     |  3 +++
>  2 files changed, 16 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> index 25f376869b3a..1a1a3f43db4d 100644
> --- a/drivers/gpu/drm/drm_mode_config.c
> +++ b/drivers/gpu/drm/drm_mode_config.c
> @@ -226,6 +226,19 @@ static const struct drm_prop_enum_list drm_plane_type_enum_list[] = {
>  	{ DRM_PLANE_TYPE_CURSOR, "Cursor" },
>  };
>
> +/**
> + * drm_get_plane_type_name - return a string for plane name
> + * @type: plane type to compute name of
> + */
> +const char *drm_get_plane_type_name(enum drm_plane_type type)
> +{
> +	if (type < ARRAY_SIZE(drm_plane_type_enum_list))
> +		return drm_plane_type_enum_list[type].name;
> +	else
> +		return "(unknown)";
> +}

AFAIK an enum can be signed, so you should check for >= 0 too for extra
safety.

Otherwise looks good.

Luca

--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
Re: [PATCH RESEND v2 01/32] drm/drm_mode_config: Add helper to get plane type name
Posted by José Expósito 2 months, 3 weeks ago
Hey Louis,

On Wed, Oct 29, 2025 at 03:36:38PM +0100, Louis Chauvet wrote:
> Create and export an helper to display plane type using the
> property string. This could be used to display debug
> information in VKMS.
> 
> Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
> ---
>  drivers/gpu/drm/drm_mode_config.c | 13 +++++++++++++
>  include/drm/drm_mode_config.h     |  3 +++
>  2 files changed, 16 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> index 25f376869b3a..1a1a3f43db4d 100644
> --- a/drivers/gpu/drm/drm_mode_config.c
> +++ b/drivers/gpu/drm/drm_mode_config.c
> @@ -226,6 +226,19 @@ static const struct drm_prop_enum_list drm_plane_type_enum_list[] = {
>  	{ DRM_PLANE_TYPE_CURSOR, "Cursor" },
>  };
>  
> +/**
> + * drm_get_plane_type_name - return a string for plane name
> + * @type: plane type to compute name of

Maybe we could document here what happens when the plane type is
not valid.

Returns: The name of the plane type. "(unknown)" if type is not a
known plane type.

Other than that:
Reviewed-by: José Expósito <jose.exposito@redhat.com>

> + */
> +const char *drm_get_plane_type_name(enum drm_plane_type type)
> +{
> +	if (type < ARRAY_SIZE(drm_plane_type_enum_list))
> +		return drm_plane_type_enum_list[type].name;
> +	else
> +		return "(unknown)";
> +}
> +EXPORT_SYMBOL(drm_get_plane_type_name);
> +
>  static int drm_mode_create_standard_properties(struct drm_device *dev)
>  {
>  	struct drm_property *prop;
> diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
> index 2e848b816218..89f3dd46178d 100644
> --- a/include/drm/drm_mode_config.h
> +++ b/include/drm/drm_mode_config.h
> @@ -30,6 +30,7 @@
>  #include <linux/llist.h>
>  
>  #include <drm/drm_modeset_lock.h>
> +#include <drm/drm_plane.h>
>  
>  struct drm_file;
>  struct drm_device;
> @@ -983,4 +984,6 @@ static inline int drm_mode_config_init(struct drm_device *dev)
>  void drm_mode_config_reset(struct drm_device *dev);
>  void drm_mode_config_cleanup(struct drm_device *dev);
>  
> +const char *drm_get_plane_type_name(enum drm_plane_type type);
> +
>  #endif
> 
> -- 
> 2.51.0
> 
Re: [PATCH RESEND v2 01/32] drm/drm_mode_config: Add helper to get plane type name
Posted by Louis Chauvet 2 months, 3 weeks ago

On 11/13/25 14:06, José Expósito wrote:
> Hey Louis,
> 
> On Wed, Oct 29, 2025 at 03:36:38PM +0100, Louis Chauvet wrote:
>> Create and export an helper to display plane type using the
>> property string. This could be used to display debug
>> information in VKMS.
>>
>> Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
>> ---
>>   drivers/gpu/drm/drm_mode_config.c | 13 +++++++++++++
>>   include/drm/drm_mode_config.h     |  3 +++
>>   2 files changed, 16 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
>> index 25f376869b3a..1a1a3f43db4d 100644
>> --- a/drivers/gpu/drm/drm_mode_config.c
>> +++ b/drivers/gpu/drm/drm_mode_config.c
>> @@ -226,6 +226,19 @@ static const struct drm_prop_enum_list drm_plane_type_enum_list[] = {
>>   	{ DRM_PLANE_TYPE_CURSOR, "Cursor" },
>>   };
>>   
>> +/**
>> + * drm_get_plane_type_name - return a string for plane name
>> + * @type: plane type to compute name of
> 
> Maybe we could document here what happens when the plane type is
> not valid.
> 
> Returns: The name of the plane type. "(unknown)" if type is not a
> known plane type.

Ack, I will integrate it for v3

> Other than that:
> Reviewed-by: José Expósito <jose.exposito@redhat.com>
> 
>> + */
>> +const char *drm_get_plane_type_name(enum drm_plane_type type)
>> +{
>> +	if (type < ARRAY_SIZE(drm_plane_type_enum_list))
>> +		return drm_plane_type_enum_list[type].name;
>> +	else
>> +		return "(unknown)";
>> +}
>> +EXPORT_SYMBOL(drm_get_plane_type_name);
>> +
>>   static int drm_mode_create_standard_properties(struct drm_device *dev)
>>   {
>>   	struct drm_property *prop;
>> diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
>> index 2e848b816218..89f3dd46178d 100644
>> --- a/include/drm/drm_mode_config.h
>> +++ b/include/drm/drm_mode_config.h
>> @@ -30,6 +30,7 @@
>>   #include <linux/llist.h>
>>   
>>   #include <drm/drm_modeset_lock.h>
>> +#include <drm/drm_plane.h>
>>   
>>   struct drm_file;
>>   struct drm_device;
>> @@ -983,4 +984,6 @@ static inline int drm_mode_config_init(struct drm_device *dev)
>>   void drm_mode_config_reset(struct drm_device *dev);
>>   void drm_mode_config_cleanup(struct drm_device *dev);
>>   
>> +const char *drm_get_plane_type_name(enum drm_plane_type type);
>> +
>>   #endif
>>
>> -- 
>> 2.51.0
>>