From patchwork Thu Dec 17 21:13:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Souza, Jose" X-Patchwork-Id: 11980793 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 623D7C2BBCD for ; Thu, 17 Dec 2020 21:13:47 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id EF8A723A24 for ; Thu, 17 Dec 2020 21:13:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EF8A723A24 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F3EEC8994D; Thu, 17 Dec 2020 21:13:45 +0000 (UTC) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1623089949; Thu, 17 Dec 2020 21:13:44 +0000 (UTC) IronPort-SDR: jpis0mINRiyS4QkzFs+DCGICmmXxzpkM0NWjl6Veizmbd6FrVkpJpjQjSU0GDBthuhwGqw584C zHsDwEfgQriw== X-IronPort-AV: E=McAfee;i="6000,8403,9838"; a="162380733" X-IronPort-AV: E=Sophos;i="5.78,428,1599548400"; d="scan'208";a="162380733" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Dec 2020 13:13:41 -0800 IronPort-SDR: 215nVJLO1vljE6os2MI4edWA7aCpTgYFT4v6OII+9zV8/rKZsIoDY1EZwKyiPgsBl+XoTWOer4 Ei7FB36u+6zA== X-IronPort-AV: E=Sophos;i="5.78,428,1599548400"; d="scan'208";a="338519151" Received: from vgupta11-mobl.amr.corp.intel.com (HELO josouza-mobl2.intel.com) ([10.255.72.148]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Dec 2020 13:13:38 -0800 From: =?utf-8?q?Jos=C3=A9_Roberto_de_Souza?= To: intel-gfx@lists.freedesktop.org Subject: [PATCH v7 1/5] drm: Add function to convert rect in 16.16 fixed format to regular format Date: Thu, 17 Dec 2020 13:13:56 -0800 Message-Id: <20201217211400.231826-1-jose.souza@intel.com> X-Mailer: git-send-email 2.29.2 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: =?utf-8?q?Jos=C3=A9_Roberto_de_Souza?= , dri-devel@lists.freedesktop.org, Gwan-gyeong Mun Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Much more clear to read one function call than four lines doing this conversion. v7: - function renamed - calculating width and height before truncate - inlined Cc: Ville Syrjälä Cc: dri-devel@lists.freedesktop.org Cc: Gwan-gyeong Mun Signed-off-by: José Roberto de Souza --- include/drm/drm_rect.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/drm/drm_rect.h b/include/drm/drm_rect.h index e7f4d24cdd00..7eb84af4a818 100644 --- a/include/drm/drm_rect.h +++ b/include/drm/drm_rect.h @@ -206,6 +206,19 @@ static inline bool drm_rect_equals(const struct drm_rect *r1, r1->y1 == r2->y1 && r1->y2 == r2->y2; } +/** + * drm_rect_fp_to_int - Convert a rect in 16.16 fixed point form to int form. + * @destination: rect to be stored the converted value + * @source: rect in 16.16 fixed point form + */ +static inline void drm_rect_fp_to_int(struct drm_rect *destination, + const struct drm_rect *source) +{ + drm_rect_init(destination, source->x1 >> 16, source->y1 >> 16, + drm_rect_width(source) >> 16, + drm_rect_height(source) >> 16); +} + bool drm_rect_intersect(struct drm_rect *r, const struct drm_rect *clip); bool drm_rect_clip_scaled(struct drm_rect *src, struct drm_rect *dst, const struct drm_rect *clip);