All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tomi Valkeinen <tomi.valkeinen@ti.com>
To: dri-devel@lists.freedesktop.org,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Peter Ujfalusi <peter.ujfalusi@ti.com>,
	Jyri Sarha <jsarha@ti.com>, Benoit Parrot <bparrot@ti.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Subject: [PATCH 07/24] drm/omap: Manage the usable omap_dss_device list within omap_drm_private
Date: Mon, 12 Feb 2018 11:44:37 +0200	[thread overview]
Message-ID: <1518428694-18018-8-git-send-email-tomi.valkeinen@ti.com> (raw)
In-Reply-To: <1518428694-18018-1-git-send-email-tomi.valkeinen@ti.com>

From: Peter Ujfalusi <peter.ujfalusi@ti.com>

Instead of reaching back to DSS to iterate through the dss_devices every
time, use an internal array where we store the available and usable
dss_devices.

At the same time remove the omapdss_device_is_connected() check from
omap_modeset_init() as it became irrelevant: We are not adding dssdevs
if their connect failed.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/gpu/drm/omapdrm/omap_drv.c | 95 +++++++++++++++++++++++---------------
 drivers/gpu/drm/omapdrm/omap_drv.h |  3 ++
 2 files changed, 62 insertions(+), 36 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c
index 57d11f9aeead..869a8ab6aa4e 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -149,18 +149,27 @@ static int get_connector_type(struct omap_dss_device *dssdev)
 	}
 }
 
-static void omap_disconnect_dssdevs(void)
+static void omap_disconnect_dssdevs(struct drm_device *ddev)
 {
-	struct omap_dss_device *dssdev = NULL;
+	struct omap_drm_private *priv = ddev->dev_private;
+	unsigned int i;
+
+	for (i = 0; i < priv->num_dssdevs; i++) {
+		struct omap_dss_device *dssdev = priv->dssdevs[i];
 
-	for_each_dss_dev(dssdev)
 		dssdev->driver->disconnect(dssdev);
+		priv->dssdevs[i] = NULL;
+		omap_dss_put_device(dssdev);
+	}
+
+	priv->num_dssdevs = 0;
 }
 
-static int omap_connect_dssdevs(void)
+static int omap_connect_dssdevs(struct drm_device *ddev)
 {
-	int r;
+	struct omap_drm_private *priv = ddev->dev_private;
 	struct omap_dss_device *dssdev = NULL;
+	int r;
 
 	if (!omapdss_stack_is_ready())
 		return -EPROBE_DEFER;
@@ -173,6 +182,14 @@ static int omap_connect_dssdevs(void)
 		} else if (r) {
 			dev_warn(dssdev->dev, "could not connect display: %s\n",
 				dssdev->name);
+		} else {
+			omap_dss_get_device(dssdev);
+			priv->dssdevs[priv->num_dssdevs++] = dssdev;
+			if (priv->num_dssdevs == ARRAY_SIZE(priv->dssdevs)) {
+				/* To balance the 'for_each_dss_dev' loop */
+				omap_dss_put_device(dssdev);
+				break;
+			}
 		}
 	}
 
@@ -183,7 +200,7 @@ static int omap_connect_dssdevs(void)
 	 * if we are deferring probe, we disconnect the devices we previously
 	 * connected
 	 */
-	omap_disconnect_dssdevs();
+	omap_disconnect_dssdevs(ddev);
 
 	return r;
 }
@@ -208,7 +225,7 @@ static int omap_modeset_init(struct drm_device *dev)
 	int num_ovls = priv->dispc_ops->get_num_ovls();
 	int num_mgrs = priv->dispc_ops->get_num_mgrs();
 	int num_crtcs, crtc_idx, plane_idx;
-	int ret;
+	int ret, i;
 	u32 plane_crtc_mask;
 
 	drm_mode_config_init(dev);
@@ -225,11 +242,7 @@ static int omap_modeset_init(struct drm_device *dev)
 	 * configuration does not match the expectations or exceeds
 	 * the available resources, the configuration is rejected.
 	 */
