一、lk进入kmain()

1. vendor/mediatek/proprietary/bootable/bootloader/lk/arch/arm/srt0.S

 bl        kmain

二、初始化lk,分配framebuffer

1. vendor/mediatek/proprietary/bootable/bootloader/lk/kernel/main.c

 void kmain(void)
{
#if !defined(MACH_FPGA) && !defined(SB_LK_BRINGUP)
boot_time = get_timer();
#endif // get us into some sort of thread context
thread_init_early(); // early arch stuff
arch_early_init(); // do any super early platform initialization
platform_early_init(); #if defined(MACH_FPGA) || defined(SB_LK_BRINGUP)
boot_time = get_timer();
#endif // do any super early target initialization
target_early_init(); dprintf(INFO, "welcome to lk\n\n"); // deal with any static constructors
dprintf(SPEW, "calling constructors\n");
call_constructors(); // bring up the kernel heap
dprintf(SPEW, "initializing heap\n");
heap_init(); // initialize the threading system
dprintf(SPEW, "initializing threads\n");
thread_init(); // initialize the dpc system
dprintf(SPEW, "initializing dpc\n");
dpc_init(); // initialize kernel timers
dprintf(SPEW, "initializing timers\n");
timer_init(); #ifdef MTK_LK_IRRX_SUPPORT
mtk_ir_init();
#endif #if (!ENABLE_NANDWRITE)
// create a thread to complete system initialization
dprintf(SPEW, "creating bootstrap completion thread\n");
thread_resume(thread_create("bootstrap2", &bootstrap2, NULL, DEFAULT_PRIORITY, DEFAULT_STACK_SIZE)); // enable interrupts
exit_critical_section(); // become the idle thread
thread_become_idle();
#else
bootstrap_nandwrite();
#endif
}
 static int bootstrap2(void *arg)
{
dprintf(SPEW, "top of bootstrap2()\n"); arch_init(); // XXX put this somewhere else
#if WITH_LIB_BIO
bio_init();
#endif
#if WITH_LIB_FS
fs_init();
#endif // initialize the rest of the platform
dprintf(SPEW, "initializing platform\n"); platform_init(); // initialize the target
dprintf(SPEW, "initializing target\n");
target_init(); dprintf(SPEW, "calling apps_init()\n");
apps_init(); return ;
}

 2. vendor/mediatek/proprietary/bootable/bootloader/lk/platform/mt6735/platform.c

 void platform_init(void)
{
#ifdef LK_PROFILING
unsigned int time_nand_emmc;
unsigned int time_led_init;
unsigned int time_env;
unsigned int time_disp_init;
unsigned int time_load_logo;
unsigned int time_backlight;
unsigned int time_boot_mode;
#ifdef MTK_SECURITY_SW_SUPPORT
unsigned int time_security_init;
#endif
unsigned int time_bat_init;
unsigned int time_RTC_boot_Check;
unsigned int time_show_logo;
unsigned int time_sw_env;
unsigned int time_platform_init; time_platform_init = get_timer();
#endif
u64 pl_start_addr = ;
plinfo_get_brom_header_block_size(&pl_start_addr); dprintf(CRITICAL," ==LK info ==\n");
dprintf(CRITICAL," Build time:%s, %s\n", __DATE__,__TIME__);
dprintf(CRITICAL," chip_code[0x%x]\n", mt_get_chip_hw_code());
dprintf(CRITICAL," chip_ver[0x%x]\n", mt_get_chip_sw_ver());
dprintf(CRITICAL," ==LK info ==\n");
dprintf(CRITICAL, "platform_init()\n"); #if defined (MTK_EFUSE_DOWNGRADE)
set_sw_segment_code();
#endif mt_set_gpio_mode(GPIO11, GPIO_MODE_00);
mt_set_gpio_dir(GPIO11, GPIO_DIR_OUT);
mt_set_gpio_out(GPIO11, GPIO_OUT_ZERO); mt_set_gpio_mode(GPIO119, GPIO_MODE_00);
mt_set_gpio_dir(GPIO119, GPIO_DIR_OUT);
mt_set_gpio_out(GPIO119, GPIO_OUT_ZERO); #ifdef DUMMY_AP
dummy_ap_entry();
#endif #ifdef LK_PROFILING
time_nand_emmc = get_timer();
#endif
#ifdef MTK_EMMC_SUPPORT
mmc_legacy_init();
#else
#ifndef MACH_FPGA
nand_init();
nand_driver_test();
#endif
#endif
#ifdef LK_PROFILING
dprintf(INFO, "[PROFILE] ------- NAND/EMMC init takes %d ms -------- \n", (int)get_timer(time_nand_emmc));
#endif
#if defined(CFG_DTB_EARLY_LOADER_SUPPORT) if (bldr_load_dtb("boot")<)
{
printf("bldr_load_dtb fail\n");
}
else
{
printf("bldr_load_dtb success\n");
} #endif #ifndef MACH_FPGA
#ifdef LK_PROFILING
time_led_init = get_timer();
#endif
leds_init();
#ifdef LK_PROFILING
dprintf(INFO, "[PROFILE] ------- led init takes %d ms -------- \n", (int)get_timer(time_led_init));
#endif
#endif #ifdef MTK_KERNEL_POWER_OFF_CHARGING
if ((g_boot_arg->boot_reason == BR_USB) && (upmu_is_chr_det() == KAL_FALSE)) {
dprintf(INFO, "[%s] Unplugged Charger/Usb between Pre-loader and Uboot in Kernel Charging Mode, Power Off \n", __func__);
mt6575_power_off();
}
#endif #ifdef LK_PROFILING
time_env = get_timer();
#endif
env_init();
print_env();
#ifdef MTK_USB2JTAG_SUPPORT
extern void usb2jtag_init(void);
usb2jtag_init();
#endif
#ifdef LK_PROFILING
dprintf(INFO, "[PROFILE] ------- ENV init takes %d ms -------- \n", (int)get_timer(time_env));
#endif #ifdef LK_PROFILING
time_disp_init = get_timer();
#endif /* initialize the frame buffet information */
#ifndef MACH_FPGA_NO_DISPLAY
g_fb_size = mt_disp_get_vram_size();
#else
g_fb_size = 0x1000000;
#endif #if 0
g_fb_base = memory_size() - g_fb_size + DRAM_PHY_ADDR;
#else #if 0
if (g_is_64bit_kernel) {
g_fb_base = mblock_reserve(&g_boot_arg->mblock_info, g_fb_size, 0x200000, 0x100000000, RANKMAX);
g_fb_base = ALIGN_TO(g_fb_base,0x200000); // size 2MB align
} else {
g_fb_base = mblock_reserve(&g_boot_arg->mblock_info, g_fb_size, 0x100000, 0x100000000, RANKMAX);
}
#else
g_fb_base = mblock_reserve(&g_boot_arg->mblock_info, g_fb_size, 0x10000, 0x100000000, RANKMAX);
#endif if (!g_fb_base) {
/* ERROR */
}
#endif dprintf(CRITICAL, "FB base = 0x%x, FB size = %d\n", g_fb_base, g_fb_size); #ifndef MACH_FPGA_NO_DISPLAY
mt_disp_init((void *)g_fb_base);
/* show black picture fisrtly in case of backlight is on before nothing is drawed*/
mt_disp_fill_rect(, , CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT, 0x0);
mt_disp_update(, , CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT);
#ifdef LK_PROFILING
dprintf(INFO, "[PROFILE] ------- disp init takes %d ms -------- \n", (int)get_timer(time_disp_init));
#endif #ifdef MTK_SECURITY_SW_SUPPORT
#ifdef LK_PROFILING
time_security_init = get_timer();
#endif /* initialize security library */
sec_func_init(pl_start_addr); #ifdef LK_PROFILING
dprintf(INFO,"[PROFILE] ------- Security init takes %d ms -------- \n", (int)get_timer(time_security_init));
#endif seclib_set_oemkey(g_oemkey, OEM_PUBK_SZ);
/* logo image authentication */
if ( != sec_logo_check() ) {
dprintf(CRITICAL,"<ASSERT> %s:line %d\n",__FILE__,__LINE__);
while ();
}
#ifdef MTK_DTBO_FEATURE
/* dtbo image authentication */
if ( != sec_dtbo_check() ) {
dprintf(CRITICAL,"<ASSERT> %s:line %d\n",__FILE__,__LINE__);
while ();
}
#endif
#endif
drv_video_init();
#endif /*for kpd pmic mode setting*/
set_kpd_pmic_mode(); #ifndef MACH_FPGA
#ifdef LK_PROFILING
time_boot_mode = get_timer();
#endif
boot_mode_select();
#ifdef CFG_DTB_EARLY_LOADER_SUPPORT
/* reload dtb when boot mode = recovery */
if ((g_boot_mode == RECOVERY_BOOT) && (bldr_load_dtb("recovery") < ))
dprintf(CRITICAL, "bldr_load_dtb fail\n");
#endif #ifdef LK_PROFILING
dprintf(INFO, "[PROFILE] ------- boot mode select takes %d ms -------- \n", (int)get_timer(time_boot_mode));
#endif
#endif #ifndef MACH_FPGA_NO_DISPLAY
#ifdef LK_PROFILING
time_load_logo = get_timer();
#endif
mboot_common_load_logo((unsigned long)mt_get_logo_db_addr_pa(), "logo");
#ifdef LK_PROFILING
dprintf(INFO, "[PROFILE] ------- load_logo takes %d ms -------- \n", (int)get_timer(time_load_logo));
#endif
#endif /*Show download logo & message on screen */
if (g_boot_arg->boot_mode == DOWNLOAD_BOOT) {
dprintf(CRITICAL, "[LK] boot mode is DOWNLOAD_BOOT\n"); #ifdef MTK_SECURITY_SW_SUPPORT
/* verify da before jumping to da*/
if (sec_usbdl_enabled()) {
u8 *da_addr = (u8*)g_boot_arg->da_info.addr;
u32 da_len = g_boot_arg->da_info.len;
u32 sig_len = g_boot_arg->da_info.sig_len;
u8 *sig_addr = (unsigned char *)da_addr + (da_len - sig_len); if (da_len == || sig_len == ) {
dprintf(INFO, "[LK] da argument is invalid\n");
dprintf(INFO, "da_addr = 0x%x\n", (int)da_addr);
dprintf(INFO, "da_len = 0x%x\n", da_len);
dprintf(INFO, "sig_len = 0x%x\n", sig_len);
} if (sec_usbdl_verify_da(da_addr, (da_len - sig_len), sig_addr, sig_len)) {
/* da verify fail */
video_printf(" => Not authenticated tool, download stop...\n");
while (); /* fix me, should not be infinite loop in lk */
}
} else
#endif
{
dprintf(INFO, " DA verification disabled...\n");
} #ifndef MACH_FPGA_NO_DISPLAY
mt_disp_show_boot_logo();
#endif
video_printf(" => Downloading...\n");
dprintf(CRITICAL, "enable backlight after show bootlogo! \n");
mt65xx_backlight_on(); mtk_wdt_disable(); //Disable wdt before jump to DA
platform_uninit();
#ifdef HAVE_CACHE_PL310
l2_disable();
#endif
arch_disable_cache(UCACHE);
arch_disable_mmu();
#ifdef ENABLE_L2_SHARING
config_shared_SRAM_size();
#endif jump_da(g_boot_arg->da_info.addr, g_boot_arg->da_info.arg1, g_boot_arg->da_info.arg2);
} #ifdef LK_PROFILING
time_bat_init = get_timer();
#endif
mt65xx_bat_init();
#ifdef LK_PROFILING
dprintf(INFO, "[PROFILE] ------- battery init takes %d ms -------- \n", (int)get_timer(time_bat_init));
#endif #ifndef CFG_POWER_CHARGING
#ifdef LK_PROFILING
time_RTC_boot_Check = get_timer();
#endif
/* NOTE: if define CFG_POWER_CHARGING, will rtc_boot_check() in mt65xx_bat_init() */
rtc_boot_check(false);
#ifdef LK_PROFILING
dprintf(INFO, "[PROFILE] ------- RTC boot check Init takes %d ms -------- \n", (int)get_timer(time_RTC_boot_Check));
#endif
#endif #ifdef LK_PROFILING
time_show_logo = get_timer();
#endif
#ifdef MTK_KERNEL_POWER_OFF_CHARGING
if (kernel_charging_boot() == ) {
#ifdef MTK_BATLOWV_NO_PANEL_ON_EARLY
CHARGER_TYPE CHR_Type_num = CHARGER_UNKNOWN;
CHR_Type_num = hw_charging_get_charger_type();
if ((g_boot_mode != LOW_POWER_OFF_CHARGING_BOOT) ||
((CHR_Type_num != STANDARD_HOST) && (CHR_Type_num != NONSTANDARD_CHARGER))) {
#endif
mt_disp_power(TRUE);
mt_disp_show_low_battery();
mt65xx_leds_brightness_set(, );
#ifdef MTK_BATLOWV_NO_PANEL_ON_EARLY
}
#endif
} else if (g_boot_mode != KERNEL_POWER_OFF_CHARGING_BOOT && g_boot_mode != LOW_POWER_OFF_CHARGING_BOOT) {
if (g_boot_mode != ALARM_BOOT && (g_boot_mode != FASTBOOT)) {
#ifndef MACH_FPGA_NO_DISPLAY
mt_disp_show_boot_logo();
#endif
}
}
#else
if (g_boot_mode != ALARM_BOOT && (g_boot_mode != FASTBOOT)) {
#ifndef MACH_FPGA_NO_DISPLAY
mt_disp_show_boot_logo();
#endif
}
#endif
#ifdef LK_PROFILING
time_backlight = get_timer();
#endif #ifdef MTK_BATLOWV_NO_PANEL_ON_EARLY
if (!is_low_battery()) {
#endif
mt65xx_backlight_on();
#ifndef MACH_FPGA_NO_DISPLAY
//pwm need display sof
mt_disp_update(, , CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT);
#endif
#ifdef MTK_BATLOWV_NO_PANEL_ON_EARLY
}
#endif #ifdef LK_PROFILING
dprintf(INFO, "[PROFILE] ------- backlight takes %d ms -------- \n", (int)get_timer(time_backlight));
#endif #ifdef LK_PROFILING
dprintf(INFO, "[PROFILE] ------- show logo takes %d ms -------- \n", (int)get_timer(time_show_logo));
#endif #ifndef MACH_FPGA
#ifdef LK_PROFILING
time_sw_env = get_timer();
#endif
sw_env();
#ifdef LK_PROFILING
dprintf(INFO, "[PROFILE] ------- sw_env takes %d ms -------- \n", (int)get_timer(time_sw_env));
#endif
#endif #ifdef LK_PROFILING
dprintf(INFO, "[PROFILE] ------- platform_init takes %d ms -------- \n", (int)get_timer(time_platform_init));
#endif
}

 3. vendor/mediatek/proprietary/bootable/bootloader/lk/platform/mt6735/mt_disp_drv.c

 UINT32 mt_disp_get_vram_size(void)
{
return DISP_GetVRamSize();
}

 4. vendor/mediatek/proprietary/bootable/bootloader/lk/platform/mt6735/primary_display.c

 unsigned int DISP_GetVRamSize(void)
{
static UINT32 vramSize = ; printf("jjh DISP_GetVRamSize\n"); if ( == vramSize) {
vramSize = DISP_GetFBRamSize(); vramSize += DAL_GetLayerSize(); #if 0
if (g_is_64bit_kernel) {
vramSize = ALIGN_TO(vramSize, 0x400000); // both start addr and size needs 2MB align, so size must 4MB align
} else {
vramSize = ALIGN_TO(vramSize, 0x100000); // both start addr and size needs 2MB align, so size must 4MB align
}
#else
vramSize = ALIGN_TO(vramSize, 0x10000); // just align to 64KB is OK
#endif DISPMSG("^^ DISP_GetVRamSize: %u bytes\n", vramSize);
} return vramSize;
}
 UINT32 DISP_GetFBRamSize(void)
{
return ALIGN_TO(DISP_GetScreenWidth(), MTK_FB_ALIGNMENT) * DISP_GetScreenHeight() * ((DISP_GetScreenBpp() + ) >> ) * DISP_GetPages();
}
 UINT32 DISP_GetScreenWidth(void)
{
return primary_display_get_width();
}
 int primary_display_get_width(void)
{
if (pgc->plcm == NULL) {
pgc->plcm = disp_lcm_probe(NULL, LCM_INTERFACE_NOTDEFINED);
DISPMSG("lcm handle is null, after probe:0x%08x\n",pgc->plcm);
if (pgc->plcm == NULL)
return ;
} if (pgc->plcm->params) {
return pgc->plcm->params->width;
} else {
DISPERR("lcm_params is null!\n");
return ;
}
}

 5. vendor/mediatek/proprietary/bootable/bootloader/lk/platform/mt6735/disp_lcm.c

 /* if lcm handle already probed, should return lcm handle directly */
