From patchwork Thu Jun 4 09:02:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 6545531 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A049AC0020 for ; Thu, 4 Jun 2015 11:06:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9C1092070A for ; Thu, 4 Jun 2015 11:06:40 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id DFBBC2068E for ; Thu, 4 Jun 2015 11:06:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4E3AC6E11A; Thu, 4 Jun 2015 04:06:35 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from devils.ext.ti.com (devils.ext.ti.com [198.47.26.153]) by gabe.freedesktop.org (Postfix) with ESMTP id DCAD46EAD7 for ; Thu, 4 Jun 2015 02:03:55 -0700 (PDT) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id t5493r1W011156; Thu, 4 Jun 2015 04:03:53 -0500 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id t5493rIe011629; Thu, 4 Jun 2015 04:03:53 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.3.224.2; Thu, 4 Jun 2015 04:03:52 -0500 Received: from deskari.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id t5493YwE014785; Thu, 4 Jun 2015 04:03:51 -0500 From: Tomi Valkeinen To: , Laurent Pinchart Subject: [PATCHv2 12/45] drm: omapdrm: Rework CRTC enable/disable for atomic updates Date: Thu, 4 Jun 2015 12:02:29 +0300 Message-ID: <1433408582-9828-13-git-send-email-tomi.valkeinen@ti.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1433408582-9828-1-git-send-email-tomi.valkeinen@ti.com> References: <1433408582-9828-1-git-send-email-tomi.valkeinen@ti.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 04 Jun 2015 04:06:34 -0700 Cc: Tomi Valkeinen 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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 From: Laurent Pinchart When using atomic updates the CRTC .enable() and .disable() helper operations are preferred over the (then legacy) .prepare() and .commit() operations. Implement .enable() and rework .disable() to not depend on DPMS, easing DPMS removal later on. Signed-off-by: Laurent Pinchart Signed-off-by: Tomi Valkeinen --- drivers/gpu/drm/omapdrm/omap_crtc.c | 83 ++++++++++++++++++++++++++----------- 1 file changed, 59 insertions(+), 24 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c b/drivers/gpu/drm/omapdrm/omap_crtc.c index 94c1bb8448be..0359a67f8f8d 100644 --- a/drivers/gpu/drm/omapdrm/omap_crtc.c +++ b/drivers/gpu/drm/omapdrm/omap_crtc.c @@ -509,50 +509,70 @@ static void omap_crtc_destroy(struct drm_crtc *crtc) kfree(omap_crtc); } -static void omap_crtc_dpms(struct drm_crtc *crtc, int mode) +static bool omap_crtc_mode_fixup(struct drm_crtc *crtc, + const struct drm_display_mode *mode, + struct drm_display_mode *adjusted_mode) +{ + return true; +} + +static void omap_crtc_enable(struct drm_crtc *crtc) { struct omap_drm_private *priv = crtc->dev->dev_private; struct omap_crtc *omap_crtc = to_omap_crtc(crtc); - bool enable = (mode == DRM_MODE_DPMS_ON); - int i; + unsigned int i; - DBG("%s: %d", omap_crtc->name, mode); + DBG("%s", omap_crtc->name); - if (enable == omap_crtc->enabled) + if (omap_crtc->enabled) return; - if (!enable) { - omap_crtc_wait_page_flip(crtc); - dispc_runtime_get(); - drm_crtc_vblank_off(crtc); - dispc_runtime_put(); - } - - /* Enable/disable all planes associated with the CRTC. */ + /* Enable all planes associated with the CRTC. */ for (i = 0; i < priv->num_planes; i++) { struct drm_plane *plane = priv->planes[i]; if (plane->crtc == crtc) - WARN_ON(omap_plane_set_enable(plane, enable)); + WARN_ON(omap_plane_set_enable(plane, true)); } - omap_crtc->enabled = enable; + omap_crtc->enabled = true; omap_crtc_setup(crtc); omap_crtc_flush(crtc); - if (enable) { - dispc_runtime_get(); - drm_crtc_vblank_on(crtc); - dispc_runtime_put(); - } + dispc_runtime_get(); + drm_crtc_vblank_on(crtc); + dispc_runtime_put(); } -static bool omap_crtc_mode_fixup(struct drm_crtc *crtc, - const struct drm_display_mode *mode, - struct drm_display_mode *adjusted_mode) +static void omap_crtc_disable(struct drm_crtc *crtc) { - return true; + struct omap_drm_private *priv = crtc->dev->dev_private; + struct omap_crtc *omap_crtc = to_omap_crtc(crtc); + unsigned int i; + + DBG("%s", omap_crtc->name); + + if (!omap_crtc->enabled) + return; + + omap_crtc_wait_page_flip(crtc); + dispc_runtime_get(); + drm_crtc_vblank_off(crtc); + dispc_runtime_put(); + + /* Disable all planes associated with the CRTC. */ + for (i = 0; i < priv->num_planes; i++) { + struct drm_plane *plane = priv->planes[i]; + + if (plane->crtc == crtc) + WARN_ON(omap_plane_set_enable(plane, false)); + } + + omap_crtc->enabled = false; + + omap_crtc_setup(crtc); + omap_crtc_flush(crtc); } static int omap_crtc_mode_set(struct drm_crtc *crtc, @@ -587,6 +607,19 @@ static int omap_crtc_mode_set(struct drm_crtc *crtc, x, y, mode->hdisplay, mode->vdisplay); } +static void omap_crtc_dpms(struct drm_crtc *crtc, int mode) +{ + struct omap_crtc *omap_crtc = to_omap_crtc(crtc); + bool enable = (mode == DRM_MODE_DPMS_ON); + + DBG("%s: %d", omap_crtc->name, mode); + + if (enable) + omap_crtc_enable(crtc); + else + omap_crtc_disable(crtc); +} + static void omap_crtc_prepare(struct drm_crtc *crtc) { struct omap_crtc *omap_crtc = to_omap_crtc(crtc); @@ -751,6 +784,8 @@ static const struct drm_crtc_helper_funcs omap_crtc_helper_funcs = { .prepare = omap_crtc_prepare, .commit = omap_crtc_commit, .mode_set_base = omap_crtc_mode_set_base, + .disable = omap_crtc_disable, + .enable = omap_crtc_enable, }; /* -----------------------------------------------------------------------------