-	num_crtcs = 0;
-	for_each_dss_dev(dssdev)
-		if (omapdss_device_is_connected(dssdev))
-			num_crtcs++;
-
+	num_crtcs = priv->num_dssdevs;
 	if (num_crtcs > num_mgrs || num_crtcs > num_ovls ||
 	    num_crtcs > ARRAY_SIZE(priv->crtcs) ||
 	    num_crtcs > ARRAY_SIZE(priv->planes) ||
@@ -247,15 +260,13 @@ static int omap_modeset_init(struct drm_device *dev)
 
 	crtc_idx = 0;
 	plane_idx = 0;
-	for_each_dss_dev(dssdev) {
+	for (i = 0; i < priv->num_dssdevs; i++) {
+		struct omap_dss_device *dssdev = priv->dssdevs[i];
 		struct drm_connector *connector;
 		struct drm_encoder *encoder;
 		struct drm_plane *plane;
 		struct drm_crtc *crtc;
 
-		if (!omapdss_device_is_connected(dssdev))
-			continue;
-
 		encoder = omap_encoder_init(dev, dssdev);
 		if (!encoder)
 			return -ENOMEM;
@@ -329,11 +340,14 @@ static int omap_modeset_init(struct drm_device *dev)
 /*
  * Enable the HPD in external components if supported
  */
-static void omap_modeset_enable_external_hpd(void)
+static void omap_modeset_enable_external_hpd(struct drm_device *ddev)
 {
-	struct omap_dss_device *dssdev = NULL;
+	struct omap_drm_private *priv = ddev->dev_private;
+	int i;
+
+	for (i = 0; i < priv->num_dssdevs; i++) {
+		struct omap_dss_device *dssdev = priv->dssdevs[i];
 
-	for_each_dss_dev(dssdev) {
 		if (dssdev->driver->enable_hpd)
 			dssdev->driver->enable_hpd(dssdev);
 	}
@@ -342,11 +356,14 @@ static void omap_modeset_enable_external_hpd(void)
 /*
  * Disable the HPD in external components if supported
  */
-static void omap_modeset_disable_external_hpd(void)
+static void omap_modeset_disable_external_hpd(struct drm_device *ddev)
 {
-	struct omap_dss_device *dssdev = NULL;
+	struct omap_drm_private *priv = ddev->dev_private;
+	int i;
+
+	for (i = 0; i < priv->num_dssdevs; i++) {
+		struct omap_dss_device *dssdev = priv->dssdevs[i];
 
-	for_each_dss_dev(dssdev) {
 		if (dssdev->driver->disable_hpd)
 			dssdev->driver->disable_hpd(dssdev);
 	}
@@ -543,7 +560,7 @@ static int pdev_probe(struct platform_device *pdev)
 
 	omap_crtc_pre_init();
 
-	ret = omap_connect_dssdevs();
+	ret = omap_connect_dssdevs(ddev);
 	if (ret)
 		goto err_crtc_uninit;
 
@@ -583,7 +600,7 @@ static int pdev_probe(struct platform_device *pdev)
 	omap_fbdev_init(ddev);
 
 	drm_kms_helper_poll_init(ddev);
-	omap_modeset_enable_external_hpd();
+	omap_modeset_enable_external_hpd(ddev);
 
 	/*
 	 * Register the DRM device with the core and the connectors with
@@ -596,7 +613,7 @@ static int pdev_probe(struct platform_device *pdev)
 	return 0;
 
 err_cleanup_helpers:
-	omap_modeset_disable_external_hpd();
+	omap_modeset_disable_external_hpd(ddev);
 	drm_kms_helper_poll_fini(ddev);
 
 	omap_fbdev_free(ddev);
@@ -606,7 +623,7 @@ static int pdev_probe(struct platform_device *pdev)
 err_gem_deinit:
 	omap_gem_deinit(ddev);
 	destroy_workqueue(priv->wq);
-	omap_disconnect_dssdevs();
+	omap_disconnect_dssdevs(ddev);
 err_crtc_uninit:
 	omap_crtc_pre_uninit();
 	drm_dev_unref(ddev);
@@ -622,7 +639,7 @@ static int pdev_remove(struct platform_device *pdev)
 
 	drm_dev_unregister(ddev);
 
-	omap_modeset_disable_external_hpd();
+	omap_modeset_disable_external_hpd(ddev);
 	drm_kms_helper_poll_fini(ddev);
 
 	omap_fbdev_free(ddev);
@@ -636,7 +653,7 @@ static int pdev_remove(struct platform_device *pdev)
 
 	destroy_workqueue(priv->wq);
 
-	omap_disconnect_dssdevs();
+	omap_disconnect_dssdevs(ddev);
 	omap_crtc_pre_uninit();
 
 	drm_dev_unref(ddev);
@@ -645,11 +662,14 @@ static int pdev_remove(struct platform_device *pdev)
 }
 
 #ifdef CONFIG_PM_SLEEP
-static int omap_drm_suspend_all_displays(void)
+static int omap_drm_suspend_all_displays(struct drm_device *ddev)
 {
-	struct omap_dss_device *dssdev = NULL;
+	struct omap_drm_private *priv = ddev->dev_private;
+	int i;
+
+	for (i = 0; i < priv->num_dssdevs; i++) {
+		struct omap_dss_device *dssdev = priv->dssdevs[i];
 
-	for_each_dss_dev(dssdev) {
 		if (!dssdev->driver)
 			continue;
 
@@ -664,11 +684,14 @@ static int omap_drm_suspend_all_displays(void)
 	return 0;
 }
 
-static int omap_drm_resume_all_displays(void)
+static int omap_drm_resume_all_displays(struct drm_device *ddev)
 {
-	struct omap_dss_device *dssdev = NULL;
+	struct omap_drm_private *priv = ddev->dev_private;
+	int i;
+
+	for (i = 0; i < priv->num_dssdevs; i++) {
+		struct omap_dss_device *dssdev = priv->dssdevs[i];
 
-	for_each_dss_dev(dssdev) {
 		if (!dssdev->driver)
 			continue;
 
@@ -688,7 +711,7 @@ static int omap_drm_suspend(struct device *dev)
 	drm_kms_helper_poll_disable(drm_dev);
 
 	drm_modeset_lock_all(drm_dev);
-	omap_drm_suspend_all_displays();
+	omap_drm_suspend_all_displays(drm_dev);
 	drm_modeset_unlock_all(drm_dev);
 
 	return 0;
@@ -699,7 +722,7 @@ static int omap_drm_resume(struct device *dev)
 	struct drm_device *drm_dev = dev_get_drvdata(dev);
 
 	drm_modeset_lock_all(drm_dev);
-	omap_drm_resume_all_displays();
+	omap_drm_resume_all_displays(drm_dev);
 	drm_modeset_unlock_all(drm_dev);
 
 	drm_kms_helper_poll_enable(drm_dev);
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h
index ba322c519999..c9e433a91cd0 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.h
+++ b/drivers/gpu/drm/omapdrm/omap_drv.h
@@ -50,6 +50,9 @@ struct omap_drm_private {
 
 	const struct dispc_ops *dispc_ops;
 
+	unsigned int num_dssdevs;
+	struct omap_dss_device *dssdevs[8];
+
 	unsigned int num_crtcs;
 	struct drm_crtc *crtcs[8];
 
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2018-02-12  9:45 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-12  9:44 [PATCH 00/24] drm/omap: misc patches Tomi Valkeinen
2018-02-12  9:44 ` [PATCH 01/24] drm/omap: fix omap_fbdev_free() when omap_fbdev_create() wasn't called Tomi Valkeinen
2018-02-27 11:28   ` Laurent Pinchart
2018-02-27 11:53     ` Tomi Valkeinen
2018-02-12  9:44 ` [PATCH 02/24] drm/omap: cleanup fbdev init/free Tomi Valkeinen
2018-02-27 11:38   ` Laurent Pinchart
2018-02-28  8:49     ` Tomi Valkeinen
2018-02-12  9:44 ` [PATCH 03/24] drm/omap: add HPD support to connector-dvi Tomi Valkeinen
2018-02-27 12:58   ` Laurent Pinchart
2018-02-28  9:00     ` Tomi Valkeinen
     [not found] ` <1518428694-18018-1-git-send-email-tomi.valkeinen-l0cyMroinI0@public.gmane.org>
2018-02-12  9:44   ` [PATCH 04/24] dt-bindings: display: add HPD gpio to DVI connector Tomi Valkeinen
2018-02-19  0:11     ` Rob Herring
2018-02-27 13:01     ` Laurent Pinchart
2018-02-12  9:44 ` [PATCH 05/24] drm/omap: Use devm_kzalloc() to allocate omap_drm_private Tomi Valkeinen
2018-02-27 13:03   ` Laurent Pinchart
2018-02-12  9:44 ` [PATCH 06/24] drm/omap: Allocate drm_device earlier and unref it as last step Tomi Valkeinen
2018-02-27 13:07   ` Laurent Pinchart
2018-02-12  9:44 ` Tomi Valkeinen [this message]
2018-02-27 13:19   ` [PATCH 07/24] drm/omap: Manage the usable omap_dss_device list within omap_drm_private Laurent Pinchart
2018-02-12  9:44 ` [PATCH 08/24] drm/omap: Separate the dssdevs array setup from the connect function Tomi Valkeinen
2018-02-27 13:23   ` Laurent Pinchart
2018-02-12  9:44 ` [PATCH 09/24] drm/omap: Do dss_device (display) ordering in omap_drv.c Tomi Valkeinen
2018-02-27 13:26   ` Laurent Pinchart
2018-02-12  9:44 ` [PATCH 10/24] drm/omap: dss: Remove display ordering from dss/display.c Tomi Valkeinen
2018-02-27 13:30   ` Laurent Pinchart
2018-02-12  9:44 ` [PATCH 11/24] drm/omap: Add kernel parameter to specify the desired display order Tomi Valkeinen
2018-02-27 13:35   ` Laurent Pinchart
2018-02-28  9:16     ` Tomi Valkeinen
2018-02-12  9:44 ` [PATCH 12/24] drm/omap: Init fbdev emulation only when we have displays Tomi Valkeinen
2018-02-27 13:36   ` Laurent Pinchart
2018-02-12  9:44 ` [PATCH 13/24] drm/omap: remove leftover enums Tomi Valkeinen
2018-02-27 13:36   ` Laurent Pinchart
2018-02-12  9:44 ` [PATCH 14/24] drm/omap: dispc: disp_wb_setup to check return code Tomi Valkeinen
2018-02-27 13:38   ` Laurent Pinchart
2018-02-12  9:44 ` [PATCH 15/24] drm/omap: Add pclk setting case when channel is DSS_WB Tomi Valkeinen
2018-02-12  9:44 ` [PATCH 16/24] drm/omap: set WB channel-in in wb_setup() Tomi Valkeinen
2018-02-12  9:44 ` [PATCH 17/24] drm/omap: fix WBDELAYCOUNT for HDMI Tomi Valkeinen
2018-02-12  9:44 ` [PATCH 18/24] drm/omap: fix WBDELAYCOUNT with interlace Tomi Valkeinen
2018-02-12  9:44 ` [PATCH 19/24] drm/omap: fix WB height " Tomi Valkeinen
2018-02-12  9:44 ` [PATCH 20/24] drm/omap: fix scaling limits for WB Tomi Valkeinen
2018-02-12  9:44 ` [PATCH 21/24] drm/omap: add writeback funcs to dispc_ops Tomi Valkeinen
2018-02-12  9:44 ` [PATCH 22/24] drm/omap: fix maximum sizes Tomi Valkeinen
2018-02-27 13:42   ` Laurent Pinchart
2018-02-28  9:10     ` Tomi Valkeinen
2018-02-12  9:44 ` [PATCH 23/24] drm/omap: Allow HDMI audio setup even if we do not have video configured Tomi Valkeinen
2018-02-12  9:44 ` [PATCH 24/24] drm/omap: cleanup color space conversion Tomi Valkeinen
2018-02-27 14:08   ` Laurent Pinchart
2018-02-28 10:09     ` Tomi Valkeinen
2018-02-28 10:13       ` Laurent Pinchart
2018-02-28 10:22         ` Tomi Valkeinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1518428694-18018-8-git-send-email-tomi.valkeinen@ti.com \
    --to=tomi.valkeinen@ti.com \
    --cc=bparrot@ti.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jsarha@ti.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=peter.ujfalusi@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.