2.7 g2d_surface structure
The Structure describes the surface with operation attributes g2d_surface Members format planes[3] left top right bottom stride width height blendfunc global_alpha clrcolor rot Type g2d_format int int int int int int int int g2d_blend_func int int g2d_rotation Description Pixel format of surface buffer Physical addresses of surface buffer Left offset in blit rectangle Top offset in blit rectangle Right offset in blit rectangle Left offset in blit rectangle RGB/Y stride of surface buffer Surface width in pixel unit Surface height in pixel unit Alpha blend mode Global alpha value 0~255 Clear color is 32bit RGBA Rotation mode Notes: 1. RGB and YUV formats can be set in source surface, but only RGB format can be set in destination surface.
2. RGB pixel buffer only uses planes [0], buffer address is with 16bytes alignment, NV12: Y in planes [0], UV in planes [1], with 64bytes alignment,
I420: Y in planes [0], U in planes [1], U in planes [2], with 64 bytes alignment
3. The cropped region in source surface is specified with left, top, right and bottom parameters. 4. RGB stride alignment is 16bytes for source and destination surface, NV12 stride alignment is 8bytes for source surface, UV stride = Y stride,
I420 stride alignment is 8bytes for source surface, U stride=V stride = ? Y stride.
5. G2D_ROTATION_0/G2D_FLIP_H/G2D_FLIP_V shall be set in source surface, and the clockwise rotation degree shall be set in destination surface.
6. Application should calculate the rotated position and set it for destination surface. 7. The geometry definition of surface structure is described as below:
i.MX 6 G2D API User’s Guide, Rev. L3.10.17_1.0.0-ga, 05/2014
Freescale Semiconductor, Inc.
6
stridePlanestopleftbottomheightrightwidth
2.8 g2d_buf structure
The Structure describes the buffer used as g2d interfaces. g2d_buf Members buf_handle buf_vaddr buf_paddr buf_size Type void * void * int int Description The handle associated with buffer Virtual address of the buffer Physical address of the buffer The actual size of the buffer
i.MX 6 G2D API User’s Guide, Rev. L3.10.17_1.0.0-ga, 05/2014
Freescale Semiconductor, Inc.
7
3. G2D Function Descriptions
3.1 g2d_open
Description:
Open g2d device and return a handle.
Syntax:
int g2d_open(void **handle);
Parameters:
handle Pointer to receive g2d device handle
Returns:
Success with 0, fail with -1
3.2 g2d_close
Description:
Close g2d device with the handle.
Syntax:
int g2d_close(void *handle);
Parameters:
handle g2d device handle
Returns:
Success with 0, fail with -1
i.MX 6 G2D API User’s Guide, Rev. L3.10.17_1.0.0-ga, 05/2014
Freescale Semiconductor, Inc.
8
3.3 g2d_make_current
Description:
Set the specific hardware type for current context, default is G2D_HARDWARE_2D
Syntax:
int g2d_make_current(void *handle, enum g2d_hardware_type type);
Parameters:
handle g2d device handle type g2d hardware type
Returns:
Success with 0, fail with -1
3.4 g2d_clear
Description:
Clear a specific area
Syntax:
int g2d_clear(void *handle, struct g2d_surface *area);
Parameters:
handle g2d device handle area the area to be cleared
Returns:
Success with 0, fail with -1
i.MX 6 G2D API User’s Guide, Rev. L3.10.17_1.0.0-ga, 05/2014
Freescale Semiconductor, Inc.
9
3.5 g2d_blit
Description:
G2d blit from source to destination with alternative operation (Blend, Dither, etc)
Syntax:
int g2d_blit(void *handle, struct g2d_surface *src, struct g2d_surface *dst);
Parameters:
handle g2d device handle src source surface dst destination surface
Returns:
Success with 0, fail with -1
3.6 g2d_copy
Description:
G2d copy with specified size
Syntax:
int g2d_copy(void *handle, struct g2d_buf *d, struct g2d_buf* s, int size);
Parameters:
handle g2d device handle d destination buffer s source buffer size copy bytes
Limitations:
If the destination buffer is cacheable, it must be invalidated before g2d_copy due to the alignment limitation of g2d driver.
Returns:
Success with 0, fail with -1
i.MX 6 G2D API User’s Guide, Rev. L3.10.17_1.0.0-ga, 05/2014
Freescale Semiconductor, Inc.
10