From patchwork Fri Jul 15 13:49:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Hogander, Jouni" X-Patchwork-Id: 12920168 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5FD5DC43334 for ; Sat, 16 Jul 2022 14:38:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 49FEA10F69F; Sat, 16 Jul 2022 14:35:46 +0000 (UTC) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5DFB010E06A; Fri, 15 Jul 2022 14:54:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1657896876; x=1689432876; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OBfw+UlmtJJMv35/qjMNnUIU3qBMu/p7R1cPRZRAiTE=; b=PyyS1keVJy74AxmQfealFciKWeMgYIiG4RFEsvMdVxrEPOj8Owq7MkF9 MJq6Pi+WPmWP9lO99KJ9iQEv7zMwvPNl2PYPvWbMQJb0XMZZ/kP0Iokt4 Axkwz3+nH0P6ybVFn9+VJLURbSdywixKJxyaaW2QIuaMoplisMR8mmc5w ix14EJxHDbf6F3TN74J7/Zllj1PJBekhYpEbkwqgVs2r+SoYT9HTSTB6I zC7FyittZ906pHxqgQogbHahIIt/+G1Q7rpeShzEj51BZswqaIVbgRCZO hB6XFHIuc+e+byb9JhGhkGUkMrTO5KWKdYRCCv1lA7bZKfC0D968hh7f8 g==; X-IronPort-AV: E=McAfee;i="6400,9594,10408"; a="284558032" X-IronPort-AV: E=Sophos;i="5.92,274,1650956400"; d="scan'208";a="284558032" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jul 2022 06:51:22 -0700 X-IronPort-AV: E=Sophos;i="5.92,274,1650956400"; d="scan'208";a="654340387" Received: from jgrajkow-mobl1.ger.corp.intel.com (HELO jhogande-mobl1.ger.corp.intel.com) ([10.252.38.223]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jul 2022 06:51:21 -0700 From: =?utf-8?q?Jouni_H=C3=B6gander?= To: dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Subject: [PATCH 1/3] drm: Use original src rect while initializing damage iterator Date: Fri, 15 Jul 2022 16:49:56 +0300 Message-Id: <20220715134958.2605746-2-jouni.hogander@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220715134958.2605746-1-jouni.hogander@intel.com> References: <20220715134958.2605746-1-jouni.hogander@intel.com> MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Jouni_H=C3=B6gander?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" drm_plane_state->src might be modified by the driver. This is done e.g. in i915 driver when there is bigger framebuffer than the plane and there is some offset within framebuffer. I915 driver calculates separate offset and adjusts src rect coords to be relative to this offset. Damage clips are still relative to original src coords provided by user-space. This patch ensures original coordinates provided by user-space are used when initiliazing damage iterator. Signed-off-by: Jouni Högander --- drivers/gpu/drm/drm_damage_helper.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/drm_damage_helper.c b/drivers/gpu/drm/drm_damage_helper.c index 937b699ac2a8..d8b2955e88fd 100644 --- a/drivers/gpu/drm/drm_damage_helper.c +++ b/drivers/gpu/drm/drm_damage_helper.c @@ -224,6 +224,7 @@ drm_atomic_helper_damage_iter_init(struct drm_atomic_helper_damage_iter *iter, const struct drm_plane_state *old_state, const struct drm_plane_state *state) { + struct drm_rect src; memset(iter, 0, sizeof(*iter)); if (!state || !state->crtc || !state->fb || !state->visible) @@ -233,10 +234,12 @@ drm_atomic_helper_damage_iter_init(struct drm_atomic_helper_damage_iter *iter, iter->num_clips = drm_plane_get_damage_clips_count(state); /* Round down for x1/y1 and round up for x2/y2 to catch all pixels */ - iter->plane_src.x1 = state->src.x1 >> 16; - iter->plane_src.y1 = state->src.y1 >> 16; - iter->plane_src.x2 = (state->src.x2 >> 16) + !!(state->src.x2 & 0xFFFF); - iter->plane_src.y2 = (state->src.y2 >> 16) + !!(state->src.y2 & 0xFFFF); + src = drm_plane_state_src(state); + + iter->plane_src.x1 = src.x1 >> 16; + iter->plane_src.y1 = src.y1 >> 16; + iter->plane_src.x2 = (src.x2 >> 16) + !!(src.x2 & 0xFFFF); + iter->plane_src.y2 = (src.y2 >> 16) + !!(src.y2 & 0xFFFF); if (!iter->clips || !drm_rect_equals(&state->src, &old_state->src)) { iter->clips = NULL; From patchwork Fri Jul 15 13:49:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Hogander, Jouni" X-Patchwork-Id: 12920152 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 258F2C433EF for ; Sat, 16 Jul 2022 14:37:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4789210F14A; Sat, 16 Jul 2022 14:35:32 +0000 (UTC) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7F5C610E0E5; Fri, 15 Jul 2022 14:54:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1657896876; x=1689432876; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xEAZ1QrS7CYRtuSAExgb4qsvuEfijpRJbgL7cKUZyWo=; b=HKCKqyuYdPDwghD/Yfpos6puuXiSK49nw+8sy/qT3FkcgAXy39Ja83Hn hUhQmwveRzzqT2k3d4aRcYJvw4taihm6xfF+o7zhZgeCNDVDL3Y81SA/r 74JZtSlZQ02dORJ4Pg9cy5n0j+25naQfStqPIuWUXdQpFslSwoYQUscYE htwLYj0RqavXKvGZqoXq/su/BWIrSbF6Nty+VDm7IVitDJTrW2XkyKv2j 2LHH6+v2oVOoZv2MHAZK6VB7OkoCdcKtAdF7kui+Al9XSazphPa9IiqTV x0RDFrZ5iN6jUF//cRXWd5p6u8zV51HyrUHLdbEn+nJdJDXxX0A6hDtfm g==; X-IronPort-AV: E=McAfee;i="6400,9594,10408"; a="284558043" X-IronPort-AV: E=Sophos;i="5.92,274,1650956400"; d="scan'208";a="284558043" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jul 2022 06:51:25 -0700 X-IronPort-AV: E=Sophos;i="5.92,274,1650956400"; d="scan'208";a="654340392" Received: from jgrajkow-mobl1.ger.corp.intel.com (HELO jhogande-mobl1.ger.corp.intel.com) ([10.252.38.223]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jul 2022 06:51:24 -0700 From: =?utf-8?q?Jouni_H=C3=B6gander?= To: dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Subject: [PATCH 2/3] drm/i915/display: Use original src in psr2 sel fetch area calculation Date: Fri, 15 Jul 2022 16:49:57 +0300 Message-Id: <20220715134958.2605746-3-jouni.hogander@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220715134958.2605746-1-jouni.hogander@intel.com> References: <20220715134958.2605746-1-jouni.hogander@intel.com> MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Jouni_H=C3=B6gander?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" drm_plane_state->src is modified when offset is calculated: before calculation: src.x1 = 8192, src.y1 = 8192 after calculation (pitch = 65536, cpp = 4, alignment = 262144) src.x1 = 8192, src.y1 = 0, offset = 0x20000000 Damage clips are relative to original coodrdinates provided by user-space. To compare these against src coordinates we need to use original coordinates as provided by user-space. These can be obtained by using drm_plane_state_src. Signed-off-by: Jouni Högander --- drivers/gpu/drm/i915/display/intel_psr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/display/intel_psr.c b/drivers/gpu/drm/i915/display/intel_psr.c index 90599dd1cb1b..5c95e24dc8d6 100644 --- a/drivers/gpu/drm/i915/display/intel_psr.c +++ b/drivers/gpu/drm/i915/display/intel_psr.c @@ -1767,7 +1767,8 @@ int intel_psr2_sel_fetch_update(struct intel_atomic_state *state, continue; } - drm_rect_fp_to_int(&src, &new_plane_state->uapi.src); + src = drm_plane_state_src(&new_plane_state->uapi); + drm_rect_fp_to_int(&src, &src); drm_atomic_helper_damage_iter_init(&iter, &old_plane_state->uapi, From patchwork Fri Jul 15 13:49:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Hogander, Jouni" X-Patchwork-Id: 12920151 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B9CD2C433EF for ; Sat, 16 Jul 2022 14:37:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 26F9D10EF61; Sat, 16 Jul 2022 14:35:29 +0000 (UTC) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 20CD410E06A; Fri, 15 Jul 2022 14:54:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1657896879; x=1689432879; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Tfm7fLXko0VFkVs2FaNKlVY+3KA6M9MeYDvTEl20a1g=; b=Skeit//PV/pRG9GOpW7UwqmLu/DphiHIGC9y4S+/7LfvDOjh9YF7Vbx5 pryMAyRd5A9IqLkOWVZbs55w2DnEr2SndoDAdhU65K5hk0b2RjMKRwHXh ZiT7Gwf9I2TXFKbXFx/kJJ04WPhr2dwGRKRNCLdnjwVk/cBXqPZXGyA15 jQNixJbOte4W6AQ6QVI6bCQYn90lnTrgKRLdfuPvYJIhi9VmmZDaXxfTO LEn14oTKt7lS4lR0fCsVbZSyBCH4sCti5kFZNSUM7gF/YKmZOzarB43VW w6EXVN0kpUwv40HIG0vnyyumKJZLOuC8LxJhM8MWwr19fPC+IlYP4c71r w==; X-IronPort-AV: E=McAfee;i="6400,9594,10408"; a="284558051" X-IronPort-AV: E=Sophos;i="5.92,274,1650956400"; d="scan'208";a="284558051" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jul 2022 06:51:28 -0700 X-IronPort-AV: E=Sophos;i="5.92,274,1650956400"; d="scan'208";a="654340400" Received: from jgrajkow-mobl1.ger.corp.intel.com (HELO jhogande-mobl1.ger.corp.intel.com) ([10.252.38.223]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jul 2022 06:51:26 -0700 From: =?utf-8?q?Jouni_H=C3=B6gander?= To: dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Subject: [PATCH 3/3] drm/i915/display: Use drm helper instead of own loop for damage clips Date: Fri, 15 Jul 2022 16:49:58 +0300 Message-Id: <20220715134958.2605746-4-jouni.hogander@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220715134958.2605746-1-jouni.hogander@intel.com> References: <20220715134958.2605746-1-jouni.hogander@intel.com> MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Jouni_H=C3=B6gander?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Use existing drm_atomic_helper_damage_merged from generic drm code instead of implementing own loop to iterate over damage_clips. Signed-off-by: Jouni Högander --- drivers/gpu/drm/i915/display/intel_psr.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_psr.c b/drivers/gpu/drm/i915/display/intel_psr.c index 5c95e24dc8d6..d44662f19b53 100644 --- a/drivers/gpu/drm/i915/display/intel_psr.c +++ b/drivers/gpu/drm/i915/display/intel_psr.c @@ -1721,8 +1721,6 @@ int intel_psr2_sel_fetch_update(struct intel_atomic_state *state, new_plane_state, i) { struct drm_rect src, damaged_area = { .x1 = 0, .y1 = -1, .x2 = INT_MAX }; - struct drm_atomic_helper_damage_iter iter; - struct drm_rect clip; if (new_plane_state->uapi.crtc != crtc_state->uapi.crtc) continue; @@ -1770,20 +1768,15 @@ int intel_psr2_sel_fetch_update(struct intel_atomic_state *state, src = drm_plane_state_src(&new_plane_state->uapi); drm_rect_fp_to_int(&src, &src); - drm_atomic_helper_damage_iter_init(&iter, - &old_plane_state->uapi, - &new_plane_state->uapi); - drm_atomic_for_each_plane_damage(&iter, &clip) { - if (drm_rect_intersect(&clip, &src)) - clip_area_update(&damaged_area, &clip, - &crtc_state->pipe_src); - } - - if (damaged_area.y1 == -1) + if (!drm_atomic_helper_damage_merged(&old_plane_state->uapi, + &new_plane_state->uapi, &damaged_area)) continue; damaged_area.y1 += new_plane_state->uapi.dst.y1 - src.y1; damaged_area.y2 += new_plane_state->uapi.dst.y1 - src.y1; + damaged_area.x1 += new_plane_state->uapi.dst.x1 - src.x1; + damaged_area.x2 += new_plane_state->uapi.dst.x1 - src.x1; + clip_area_update(&pipe_clip, &damaged_area, &crtc_state->pipe_src); }