From patchwork Fri Mar 10 04:32:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 9615063 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 768B160415 for ; Fri, 10 Mar 2017 05:26:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 67AE4285B6 for ; Fri, 10 Mar 2017 05:26:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C8E2286E3; Fri, 10 Mar 2017 05:26:05 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4D3BD286E5 for ; Fri, 10 Mar 2017 05:26:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=BKHA9HiAO0n7rkSswh0CCLR8+st5fapOkn2jMhvomAk=; b=aZ3rf23EyjBHfustRtquiUAORF 2KXuPSjJ8cJ66l5bi1DcfDkhD3hlZx83E0Nl7h2T80jtUt34W6M+o42CuDMKkNqGIoVAYutdlZVK8 1FyWQETVLFAMdYm3yKaXlQ9Iv2oa6rja+1nCW85u43hMETbHxYaEruiY+GFvmjm9VzRMFd8HBPl2U 3GATJbBQWHk52Fyj5rS0xJOmMev9OJReH5vKPAcW6NGhW3yE8NEFkfLXBVJCZqvpXZ2f7Ml8EuIIo yjq8asoudj6pBwm1vMCugyHYFExixvzG39/RSrC7tZTWsmZ0l8u8alCXWEXTD5OaIrgsy59v7xCFw wpyrUIdg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cmD3y-0001K8-JX; Fri, 10 Mar 2017 05:26:02 +0000 Received: from mail-qk0-x233.google.com ([2607:f8b0:400d:c09::233]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cmCN8-0004c6-0o for linux-rockchip@lists.infradead.org; Fri, 10 Mar 2017 04:41:50 +0000 Received: by mail-qk0-x233.google.com with SMTP id p64so152358414qke.1 for ; Thu, 09 Mar 2017 20:41:25 -0800 (PST) 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=+Ps/V/8lQxUgA4M8H10UKEp+Xi8f9OejsKFMnnZtZ7M=; b=iFlotXa4KZSH8Y7SaR5HDz5jwBvB7LY7g/9XYZGgohjDAM+GkAvSrWQmFAhnbBtaS9 /BP0GEy+XPQF/6THGHeF+SharchG4AwDWvOcZB85it5qgAFgvPyn5t5y8vyjn4vvfhGL gQAExtgMEOINfeH/Ye2l/pJzt1/518cOxuLE8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+Ps/V/8lQxUgA4M8H10UKEp+Xi8f9OejsKFMnnZtZ7M=; b=SVtcQwP/XVBDxMBxxGEBYLxtKPgYaldGOhywnGl8D0IGOT2832PjzZWpPh/vIsDjB2 XCG5X3txny5JV9bmo9rW7QwF2GGrLw9NKYuf80udSwYDTa8P4OZH+gqffIllNwaF+XMt F9x6Pxq/25IOOnc3GupFiJxVqriMClfT4FYtbp+/xrH89YL8hjKHvJU9kQEQHFClfkpe KxbDdBwtPbn+F+54NrjDW0cWuhdLoblR+PCfg7Y3dQxDJGtgdI+6nKO7bdGi47cDRP+Y WtQj0Dpoba76gwQZzb3F95IR4vQHVw+YMmAtjixy6mL4+E4NyoVbQxLDDL2z1fOaTpqm zs7w== X-Gm-Message-State: AMke39lHGmOJs60ovQ/Me4heb5S6c6WksFb+JaURvFoUMbrpXRt90ZSntoaDZzGu6YlHYrCy X-Received: by 10.55.46.198 with SMTP id u189mr17036610qkh.88.1489120884970; Thu, 09 Mar 2017 20:41:24 -0800 (PST) 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 n19sm5697731qtn.35.2017.03.09.20.41.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 09 Mar 2017 20:41:24 -0800 (PST) From: Sean Paul To: linux-rockchip@lists.infradead.org, dri-devel@lists.freedesktop.org Subject: [PATCH 33/41] drm/rockchip: Disable VOP windows when PSR is active Date: Thu, 9 Mar 2017 23:32:48 -0500 Message-Id: <20170310043305.17216-34-seanpaul@chromium.org> X-Mailer: git-send-email 2.12.0.246.ga2ecc84866-goog In-Reply-To: <20170310043305.17216-1-seanpaul@chromium.org> References: <20170310043305.17216-1-seanpaul@chromium.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170309_204146_266046_A92DC223 X-CRM114-Status: GOOD ( 15.36 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: zain wang , Heiko Stuebner , David Airlie , Douglas Anderson , Tomasz Figa , Sean Paul , "Kristian H . Kristensen" , linux-arm-kernel@lists.infradead.org, Mark Yao 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 From: zain wang We do not have to drive the display when it is in PSR mode, so we can save some power by disabling active VOP windows, until a next PSR flush turns them back on. Cc: Kristian H. Kristensen Signed-off-by: zain wang Signed-off-by: Tomasz Figa Signed-off-by: Douglas Anderson Signed-off-by: Sean Paul --- drivers/gpu/drm/rockchip/analogix_dp-rockchip.c | 34 +++++++++++++++++-------- drivers/gpu/drm/rockchip/rockchip_drm_drv.h | 1 + drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 31 ++++++++++++++++++++++ 3 files changed, 55 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c index 0614d32c5435..de23cc6fd05d 100644 --- a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c +++ b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c @@ -91,19 +91,31 @@ static int analogix_dp_psr_set(struct drm_encoder *encoder, bool enabled) if (!crtc) return -EINVAL; - vact_end = crtc->mode.vtotal - crtc->mode.vsync_start + crtc->mode.vdisplay; + if (enabled) { + vact_end = crtc->mode.vtotal - crtc->mode.vsync_start + + crtc->mode.vdisplay; + ret = rockchip_drm_wait_line_flag(dp->encoder.crtc, vact_end, + PSR_WAIT_LINE_FLAG_TIMEOUT_MS); + if (ret) { + dev_err(dp->dev, "line flag interrupt did not arrive\n"); + return -ETIMEDOUT; + } - ret = rockchip_drm_wait_line_flag(dp->encoder.crtc, vact_end, - PSR_WAIT_LINE_FLAG_TIMEOUT_MS); - if (ret) { - dev_err(dp->dev, "line flag interrupt did not arrive\n"); - return -ETIMEDOUT; + ret = analogix_dp_enable_psr(dp->dev); + if (ret) { + dev_err(dp->dev, "failed to enable psr %d\n", ret); + return ret; + } + rockchip_drm_set_win_enabled(crtc, false); + } else { + rockchip_drm_set_win_enabled(crtc, true); + ret = analogix_dp_disable_psr(dp->dev); + if (ret) { + dev_err(dp->dev, "failed to disable psr %d\n", ret); + return ret; + } } - - if (enabled) - return analogix_dp_enable_psr(dp->dev); - else - return analogix_dp_disable_psr(dp->dev); + return 0; } static int rockchip_dp_pre_init(struct rockchip_dp_device *dp) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h index a966d1d37378..be4ad9b670cf 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h @@ -65,5 +65,6 @@ void rockchip_drm_dma_detach_device(struct drm_device *drm_dev, struct device *dev); int rockchip_drm_wait_line_flag(struct drm_crtc *crtc, unsigned int line_num, unsigned int mstimeout); +void rockchip_drm_set_win_enabled(struct drm_crtc *ctrc, bool enabled); #endif /* _ROCKCHIP_DRM_DRV_H_ */ diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c index 879efc3a6c67..e90a32ee5a36 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c @@ -89,6 +89,9 @@ #define VOP_WIN_GET_YRGBADDR(vop, win) \ vop_readl(vop, win->base + win->phy->yrgb_mst.offset) +#define VOP_WIN_TO_INDEX(vop_win) \ + ((vop_win) - (vop_win)->vop->win) + #define to_vop(x) container_of(x, struct vop, crtc) #define to_vop_win(x) container_of(x, struct vop_win, base) @@ -108,6 +111,8 @@ struct vop { struct drm_device *drm_dev; bool is_enabled; + unsigned int win_enabled; + struct completion dsp_hold_completion; /* protected by dev->event_lock */ @@ -562,6 +567,27 @@ static int vop_enable(struct drm_crtc *crtc) return ret; } +void rockchip_drm_set_win_enabled(struct drm_crtc *crtc, bool enabled) +{ + struct vop *vop = to_vop(crtc); + int i; + + spin_lock(&vop->reg_lock); + + for (i = 0; i < vop->data->win_size; i++) { + struct vop_win *vop_win = &vop->win[i]; + const struct vop_win_data *win = vop_win->data; + + VOP_WIN_SET(vop, win, enable, + enabled && (vop->win_enabled & BIT(i))); + } + + vop_cfg_done(vop); + + spin_unlock(&vop->reg_lock); +} +EXPORT_SYMBOL(rockchip_drm_set_win_enabled); + static void vop_crtc_disable(struct drm_crtc *crtc) { struct vop *vop = to_vop(crtc); @@ -581,6 +607,7 @@ static void vop_crtc_disable(struct drm_crtc *crtc) spin_lock(&vop->reg_lock); VOP_WIN_SET(vop, win, enable, 0); + vop->win_enabled &= ~BIT(i); spin_unlock(&vop->reg_lock); } @@ -700,6 +727,7 @@ static void vop_plane_atomic_disable(struct drm_plane *plane, spin_lock(&vop->reg_lock); VOP_WIN_SET(vop, win, enable, 0); + vop->win_enabled &= ~BIT(VOP_WIN_TO_INDEX(vop_win)); spin_unlock(&vop->reg_lock); } @@ -807,6 +835,8 @@ static void vop_plane_atomic_update(struct drm_plane *plane, } VOP_WIN_SET(vop, win, enable, 1); + vop->win_enabled |= BIT(VOP_WIN_TO_INDEX(vop_win)); + spin_unlock(&vop->reg_lock); } @@ -1443,6 +1473,7 @@ static int vop_initial(struct vop *vop) const struct vop_win_data *win = &vop_data->win[i]; VOP_WIN_SET(vop, win, enable, 0); + vop->win_enabled &= ~BIT(i); } vop_cfg_done(vop);