diff mbox

[v2,03/60] drm/omap: Do dss_device (display) ordering in omap_drv.c

Message ID 20180526172518.18710-4-laurent.pinchart@ideasonboard.com (mailing list archive)
State New, archived
Headers show

Commit Message

Laurent Pinchart May 26, 2018, 5:24 p.m. UTC
From: Peter Ujfalusi <peter.ujfalusi@ti.com>

Sort the dssdev array based on DT aliases.

With this change we can remove the panel ordering from dss/display.c and
have all sorting related to dssdevs in one place.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
Changes since v0:

- Make alias_id unsigned
---
 drivers/gpu/drm/omapdrm/dss/display.c |  2 ++
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  1 +
 drivers/gpu/drm/omapdrm/omap_drv.c    | 18 ++++++++++++++++++
 3 files changed, 21 insertions(+)

Comments

Sebastian Reichel June 10, 2018, 3:23 p.m. UTC | #1
Hi,

On Sat, May 26, 2018 at 08:24:21PM +0300, Laurent Pinchart wrote:
> From: Peter Ujfalusi <peter.ujfalusi@ti.com>
> 
> Sort the dssdev array based on DT aliases.
> 
> With this change we can remove the panel ordering from dss/display.c and
> have all sorting related to dssdevs in one place.
> 
> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

> Changes since v0:
> 
> - Make alias_id unsigned
> ---
>  drivers/gpu/drm/omapdrm/dss/display.c |  2 ++
>  drivers/gpu/drm/omapdrm/dss/omapdss.h |  1 +
>  drivers/gpu/drm/omapdrm/omap_drv.c    | 18 ++++++++++++++++++
>  3 files changed, 21 insertions(+)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/display.c b/drivers/gpu/drm/omapdrm/dss/display.c
> index 424143128cd4..3ef99f344bd3 100644
> --- a/drivers/gpu/drm/omapdrm/dss/display.c
> +++ b/drivers/gpu/drm/omapdrm/dss/display.c
> @@ -52,6 +52,8 @@ int omapdss_register_display(struct omap_dss_device *dssdev)
>  	if (id < 0)
>  		id = disp_num_counter++;
>  
> +	dssdev->alias_id = id;
> +
>  	snprintf(dssdev->alias, sizeof(dssdev->alias), "display%d", id);
>  
>  	/* Use 'label' property for name, if it exists */
> diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
> index 14d74adb13fb..eae105b0b961 100644
> --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
> +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
> @@ -467,6 +467,7 @@ struct omap_dss_device {
>  
>  	/* alias in the form of "display%d" */
>  	char alias[16];
> +	unsigned int alias_id;
>  
>  	enum omap_display_type type;
>  	enum omap_display_type output_type;
> diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c
> index 9277aa8c49c0..e2d7f8bfb4c1 100644
> --- a/drivers/gpu/drm/omapdrm/omap_drv.c
> +++ b/drivers/gpu/drm/omapdrm/omap_drv.c
> @@ -15,6 +15,8 @@
>   * this program.  If not, see <http://www.gnu.org/licenses/>.
>   */
>  
> +#include <linux/of.h>
> +#include <linux/sort.h>
>  #include <linux/sys_soc.h>
>  
>  #include <drm/drm_atomic.h>
> @@ -165,6 +167,18 @@ static void omap_disconnect_dssdevs(struct drm_device *ddev)
>  	priv->num_dssdevs = 0;
>  }
>  
> +static int omap_compare_dssdevs(const void *a, const void *b)
> +{
> +	const struct omap_dss_device *dssdev1 = *(struct omap_dss_device **)a;
> +	const struct omap_dss_device *dssdev2 = *(struct omap_dss_device **)b;
> +
> +	if (dssdev1->alias_id > dssdev2->alias_id)
> +		return 1;
> +	else if (dssdev1->alias_id < dssdev2->alias_id)
> +		return -1;
> +	return 0;
> +}
> +
>  static int omap_connect_dssdevs(struct drm_device *ddev)
>  {
>  	struct omap_drm_private *priv = ddev->dev_private;
> @@ -193,6 +207,10 @@ static int omap_connect_dssdevs(struct drm_device *ddev)
>  		}
>  	}
>  
> +	/* Sort the list by DT aliases */
> +	sort(priv->dssdevs, priv->num_dssdevs, sizeof(priv->dssdevs[0]),
> +	     omap_compare_dssdevs, NULL);
> +
>  	return 0;
>  
>  cleanup:
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
diff mbox

Patch

diff --git a/drivers/gpu/drm/omapdrm/dss/display.c b/drivers/gpu/drm/omapdrm/dss/display.c
index 424143128cd4..3ef99f344bd3 100644
--- a/drivers/gpu/drm/omapdrm/dss/display.c
+++ b/drivers/gpu/drm/omapdrm/dss/display.c
@@ -52,6 +52,8 @@  int omapdss_register_display(struct omap_dss_device *dssdev)
 	if (id < 0)
 		id = disp_num_counter++;
 
+	dssdev->alias_id = id;
+
 	snprintf(dssdev->alias, sizeof(dssdev->alias), "display%d", id);
 
 	/* Use 'label' property for name, if it exists */
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 14d74adb13fb..eae105b0b961 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -467,6 +467,7 @@  struct omap_dss_device {
 
 	/* alias in the form of "display%d" */
 	char alias[16];
+	unsigned int alias_id;
 
 	enum omap_display_type type;
 	enum omap_display_type output_type;
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c
index 9277aa8c49c0..e2d7f8bfb4c1 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -15,6 +15,8 @@ 
  * this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <linux/of.h>
+#include <linux/sort.h>
 #include <linux/sys_soc.h>
 
 #include <drm/drm_atomic.h>
@@ -165,6 +167,18 @@  static void omap_disconnect_dssdevs(struct drm_device *ddev)
 	priv->num_dssdevs = 0;
 }
 
+static int omap_compare_dssdevs(const void *a, const void *b)
+{
+	const struct omap_dss_device *dssdev1 = *(struct omap_dss_device **)a;
+	const struct omap_dss_device *dssdev2 = *(struct omap_dss_device **)b;
+
+	if (dssdev1->alias_id > dssdev2->alias_id)
+		return 1;
+	else if (dssdev1->alias_id < dssdev2->alias_id)
+		return -1;
+	return 0;
+}
+
 static int omap_connect_dssdevs(struct drm_device *ddev)
 {
 	struct omap_drm_private *priv = ddev->dev_private;
@@ -193,6 +207,10 @@  static int omap_connect_dssdevs(struct drm_device *ddev)
 		}
 	}
 
+	/* Sort the list by DT aliases */
+	sort(priv->dssdevs, priv->num_dssdevs, sizeof(priv->dssdevs[0]),
+	     omap_compare_dssdevs, NULL);
+
 	return 0;
 
 cleanup: