DRV_DMA2D

[English]

DRV_DMA2D API Status

API

drv_dma2d_init()

drv_dma2d_deinit()

drv_dma2d_init_config()

drv_dma2d_layer_config()

drv_dma2d_clut_config()

drv_dma2d_transfer_start()

drv_dma2d_transfer_stop()

drv_dma2d_transfer_suspend()

drv_dma2d_transfer_abort()

drv_dma2d_is_transfer_done()

drv_dma2d_blending_config()

drv_dma2d_line_Watermar_set()

drv_dma2d_interrupt_enable()

drv_dma2d_interrupt_callback_register()

DRV_DMA2D API Reference

Header File

Functions

int32_t drv_dma2d_init(void)

open DMA2D peripheral clock soft reset dma2d device

返回值:
  • 0 – success [BK_RET_OK]

  • other – fail

返回:

result

int32_t drv_dma2d_deinit(void)

Deinitializes the DMA2D peripheral registers to their default reset values. close dma2d interrupt.

返回值:
  • 0 – success [BK_RET_OK]

  • other – fail

返回:

result

int32_t drv_dma2d_init_config(dma2d_config_t *p_config)

config dma2d work mode/ data format/ offset etc.

you can reference cli_dma2d.c for all API usage

Usage example:

       dma2d_config_t dma2d_config = {0};
       dma2d_config.init_cfg.mode = DMA2D_R2M;                     Mode Register to Memory
       dma2d_config.init_cfg.color_mode = DMA2D_OUTPUT_RGB565;       DMA2D Output color mode is ARGB4444 (16 bpp)
       dma2d_config.init_cfg.output_offset = 0;            No offset in output
       dma2d_config.init_cfg.red_blue_swap = DMA2D_RB_REGULAR;       No R&B swap for the output image
       dma2d_config.init_cfg.alpha_inverted = DMA2D_REGULAR_ALPHA;   No alpha inversion for the output image
       drv_dma2d_init_config(&dma2d_config);

参数:

dma2d_config[in] pointer to a dma2d_config_t structure that contains the configuration information for the DMA2D.

返回值:
  • 0 – success [BK_RET_OK]

  • other – fail

返回:

result

int32_t drv_dma2d_layer_config(dma2d_config_t *p_config, dma2d_layer_e LayerIdx)

Configure the DMA2D background or foreground Layer include layer offset, color mode, alpha value etc.

Usage example:

       dma2d_config.layer_cfg[DMA2D_FOREGROUND_LAYER].alpha_mode = DMA2D_REPLACE_ALPHA;
       dma2d_config.layer_cfg[DMA2D_FOREGROUND_LAYER].input_alpha = alpha_value;
       dma2d_config.layer_cfg[DMA2D_FOREGROUND_LAYER].input_color_mode = DMA2D_INPUT_RGB565;
       dma2d_config.layer_cfg[DMA2D_FOREGROUND_LAYER].input_offset = fg_offline;
       dma2d_config.layer_cfg[DMA2D_FOREGROUND_LAYER].red_blue_swap  = DMA2D_RB_REGULAR;
       dma2d_config.layer_cfg[DMA2D_FOREGROUND_LAYER].alpha_inverted = DMA2D_REGULAR_ALPHA;

       Background layer Configuration
       dma2d_config.layer_cfg[DMA2D_BACKGROUND_LAYER].alpha_mode  = DMA2D_REPLACE_ALPHA;
       dma2d_config.layer_cfg[DMA2D_BACKGROUND_LAYER].input_alpha   = 0x80;
       dma2d_config.layer_cfg[DMA2D_BACKGROUND_LAYER].input_color_mode = DMA2D_INPUT_RGB565;
       dma2d_config.layer_cfg[DMA2D_BACKGROUND_LAYER].input_offset   = bg_offline;
       dma2d_config.layer_cfg[DMA2D_BACKGROUND_LAYER].red_blue_swap   = DMA2D_RB_REGULAR;
       dma2d_config.layer_cfg[DMA2D_BACKGROUND_LAYER].alpha_inverted  = DMA2D_REGULAR_ALPHA;

       bk_dma2d_layer_config(&dma2d_config, DMA2D_FOREGROUND_LAYER);
       bk_dma2d_layer_config(&dma2d_config, DMA2D_BACKGROUND_LAYER);