disp_lcm_handle *disp_lcm_probe(char *plcm_name, LCM_INTERFACE_ID lcm_id)
{
DISPFUNC(); int ret = ;
bool isLCMFound = false;
bool isLCMConnected = false; LCM_DRIVER *lcm_drv = NULL;
LCM_PARAMS *lcm_param = NULL;
disp_lcm_handle *plcm = NULL; #if defined(MTK_LCM_DEVICE_TREE_SUPPORT)
bool isLCMDtFound = false; if (check_lcm_node_from_DT() == ) {
lcm_drv = &lcm_common_drv;
isLCMFound = true;
isLCMDtFound = true;
} else
#endif
if (_lcm_count() == ) {
DISPERR("no lcm driver defined in linux kernel driver\n");
return NULL;
} else if (_lcm_count() == ) {
lcm_drv = lcm_driver_list[];
isLCMFound = true;
} else {
/* in lk, plcm_name should always be NULL */
if (plcm_name == NULL) {
int i = ;
disp_path_handle handle = NULL;
disp_lcm_handle hlcm;
disp_lcm_handle *plcm = &hlcm;
LCM_PARAMS hlcm_param; for (i=; i<_lcm_count(); i++) {
memset((void*)&hlcm, , sizeof(disp_lcm_handle));
memset((void*)&hlcm_param, , sizeof(LCM_PARAMS)); lcm_drv= lcm_driver_list[i];
lcm_drv->get_params(&hlcm_param);
plcm->drv = lcm_drv;
plcm->params = &hlcm_param;
plcm->lcm_if_id = plcm->params->lcm_if;
DISPMSG("we will check lcm: %s\n", lcm_drv->name);
if (lcm_id == LCM_INTERFACE_NOTDEFINED ||(lcm_id != LCM_INTERFACE_NOTDEFINED && plcm->lcm_if_id == lcm_id)) {
handle = _display_interface_path_init(plcm);
if (handle == NULL) {
DISPERR("_display_interface_path_init returns NULL\n");
goto FAIL;
} if (lcm_drv->init_power) {
lcm_drv->init_power();
} if (lcm_drv->compare_id != NULL) {
if (lcm_drv->compare_id() != ) {
isLCMFound = true;
_display_interface_path_deinit(handle);
dprintf(INFO,"we will use lcm: %s\n", lcm_drv->name);
break;
}
} _display_interface_path_deinit(handle);
}
} if (isLCMFound == false) {
DISPERR("we have checked all lcm driver, but no lcm found\n");
lcm_drv = lcm_driver_list[];
isLCMFound = true;
}
} else {
int i = ;
for (i=; i<_lcm_count(); i++) {
lcm_drv = lcm_driver_list[i];
if (!strcmp(lcm_drv->name, plcm_name)) {
isLCMFound = true;
break;
}
}
}
} if (isLCMFound == false) {
DISPERR("FATAL ERROR!!!No LCM Driver defined\n");
return NULL;
} plcm = &_disp_lcm_driver[0];
95 lcm_param = &_disp_lcm_params;
if (plcm && lcm_param) {
plcm->params = lcm_param;
plcm->drv = lcm_drv;
} else {
DISPERR("FATAL ERROR!!!kzalloc plcm and plcm->params failed\n");
goto FAIL;
} #if defined(MTK_LCM_DEVICE_TREE_SUPPORT)
if (isLCMDtFound == true)
load_lcm_resources_from_DT(plcm->drv);
#endif plcm->drv->get_params(plcm->params);
plcm->lcm_if_id = plcm->params->lcm_if;
/* below code is for lcm driver forward compatible */
if (plcm->params->type == LCM_TYPE_DSI && plcm->params->lcm_if == LCM_INTERFACE_NOTDEFINED)
plcm->lcm_if_id = LCM_INTERFACE_DSI0;
if (plcm->params->type == LCM_TYPE_DPI && plcm->params->lcm_if == LCM_INTERFACE_NOTDEFINED)
plcm->lcm_if_id = LCM_INTERFACE_DPI0;
if (plcm->params->type == LCM_TYPE_DBI && plcm->params->lcm_if == LCM_INTERFACE_NOTDEFINED)
plcm->lcm_if_id = LCM_INTERFACE_DBI0;
#if 1
plcm->is_connected = isLCMConnected;
#endif _dump_lcm_info(plcm);
return plcm; FAIL: return NULL;
}
 int _lcm_count(void)
{
return lcm_count;
}

