From patchwork Tue Sep 26 14:15:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Carlos Eduardo Gallo Filho X-Patchwork-Id: 13399278 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 3D43BE7E642 for ; Tue, 26 Sep 2023 14:15:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8B50B10E3EE; Tue, 26 Sep 2023 14:15:30 +0000 (UTC) Received: from layka.disroot.org (layka.disroot.org [178.21.23.139]) by gabe.freedesktop.org (Postfix) with ESMTPS id B78CB10E3EA; Tue, 26 Sep 2023 14:15:28 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 794B140C4D; Tue, 26 Sep 2023 16:15:27 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from layka.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FvOUPklXKT65; Tue, 26 Sep 2023 16:15:26 +0200 (CEST) From: Carlos Eduardo Gallo Filho DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1695737726; bh=tbIuZbuKopIN9rP05CY58VoWpUlSsMuL5vfdFRjoxpM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=a4ZM6fteovxSDa1BISnRkCPmIdf/3QyYiEHE1ZddzF9UAME/pSs+cTiv/6DKldDS7 lZyHsBiZCW7AQrcnvhv+a3qzGJz+JwXL5Uijzs7VyZ10HkhiNKCxEpNhEOIU9tYaI5 ouJVuiD1xwE26qUikw4Rv1f1EO76WLKpFqidnIzR4EFiPfjlFffzh2CiDuiLDi57kK i/5/by4HhILlGG7tXzGByTp1eSiKgZx7xB5bJiBPB584B7F+eCxbX8y1xjDAuqSXiA smFic3oehmOv1MqRfixDSKsCptrabssJiCkUJntMCvH/mGjNn1ecECCsqOmUeUHAdD OT8L4xPs2xB7w== To: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH v2 1/2] drm: Remove plane hsub/vsub alignment requirement for core helpers Date: Tue, 26 Sep 2023 11:15:18 -0300 Message-ID: <20230926141519.9315-2-gcarlos@disroot.org> In-Reply-To: <20230926141519.9315-1-gcarlos@disroot.org> References: <20230926141519.9315-1-gcarlos@disroot.org> MIME-Version: 1.0 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: Matt Roper , Tvrtko Ursulin , =?utf-8?q?Andr=C3=A9_Almei?= =?utf-8?q?da?= , Juha-Pekka Heikkila , Tales Aparecida , Carlos Eduardo Gallo Filho , Maxime Ripard , Maira Canal , Thomas Zimmermann , Rodrigo Vivi , Niranjana Vishwanathapura , Arthur Grillo Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The drm_format_info_plane_{height,width} functions was implemented using regular division for the plane size calculation, which cause issues [1][2] when used on contexts where the dimensions are misaligned with relation to the subsampling factors. So, replace the regular division by the DIV_ROUND_UP macro. This allows these functions to be used in more drivers, making further work to bring more core presence on them possible. [1] http://patchwork.freedesktop.org/patch/msgid/20170321181218.10042-3-ville.syrjala@linux.intel.com [2] https://patchwork.freedesktop.org/patch/msgid/20211026225105.2783797-2-imre.deak@intel.com Signed-off-by: Carlos Eduardo Gallo Filho Reviewed-by: André Almeida --- include/drm/drm_fourcc.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/drm/drm_fourcc.h b/include/drm/drm_fourcc.h index 532ae78ca747..ccf91daa4307 100644 --- a/include/drm/drm_fourcc.h +++ b/include/drm/drm_fourcc.h @@ -22,6 +22,7 @@ #ifndef __DRM_FOURCC_H__ #define __DRM_FOURCC_H__ +#include #include #include @@ -279,7 +280,7 @@ int drm_format_info_plane_width(const struct drm_format_info *info, int width, if (plane == 0) return width; - return width / info->hsub; + return DIV_ROUND_UP(width, info->hsub); } /** @@ -301,7 +302,7 @@ int drm_format_info_plane_height(const struct drm_format_info *info, int height, if (plane == 0) return height; - return height / info->vsub; + return DIV_ROUND_UP(height, info->vsub); } const struct drm_format_info *__drm_format_info(u32 format);