参数:
  • dma2d[in] Pointer to a dma2d_config_t structure that contains the configuration information for the DMA2D.

  • LayerIdx[in] DMA2D Layer index. This parameter can be one of the following values: DMA2D_BACKGROUND_LAYER(0) / DMA2D_FOREGROUND_LAYER(1)

返回值:
  • 0 – success [BK_RET_OK]

  • other – fail

返回:

result

int32_t drv_dma2d_transfer_config(dma2d_config_t *p_config, uint32_t src_addr, uint32_t dst_addr, uint32_t width, uint32_t height)

Configure the DMA2D Transfer when you use (drv_dma2d_init_config) and (bk_dma2d_layer_config) API, then use this API start dma2d work.

Usage example:

       dma2d_config_t dma2d_config = {0};
       dma2d_config.init_cfg.mode   = DMA2D_R2M;                     Mode Register to Memory
       dma2d_config.init_cfg.color_mode = DMA2D_OUTPUT_RGB565;       DMA2D Output color mode is ARGB4444 (16 bpp)
       dma2d_config.init_cfg.output_offset = 0;          No offset in output
       dma2d_config.init_cfg.red_blue_swap = DMA2D_RB_REGULAR;       No R&B swap for the output image
       dma2d_config.init_cfg.alpha_inverted = DMA2D_REGULAR_ALPHA;   No alpha inversion for the output image

       drv_dma2d_init_config(&dma2d_config);
       bk_dma2d_layer_config(&dma2d_config, color, (uint32_t)dst_addr, width, high);
       drv_dma2d_transfer_start();

参数:
  • dma2d[in] Pointer to a dma2d_config_t structure that contains the configuration information for the DMA2D.

  • src_addr[in] have two means:

    • 1: if the Memory-to-Memory or Memory-to-Memory with pixel format select, should Configure the source memory Buffer address

    • 2: if Register-to-Memory mode is selected, should configure the color value

  • dst_addr[in] The destination memory Buffer address.

  • Width[in] The width of data to be transferred from source to destination (expressed in number of pixels per line).

  • Height[in] The height of data to be transferred from source to destination (expressed in number of lines).

返回值:
  • 0 – success [BK_RET_OK]

  • other – fail

返回:

result

int32_t drv_dma2d_clut_config(dma2d_clut_cfg_t clut_cfg, dma2d_layer_e LayerIdx)

Configure the DMA2D CLUT Transfer.

API obsolete and maintained for compatibility with legacy. User is invited to resort to HAL_DMA2D_CLUTStartLoad() instead to benefit from code compactness, code size and improved heap usage.

参数:
  • dma2d[in] Pointer to a dma2d_config_t structure that contains the configuration information for the DMA2D.

  • CLUTCfg[in] Pointer to a DMA2D_CLUTCfgTypeDef structure that contains the configuration information for the color look up table.

  • LayerIdx[in] DMA2D Layer index. This parameter can be one of the following values: DMA2D_BACKGROUND_LAYER(0) / DMA2D_FOREGROUND_LAYER(1)

返回值:
  • 0 – success [BK_RET_OK]

  • other – fail

返回:

result

int32_t drv_dma2d_transfer_start(void)

Start the DMA2D Transfer when config dma2d finshed, then should use this function to start transfer.

返回值:
  • 0 – success [BK_RET_OK]

  • other – fail

返回:

result

int32_t drv_dma2d_transfer_stop(void)

stop the DMA2D Transfer

返回值:
  • 0 – success [BK_RET_OK]

  • other – fail