lcm_count在vendor/mediatek/proprietary/bootable/bootloader/lk/dev/lcm/mt65xx_lcm_list.c中定义:

 unsigned int lcm_count = sizeof(lcm_driver_list) / sizeof(LCM_DRIVER *);

三、 disp 初始化

vendor/mediatek/proprietary/bootable/bootloader/lk/platform/mt6735/platform.c

     mt_disp_init((void *)g_fb_base);

 1. vendor/mediatek/proprietary/bootable/bootloader/lk/platform/mt6735/mt_disp_drv.c

 void mt_disp_init(void *lcdbase)
{
unsigned int lcm_fake_width = ;
unsigned int lcm_fake_height = ;
UINT32 boot_mode_addr = ;
/// fb base pa and va
fb_addr_pa_k = arm_mmu_va2pa(lcdbase); fb_addr_pa = fb_addr_pa_k & 0xffffffffull;
fb_addr = lcdbase; dprintf(,"fb_va: 0x%08x, fb_pa: 0x%08x, fb_pa_k: 0x%llx\n", fb_addr, fb_addr_pa, fb_addr_pa_k); fb_size = ALIGN_TO(CFG_DISPLAY_WIDTH, MTK_FB_ALIGNMENT) * CFG_DISPLAY_HEIGHT * CFG_DISPLAY_BPP / ;
// pa;
boot_mode_addr = ((UINT32)fb_addr_pa + fb_size);
logo_db_addr_pa = (void *)((UINT32)fb_addr_pa - * * ); // va;
logo_db_addr = (void *)((UINT32)fb_addr - * * ); fb_offset_logo = ; primary_display_init(NULL);
memset((void*)lcdbase, 0x0, DISP_GetVRamSize()); disp_input_config input;
memset(&input, , sizeof(disp_input_config));
input.layer = BOOT_MENU_LAYER;
input.layer_en = ;
input.fmt = redoffset_32bit ? eBGRA8888 : eRGBA8888;
input.addr = boot_mode_addr;
input.src_x = ;
input.src_y = ;
input.src_w = CFG_DISPLAY_WIDTH;
input.src_h = CFG_DISPLAY_HEIGHT;
input.src_pitch = CFG_DISPLAY_WIDTH*;
input.dst_x = ;
input.dst_y = ;
input.dst_w = CFG_DISPLAY_WIDTH;
input.dst_h = CFG_DISPLAY_HEIGHT;
input.aen = ;
input.alpha = 0xff; primary_display_config_input(&input); memset(&input, , sizeof(disp_input_config));
input.layer = FB_LAYER;
input.layer_en = ;
input.fmt = redoffset_32bit ? eBGRA8888 : eRGBA8888;
input.addr = fb_addr_pa;
input.src_x = ;
input.src_y = ;
input.src_w = CFG_DISPLAY_WIDTH;
input.src_h = CFG_DISPLAY_HEIGHT;
input.src_pitch = ALIGN_TO(CFG_DISPLAY_WIDTH, MTK_FB_ALIGNMENT)*;
input.dst_x = ;
input.dst_y = ;
input.dst_w = CFG_DISPLAY_WIDTH;
input.dst_h = CFG_DISPLAY_HEIGHT; input.aen = ;
input.alpha = 0xff;
primary_display_config_input(&input); //_mtkfb_internal_test(fb_addr, CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT); #if 0
mt_disp_parse_dfo_setting(); if (( == mt_disp_get_dfo_setting("LCM_FAKE_WIDTH", &lcm_fake_width)) && ( == mt_disp_get_dfo_setting("LCM_FAKE_HEIGHT", &lcm_fake_height))) {
if (DISP_STATUS_OK != DISP_Change_LCM_Resolution(lcm_fake_width, lcm_fake_height)) {
dprintf(INFO,"[DISP_DFO]WARNING!!! Change LCM Resolution FAILED!!!\n");
}
}
#endif }

 2. vendor/mediatek/proprietary/bootable/bootloader/lk/platform/mt6735/primary_display.c

 int primary_display_init(char *lcm_name)
{
DISPFUNC();
DISP_STATUS ret = DISP_STATUS_OK;
DISP_MODULE_ENUM dst_module = ; unsigned int lcm_fake_width = ;
unsigned int lcm_fake_height = ;
LCM_PARAMS *lcm_param = NULL;
LCM_INTERFACE_ID lcm_id = LCM_INTERFACE_NOTDEFINED; dpmgr_init();
#ifndef DDP_LK_BOOT
mutex_init(&(pgc->lock));
#endif
_primary_path_lock(); if (pgc->plcm == NULL)
pgc->plcm = disp_lcm_probe( lcm_name, LCM_INTERFACE_NOTDEFINED);
mt_disp_parse_dfo_setting(); if (( == mt_disp_get_dfo_setting("LCM_FAKE_WIDTH", &lcm_fake_width)) && ( == mt_disp_get_dfo_setting("LCM_FAKE_HEIGHT", &lcm_fake_height))) { if ( != primary_display_change_lcm_resolution(lcm_fake_width, lcm_fake_height)) {
DISPERR("[DISP_DFO]WARNING!!! Change LCM Resolution FAILED!!!\n");
}
} if (pgc->plcm == NULL) {
DISPCHECK("disp_lcm_probe returns null\n");
ret = DISP_STATUS_ERROR;
goto done;
} else {
DISPCHECK("disp_lcm_probe SUCCESS\n");
} lcm_param = disp_lcm_get_params(pgc->plcm); if (lcm_param == NULL) {
DISPERR("get lcm params FAILED\n");
ret = DISP_STATUS_ERROR;
goto done;
} if (primary_display_mode == DIRECT_LINK_MODE) {
_build_path_direct_link(); DISPCHECK("primary display is DIRECT LINK MODE\n");
} else if (primary_display_mode == DECOUPLE_MODE) {
_build_path_decouple(); DISPCHECK("primary display is DECOUPLE MODE\n");
} else if (primary_display_mode == SINGLE_LAYER_MODE) {
_build_path_single_layer(); DISPCHECK("primary display is SINGLE LAYER MODE\n");
} else if (primary_display_mode == DEBUG_RDMA1_DSI0_MODE) {
_build_path_debug_rdma1_dsi0(); DISPCHECK("primary display is DEBUG RDMA1 DSI0 MODE\n");
} else {
DISPCHECK("primary display mode is WRONG\n");
} _build_cmdq_trigger_loop(); DISPCHECK("primary display BUILD cmdq trigger loop finished\n"); _start_cmdq_trigger_loop(); DISPCHECK("primary display START cmdq trigger loop finished\n"); dpmgr_path_set_video_mode(pgc->dpmgr_handle, primary_display_is_video_mode()); dpmgr_path_init(pgc->dpmgr_handle, CMDQ_DISABLE); #ifdef MACH_FPGA
dpmgr_path_reset(pgc->dpmgr_handle, CMDQ_DISABLE);
#endif disp_ddp_path_config data_config;
memset((void*)&data_config, , sizeof(disp_ddp_path_config)); memcpy(&(data_config.dsi_config), &(lcm_param->dsi), sizeof(LCM_DSI_PARAMS)); data_config.dst_w = lcm_param->width;
data_config.dst_h = lcm_param->height;
if (lcm_param->type == LCM_TYPE_DSI) {
if (lcm_param->dsi.data_format.format == LCM_DSI_FORMAT_RGB888)
data_config.lcm_bpp = ;
else if (lcm_param->dsi.data_format.format == LCM_DSI_FORMAT_RGB565)
data_config.lcm_bpp = ;
else if (lcm_param->dsi.data_format.format == LCM_DSI_FORMAT_RGB666)
data_config.lcm_bpp = ;
} else if (lcm_param->type == LCM_TYPE_DPI) {
if ( lcm_param->dpi.format == LCM_DPI_FORMAT_RGB888)
data_config.lcm_bpp = ;
else if ( lcm_param->dpi.format == LCM_DPI_FORMAT_RGB565)
data_config.lcm_bpp = ;
if ( lcm_param->dpi.format == LCM_DPI_FORMAT_RGB666)
data_config.lcm_bpp = ;
}
data_config.dst_dirty = ;
#ifdef MACH_FPGA
data_config.ovl_dirty = ;
#endif ret = dpmgr_path_config(pgc->dpmgr_handle, &data_config, CMDQ_DISABLE);
ret = disp_lcm_init(pgc->plcm); if (primary_display_is_video_mode()) {
dpmgr_map_event_to_irq(pgc->dpmgr_handle, DISP_PATH_EVENT_IF_VSYNC, DDP_IRQ_RDMA0_DONE);
} else { } dpmgr_enable_event(pgc->dpmgr_handle, DISP_PATH_EVENT_IF_VSYNC);
dpmgr_enable_event(pgc->dpmgr_handle, DISP_PATH_EVENT_FRAME_DONE); #if ROME_TODO
if (esd_check_enable) {
wakeup(esd_check_task);
}
#endif pgc->state = ; done: _primary_path_unlock();
return ret;
}

 3. vendor/mediatek/proprietary/bootable/bootloader/lk/platform/mt6735/disp_lcm.c

 int disp_lcm_init(disp_lcm_handle *plcm)
{
DISPFUNC();
LCM_DRIVER *lcm_drv = NULL;
bool isLCMConnected = false; if (_is_lcm_inited(plcm)) {
lcm_drv = plcm->drv; if (lcm_drv->init_power) {
lcm_drv->init_power();
} if (lcm_drv->init) {
if (!disp_lcm_is_inited(plcm)) {
lcm_drv->init();
}
} else {
DISPERR("FATAL ERROR, lcm_drv->init is null\n");
return -;
}
#if 1
if (LCM_TYPE_DSI == plcm->params->type) {
int ret = ;
char buffer = ;
unsigned int data_array[]; /*
* Some LCD may return fail when reading register 0x0A due to no getting maximum return size.
* Therefore, we add a command here to read maximum return size to avoid this problem.
*/
data_array[] = 0x00013700; /* read a byte. */
ret = DSI_set_cmdq(_get_dst_module_by_lcm(plcm), NULL, data_array, , ); /* read maximum return size. */
if (ret == ) {
DISPMSG("read lcm maximum return size failed.\n");
} ret =
DSI_dcs_read_lcm_reg_v2(_get_dst_module_by_lcm(plcm), NULL, 0x0A,
&buffer, );
if (ret == ) {
isLCMConnected = ;
DISPMSG("lcm is not connected\n");
} else {
isLCMConnected = ;
DISPMSG("lcm is connected\n");
}
}
if (plcm->params->dsi.edp_panel == ) {
isLCMConnected = ;
}
plcm->is_connected = isLCMConnected;
#endif
return ;
} else {
DISPERR("plcm is null\n");
return -;
}
}

四、 disp LOGO 初始化

vendor/mediatek/proprietary/bootable/bootloader/lk/platform/mt6735/platform.c

 /* show black picture fisrtly in case of  backlight is on before nothing is drawed*/
mt_disp_fill_rect(, , CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT, 0x0);
mt_disp_update(, , CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT);

1. vendor/mediatek/proprietary/bootable/bootloader/lk/platform/mt6735/mt_logo.c

 /*
* Fill rectangle region for with black or other color
*
*/
void mt_disp_fill_rect(UINT32 left, UINT32 top,
UINT32 right, UINT32 bottom,
UINT32 color)
{
dprintf(INFO, "[lk logo: %s %d]\n",__FUNCTION__,__LINE__);
init_fb_screen();
RECT_REGION_T rect = {left, top, right, bottom}; fill_rect_with_color(mt_get_fb_addr(), rect, color, phical_screen);
}
 /*
* Initliaze charging animation parameters
*
*/
void init_fb_screen()
{
dprintf(INFO, "[lk logo: %s %d]\n",__FUNCTION__,__LINE__);
unsigned int fb_size = mt_get_fb_size();
logo_addr = mt_get_logo_db_addr(); phical_screen.width = CFG_DISPLAY_WIDTH;
phical_screen.height = CFG_DISPLAY_HEIGHT;
phical_screen.fb_size = fb_size;
phical_screen.fill_dst_bits = CFG_DISPLAY_BPP;
phical_screen.bits_per_pixel = CFG_DISPLAY_BPP; // in JB2.MP need to allign width and height to 32 ,but jb5.mp needn't
phical_screen.needAllign = ;
phical_screen.allignWidth = ALIGN_TO(CFG_DISPLAY_WIDTH, MTK_FB_ALIGNMENT); /* In GB, no need to adjust 180 showing logo ,for fb driver dealing the change */
/* but in JB, need adjust it for screen 180 roration */
phical_screen.need180Adjust = ; // need sync with chip driver dprintf(INFO, "[lk logo: %s %d]MTK_LCM_PHYSICAL_ROTATION = %s\n",__FUNCTION__,__LINE__, MTK_LCM_PHYSICAL_ROTATION); if ( == strncmp(MTK_LCM_PHYSICAL_ROTATION, "", )) {
phical_screen.rotation = ;
} else if ( == strncmp(MTK_LCM_PHYSICAL_ROTATION, "", )) {
phical_screen.rotation = ;
} else if ( == strncmp(MTK_LCM_PHYSICAL_ROTATION, "", ) && (phical_screen.need180Adjust == )) {
phical_screen.rotation = ;
} else {
phical_screen.rotation = ;
} sync_anim_version();
if (show_animationm_ver == ) {
unsigned int logonum;
unsigned int *db_addr = logo_addr; unsigned int *pinfo = (unsigned int*)db_addr; logonum = pinfo[];
dprintf(INFO, "[lk logo: %s %d]pinfo[0]=0x%08x, pinfo[1]=0x%08x, pinfo[2]=%d\n", __FUNCTION__,__LINE__,
pinfo[], pinfo[], pinfo[]); dprintf(INFO, "[lk logo: %s %d]define ANIMATION_NEW:show new animation with capacity num\n",__FUNCTION__,__LINE__);
dprintf(INFO, "[lk logo: %s %d]CAPACITY_LEFT =%d, CAPACITY_TOP =%d \n",__FUNCTION__,__LINE__,(CAPACITY_LEFT) ,(CAPACITY_TOP) );
dprintf(INFO, "[lk logo: %s %d]LCM_HEIGHT=%d, LCM_WIDTH=%d \n",__FUNCTION__,__LINE__,(CAPACITY_RIGHT),(CAPACITY_BOTTOM));
if (logonum < ) {
show_animationm_ver = ;
} else {
show_animationm_ver = ;
}
} }

