K230 LCD Adaptation Guide#
Preface#
Overview#
This document mainly describes the LCD framework of the K230 platform and how to add support for a new LCD.
Target Audience#
This document (this guide) is mainly intended for the following personnel:
Technical Support Engineers
Software Development Engineers
Abbreviation Definitions#
Abbreviation |
Description |
---|---|
Revision History#
Document Version |
Description of Changes |
Author |
Date |
---|---|---|---|
V1.0 |
Initial Version |
Wang Quan |
2023-11-30 |
1. Overview#
This document mainly describes the basic framework of the K230 platform LCD and how to add support for a new LCD.
The K230 platform supports LCDs with MIPI-DSI interfaces. The hardware connection diagram between the LCD and the main control platform is as follows:
The main control sends configuration information to the LCD through the MIPI-DSI interface while transmitting image data to the LCD.
2. LCD Adaptation Preparation Work#
Before adapting a new LCD, users need to do the following preparation work:
Obtain the LCD Datasheet and initialization sequence from official channels.
Carefully analyze the LCD Datasheet to obtain the LCD output timing, specifically including: pixelclock, vtotal, vactive, vfp, vbp, vsa, htotal, hactive, hfp, hbp, hsa, etc.
Refer to the “K230_Video Output_API Reference” to calculate the TxDPHY clock parameters.
3. LCD Adaptation Example#
Here we take the hx8399 driver as an example to explain, the corresponding driver file source path is as follows:
src/big/mpp/kernel/connector/src/hx8399.c
3.1 Define Supported LCD Types#
Define the following enumeration variables in the src/big/mpp/include/comm/k_connector_comm.h file:
typedef enum {
HX8377_V2_MIPI_4LAN_1080X1920_30FPS = 0,
LT9611_MIPI_4LAN_1920X1080_30FPS = 1,
ST7701_V1_MIPI_2LAN_480X800_30FPS = 2,
ST7701_V1_MIPI_2LAN_480X854_30FPS = 3,
LT9611_MIPI_ADAPT_RESOLUTION = 100,
LT9611_MIPI_4LAN_1920X1080_60FPS,
LT9611_MIPI_4LAN_1920X1080_50FPS,
LT9611_MIPI_4LAN_1920X1080_25FPS,
LT9611_MIPI_4LAN_1920X1080_24FPS,
LT9611_MIPI_4LAN_1280X720_60FPS = 110,
LT9611_MIPI_4LAN_1280X720_50FPS,
LT9611_MIPI_4LAN_1280X720_30FPS,
LT9611_MIPI_4LAN_640X480_60FPS = 120,
} k_connector_type;
When users need to add new LCD support types, they first need to add the corresponding type definition here. This type is the only identifier for the application to obtain the LCD configuration.
3.2 LCD Driver Adaptation#
The LCD driver adaptation is the most important part of the entire process. Users can modify by copying existing LCD driver files.
3.2.1 Add LCD Initialization Code#
k_s32 hx8399_init(void *ctx, k_connector_info *info)
{
k_s32 ret = 0;
struct connector_driver_dev* dev = ctx;
ret |= hx8399_set_phy_freq(&info->phy_attr);
ret |= hx8399_dsi_resolution_init(info);
ret |= hx8399_dsi_resolution_init(&info->resolution, info->bg_color, info->intr_line);
return ret;
}
hx8399_set_phy_freq will initialize the TxDPHY output timing.
hx8399_dsi_resolution_init initializes the MIPI-DSI controller, including the LCD’s initialization firmware data.
hx8399_dsi_resolution_init initializes the display controller.
3.2.2 Implement LCD Operation Interface#
The LCD operation interface is defined by the data type k_connector_function. Users implement the relevant operation interfaces according to the actual situation. Not all interfaces must be implemented.
typedef struct {
k_s32 (*connector_power) (void *ctx, k_s32 on);
k_s32 (*connector_init) (void *ctx, k_connector_info *info);
k_s32 (*connector_get_chip_id) (void *ctx, k_u32 *chip_id);
k_s32 (*connector_get_negotiated_data) (void *ctx, k_connector_negotiated_data *negotiated_data);
k_s32 (*connector_conn_check)(void *ctx, k_s32 *conn);
} k_connector_function;
The following is the supported operation set of the LCD:
.connector_func = {
.connector_power = hx8399_power_on,
.connector_init = hx8399_init,
.connector_get_chip_id = hx8399_get_chip_id,
.connector_conn_check = hx8399_conn_check,
},
3.2.3 Define LCD Driver Structure#
The LCD driver structure is defined by struct connector_driver_dev, mainly including the LCD driver name, GPIO reset signal, and LCD operation set.
struct connector_driver_dev
{
struct rt_device parent;
struct rt_mutex connector_mutex;
k_u8 *connector_name;
k_connector_function connector_func;
k_s32 backlight_gpio;
k_s32 reset_gpio;
void *driver_data;
};
The LCD driver structure definition and initialization content are as follows:
struct connector_driver_dev hx8399_connector_drv = {
.connector_name = "hx8399",
.connector_func = {
.connector_power = hx8399_power_on,
.connector_init = hx8399_init,
.connector_get_chip_id = hx8399_get_chip_id,
.connector_conn_check = hx8399_conn_check,
},
};
3.2.4 Update LCD Driver List#
Add the LCD driver structure defined in the previous section to the connector_drv_list array. The list of LCDs supported by the current system is as follows:
src/big/mpp/kernel/connector/src/connector_comm.c
extern struct connector_driver_dev hx8399_connector_drv;
extern struct connector_driver_dev lt9611_connector_drv;
struct connector_driver_dev *connector_drv_list[CONNECTOR_NUM_MAX] = {
&hx8399_connector_drv,
<9611_connector_drv,
};
3.3 Update LCD Configuration Information List#
The LCD configuration information is defined by the structure k_connector_info:
typedef struct
{
k_u32 n;
k_u32 m;
k_u32 voc;
k_u32 hs_freq;
} k_connectori_phy_attr;
typedef struct {
const char *connector_name;
k_u32 screen_test_mode;
k_u32 dsi_test_mode;
k_u32 bg_color;
k_u32 intr_line;
k_dsi_lan_num lan_num;
k_dsi_work_mode work_mode;
k_vo_dsi_cmd_mode cmd_mode;
k_connectori_phy_attr phy_attr;
k_vo_display_resolution resolution;
k_connector_type type;
} k_connector_info;
The following is the corresponding configuration information for HX8399:
src/big/mpp/userapps/src/connector/mpi_connector.c
const k_connector_info connector_info_list[] = {
{
"hx8399",
0,
0,
BACKGROUND_BLACK_COLOR,
11,
K_DSI_4LAN,
K_BURST_MODE,
K_VO_LP_MODE,
{15, 295, 0x17, 0x96},
{74250, 445500, 1160, 1080, 20, 20, 40, 2134, 1920, 5, 8, 206},
HX8377_V2_MIPI_4LAN_1080X1920_30FPS,
},
Each time a user adds an LCD configuration mode, they need to add a corresponding mode configuration item to the sensor_info_list structure.
Let’s take HX8399 LCD as an example to explain:
The parameters {15, 295, 0x17, 0x96} need to refer to the document “K230_Video Output_API Reference” to calculate the TxDPHY clock parameters.
The parameters {74250, 445500, 1160, 1080, 20, 20, 40, 2134, 1920, 5, 8, 206} need to refer to the LCD datasheet.
HX8377_V2_MIPI_4LAN_1080X1920_30FPS is the k_connector_type we defined in the src/big/mpp/include/comm/k_connector_comm.h file.