Display Driver API
Note
Display driver is currently only available on modules based on RDA8910 and RDA8955.
Application Example
API Reference
Header File
Source: include/hw/display.h
#include <hw/display.h>
Functions
-
int display_init(const struct lcd_drv_t *lcd)
Initialize onchip display controller and LCD controller.
- Parameters:
lcd – LCD driver structure lcd_drv_t
- Returns:
0 for success, negative for error
-
int display_sleep(uint8_t enable)
Enable or disable sleep.
Note
display flush is needed after wakeup from sleep
- Parameters:
enable – TRUE to enable sleep, FALSE to disable
- Returns:
0 for success, negative for error
-
int display_layer_setup(int layer, const struct layer_cfg_t *cfg)
Setup display layer.
Note
Layer 0 is setup by default during initialization with size of LCD panel
- Parameters:
layer – Layer to setup disp_layer_e
cfg – Layer configuration layer_cfg_t
- Returns:
0 for success, negative for error
-
int display_layer_getcfg(int layer, struct layer_cfg_t *cfg)
Get display layer configuration, If layer is not setup cfg will be filled with valid default values and area set to invalid.
- Parameters:
layer – Layer number disp_layer_e
cfg – Layer configuration pointer to fill
- Returns:
0 for success, negative for error
-
void *display_layer_getbuffer(int layer)
Get display layer buffer. Image data written on buffer will be sent to display on flush.
- Parameters:
layer – Layer number disp_layer_e
- Returns:
buffer pointer on success, NULL on error
-
int display_layer_enable(int layer, uint8_t en)
Enable or disable display layer.
- Parameters:
layer – Layer number disp_layer_e
en – TRUE to enable, FALSE to disable layer
- Returns:
0 for success, negative for error
-
int display_layer_delete(int layer)
Delete a display layer.
Note
Base Layer 0 cannot be deleted
- Parameters:
layer – Layer number disp_layer_e
- Returns:
0 for success, negative for error
-
int display_flush(const struct lcd_area_t *area, uint8_t sync)
Flush blended display layers on LCD.
- Parameters:
area – area to update, NULL for complete update
sync – TRUE - to wait for operation to complete, FALSE - do not wait
- Returns:
0 for success, negative for error
-
int display_write_cmd(uint16_t cmd)
Send command to LCD controller.
- Parameters:
cmd – command to write
- Returns:
0 for success, negative for error
-
int display_write_data(uint16_t data)
Send data to LCD controller.
- Parameters:
data – data to write
- Returns:
0 for success, negative for error
-
int display_read_data(uint16_t cmd, uint8_t *data, unsigned len)
Read data from LCD controller, e.g. LCD controller ID.
- Parameters:
cmd – Read command for LCD controller
data – data buffer to store read data
len – length of data to read (max 4 bytes)
- Returns:
0 for success, negative for error
-
void display_wait_transfer(void)
Wait for transfer to complete, this is blocking call.
-
void display_backlight_enable(uint8_t enabled)
Enable/disable display backlight (if supported by hardware)
- Parameters:
enabled – TRUE to enable, FALSE disable
-
int display_clear(uint8_t sync)
Clear display. This function disable all display layers and set display background to default as in config.
- Parameters:
sync – TRUE - to wait for operation to complete, FALSE - do not wait
- Returns:
0 for success, negative for error
Structures
-
struct lcd_area_t
An area.
Area with (w == 0 || h == 0) is nul or invalid area.
-
struct lcd_ops_t
LCD driver operations.
Public Members
-
void (*init)(void)
Initialization.
-
void (*prepare)(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1)
Setup lcd controller area for display data transfer.
- Param x0:
top left corner x coordinate
- Param y0:
top left corner y coordinate
- Param x1:
bottom right corner x coordinate
- Param y1:
bottom right corner y coordinate
-
void (*init)(void)
-
struct lcd_drv_t
LCD Driver structure.
Public Members
-
uint32_t init_delay_us
Reset delay in microseconds
-
uint16_t io_level_mv
Delay in microseconds before driver init is called
-
uint16_t width
LCD IO Level in millivolts, 0 for default 1800mV, max 3200mV
-
uint16_t height
Width of LCD panel
-
uint16_t bg_color
Height of LCD panel
-
uint8_t output_format
Default background color
-
uint8_t in_format
LCD output pixel format lcd_outfmt_e
-
uint8_t spi_linemode
Input data format for Base layer 0 disp_infmt_e
-
uint8_t cs_polarity
LCD controller SPI interface lcd_spi_linemode_e
-
uint8_t te_enable
Chip select line polarity, 0 - active low, 1 - active high
-
uint8_t te_polarity
Enable tearing effect signal detect (FMARK), - TRUE to enable, FALSE to disable
-
uint16_t te_delay
TE polarity (unused), positive edge default
-
uint32_t spi_freq
TE detect delay
-
uint32_t init_delay_us
-
struct layer_cfg_t
Display layer configuration.
Public Members
-
uint8_t alpha
input data format disp_infmt_e
-
uint8_t key_en
blending alpha, 0 for transparent
-
uint8_t key_mask
whether to enable color key
-
uint16_t key_color
key color mask
-
struct lcd_area_t area
key color in RGB565
-
uint8_t alpha
Enumerations
-
enum disp_layer_e
Display Controller Layers.
Values:
-
enumerator DISPLAY_LAYER0
Base/bottom layer
-
enumerator DISPLAY_LAYER1
Middle layer
-
enumerator DISPLAY_LAYER2
Top layer
-
enumerator DISPLAY_LAYER_VIDEO
Video layer, shown above all graphics layers
-
enumerator DISPLAY_LAYER0
-
enum lcd_outfmt_e
LCD controller supported output format.
Values:
-
enumerator LCD_OUT_FMT_8BIT_RGB332
-
enumerator LCD_OUT_FMT_8BIT_RGB444
-
enumerator LCD_OUT_FMT_8BIT_RGB565
-
enumerator LCD_OUT_FMT_16BIT_RGB332
-
enumerator LCD_OUT_FMT_16BIT_RGB444
-
enumerator LCD_OUT_FMT_16BIT_RGB565
-
enumerator LCD_OUT_FMT_8BIT_RGB332
-
enum lcd_spi_linemode_e
LCD controler SPI interface line mode.
Values:
-
enumerator LCD_SPI_4WIRE
-
enumerator LCD_SPI_3WIRE
-
enumerator LCD_SPI_4WIRE_START_BYTE
-
enumerator LCD_SPI_3WIRE_2LANE
-
enumerator LCD_SPI_4WIRE
-
enum lcd_dir_e
Direction transform.
Values:
-
enumerator LCD_DIR_NORMAL
normal direction
-
enumerator LCD_DIR_YINV
Y is inverted
-
enumerator LCD_DIR_XINV
X is inverted
-
enumerator LCD_DIR_YINV_XINV
both Y and X are inverted
-
enumerator LCD_DIR_EXCHG
X-Y are swapped
-
enumerator LCD_DIR_EXCHG_YINV
X-Y are swapped, Y is inverted
-
enumerator LCD_DIR_EXCHG_XINV
X-Y are swapped, X is inverted
-
enumerator LCD_DIR_EXCHG_XINV_YINV
X-Y are swapped, both X and Y are inverted
-
enumerator LCD_DIR_ROTATE_0
alias for rotate 0 degree
-
enumerator LCD_DIR_ROTATE_90
alias for rotate 90 degree
-
enumerator LCD_DIR_ROTATE_180
alias for rotate 180 degree
-
enumerator LCD_DIR_ROTATE_270
alias for rotate 270 degree
-
enumerator LCD_DIR_NORMAL
-
enum disp_infmt_e
Input buffer color format.
RGB565 and ARGB8888 format for layer0, 1 and 2 YUV formats are for video layer
Values:
-
enumerator LCD_IN_FMT_RGB565
RGB565 in little endian, [15:11] R, [10:5] G, [4:0] B
-
enumerator LCD_IN_FMT_ARGB8888
ARGB8888 in little endian, [31:24] A, [23:16] R, [15:8] G, [7:0] B
-
enumerator LCD_IN_FMT_YUV422_UYVY
UYVY pixel-packed format
-
enumerator LCD_IN_FMT_YUV422_YUYV
YUYV pixel-packed format
-
enumerator LCD_IN_FMT_YUV420_IYUV
IYUV planar format
-
enumerator LCD_IN_FMT_RGB565
