blob: ec943a7fb032b7b2517874725394e4244f4bf240 [file] [log] [blame]
Jian Caob9fb3ed2019-04-16 16:51:27 +08001/*
2 * Copyright (c) 2014 Amlogic, Inc. All rights reserved.
3 *
4 * This source code is subject to the terms and conditions defined in the
5 * file 'LICENSE' which is part of this source code package.
6 *
7 * Description:
8 */
9libge2d user guide
10API:
11int ge2d_open(void);
12int ge2d_close(int fd);
13int ge2d_process(int fd,aml_ge2d_info_t *pge2dinfo);
14
15
16typedef struct aml_ge2d_info {
17 unsigned int offset;
18 unsigned int blend_mode;
19 GE2DOP ge2d_op;
20 buffer_info_t src_info[2];
21 buffer_info_t dst_info;
22 unsigned int color;
23 unsigned int gl_alpha;
24 unsigned int const_color;
Cao Jian65331472019-11-01 21:01:49 +080025 unsigned int dst_op_cnt;
Jian Caob9fb3ed2019-04-16 16:51:27 +080026 unsigned int reserved;
27} aml_ge2d_info_t;
28
29some bits of struct aml_ge2d_info:
30unsigned int offset: y_offset of osd
31unsigned int blend_mode: only valid when work under blend operation
32unsigned int color: only valid when fillrectangle operation
33GE2DOP ge2d_op: supported ge2d operation
34supported ge2d operation include:
35 AML_GE2D_FILLRECTANGLE,
36 AML_GE2D_BLEND,
37 AML_GE2D_STRETCHBLIT,
38 AML_GE2D_BLIT,
39
40typedef struct buffer_info {
41 unsigned int mem_alloc_type;
42 unsigned int memtype;
43 char* vaddr;
44 unsigned long offset;
45 unsigned int canvas_w;
46 unsigned int canvas_h;
47 rectangle_t rect;
48 int format;
49 unsigned int rotation;
50 int shared_fd;
51 unsigned char plane_alpha;
52 unsigned char layer_mode;
53 unsigned char fill_color_en;
54 unsigned int def_color;
55} buffer_info_t;
56some bits of struct buffer_info:
57mem_alloc_type: if used as ion alloc or dma_buf alloc
58memtype: if used as mem alloc:CANVAS_ALLOC
59 if used as OSD0/OSD1:CANVAS_OSD0/CANVAS_OSD1
60char* vaddr: not need set,for debug
61int shared_fd: shared buffer fd, alloc by ion or dma_buf
62unsigned offset: buffer offset, default is 0
63unsigned int canvas_w,
64unsigned int canvas_h: if used as mem alloc,for src1, set it to rect.w, rect.h;
65 for dst, set it to canvas width,canvas height,
66 related to mem size.
67 if used as OSD0/OSD1,leave it unset,it will set by kernel;
68int format: if used as mem alloc,set pixel format
69 if used as OSD0/OSD1,leave it unset,it will set by kernel;
70rectangle_t rect: must be set,set it according real rect value.
71unsigned int rotation: it can be set GE2D_ROTATION,rotation 0/90/180/270;
72
731. AML_GE2D_FILLRECTANGLE need set content:
74src_info[0];
75dst_info;
76color;
77offset;
78
792.AML_GE2D_BLEND need set content:
80src_info[0];
81src_info[1];
82dst_info;
83blend_mode;
84offset;
85
863.AML_GE2D_STRETCHBLIT need set content:
87src_info[0];
88dst_info;
89offset;
90
913.AML_GE2D_BLIT need set content:
92src_info[0];
93dst_info;
94offset;
95
96/////////////////////////////////////////////////////////////////
97The test application include ge2d_load_test and ge2d_feature test.
98ge2d_load_test provide ge2d loading test.
99 ge2d_load_test --op 2 --duration 3000 --size 1920x1080 --pixelformat 0
100 --op <0:fillrect, 1:blend, 2:strechblit, 3:blit> ge2d operation case.
101 --size <WxH> define src1/src2/dst size.
102 --src1_memtype <0: ion, 1: dmabuf> define memory alloc type.
103 --src2_memtype <0: ion, 1: dmabuf> define memory alloc type.
104 --dst_memtype <0: ion, 1: dmabuf> define memory alloc type.
Cao Jian65331472019-11-01 21:01:49 +0800105 --src1_format <num> define src1 format.
Jian Caob9fb3ed2019-04-16 16:51:27 +0800106 --src2_format <num> define src2 format.
107 --dst_format <num> define dst format.
Cao Jian65331472019-11-01 21:01:49 +0800108 --src1_size <WxH> define src1 size.
Jian Caob9fb3ed2019-04-16 16:51:27 +0800109 --src2_size <WxH> define src2 size.
110 --dst_size <WxH> define dst size.
Cao Jian65331472019-11-01 21:01:49 +0800111 --src1_file <name> define src1 file.
Jian Caob9fb3ed2019-04-16 16:51:27 +0800112 --src2_file <name> define src2 file.
113 --dst_file <name> define dst file.
Cao Jian65331472019-11-01 21:01:49 +0800114 --src1_canvas_alloc <num> define whether src1 need alloc mem 0:GE2D_CANVAS_OSD0 1:GE2D_CANVAS_ALLOC.
Jian Caob9fb3ed2019-04-16 16:51:27 +0800115 --src2_canvas_alloc <num> defien whether src2 need alloc mem 0:GE2D_CANVAS_OSD0 1:GE2D_CANVAS_ALLOC.
Cao Jian65331472019-11-01 21:01:49 +0800116 --src1_rect <x_y_w_h> define src1 rect.
Jian Caob9fb3ed2019-04-16 16:51:27 +0800117 --src2_rect <x_y_w_h> define src2 rect.
118 --dst_rect <x_y_w_h> define dst rect.
119 --bo1 <layer_mode_num> define src1_layer_mode.
120 --bo2 <layer_mode_num> define src2_layer_mode.
121 --gb1 <gb1_alpha> define src1 global alpha.
122 --gb2 <gb2_alpha> define src2 global alpha.
123 --strechblit <x0_y0_w_h-x1_y1_w1_h1> define strechblit info.
124 --fillrect <color_x_y_w_h> define fillrect info, color in rgba format.
Cao Jian65331472019-11-01 21:01:49 +0800125 --src2_planenumber <num> define src2 plane number.
126 --src1_planenumber <num> define src1 plane number.
127 --dst_planenumber <num> define dst plane number.
Jian Caob9fb3ed2019-04-16 16:51:27 +0800128 --help Print usage information.
129note: tester can change memtype to GE2D_CANVAS_ALLOC/GE2D_CANVAS_OSD0/GE2D_CANVAS_OSD1 as your requirement
130 if src1 memtype is GE2D_CANVAS_ALLOC, it can read data from file via aml_read_file.
131
132note: tester can change memtype to GE2D_CANVAS_ALLOC/GE2D_CANVAS_OSD0/GE2D_CANVAS_OSD1 as your requirement
133 if src1 memtype is GE2D_CANVAS_ALLOC, you can read data from file via aml_read_file_src1
134 if src2 memtype is GE2D_CANVAS_ALLOC, you can read data from file via aml_read_file_src2
135 if dst memtype is GE2D_CANVAS_ALLOC, you can write data to file aml_write_file
136
137ge2d_feature_test provide ge2d operation example.
138//src used ion alloc, dst used osd
Cao Jian65331472019-11-01 21:01:49 +0800139./ge2d_feature_test --op 2 --src1_memtype 0 --dst_memtype 0 --size 1920x1080 --src1_format 1 --dst_format 1 --src1_file 1080P_RGBA8888.rgb32
Jian Caob9fb3ed2019-04-16 16:51:27 +0800140//src used dma_buf alloc, dst used osd
Cao Jian65331472019-11-01 21:01:49 +0800141./ge2d_feature_test --op 2 --src1_memtype 1 --dst_memtype 1 --size 1920x1080 --src1_format 1 --dst_format 1 --src1_file 1080P_RGBA8888.rgb32
Jian Caob9fb3ed2019-04-16 16:51:27 +0800142
143//src used ion alloc, dst used dma_buf alloc
Cao Jian65331472019-11-01 21:01:49 +0800144./ge2d_feature_test --op 2 --src1_memtype 0 --dst_memtype 1 --size 1920x1080 --src1_format 1 --dst_format 1 --src1_file 1080P_RGBA8888.rgb32 --dst_file out_dma.rgb32
Jian Caob9fb3ed2019-04-16 16:51:27 +0800145
146//src used dma_buf alloc, dst used ion alloc
Cao Jian65331472019-11-01 21:01:49 +0800147./ge2d_feature_test --op 2 --src1_memtype 1 --dst_memtype 0 --size 1920x1080 --src1_format 1 --dst_format 1 --src1_file 1080P_RGBA8888.rgb32 --dst_file out_ion.rgb32
Jian Caob9fb3ed2019-04-16 16:51:27 +0800148
149//src used dma_buf alloc, dst used dma_buf alloc
Cao Jian65331472019-11-01 21:01:49 +0800150./ge2d_feature_test --op 2 --src1_memtype 1 --dst_memtype 1--size 1920x1080 --src1_format 1 --dst_format 1 --src1_file 1080P_RGBA8888.rgb32 --dst_file out_ion.rgb32
Jian Caob9fb3ed2019-04-16 16:51:27 +0800151
152
153
154
155if dma buffer is allocated by ge2d, please add content blow in DTS:
156
157/ {
158 /* ...... */
159 reserved-memory {
160 /* ...... */
161 ge2d_cma_reserved:linux,ge2d_cma {
162 compatible = "shared-dma-pool";
163 reusable;
164 status = "okay";
165 size = <0x0 0x1800000>;
166 alignment = <0x0 0x400000>;
167 };
168 }
169 /* ...... */
170 ge2d {
171 /* ...... */
172 memory-region = <&ge2d_cma_reserved>;
173 };
174}
175
176
177usage examples:
178fillrect ---
Cao Jian65331472019-11-01 21:01:49 +0800179./ge2d_feature_test --op 0 --dst_size 1920x1080 --src1_format 1 --dst_format 1 --fillrect 0x00ff00ff_50_50_100_100 --dst_file fillrect.rgb32
Jian Caob9fb3ed2019-04-16 16:51:27 +0800180
181blend ---
Cao Jian65331472019-11-01 21:01:49 +0800182./ge2d_feature_test --op 1 --dst_size 1920x1080 --dst_rect 100_100_400_400 --src1_size 1920x1080 --src1_rect 100_100_400_400 --src2_size 400x400 --src2_rect 0_0_400_400 --dst_format 1 --src1_format 1 --src2_format 1 --src1_file 1080P_RGBA8888.rgb32 --src2_file 400x400_RGBA8888.rgb32 --bo1 2 --bo2 2 --gb1 150 --gb2 255 --dst_file blend.rgb32
Jian Caob9fb3ed2019-04-16 16:51:27 +0800183
184strechblit ---
Cao Jian65331472019-11-01 21:01:49 +0800185./ge2d_feature_test --op 2 --size 1920x1080 --src1_format 1 --dst_format 1 --strechblit 0_0_1920_100-50_50_200_300 --src1_file 1080P_RGBA8888.rgb32 --dst_file strechblit.rgb32
Jian Caob9fb3ed2019-04-16 16:51:27 +0800186
187blit ---
Cao Jian65331472019-11-01 21:01:49 +0800188./ge2d_feature_test --op 3 --size 1920x1080 --src1_format 1 --dst_format 1 --src1_rect 0_0_1920_100 --dst_rect 0_0_1920_100 --src1_file 1080P_RGBA8888.rgb32 --dst_file blit.rgb32
189multiplane fd support:
190add options para if needed:
191--src1_planenumber 1 src2_planenumber 1 --dst_planenumber 1
192--src1_planenumber 2 src2_planenumber 2 --dst_planenumber 2