Rotate APIs

[中文]

Rotate Interface

The main function of the Rotate module is to rotate the yuv422 image stored in memory into an image in rgb565 format, and store it in another memory after completion

The modules work in three modes:

  1. Rotate clockwise mode

  2. Counterclockwise rotation mode

  3. Format conversion without rotation

  • For rotation, if the input data is RGB565 data, then only rotation is performed

demo run dependent macro configuration:

Name

Description

File

value

CONFIG_HW_ROTATE_PFC

Configures the Rotate function

\middleware\soc\bk7236\bk7236.defconfig

y

Rotate Categories

API Reference

Header File

Functions

bk_err_t bk_rott_driver_init(void)

This API used config sysclk.

Returns

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_rott_soft_reset(void)

This API used reset rotate.

Returns

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_rott_driver_deinit(void)

This API used disable rotate cpu int.

Returns

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_rott_int_enable(rott_int_type_t int_type, bool en)

This API used to config rotate int type and int enable.

Parameters

1:int_type – include:

       - ROTATE_COMPLETE_INT: rotate complete int
       - ROTATE_WARTERMARK_INT: if enable, wtmk_block need config, and not set 0, you can set wtmk_block by api bk_rott_wartermark_block_config config or rott_config
       - ROTATE_CFG_ERR_INT, the following will trigger cfg err int,like:
                        - picture_xpixel & picture_ypixel be zero while working.
                        - ROTATE_WARTERMARK_INT=1, but wtmk_block=0
                        - block_cnt=0
                        - block_xpixel > picture_xpixel,  block_ypixel > picture_ypixel
2: en enable or disable

Returns

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_rott_block_delay_config(bool en, uint16_t delay_hclk_count1, uint16_t delay_hclk_count2)

This API used config rotate delay cycle in block and block interval.

Parameters

- – en,enable the delay function

  • delay_hclk_count1 (range 0 ~ 0x7fff), the delay pclk cycle is calculate by (delay_hclk_count1 * delay_hclk_count2)

  • delay_hclk_count2 (range 0 ~ 0xffff), the delay pclk cycle is calculate by (delay_hclk_count1 * delay_hclk_count2)

Returns

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_rott_mode_config(media_rotate_t rot_mode)

This API used config rotate mode.

Parameters

struct – rott_mode_t

  • ROTT_ONLY_YUV2RGB565, only use yuv data pixel convert to rgb565 pixel, no rotate

  • ROTT_ROTATE90, if rot_input_fmt = RGB565, just rotate; if rot_input_fmt = yuv, not only rotate but convert to rgb565.

  • ROTT_ROTATE170,if rot_input_fmt = RGB565, just rotate; if rot_input_fmt = yuv, not only rotate but convert to rgb565.

Returns

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_rott_input_data_format(pixel_format_t rot_input_fmt)

This API used config input data format, output data format is default rgb565.

Attention

if your data rotate or pixel convert not display normally,you can use api bk_rott_data_reverse modify input/output data flow to see see

Parameters

struct – rott_input_fmt_t

  • RGB565, input format is rgb565 be

  • RGB565le, input format is rgb565 le

  • ROTT_FMT_YUYV

  • ROTT_FMT_VUYY

  • others

Returns

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_rott_data_reverse(rott_input_data_flow_t input_flow, rott_output_data_flow_t output_flow)

This API used config input data or output data flip(reverse)

Attention

if your data rotate or pixel convert not display normally,you can use api bk_rott_data_reverse modify input/output data flow to see see

Parameters
  • struct – rott_input_data_flow_t

    • ROTT_INPUT_NORMAL just input data, no flip

    • ROTT_INPUT_REVESE_BYTE_BY_BYTE, input data input convert or flip byte by byte

    • ROTT_INPUT_REVESE_HALFWORD_BY_HALFWORD, the input convert or flip halfword by halfword

  • struct – rott_output_data_flow_t

    • ROTT_OUTPUT_NORMAL just output data, no flip outpuy

    • ROTT_OUTPUT_REVESE_HALFWORD_BY_HALFWORD, convert output data reversed(flip) halfword by halfword

Returns

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_rott_block_rotate_config(uint16_t picture_xpixel, uint16_t picture_ypixel, uint16_t block_xpixel, uint16_t block_ypixel, uint16_t block_cnt)

This API used config rotate param, rotate is by block, a block is max 4800 pixel,so (block_xpixel * block_ypixel) not over then 4800.

Param

bk_err_t bk_rott_wr_addr_config(uint32_t rd_base_addr, uint32_t wr_base_addr)

This API used config rotate src/dst addr.

Param

bk_err_t bk_rott_wartermark_block_config(uint16_t wtmk_block)

This API used config block threshold value,must make sure you enable ROTATE_WARTERMARK_INT int.

Usage example:

     A 640X480 picture, the param can set [640,480,80,60,64], you can set wtmk_block 32 or 16 or 48 or other less then block_cnt value

Parameters

wtmk_block – when rotate block is wtmk_block, will trigger ROTATE_WARTERMARK_INT

Returns

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_rott_enable(void)

This API used enable rotate, when rotate complete once, you should enable again to rotate.

Returns

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_rott_soft_rst(void)

This API used reset ROTATE hardware logic.

