aboutsummaryrefslogtreecommitdiffstats
path: root/exynos
diff options
context:
space:
mode:
authorTobias Jakobi2015-02-24 08:20:46 -0600
committerEmil Velikov2015-03-10 14:21:44 -0500
commit74add49f1b829dd580aae1dfdce2a0ebbbba216c (patch)
treeaef2ceb5172edcc4d2ba10ce41006126a9139576 /exynos
parent6e2a9f936e032813dfb5be7d18cabdd177910645 (diff)
downloadexternal-libdrm-74add49f1b829dd580aae1dfdce2a0ebbbba216c.tar.gz
external-libdrm-74add49f1b829dd580aae1dfdce2a0ebbbba216c.tar.xz
external-libdrm-74add49f1b829dd580aae1dfdce2a0ebbbba216c.zip
exynos: introduce g2d_add_base_addr helper function
In almost all functions the base address register is written, so it makes sense to have a helper function for this. v3: Wrap line 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.c75
1 files changed, 32 insertions, 43 deletions
diff --git a/exynos/exynos_fimg2d.c b/exynos/exynos_fimg2d.c
index df18a089..03cf182f 100644
--- a/exynos/exynos_fimg2d.c
+++ b/exynos/exynos_fimg2d.c
@@ -41,6 +41,11 @@
41 41
42#define MIN(a, b) ((a) < (b) ? (a) : (b)) 42#define MIN(a, b) ((a) < (b) ? (a) : (b))
43 43
44enum g2d_base_addr_reg {
45 g2d_dst = 0,
46 g2d_src
47};
48
44static unsigned int g2d_get_scaling(unsigned int src, unsigned int dst) 49static unsigned int g2d_get_scaling(unsigned int src, unsigned int dst)
45{ 50{
46 /* 51 /*
@@ -134,6 +139,26 @@ static int g2d_add_cmd(struct g2d_context *ctx, unsigned long cmd,
134} 139}
135 140
136/* 141/*
142 * g2d_add_base_addr - helper function to set dst/src base address register.
143 *
144 * @ctx: a pointer to g2d_context structure.
145 * @img: a pointer to the dst/src g2d_image structure.
146 * @reg: the register that should be set.
147 */
148static void g2d_add_base_addr(struct g2d_context *ctx, struct g2d_image *img,
149 enum g2d_base_addr_reg reg)
150{
151 const unsigned long cmd = (reg == g2d_dst) ?
152 DST_BASE_ADDR_REG : SRC_BASE_ADDR_REG;
153
154 if (img->buf_type == G2D_IMGBUF_USERPTR)
155 g2d_add_cmd(ctx, cmd | G2D_BUF_USERPTR,
156 (unsigned long)&img->user_ptr[0]);
157 else
158 g2d_add_cmd(ctx, cmd, img->bo[0]);
159}
160
161/*
137 * g2d_reset - reset fimg2d hardware. 162 * g2d_reset - reset fimg2d hardware.
138 * 163 *
139 * @ctx: a pointer to g2d_context structure. 164 * @ctx: a pointer to g2d_context structure.
@@ -278,13 +303,7 @@ g2d_solid_fill(struct g2d_context *ctx, struct g2d_image *img,
278 303
279 g2d_add_cmd(ctx, DST_SELECT_REG, G2D_SELECT_MODE_NORMAL); 304 g2d_add_cmd(ctx, DST_SELECT_REG, G2D_SELECT_MODE_NORMAL);
280 g2d_add_cmd(ctx, DST_COLOR_MODE_REG, img->color_mode); 305 g2d_add_cmd(ctx, DST_COLOR_MODE_REG, img->color_mode);
281 306 g2d_add_base_addr(ctx, img, g2d_dst);
282 if (img->buf_type == G2D_IMGBUF_USERPTR)
283 g2d_add_cmd(ctx, DST_BASE_ADDR_REG | G2D_BUF_USERPTR,
284 (unsigned long)&img->user_ptr[0]);
285 else
286 g2d_add_cmd(ctx, DST_BASE_ADDR_REG, img->bo[0]);
287
288 g2d_add_cmd(ctx, DST_STRIDE_REG, img->stride); 307 g2d_add_cmd(ctx, DST_STRIDE_REG, img->stride);
289 308
290 if (x + w > img->width) 309 if (x + w > img->width)
@@ -341,22 +360,12 @@ g2d_copy(struct g2d_context *ctx, struct g2d_image *src,
341 360
342 g2d_add_cmd(ctx, DST_SELECT_REG, G2D_SELECT_MODE_BGCOLOR); 361 g2d_add_cmd(ctx, DST_SELECT_REG, G2D_SELECT_MODE_BGCOLOR);
343 g2d_add_cmd(ctx, DST_COLOR_MODE_REG, dst->color_mode); 362 g2d_add_cmd(ctx, DST_COLOR_MODE_REG, dst->color_mode);
344 if (dst->buf_type == G2D_IMGBUF_USERPTR) 363 g2d_add_base_addr(ctx, dst, g2d_dst);
345 g2d_add_cmd(ctx, DST_BASE_ADDR_REG | G2D_BUF_USERPTR,
346 (unsigned long)&dst->user_ptr[0]);
347 else
348 g2d_add_cmd(ctx, DST_BASE_ADDR_REG, dst->bo[0]);
349
350 g2d_add_cmd(ctx, DST_STRIDE_REG, dst->stride); 364 g2d_add_cmd(ctx, DST_STRIDE_REG, dst->stride);
351 365
352 g2d_add_cmd(ctx, SRC_SELECT_REG, G2D_SELECT_MODE_NORMAL); 366 g2d_add_cmd(ctx, SRC_SELECT_REG, G2D_SELECT_MODE_NORMAL);
353 g2d_add_cmd(ctx, SRC_COLOR_MODE_REG, src->color_mode); 367 g2d_add_cmd(ctx, SRC_COLOR_MODE_REG, src->color_mode);
354 if (src->buf_type == G2D_IMGBUF_USERPTR) 368 g2d_add_base_addr(ctx, src, g2d_src);
355 g2d_add_cmd(ctx, SRC_BASE_ADDR_REG | G2D_BUF_USERPTR,
356 (unsigned long)&src->user_ptr[0]);
357 else
358 g2d_add_cmd(ctx, SRC_BASE_ADDR_REG, src->bo[0]);
359
360 g2d_add_cmd(ctx, SRC_STRIDE_REG, src->stride); 369 g2d_add_cmd(ctx, SRC_STRIDE_REG, src->stride);
361 370
362 src_w = w; 371 src_w = w;
@@ -444,22 +453,12 @@ g2d_copy_with_scale(struct g2d_context *ctx, struct g2d_image *src,
444 453
445 g2d_add_cmd(ctx, DST_SELECT_REG, G2D_SELECT_MODE_BGCOLOR); 454 g2d_add_cmd(ctx, DST_SELECT_REG, G2D_SELECT_MODE_BGCOLOR);
446 g2d_add_cmd(ctx, DST_COLOR_MODE_REG, dst->color_mode); 455 g2d_add_cmd(ctx, DST_COLOR_MODE_REG, dst->color_mode);
447 if (dst->buf_type == G2D_IMGBUF_USERPTR) 456 g2d_add_base_addr(ctx, dst, g2d_dst);
448 g2d_add_cmd(ctx, DST_BASE_ADDR_REG | G2D_BUF_USERPTR,
449 (unsigned long)&dst->user_ptr[0]);
450 else
451 g2d_add_cmd(ctx, DST_BASE_ADDR_REG, dst->bo[0]);
452
453 g2d_add_cmd(ctx, DST_STRIDE_REG, dst->stride); 457 g2d_add_cmd(ctx, DST_STRIDE_REG, dst->stride);
454 458
455 g2d_add_cmd(ctx, SRC_SELECT_REG, G2D_SELECT_MODE_NORMAL); 459 g2d_add_cmd(ctx, SRC_SELECT_REG, G2D_SELECT_MODE_NORMAL);
456 g2d_add_cmd(ctx, SRC_COLOR_MODE_REG, src->color_mode); 460 g2d_add_cmd(ctx, SRC_COLOR_MODE_REG, src->color_mode);
457 if (src->buf_type == G2D_IMGBUF_USERPTR) 461 g2d_add_base_addr(ctx, src, g2d_src);
458 g2d_add_cmd(ctx, SRC_BASE_ADDR_REG | G2D_BUF_USERPTR,
459 (unsigned long)&src->user_ptr[0]);
460 else
461 g2d_add_cmd(ctx, SRC_BASE_ADDR_REG, src->bo[0]);
462
463 g2d_add_cmd(ctx, SRC_STRIDE_REG, src->stride); 462 g2d_add_cmd(ctx, SRC_STRIDE_REG, src->stride);
464 463
465 if (src_w == dst_w && src_h == dst_h) 464 if (src_w == dst_w && src_h == dst_h)
@@ -562,12 +561,7 @@ g2d_blend(struct g2d_context *ctx, struct g2d_image *src,
562 g2d_add_cmd(ctx, DST_SELECT_REG, G2D_SELECT_MODE_NORMAL); 561 g2d_add_cmd(ctx, DST_SELECT_REG, G2D_SELECT_MODE_NORMAL);
563 562
564 g2d_add_cmd(ctx, DST_COLOR_MODE_REG, dst->color_mode); 563 g2d_add_cmd(ctx, DST_COLOR_MODE_REG, dst->color_mode);
565 if (dst->buf_type == G2D_IMGBUF_USERPTR) 564 g2d_add_base_addr(ctx, dst, g2d_dst);
566 g2d_add_cmd(ctx, DST_BASE_ADDR_REG | G2D_BUF_USERPTR,
567 (unsigned long)&dst->user_ptr[0]);
568 else
569 g2d_add_cmd(ctx, DST_BASE_ADDR_REG, dst->bo[0]);
570
571 g2d_add_cmd(ctx, DST_STRIDE_REG, dst->stride); 565 g2d_add_cmd(ctx, DST_STRIDE_REG, dst->stride);
572 566
573 g2d_add_cmd(ctx, SRC_SELECT_REG, src->select_mode); 567 g2d_add_cmd(ctx, SRC_SELECT_REG, src->select_mode);
@@ -575,12 +569,7 @@ g2d_blend(struct g2d_context *ctx, struct g2d_image *src,
575 569
576 switch (src->select_mode) { 570 switch (src->select_mode) {
577 case G2D_SELECT_MODE_NORMAL: 571 case G2D_SELECT_MODE_NORMAL:
578 if (src->buf_type == G2D_IMGBUF_USERPTR) 572 g2d_add_base_addr(ctx, src, g2d_src);
579 g2d_add_cmd(ctx, SRC_BASE_ADDR_REG | G2D_BUF_USERPTR,
580 (unsigned long)&src->user_ptr[0]);
581 else
582 g2d_add_cmd(ctx, SRC_BASE_ADDR_REG, src->bo[0]);
583
584 g2d_add_cmd(ctx, SRC_STRIDE_REG, src->stride); 573 g2d_add_cmd(ctx, SRC_STRIDE_REG, src->stride);
585 break; 574 break;
586 case G2D_SELECT_MODE_FGCOLOR: 575 case G2D_SELECT_MODE_FGCOLOR: