From patchwork Fri Jun 27 14:35:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Jakobi X-Patchwork-Id: 4437821 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C0ED2BEEAA for ; Fri, 27 Jun 2014 20:56:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E85C6203AE for ; Fri, 27 Jun 2014 20:56:23 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id F0C2E203AD for ; Fri, 27 Jun 2014 20:56:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 23CB38A1FA; Fri, 27 Jun 2014 13:56:09 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from smtp.math.uni-bielefeld.de (smtp.math.uni-bielefeld.de [129.70.45.10]) by gabe.freedesktop.org (Postfix) with ESMTP id 741E76E776 for ; Fri, 27 Jun 2014 07:35:47 -0700 (PDT) Received: from chidori.math.uni-bielefeld.de (dhcp24-210.math.uni-bielefeld.de [129.70.24.210]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by smtp.math.uni-bielefeld.de (Postfix) with ESMTPSA id 8AFEE60ECC; Fri, 27 Jun 2014 16:35:46 +0200 (CEST) From: Tobias Jakobi To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/3] exynos: replace G2D_DOUBLE_TO_FIXED macro with documented function Date: Fri, 27 Jun 2014 16:35:23 +0200 Message-Id: <1403879724-7838-2-git-send-email-tjakobi@math.uni-bielefeld.de> X-Mailer: git-send-email 1.8.5.5 In-Reply-To: <1403879724-7838-1-git-send-email-tjakobi@math.uni-bielefeld.de> References: <1403879724-7838-1-git-send-email-tjakobi@math.uni-bielefeld.de> X-Mailman-Approved-At: Fri, 27 Jun 2014 13:56:06 -0700 Cc: Tobias Jakobi , robclark@freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This also avoids the floating point conversion steps and just uses pure integer arithmetic. Also the G2D hardware scaling factor is a bit unintuitive, so explain it in the function. Signed-off-by: Tobias Jakobi --- exynos/exynos_fimg2d.c | 19 ++++++++++++++----- exynos/fimg2d.h | 2 -- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/exynos/exynos_fimg2d.c b/exynos/exynos_fimg2d.c index fc281b6..435a88d 100644 --- a/exynos/exynos_fimg2d.c +++ b/exynos/exynos_fimg2d.c @@ -40,6 +40,15 @@ #define MIN(a, b) ((a) < (b) ? (a) : (b)) +static unsigned int g2d_get_scaling(unsigned int src, unsigned int dst) +{ + /* The G2D hw scaling factor is a normalized inverse of the scaling factor. * + * For example: When source width is 100 and destination width is 200 * + * (scaling of 2x), then the hw factor is NORMALIZE_CONSTANT * 100 / 200. */ + + return ((src << 16) / dst); +} + static unsigned int g2d_get_blend_op(enum e_g2d_op op) { union g2d_blend_func_val val; @@ -424,7 +433,7 @@ int g2d_copy_with_scale(struct g2d_context *ctx, struct g2d_image *src, union g2d_rop4_val rop4; union g2d_point_val pt; unsigned int scale; - double scale_x = 0.0f, scale_y = 0.0f; + unsigned int scale_x, scale_y; g2d_add_cmd(ctx, DST_SELECT_REG, G2D_SELECT_MODE_BGCOLOR); g2d_add_cmd(ctx, DST_COLOR_MODE_REG, dst->color_mode); @@ -450,8 +459,8 @@ int g2d_copy_with_scale(struct g2d_context *ctx, struct g2d_image *src, scale = 0; else { scale = 1; - scale_x = (double)src_w / (double)dst_w; - scale_y = (double)src_h / (double)dst_h; + scale_x = g2d_get_scaling(src_w, dst_w); + scale_y = g2d_get_scaling(src_h, dst_h); } if (src_x + src_w > src->width) @@ -483,8 +492,8 @@ int g2d_copy_with_scale(struct g2d_context *ctx, struct g2d_image *src, if (scale) { g2d_add_cmd(ctx, SRC_SCALE_CTRL_REG, G2D_SCALE_MODE_BILINEAR); - g2d_add_cmd(ctx, SRC_XSCALE_REG, G2D_DOUBLE_TO_FIXED(scale_x)); - g2d_add_cmd(ctx, SRC_YSCALE_REG, G2D_DOUBLE_TO_FIXED(scale_y)); + g2d_add_cmd(ctx, SRC_XSCALE_REG, scale_x); + g2d_add_cmd(ctx, SRC_YSCALE_REG, scale_y); } pt.val = 0; diff --git a/exynos/fimg2d.h b/exynos/fimg2d.h index 4785e2f..8e0321c 100644 --- a/exynos/fimg2d.h +++ b/exynos/fimg2d.h @@ -25,8 +25,6 @@ #define G2D_MAX_CMD_LIST_NR 64 #define G2D_PLANE_MAX_NR 2 -#define G2D_DOUBLE_TO_FIXED(d) ((unsigned int)((d) * 65536.0)) - enum e_g2d_color_mode { /* COLOR FORMAT */ G2D_COLOR_FMT_XRGB8888,