原文地址:http://blog.csdn.net/dwyane_zhang/article/details/8441854
最近我们在做一个LCM两屏或三屏兼容的问题,所以首先要在uboot里面读出各屏的id,然后再将读得到的id传给recovery和kernel,实现机器的正常显示.
一.首先实现uboot读lcm的id.
1.bootable/bootloader/lk/target/msm7627a_sku3_Q6_D/rules.mk是uboot里面宏开关,打开所显示的屏宏
DEFINES += DISPLAY_MIPI_CMD_PANEL_ILI9487=1
DEFINES += DISPLAY_MIPI_CMD_PANEL_HX8357=1
2.去初始化mipi的地方先读id. bootable/bootloader/lk/platform/msm_shared/mipi_dsi.c
在函数int mipi_dsi_panel_initialize(struct mipi_dsi_panel_config *pinfo)
{
......
#if defined(DISPLAY_MIPI_CMD_PANEL_ILI9487)||defined(DISPLAY_MIPI_CMD_PANEL_HX8357)
mipi_dsi_cmd_bta_sw_trigger();
dat = mipi_viroyal_manufacture_id();
if(dat == 0x90)
{
lcm_flag = 8357; //hx8357-c
}
else
{
lcm_flag = 9487; //ili9487
}
pinfo_tmp =get_panel_info();
memcpy(pinfo, pinfo_tmp, sizeof(struct mipi_dsi_panel_config));
#endif
......
}
3.读到id后再初始化屏
struct mipi_dsi_panel_config *get_panel_info(void)
{
.........
#elif (DISPLAY_MIPI_CMD_PANEL_ILI9487)||(DISPLAY_MIPI_CMD_PANEL_HX8357)
if (lcm_flag == 8357)
return &hx8357_cmd_panel_info;
else
return &ili9487_cmd_panel_info;
#endif
..........
}
这样在uboot里面就成功可以显示图片了,下面是如何将lcm_flag的值传给kernel了.
二.传lcm_flag给kernel
1.uboot里面要做的bootable/bootloader/lk/app/aboot/aboot.c
其实原生态的android系统就有一个将uboot传给kernel的例子,那就是跟踪代码static const char *boot_splash = " splash=1";
我做的也是效仿系统做的,先定义一个字符串
static const char *lcm_flg_ili9486 = " lcmflag=9486";
static const char *lcm_flg_nt35310 = " lcmflag=5310";
然后在下面的函数copy到kernel
void boot_linux(void *kernel, unsigned *tags,
const char *cmdline, unsigned machtype,
void *ramdisk, unsigned ramdisk_size)
{
.....
if(!boot_into_recovery)
{
cmdline_len += strlen(boot_splash);
#if DISPLAY_TYPE_MIPI
if (lcm_flag == 8357)
cmdline_len += strlen(lcm_flg_hx8357c);
else
cmdline_len += strlen(lcm_flg_ili9487);
#endif
.....
if (!boot_into_recovery)
{
#if DISPLAY_TYPE_MIPI
if (lcm_flag == 8357)
src = lcm_flg_hx8357c;
else
src = lcm_flg_ili9487;
#endif
if (have_cmdline) --dst;
while ((*dst++ = *src++));
.....
}
这样uboot里面的动作就做完了,即是将uboot里面的数据copy到一个数组里面,这个数组能从uboot传给kernel.
三.kernel接受uboot传来的字符串
msm7627a/kernel/arch/arm/mach-msm/board-msm7x27a.c
在这个函数里面接受(依据自己用的平台阿,要灵活),同样是模仿boot_splash,在代码里添加接受字符串,并转化为数字
/* LK lcm_flag, 0 - off, 1 - on */
int lcm_flag = 0;
static int __init lk_lcmflag_setup(char *str)
{
lcm_flag = simple_strtol(str, NULL, 0);
printk("lcmflag = %d\n", lcm_flag);
return 1;
}
__setup("lcmflag=", lk_lcmflag_setup);
这样就算是取到lcm_flag的值了,然后在具体的驱动中extern int lcm_flag即可,简单吧.其实技术就那样,很怕人认真,呵呵.开玩笑的.