All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
To: linux-samsung-soc@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org, m.szyprowski@samsung.com,
	djkurtz@chromium.org, robclark@freedesktop.org,
	Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
Subject: [PATCH 02/15] exynos: replace G2D_DOUBLE_TO_FIXED macro with function
Date: Tue,  3 Feb 2015 14:53:52 +0100	[thread overview]
Message-ID: <1422971645-30621-3-git-send-email-tjakobi@math.uni-bielefeld.de> (raw)
In-Reply-To: <1422971645-30621-1-git-send-email-tjakobi@math.uni-bielefeld.de>

This also avoids the floating point conversion steps and just
uses pure integer arithmetic.
Since the G2D hardware scaling approach is a bit unintuitive,
document it in the function as well.

Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
---
 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 ce1ba1e..d22c893 100644
--- a/exynos/exynos_fimg2d.c
+++ b/exynos/exynos_fimg2d.c
@@ -41,6 +41,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;
@@ -428,7 +437,7 @@ 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);
@@ -454,8 +463,8 @@ 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)
@@ -487,8 +496,8 @@ 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,
-- 
2.0.5

  parent reply	other threads:[~2015-02-03 13:54 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-03 13:53 [libdrm] improvements to userspace exynos component Tobias Jakobi
2015-02-03 13:53 ` [PATCH 01/15] tests/exynos: fimg2d: add a checkerboard test Tobias Jakobi
2015-02-03 13:53 ` Tobias Jakobi [this message]
2015-02-03 13:53 ` [PATCH 03/15] tests/exynos: fix typos and change wording Tobias Jakobi
2015-02-03 13:53 ` [PATCH 04/15] tests/exynos: disable the G2D userptr/blend test Tobias Jakobi
2015-02-11  1:11   ` Joonyoung Shim
2015-02-11  1:39     ` Tobias Jakobi
2015-02-11  1:47       ` Joonyoung Shim
2015-02-03 13:53 ` [PATCH 05/15] exynos: add g2d_scale_and_blend Tobias Jakobi
2015-02-03 13:53 ` [PATCH 06/15] tests/exynos: introduce wait_for_user_input Tobias Jakobi
2015-02-03 13:53 ` [PATCH 07/15] exynos: honor the repeat mode in g2d_copy_with_scale Tobias Jakobi
2015-02-03 13:53 ` [PATCH 08/15] exynos: introduce g2d_add_base_addr helper function Tobias Jakobi
2015-02-03 13:53 ` [PATCH 09/15] exynos: use structure initialization instead of memset Tobias Jakobi
2015-02-03 13:54 ` [PATCH 10/15] tests/exynos: improve error handling Tobias Jakobi
2015-02-03 13:54 ` [PATCH 11/15] exynos: add exynos prefix to fimg2d header Tobias Jakobi
2015-02-03 13:54 ` [PATCH 12/15] exynos: add fimg2d header to common includes Tobias Jakobi
2015-02-03 13:54 ` [PATCH 13/15] exynos: fimg2d: fix comment for G2D_COEFF_MODE_GB_COLOR Tobias Jakobi
2015-02-03 13:54 ` [PATCH 14/15] exynos: fimg2d: unify register style Tobias Jakobi
2015-02-03 13:54 ` [PATCH 15/15] exynos: fimg2d: introduce G2D_OP_INTERPOLATE Tobias Jakobi
2015-02-11  1:11 ` [libdrm] improvements to userspace exynos component Joonyoung Shim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1422971645-30621-3-git-send-email-tjakobi@math.uni-bielefeld.de \
    --to=tjakobi@math.uni-bielefeld.de \
    --cc=djkurtz@chromium.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=robclark@freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.