返回:

result

int32_t drv_dma2d_transfer_suspend(bool xfer_suspend)

suspend the DMA2D Transfer

返回值:
  • 0 – success [BK_RET_OK]

  • other – fail

返回:

result

int32_t drv_dma2d_transfer_abort(bool xfer_abort)

abort the DMA2D Transfer

返回值:
  • 0 – success [BK_RET_OK]

  • other – fail

返回:

result

bool drv_dma2d_is_transfer_done(void)

check dma2d is transfer busy or not

返回值:
  • 0 – transfer stop or transfer done;

  • 1 – dma2d is work or transfer not done

返回:

transfer busy status

int32_t drv_dma2d_blending_config(dma2d_config_t *p_config, uint32_t src_addr1, uint32_t src_addr2, uint32_t dst_addr, uint32_t Width, uint32_t Height)

Start the multi-source DMA2D Transfer with interrupt enabled.

参数:
  • dma2d – Pointer to a dma2d_config_t structure that contains the configuration information for the DMA2D.

  • src_addr1[in] The source memory Buffer address for the foreground layer.

  • src_addr2[in] The source memory Buffer address for the background layer.

  • dst_addr[in] The destination memory Buffer address.

  • Width[in] The width of data to be transferred from source to destination (expressed in number of pixels per line).

  • Height[in] The height of data to be transferred from source to destination (expressed in number of lines).

返回值:
  • 0 – success [BK_RET_OK]

  • other – fail

返回:

result

int32_t drv_dma2d_line_Watermar_set(uint32_t line)

set the line watermark.

dma2d_hal_line_Watermar_cfg() API used with the transfer watermark interrupt. The transfer watermark interrupt is disabled once it has occurred.

参数:

line[in] Line Watermark configuration (maximum 16-bit long value expected).

返回值:
  • 0 – success [BK_RET_OK]

  • other – fail

返回:

result

int32_t drv_dma2d_interrupt_enable(dma2d_int_type_e int_type, bool enable)

dma2d int enable.

Usage example:

       drv_dma2d_interrupt_enable(DMA2D_TRANS_ERROR | DMA2D_TRANS_COMPLETE ,1);

参数:
  • int_type[in] select from dma2d_int_type_t, include int type:

    • DMA2D_CFG_ERROR

    • DMA2D_CLUT_TRANS_COMPLETE

    • DMA2D_CLUT_TRANS_ERROR

    • DMA2D_WARTERMARK_INT

    • DMA2D_TRANS_COMPLETE

    • DMA2D_TRANS_ERROR

  • enable[in] 1:enable int, 0 disable int

返回值:
  • 0 – success [BK_RET_OK]

  • other – fail

返回:

result

int32_t drv_dma2d_interrupt_callback_register(pfunc_drv_dma2d_cb_t pfn_cb, void *pv_arg)

register dma2d interrupt callback function

参数:
  • pfn_cb[in] callback function

  • pv_arg[in] callback parameter

返回值:
  • 0 – success [BK_RET_OK]

  • other – fail

返回:

result

Structures

struct dma2d_init_cfg_t

DMA2D Init structure definition.

Public Members

dma2d_mode_e mode

Configures the DMA2D transfer mode.his parameter can be one value of DMA2D_Mode.

uint32_t color_mode

Configures the color format of the output image. This parameter can be one value of DMA2D_Output_Color_Mode.

uint32_t output_offset

Specifies the Offset value. This parameter must be a number between Min_Data = 0x0000 and Max_Data = 0x3FFF.

uint32_t alpha_inverted

Select regular or inverted alpha value for the output pixel format converter. This parameter can be one value of DMA2D_Alpha_Inverted.

uint32_t line_offset_mode

Configures how is expressed the line offset for the foreground, background and output. This parameter can be one value of DMA2D_Line_Offset_Mode.

red_blue_swap_e red_blue_swap