mtk lk阶段的lcm流程的更多相关文章

  1. MSM8909中LK阶段LCM屏适配与显示流程分析(二)

    1.前言 在前面的文章MSM8909中LK阶段LCM屏适配与显示流程分析(一),链接如下: https://www.cnblogs.com/Cqlismy/p/12019317.html 介绍了如何使 ...

  2. MSM8909中LK阶段LCM屏适配与显示流程分析(一)

    1.前言 在驱动开发中,我们往往需要适配一些新的屏幕或者调试一些屏幕的参数等,对于Qualcomm的MSM8909这款SoC,当启动Android系统时,会有一个LK阶段,该阶段用来启动Linux内核 ...

  3. MTK Android Driver :Lcm

    MTK Android Driver :lcm 1.怎样新建一个LCD驱动 LCD模组主要包括LCD显示屏和驱动IC.比如LF040DNYB16a模组的驱动IC型号为NT35510.要在MTK6577 ...

  4. mtk 的conferrence call建立流程

    (重点看main_log与) 抓mtk log: 1.*#*#82533284#*#*      进入抓log UI 2.*#*#825364#*#*      进入工程模式 3.进入"Lo ...

  5. Android系统之LK启动流程分析(一)

    1.前言 LK是Little Kernel的缩写,在Qualcomm平台的Android系统中普遍采用LK作为bootloader,它是一个开源项目,LK是整个系统的引导部分,所以不是独立存在的,但是 ...

  6. MTK Android Driver知识大全

    一.Display 1.lcm 相关概念1.1) MIPI接口:一共有三种接口:DBI(也做CPU或MCU接口).DPI(也叫RGB接口).DSI.在使用DSI接口时,目前75/77都只支持到2条da ...

  7. 【转】MTK Android Driver知识大全

    原文网址:http://www.cnblogs.com/biglucky/p/4413797.html 一.Display 1.lcm 相关概念1.1) MIPI接口:一共有三种接口:DBI(也做CP ...

  8. LCM在Kernel中的代码分析

    lcm的分析首先是mtkfb.c 1.mtk_init中platform_driver_register(&mtkfb_driver)注册平台驱动 panelmaster_init(); DB ...

  9. 高通spi 屏幕 -lk代码分析

    lk SPI驱动 1. 初始化时钟 在lk中,我们是从kmain开始执行下来的,而执行顺序则是先初始化时钟,也就是在platform_early_init函数中开始执行的: 在这里我们需要修改这个函数 ...

