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: 9252779 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 545BC6075F for ; Fri, 29 Jul 2016 19:17:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 43AB2283E3 for ; Fri, 29 Jul 2016 19:17:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3828E28409; Fri, 29 Jul 2016 19:17:27 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BAF10283E3 for ; Fri, 29 Jul 2016 19:17:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752505AbcG2TRY (ORCPT ); Fri, 29 Jul 2016 15:17:24 -0400 Received: from mail-qk0-f174.google.com ([209.85.220.174]:33951 "EHLO mail-qk0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752439AbcG2TRX (ORCPT ); Fri, 29 Jul 2016 15:17:23 -0400 Received: by mail-qk0-f174.google.com with SMTP id o67so99513921qke.1 for ; Fri, 29 Jul 2016 12:17:22 -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=lKyp3Gak9FRhjJPwR+LWJeejPGkBqTAcwbGAYwv9YG6UEjpObsw6dBlOwjYM1dNixV hJ5JwXY5bqIp6Yw5NPmPN0uCqrMC8drIY4j3MpCONhqbcenVSRV6wnL1ihYwdgMroW8W 72YP8EQzt6zE78EOU+bL3+j6y7hagZBf36VMTT9wInMiF/e94I7cDE5rLq8RwBFyJFrt pFq1MSRpuCFD0k+SIZ1HoomXTzXqvqvcKJqn1XgvYpYSxrhamIrtaAhwa9Xkh2Q99Zye yjjXfnZxJorCDT3V4Q+EIaPhHgCFsla/VDWRXbXCgaoZqdBZ6t169dtVPLi5rTblSutm 4D1A== X-Gm-Message-State: AEkoouuydvBNtTgmQRr/5EKwR0QC7mF35+udqXbLAnMMc6ahNdBeg5+S7yDCD3/VWYi7IFj1 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 Cc: yzq@rock-chips.com, inki.dae@samsung.com, treding@nvidia.com, heiko@sntech.de, jingoohan1@gmail.com, javier@osg.samsung.com, marcheu@chromium.org, tfiga@chromium.org, dianders@chromium.org, airlied@linux.ie, daniel.vetter@ffwll.ch, k.kozlowski@samsung.com, emil.l.velikov@gmail.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-rockchip@lists.infradead.org, Sean Paul 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: Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.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,