2 * Copyright (C) 2013 Samsung Electronics Co.Ltd
4 * Inki Dae <inki.dae@samsung.com>
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
23 #include <linux/stddef.h>
27 #include "libdrm_macros.h"
28 #include "exynos_drm.h"
29 #include "fimg2d_reg.h"
30 #include "exynos_fimg2d.h"
32 #define SET_BF(val, sc, si, scsa, scda, dc, di, dcsa, dcda) \
33 val.data.src_coeff = sc; \
34 val.data.inv_src_color_coeff = si; \
35 val.data.src_coeff_src_a = scsa; \
36 val.data.src_coeff_dst_a = scda; \
37 val.data.dst_coeff = dc; \
38 val.data.inv_dst_color_coeff = di; \
39 val.data.dst_coeff_src_a = dcsa; \
40 val.data.dst_coeff_dst_a = dcda;
42 #define MIN(a, b) ((a) < (b) ? (a) : (b))
44 enum g2d_base_addr_reg {
49 static unsigned int g2d_get_scaling(unsigned int src, unsigned int dst)
52 * The G2D hw scaling factor is a normalized inverse of the scaling factor.
53 * For example: When source width is 100 and destination width is 200
54 * (scaling of 2x), then the hw factor is NC * 100 / 200.
55 * The normalization factor (NC) is 2^16 = 0x10000.
58 return ((src << 16) / dst);
61 static unsigned int g2d_get_blend_op(enum e_g2d_op op)
63 union g2d_blend_func_val val;
69 case G2D_OP_DISJOINT_CLEAR:
70 case G2D_OP_CONJOINT_CLEAR:
71 SET_BF(val, G2D_COEFF_MODE_ZERO, 0, 0, 0, G2D_COEFF_MODE_ZERO,
75 case G2D_OP_DISJOINT_SRC:
76 case G2D_OP_CONJOINT_SRC:
77 SET_BF(val, G2D_COEFF_MODE_ONE, 0, 0, 0, G2D_COEFF_MODE_ZERO,
81 case G2D_OP_DISJOINT_DST:
82 case G2D_OP_CONJOINT_DST:
83 SET_BF(val, G2D_COEFF_MODE_ZERO, 0, 0, 0, G2D_COEFF_MODE_ONE,
87 SET_BF(val, G2D_COEFF_MODE_ONE, 0, 0, 0,
88 G2D_COEFF_MODE_SRC_ALPHA, 1, 0, 0);
90 case G2D_OP_INTERPOLATE:
91 SET_BF(val, G2D_COEFF_MODE_SRC_ALPHA, 0, 0, 0,
92 G2D_COEFF_MODE_SRC_ALPHA, 1, 0, 0);
95 fprintf(stderr, "Not support operation(%d).\n", op);
96 SET_BF(val, G2D_COEFF_MODE_ONE, 0, 0, 0, G2D_COEFF_MODE_ZERO,
105 * g2d_add_cmd - set given command and value to user side command buffer.
107 * @ctx: a pointer to g2d_context structure.
108 * @cmd: command data.
109 * @value: value data.
111 static int g2d_add_cmd(struct g2d_context *ctx, unsigned long cmd,
114 switch (cmd & ~(G2D_BUF_USERPTR)) {
115 case SRC_BASE_ADDR_REG:
116 case SRC_PLANE2_BASE_ADDR_REG:
117 case DST_BASE_ADDR_REG:
118 case DST_PLANE2_BASE_ADDR_REG:
119 case PAT_BASE_ADDR_REG:
120 case MASK_BASE_ADDR_REG:
121 if (ctx->cmd_buf_nr >= G2D_MAX_GEM_CMD_NR) {
122 fprintf(stderr, "Overflow cmd_gem size.\n");
126 ctx->cmd_buf[ctx->cmd_buf_nr].offset = cmd;
127 ctx->cmd_buf[ctx->cmd_buf_nr].data = value;
131 if (ctx->cmd_nr >= G2D_MAX_CMD_NR) {
132 fprintf(stderr, "Overflow cmd size.\n");
136 ctx->cmd[ctx->cmd_nr].offset = cmd;
137 ctx->cmd[ctx->cmd_nr].data = value;
146 * g2d_add_base_addr - helper function to set dst/src base address register.
148 * @ctx: a pointer to g2d_context structure.
149 * @img: a pointer to the dst/src g2d_image structure.
150 * @reg: the register that should be set.
152 static void g2d_add_base_addr(struct g2d_context *ctx, struct g2d_image *img,
153 enum g2d_base_addr_reg reg)
155 const unsigned long cmd = (reg == g2d_dst) ?
156 DST_BASE_ADDR_REG : SRC_BASE_ADDR_REG;
158 if (img->buf_type == G2D_IMGBUF_USERPTR)
159 g2d_add_cmd(ctx, cmd | G2D_BUF_USERPTR,
160 (unsigned long)&img->user_ptr[0]);
162 g2d_add_cmd(ctx, cmd, img->bo[0]);
166 * g2d_reset - reset fimg2d hardware.
168 * @ctx: a pointer to g2d_context structure.
171 static void g2d_reset(struct g2d_context *ctx)
176 g2d_add_cmd(ctx, SOFT_RESET_REG, 0x01);
180 * g2d_flush - submit all commands and values in user side command buffer
181 * to command queue aware of fimg2d dma.
183 * @ctx: a pointer to g2d_context structure.
185 * This function should be called after all commands and values to user
186 * side command buffer are set. It submits that buffer to the kernel side driver.
188 static int g2d_flush(struct g2d_context *ctx)
191 struct drm_exynos_g2d_set_cmdlist cmdlist = {0};
193 if (ctx->cmd_nr == 0 && ctx->cmd_buf_nr == 0)
196 if (ctx->cmdlist_nr >= G2D_MAX_CMD_LIST_NR) {
197 fprintf(stderr, "Overflow cmdlist.\n");
201 cmdlist.cmd = (uint64_t)(uintptr_t)&ctx->cmd[0];
202 cmdlist.cmd_buf = (uint64_t)(uintptr_t)&ctx->cmd_buf[0];
203 cmdlist.cmd_nr = ctx->cmd_nr;
204 cmdlist.cmd_buf_nr = ctx->cmd_buf_nr;
205 cmdlist.event_type = G2D_EVENT_NOT;
206 cmdlist.user_data = 0;
211 ret = drmIoctl(ctx->fd, DRM_IOCTL_EXYNOS_G2D_SET_CMDLIST, &cmdlist);
213 fprintf(stderr, "failed to set cmdlist.\n");
223 * g2d_init - create a new g2d context and get hardware version.
225 * fd: a file descriptor to an opened drm device.
227 struct g2d_context *g2d_init(int fd)
229 struct drm_exynos_g2d_get_ver ver;
230 struct g2d_context *ctx;
233 ctx = calloc(1, sizeof(*ctx));
235 fprintf(stderr, "failed to allocate context.\n");
241 ret = drmIoctl(fd, DRM_IOCTL_EXYNOS_G2D_GET_VER, &ver);
243 fprintf(stderr, "failed to get version.\n");
248 ctx->major = ver.major;
249 ctx->minor = ver.minor;
251 printf("g2d version(%d.%d).\n", ctx->major, ctx->minor);
255 void g2d_fini(struct g2d_context *ctx)
262 * g2d_exec - start the dma to process all commands summited by g2d_flush().
264 * @ctx: a pointer to g2d_context structure.
266 int g2d_exec(struct g2d_context *ctx)
268 struct drm_exynos_g2d_exec exec;
271 if (ctx->cmdlist_nr == 0)
276 ret = drmIoctl(ctx->fd, DRM_IOCTL_EXYNOS_G2D_EXEC, &exec);
278 fprintf(stderr, "failed to execute.\n");
288 * g2d_solid_fill - fill given buffer with given color data.
290 * @ctx: a pointer to g2d_context structure.
291 * @img: a pointer to g2d_image structure including image and buffer
293 * @x: x start position to buffer filled with given color data.
294 * @y: y start position to buffer filled with given color data.
295 * @w: width value to buffer filled with given color data.
296 * @h: height value to buffer filled with given color data.
299 g2d_solid_fill(struct g2d_context *ctx, struct g2d_image *img,
300 unsigned int x, unsigned int y, unsigned int w,
303 union g2d_bitblt_cmd_val bitblt;
304 union g2d_point_val pt;
306 g2d_add_cmd(ctx, DST_SELECT_REG, G2D_SELECT_MODE_NORMAL);
307 g2d_add_cmd(ctx, DST_COLOR_MODE_REG, img->color_mode);
308 g2d_add_base_addr(ctx, img, g2d_dst);
309 g2d_add_cmd(ctx, DST_STRIDE_REG, img->stride);
311 if (x + w > img->width)
313 if (y + h > img->height)
319 g2d_add_cmd(ctx, DST_LEFT_TOP_REG, pt.val);
325 g2d_add_cmd(ctx, DST_RIGHT_BOTTOM_REG, pt.val);
327 g2d_add_cmd(ctx, SF_COLOR_REG, img->color);
330 bitblt.data.fast_solid_color_fill_en = 1;
331 g2d_add_cmd(ctx, BITBLT_COMMAND_REG, bitblt.val);
333 return g2d_flush(ctx);
337 * g2d_copy - copy contents in source buffer to destination buffer.
339 * @ctx: a pointer to g2d_context structure.
340 * @src: a pointer to g2d_image structure including image and buffer
341 * information to source.
342 * @dst: a pointer to g2d_image structure including image and buffer
343 * information to destination.
344 * @src_x: x start position to source buffer.
345 * @src_y: y start position to source buffer.
346 * @dst_x: x start position to destination buffer.
347 * @dst_y: y start position to destination buffer.
348 * @w: width value to source and destination buffers.
349 * @h: height value to source and destination buffers.
352 g2d_copy(struct g2d_context *ctx, struct g2d_image *src,
353 struct g2d_image *dst, unsigned int src_x, unsigned int src_y,
354 unsigned int dst_x, unsigned dst_y, unsigned int w,
357 union g2d_rop4_val rop4;
358 union g2d_point_val pt;
359 unsigned int src_w = 0, src_h = 0, dst_w = 0, dst_h = 0;
361 g2d_add_cmd(ctx, DST_SELECT_REG, G2D_SELECT_MODE_BGCOLOR);
362 g2d_add_cmd(ctx, DST_COLOR_MODE_REG, dst->color_mode);
363 g2d_add_base_addr(ctx, dst, g2d_dst);
364 g2d_add_cmd(ctx, DST_STRIDE_REG, dst->stride);
366 g2d_add_cmd(ctx, SRC_SELECT_REG, G2D_SELECT_MODE_NORMAL);
367 g2d_add_cmd(ctx, SRC_COLOR_MODE_REG, src->color_mode);
368 g2d_add_base_addr(ctx, src, g2d_src);
369 g2d_add_cmd(ctx, SRC_STRIDE_REG, src->stride);
373 if (src_x + src->width > w)
374 src_w = src->width - src_x;
375 if (src_y + src->height > h)
376 src_h = src->height - src_y;
380 if (dst_x + dst->width > w)
381 dst_w = dst->width - dst_x;
382 if (dst_y + dst->height > h)
383 dst_h = dst->height - dst_y;
385 w = MIN(src_w, dst_w);
386 h = MIN(src_h, dst_h);
388 if (w <= 0 || h <= 0) {
389 fprintf(stderr, "invalid width or height.\n");
397 g2d_add_cmd(ctx, SRC_LEFT_TOP_REG, pt.val);
399 pt.data.x = src_x + w;
400 pt.data.y = src_y + h;
401 g2d_add_cmd(ctx, SRC_RIGHT_BOTTOM_REG, pt.val);
406 g2d_add_cmd(ctx, DST_LEFT_TOP_REG, pt.val);
408 pt.data.x = dst_x + w;
409 pt.data.y = dst_y + h;
410 g2d_add_cmd(ctx, DST_RIGHT_BOTTOM_REG, pt.val);
413 rop4.data.unmasked_rop3 = G2D_ROP3_SRC;
414 g2d_add_cmd(ctx, ROP4_REG, rop4.val);
416 return g2d_flush(ctx);
420 * g2d_copy_with_scale - copy contents in source buffer to destination buffer
421 * scaling up or down properly.
423 * @ctx: a pointer to g2d_context structure.
424 * @src: a pointer to g2d_image structure including image and buffer
425 * information to source.
426 * @dst: a pointer to g2d_image structure including image and buffer
427 * information to destination.
428 * @src_x: x start position to source buffer.
429 * @src_y: y start position to source buffer.
430 * @src_w: width value to source buffer.
431 * @src_h: height value to source buffer.
432 * @dst_x: x start position to destination buffer.
433 * @dst_y: y start position to destination buffer.
434 * @dst_w: width value to destination buffer.
435 * @dst_h: height value to destination buffer.
436 * @negative: indicate that it uses color negative to source and
437 * destination buffers.
440 g2d_copy_with_scale(struct g2d_context *ctx, struct g2d_image *src,
441 struct g2d_image *dst, unsigned int src_x,
442 unsigned int src_y, unsigned int src_w,
443 unsigned int src_h, unsigned int dst_x,
444 unsigned int dst_y, unsigned int dst_w,
445 unsigned int dst_h, unsigned int negative)
447 union g2d_rop4_val rop4;
448 union g2d_point_val pt;
450 unsigned int scale_x, scale_y;
452 g2d_add_cmd(ctx, DST_SELECT_REG, G2D_SELECT_MODE_BGCOLOR);
453 g2d_add_cmd(ctx, DST_COLOR_MODE_REG, dst->color_mode);
454 g2d_add_base_addr(ctx, dst, g2d_dst);
455 g2d_add_cmd(ctx, DST_STRIDE_REG, dst->stride);
457 g2d_add_cmd(ctx, SRC_SELECT_REG, G2D_SELECT_MODE_NORMAL);
458 g2d_add_cmd(ctx, SRC_COLOR_MODE_REG, src->color_mode);
460 g2d_add_cmd(ctx, SRC_REPEAT_MODE_REG, src->repeat_mode);
461 if (src->repeat_mode == G2D_REPEAT_MODE_PAD)
462 g2d_add_cmd(ctx, SRC_PAD_VALUE_REG, dst->color);
464 g2d_add_base_addr(ctx, src, g2d_src);
465 g2d_add_cmd(ctx, SRC_STRIDE_REG, src->stride);
467 if (src_w == dst_w && src_h == dst_h)
471 scale_x = g2d_get_scaling(src_w, dst_w);
472 scale_y = g2d_get_scaling(src_h, dst_h);
475 if (src_x + src_w > src->width)
476 src_w = src->width - src_x;
477 if (src_y + src_h > src->height)
478 src_h = src->height - src_y;
480 if (dst_x + dst_w > dst->width)
481 dst_w = dst->width - dst_x;
482 if (dst_y + dst_h > dst->height)
483 dst_h = dst->height - dst_y;
485 if (src_w <= 0 || src_h <= 0 || dst_w <= 0 || dst_h <= 0) {
486 fprintf(stderr, "invalid width or height.\n");
492 g2d_add_cmd(ctx, BG_COLOR_REG, 0x00FFFFFF);
494 rop4.data.unmasked_rop3 = G2D_ROP3_SRC^G2D_ROP3_DST;
495 g2d_add_cmd(ctx, ROP4_REG, rop4.val);
498 rop4.data.unmasked_rop3 = G2D_ROP3_SRC;
499 g2d_add_cmd(ctx, ROP4_REG, rop4.val);
503 g2d_add_cmd(ctx, SRC_SCALE_CTRL_REG, G2D_SCALE_MODE_BILINEAR);
504 g2d_add_cmd(ctx, SRC_XSCALE_REG, scale_x);
505 g2d_add_cmd(ctx, SRC_YSCALE_REG, scale_y);
511 g2d_add_cmd(ctx, SRC_LEFT_TOP_REG, pt.val);
513 pt.data.x = src_x + src_w;
514 pt.data.y = src_y + src_h;
515 g2d_add_cmd(ctx, SRC_RIGHT_BOTTOM_REG, pt.val);
520 g2d_add_cmd(ctx, DST_LEFT_TOP_REG, pt.val);
522 pt.data.x = dst_x + dst_w;
523 pt.data.y = dst_y + dst_h;
524 g2d_add_cmd(ctx, DST_RIGHT_BOTTOM_REG, pt.val);
526 return g2d_flush(ctx);
530 * g2d_blend - blend image data in source and destination buffers.
532 * @ctx: a pointer to g2d_context structure.
533 * @src: a pointer to g2d_image structure including image and buffer
534 * information to source.
535 * @dst: a pointer to g2d_image structure including image and buffer
536 * information to destination.
537 * @src_x: x start position to source buffer.
538 * @src_y: y start position to source buffer.
539 * @dst_x: x start position to destination buffer.
540 * @dst_y: y start position to destination buffer.
541 * @w: width value to source and destination buffer.
542 * @h: height value to source and destination buffer.
543 * @op: blend operation type.
546 g2d_blend(struct g2d_context *ctx, struct g2d_image *src,
547 struct g2d_image *dst, unsigned int src_x,
548 unsigned int src_y, unsigned int dst_x, unsigned int dst_y,
549 unsigned int w, unsigned int h, enum e_g2d_op op)
551 union g2d_point_val pt;
552 union g2d_bitblt_cmd_val bitblt;
553 union g2d_blend_func_val blend;
554 unsigned int src_w = 0, src_h = 0, dst_w = 0, dst_h = 0;
559 if (op == G2D_OP_SRC || op == G2D_OP_CLEAR)
560 g2d_add_cmd(ctx, DST_SELECT_REG, G2D_SELECT_MODE_BGCOLOR);
562 g2d_add_cmd(ctx, DST_SELECT_REG, G2D_SELECT_MODE_NORMAL);
564 g2d_add_cmd(ctx, DST_COLOR_MODE_REG, dst->color_mode);
565 g2d_add_base_addr(ctx, dst, g2d_dst);
566 g2d_add_cmd(ctx, DST_STRIDE_REG, dst->stride);
568 g2d_add_cmd(ctx, SRC_SELECT_REG, src->select_mode);
569 g2d_add_cmd(ctx, SRC_COLOR_MODE_REG, src->color_mode);
571 switch (src->select_mode) {
572 case G2D_SELECT_MODE_NORMAL:
573 g2d_add_base_addr(ctx, src, g2d_src);
574 g2d_add_cmd(ctx, SRC_STRIDE_REG, src->stride);
576 case G2D_SELECT_MODE_FGCOLOR:
577 g2d_add_cmd(ctx, FG_COLOR_REG, src->color);
579 case G2D_SELECT_MODE_BGCOLOR:
580 g2d_add_cmd(ctx, BG_COLOR_REG, src->color);
583 fprintf(stderr , "failed to set src.\n");
589 if (src_x + w > src->width)
590 src_w = src->width - src_x;
591 if (src_y + h > src->height)
592 src_h = src->height - src_y;
596 if (dst_x + w > dst->width)
597 dst_w = dst->width - dst_x;
598 if (dst_y + h > dst->height)
599 dst_h = dst->height - dst_y;
601 w = MIN(src_w, dst_w);
602 h = MIN(src_h, dst_h);
604 if (w <= 0 || h <= 0) {
605 fprintf(stderr, "invalid width or height.\n");
610 bitblt.data.alpha_blend_mode = G2D_ALPHA_BLEND_MODE_ENABLE;
611 blend.val = g2d_get_blend_op(op);
612 g2d_add_cmd(ctx, BITBLT_COMMAND_REG, bitblt.val);
613 g2d_add_cmd(ctx, BLEND_FUNCTION_REG, blend.val);
618 g2d_add_cmd(ctx, SRC_LEFT_TOP_REG, pt.val);
620 pt.data.x = src_x + w;
621 pt.data.y = src_y + h;
622 g2d_add_cmd(ctx, SRC_RIGHT_BOTTOM_REG, pt.val);
627 g2d_add_cmd(ctx, DST_LEFT_TOP_REG, pt.val);
629 pt.data.x = dst_x + w;
630 pt.data.y = dst_y + h;
631 g2d_add_cmd(ctx, DST_RIGHT_BOTTOM_REG, pt.val);
633 return g2d_flush(ctx);
637 * g2d_scale_and_blend - apply scaling to source buffer and then blend to destination buffer
639 * @ctx: a pointer to g2d_context structure.
640 * @src: a pointer to g2d_image structure including image and buffer
641 * information to source.
642 * @dst: a pointer to g2d_image structure including image and buffer
643 * information to destination.
644 * @src_x: x start position to source buffer.
645 * @src_y: y start position to source buffer.
646 * @src_w: width value to source buffer.
647 * @src_h: height value to source buffer.
648 * @dst_x: x start position to destination buffer.
649 * @dst_y: y start position to destination buffer.
650 * @dst_w: width value to destination buffer.
651 * @dst_h: height value to destination buffer.
652 * @op: blend operation type.
655 g2d_scale_and_blend(struct g2d_context *ctx, struct g2d_image *src,
656 struct g2d_image *dst, unsigned int src_x, unsigned int src_y,
657 unsigned int src_w, unsigned int src_h, unsigned int dst_x,
658 unsigned int dst_y, unsigned int dst_w, unsigned int dst_h,
661 union g2d_point_val pt;
662 union g2d_bitblt_cmd_val bitblt;
663 union g2d_blend_func_val blend;
665 unsigned int scale_x, scale_y;
670 if (op == G2D_OP_SRC || op == G2D_OP_CLEAR)
671 g2d_add_cmd(ctx, DST_SELECT_REG, G2D_SELECT_MODE_BGCOLOR);
673 g2d_add_cmd(ctx, DST_SELECT_REG, G2D_SELECT_MODE_NORMAL);
675 g2d_add_cmd(ctx, DST_COLOR_MODE_REG, dst->color_mode);
676 if (dst->buf_type == G2D_IMGBUF_USERPTR)
677 g2d_add_cmd(ctx, DST_BASE_ADDR_REG | G2D_BUF_USERPTR,
678 (unsigned long)&dst->user_ptr[0]);
680 g2d_add_cmd(ctx, DST_BASE_ADDR_REG, dst->bo[0]);
682 g2d_add_cmd(ctx, DST_STRIDE_REG, dst->stride);
684 g2d_add_cmd(ctx, SRC_SELECT_REG, src->select_mode);
685 g2d_add_cmd(ctx, SRC_COLOR_MODE_REG, src->color_mode);
687 switch (src->select_mode) {
688 case G2D_SELECT_MODE_NORMAL:
689 if (src->buf_type == G2D_IMGBUF_USERPTR)
690 g2d_add_cmd(ctx, SRC_BASE_ADDR_REG | G2D_BUF_USERPTR,
691 (unsigned long)&src->user_ptr[0]);
693 g2d_add_cmd(ctx, SRC_BASE_ADDR_REG, src->bo[0]);
695 g2d_add_cmd(ctx, SRC_STRIDE_REG, src->stride);
697 case G2D_SELECT_MODE_FGCOLOR:
698 g2d_add_cmd(ctx, FG_COLOR_REG, src->color);
700 case G2D_SELECT_MODE_BGCOLOR:
701 g2d_add_cmd(ctx, BG_COLOR_REG, src->color);
704 fprintf(stderr , "failed to set src.\n");
708 if (src_w == dst_w && src_h == dst_h)
712 scale_x = g2d_get_scaling(src_w, dst_w);
713 scale_y = g2d_get_scaling(src_h, dst_h);
716 if (src_x + src_w > src->width)
717 src_w = src->width - src_x;
718 if (src_y + src_h > src->height)
719 src_h = src->height - src_y;
721 if (dst_x + dst_w > dst->width)
722 dst_w = dst->width - dst_x;
723 if (dst_y + dst_h > dst->height)
724 dst_h = dst->height - dst_y;
726 if (src_w <= 0 || src_h <= 0 || dst_w <= 0 || dst_h <= 0) {
727 fprintf(stderr, "invalid width or height.\n");
733 g2d_add_cmd(ctx, SRC_SCALE_CTRL_REG, G2D_SCALE_MODE_BILINEAR);
734 g2d_add_cmd(ctx, SRC_XSCALE_REG, scale_x);
735 g2d_add_cmd(ctx, SRC_YSCALE_REG, scale_y);
738 bitblt.data.alpha_blend_mode = G2D_ALPHA_BLEND_MODE_ENABLE;
739 blend.val = g2d_get_blend_op(op);
740 g2d_add_cmd(ctx, BITBLT_COMMAND_REG, bitblt.val);
741 g2d_add_cmd(ctx, BLEND_FUNCTION_REG, blend.val);
746 g2d_add_cmd(ctx, SRC_LEFT_TOP_REG, pt.val);
748 pt.data.x = src_x + src_w;
749 pt.data.y = src_y + src_h;
750 g2d_add_cmd(ctx, SRC_RIGHT_BOTTOM_REG, pt.val);
755 g2d_add_cmd(ctx, DST_LEFT_TOP_REG, pt.val);
757 pt.data.x = dst_x + dst_w;
758 pt.data.y = dst_y + dst_h;
759 g2d_add_cmd(ctx, DST_RIGHT_BOTTOM_REG, pt.val);
761 return g2d_flush(ctx);