From patchwork Fri Jul 29 19:16:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 9252781 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 185436075F for ; Fri, 29 Jul 2016 19:17:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0912928407 for ; Fri, 29 Jul 2016 19:17:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F209F2840A; Fri, 29 Jul 2016 19:17:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9097D28407 for ; Fri, 29 Jul 2016 19:17:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A9C5A6E0C8; Fri, 29 Jul 2016 19:17:26 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qk0-x229.google.com (mail-qk0-x229.google.com [IPv6:2607:f8b0:400d:c09::229]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5588E6E0C8 for ; Fri, 29 Jul 2016 19:17:24 +0000 (UTC) Received: by mail-qk0-x229.google.com with SMTP id x1so99498405qkb.3 for ; Fri, 29 Jul 2016 12:17:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Do+UyA8tqirKMDPc7pLnygLBt4twW45ifF6XPPHdmBg=; b=EGUpAUvm1Zm2ulIZiBNxS8YEAfdmsld81k5A84bovrtQvO5tQoXi4RvoJUsAvqF4eP 0av5W+uKBI+utg8WOIVHiNeOTasJNKFbgk/9QJ9TJUTK83Bt0vHIEpD00LXncVNf2/mS NSCuuhmI9F59teZfZ3cFhYv5UpsgKF3uK6TXE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Do+UyA8tqirKMDPc7pLnygLBt4twW45ifF6XPPHdmBg=; b=f/vPsHo0FdkuaHyo5Xehrf5ZEY/houeo58eXYY1CsRBjLQ4l/9r2Qrhy4veFM+xAUE HwG99fgbTBc7OOb2u9FuaGdY9LptTflW6V+z8lo9f7lQUq687xZcMUs3V6tty3K8aZpY qYaWcR4MPAXukrJq8ltHVDJ02/TD1/9ZUoDJHRZzNGRln1AuJZ3IR3sG7FBqFoMimmzg 20TXHB9qa9+Fv2hIr+90CXE0EYB9JKjb+2h0fAOSfJ3aLZUWuAFisj4cL41WGTwhzVNG OuX7xARaFoJz9aeN/gupuO56uMyxXxWzNef7zFKtNg2II++ZBcK06T3zL71xWsHSD077 E4QQ== X-Gm-Message-State: AEkoouvA4/UpDIZfUA81Ll1bX1Ce2AMsYQDpuH3+rx2IYJdd2wzVMcewTzsEhvv5wxviBmf1 X-Received: by 10.55.67.138 with SMTP id q132mr53490614qka.191.1469819842344; Fri, 29 Jul 2016 12:17:22 -0700 (PDT) Received: from boxwood.roam.corp.google.com (cpe-75-189-128-87.nc.res.rr.com. [75.189.128.87]) by smtp.gmail.com with ESMTPSA id f23sm1374981qke.37.2016.07.29.12.17.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 Jul 2016 12:17:21 -0700 (PDT) From: Sean Paul To: ykk@rock-chips.com Subject: [PATCH] drm/analogix_dp: Ensure the panel is properly prepared/unprepared Date: Fri, 29 Jul 2016 15:16:31 -0400 Message-Id: <1469819791-31860-1-git-send-email-seanpaul@chromium.org> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 In-Reply-To: References: Cc: k.kozlowski@samsung.com, linux-samsung-soc@vger.kernel.org, linux-rockchip@lists.infradead.org, yzq@rock-chips.com, jingoohan1@gmail.com, emil.l.velikov@gmail.com, dianders@chromium.org, dri-devel@lists.freedesktop.org, tfiga@chromium.org, javier@osg.samsung.com, daniel.vetter@ffwll.ch, marcheu@chromium.org, treding@nvidia.com, linux-kernel@vger.kernel.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Instead of just preparing the panel on bind, actually prepare/unprepare during modeset/disable. The panel must be prepared in order to read hpd status, so we need to refcount the prepares in order to ensure we don't accidentally turn the panel off at the wrong time. Signed-off-by: Sean Paul --- Hi Yakir, This is what I was talking about upthread. I've tested it and it seems to be working. What do you think? Sean drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 48 +++++++++++++++++----- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c index 32715da..7b764a4 100644 --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c @@ -960,11 +960,27 @@ enum drm_connector_status analogix_dp_detect(struct drm_connector *connector, bool force) { struct analogix_dp_device *dp = to_dp(connector); + enum drm_connector_status status = connector_status_disconnected; + int ret; - if (analogix_dp_detect_hpd(dp)) - return connector_status_disconnected; + if (dp->plat_data->panel && dp->dpms_mode != DRM_MODE_DPMS_ON) { + ret = drm_panel_prepare(dp->plat_data->panel); + if (ret) { + DRM_ERROR("failed to setup panel (%d)\n", ret); + return connector_status_disconnected; + } + } + + if (!analogix_dp_detect_hpd(dp)) + status = connector_status_connected; + + if (dp->plat_data->panel && dp->dpms_mode != DRM_MODE_DPMS_ON) { + ret = drm_panel_unprepare(dp->plat_data->panel); + if (ret) + DRM_ERROR("failed to setup the panel ret = %d\n", ret); + } - return connector_status_connected; + return status; } static void analogix_dp_connector_destroy(struct drm_connector *connector) @@ -1035,6 +1051,18 @@ static int analogix_dp_bridge_attach(struct drm_bridge *bridge) return 0; } +static void analogix_dp_bridge_pre_enable(struct drm_bridge *bridge) +{ + struct analogix_dp_device *dp = bridge->driver_private; + int ret; + + if (dp->plat_data->panel) { + ret = drm_panel_prepare(dp->plat_data->panel); + if (ret) + DRM_ERROR("failed to setup the panel ret = %d\n", ret); + } +} + static void analogix_dp_bridge_enable(struct drm_bridge *bridge) { struct analogix_dp_device *dp = bridge->driver_private; @@ -1058,6 +1086,7 @@ static void analogix_dp_bridge_enable(struct drm_bridge *bridge) static void analogix_dp_bridge_disable(struct drm_bridge *bridge) { struct analogix_dp_device *dp = bridge->driver_private; + int ret; if (dp->dpms_mode != DRM_MODE_DPMS_ON) return; @@ -1077,6 +1106,10 @@ static void analogix_dp_bridge_disable(struct drm_bridge *bridge) pm_runtime_put_sync(dp->dev); + ret = drm_panel_unprepare(dp->plat_data->panel); + if (ret) + DRM_ERROR("failed to setup the panel ret = %d\n", ret); + dp->dpms_mode = DRM_MODE_DPMS_OFF; } @@ -1165,9 +1198,9 @@ static void analogix_dp_bridge_nop(struct drm_bridge *bridge) } static const struct drm_bridge_funcs analogix_dp_bridge_funcs = { + .pre_enable = analogix_dp_bridge_pre_enable, .enable = analogix_dp_bridge_enable, .disable = analogix_dp_bridge_disable, - .pre_enable = analogix_dp_bridge_nop, .post_disable = analogix_dp_bridge_nop, .mode_set = analogix_dp_bridge_mode_set, .attach = analogix_dp_bridge_attach, @@ -1333,13 +1366,6 @@ int analogix_dp_bind(struct device *dev, struct drm_device *drm_dev, phy_power_on(dp->phy); - if (dp->plat_data->panel) { - if (drm_panel_prepare(dp->plat_data->panel)) { - DRM_ERROR("failed to setup the panel\n"); - return -EBUSY; - } - } - analogix_dp_init_dp(dp); ret = devm_request_threaded_irq(&pdev->dev, dp->irq,