在内核的当前目录进入到drivers/video/console/fbcon.c 文件
将static void fb_flashcursor(void *private) 和 static void fbcon_cursor(struct vc_data *vc, int mode) 里的内容注释掉,使之变成空函数。
二、设置Linux内核启动Logo
(1) 让内核支持启动LOGO
在内核目录中 make menuconfig
Device Drivers ----> Graphics support ---->
选中 Bootup logo ----> Standard 224-color Linux logo
(2)制作一张启动LOGO的PNG格式的图片logo_linux_clut224.png
(3)sudo apt-get install netpbm
#pngtopnm logo_linux_clut224.png > logo_linux.pnm
#pnmquant 224 logo_linux.pnm > logo_linux_224.pnm
#pnmtoplainpnm logo_linux_224.pnm > logo_linux_clut224.ppm
(4)将LOGO文件放入内核中
拷贝到制作好的LOGO文件到 /drivers/video/logo 文件夹
替换 logo_linux_clut224.ppm 文件
(5)重新编译内核
三、居中显示
Linux 内核启动 Logo 居中显示需要修改下列两个源文件:
1.)drivers/video/console/fbcon.c
diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index 10c0b74..cdb3b6c 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -589,6 +589,7 @@ static void fbcon_prepare_logo(struct vc_data *vc, struct fb_info *info,
if (fb_get_color_depth(&info->var, &info->fix) == 1)
erase &= ~0x400;
logo_height = fb_prepare_logo(info, ops->rotate);
+ logo_height += (info->var.yres/2)-(logo->height/2);
logo_lines = DIV_ROUND_UP(logo_height, vc->vc_font.height);
q = (unsigned short *) (vc->vc_origin +
vc->vc_size_row * rows);
2.)drivers/video/fbmem.c
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index b066475..c8e7fc0 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -468,8 +468,8 @@ static int fb_show_logo_line(struct fb_info *info, int rotate,
fb_set_logo(info, logo, logo_new, fb_logo.depth);
}
- image.dx = 0;
- image.dy = y;
+ image.dx = (info->var.xres/2)-(logo->width/2);
+ image.dy = (info->var.yres/2)-(logo->height/2);
image.width = logo->width;
image.height = logo->height;
四 调试
关联软件
软件
/kernel/drivers/video/fbmem.c
/kernel/drivers/video/logo/logo.c
/kernel/drivers/video/logo/Kconfig
/kernel/include/linux/linux_logo.h
一、首先说明logo显示相关程序。
(1)在driver/video/console/fbcon.c文件中,函数fncon_init(),为虚拟设备结构体VC赋值,并调用本文件中的fbcon_prepare_logo()函数,为显示logo做准备。
(2)fbcon_prepare_logo(),调用了fb_prepare_logo()函数(此函数在driver/video/fbmem.c中)。
(3)fb_prepare_logo()中调用了fb_find_logo()函数(此函数在driver/video/logo/logo.c中),这个函数会根据配置文件找到相应的logo数据,这个数据就是logo文件夹下logo_xxx_xxx.ppm生成的,我的linux就是logo_linux_clut224.ppm。
(4)fb_prepare_logo()函数获取了照片信息后进行一次判断,看图片高度是否超过屏幕高度,否则,不显示。
(5)fbcon_prepare_logo()函数获取图片数据后,又进一步处理判断,用照片的高度除以字模高度后,于屏高度除以字模高度的值相比较,判断图片可否显示。若过大,则打印显示“fbcon_init:disable boot-logo(boot-logo bigger than screen)”
打印打印显示“fbcon_init:disable boot-logo(boot-logo bigger than screen)”分析
if (logo_lines > vc->vc_bottom) {
logo_shown = FBCON_LOGO_CANSHOW;
printk(KERN_INFO
"fbcon_init: disable boot-logo (boot-logo bigger than screen).\n");
}
可以发现是因为logo_lines > vc->vc_bottom引起的
。
其中logo_lines = DIV_ROUND_UP(logo_height, vc->vc_font.height); //(DIV_ROUND_UP是向上取整的意思
)
而vc->vc_bottom代码读下来为vc->vc_bottom = info->var.yres/ vc->vc_font.height;
其关键就是vc->vc_font.height了,Linux下vc->vc_font.height默认为16,
所以当液晶屏和Logo的分辨率都为800*600时,
600/16无法整除,故取整logo_lines =38; vc->vc_bottom = 37;
提示错误无法显示。
只要把logo的改小一下,改为592,则logo_lines = 592/16=37; vc->vc_bottom = 600/16=37;就可以正常显示了。