Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1229594
  • 博文数量: 479
  • 博客积分: 12240
  • 博客等级: 上将
  • 技术积分: 4999
  • 用 户 组: 普通用户
  • 注册时间: 2007-10-24 17:12
文章分类

全部博文(479)

文章存档

2014年(1)

2013年(1)

2012年(1)

2011年(95)

2010年(177)

2009年(167)

2008年(16)

2007年(21)

分类: LINUX

2009-10-14 20:47:47

适用于2.6.10内核。

默认情况下,Linux的开机LOGO小企鹅是显示在LCD的左上角的,如果想让LOGO居中显示,需要进行修改:


drivers/video/fbmem.c

修改 fb_show_logo函数.

int fb_show_logo(struct fb_info *info)
{
u32 *palette = NULL, *saved_pseudo_palette = NULL;
// unsigned char *logo_new = NULL;
// struct fb_image image;
// int x;
        unsigned char *logo_new = NULL, *border = NULL;
        struct fb_image image, imageborder;
         int x, xoffset;
         int y, yoffset;

/* Return if the frame buffer is not mapped or suspended */
if (fb_logo.logo == NULL || info->state != FBINFO_STATE_RUNNING)
return 0;

image.depth = 8;
image.data = fb_logo.logo->data;

if (fb_logo.needs_cmapreset)
fb_set_logocmap(info, fb_logo.logo);

if (fb_logo.needs_truepalette || 
    fb_logo.needs_directpalette) {
palette = kmalloc(256 * 4, GFP_KERNEL);
if (palette == NULL)
return 0;

if (fb_logo.needs_truepalette)
fb_set_logo_truepalette(info, fb_logo.logo, palette);
else
fb_set_logo_directpalette(info, fb_logo.logo, palette);

saved_pseudo_palette = info->pseudo_palette;
info->pseudo_palette = palette;
}

if (fb_logo.depth <= 4) {
logo_new = kmalloc(fb_logo.logo->width * fb_logo.logo->height, 
   GFP_KERNEL);
if (logo_new == NULL) {
if (palette)
kfree(palette);
if (saved_pseudo_palette)
info->pseudo_palette = saved_pseudo_palette;
return 0;
}
image.data = logo_new;
fb_set_logo(info, fb_logo.logo, logo_new, fb_logo.depth);
}

image.width = fb_logo.logo->width;
image.height = fb_logo.logo->height;
image.dy = 0;

    //这段代码实现了重复左右边界直至屏幕两边
#if 0 //def CONFIG_LOGO_REPEAT_RIGHT
    border = kmalloc(4 * fb_logo.logo->height, GFP_KERNEL);
    if (border != NULL){
      for (x = 0; x < fb_logo.logo->height; x++){ /* use x as y */
               *((u32 *)border + x) = /* will repeat 4 pixels of the right side*/
               *(u32 *)(image.data + (x+1)*fb_logo.logo->width - 4);
          }
          imageborder.depth = 8;
          imageborder.data = border;
          imageborder.width = 4;
          imageborder.height = image.height;
          imageborder.dy = 0;
          for (x = 0; x < info->var.xres; x+=4){
              imageborder.dx = x;
              info->fbops->fb_imageblit(info, &imageborder);
          }
              kfree(border);
    }
#endif

 
#if 0 //ndef CONFIG_CENTER_LOGO
               xoffset = 0;
    

    
for (x = 0; x < num_online_cpus() * (fb_logo.logo->width + 8) &&
     x <= info->var.xres-fb_logo.logo->width; x += (fb_logo.logo->width + 8)) {
image.dx = x;
info->fbops->fb_imageblit(info, &image);
}
#else     //这段代码仅仅实现了X方向居中
    xoffset = (info->var.xres - num_online_cpus() * (fb_logo.logo->width + 8))>>1;
    yoffset = (info->var.yres - num_online_cpus() * (fb_logo.logo->height + 8))>>1;

    if (xoffset<0) xoffset = 0;
    if (yoffset<0) yoffset = 0;
#if 0//only-x
    for (x = xoffset; x < num_online_cpus() * (fb_logo.logo->width + 8) + xoffset  &&
         x <= info->var.xres-fb_logo.logo->width+xoffset; x += (fb_logo.logo->width + 8)) {
            image.dx = x;
            info->fbops->fb_imageblit(info, &image);
    }
#endif
    
#if 1//  x-y  //这段代码是实现X、Y居中的一部分,另外一部分是设置logo_lines。
for (x = xoffset,y=yoffset;                                         \
           x < num_online_cpus() * (fb_logo.logo->width +  8) + xoffset \
        && x <= info->var.xres - fb_logo.logo->width + xoffset          \
        && y < num_online_cpus() * (fb_logo.logo->height + 8) + yoffset     \ 
        && y <= info->var.yres - fb_logo.logo->height + yoffset;  
        x  += (fb_logo.logo->width + 8),                             \
        y  += (fb_logo.logo->height +8) ) 
    image.dx = x; 
    image.dy = y; 
    info->fbops->fb_imageblit(info, &image); 
}    
#endif

#endif

    
if (palette != NULL)
kfree(palette);
if (saved_pseudo_palette != NULL)
info->pseudo_palette = saved_pseudo_palette;
if (logo_new != NULL)
kfree(logo_new);
return fb_logo.logo->height;
}


drivers/video/console/fbcon.c

修改fbcon_prepare_logo函数中设置logo_lines的代码
       int cols, int rows, int new_cols, int new_rows)

if (fb_get_color_depth(info) == 1)
erase &= ~0x400;

    #ifdef CONFIG_CENTER_LOGO
            logo_height = fb_prepare_logo(info);
            logo_lines = (logo_height +((info->var.yres-logo_height)/2) + vc->vc_font.height - 1) /
            vc->vc_font.height;
    #else
            logo_lines = (logo_height + vc->vc_font.height - 1) /
            vc->vc_font.height;
    #endif


经过修改后,重新编译内核,即可看到居中的LOGO了。
阅读(1900) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~