From patchwork Fri Nov 13 15:53:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jyri Sarha X-Patchwork-Id: 7612411 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 40917C05CA for ; Fri, 13 Nov 2015 15:53:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 12FA920807 for ; Fri, 13 Nov 2015 15:53:33 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id D21F7207F1 for ; Fri, 13 Nov 2015 15:53:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2D4D06F0CB; Fri, 13 Nov 2015 07:53:31 -0800 (PST) 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 ESMTPS id 976E96F0C8 for ; Fri, 13 Nov 2015 07:53:27 -0800 (PST) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id tADFrMI2004970; Fri, 13 Nov 2015 09:53:22 -0600 Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id tADFrMdX006521; Fri, 13 Nov 2015 09:53:22 -0600 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.3.224.2; Fri, 13 Nov 2015 09:53:22 -0600 Received: from imryr.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id tADFrHJu023368; Fri, 13 Nov 2015 09:53:20 -0600 From: Jyri Sarha To: , Subject: [PATCH RFC v2 1/2] drm/atomic: Track drm_plane's active state Date: Fri, 13 Nov 2015 17:53:14 +0200 Message-ID: <31721575aebfdce64636ab06ffc2a25a30621b61.1447428525.git.jsarha@ti.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: MIME-Version: 1.0 Cc: tomi.valkeinen@ti.com, Jyri Sarha , laurent.pinchart@ideasonboard.com 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.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 Track drm_plane's active state with a new boolean in struct drm_plane_state. The patch replaces drm_atomic_plane_disabling() with drm_atomic_helper_update_plane_state(). In addition to all the same things the drm_atomic_plane_disabling() used to do the new function updates the active-flag and calls atomic_update() or atomic_disable() from the plane's helper funcs as needed. Signed-off-by: Jyri Sarha --- drivers/gpu/drm/drm_atomic_helper.c | 63 ++++++++++++++++++++++++++++--------- drivers/gpu/drm/drm_plane_helper.c | 10 +----- include/drm/drm_atomic_helper.h | 39 ++--------------------- include/drm/drm_crtc.h | 2 ++ 4 files changed, 53 insertions(+), 61 deletions(-) diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index aecb5d6..d03e2ac 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -1197,15 +1197,7 @@ void drm_atomic_helper_commit_planes(struct drm_device *dev, if (!funcs) continue; - /* - * Special-case disabling the plane if drivers support it. - */ - if (drm_atomic_plane_disabling(plane, old_plane_state) && - funcs->atomic_disable) - funcs->atomic_disable(plane, old_plane_state); - else if (plane->state->crtc || - drm_atomic_plane_disabling(plane, old_plane_state)) - funcs->atomic_update(plane, old_plane_state); + drm_atomic_helper_update_plane_state(plane, old_plane_state); } for_each_crtc_in_state(old_state, crtc, old_crtc_state, i) { @@ -1266,12 +1258,7 @@ drm_atomic_helper_commit_planes_on_crtc(struct drm_crtc_state *old_crtc_state) WARN_ON(plane->state->crtc && plane->state->crtc != crtc); - if (drm_atomic_plane_disabling(plane, old_plane_state) && - plane_funcs->atomic_disable) - plane_funcs->atomic_disable(plane, old_plane_state); - else if (plane->state->crtc || - drm_atomic_plane_disabling(plane, old_plane_state)) - plane_funcs->atomic_update(plane, old_plane_state); + drm_atomic_helper_update_plane_state(plane, old_plane_state); } if (crtc_funcs && crtc_funcs->atomic_flush) @@ -1279,6 +1266,52 @@ drm_atomic_helper_commit_planes_on_crtc(struct drm_crtc_state *old_crtc_state) } EXPORT_SYMBOL(drm_atomic_helper_commit_planes_on_crtc); +/* + * drm_atomic_helper_update_plane_state - update plane's atomic state + * @plane: plane object + * @old_state: previous atomic state + * + * Update plane's atomic state, disables it if that is required, and + * updates drm_palnes_state's active-flag. This also WARNs if it + * detects an invalid state (both CRTC and FB need to either both be + * NULL or both be non-NULL). + */ +void drm_atomic_helper_update_plane_state(struct drm_plane *plane, + struct drm_plane_state *old_state) +{ + const struct drm_plane_helper_funcs *funcs = plane->helper_private; + + /* + * When disabling a plane, CRTC and FB should always be NULL together. + * Anything else should be considered a bug in the atomic core, so we + * gently warn about it. + */ + WARN_ON((plane->state->crtc == NULL && plane->state->fb != NULL) || + (plane->state->crtc != NULL && plane->state->fb == NULL)); + + if (!funcs) + return; + + /* + * The plane needs to be active only if it has an associated CRTC + * and the CRTC is active. Use atomic_disable() if available. + */ + if (plane->state->active) { + if (!plane->state->crtc || !plane->state->crtc->state->active) { + plane->state->active = false; + if (funcs->atomic_disable) { + funcs->atomic_disable(plane, old_state); + return; + } + } + funcs->atomic_update(plane, old_state); + } else if (plane->state->crtc && plane->state->crtc->state->active) { + plane->state->active = true; + funcs->atomic_update(plane, old_state); + } +} +EXPORT_SYMBOL(drm_atomic_helper_update_plane_state); + /** * drm_atomic_helper_cleanup_planes - cleanup plane resources after commit * @dev: DRM device diff --git a/drivers/gpu/drm/drm_plane_helper.c b/drivers/gpu/drm/drm_plane_helper.c index 5e5a07a..93052de 100644 --- a/drivers/gpu/drm/drm_plane_helper.c +++ b/drivers/gpu/drm/drm_plane_helper.c @@ -440,15 +440,7 @@ int drm_plane_helper_commit(struct drm_plane *plane, crtc_funcs[i]->atomic_begin(crtc[i], crtc[i]->state); } - /* - * Drivers may optionally implement the ->atomic_disable callback, so - * special-case that here. - */ - if (drm_atomic_plane_disabling(plane, plane_state) && - plane_funcs->atomic_disable) - plane_funcs->atomic_disable(plane, plane_state); - else - plane_funcs->atomic_update(plane, plane_state); + drm_atomic_helper_update_plane_state(plane, plane_state); for (i = 0; i < 2; i++) { if (crtc_funcs[i] && crtc_funcs[i]->atomic_flush) diff --git a/include/drm/drm_atomic_helper.h b/include/drm/drm_atomic_helper.h index 11266d14..2fbdf5e 100644 --- a/include/drm/drm_atomic_helper.h +++ b/include/drm/drm_atomic_helper.h @@ -59,6 +59,8 @@ void drm_atomic_helper_commit_planes(struct drm_device *dev, void drm_atomic_helper_cleanup_planes(struct drm_device *dev, struct drm_atomic_state *old_state); void drm_atomic_helper_commit_planes_on_crtc(struct drm_crtc_state *old_crtc_state); +void drm_atomic_helper_update_plane_state(struct drm_plane *plane, + struct drm_plane_state *old_state); void drm_atomic_helper_swap_state(struct drm_device *dev, struct drm_atomic_state *state); @@ -148,41 +150,4 @@ void drm_atomic_helper_connector_destroy_state(struct drm_connector *connector, #define drm_atomic_crtc_state_for_each_plane(plane, crtc_state) \ drm_for_each_plane_mask(plane, (crtc_state)->state->dev, (crtc_state)->plane_mask) -/* - * drm_atomic_plane_disabling - check whether a plane is being disabled - * @plane: plane object - * @old_state: previous atomic state - * - * Checks the atomic state of a plane to determine whether it's being disabled - * or not. This also WARNs if it detects an invalid state (both CRTC and FB - * need to either both be NULL or both be non-NULL). - * - * RETURNS: - * True if the plane is being disabled, false otherwise. - */ -static inline bool -drm_atomic_plane_disabling(struct drm_plane *plane, - struct drm_plane_state *old_state) -{ - /* - * When disabling a plane, CRTC and FB should always be NULL together. - * Anything else should be considered a bug in the atomic core, so we - * gently warn about it. - */ - WARN_ON((plane->state->crtc == NULL && plane->state->fb != NULL) || - (plane->state->crtc != NULL && plane->state->fb == NULL)); - - /* - * When using the transitional helpers, old_state may be NULL. If so, - * we know nothing about the current state and have to assume that it - * might be enabled. - * - * When using the atomic helpers, old_state won't be NULL. Therefore - * this check assumes that either the driver will have reconstructed - * the correct state in ->reset() or that the driver will have taken - * appropriate measures to disable all planes. - */ - return (!old_state || old_state->crtc) && !plane->state->crtc; -} - #endif /* DRM_ATOMIC_HELPER_H_ */ diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index faaeff7..c5ee6b6 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -768,6 +768,8 @@ struct drm_connector { struct drm_plane_state { struct drm_plane *plane; + bool active; + struct drm_crtc *crtc; /* do not write directly, use drm_atomic_set_crtc_for_plane() */ struct drm_framebuffer *fb; /* do not write directly, use drm_atomic_set_fb_for_plane() */ struct fence *fence;