From patchwork Thu Jun 4 09:02:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 6545961 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 72FFB9F6CE for ; Thu, 4 Jun 2015 11:07:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7628E2077E for ; Thu, 4 Jun 2015 11:07:21 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 90D102070A for ; Thu, 4 Jun 2015 11:07:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AD40F6EB04; Thu, 4 Jun 2015 04:06:50 -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 2559A6EADA for ; Thu, 4 Jun 2015 02:04:01 -0700 (PDT) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id t5493we6011173; Thu, 4 Jun 2015 04:03:58 -0500 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id t5493w4h029576; Thu, 4 Jun 2015 04:03:58 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.224.2; Thu, 4 Jun 2015 04:03:57 -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 t5493YwI014785; Thu, 4 Jun 2015 04:03:57 -0500 From: Tomi Valkeinen To: , Laurent Pinchart Subject: [PATCHv2 16/45] drm: omapdrm: Handle primary plane config through atomic plane ops Date: Thu, 4 Jun 2015 12:02:33 +0300 Message-ID: <1433408582-9828-17-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 Use the new CRTC atomic transitional helpers drm_helper_crtc_mode_set() and drm_helper_crtc_mode_set_base() to implement the CRTC .mode_set and .mode_set_base operations. This delegates primary plane configuration to the plane .atomic_update and .atomic_disable operations, removing duplicate code from the CRTC implementation. Signed-off-by: Laurent Pinchart Signed-off-by: Tomi Valkeinen --- drivers/gpu/drm/omapdrm/omap_crtc.c | 69 +++++++++++++++---------------------- 1 file changed, 27 insertions(+), 42 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c b/drivers/gpu/drm/omapdrm/omap_crtc.c index 277cad1dacf7..31d50533d538 100644 --- a/drivers/gpu/drm/omapdrm/omap_crtc.c +++ b/drivers/gpu/drm/omapdrm/omap_crtc.c @@ -571,42 +571,42 @@ static void omap_crtc_disable(struct drm_crtc *crtc) WARN_ON(omap_plane_set_enable(plane, false)); } + /* + * HACK: Unpin the primary plane frame buffer if we're disabled without + * going through full mode set. + * HACK: The legacy set config helper drm_crtc_helper_set_config() that + * we still use calls the .disable() operation directly when called with + * a NULL frame buffer (for instance from drm_fb_release()). As a result + * the CRTC is disabled without going through a full mode set, and the + * primary plane' framebuffer is kept pin. Unpin it manually here until + * we switch to the atomic set config helper. + */ + if (crtc->primary->fb) { + const struct drm_plane_helper_funcs *funcs; + + funcs = crtc->primary->helper_private; + funcs->cleanup_fb(crtc->primary, crtc->primary->fb, NULL); + } + omap_crtc->enabled = false; omap_crtc_setup(crtc); omap_crtc_flush(crtc); } -static int omap_crtc_mode_set(struct drm_crtc *crtc, - struct drm_display_mode *mode, - struct drm_display_mode *adjusted_mode, - int x, int y, - struct drm_framebuffer *old_fb) +static void omap_crtc_mode_set_nofb(struct drm_crtc *crtc) { struct omap_crtc *omap_crtc = to_omap_crtc(crtc); - - mode = adjusted_mode; + struct drm_display_mode *mode = &crtc->state->adjusted_mode; DBG("%s: set mode: %d:\"%s\" %d %d %d %d %d %d %d %d %d %d 0x%x 0x%x", - omap_crtc->name, mode->base.id, mode->name, - mode->vrefresh, mode->clock, - mode->hdisplay, mode->hsync_start, - mode->hsync_end, mode->htotal, - mode->vdisplay, mode->vsync_start, - mode->vsync_end, mode->vtotal, - mode->type, mode->flags); + omap_crtc->name, mode->base.id, mode->name, + mode->vrefresh, mode->clock, + mode->hdisplay, mode->hsync_start, mode->hsync_end, mode->htotal, + mode->vdisplay, mode->vsync_start, mode->vsync_end, mode->vtotal, + mode->type, mode->flags); copy_timings_drm_to_omap(&omap_crtc->timings, mode); - - /* - * The primary plane CRTC can be reset if the plane is disabled directly - * through the universal plane API. Set it again here. - */ - crtc->primary->crtc = crtc; - - return omap_plane_mode_set(crtc->primary, crtc, crtc->primary->fb, - 0, 0, mode->hdisplay, mode->vdisplay, - x, y, mode->hdisplay, mode->vdisplay); } static void omap_crtc_dpms(struct drm_crtc *crtc, int mode) @@ -636,22 +636,6 @@ static void omap_crtc_commit(struct drm_crtc *crtc) omap_crtc_dpms(crtc, DRM_MODE_DPMS_ON); } -static int omap_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y, - struct drm_framebuffer *old_fb) -{ - struct drm_plane *plane = crtc->primary; - struct drm_display_mode *mode = &crtc->mode; - int ret; - - ret = omap_plane_mode_set(plane, crtc, crtc->primary->fb, - 0, 0, mode->hdisplay, mode->vdisplay, - x, y, mode->hdisplay, mode->vdisplay); - if (ret < 0) - return ret; - - return omap_crtc_flush(crtc); -} - static void omap_crtc_atomic_begin(struct drm_crtc *crtc) { dispc_runtime_get(); @@ -798,10 +782,11 @@ static const struct drm_crtc_funcs omap_crtc_funcs = { static const struct drm_crtc_helper_funcs omap_crtc_helper_funcs = { .dpms = omap_crtc_dpms, .mode_fixup = omap_crtc_mode_fixup, - .mode_set = omap_crtc_mode_set, + .mode_set = drm_helper_crtc_mode_set, .prepare = omap_crtc_prepare, .commit = omap_crtc_commit, - .mode_set_base = omap_crtc_mode_set_base, + .mode_set_nofb = omap_crtc_mode_set_nofb, + .mode_set_base = drm_helper_crtc_mode_set_base, .disable = omap_crtc_disable, .enable = omap_crtc_enable, .atomic_begin = omap_crtc_atomic_begin,