此次移植打算分成两个模块来说,bootloader部分和kernel部分。在实际的移植调试过程中也是这么分成了两个部分分别调试。
高通平台中的bootloader叫做LK(Little Kernel,对于LCM来说LK部分相当重要,它不仅要负责开机部分的LCD显示任务,还要负责传参给kernel的LCM驱动,指导kernel选择合适的LCM参数。
1、LK中LCM启动流程
注:read_panel_id()和read_panel_id_ddr3()为私有添加,非高通库上代码。
在这个流程图中,需要着重了解的有oem_panel_select() mdss_dsi_initialize() 和read_panel_id()函数,这三个函数主要是做lcd兼容,下面来具体看函数内容。
2、oem_panel_select()
这个函数在 android/bootloader/lk/target/msm8916/oem_panel.c文件中
主要是识别不同IC,赋值给参数panel_id,panel_id的使用在同一文件中的 init_panel_data()函数中。
- /********************************************************
- *Name: oem_panel_select
- *Function: selection different lcm panel
- *Description: 1)This func will be roaded twice,first time use default value
- second time depend on lk_lcd_id value match correct branch.
- *Author: Jerry.peng
- *********************************************************/
- bool oem_panel_select(const charchar *panel_name, struct panel_struct *panelstruct,
- struct msm_panel_info *pinfo,
- struct mdss_dsi_phy_ctrl *phy_db)
- {
- uint32_t soc_version = board_soc_version();
- uint32_t gpio_state = 0;
-
- gpio_tlmm_config(LCM_GPIO_DETECT, 0, GPIO_INPUT, GPIO_NO_PULL, GPIO_8MA, GPIO_ENABLE);<span style="color:#33ff33;"> </span><span style="color:#009900;">
- mdelay(10);
- gpio_state = gpio_status(LCM_GPIO_DETECT);
- dprintf(CRITICAL, "[PHC]:oem_panel.c soc_version = 0X%x value,gpio_state=%d\n",soc_version,gpio_state);
- if(0x6089 == lk_lcd_id || 0xFFFF == lk_lcd_id){ <span style="color:#009900;">
- if(gpio_state){ <span style="color:#009900;">
- panel_id = ILI9806E_WVGA_VIDEO_HONGTAO_PANEL;
- dprintf(CRITICAL,"[PHC]: ILI9806E hongtao panel choosed\n");
- } else {
- panel_id = ILI9806E_WVGA_VIDEO_HAIFEI_PANEL;
- dprintf(CRITICAL,"[PHC]: ILI9806E haifei panel choosed\n");
- }
- }
- else if(0x8018 == lk_lcd_id){ <span style="background-color: rgb(255, 255, 255);"><span style="color:#009900;">
- if(gpio_state){
- panel_id = OTM8019_WVGA_VIDEO_SUXIAN_PANEL;
- dprintf(CRITICAL,"[PHC]: otm8019 panel choosed\n");
- } else {
- panel_id = OTM8019_WVGA_VIDEO_HAOSHITONG_PANEL;
- dprintf(CRITICAL,"[PHC]: otm8018b panel choosed\n");
- }
- }
- else if (0x3551 == lk_lcd_id){ <span style="font-family: Arial, Helvetica, sans-serif;"><span style="color:#009900;">
-
- panel_id = NT35512S_WVGA_VIDEO_HAIFEI_PANEL;
- dprintf(CRITICAL,"[PHC]: NT35512S haifei panel choosed\n");
- }
- panel_init:
- pinfo->pipe_type = MDSS_MDP_PIPE_TYPE_RGB;
- return init_panel_data(panelstruct, pinfo, phy_db);
- }
3、mdss_dsi_initialize()
mdss_dsi_initialize() 在文件Android/bootable/bootloader/lk/platform/msm_shared/mipi_dsi.c 中
在 mipi_dsi.c 文件开始先申明全局变量 lk_lcd_id
- uint32_t lk_lcd_id = 0xFFFF;
-
-
-
-
-
-
- int mdss_dsi_panel_initialize(struct mipi_dsi_panel_config *pinfo, uint32_t
- broadcast)
- {
- int status = 0;
-
- #if (DISPLAY_TYPE_MDSS == 1)
- <span style="background-color: rgb(255, 255, 255);"><span style="color:#cc33cc;"> if (0xffff == lk_lcd_id ){ </span><span style="color:#009900;">
- lk_lcd_id = read_panel_id(); </span><span style="color:#009900;">
- target_force_cont_splash_disable(true);
- msm_display_off();
- target_force_cont_splash_disable(false);
- target_display_init(NULL); </span><span style="color:#009900;">
- return 1;
- }</span></span>
- if (pinfo->panel_cmds) {
- if (broadcast) {
- status = mdss_dual_dsi_cmds_tx(pinfo->panel_cmds,
- pinfo->num_of_panel_cmds);
-
- } else {
- status = mipi_dsi_cmds_tx(pinfo->panel_cmds,
- pinfo->num_of_panel_cmds);
- if (!status && target_panel_auto_detect_enabled())
- status =
- mdss_dsi_read_panel_signature(pinfo->signature);
- }
- dprintf(CRITICAL,"[PHC]: status=%d\n",status);
- }
- #endif
- return status;
- }
4、read_panel_id()
read_panel_id()为读取LCM ID的函数,里面包括读取各中IC函数,详细看下面代码。
- <pre name="code" class="cpp">
-
-
-
-
-
-
- uint32_t read_panel_id(void)
- {
- uint32_t lcd_id = 0xffff;
- <span style="white-space:pre"> </span>if( mdss_dsi_read_ili9806e_id() )
- <span style="white-space:pre"> </span>lcd_id = 0x6089;
- <span style="white-space:pre"> </span>else if( mdss_dsi_read_otm8018b_id())
- <span style="white-space:pre"> </span>lcd_id = 0x8018;
- <span style="white-space:pre"> </span>else if( mdss_dsi_read_nt35512s_id() )
- <span style="white-space:pre"> </span>lcd_id = 0x3551;
- if(lcd_id == 0xffff){
- lcd_id = 0x1283;
- dprintf(CRITICAL,"[PHC]: no panel id readed use default \n");
- return lcd_id;
- }
不同IC的读取ID的函数都大同小异,我这里就用ili9806e这颗IC来举例:
- <pre name="code" class="cpp">static struct mipi_dsi_cmd apex_ili9806e_panel_set_cmd[] = {
- {sizeof(apex_ili9806e_cmd0), apex_ili9806e_cmd0},
- };
-
- static char apex_ili9806e_panel_set_pkt_size[4] = {0x08, 0x00, 0x37, 0x80};
- static struct mipi_dsi_cmd apex_ili9806e_panel_set_pkt_size_cmd[] = {
- {sizeof(apex_ili9806e_panel_set_pkt_size), apex_ili9806e_panel_set_pkt_size},};
- static char apex_ili9806e_panel_manufacture_id[4] = {0x00, 0x00, 0x06, 0xA0};
- static struct mipi_dsi_cmd apex_ili9806e_panel_manufacture_id_cmd[] = {
- {sizeof(apex_ili9806e_panel_manufacture_id), apex_ili9806e_panel_manufacture_id},};
- <pre name="code" class="cpp">static bool mdss_dsi_read_ili9806e_id(void)
- {
- char rec_buf[24];
- char *rp = rec_buf;
- uint32_t *lp,temp,ret, data = 0;
-
-
- ret = mipi_dsi_cmds_tx(apex_ili9806e_panel_set_cmd, ARRAY_SIZE(apex_ili9806e_panel_set_cmd));
- mdelay(10);
- ret = mipi_dsi_cmds_tx(apex_ili9806e_panel_set_pkt_size_cmd, ARRAY_SIZE(apex_ili9806e_panel_set_pkt_size_cmd));
- mdelay(10);
- ret = mipi_dsi_cmds_tx(apex_ili9806e_panel_manufacture_id_cmd, ARRAY_SIZE(apex_ili9806e_panel_manufacture_id_cmd));
- mdelay(10);
- if(ret == 1)
- lcm_id_retry += 1;
- mipi_dsi_cmds_rx(&rp, 3);
-
-
- lp = (uint32_t *)rp;
- data = (uint32_t)*lp;
- data = ntohl(data);
-
-
- data = data & 0xFF;
- dprintf(CRITICAL,"[PHC]: ili9806e id: 0x%x\n", data);
- if(data == 0x98) {
- lcm_id_retry = 0;
- return true;
- }
- else
- return false;
- }
到此,整个lk中LCM兼容和移植的主体部分就已经完成了,剩下就是填LCM参数进.h文件,这里再对整个流程进行一个补充整理。
首先解释下为什么不用高通默认的兼容方法,因为高通默认的兼容需要用到各种硬件id,平台id,这些都是在SBL中设定的,修改起来麻烦,而且可以兼容的屏幕个数有限,我上面所说的这种方法加上我拓展的一些代码,已经可以兼容十多块屏幕。
整个兼容方法的思路是,在LCM进行第一遍初始化的时候,什么都不变,但进行到mipi_dsi.c文件中的mdss_dsi_initialize()函数的时候,回去读当前使用的LCM IC 的id
,如果和默认的屏幕id一样,则不进行第二次初始化,若不一样,则重新初始化,这个时候全局变量lk_lcd_id已经被赋值,当第二遍初始化到了oem_panel.c文件的oem_panel_select()函数中,函数根据lk_lcd_id的值来匹配正确的屏幕变量。匹配完成之后继续未完成的屏幕初始化,至此整个流程走完,屏幕点亮!
文章介绍完毕,如有错误欢迎大家指正~