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: 9252785 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 E337B6075F for ; Fri, 29 Jul 2016 19:17:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CFC5D283E3 for ; Fri, 29 Jul 2016 19:17:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BF9F028409; Fri, 29 Jul 2016 19:17:49 +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=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 290C0283E3 for ; Fri, 29 Jul 2016 19:17:48 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bTDI2-000738-Bb; Fri, 29 Jul 2016 19:17:46 +0000 Received: from mail-qk0-x22f.google.com ([2607:f8b0:400d:c09::22f]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bTDI0-000703-DU for linux-rockchip@lists.infradead.org; Fri, 29 Jul 2016 19:17:45 +0000 Received: by mail-qk0-x22f.google.com with SMTP id s63so99669283qkb.2 for ; Fri, 29 Jul 2016 12:17:23 -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=d5M6TLJ9/mrQSASWQA04NWURKEi7PHj7LGqRZgoCzYr36cHFeWz2KUbi3Z+1zbHUVT jkw2/oo6YOCHuOIx/Bhz0H3dEvWCGTa++1B0kqhhm1DOcTPhB2s4PPj+GhY1tvPE0mzT KqChgaId7E+vUYIeDJ/E3FEBwcjo91v4zt0wbvB1mYtnmRtCvejYMxDp1xN2H8edIsfX Mqd6JYKAU4OatEfb+4JytglMgPqvnsIhfI29qxA0nrJbC7PJFNkEt3/SxYH3pVRNysP/ oXhZZBPcLTHm8xU1Tln0OUnPwAgsDNF3w4yILD/gmB4aruWl2q5lQLRr8q1R/LAUsEf5 bBBQ== X-Gm-Message-State: AEkooutA6FBam/E8W9mXwdQ2hJSvIY3r3B9Is1AXCscSGEavmF0ps9ITqxFABv5WGVnN5h3y 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: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160729_121744_545286_171DED74 X-CRM114-Status: GOOD ( 14.00 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: k.kozlowski@samsung.com, linux-samsung-soc@vger.kernel.org, heiko@sntech.de, linux-rockchip@lists.infradead.org, yzq@rock-chips.com, jingoohan1@gmail.com, airlied@linux.ie, emil.l.velikov@gmail.com, dianders@chromium.org, dri-devel@lists.freedesktop.org, tfiga@chromium.org, inki.dae@samsung.com, javier@osg.samsung.com, Sean Paul , daniel.vetter@ffwll.ch, marcheu@chromium.org, treding@nvidia.com, linux-kernel@vger.kernel.org MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org 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,