aboutsummaryrefslogtreecommitdiffstats
path: root/exynos
diff options
context:
space:
mode:
authorTobias Jakobi2015-02-24 08:20:40 -0600
committerEmil Velikov2015-03-10 14:04:35 -0500
commit1d7e78d7877f054f7b96d6a35d50255e76aed44f (patch)
tree1f78133802b99ea91f1ac0daf3055b70c6cc6cfc /exynos
parent0ca03a4087a550646de7f26b6b53a932e8546474 (diff)
downloadexternal-libdrm-1d7e78d7877f054f7b96d6a35d50255e76aed44f.tar.gz
external-libdrm-1d7e78d7877f054f7b96d6a35d50255e76aed44f.tar.xz
external-libdrm-1d7e78d7877f054f7b96d6a35d50255e76aed44f.zip
exynos: replace G2D_DOUBLE_TO_FIXED macro with function
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. v2: Explicitly mention the normalization constant. v3: Use common commenting style as pointed out by Emil Velikov <emil.l.velikov@gmail.com>. Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com> Tested-by: Joonyoung Shim <jy0922.shim@samsung.com>
Diffstat (limited to 'exynos')
-rw-r--r--exynos/exynos_fimg2d.c22
-rw-r--r--exynos/fimg2d.h2
2 files changed, 17 insertions, 7 deletions
diff --git a/exynos/exynos_fimg2d.c b/exynos/exynos_fimg2d.c
index ce1ba1ef..9c66c3ab 100644
--- a/exynos/exynos_fimg2d.c
+++ b/exynos/exynos_fimg2d.c
@@ -41,6 +41,18 @@
41 41
42#define MIN(a, b) ((a) < (b) ? (a) : (b)) 42#define MIN(a, b) ((a) < (b) ? (a) : (b))
43 43
44static unsigned int g2d_get_scaling(unsigned int src, unsigned int dst)
45{
46 /*
47 * The G2D hw scaling factor is a normalized inverse of the scaling factor.
48 * For example: When source width is 100 and destination width is 200
49 * (scaling of 2x), then the hw factor is NC * 100 / 200.
50 * The normalization factor (NC) is 2^16 = 0x10000.
51 */
52
53 return ((src << 16) / dst);
54}
55
44static unsigned int g2d_get_blend_op(enum e_g2d_op op) 56static unsigned int g2d_get_blend_op(enum e_g2d_op op)
45{ 57{
46 union g2d_blend_func_val val; 58 union g2d_blend_func_val val;
@@ -428,7 +440,7 @@ g2d_copy_with_scale(struct g2d_context *ctx, struct g2d_image *src,
428 union g2d_rop4_val rop4; 440 union g2d_rop4_val rop4;
429 union g2d_point_val pt; 441 union g2d_point_val pt;
430 unsigned int scale; 442 unsigned int scale;
431 double scale_x = 0.0f, scale_y = 0.0f; 443 unsigned int scale_x, scale_y;
432 444
433 g2d_add_cmd(ctx, DST_SELECT_REG, G2D_SELECT_MODE_BGCOLOR); 445 g2d_add_cmd(ctx, DST_SELECT_REG, G2D_SELECT_MODE_BGCOLOR);
434 g2d_add_cmd(ctx, DST_COLOR_MODE_REG, dst->color_mode); 446 g2d_add_cmd(ctx, DST_COLOR_MODE_REG, dst->color_mode);
@@ -454,8 +466,8 @@ g2d_copy_with_scale(struct g2d_context *ctx, struct g2d_image *src,
454 scale = 0; 466 scale = 0;
455 else { 467 else {
456 scale = 1; 468 scale = 1;
457 scale_x = (double)src_w / (double)dst_w; 469 scale_x = g2d_get_scaling(src_w, dst_w);
458 scale_y = (double)src_h / (double)dst_h; 470 scale_y = g2d_get_scaling(src_h, dst_h);
459 } 471 }
460 472
461 if (src_x + src_w > src->width) 473 if (src_x + src_w > src->width)
@@ -487,8 +499,8 @@ g2d_copy_with_scale(struct g2d_context *ctx, struct g2d_image *src,
487 499
488 if (scale) { 500 if (scale) {
489 g2d_add_cmd(ctx, SRC_SCALE_CTRL_REG, G2D_SCALE_MODE_BILINEAR); 501 g2d_add_cmd(ctx, SRC_SCALE_CTRL_REG, G2D_SCALE_MODE_BILINEAR);
490 g2d_add_cmd(ctx, SRC_XSCALE_REG, G2D_DOUBLE_TO_FIXED(scale_x)); 502 g2d_add_cmd(ctx, SRC_XSCALE_REG, scale_x);
491 g2d_add_cmd(ctx, SRC_YSCALE_REG, G2D_DOUBLE_TO_FIXED(scale_y)); 503 g2d_add_cmd(ctx, SRC_YSCALE_REG, scale_y);
492 } 504 }
493 505
494 pt.val = 0; 506 pt.val = 0;
diff --git a/exynos/fimg2d.h b/exynos/fimg2d.h
index 4785e2f0..8e0321cf 100644
--- a/exynos/fimg2d.h
+++ b/exynos/fimg2d.h
@@ -25,8 +25,6 @@
25#define G2D_MAX_CMD_LIST_NR 64 25#define G2D_MAX_CMD_LIST_NR 64
26#define G2D_PLANE_MAX_NR 2 26#define G2D_PLANE_MAX_NR 2
27 27
28#define G2D_DOUBLE_TO_FIXED(d) ((unsigned int)((d) * 65536.0))
29
30enum e_g2d_color_mode { 28enum e_g2d_color_mode {
31 /* COLOR FORMAT */ 29 /* COLOR FORMAT */
32 G2D_COLOR_FMT_XRGB8888, 30 G2D_COLOR_FMT_XRGB8888,