From patchwork Wed Dec 10 15:48:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 5470451 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1A5D6BEEA8 for ; Wed, 10 Dec 2014 15:56:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 231B52012B for ; Wed, 10 Dec 2014 15:56:39 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 03DC12011D for ; Wed, 10 Dec 2014 15:56:38 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XyjYO-0004Az-Ml; Wed, 10 Dec 2014 15:51:52 +0000 Received: from mailout3.w1.samsung.com ([210.118.77.13]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XyjWA-0000pN-TE for linux-arm-kernel@lists.infradead.org; Wed, 10 Dec 2014 15:49:36 +0000 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout3.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NGD00GJEISREGA0@mailout3.w1.samsung.com> for linux-arm-kernel@lists.infradead.org; Wed, 10 Dec 2014 15:53:15 +0000 (GMT) X-AuditID: cbfec7f5-b7fc86d0000066b7-a3-54886b7807f9 Received: from eusync1.samsung.com ( [203.254.199.211]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id 1D.30.26295.87B68845; Wed, 10 Dec 2014 15:49:12 +0000 (GMT) Received: from AMDC1061.digital.local ([106.116.147.88]) by eusync1.samsung.com (Oracle Communications Messaging Server 7u4-23.01 (7.0.4.23.0) 64bit (built Aug 10 2011)) with ESMTPA id <0NGD00L5CIL48260@eusync1.samsung.com>; Wed, 10 Dec 2014 15:49:11 +0000 (GMT) From: Andrzej Hajda To: linux-kernel@vger.kernel.org (open list) Subject: [RFC 10/15] drm/exynos/dsi: simplify hotplug code Date: Wed, 10 Dec 2014 16:48:28 +0100 Message-id: <1418226513-14105-11-git-send-email-a.hajda@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1418226513-14105-1-git-send-email-a.hajda@samsung.com> References: <1418226513-14105-1-git-send-email-a.hajda@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrGLMWRmVeSWpSXmKPExsVy+t/xy7oV2R0hBl1rRSxurTvHanHgxUIW i6kPn7BZzD8C5F75+p7N4tyrRywWB/7sYLRoXryezWLS/QksFhee9rBZfLvSwWQx5c9yJotN j6+xWmye/4fR4vKuOWwWM87vY7K4fZnXYu2Ru+wWTydcZLNo3XuE3eLnrnksDqIeLc09bB5P Nl1k9Ng56y67x6ZVnWwed67tYfPYP3cNu8f97uNMHpuX1Hv0bVnF6HH8xnYmj8+b5AK4o7hs UlJzMstSi/TtErgyjp2/zlpwU6nizjzVBsb/Ml2MHBwSAiYSk/dHdzFyApliEhfurWfrYuTi EBJYyigxcWsjM0hCSKCPSWLpazCbTUBT4u/mm2wgtoiAjsT1nm5mkAZmgQ3sEuum7wNLCAtY SbQu+8wOYrMIqEqs/v4OLM4r4CJx6eFDVohtchInj00GszmB4n+f72WEWOYssWTbe9YJjLwL GBlWMYqmliYXFCel5xrpFSfmFpfmpesl5+duYoTExdcdjEuPWR1iFOBgVOLh3aHYFiLEmlhW XJl7iFGCg1lJhHdhckeIEG9KYmVValF+fFFpTmrxIUYmDk6pBsaioqlH5Y4pr+kV7NweNklR eP31kORfDGnvAgSeLo8+bmT0IdrP5WXp/tzE2ypSRytv1Cc1e06eJS7oKPPWWO9w2sfJd788 s90l1+vI/Xhj8F2VKDkBjz+LEpx/20Wel7Zcye11vIzjnGDBPaNZby+u3mzZmi/7fpNN69Lk otAdSz8c6OQ/Kq7EUpyRaKjFXFScCAC3RtjxaQIAAA== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141210_074935_159248_8C640D2E X-CRM114-Status: GOOD ( 14.51 ) X-Spam-Score: -5.0 (-----) Cc: Alexandre Courbot , "moderated list:ARM/S5P EXYNOS AR..." , Mike Turquette , "open list:DRM PANEL DRIVERS" , "open list:GPIO SUBSYSTEM" , Greg Kroah-Hartman , Linus Walleij , Liam Girdwood , Rob Herring , Kishon Vijay Abraham I , Inki Dae , Andrzej Hajda , "open list:OPEN FIRMWARE AND..." , Thierry Reding , boris.brezillon@free-electrons.com, Mark Brown , Grant Likely , Russell King , "moderated list:ARM/CLKDEV SUPPORT" , Marek Szyprowski X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Exynos DSI driver uses DSI bus attach/detach callbacks to implement panel hotplug mechanism. The patch moves panel attachment code from .detect callback to DSI bus callbacks. It makes the code simpler and more straightforward. The patch removes also redundant and lock unprotected dpms_off call from unbind code. Signed-off-by: Andrzej Hajda --- drivers/gpu/drm/exynos/exynos_drm_dsi.c | 61 ++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 23 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c index 05fe93d..8201d79 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c @@ -271,7 +271,6 @@ struct exynos_dsi { struct exynos_drm_display display; struct mipi_dsi_host dsi_host; struct drm_connector connector; - struct device_node *panel_node; struct drm_panel *panel; struct device *dev; @@ -1154,10 +1153,11 @@ static int exynos_dsi_init(struct exynos_dsi *dsi) static int exynos_dsi_register_te_irq(struct exynos_dsi *dsi) { + struct device_node *panel_node = dsi->panel->dev->of_node; int ret; int te_gpio_irq; - dsi->te_gpio = of_get_named_gpio(dsi->panel_node, "te-gpios", 0); + dsi->te_gpio = of_get_named_gpio(panel_node, "te-gpios", 0); if (!gpio_is_valid(dsi->te_gpio)) { dev_err(dsi->dev, "no te-gpios specified\n"); ret = dsi->te_gpio; @@ -1198,11 +1198,25 @@ static int exynos_dsi_host_attach(struct mipi_dsi_host *host, struct mipi_dsi_device *device) { struct exynos_dsi *dsi = host_to_dsi(host); + struct drm_device *drm_dev = dsi->connector.dev; + bool changed = false; dsi->lanes = device->lanes; dsi->format = device->format; dsi->mode_flags = device->mode_flags; - dsi->panel_node = device->dev.of_node; + + mutex_lock(&drm_dev->mode_config.mutex); + + dsi->panel = of_drm_find_panel(device->dev.of_node); + if (dsi->panel) { + drm_panel_attach(dsi->panel, &dsi->connector); + if (drm_dev->mode_config.poll_enabled) { + dsi->connector.status = connector_status_connected; + changed = true; + } + } + + mutex_unlock(&drm_dev->mode_config.mutex); /* * This is a temporary solution and should be made by more generic way. @@ -1217,8 +1231,8 @@ static int exynos_dsi_host_attach(struct mipi_dsi_host *host, return ret; } - if (dsi->connector.dev) - drm_helper_hpd_irq_event(dsi->connector.dev); + if (changed) + drm_kms_helper_hotplug_event(drm_dev); return 0; } @@ -1227,13 +1241,29 @@ static int exynos_dsi_host_detach(struct mipi_dsi_host *host, struct mipi_dsi_device *device) { struct exynos_dsi *dsi = host_to_dsi(host); + struct drm_device *drm_dev = dsi->connector.dev; + struct exynos_drm_display *display = dev_get_drvdata(dsi->dev); + bool changed = false; exynos_dsi_unregister_te_irq(dsi); - dsi->panel_node = NULL; + mutex_lock(&drm_dev->mode_config.mutex); + + display->ops->dpms(display, DRM_MODE_DPMS_OFF); + + if (dsi->panel) { + drm_panel_detach(dsi->panel); + dsi->panel = NULL; + if (drm_dev->mode_config.poll_enabled) { + dsi->connector.status = connector_status_disconnected; + changed = true; + } + } + + mutex_unlock(&drm_dev->mode_config.mutex); - if (dsi->connector.dev) - drm_helper_hpd_irq_event(dsi->connector.dev); + if (changed) + drm_kms_helper_hotplug_event(drm_dev); return 0; } @@ -1430,19 +1460,6 @@ exynos_dsi_detect(struct drm_connector *connector, bool force) { struct exynos_dsi *dsi = connector_to_dsi(connector); - if (!dsi->panel) { - dsi->panel = of_drm_find_panel(dsi->panel_node); - if (dsi->panel) - drm_panel_attach(dsi->panel, &dsi->connector); - } else if (!dsi->panel_node) { - struct exynos_drm_display *display; - - display = platform_get_drvdata(to_platform_device(dsi->dev)); - exynos_dsi_dpms(display, DRM_MODE_DPMS_OFF); - drm_panel_detach(dsi->panel); - dsi->panel = NULL; - } - if (dsi->panel) return connector_status_connected; @@ -1665,8 +1682,6 @@ static void exynos_dsi_unbind(struct device *dev, struct device *master, struct exynos_drm_display *display = dev_get_drvdata(dev); struct exynos_dsi *dsi = display_to_dsi(display); - exynos_dsi_dpms(display, DRM_MODE_DPMS_OFF); - mipi_dsi_host_unregister(&dsi->dsi_host); }