eIQ MPP Hardware Abstraction Layer API
MPP-HAL VERSION 3.5
Chapter 1
This is the documentation for the Hardware Abstraction Layer(HAL) API.
1.1 HAL overview
The hardware abstraction layer is used to abstract hardware and software components. With the usage of an HAL abstraction, the vision pipeline will be leveraging hardware accelerated components whenever possible.
1.1.1 MPP hal description
The HAL is presented with respect of the following points:
A common header file “hal.h” includes all hardware top level functions.
All hardware top level functions are using the prefix: “hal_ “.
For each platform all hal_ functions defined in hal.h should be implemented at least with an empty function.
Here is an overview:
Figure 1.1 HAL overview
1.1.2 MPP HAL components
Camera
Static image
Graphics driver
Vision algorithms
Labeled rectangle
Display
1.1.3 Supported devices
At present, the MPP HAL supports the following devices:
Cameras:
OV5640
MT9M114
OV7670
Logitech C920 PRO HD WEBCAM
Displays:
LVGL
RK055AHD091
RK055MHD091
RK043FN02H-CT
Mikroe TFT Proto 5(SSD1963 controller)
NXP’s LCD-PAR-S035 (ST7796S controller) Graphics:
PXP
CPU
GPU
1.1.4 Supported boards
Currently, the MPP HAL supports the following boards:
(deprecated) evkmimxrt1170 is supported with the following devices:
Cameras: OV5640.
Displays: RK055AHD091 and RK055MHD091.
(deprecated) evkbimxrt1050 is supported with the following devices:
Cameras: MT9M114.
Displays: RK043FN02H-CT.
evkbmimxrt1170 is supported by porting the following devices:
Cameras: OV5640.
Displays: LVGL, RK055AHD091 and RK055MHD091.
frdmmcxn947 is supported by porting the following devices:
Cameras: OV7670.
Displays: Mikroe TFT Proto 5” and NXP’s LCD-PAR-S035.
mimxrt700evk is supported by porting the following devices:
Cameras: OV7670, Logitech C920 PRO HD WEBCAM
Displays: RK055AHD091 and RK055MHD091.
How to port new boards/devices: The MPP Hal provides the flexibility to the user to port new boards and devices(cameras and displays).
Supporting new boards: To support a new board a new file hal_{board_name} should be added under the ‘hal’ directory.
Supporting new devices: The hal components that can support new devices are:
Cameras
Display
Graphics processing
A new device can simply be supported by:
Providing the approriate hal_{device_module} implementation.
Adding his name and setup entry point to the appropriate device list in the associated board hal_{board_name} file.
Enabling/Disabling Hal components and devices:
The HAL components can be enabled/disabled from “mpp_config.h” using the compilation flags(HAL_ENABLE_{component_name}).
The HAL devices can also be enabled/disabled from “mpp_config.h” using the compilation flags(HAL_ENABLE_{device_name}).
Chapter 2
2.1 HAL Types
Data Structures
struct camera_dev_static_config_t
struct camera_dev_t
struct static_image_static_config_t
struct static_image_t
struct gfx_surface_t
struct gfx_rotate_config_t
struct gfx_dev_t
struct hal_rect_t
struct model_param_t
struct vision_frame_t
struct vision_algo_dev_t
struct display_dev_t
struct hw_buf_desc_t
struct hal_img_decoder_setup_t
struct hal_graphics_setup_t
struct hal_display_setup_t
struct hal_camera_setup_t
struct checksum_data_t
Macros
#define HAL_GFX_DEV_CPU_NAME
#define GUI_PRINTF_BUF_SIZE
#define GUI_PRINTF_BUF_SIZE
#define MAX_INPUT_PORTS
#define MAX_OUTPUT_PORTS
#define HAL_DEVICE_NAME_MAX_LENGTH
Typedefs
typedef int(∗ camera_dev_callback_t) (const camera_dev_t ∗dev, camera_event_t event, void ∗param, uint8_t fromISR)
typedef void ∗vision_algo_private_data_t
typedef int(∗mpp_callback_t) (mpp_t mpp, mpp_evt_t evt, void ∗evt_data, void ∗user_data)
typedef int(∗img_decoder_setup_func_t) (vdec_dev_t ∗)
typedef int(∗graphic_setup_func_t) (gfx_dev_t ∗)
typedef int(∗display_setup_func_t) (display_dev_t ∗)
typedef int(∗camera_setup_func_t) (const char ∗, camera_dev_t ∗)
Enumerations
enum hal_camera_status_t {
enum camera_event_t {
enum hal_image_status_t {
enum gfx_rotate_target_t {
kGFXRotateTarget_None,
kGFXRotate_SRCSurface,
kGFXRotate_DSTSurface }
enum hal_valgo_status_t {
enum display_event_t {
enum hal_display_status_t {
enum mpp_memory_policy_t {
enum checksum_type_t {
Functions
int HAL_GfxDev_CPU_Register (gfx_dev_t ∗dev)
int HAL_GfxDev_GPU_Register (gfx_dev_t ∗dev)
int setup_static_image_elt (static_image_t ∗elt)
uint32_t calc_checksum (int size_b, void ∗pbuf)
2.1.1 Detailed Description
This section provides the detailed documentation for the MPP HAL types.
2.1.1.1 Data Structure Documentation
Structure that characterizes the camera device.
Data Fields
type |
name |
description |
---|---|---|
int |
height |
buffer height |
int |
width |
buffer width |
int |
pitch |
buffer pitch |
int |
left |
left position |
int |
top |
top position |
int |
right |
right position |
int |
bottom |
bottom position |
mpp_rotate_degree_t |
rotate |
rotate degree |
mpp_flip_mode_t |
flip |
flip |
int |
swapByte |
swap byte per two bytes |
mpp_pixel_format_t |
format |
pixel format |
int |
framerate |
frame rate |
int |
stripe_size |
stripe size in bytes |
bool |
stripe |
stripe mode |
camera device private capability.
Data Fields
type |
name |
description |
---|---|---|
callback |
callback |
|
void ∗ |
param |
parameter for the callback |
Attributes of a camera device. hal camera device declaration.
Camera devices can enqueue and dequeue frames as well as react to events from input devices via the “input← Notify” function. Camera devices can use any number of interfaces, including MIPI and CSI as long as the HAL driver implements the necessary functions found in camera_dev_operator_t. Examples of camera devices include the Orbbec U1S 3D SLM camera module and the OnSemi MT9M114 camera module.
Data Fields
type |
name |
description |
---|---|---|
int |
id |
unique id which is assigned by camera manager during registration |
char |
ENGTHname of] the device |
|
const camera_dev_operator_t ∗ |
ops |
operations |
config |
static configurations |
|
cap |
private capability |
Structure that characterize the image element.
Data Fields
type |
name |
description |
---|---|---|
int |
height |
buffer height |
int |
width |
buffer width |
int |
left |
left position |
int |
top |
top position |
int |
right |
right position |
int |
bottom |
bottom position |
mpp_pixel_format_t |
format |
pixel format |
bool |
stripe |
stripe mode |
Attributes of an image element.
Data Fields
type |
name |
description |
---|---|---|
int |
id |
unique id which is assigned by image manager |
const static_image_operator_t ∗ |
ops |
operations |
config |
static configs |
|
int |
stripe_idx |
the current stripe index |
uint8_t ∗ |
buffer |
static image buffer |
Gfx surface parameters.
Data Fields
type |
name |
description |
---|---|---|
int |
height |
buffer height |
int |
width |
buffer width |
int |
pitch |
buffer pitch |
int |
left |
left position |
int |
top |
top position |
int |
right |
right position |
int |
bottom |
bottom position |
int |
swapByte |
swap byte per two bytes |
mpp_pixel_format_t |
format |
pixel format |
void ∗ |
buf |
buffer |
void ∗ |
lock |
the structure is determined by hal and set to null if not use in hal |
gfx rotate configuration
Data Fields
type |
name |
description |
---|---|---|
target |
||
mpp_rotate_degree_t |
degree |
Data Fields
type |
name |
description |
---|---|---|
int |
id |
|
const gfx_dev_operator_t ∗ |
ops |
|
src |
||
dst |
||
callback |
||
void ∗ |
user_data |
rectangle positions.
Data Fields
type |
name |
description |
---|---|---|
int |
||
int |
left |
|
int |
bottom |
|
int |
right |
Structure passed to HAL as description of the binary model provided by user.
Data Fields
const void ∗model_data
int model_size
float model_input_mean
float model_input_std
mpp_inference_params_t inference_params
int height
int width
mpp_pixel_format_t format
mpp_tensor_type_t inputType
mpp_tensor_order_t tensor_order
int(∗evt_callback_f )(mpp_t mpp, mpp_evt_t evt, void ∗evt_data, void ∗user_data)
void ∗cb_userdata
Field Documentation
const void∗ model_param_t::model_data pointer to model binary
int model_param_t::model_size model binary size
float model_param_t::model_input_mean
model ‘mean’ of input values, used for normalization
float model_param_t::model_input_std
model ‘standard deviation’ of input values, used for normalization
inference_params
mpp_inference_params_t model_param_t::inference_params inference parameters
int model_param_t::height frame height
int model_param_t::width frame width
mpp_pixel_format_t model_param_t::format pixel format
mpp_tensor_type_t model_param_t::inputType input type
mpp_tensor_order_t model_param_t::tensor_order tensor order
evt_callback_f
int(∗ model_param_t::evt_callback_f) (mpp_t mpp, mpp_evt_t evt, void ∗evt_data, void ∗user_data)
the callback to be called when model output is ready
void∗ model_param_t::cb_userdata
pointer to user data, should be passed by callback
Valgo devices private capability.
Data Fields
type |
name |
description |
---|---|---|
void ∗ |
param |
param for the callback |
Characteristics that need to be defined by a vision algo.
Data Fields
type |
name |
description |
---|---|---|
int |
height |
frame height |
int |
width |
frame width |
int |
pitch |
frame pitch |
mpp_pixel_format_t |
format |
pixel format |
void ∗ |
input_buf |
pixel input buffer |
Attributes of a vision algo device.
Data Fields
type |
name |
description |
---|---|---|
int |
id |
unique id which is assigned by algorithm manager during the registration |
char |
ENGTHname to] identify |
|
cap |
private capability |
|
const vision_algo_dev_operator_t ∗ |
ops |
operations |
vision_algo_private_data_t |
priv_data |
private data |
Structure that characterizes the display device.
Data Fields
type |
name |
description |
---|---|---|
int |
height |
buffer height |
int |
width |
buffer width |
int |
pitch |
buffer pitch |
int |
left |
left position |
int |
top |
top position |
int |
right |
right position |
int |
bottom |
bottom position |
int |
stripe_height |
stripe height (0 if stripe mode is off) |
bool |
stripe |
stripe mode |
mpp_rotate_degree_t |
rotate |
rotate degree |
mpp_pixel_format_t |
format |
pixel format |
int |
nbFrameBuffer |
number of input buffers |
void ∗∗ |
frameBuffers |
array of pointers to frame buffer |
callback |
callback |
|
void ∗ |
user_data |
parameter for the callback |
void ∗ |
handle |
Handle to the LVGL widget ‘image’. |
Attributes of a display device. hal display device declaration.
Display devices can be used to display images, GUI overlays, etc. Examples of display devices include display panels like the RK024hh298 display, and external displays like UVC (video over USB).
Data Fields
type |
name |
description |
---|---|---|
int |
id |
unique id which is assigned by the display manager during the registration |
char |
ENGTHname of] the device |
|
const display_dev_operator_t ∗ |
ops |
operations |
display_dev_private_capability_t |
cap |
private capability |
the hardware specific buffer requirements
Data Fields
type |
name |
description |
---|---|---|
int |
stride |
the number of bytes between 2 lines of image |
int |
nb_lines |
the number of lines required (set to 0 if the element doesn’t require a specific number of lines) |
int |
alignment |
alignment requirement in bytes |
int |
max_image_size |
the number of bytes allocated |
bool |
cacheable |
if true, HW will require cache maintenance |
unsigned char ∗ |
addr |
the aligned buffer address |
unsigned char ∗ |
heap_p |
pointer to the heap that should be freed |
Data Fields
type |
name |
description |
---|---|---|
const char ∗ |
vdec_dev_name |
|
decoder_setup_func |
Data Fields
type |
name |
description |
---|---|---|
const char ∗ |
gfx_dev_name |
|
gfx_setup_func |
Data Fields
type |
name |
description |
---|---|---|
const char ∗ |
display_name |
|
display_setup_func |
Data Fields
type |
name |
description |
---|---|---|
const char ∗ |
camera_name |
|
camera_setup_func |
computed checksum
Data Fields
type |
name |
description |
---|---|---|
type |
checksum calculation method |
|
uint32_t |
value |
checksum value |
2.1.1.2 Macro Definition Documentation
HAL_GFX_DEV_CPU_NAME
#define HAL_GFX_DEV_CPU_NAME hal graphics (gfx) device declaration.
Graphics processing devices can be used to perform conversion from one image format to another, resize images and compose images on top of one another. Examples of graphics devices include the PXP (pixel pipeline) found on many i.MXRT series MCUs. Name of the graphic device using CPU operations
#define GUI_PRINTF_BUF_SIZE Local text buffer size.
#define GUI_PRINTF_BUF_SIZE Local text buffer size.
MAX_INPUT_PORTS
HAL public types header.
maximum number of element inputs/outputs
#define HAL_DEVICE_NAME_MAX_LENGTH maximum length of device name
2.1.1.3 Typedef Documentation
camera_dev_callback_t
typedef int(∗ camera_dev_callback_t) (const camera_dev_t ∗dev, camera_event_t event, void ∗param, uint8_t fromISR)
Callback function to notify camera manager that one frame is dequeued.
Parameters
name |
description |
---|---|
dev |
Device structure of the camera device calling this function |
event |
id of the event that took place |
param |
Parameters |
fromISR |
True if this operation takes place in an irq, 0 otherwise |
Returns
0 if the operation was successfully
mpp_callback_t
typedef int(∗ mpp_callback_t) (mpp_t mpp, mpp_evt_t evt, void ∗evt_data, void ∗user_data) The mpp callback function prototype.
img_decoder_setup_func_t
typedef int(∗ img_decoder_setup_func_t) (vdec_dev_t ∗) video decoder setup
graphic_setup_func_t
typedef int(∗ graphic_setup_func_t) (gfx_dev_t ∗) graphics setup
display_setup_func_t
typedef int(∗ display_setup_func_t) (display_dev_t ∗) display setup
camera_setup_func_t
typedef int(∗ camera_setup_func_t) (const char ∗, camera_dev_t ∗) camera setup
2.1.1.4 Enumeration Type Documentation
hal_camera_status_t
enum hal_camera_status_t Camera return status.
Enumerator
label |
description |
---|---|
HAL camera successful. |
|
Camera is busy. |
|
Camera will return immediately. |
|
Error occurs on HAL Camera. |
camera_event_t
enum camera_event_t
Type of events that are supported by calling the callback function.
Enumerator
label |
description |
---|---|
Camera new frame is available. |
|
Camera device finished the initialization process. |
hal_image_status_t
enum hal_image_status_t static image return status
Enumerator
label |
description |
---|---|
Successfully. |
|
Error occurs on HAL Image. |
gfx_rotate_target_t
enum gfx_rotate_target_t gfx rotate target
hal_valgo_status_t
enum hal_valgo_status_t
Valgo Error codes for hal operations.
Enumerator
label |
description |
---|---|
Successfully. |
|
memory allocation failed for HAL algorithm |
|
algorithm initialization error |
|
Error occurs in HAL algorithm |
|
HAL algorithm stop |
display_event_t
enum display_event_t
Type of events that are supported by calling the callback function.
Enumerator
label |
description |
---|---|
Display finished sending the frame asynchronously, provide another frame. |
hal_display_status_t
enum hal_display_status_t Error codes for display hal devices.
Enumerator
label |
description |
---|---|
HAL display successful. |
|
Display tx is busy. |
|
Display will return immediately. |
|
Error occurs on HAL Display. |
mpp_memory_policy_t
enum mpp_memory_policy_t
The memory allocation policy of an element’s hal.
During the pipeline construction, the HAL uses this enum to tell the pipeline if it already owns input/ouput buffers. Before the pipeline starts, the memory manager will map the existing buffers to elements and allocate missing buffers from the heap.
Enumerator
label |
description |
---|---|
element requires buffers to be provided by other elements, or by the pipeline |
|
element allocates its input buffer, it may require output buffers to be provided by other elements, or by the pipeline |
|
element allocates its output buffer, it may require input buffers to be provided by other elements, or by the pipeline |
|
element allocates both its input and output buffers |
checksum_type_t
enum checksum_type_t checksum calculation method
Enumerator
label |
description |
---|---|
checksum computed using Pisano |
|
checksum computed CRC from ELCDIF |
2.1.1.5 Function Documentation
HAL_GfxDev_CPU_Register()
int HAL_GfxDev_CPU_Register ( gfx_dev_t ∗ dev )
Register the graphic device with the CPU operations.
Parameters
in/out |
name |
description |
---|---|---|
in |
dev |
graphic device to register |
Returns
error code (0: success, otherwise: failure)
HAL_GfxDev_GPU_Register()
int HAL_GfxDev_GPU_Register ( gfx_dev_t ∗ dev )
Register the graphic device with the GPU operations.
Parameters
in/out |
name |
description |
---|---|---|
in |
dev |
graphic device to register |
Returns
error code (0: success, otherwise: failure)
2.2 HAL OPERATIONS
Data Structures
struct camera_dev_operator_t
struct static_image_operator_t
struct gfx_dev_operator_t
struct vision_algo_dev_operator_t
struct display_dev_operator_t
Typedefs
typedef int(∗mpp_callback_t) (mpp_t mpp, mpp_evt_t evt, void ∗evt_data, void ∗user_data)
Functions
void GUI_DrawText (uint16_t ∗lcd_buf, uint16_t fcolor, uint16_t bcolor, uint32_t width, int x, int y, const char ∗label)
static void hal_draw_pixel565 (uint16_t ∗pDst, uint32_t x, uint32_t y, uint16_t color, uint32_t lcd_w)
static void hal_draw_text565 (uint16_t ∗lcd_buf, uint16_t fcolor, uint16_t bcolor, uint32_t width, int x, int y, const char ∗label, int stripe_top, int stripe_bottom)
static void hal_draw_rect565 (uint16_t ∗lcd_buf, hal_rect_t rect, mpp_color_t rgb, uint32_t width, int stripe← _top, int stripe_bottom)
static int get_bitpp (mpp_pixel_format_t type)
void swap_2_bytes (uint8_t ∗data, int size)
2.2.1 Detailed Description
This section provides the detailed documentation for the MPP HAL operations that needs to be implemented for each component.
2.2.1.1 Data Structure Documentation
Operation that needs to be implemented by a camera device.
Data Fields
hal_camera_status_t(∗init)(camera_dev_t ∗dev, mpp_camera_params_t ∗config, camera_dev_callback_t callback, void ∗param)
hal_camera_status_t(∗deinit)(camera_dev_t ∗dev)
hal_camera_status_t(∗start)(const camera_dev_t ∗dev)
hal_camera_status_t(∗stop)(const camera_dev_t ∗dev)
hal_camera_status_t(∗enqueue)(const camera_dev_t ∗dev, void ∗data)
hal_camera_status_t(∗dequeue)(const camera_dev_t ∗dev, void ∗∗data, int ∗stripe)
hal_camera_status_t(∗get_buf_desc)(const camera_dev_t ∗dev, hw_buf_desc_t ∗out_buf, mpp_memory_policy_t ∗policy)
init
hal_camera_status_t(∗ camera_dev_operator_t::init) (camera_dev_t ∗dev, mpp_camera_params_t ∗config, camera_dev_callback_t callback, void ∗param)
deinit
hal_camera_status_t(∗ camera_dev_operator_t::deinit) (camera_dev_t ∗dev)
start
hal_camera_status_t(∗ camera_dev_operator_t::start) (const camera_dev_t ∗dev)
stop
hal_camera_status_t(∗ camera_dev_operator_t::stop) (const camera_dev_t ∗dev)
enqueue
hal_camera_status_t(∗ camera_dev_operator_t::enqueue) (const camera_dev_t ∗dev, void ∗data) enqueue a buffer to the dev
dequeue
hal_camera_status_t(∗ camera_dev_operator_t::dequeue) (const camera_dev_t ∗dev, void ∗∗data, int ∗stripe)
dequeue a buffer from the dev (blocking)
get_buf_desc
hal_camera_status_t(∗ camera_dev_operator_t::get_buf_desc) (const camera_dev_t ∗dev, hw_buf_desc_t ∗out_buf, mpp_memory_policy_t ∗policy)
get buffer descriptors and policy
Operation that needs to be implemented by an image element.
Data Fields
hal_image_status_t(∗init )(static_image_t ∗elt, mpp_img_params_t ∗config, void ∗param)
hal_image_status_t(∗dequeue )(static_image_t ∗elt, hw_buf_desc_t ∗out_buf, int ∗stripe_num)
init
hal_image_status_t(∗ static_image_operator_t::init) (static_image_t ∗elt, mpp_img_params_t ∗config, void ∗param)
dequeue
hal_image_status_t(∗ static_image_operator_t::dequeue) (static_image_t ∗elt, hw_buf_desc_t ∗out_buf, int ∗stripe_num)
Operation that needs to be implemented by gfx device.
Data Fields
int(∗init )(const gfx_dev_t ∗dev, void ∗param)
int(∗deinit )(const gfx_dev_t ∗dev)
int(∗get_buf_desc )(const gfx_dev_t ∗dev, hw_buf_desc_t ∗in_buf, hw_buf_desc_t ∗out_buf, mpp_memory_policy_t ∗policy)
int(∗ blit )(const gfx_dev_t ∗dev, const gfx_surface_t ∗pSrc, const gfx_surface_t ∗pDst, const gfx_rotate_config_t ∗pRotate, mpp_flip_mode_t flip)
int(∗drawRect )(const gfx_dev_t ∗dev, gfx_surface_t ∗pOverlay, int x, int y, int w, int h, int color)
int(∗drawPicture )(const gfx_dev_t ∗dev, gfx_surface_t ∗pOverlay, int x, int y, int w, int h, int alpha, const char ∗pIcon)
int(∗drawText )(const gfx_dev_t ∗dev, gfx_surface_t ∗pOverlay, int x, int y, int textColor, int bgColor, int type, const char ∗pText)
int(∗compose )(const gfx_dev_t ∗dev, gfx_surface_t ∗pSrc, gfx_surface_t ∗pOverlay, gfx_surface_t ∗pDst, gfx_rotate_config_t ∗pRotate, mpp_flip_mode_t flip)
Operation that needs to be implemented by a vision algorithm device.
Data Fields
hal_valgo_status_t(∗init )(vision_algo_dev_t ∗dev, model_param_t ∗param)
hal_valgo_status_t(∗run )(const vision_algo_dev_t ∗dev, void ∗data)
hal_valgo_status_t(∗get_buf_desc )(const vision_algo_dev_t ∗dev, hw_buf_desc_t ∗in_buf, mpp_memory_policy_t ∗policy)
init
hal_valgo_status_t(∗ vision_algo_dev_operator_t::init) (vision_algo_dev_t ∗dev, model_param_t ∗param)
deinit
hal_valgo_status_t(∗ vision_algo_dev_operator_t::deinit) (vision_algo_dev_t ∗dev) deinitialize the dev
run
hal_valgo_status_t(∗ vision_algo_dev_operator_t::run) (const vision_algo_dev_t ∗dev, void ∗data)
get_buf_desc
hal_valgo_status_t(∗ vision_algo_dev_operator_t::get_buf_desc) (const vision_algo_dev_t ∗dev, hw_buf_desc_t ∗in_buf, mpp_memory_policy_t ∗policy)
read input parameters
Operation that needs to be implemented by a display device.
Data Fields
hal_display_status_t(∗init)(display_dev_t ∗dev, mpp_display_params_t ∗config, mpp_callback_t callback, void ∗user_data)
hal_display_status_t(∗deinit )(const display_dev_t ∗dev)
hal_display_status_t(∗start )(display_dev_t ∗dev)
hal_display_status_t(∗stop )(display_dev_t ∗dev)
hal_display_status_t(∗blit )(const display_dev_t ∗dev, void ∗frame, int stripe)
hal_display_status_t(∗get_buf_desc )(const display_dev_t ∗dev, hw_buf_desc_t ∗in_buf, mpp_memory_policy_t ∗policy)
init
hal_display_status_t(∗ display_dev_operator_t::init) (display_dev_t ∗dev, mpp_display_params_t ∗config, mpp_callback_t callback, void ∗user_data)
deinit
hal_display_status_t(∗ display_dev_operator_t::deinit) (const display_dev_t ∗dev) deinitialize the dev
start
hal_display_status_t(∗ display_dev_operator_t::start) (display_dev_t ∗dev) start the dev
stop
hal_display_status_t(∗ display_dev_operator_t::stop) (display_dev_t ∗dev) stop the dev
hal_display_status_t(∗ display_dev_operator_t::blit) (const display_dev_t ∗dev, void ∗frame, int stripe)
get_buf_desc
hal_display_status_t(∗ display_dev_operator_t::get_buf_desc) (const display_dev_t ∗dev, hw_buf_desc_t ∗in_buf, mpp_memory_policy_t ∗policy)
get buffer descriptors and policy
2.2.1.2 Typedef Documentation
typedef int(∗ mpp_callback_t) (mpp_t mpp, mpp_evt_t evt, void ∗evt_data, void ∗user_data) The mpp callback function prototype.
2.2.1.3 Function Documentation
GUI_DrawText()
void GUI_DrawText ( uint16_t ∗ lcd_buf, uint16_t fcolor, uint16_t bcolor, uint32_t width, int x, int y, const char ∗ label )
Draws text stored in label pointer to LCD buffer. This function copy content of data from label text buffer to the LCD.
Parameters
name |
description |
---|---|
lcd_buf |
LCD buffer address destination for drawing text |
fcolor |
foreground color in rgb565 format |
bcolor |
background color in rgb565 format |
width |
LCD width |
x |
drawing position on X axe |
y |
drawing position on Y axe |
label |
C string pointed by label |
Returns
hal_draw_pixel565()
static void hal_draw_pixel565 ( uint16_t ∗ pDst, uint32_t x, uint32_t y, uint16_t color, uint32_t lcd_w )
Draws pixel with RGB565 color to defined point.
Parameters
name |
description |
---|---|
pDst |
image data address of destination buffer |
x |
drawing position on X axe |
y |
drawing position on Y axe |
color |
RGB565 encoded value |
lcd_w |
lcd width |
hal_draw_text565()
static void hal_draw_text565 ( uint16_t ∗ lcd_buf, uint16_t fcolor, uint16_t bcolor, uint32_t width, int x, int y, const char ∗ label, int stripe_top, int stripe_bottom ) [static]
Draws text stored in label pointer to LCD buffer. This function copy content of data from label text buffer to the LCD.
Parameters
name |
description |
---|---|
lcd_buf |
LCD buffer address destination for drawing text |
fcolor |
foreground color in rgb565 format |
bcolor |
background color in rgb565 format |
width |
LCD width |
x |
drawing position on X axe |
y |
drawing position on Y axe |
format |
C string pointed by format |
Returns
The return number of written chars to the buffer
hal_draw_rect565()
static void hal_draw_rect565 ( uint16_t ∗ lcd_buf, hal_rect_t rect, mpp_color_t rgb, uint32_t width, int stripe_top, int stripe_bottom ) [static]
Draws rectangle.
Parameters
in/out |
name |
description |
---|---|---|
in |
lcd_buf |
LCD buffer address destination for drawing rectangle |
in |
color |
background color in rgb565 format |
in |
x |
drawing position on X axe |
in |
y |
drawing position on Y axe |
in |
xsize |
rectangle width |
in |
ysize |
rectangle height |
in |
r |
0-255 red color value |
in |
g |
0-255 green color value |
in |
b |
0-255 blue color value |
in |
width |
LCD width |
Returns
N/A
static int get_bitpp ( mpp_pixel_format_t type ) [static]
returns the number of bits per pixel per format, unknown format return 0
void swap_2_bytes ( uint8_t ∗ data, int size )
Swaps a buffer’s MSB and LSB bytes.
Parameters
name |
description |
---|---|
data |
pointer to the buffer to be converted(from little endian to big endian and vice-versa). |
size |
buffer size. |
2.3 HAL Setup Functions
Functions
int hal_label_rectangle (uint8_t ∗frame, int width, int height, mpp_pixel_format_t format, mpp_labeled_rect_t ∗lr, int stripe, int stripe_max)
int hal_inference_tflite_setup (vision_algo_dev_t ∗dev)
int hal_display_setup (const char ∗name, display_dev_t ∗dev)
int hal_camera_setup (const char ∗name, camera_dev_t ∗dev)
int hal_gfx_setup (const char ∗name, gfx_dev_t ∗dev)
int hal_img_decoder_setup (const char ∗name, vdec_dev_t ∗dev)
2.3.1 Detailed Description
This section provides the detailed documentation for the HAL setup functions that should be defined by each device.
2.3.1.1 Function Documentation
hal_label_rectangle()
int hal_label_rectangle ( uint8_t ∗ frame, int width, int height, mpp_pixel_format_t format, mpp_labeled_rect_t ∗ lr, int stripe, int stripe_max )
Implementation of hal labeled rectangle component that draws a rectangle and a text on an input image.
Parameters
in/out |
name |
description |
---|---|---|
in |
frame |
The buffer address |
in |
width |
Image width |
in |
height |
Image height |
in |
format |
Image format |
in |
lr |
Labeled rectangle parameters |
in |
stripe |
stripe number (0=no stripe) |
in |
stripe_max |
max nb of stripes |
Returns
0
hal_inference_tflite_setup()
int hal_inference_tflite_setup ( vision_algo_dev_t ∗ dev )
Hal setup function for inference engine Tensorflow-Lite Micro.
Parameters
in/out |
name |
description |
---|---|---|
in |
dev |
vision algo device to register |
Returns
error code (0: success, otherwise: failure)
int hal_display_setup ( const char ∗ name, display_dev_t ∗ dev )
Register with a display device specified by name. If name is NULL, return error.
Parameters
in/out |
name |
description |
---|---|---|
in |
name |
display name |
in |
dev |
display device to register |
Returns
error code (0: success, otherwise: failure)
int hal_camera_setup ( const char ∗ name, camera_dev_t ∗ dev )
Register with a camera device specified by name. If name is NULL, return error.
Parameters
in/out |
name |
description |
---|---|---|
in |
name |
camera name |
in |
dev |
camera device to register |
Returns
error code (0: success, otherwise: failure)
int hal_gfx_setup ( const char ∗ name, gfx_dev_t ∗ dev )
Register with a graphic processing device specified by name.
If name is NULL, the first available graphic processing supported by Hw will be selected. The graphic device using CPU operations will be selected if name is not specified and if no graphic processing is available for the Hw.
Parameters
in/out |
name |
description |
---|---|---|
in |
name |
graphic processing device performing the image conversion |
in |
dev |
graphic device to register |
Returns
error code (0: success, otherwise: failure)
hal_img_decoder_setup()
int hal_img_decoder_setup ( const char ∗ name, vdec_dev_t ∗ dev )
Register with an image decoder device specified by name.
If name is NULL, the first available decoder supported by Hw will be selected. The decoder device using CPU operations will be selected if name is not specified and if no decoder is available for the Hw.
Parameters
in/out |
name |
description |
---|---|---|
in |
name |
image decoding device name |
in |
dev |
decoder device to register |
Returns
error code (0: success, otherwise: failure)