diff mbox series

[v6,02/51] drm/connector: Add helper to get a connector type name

Message ID 20200216210308.17312-3-laurent.pinchart@ideasonboard.com (mailing list archive)
State New, archived
Headers show
Series drm/omap: Replace custom display drivers with drm_bridge and drm_panel | expand

Commit Message

Laurent Pinchart Feb. 16, 2020, 9:02 p.m. UTC
drm_connector.c contains a map of connector types (DRM_MODE_CONNECTOR_*)
to name strings, but doesn't expose it. This leads to drivers having to
store a similar map.

Add a new drm_get_connector_type_name() helper function that return a
name string for a connector type.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
---
 drivers/gpu/drm/drm_connector.c | 15 +++++++++++++++
 include/drm/drm_connector.h     |  1 +
 2 files changed, 16 insertions(+)

Comments

Daniel Vetter Feb. 17, 2020, 9:43 a.m. UTC | #1
On Sun, Feb 16, 2020 at 11:02:19PM +0200, Laurent Pinchart wrote:
> drm_connector.c contains a map of connector types (DRM_MODE_CONNECTOR_*)
> to name strings, but doesn't expose it. This leads to drivers having to
> store a similar map.

Maybe also a todo if there's many of these?
-Daniel

> 
> Add a new drm_get_connector_type_name() helper function that return a
> name string for a connector type.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
> Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
> ---
>  drivers/gpu/drm/drm_connector.c | 15 +++++++++++++++
>  include/drm/drm_connector.h     |  1 +
>  2 files changed, 16 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
> index f632ca05960e..644f0ad10671 100644
> --- a/drivers/gpu/drm/drm_connector.c
> +++ b/drivers/gpu/drm/drm_connector.c
> @@ -111,6 +111,21 @@ void drm_connector_ida_destroy(void)
>  		ida_destroy(&drm_connector_enum_list[i].ida);
>  }
>  
> +/**
> + * drm_get_connector_type_name - return a string for connector type
> + * @type: The connector type (DRM_MODE_CONNECTOR_*)
> + *
> + * Returns: the name of the connector type, or NULL if the type is not valid.
> + */
> +const char *drm_get_connector_type_name(unsigned int type)
> +{
> +	if (type < ARRAY_SIZE(drm_connector_enum_list))
> +		return drm_connector_enum_list[type].name;
> +
> +	return NULL;
> +}
> +EXPORT_SYMBOL(drm_get_connector_type_name);
> +
>  /**
>   * drm_connector_get_cmdline_mode - reads the user's cmdline mode
>   * @connector: connector to quwery
> diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
> index b3815371c271..c3bd5262db9c 100644
> --- a/include/drm/drm_connector.h
> +++ b/include/drm/drm_connector.h
> @@ -1518,6 +1518,7 @@ drm_connector_is_unregistered(struct drm_connector *connector)
>  		DRM_CONNECTOR_UNREGISTERED;
>  }
>  
> +const char *drm_get_connector_type_name(unsigned int connector_type);
>  const char *drm_get_connector_status_name(enum drm_connector_status status);
>  const char *drm_get_subpixel_order_name(enum subpixel_order order);
>  const char *drm_get_dpms_name(int val);
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
Laurent Pinchart Feb. 21, 2020, 2:15 p.m. UTC | #2
Hi Daniel,

On Mon, Feb 17, 2020 at 10:43:03AM +0100, Daniel Vetter wrote:
> On Sun, Feb 16, 2020 at 11:02:19PM +0200, Laurent Pinchart wrote:
> > drm_connector.c contains a map of connector types (DRM_MODE_CONNECTOR_*)
> > to name strings, but doesn't expose it. This leads to drivers having to
> > store a similar map.
> 
> Maybe also a todo if there's many of these?

I had a quick look, and this is actually mostly need for a patch further
in this series :-) I don't think there's a need for a todo item.

> > Add a new drm_get_connector_type_name() helper function that return a
> > name string for a connector type.
> > 
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
> > Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
> > ---
> >  drivers/gpu/drm/drm_connector.c | 15 +++++++++++++++
> >  include/drm/drm_connector.h     |  1 +
> >  2 files changed, 16 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
> > index f632ca05960e..644f0ad10671 100644
> > --- a/drivers/gpu/drm/drm_connector.c
> > +++ b/drivers/gpu/drm/drm_connector.c
> > @@ -111,6 +111,21 @@ void drm_connector_ida_destroy(void)
> >  		ida_destroy(&drm_connector_enum_list[i].ida);
> >  }
> >  
> > +/**
> > + * drm_get_connector_type_name - return a string for connector type
> > + * @type: The connector type (DRM_MODE_CONNECTOR_*)
> > + *
> > + * Returns: the name of the connector type, or NULL if the type is not valid.
> > + */
> > +const char *drm_get_connector_type_name(unsigned int type)
> > +{
> > +	if (type < ARRAY_SIZE(drm_connector_enum_list))
> > +		return drm_connector_enum_list[type].name;
> > +
> > +	return NULL;
> > +}
> > +EXPORT_SYMBOL(drm_get_connector_type_name);
> > +
> >  /**
> >   * drm_connector_get_cmdline_mode - reads the user's cmdline mode
> >   * @connector: connector to quwery
> > diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
> > index b3815371c271..c3bd5262db9c 100644
> > --- a/include/drm/drm_connector.h
> > +++ b/include/drm/drm_connector.h
> > @@ -1518,6 +1518,7 @@ drm_connector_is_unregistered(struct drm_connector *connector)
> >  		DRM_CONNECTOR_UNREGISTERED;
> >  }
> >  
> > +const char *drm_get_connector_type_name(unsigned int connector_type);
> >  const char *drm_get_connector_status_name(enum drm_connector_status status);
> >  const char *drm_get_subpixel_order_name(enum subpixel_order order);
> >  const char *drm_get_dpms_name(int val);
diff mbox series

Patch

diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index f632ca05960e..644f0ad10671 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -111,6 +111,21 @@  void drm_connector_ida_destroy(void)
 		ida_destroy(&drm_connector_enum_list[i].ida);
 }
 
+/**
+ * drm_get_connector_type_name - return a string for connector type
+ * @type: The connector type (DRM_MODE_CONNECTOR_*)
+ *
+ * Returns: the name of the connector type, or NULL if the type is not valid.
+ */
+const char *drm_get_connector_type_name(unsigned int type)
+{
+	if (type < ARRAY_SIZE(drm_connector_enum_list))
+		return drm_connector_enum_list[type].name;
+
+	return NULL;
+}
+EXPORT_SYMBOL(drm_get_connector_type_name);
+
 /**
  * drm_connector_get_cmdline_mode - reads the user's cmdline mode
  * @connector: connector to quwery
diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
index b3815371c271..c3bd5262db9c 100644
--- a/include/drm/drm_connector.h
+++ b/include/drm/drm_connector.h
@@ -1518,6 +1518,7 @@  drm_connector_is_unregistered(struct drm_connector *connector)
 		DRM_CONNECTOR_UNREGISTERED;
 }
 
+const char *drm_get_connector_type_name(unsigned int connector_type);
 const char *drm_get_connector_status_name(enum drm_connector_status status);
 const char *drm_get_subpixel_order_name(enum subpixel_order order);
 const char *drm_get_dpms_name(int val);