From patchwork Fri Dec 18 18:46:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Souza, Jose" X-Patchwork-Id: 11982759 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.8 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 B0B55C2D0E4 for ; Fri, 18 Dec 2020 18:46:49 +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 667BE23B08 for ; Fri, 18 Dec 2020 18:46:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 667BE23B08 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 A35BA89DB4; Fri, 18 Dec 2020 18:46:48 +0000 (UTC) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5E34489B9F; Fri, 18 Dec 2020 18:46:47 +0000 (UTC) IronPort-SDR: CgmQpiyiFX8f9Jrq0MDY/hAv1kLI9tlPFAWY1vJW900Q+wevxBqme210E7rFSasNI0NljxBGop PUBZUSjjWhTg== X-IronPort-AV: E=McAfee;i="6000,8403,9839"; a="172919170" X-IronPort-AV: E=Sophos;i="5.78,431,1599548400"; d="scan'208";a="172919170" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Dec 2020 10:46:46 -0800 IronPort-SDR: ftG2Wli8XLagnWGHJivtlemwLMUi4/QL4ayfuDFhyF6MJ5UmETeeDi1A1LTl0C1FJgvSCIs1BC jbFWFP5YLzKQ== X-IronPort-AV: E=Sophos;i="5.78,431,1599548400"; d="scan'208";a="343429148" Received: from svasud1x-mobl3.amr.corp.intel.com (HELO josouza-mobl2.intel.com) ([10.254.182.238]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Dec 2020 10:46:44 -0800 From: =?utf-8?q?Jos=C3=A9_Roberto_de_Souza?= To: intel-gfx@lists.freedesktop.org Subject: [PATCH v9 1/5] drm: Add function to convert rect in 16.16 fixed format to regular format Date: Fri, 18 Dec 2020 10:46:57 -0800 Message-Id: <20201218184701.111857-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 Reviewed-by: Gwan-gyeong Mun --- 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);