exynos: introduce g2d_add_base_addr helper function
[platform/upstream/libdrm.git] / exynos / exynos_fimg2d.c
1 /*
2  * Copyright (C) 2013 Samsung Electronics Co.Ltd
3  * Authors:
4  *      Inki Dae <inki.dae@samsung.com>
5  *
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.
10  *
11  */
12
13 #ifdef HAVE_CONFIG_H
14 #include "config.h"
15 #endif
16
17 #include <stdlib.h>
18 #include <stdio.h>
19 #include <string.h>
20 #include <errno.h>
21
22 #include <sys/mman.h>
23 #include <linux/stddef.h>
24
25 #include <xf86drm.h>
26
27 #include "libdrm.h"
28 #include "exynos_drm.h"
29 #include "fimg2d_reg.h"
30 #include "fimg2d.h"
31
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;
41
42 #define MIN(a, b)       ((a) < (b) ? (a) : (b))
43
44 enum g2d_base_addr_reg {
45         g2d_dst = 0,
46         g2d_src
47 };
48
49 static unsigned int g2d_get_scaling(unsigned int src, unsigned int dst)
50 {
51         /*
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.
56          */
57
58         return ((src << 16) / dst);
59 }
60
61 static unsigned int g2d_get_blend_op(enum e_g2d_op op)
62 {
63         union g2d_blend_func_val val;
64
65         val.val = 0;
66
67         switch (op) {
68         case G2D_OP_CLEAR:
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,
72                                 0, 0, 0);
73                 break;
74         case G2D_OP_SRC:
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,
78                                 0, 0, 0);
79                 break;
80         case G2D_OP_DST:
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,
84                                 0, 0, 0);
85                 break;
86         case G2D_OP_OVER:
87                 SET_BF(val, G2D_COEFF_MODE_ONE, 0, 0, 0,
88                                 G2D_COEFF_MODE_SRC_ALPHA, 1, 0, 0);
89                 break;
90         default:
91                 fprintf(stderr, "Not support operation(%d).\n", op);
92                 SET_BF(val, G2D_COEFF_MODE_ONE, 0, 0, 0, G2D_COEFF_MODE_ZERO,
93                                 0, 0, 0);
94                 break;
95         }
96
97         return val.val;
98 }
99
100 /*
101  * g2d_add_cmd - set given command and value to user side command buffer.
102  *
103  * @ctx: a pointer to g2d_context structure.
104  * @cmd: command data.
105  * @value: value data.
106  */
107 static int g2d_add_cmd(struct g2d_context *ctx, unsigned long cmd,
108                         unsigned long value)
109 {
110         switch (cmd & ~(G2D_BUF_USERPTR)) {
111         case SRC_BASE_ADDR_REG:
112         case SRC_PLANE2_BASE_ADDR_REG:
113         case DST_BASE_ADDR_REG:
114         case DST_PLANE2_BASE_ADDR_REG:
115         case PAT_BASE_ADDR_REG:
116         case MASK_BASE_ADDR_REG:
117                 if (ctx->cmd_buf_nr >= G2D_MAX_GEM_CMD_NR) {
118                         fprintf(stderr, "Overflow cmd_gem size.\n");
119                         return -EINVAL;
120                 }
121
122                 ctx->cmd_buf[ctx->cmd_buf_nr].offset = cmd;
123                 ctx->cmd_buf[ctx->cmd_buf_nr].data = value;
124                 ctx->cmd_buf_nr++;
125                 break;
126         default:
127                 if (ctx->cmd_nr >= G2D_MAX_CMD_NR) {
128                         fprintf(stderr, "Overflow cmd size.\n");
129                         return -EINVAL;
130                 }
131
132                 ctx->cmd[ctx->cmd_nr].offset = cmd;
133                 ctx->cmd[ctx->cmd_nr].data = value;
134                 ctx->cmd_nr++;
135                 break;
136         }
137
138         return TRUE;
139 }
140
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  */
148 static 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 /*
162  * g2d_reset - reset fimg2d hardware.
163  *
164  * @ctx: a pointer to g2d_context structure.
165  *
166  */
167 static void g2d_reset(struct g2d_context *ctx)
168 {
169         ctx->cmd_nr = 0;
170         ctx->cmd_buf_nr = 0;
171
172         g2d_add_cmd(ctx, SOFT_RESET_REG, 0x01);
173 }
174
175 /*
176  * g2d_flush - submit all commands and values in user side command buffer
177  *              to command queue aware of fimg2d dma.
178  *
179  * @ctx: a pointer to g2d_context structure.
180  *
181  * This function should be called after all commands and values to user
182  * side command buffer are set. It submits that buffer to the kernel side driver.
183  */
184 static int g2d_flush(struct g2d_context *ctx)
185 {
186         int ret;
187         struct drm_exynos_g2d_set_cmdlist cmdlist;
188
189         if (ctx->cmd_nr  == 0 && ctx->cmd_buf_nr == 0)
190                 return FALSE;
191
192         if (ctx->cmdlist_nr >= G2D_MAX_CMD_LIST_NR) {
193                 fprintf(stderr, "Overflow cmdlist.\n");
194                 return -EINVAL;
195         }
196
197         memset(&cmdlist, 0, sizeof(struct drm_exynos_g2d_set_cmdlist));
198
199         cmdlist.cmd = (uint64_t)(uintptr_t)&ctx->cmd[0];
200         cmdlist.cmd_buf = (uint64_t)(uintptr_t)&ctx->cmd_buf[0];
201         cmdlist.cmd_nr = ctx->cmd_nr;
202         cmdlist.cmd_buf_nr = ctx->cmd_buf_nr;
203         cmdlist.event_type = G2D_EVENT_NOT;
204         cmdlist.user_data = 0;
205
206         ctx->cmd_nr = 0;
207         ctx->cmd_buf_nr = 0;
208
209         ret = drmIoctl(ctx->fd, DRM_IOCTL_EXYNOS_G2D_SET_CMDLIST, &cmdlist);
210         if (ret < 0) {
211                 fprintf(stderr, "failed to set cmdlist.\n");
212                 return ret;
213         }
214
215         ctx->cmdlist_nr++;
216
217         return ret;
218 }
219
220 /**
221  * g2d_init - create a new g2d context and get hardware version.
222  *
223  * fd: a file descriptor to an opened drm device.
224  */
225 drm_public struct g2d_context *g2d_init(int fd)
226 {
227         struct drm_exynos_g2d_get_ver ver;
228         struct g2d_context *ctx;
229         int ret;
230
231         ctx = calloc(1, sizeof(*ctx));
232         if (!ctx) {
233                 fprintf(stderr, "failed to allocate context.\n");
234                 return NULL;
235         }
236
237         ctx->fd = fd;
238
239         ret = drmIoctl(fd, DRM_IOCTL_EXYNOS_G2D_GET_VER, &ver);
240         if (ret < 0) {
241                 fprintf(stderr, "failed to get version.\n");
242                 free(ctx);
243                 return NULL;
244         }
245
246         ctx->major = ver.major;
247         ctx->minor = ver.minor;
248
249         printf("g2d version(%d.%d).\n", ctx->major, ctx->minor);
250         return ctx;
251 }
252
253 drm_public void g2d_fini(struct g2d_context *ctx)
254 {
255         if (ctx)
256                 free(ctx);
257 }
258
259 /**
260  * g2d_exec - start the dma to process all commands summited by g2d_flush().
261  *
262  * @ctx: a pointer to g2d_context structure.
263  */
264 drm_public int g2d_exec(struct g2d_context *ctx)
265 {
266         struct drm_exynos_g2d_exec exec;
267         int ret;
268
269         if (ctx->cmdlist_nr == 0)
270                 return -EINVAL;
271
272         exec.async = 0;
273
274         ret = drmIoctl(ctx->fd, DRM_IOCTL_EXYNOS_G2D_EXEC, &exec);
275         if (ret < 0) {
276                 fprintf(stderr, "failed to execute.\n");
277                 return ret;
278         }
279
280         ctx->cmdlist_nr = 0;
281
282         return ret;
283 }
284
285 /**
286  * g2d_solid_fill - fill given buffer with given color data.
287  *
288  * @ctx: a pointer to g2d_context structure.
289  * @img: a pointer to g2d_image structure including image and buffer
290  *      information.
291  * @x: x start position to buffer filled with given color data.
292  * @y: y start position to buffer filled with given color data.
293  * @w: width value to buffer filled with given color data.
294  * @h: height value to buffer filled with given color data.
295  */
296 drm_public int
297 g2d_solid_fill(struct g2d_context *ctx, struct g2d_image *img,
298                         unsigned int x, unsigned int y, unsigned int w,
299                         unsigned int h)
300 {
301         union g2d_bitblt_cmd_val bitblt;
302         union g2d_point_val pt;
303
304         g2d_add_cmd(ctx, DST_SELECT_REG, G2D_SELECT_MODE_NORMAL);
305         g2d_add_cmd(ctx, DST_COLOR_MODE_REG, img->color_mode);
306         g2d_add_base_addr(ctx, img, g2d_dst);
307         g2d_add_cmd(ctx, DST_STRIDE_REG, img->stride);
308
309         if (x + w > img->width)
310                 w = img->width - x;
311         if (y + h > img->height)
312                 h = img->height - y;
313
314         pt.val = 0;
315         pt.data.x = x;
316         pt.data.y = y;
317         g2d_add_cmd(ctx, DST_LEFT_TOP_REG, pt.val);
318
319         pt.val = 0;
320         pt.data.x = x + w;
321         pt.data.y = y + h;
322
323         g2d_add_cmd(ctx, DST_RIGHT_BOTTOM_REG, pt.val);
324
325         g2d_add_cmd(ctx, SF_COLOR_REG, img->color);
326
327         bitblt.val = 0;
328         bitblt.data.fast_solid_color_fill_en = 1;
329         g2d_add_cmd(ctx, BITBLT_COMMAND_REG, bitblt.val);
330
331         g2d_flush(ctx);
332
333         return 0;
334 }
335
336 /**
337  * g2d_copy - copy contents in source buffer to destination buffer.
338  *
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.
350  */
351 drm_public int
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,
355                 unsigned int h)
356 {
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;
360
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);
365
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);
370
371         src_w = w;
372         src_h = h;
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;
377
378         dst_w = w;
379         dst_h = w;
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;
384
385         w = MIN(src_w, dst_w);
386         h = MIN(src_h, dst_h);
387
388         if (w <= 0 || h <= 0) {
389                 fprintf(stderr, "invalid width or height.\n");
390                 g2d_reset(ctx);
391                 return -EINVAL;
392         }
393
394         pt.val = 0;
395         pt.data.x = src_x;
396         pt.data.y = src_y;
397         g2d_add_cmd(ctx, SRC_LEFT_TOP_REG, pt.val);
398         pt.val = 0;
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);
402
403         pt.val = 0;
404         pt.data.x = dst_x;
405         pt.data.y = dst_y;
406         g2d_add_cmd(ctx, DST_LEFT_TOP_REG, pt.val);
407         pt.val = 0;
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);
411
412         rop4.val = 0;
413         rop4.data.unmasked_rop3 = G2D_ROP3_SRC;
414         g2d_add_cmd(ctx, ROP4_REG, rop4.val);
415
416         g2d_flush(ctx);
417
418         return 0;
419 }
420
421 /**
422  * g2d_copy_with_scale - copy contents in source buffer to destination buffer
423  *      scaling up or down properly.
424  *
425  * @ctx: a pointer to g2d_context structure.
426  * @src: a pointer to g2d_image structure including image and buffer
427  *      information to source.
428  * @dst: a pointer to g2d_image structure including image and buffer
429  *      information to destination.
430  * @src_x: x start position to source buffer.
431  * @src_y: y start position to source buffer.
432  * @src_w: width value to source buffer.
433  * @src_h: height value to source buffer.
434  * @dst_x: x start position to destination buffer.
435  * @dst_y: y start position to destination buffer.
436  * @dst_w: width value to destination buffer.
437  * @dst_h: height value to destination buffer.
438  * @negative: indicate that it uses color negative to source and
439  *      destination buffers.
440  */
441 drm_public int
442 g2d_copy_with_scale(struct g2d_context *ctx, struct g2d_image *src,
443                                 struct g2d_image *dst, unsigned int src_x,
444                                 unsigned int src_y, unsigned int src_w,
445                                 unsigned int src_h, unsigned int dst_x,
446                                 unsigned int dst_y, unsigned int dst_w,
447                                 unsigned int dst_h, unsigned int negative)
448 {
449         union g2d_rop4_val rop4;
450         union g2d_point_val pt;
451         unsigned int scale;
452         unsigned int scale_x, scale_y;
453
454         g2d_add_cmd(ctx, DST_SELECT_REG, G2D_SELECT_MODE_BGCOLOR);
455         g2d_add_cmd(ctx, DST_COLOR_MODE_REG, dst->color_mode);
456         g2d_add_base_addr(ctx, dst, g2d_dst);
457         g2d_add_cmd(ctx, DST_STRIDE_REG, dst->stride);
458
459         g2d_add_cmd(ctx, SRC_SELECT_REG, G2D_SELECT_MODE_NORMAL);
460         g2d_add_cmd(ctx, SRC_COLOR_MODE_REG, src->color_mode);
461         g2d_add_base_addr(ctx, src, g2d_src);
462         g2d_add_cmd(ctx, SRC_STRIDE_REG, src->stride);
463
464         if (src_w == dst_w && src_h == dst_h)
465                 scale = 0;
466         else {
467                 scale = 1;
468                 scale_x = g2d_get_scaling(src_w, dst_w);
469                 scale_y = g2d_get_scaling(src_h, dst_h);
470         }
471
472         if (src_x + src_w > src->width)
473                 src_w = src->width - src_x;
474         if (src_y + src_h > src->height)
475                 src_h = src->height - src_y;
476
477         if (dst_x + dst_w > dst->width)
478                 dst_w = dst->width - dst_x;
479         if (dst_y + dst_h > dst->height)
480                 dst_h = dst->height - dst_y;
481
482         if (src_w <= 0 || src_h <= 0 || dst_w <= 0 || dst_h <= 0) {
483                 fprintf(stderr, "invalid width or height.\n");
484                 g2d_reset(ctx);
485                 return -EINVAL;
486         }
487
488         if (negative) {
489                 g2d_add_cmd(ctx, BG_COLOR_REG, 0x00FFFFFF);
490                 rop4.val = 0;
491                 rop4.data.unmasked_rop3 = G2D_ROP3_SRC^G2D_ROP3_DST;
492                 g2d_add_cmd(ctx, ROP4_REG, rop4.val);
493         } else {
494                 rop4.val = 0;
495                 rop4.data.unmasked_rop3 = G2D_ROP3_SRC;
496                 g2d_add_cmd(ctx, ROP4_REG, rop4.val);
497         }
498
499         if (scale) {
500                 g2d_add_cmd(ctx, SRC_SCALE_CTRL_REG, G2D_SCALE_MODE_BILINEAR);
501                 g2d_add_cmd(ctx, SRC_XSCALE_REG, scale_x);
502                 g2d_add_cmd(ctx, SRC_YSCALE_REG, scale_y);
503         }
504
505         pt.val = 0;
506         pt.data.x = src_x;
507         pt.data.y = src_y;
508         g2d_add_cmd(ctx, SRC_LEFT_TOP_REG, pt.val);
509         pt.val = 0;
510         pt.data.x = src_x + src_w;
511         pt.data.y = src_y + src_h;
512         g2d_add_cmd(ctx, SRC_RIGHT_BOTTOM_REG, pt.val);
513
514         pt.val = 0;
515         pt.data.x = dst_x;
516         pt.data.y = dst_y;
517         g2d_add_cmd(ctx, DST_LEFT_TOP_REG, pt.val);
518         pt.val = 0;
519         pt.data.x = dst_x + dst_w;
520         pt.data.y = dst_y + dst_h;
521         g2d_add_cmd(ctx, DST_RIGHT_BOTTOM_REG, pt.val);
522
523         g2d_flush(ctx);
524
525         return 0;
526 }
527
528 /**
529  * g2d_blend - blend image data in source and destination buffers.
530  *
531  * @ctx: a pointer to g2d_context structure.
532  * @src: a pointer to g2d_image structure including image and buffer
533  *      information to source.
534  * @dst: a pointer to g2d_image structure including image and buffer
535  *      information to destination.
536  * @src_x: x start position to source buffer.
537  * @src_y: y start position to source buffer.
538  * @dst_x: x start position to destination buffer.
539  * @dst_y: y start position to destination buffer.
540  * @w: width value to source and destination buffer.
541  * @h: height value to source and destination buffer.
542  * @op: blend operation type.
543  */
544 drm_public int
545 g2d_blend(struct g2d_context *ctx, struct g2d_image *src,
546                 struct g2d_image *dst, unsigned int src_x,
547                 unsigned int src_y, unsigned int dst_x, unsigned int dst_y,
548                 unsigned int w, unsigned int h, enum e_g2d_op op)
549 {
550         union g2d_point_val pt;
551         union g2d_bitblt_cmd_val bitblt;
552         union g2d_blend_func_val blend;
553         unsigned int src_w = 0, src_h = 0, dst_w = 0, dst_h = 0;
554
555         bitblt.val = 0;
556         blend.val = 0;
557
558         if (op == G2D_OP_SRC || op == G2D_OP_CLEAR)
559                 g2d_add_cmd(ctx, DST_SELECT_REG, G2D_SELECT_MODE_BGCOLOR);
560         else
561                 g2d_add_cmd(ctx, DST_SELECT_REG, G2D_SELECT_MODE_NORMAL);
562
563         g2d_add_cmd(ctx, DST_COLOR_MODE_REG, dst->color_mode);
564         g2d_add_base_addr(ctx, dst, g2d_dst);
565         g2d_add_cmd(ctx, DST_STRIDE_REG, dst->stride);
566
567         g2d_add_cmd(ctx, SRC_SELECT_REG, src->select_mode);
568         g2d_add_cmd(ctx, SRC_COLOR_MODE_REG, src->color_mode);
569
570         switch (src->select_mode) {
571         case G2D_SELECT_MODE_NORMAL:
572                 g2d_add_base_addr(ctx, src, g2d_src);
573                 g2d_add_cmd(ctx, SRC_STRIDE_REG, src->stride);
574                 break;
575         case G2D_SELECT_MODE_FGCOLOR:
576                 g2d_add_cmd(ctx, FG_COLOR_REG, src->color);
577                 break;
578         case G2D_SELECT_MODE_BGCOLOR:
579                 g2d_add_cmd(ctx, BG_COLOR_REG, src->color);
580                 break;
581         default:
582                 fprintf(stderr , "failed to set src.\n");
583                 return -EINVAL;
584         }
585
586         src_w = w;
587         src_h = h;
588         if (src_x + w > src->width)
589                 src_w = src->width - src_x;
590         if (src_y + h > src->height)
591                 src_h = src->height - src_y;
592
593         dst_w = w;
594         dst_h = h;
595         if (dst_x + w > dst->width)
596                 dst_w = dst->width - dst_x;
597         if (dst_y + h > dst->height)
598                 dst_h = dst->height - dst_y;
599
600         w = MIN(src_w, dst_w);
601         h = MIN(src_h, dst_h);
602
603         if (w <= 0 || h <= 0) {
604                 fprintf(stderr, "invalid width or height.\n");
605                 g2d_reset(ctx);
606                 return -EINVAL;
607         }
608
609         bitblt.data.alpha_blend_mode = G2D_ALPHA_BLEND_MODE_ENABLE;
610         blend.val = g2d_get_blend_op(op);
611         g2d_add_cmd(ctx, BITBLT_COMMAND_REG, bitblt.val);
612         g2d_add_cmd(ctx, BLEND_FUNCTION_REG, blend.val);
613
614         pt.val = 0;
615         pt.data.x = src_x;
616         pt.data.y = src_y;
617         g2d_add_cmd(ctx, SRC_LEFT_TOP_REG, pt.val);
618         pt.val = 0;
619         pt.data.x = src_x + w;
620         pt.data.y = src_y + h;
621         g2d_add_cmd(ctx, SRC_RIGHT_BOTTOM_REG, pt.val);
622
623         pt.val = 0;
624         pt.data.x = dst_x;
625         pt.data.y = dst_y;
626         g2d_add_cmd(ctx, DST_LEFT_TOP_REG, pt.val);
627         pt.val = 0;
628         pt.data.x = dst_x + w;
629         pt.data.y = dst_y + h;
630         g2d_add_cmd(ctx, DST_RIGHT_BOTTOM_REG, pt.val);
631
632         g2d_flush(ctx);
633
634         return 0;
635 }
636