随机推荐

  1. 转: MySQL索引原理及慢查询优化 (from 美团技术博客)

    转: http://tech.meituan.com/mysql-index.html MySQL凭借着出色的性能.低廉的成本.丰富的资源,已经成为绝大多数互联网公司的首选关系型数据库.虽然性能出色, ...

  2. tomcat启动文件

    home目录下创建run.bat文件,文件内容如下: @echo off set JAVA_OPTS=-server -Xms1024m -Xmx1024m ^-XX:+UseG1GC ^-XX:Ma ...

  3. Cookie学习笔记二:Cookie实例

    今天说说刚刚学到的两个Cookie的最经典应用:自己主动登录和购物车设置 一:自己主动登录 须要两个页面:login.jsp与index.jsp,login.jsp用来输出登录信息,index.jsp ...

  4. XSS过滤

    XSS过滤封装用法 封装到app01/form.py文件中进行验证 from django.forms import Form,widgets,fields class ArticleForm(For ...

  5. 【转】VMware 11.0 简体中文版|附永久密钥

    VMware 11.0 简体中文版|附永久密钥 昨天,VMware虚拟机11.0 简体中文版正式发布,值得注意的是新版抛弃了32位系统支持,安装包体积大幅减小, 新增Windows 10 技术预览版支 ...

  6. centos下保留python2安装python3

    1. 安装依赖环境 # yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline- ...

  7. caffe学习--caffe入门classification00学习--ipython

    首先,数据文件和模型文件都已经下载并处理好,不提. cd   "caffe-root-dir " ----------------------------------分割线---- ...

  8. live555直播

    http://www.cppblog.com/tx7do/archive/2014/05/31/207155.aspx http://blog.csdn.net/sunkwei/article/det ...

  9. The server must be started under an unprivileged user ID to prevent

    mysql8 PostgreSQL [root@test local]# postgres -D /usr/local/pgsql/data"root" execution of ...

  10. NOIP考前感悟

    闭关这么久,后来突然后悔自己前几天和暑假的状态很頽 不然进步也还能多一点吧 还好提前发现了,最后也还是努力了一把 也算不枉费自己的选择吧 从初中开始学习OI,到头来也没有什么成果 但还好自己高一 也还 ...