Received: by 10.213.65.68 with SMTP id h4csp1315161imn; Wed, 4 Apr 2018 17:07:47 -0700 (PDT) X-Google-Smtp-Source: AIpwx49GnVEtzPO9DyHuZMeKEsrZDNIaORoeA5YAZiklPph7NuTZ3OC7v0DlGe7SoVVF16u3OfjC X-Received: by 2002:a17:902:1007:: with SMTP id b7-v6mr4081236pla.205.1522886867069; Wed, 04 Apr 2018 17:07:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522886867; cv=none; d=google.com; s=arc-20160816; b=YplOMJi5+BQ+5pZ0KTJ/wPwbAOLld7fy6cBYFxhYMgcg7sdThnLDnqmGCEJEz8/Zqa OCgnfKAm8Oe86dnapEVtGeSYRSIC4AUW4/kWp36wc+7IbNEc7Be1+CBldvU6ta4hhgjD QWFkymyxQk0Bg1X/rXuv10mxqgyxaO3fKZvR8FvutCgcDghBJ3bVuvsReCjDNiOn+DNp QqEJC7gzKYXx3ktYzWK6GZu6lkBuTiGxw23tEmTSTj3V4OMtfIJTOM3vDSznNByqRvds bu+xZ/bwN2WsaxsUKb4U3lEConKjBJnQqGVYG8W7INu482M9FhcI2ADSaUv06ipIw7wx 7eug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=nnu0DgtCHBoPZWQ+8KTM59B40yLO5RBJ+1VkIxbxDE0=; b=yJTiW+nplf7+CvdtAeAIewUibMWMOxccbxjdKo1stGVjubIBGybteIv94dxg5pGyZU saa5xAF0M3uQueOa0yCxnmPDCuMsKnn2Mux0S8hwcj1umDAwTXIKha7aYaGoCL2to/D8 0r1JE4V5ZNI2QBltQiJzDhJFbaClPlO32kKDtONeXk0hMWt0tv9Jbn4OlYZ/1pxiMT9J L1sPqLa5Uf9eJMRXfZCMbpGnusnBQdJZesTb8we2UDHLbwvkrJuYnWr5Vs3qEQjemn9n iUGe/hj27vV9vVAUkgNlMMKlkGxB0fIYXUt9BF39+p99G5P/OCXJEDUYbfzXs/fcV9ug aA9Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e21si4902261pfn.177.2018.04.04.17.07.33; Wed, 04 Apr 2018 17:07:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752831AbeDEAGI (ORCPT + 99 others); Wed, 4 Apr 2018 20:06:08 -0400 Received: from ex13-edg-ou-002.vmware.com ([208.91.0.190]:58457 "EHLO EX13-EDG-OU-002.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752794AbeDEAGF (ORCPT ); Wed, 4 Apr 2018 20:06:05 -0400 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: , , CC: , , , , , , , , , , , Deepak Rawat 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 Content-Type: text/plain Received-SPF: None (EX13-EDG-OU-002.vmware.com: drawat@vmware.com does not designate permitted sender hosts) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 -- 2.7.4