Freescale Semiconductor Document Number: IMX6G2DAPIUG User’s Guide Rev. L3.10.17_1.0.0-ga, 05/2014
i.MX 6 G2D API User’s
? 2014 Freescale Semiconductor, Inc. All rights reserved.
Guide
1. Overview
G2D API (Application Programming Interface) is designed for the purposes of easy to understand and use 2D BLT function. It allows the user to implement the customized applications with the simple interfaces. It is hardware and platform independent for i.MX 6 2D Graphics. G2D API supports the following features but not limited: - Simple BLT operation from source to destination
- Alpha blend for source and destination with Porter-Duff rules - High performance memory copy from source to destination - Up-scaling and down-scaling from source to destination - 90/180/270 degree rotation from source to destination - Horizontal and vertical flip from source to destination - Enhanced visual quality with dither for pixel precision-loss - High performance memory clear for destination - Pixel-level cropping for source surface - Global alpha blend for source only - Asynchronous mode and sync - Contiguous memory allocator - Support VG engine
G2D API document include the detailed interface description, and sample code for reference. The API is designed with C-Style and can be used in both C and C++ application.
i.MX 6 G2D API User’s Guide, Rev. L3.10.17_1.0.0-ga, 05/2014
Freescale Semiconductor, Inc.
2
Contents
1.
Overview .............................................................................................................................................................2 2. Enumerations and Structures ...............................................................................................................................4 2.1 g2d_format enumeration ................................................................................................................................4 2.2 g2d_blend_func enumeration .........................................................................................................................4 2.3 g2d_cap_mode enumeration ..........................................................................................................................5 2.4 g2d_rotation enumeration ..............................................................................................................................5 2.5 g2d_cache_mode enumeration ......................................................................................................................5 2.6 g2d_hardware_type enumeration ..................................................................................................................5 2.7 g2d_surface structure......................................................................................................................................6 2.8 g2d_buf structure ............................................................................................................................................7 3. G2D Function Descriptions ...................................................................................................................................8 3.1 g2d_open ........................................................................................................................................................8 3.2 g2d_close ........................................................................................................................................................8 3.3 g2d_make_current .........................................................................................................................................9 3.4 g2d_clear ........................................................................................................................................................9 3.5 g2d_blit ........................................................................................................................................................ 10 3.6 g2d_copy ...................................................................................................................................................... 10 3.7 g2d_query_cap ............................................................................................................................................ 11 3.8 g2d_enable .................................................................................................................................................. 11 3.9 g2d_disable .................................................................................................................................................. 11 3.10 g2d_cache_op ............................................................................................................................................ 12 3.11 g2d_alloc .................................................................................................................................................... 12 3.12 g2d_free ..................................................................................................................................................... 12 3.13 g2d_flush ................................................................................................................................................... 13 3.14 g2d_finish .................................................................................................................................................. 13 4. Sample Codes for G2D API Usage ...................................................................................................................... 14 4.1 Color space conversion from YUV to RGB ..................................................................................................... 14 4.2 Alpha blend in Source Over mode ................................................................................................................. 15 4.3 Source cropping and destination rotation .................................................................................................... 16
i.MX 6 G2D API User’s Guide, Rev. L3.10.17_1.0.0-ga, 05/2014 Freescale Semiconductor, Inc.
3
2. Enumerations and Structures
This chapter describes all Enumeration and Structure definition in G2D.
2.1 g2d_format enumeration
The Enumeration describes the pixel format for source and destination Name G2D_RGB565 G2D_RGBA8888 G2D_RGBX8888 G2D_BGRA8888 G2D_BGRX8888 G2D_BGR565 G2D_ARGBA8888 G2D_ABGR8888 G2D_XRGB8888 G2D_XBGR8888 G2D_NV12 G2D_I420 G2D_YV12 G2D_NV21 G2D_YUYV G2D_YVYU G2D_UYVY G2D_VYUY G2D_NV16 G2D_NV61 Numeric 0 1 2 3 4 5 6 7 8 9 20 21 22 23 24 25 26 27 28 29 Description RGB565 pixel format 32bit-RGBA pixel format 32bit-RGBX without alpha 32bit-BGRA pixel format 32bit-BGRX without alpha 16bit-BGR565 pixel format 32bit-ARGB pixel format 32bit-ABGR pixel format 32bit-XRGB without alpha 32bit-XBGR without alpha Y plane followed by interleaved U/V plane Y, U, V are within separate planes Y, V, U are within separate planes Y plane followed by interleaved V/U plane interleaved Y/U/Y/V plane interleaved Y/V/Y/U plane interleaved U/Y/V/Y plane interleaved V/Y/U/Y plane Y plane followed by interleaved U/V plane Y plane followed by interleaved V/U plane
2.2 g2d_blend_func enumeration
The Enumeration describes the blend factor for source and destination Name G2D_ZERO G2D_ONE G2D_SRC_ALPHA G2D_ONE_MINUS_SRC_ALPHA G2D_DST_ALPHA G2D_ONE_MINUS_DST_ALPHA Numeric 0 1 2 3 4 5 Description Blend factor with 0 Blend factor with 1 Blend factor with source alpha Blend factor with 1 - source alpha Blend factor with destination alpha Blend factor with 1 - destination alpha
i.MX 6 G2D API User’s Guide, Rev. L3.10.17_1.0.0-ga, 05/2014
Freescale Semiconductor, Inc.
4
2.3 g2d_cap_mode enumeration
The Enumeration describes the alternative capability in 2D BLT Name G2D_BLEND G2D_DITHER G2D_GLOBAL_ALPHA Numeric 0 1 2 Description Enable alpha blend in 2D BLT Enable dither in 2D BLT Enable global alpha in blend Note: G2D_GLOBAL_ALPHA is only valid when G2D_BLEND is enabled.
2.4 g2d_rotation enumeration
The Enumeration describes the rotation mode in 2D BLT Name G2D_ROTATION_0 G2D_ROTATION_90 G2D_ROTATION_180 G2D_ROTATION_270 G2D_FLIP_H G2D_FLIP_V Numeric 0 1 2 3 4 5 Description No rotation Rotation with 90 degree Rotation with 180 degree Rotation with 270 degree Horizontal flip Vertical flip
2.5 g2d_cache_mode enumeration
The Enumeration describes the cache operation mode Name G2D_CACHE_CLEAN G2D_CACHE_FLUSH G2D_GLOBAL_INVALIDATE Numeric 0 1 2 Description Clean the cacheable buffer Clean and invalidate cacheable buffer Invalidate the cacheable buffer
2.6 g2d_hardware_type enumeration
The Enumeration describes the supported hardware type Name G2D_HARDWARE_2D G2D_HARDWARE_VG Numeric Description 0 2D hardware type by default 1 VG hardware type
i.MX 6 G2D API User’s Guide, Rev. L3.10.17_1.0.0-ga, 05/2014
Freescale Semiconductor, Inc.
5