aboutsummaryrefslogtreecommitdiffstats
path: root/exynos
diff options
context:
space:
mode:
authorTobias Jakobi2015-11-29 21:12:19 -0600
committerEmil Velikov2015-12-18 11:42:54 -0600
commit676462c43e97896caa891b1e0aeb27d5d4f13637 (patch)
tree4ebc62fa3aa07d3b6566d963e2adc71f8d5a7d75 /exynos
parent51fd93bc38a33df33f7bf6cbf1ae3fbf74a47dba (diff)
downloadexternal-libdrm-676462c43e97896caa891b1e0aeb27d5d4f13637.tar.gz
external-libdrm-676462c43e97896caa891b1e0aeb27d5d4f13637.tar.xz
external-libdrm-676462c43e97896caa891b1e0aeb27d5d4f13637.zip
exynos/fimg2d: add g2d_move
We already have g2d_copy() which implements G2D copy operations from one buffer to another. However we can't do a overlapping copy operation in one buffer. Add g2d_move() which acts like the standard memmove() and properly handles overlapping copies. Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
Diffstat (limited to 'exynos')
-rw-r--r--exynos/exynos_fimg2d.c95
-rw-r--r--exynos/exynos_fimg2d.h3
2 files changed, 98 insertions, 0 deletions
diff --git a/exynos/exynos_fimg2d.c b/exynos/exynos_fimg2d.c
index 3bef93b0..7f1d105a 100644
--- a/exynos/exynos_fimg2d.c
+++ b/exynos/exynos_fimg2d.c
@@ -567,6 +567,101 @@ g2d_copy(struct g2d_context *ctx, struct g2d_image *src,
567} 567}
568 568
569/** 569/**
570 * g2d_move - copy content inside single buffer.
571 * Similar to libc's memmove() this copies a rectangular
572 * region of the provided buffer to another location, while
573 * properly handling the situation where source and
574 * destination rectangle overlap.
575 *
576 * @ctx: a pointer to g2d_context structure.
577 * @img: a pointer to g2d_image structure providing
578 * buffer information.
579 * @src_x: x position of source rectangle.
580 * @src_y: y position of source rectangle.
581 * @dst_x: x position of destination rectangle.
582 * @dst_y: y position of destination rectangle.
583 * @w: width of rectangle to move.
584 * @h: height of rectangle to move.
585 */
586int
587g2d_move(struct g2d_context *ctx, struct g2d_image *img,
588 unsigned int src_x, unsigned int src_y,
589 unsigned int dst_x, unsigned dst_y, unsigned int w,
590 unsigned int h)
591{
592 union g2d_rop4_val rop4;
593 union g2d_point_val pt;
594 union g2d_direction_val dir;
595 unsigned int src_w, src_h, dst_w, dst_h;
596
597 src_w = w;
598 src_h = h;
599 if (src_x + img->width > w)
600 src_w = img->width - src_x;
601 if (src_y + img->height > h)
602 src_h = img->height - src_y;
603
604 dst_w = w;
605 dst_h = w;
606 if (dst_x + img->width > w)
607 dst_w = img->width - dst_x;
608 if (dst_y + img->height > h)
609 dst_h = img->height - dst_y;
610
611 w = MIN(src_w, dst_w);
612 h = MIN(src_h, dst_h);
613
614 if (w == 0 || h == 0) {
615 fprintf(stderr, MSG_PREFIX "invalid width or height.\n");
616 return -EINVAL;
617 }
618
619 if (g2d_check_space(ctx, 13, 2))
620 return -ENOSPC;
621
622 g2d_add_cmd(ctx, DST_SELECT_REG, G2D_SELECT_MODE_BGCOLOR);
623 g2d_add_cmd(ctx, SRC_SELECT_REG, G2D_SELECT_MODE_NORMAL);
624
625 g2d_add_cmd(ctx, DST_COLOR_MODE_REG, img->color_mode);
626 g2d_add_cmd(ctx, SRC_COLOR_MODE_REG, img->color_mode);
627
628 g2d_add_base_addr(ctx, img, g2d_dst);
629 g2d_add_base_addr(ctx, img, g2d_src);
630
631 g2d_add_cmd(ctx, DST_STRIDE_REG, img->stride);
632 g2d_add_cmd(ctx, SRC_STRIDE_REG, img->stride);
633
634 dir.val[0] = dir.val[1] = 0;
635
636 if (dst_x >= src_x)
637 dir.data.src_x_direction = dir.data.dst_x_direction = 1;
638 if (dst_y >= src_y)
639 dir.data.src_y_direction = dir.data.dst_y_direction = 1;
640
641 g2d_set_direction(ctx, &dir);
642
643 pt.data.x = src_x;
644 pt.data.y = src_y;
645 g2d_add_cmd(ctx, SRC_LEFT_TOP_REG, pt.val);
646 pt.data.x = src_x + w;
647 pt.data.y = src_y + h;
648 g2d_add_cmd(ctx, SRC_RIGHT_BOTTOM_REG, pt.val);
649
650 pt.data.x = dst_x;
651 pt.data.y = dst_y;
652 g2d_add_cmd(ctx, DST_LEFT_TOP_REG, pt.val);
653 pt.data.x = dst_x + w;
654 pt.data.y = dst_y + h;
655 g2d_add_cmd(ctx, DST_RIGHT_BOTTOM_REG, pt.val);
656
657 rop4.val = 0;
658 rop4.data.unmasked_rop3 = G2D_ROP3_SRC;
659 g2d_add_cmd(ctx, ROP4_REG, rop4.val);
660
661 return g2d_flush(ctx);
662}
663
664/**
570 * g2d_copy_with_scale - copy contents in source buffer to destination buffer 665 * g2d_copy_with_scale - copy contents in source buffer to destination buffer
571 * scaling up or down properly. 666 * scaling up or down properly.
572 * 667 *
diff --git a/exynos/exynos_fimg2d.h b/exynos/exynos_fimg2d.h
index a2c22da7..a825c683 100644
--- a/exynos/exynos_fimg2d.h
+++ b/exynos/exynos_fimg2d.h
@@ -299,6 +299,9 @@ int g2d_copy(struct g2d_context *ctx, struct g2d_image *src,
299 struct g2d_image *dst, unsigned int src_x, 299 struct g2d_image *dst, unsigned int src_x,
300 unsigned int src_y, unsigned int dst_x, unsigned int dst_y, 300 unsigned int src_y, unsigned int dst_x, unsigned int dst_y,
301 unsigned int w, unsigned int h); 301 unsigned int w, unsigned int h);
302int g2d_move(struct g2d_context *ctx, struct g2d_image *img,
303 unsigned int src_x, unsigned int src_y, unsigned int dst_x,
304 unsigned dst_y, unsigned int w, unsigned int h);
302int g2d_copy_with_scale(struct g2d_context *ctx, struct g2d_image *src, 305int g2d_copy_with_scale(struct g2d_context *ctx, struct g2d_image *src,
303 struct g2d_image *dst, unsigned int src_x, 306 struct g2d_image *dst, unsigned int src_x,
304 unsigned int src_y, unsigned int src_w, 307 unsigned int src_y, unsigned int src_w,