函數fb_show_logo_line也是實如今文件kernel/goldfish/drivers/video/fbmem.c中,以下所示:linux
- static int fb_show_logo_line(struct fb_info *info, int rotate,
- const struct linux_logo *logo, int y,
- unsigned int n)
- {
- u32 *palette = NULL, *saved_pseudo_palette = NULL;
- unsigned char *logo_new = NULL, *logo_rotate = NULL;
- struct fb_p_w_picpath p_w_picpath;
-
-
- if (logo == NULL || info->state != FBINFO_STATE_RUNNING ||
- info->flags & FBINFO_MODULE)
- return 0;
-
- p_w_picpath.depth = 8;
- p_w_picpath.data = logo->data;
-
- if (fb_logo.needs_cmapreset)
- fb_set_logocmap(info, 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, logo, palette);
- else
- fb_set_logo_directpalette(info, logo, palette);
-
- saved_pseudo_palette = info->pseudo_palette;
- info->pseudo_palette = palette;
- }
-
- if (fb_logo.depth <= 4) {
- logo_new = kmalloc(logo->width * logo->height, GFP_KERNEL);
- if (logo_new == NULL) {
- kfree(palette);
- if (saved_pseudo_palette)
- info->pseudo_palette = saved_pseudo_palette;
- return 0;
- }
- p_w_picpath.data = logo_new;
- fb_set_logo(info, logo, logo_new, fb_logo.depth);
- }
-
- p_w_picpath.dx = 0;
- p_w_picpath.dy = y;
- p_w_picpath.width = logo->width;
- p_w_picpath.height = logo->height;
-
- if (rotate) {
- logo_rotate = kmalloc(logo->width *
- logo->height, GFP_KERNEL);
- if (logo_rotate)
- fb_rotate_logo(info, logo_rotate, &p_w_picpath, rotate);
- }
-
- fb_do_show_logo(info, &p_w_picpath, rotate, n);
-
- kfree(palette);
- if (saved_pseudo_palette != NULL)
- info->pseudo_palette = saved_pseudo_palette;
- kfree(logo_new);
- kfree(logo_rotate);
- return logo->height;
- }
參數logo指向了前面所準備的第一個開機畫面的內容。這個函數首先根據參數logo的內容來構造一個fb_p_w_picpath結構體p_w_picpath,用來描述最終要顯示的第一個開機畫面。最後就調用函數fb_do_show_logo來真正執行渲染第一個開機畫面的操做。 函數fbcon_switch實如今文件kernel/goldfish/drivers/video/console/fbcon.c中,顯示第一個開機畫面的過程以下所示:
- static void fb_do_show_logo(struct fb_info *info, struct fb_p_w_picpath *p_w_picpath,
- int rotate, unsigned int num)
- {
- unsigned int x;
-
- if (rotate == FB_ROTATE_UR) {
- for (x = 0;
- x < num && p_w_picpath->dx + p_w_picpath->width <= info->var.xres;
- x++) {
- info->fbops->fb_p_w_picpathblit(info, p_w_picpath);
- p_w_picpath->dx += p_w_picpath->width + 8;
- }
- } else if (rotate == FB_ROTATE_UD) {
- for (x = 0; x < num && p_w_picpath->dx >= 0; x++) {
- info->fbops->fb_p_w_picpathblit(info, p_w_picpath);
- p_w_picpath->dx -= p_w_picpath->width + 8;
- }
- } else if (rotate == FB_ROTATE_CW) {
- for (x = 0;
- x < num && p_w_picpath->dy + p_w_picpath->height <= info->var.yres;
- x++) {
- info->fbops->fb_p_w_picpathblit(info, p_w_picpath);
- p_w_picpath->dy += p_w_picpath->height + 8;
- }
- } else if (rotate == FB_ROTATE_CCW) {
- for (x = 0; x < num && p_w_picpath->dy >= 0; x++) {
- info->fbops->fb_p_w_picpathblit(info, p_w_picpath);
- p_w_picpath->dy -= p_w_picpath->height + 8;
- }
- }
- }
參數rotate用來描述屏幕的當前旋轉方向。屏幕旋轉方向不一樣,第一個開機畫面的渲染方式也有所不一樣。例如,當屏幕上下顛倒時(FB_ROTATE_UD),第一個開機畫面的左右順序就恰好調換過來,這時候就須要從右到左來渲染。其它三個方向FB_ROTATE_UR、FB_ROTATE_CW和FB_ROTATE_CCW分別表示沒有旋轉、順時針旋轉90度和逆時針旋轉90度。
參數info用來描述要渲染的幀緩衝區硬件設備,它的成員變量fbops指向了一系列回調函數,用來操做幀緩衝區硬件設備,其中,回調函數fb_p_w_picpathblit就是用來在指定的幀緩衝區硬件設備渲染指定的圖像的。
至此,第一個開機畫面的顯示過程就分析完成了。