Select regular mode (RGB or ARGB) or swap mode (BGR or ABGR) for the output pixel format converter. This parameter can be one value of DMA2D_RB_Swap.

rgb888_dataout_reverse_e data_reverse

in output rgb888 formart, reverse data byte by byte..

dma2d_trans_ability_e trans_ability

set defult MAX_TRANS_256BYTES

struct dma2d_layer_cfg_t

DMA2D Layer structure definition

Public Members

uint32_t input_offset

Configures the DMA2D foreground or background offset. This parameter must be a number between Min_Data = 0x0000 and Max_Data = 0x3FFF.

uint32_t input_color_mode

Configures the DMA2D foreground or background color mode. This parameter can be one value of DMA2D_Input_Color_Mode.

blend_alpha_mode_e alpha_mode

Configures the DMA2D foreground or background alpha mode.This parameter can be one value of DMA2D_Alpha_Mode.

uint32_t input_color

Specifies color value in case of A8 or A4 color mode.

备注

In case of A8 or A4 color mode (ARGB), this parameter must be a number between Min_Data = 0x00000000 and Max_Data = 0xFFFFFF where

  • Inputcolor[16:23] is the red value RED[0:7]

  • Inputcolor[8:15] is the green value GREEN[0:7]

  • Inputcolor[0:7] is the blue value BLUE[0:7].

uint32_t alpha_inverted

Select regular or inverted alpha value.This parameter can be one value of DMA2D_Alpha_Inverted.

red_blue_swap_e red_blue_swap

Select regular mode (RGB or ARGB) or swap mode (BGR or ABGR). This parameter can be one value of DMA2D_RB_Swap.

struct dma2d_config_t

Public Members

dma2d_init_cfg_t init_cfg

dma2d init config, is the value of struct dma2d_init_t

dma2d_layer_cfg_t layer_cfg[MAX_DMA2D_LAYER]

dma2d layer config, is the value of struct dma2d_layer_cfg_t the param MAX_DMA2D_LAYER is select from DMA2D_BACKGROUND_LAYER and DMA2D_FOREGROUND_LAYER

struct dma2d_clut_cfg_t

DMA2D CLUT Structure definition.

Public Members

uint32_t *pclut

Configures the DMA2D CLUT memory address.

uint32_t club_color_mode

Configures the DMA2D CLUT color mode. This parameter can be one value of DMA2D_CLUT_CM.

uint32_t size

Configures the DMA2D CLUT size. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF.

Macros

MAX_DMA2D_LAYER

DMA2D maximum number of layers

DMA2D_REGULAR_ALPHA

No modification of the alpha channel value

DMA2D_INVERTED_ALPHA

Invert the alpha channel value

Type Definitions

typedef void (*pfunc_drv_dma2d_cb_t)(dm2d_isr_id_e isr_id, void *pv_arg)

Enumerations

enum dm2d_isr_id_e

if USE_HAL_DMA2D_REGISTER_CALLBACKS = 1, define int isr register id

Values:

enumerator DMA2D_CFG_ERROR_ISR
enumerator DMA2D_CLUT_TRANS_COMPLETE_ISR
enumerator DMA2D_CLUT_TRANS_ERROR_ISR
enumerator DMA2D_WARTERMARK_INT_ISR
enumerator DMA2D_TRANS_COMPLETE_ISR
enumerator DMA2D_TRANS_ERROR_ISR
enum blend_alpha_mode_e

DMA2D alpha mode

Values:

enumerator DMA2D_NO_MODIF_ALPHA

define DMA2D Alpha Mode: No modification of the alpha channel value

enumerator DMA2D_REPLACE_ALPHA

Replace original alpha channel value by programmed alpha value

enumerator DMA2D_COMBINE_ALPHA

Replace original foreground image alpha channel value by ALPHA[7:0] multiplied with original alpha channel value

enum red_blue_swap_e

DMA2D bule swap define

Values:

