1. 程式人生 > >imx6q 修改開機LOGO指南

imx6q 修改開機LOGO指南

1 修改u-boot中的LOGO
  1 更換logo
    替換 u-boot-imx/2015.04-r0/git/tools/logos/目錄下的freescale.bmp,注意這裡要替換的圖片一定是256色的點陣圖,如果是24位色的圖片轉換可能會出錯,造成圖片顯示不正常。
    我們也可以,直接把自己需要顯示的檔案不命名為freescale.bmp,那就需要自己修改u-boot-imx/2015.04-r0/git/tools/Makefile檔案,將LOGO_BMP=後面的路徑設定為自己的圖片的名稱。
    編譯的時候,bmp_logo會將我們指定的圖片轉換為陣列檔案,儲存在/u-boot-imx/2015.04-r0/git/mx6qsabresd_config/include/目錄下的bmp_logo.h、bmp_logo_data.h中
  2 將圖片居中顯示
    修改 u-boot-imx/2015.04-r0/git/drivers/video/cfb_console.c
    在函式static void *video_logo(void)中修改
    splash_get_pos(&video_logo_xpos, &video_logo_ypos);
         
        if(video_logo_xpos==0&&video_logo_ypos==0)//這裡是增加的程式碼,設定圖片居中顯示
        {
                video_logo_xpos= (VIDEO_VISIBLE_COLS - BMP_LOGO_WIDTH)>>1;
                video_logo_ypos= (VIDEO_VISIBLE_ROWS - BMP_LOGO_HEIGHT)>>1;
        }
  3 去掉編譯資訊
    在函式static void *video_logo(void)函式中註釋掉下面的程式碼
    sprintf(info, " %s", version_string);
         
        space = (VIDEO_COLS - VIDEO_INFO_X) / VIDEO_FONT_WIDTH;
        len = strlen(info);


        if (len > space) {
                int xx = VIDEO_INFO_X, yy = VIDEO_INFO_Y;
                uchar *p = (uchar *) info;
                while (len) {
                        if (len > space) {
                                video_drawchars(xx, yy, p, space);
                                len -= space;


                                p = (uchar *) p + space;


                                if (!y_off) {
                                        xx += VIDEO_FONT_WIDTH;
                                        space--;
                                }
                                yy += VIDEO_FONT_HEIGHT;


                                y_off++;
                        } else {
                                video_drawchars(xx, yy, p, len);
                                len = 0;
                        }
                }
        } else
                video_drawstring(VIDEO_INFO_X, VIDEO_INFO_Y, (uchar *) info);
                
2 修改Linux啟動的logo
  1 生成logo檔案
    生成logo檔案,我們需要用png圖片來轉換
    在terminal中執行下面的命令
    pngtopnm car.png > car.pnm         #轉換png成pnm格式
        pnmquant 224 car.pnm > car224.pnm       #轉換畫素數為224
        pnmtoplainpnm car224.pnm > logo_car_clut224.ppm
  2 將logo_car_clut224.ppm拷貝到/kernel-source/drivers/video/logo/目錄下
  
  3 在/kernel-source/drivers/video/logo/Kconfig下增加
    config LOGO_CAR224
        bool "Standard car logo"
        default y
        
    在/kernel-source/drivers/video/logo/Makefile下增加
    obj-$(CONFIG_LOGO_CAR224)                        += logo_car_clut224.o
  
  4 執行bitbake -c menuconfig -v linux-imx 
    在menuconfig中選擇Standard car logo
    
  5 在/kernel-source/drivers/video/logo/logo.c中的
    const struct linux_logo * __init_refok fb_find_logo(int depth)函式中
    if (depth >= 8) {
    。。。。。。。
    }
    裡面新增
    #ifdef CONFIG_LOGO_CAR224
                /* Generic car logo */
                logo = &logo_car_clut224;
    #endif
    
    在/kernel-source/include/linux/linux_logo.h
    中新增extern const struct linux_logo logo_car_clut224;
    
  6 去掉根據CPU的數目顯示logo,只顯示一個logo
    將/kernel-source/drivers/video/fbmem.c
    中函式int fb_show_logo(struct fb_info *info, int rotate)
    將y = fb_show_logo_line(info, rotate, fb_logo.logo, 0,
                              num_online_cpus());
        改為
        y = fb_show_logo_line(info, rotate, fb_logo.logo, 0,
                              /*num_online_cpus()*/1);
                              
  7 設定logo居中顯示
    修改 /kernel-source/drivers/video/fbmem.c中的
    static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
                            int rotate, unsigned int num)函式
    程式碼如下:
    unsigned int x;
        unsigned int xoff,yoff; 
        //新增的程式碼 ,設定logo居中顯示
        xoff = (info->var.xres - num * (fb_logo.logo->width ))>>1; 


        yoff = (info->var.yres -  (fb_logo.logo->height ))>>1;
        ////////////////////////////////////////////////////////////
        if (rotate == FB_ROTATE_UR) {
                //新增的程式碼,設定logo居中顯示 
                image->dx = xoff ;
                image->dy = yoff ;
                ///////////////////////////////
                for (x = 0;
                     x < num && image->dx + image->width <= info->var.xres;
                     x++) {
                        info->fbops->fb_imageblit(info, image);
                        printk(KERN_ALERT"end\n" );
                        image->dx += image->width + 8;
                }
        } 
        
        修改函式int fb_prepare_logo(struct fb_info *info, int rotate)
        在函式的結尾
        return fb_prepare_extra_logos(info, fb_logo.logo->height, yres);
        改為
        return fb_prepare_extra_logos(info, fb_logo.logo->height, yres)+((info->var.yres )>>1);
        重新編譯就大功告成。