From patchwork Wed Apr 4 23:49:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepak Singh Rawat X-Patchwork-Id: 10323625 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 211E46032A for ; Wed, 4 Apr 2018 23:51:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 122BA29077 for ; Wed, 4 Apr 2018 23:51:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 067212907B; Wed, 4 Apr 2018 23:51:11 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AA3A129077 for ; Wed, 4 Apr 2018 23:51:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E0FDC6E65F; Wed, 4 Apr 2018 23:51:03 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EX13-EDG-OU-002.vmware.com (ex13-edg-ou-002.vmware.com [208.91.0.190]) by gabe.freedesktop.org (Postfix) with ESMTPS id 935366E656 for ; Wed, 4 Apr 2018 23:51:02 +0000 (UTC) Received: from sc9-mailhost2.vmware.com (10.113.161.72) by EX13-EDG-OU-002.vmware.com (10.113.208.156) with Microsoft SMTP Server id 15.0.1156.6; Wed, 4 Apr 2018 16:50:56 -0700 Received: from ubuntu.localdomain (promb-2n-dhcp336.eng.vmware.com [10.20.89.90]) by sc9-mailhost2.vmware.com (Postfix) with ESMTP id 124C8B09B2; Wed, 4 Apr 2018 16:51:02 -0700 (PDT) From: Deepak Rawat To: , , Subject: [RFC 3/3] drm: Add helper to validate damage during modeset_check Date: Wed, 4 Apr 2018 16:49:08 -0700 Message-ID: <1522885748-67122-4-git-send-email-drawat@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522885748-67122-1-git-send-email-drawat@vmware.com> References: <1522885748-67122-1-git-send-email-drawat@vmware.com> MIME-Version: 1.0 Received-SPF: None (EX13-EDG-OU-002.vmware.com: drawat@vmware.com does not designate permitted sender hosts) X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: airlied@linux.ie, linux-kernel@vger.kernel.org, linux-graphics-maintainer@vmware.com, Deepak Rawat , lukasz.spintzyk@displaylink.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP This patch adds a helper which should be called by driver which enable damage (by calling drm_plane_enable_damage_clips) from atomic_check hook. This helper for now set the damage to NULL for the planes on crtc which need full modeset. The driver also need to check for other crtc properties which can affect damage in atomic_check hook, like gamma, ctm, etc. Plane related properties which affect damage can be handled in damage iterator. Signed-off-by: Deepak Rawat --- drivers/gpu/drm/drm_atomic_helper.c | 47 +++++++++++++++++++++++++++++++++++++ include/drm/drm_atomic_helper.h | 2 ++ 2 files changed, 49 insertions(+) diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index 355b514..23f44ab 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -3987,3 +3987,50 @@ drm_atomic_helper_damage_iter_next(struct drm_atomic_helper_damage_iter *iter, return true; } EXPORT_SYMBOL(drm_atomic_helper_damage_iter_next); + +/** + * drm_atomic_helper_check_damage - validate state object for damage changes + * @dev: DRM device + * @state: the driver state object + * + * Check the state object if damage is required or not. In case damage is not + * required e.g. need modeset, the damage blob is set to NULL. + * + * NOTE: This helper is not called by core. Those driver which enable damage + * using drm_plane_enable_damage_clips should call this from their @atomic_check + * hook. + */ +int drm_atomic_helper_check_damage(struct drm_device *dev, + struct drm_atomic_state *state) +{ + struct drm_crtc *crtc; + struct drm_plane *plane; + struct drm_crtc_state *crtc_state; + unsigned plane_mask; + int i; + + for_each_new_crtc_in_state(state, crtc, crtc_state, i) { + if (!drm_atomic_crtc_needs_modeset(crtc_state)) + continue; + + plane_mask = crtc_state->plane_mask; + plane_mask |= crtc->state->plane_mask; + + drm_for_each_plane_mask(plane, dev, plane_mask) { + struct drm_plane_state *plane_state = + drm_atomic_get_plane_state(state, plane); + + if (IS_ERR(plane_state)) + return PTR_ERR(plane_state); + + if (plane_state->damage_clips) { + drm_property_blob_put(plane_state->damage_clips); + plane_state->damage_clips = NULL; + plane_state->num_clips = 0; + } + } + } + + return 0; +} +EXPORT_SYMBOL(drm_atomic_helper_check_damage); diff --git a/include/drm/drm_atomic_helper.h b/include/drm/drm_atomic_helper.h index ebd4b66..b12335c 100644 --- a/include/drm/drm_atomic_helper.h +++ b/include/drm/drm_atomic_helper.h @@ -224,6 +224,8 @@ drm_atomic_helper_damage_iter_init(struct drm_atomic_helper_damage_iter *iter, bool drm_atomic_helper_damage_iter_next(struct drm_atomic_helper_damage_iter *iter, struct drm_rect *rect); +int drm_atomic_helper_check_damage(struct drm_device *dev, + struct drm_atomic_state *state); /** * drm_atomic_crtc_for_each_plane - iterate over planes currently attached to CRTC