Returns

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_rott_isr_register(rott_isr_t rott_isr)

This API register rotate isr.

Param

bk_err_t bk_rott_int_status_clear(rott_int_type_t int_type)

This API used to clear int status.

Usage example:

  if ((bk_rott_int_status_get() & ROTATE_COMPLETE_INT))
   bk_rott_int_status_clear(ROTATE_COMPLETE_INT);

Parameters

- – int type: you should used with bk_rott_int_status_get() api

Returns

  • BK_OK: succeed

  • others: other errors.

uint32_t bk_rott_int_status_get(void)

This API get int status.

Returns

  • the int status value

bk_err_t rott_config(rott_config_t *rott)

This API is concentrate multiple api to realize rotate config.

Usage example:

 - you can realize only yuv to  rgb565 no rotate mode like this:
     rott.rot_mode = ROTT_ONLY_YUV2RGB565
     rott.input_addr = (void*)&yuyv_640_480[0];
     rott.output_addr = (uint8_t *)0x60000000;
     rott.input_fmt = PIXEL_FMT_YUYV;
     rott.input_flow = ROTT_INPUT_NORMAL;
     rott.output_flow = ROTT_OUTPUT_REVESE_HALFWORD_BY_HALFWORD;
     rott.picture_xpixel = 640;
     rott.picture_ypixel = 480;
     rott.block_xpixel = 80;
     rott.block_ypixel = 60;
     rott.block_cnt = 64;
     rott.watermark_blk = 32;
     rott_config(&rott);

 - you can realize only yuyv to  rgb565 rotate 270 mode like this:
     rott.rot_mode = ROTT_ROTATE270;
     rott.input_addr = (void*)&yuyv_640_480[0];
     rott.output_addr = (uint8_t *)0x60000000;
     rott.input_fmt = PIXEL_FMT_YUYV;
     rott.input_flow = ROTT_INPUT_NORMAL;
     rott.output_flow = ROTT_OUTPUT_REVESE_HALFWORD_BY_HALFWORD;
     rott.picture_xpixel = ROTT_XPIXE;
     rott.picture_ypixel = ROTT_YPIXE;
     rott.block_xpixel = ROTT_XBLOCK;
     rott.block_ypixel = ROTT_YBLOCK;
     rott.block_cnt = ROTT_BLOCK_NUM;
     rott.watermark_blk = ROTT_BLOCK_NUM >> 1;
     rott_config(&rott);


 - you can realize only  rgb565 rotate 270 mode like this:
     rott.rot_mode = ROTT_ROTATE270;
     rott.input_fmt = PIXEL_FMT_RGB565;
     rott.input_addr = XXXX;
     .................

Parameters

struct – rott_input_data_flow_t

  • those params is the same as every solo api

Returns

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_rott_transfer_ability(rott_trans_ability_t ability)

set ahb master busrt len.

Parameters

0:64 – word per busrt; 1:32;2:16; 3:8; 4:4

API Typedefs

Header File

Structures

struct rott_config_t

Public Members

media_rotate_t rot_mode

bypass rotating, only use yuv2rgb565 pixel formart convert function

void *input_addr

input data addr

void *output_addr

output data addr

pixel_format_t input_fmt

pixel format, output rgb565 always

rott_input_data_flow_t input_flow

input data convert or not

rott_output_data_flow_t output_flow

output data convert or not

uint16_t picture_xpixel

image width

uint16_t picture_ypixel

image height

uint16_t block_xpixel

the following is optional, but should make sure rott_driver.c’s TABLE_ROTT_BLOCK table is include used x/y pixel image width separated block width , must be devisible by picture_xpixel

uint16_t block_ypixel

image height separated block height, must be devisible by picture_ypixel

uint16_t block_cnt

block counts, must be (picture_xpixel/block_xpixel)*(picture_ypixel/block_ypixel) cnt

uint16_t watermark_blk

if enable watermark enable, you should config watermark_blk, normally defult one-half block cnt

Macros

USE_ROTT_REGISTER_CALLBACKS
BK_ERR_ROTT_NOT_INIT

rotate driver not init

Type Definitions

typedef void (*rott_isr_t)(void)

Enumerations

enum rott_trans_ability_t

Values:

enumerator ROTATE_BURST_64
enumerator ROTATE_BURST_32
enumerator ROTATE_BURST_16
enumerator ROTATE_BURST_8
enumerator ROTATE_BURST_4
enum rott_int_type_t

Values:

enumerator ROTATE_COMPLETE_INT

rotate finish int enable

enumerator ROTATE_WARTERMARK_INT

rotate watermark int enable.

enumerator ROTATE_CFG_ERR_INT

rotate config error int enable

enum rott_input_data_flow_t

Values:

enumerator ROTT_INPUT_NORMAL

input data not flip

enumerator ROTT_INPUT_REVESE_BYTE_BY_BYTE

convert input data revese byte by byte.

enumerator ROTT_INPUT_REVESE_HALFWORD_BY_HALFWORD

convert input data revese halfword by halfword

enum rott_output_data_flow_t

Values:

enumerator ROTT_OUTPUT_NORMAL

output data not flip

enumerator ROTT_OUTPUT_REVESE_HALFWORD_BY_HALFWORD

convert output data reverse halfword by halfword