enumerator DMA2D_RB_REGULAR

Select regular mode (RGB or ARGB)

enumerator DMA2D_RB_SWAP

Select swap mode (BGR or ABGR) * = 0

enum dma2d_layer_e

DMA2D Layer define

Values:

enumerator DMA2D_BACKGROUND_LAYER

DMA2D Background Layer (layer 0)

enumerator DMA2D_FOREGROUND_LAYER

DMA2D Foreground Layer (layer 1)

enum dma2d_mode_e

DMA2D_Mode

Values:

enumerator DMA2D_M2M

DMA2D memory to memory transfer mode

enumerator DMA2D_M2M_PFC

DMA2D memory to memory with pixel format conversion transfer mode

enumerator DMA2D_M2M_BLEND

DMA2D memory to memory with blending transfer mode

enumerator DMA2D_R2M

DMA2D register to memory transfer mode

enumerator DMA2D_M2M_BLEND_FG

DMA2D memory to memory with blending transfer mode and fixed color FG

enumerator DMA2D_M2M_BLEND_BG

DMA2D memory to memory with blending transfer mode and fixed color BG

enum rgb888_dataout_reverse_e

DMA2D reb888 formart data reverse define

Values:

enumerator NO_REVERSE

in output rgb888 formart, not reverse data byte by byte

enumerator REVERSE

in output rgb888 formart, reverse data byte by byte

enum out_color_mode_e

DMA2D_Output_Color_Mode

Values:

enumerator DMA2D_OUTPUT_ARGB8888

ARGB8888 DMA2D color mode

enumerator DMA2D_OUTPUT_RGB888

RGB888 DMA2D color mode

enumerator DMA2D_OUTPUT_RGB565

RGB565 DMA2D color mode

enumerator DMA2D_OUTPUT_ARGB1555

ARGB1555 DMA2D color mode

enumerator DMA2D_OUTPUT_ARGB4444

ARGB4444 DMA2D color mode

enum input_color_mode_e

DMA2D_Input_Color_Mode

Values:

enumerator DMA2D_INPUT_ARGB8888

ARGB8888 DMA2D color mode

enumerator DMA2D_INPUT_RGB888

RGB888 DMA2D color mode

enumerator DMA2D_INPUT_RGB565

RGB565 DMA2D color mode

enumerator DMA2D_INPUT_ARGB1555

ARGB1555 DMA2D color mode

enumerator DMA2D_INPUT_ARGB4444

ARGB4444 DMA2D color mode

enumerator DMA2D_INPUT_L8
enumerator DMA2D_INPUT_AL44
enumerator DMA2D_INPUT_AL88
enumerator DMA2D_INPUT_L4
enumerator DMA2D_INPUT_A8
enumerator DMA2D_INPUT_A4
enumerator DMA2D_INPUT_YUYV
enum dma2d_int_type_e

dma2d int type

Values:

enumerator DMA2D_CFG_ERROR
enumerator DMA2D_CLUT_TRANS_COMPLETE
enumerator DMA2D_CLUT_TRANS_ERROR
enumerator DMA2D_WARTERMARK_INT
enumerator DMA2D_TRANS_COMPLETE
enumerator DMA2D_TRANS_ERROR
enumerator DMA2D_ALL_INI
enum dma2d_int_status_e

dma2d int status

Values:

enumerator DMA2D_TRANS_ERROR_STATUS
enumerator DMA2D_TRANS_COMPLETE_STATUS
enumerator DMA2D_WARTERMARK_INT_STATUS
enumerator DMA2D_CLUT_TRANS_ERROR_STATUS
enumerator DMA2D_CLUT_TRANS_COMPLETE_STATU
enumerator DMA2D_CFG_ERROR_STATUS
enum dma2d_trans_ability_e

Values:

enumerator MAX_TRANS_256BYTES
enumerator TRANS_192BYTES
enumerator TRANS_128BYTES
enumerator TRANS_64BYTES