3.7 g2d_query_cap
Description:
Query the alternative capability enablement
Syntax:
int g2d_query_cap(void *handle, enum g2d_cap_mode cap, int *enable);
Parameters:
handle g2d device handle cap g2d capability to query
enable Pointer to receive g2d capability enablement
Returns: Success with 0, fail with -1
3.8 g2d_enable
Description:
Enable g2d capability with the specific mode
Syntax:
int g2d_enable(void *handle, enum g2d_cap_mode cap);
Parameters:
handle g2d device handle
cap g2d capability to enable
Returns:
Success with 0, fail with -1
3.9 g2d_disable
Description:
Enable g2d capability with the specific mode
Syntax:
int g2d_disable (void *handle, enum g2d_cap_mode cap);
Parameters:
handle g2d device handle
cap g2d capability to disable
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.
11
3.10 g2d_cache_op
Description:
Perform cache operations for the cacheable buffer allocated through g2d driver
Syntax:
int g2d_cache_op (struct g2d_buf *buf, enum g2d_cache_mode op);
Parameters:
buf the buffer to be handled with cache operations op cache operation type
Returns:
Success with 0, fail with -1
3.11 g2d_alloc
Description:
Allocate a buffer through g2d device
Syntax:
struct g2d_buf *g2d_alloc(int size, int cacheable);
Parameters:
size allocated bytes
cacheable 0, non-cacheable, 1, cacheable attribute defined by system
Returns:
Success with valid g2d buffer pointer, fail with 0
3.12 g2d_free
Description:
Free the buffer through g2d device
Syntax:
int g2d_free(struct g2d_buf *buf);
Parameters:
buf g2d buffer to free
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.
12
3.13 g2d_flush
Description:
Flush g2d command and return without completing pipeline.
Syntax:
int g2d_flush (void *handle);
Parameters:
handle g2d device handle
Returns:
Success with 0, fail with -1
3.14 g2d_finish
Description:
Flush g2d command and then return when pipeline is finished
Syntax:
int g2d_finish (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.
13
4. Sample Codes for G2D API Usage
This chapter provides the brief prototype codes with G2D API.
4.1 Color space conversion from YUV to RGB
g2d_open(&handle);
src.planes[0] = buf_y; src.planes[1] = buf_u; src.planes[2] = buf_v; src.left = crop.left; src.top = crop.top; src.right = crop.right; src.bottom = crop.bottom; src.stride = y_stride; src.width = y_width; src.height = y_height; src.rot = G2D_ROTATION_0; src.format = G2D_I420; dst.planes[0] = buf_rgba; dst.left = 0; dst.top = 0; dst.right = disp_width; dst.bottom = disp_height; dst.stride = disp_width; dst.width = disp_width; dst.height = disp_height; dst.rot = G2D_ROTATION_0; dst.format = G2D_RGBA8888; g2d_blit(handle, &src, &dst); g2d_finish(handle); g2d_close(handle);
i.MX 6 G2D API User’s Guide, Rev. L3.10.17_1.0.0-ga, 05/2014
Freescale Semiconductor, Inc.
14
4.2 Alpha blend in Source Over mode
g2d_open(&handle);
src.planes[0] = src_buf; src.left = 0; src.top = 0; src.right = test_width; src.bottom = test_height; src.stride = test_width; src.width = test_width; src.height = test_height; src.rot = G2D_ROTATION_0; src.format = G2D_RGBA8888; src.blendfunc = G2D_ONE; dst.planes[0] = dst_buf; dst.left = 0; dst.top = 0; dst.right = test_width; dst.bottom = test_height; dst.stride = test_width;
dst.width = test_width;
dst.height = test_height; dst.format = G2D_RGBA8888;
dst.rot = G2D_ROTATION_0;
dst.blendfunc = G2D_ONE_MINUS_SRC_ALPHA;
g2d_enable(handle,G2D_BLEND);
g2d_blit(handle, &src, &dst); g2d_finish(handle);
g2d_disable(handle,G2D_BLEND);
g2d_close(handle);
i.MX 6 G2D API User’s Guide, Rev. L3.10.17_1.0.0-ga, 05/2014
Freescale Semiconductor, Inc.
15