日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

android开机画面在uboot里吗,uboot里开机LOGO显示功能解析

發布時間:2024/1/18 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android开机画面在uboot里吗,uboot里开机LOGO显示功能解析 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

uboot里開機LOGO顯示功能解析

開機LOGO,對于絕大多數帶顯示屏的電子產品都是必備的一個功能,是產品開機的第一印象,重要性不言而喻的,那我們下面就看看這個是怎么實現的。

要盡早的顯示出LOGO就需要在系統真正起來之前的boot階段就能打通顯示,而這個任務大多是以U-BOOT這樣的角色來充當,全志平臺在android4.4平臺就是在u-boot里面實現的,支持的是BMP圖片。大家分為幾個步驟了,首先要讀取圖片,再解析圖片數據,然后再送到顯示部分,最后顯示出來。事就是這么個事,說起來簡單,理起來也簡單,真正寫出來的人并不簡單,需要對這幾個部分都很了解,當然對于平臺來說,難度倒不是太大。下面一起看看吧!

/*****************************************************************************************************/聲明:本博內容均由http://blog.csdn.net/edsam49原創,轉載請注明出處,謝謝!/*****************************************************************************************************/

首先,加載圖片到內存中。加載的話,大家比較熟悉的也就是fatload,就是掛載一個fat的文件系統,從這個文件系統里面去讀取這個文件的數據到指定內存位置,看看代碼吧,也不難!

char *const bmp_argv[6] = { "fatload", "sunxi_flash", "0", "40000000", bmp_name, NULL };

memset(bmp_name, 0, 32);

strcpy(bmp_name, name);

if(do_fat_fsload(0, 0, 5, bmp_argv))

{

printf("sunxi bmp info error : unable to open logo file %s\n", bmp_argv[4]);

return -1;

}

其次,得到圖片原始數據了就需要做解析了,當然BMP圖片的數據格式也是確定的,數據頭確定,一般是54個字節,我們看看數據頭的數據結構:

typedef struct bmp_header {

/* Header */

char signature[2];

__u32file_size;

__u32reserved;

__u32data_offset;

/* InfoHeader */

__u32size;

__u32width;

__u32height;

__u16planes;

__u16bit_count;

__u32compression;

__u32image_size;

__u32x_pixels_per_m;

__u32y_pixels_per_m;

__u32colors_used;

__u32colors_important;

/* ColorTable */

} __attribute__ ((packed)) bmp_header_t;

打印出來又是怎么一個效果呢?如下:

bmp signature[] B, M

bmp file_size 1536054

bmp reserved -1

bmp data_offset 54

bmp size 40

bmp width 800

bmp height -480

bmp planes 1

bmp bit_count 32

bmp compression 0

bmp image_size 1536000

bmp x_pixels_per_m 0

bmp y_pixels_per_m 0

bmp colors_used 0

bmp colors_important 0

bmp x = 320, bmp y = 1e0? ?筆者測試的這個BMP圖片用工具處理過,就是調整它的透明度,所以顯示的高度有一點異常,取反就好了??纯聪旅娴奶幚?#xff1a;

if((bmp->header.signature[0]!=‘B‘) || (bmp->header.signature[1] !=‘M‘))

{

printf("this is not a bmp picture\n");

return -1;

}

debug("bmp dectece\n");

bmp_bpix = bmp->header.bit_count/8;

if((bmp_bpix != 3) && (bmp_bpix != 4))

{

printf("no support bmp picture without bpix 24 or 32\n");

return -1;

}

if(bmp_bpix ==3)

{

zero_num = (4 - ((3*bmp->header.width) % 4))&3;

}

debug("bmp bitcount %d\n", bmp->header.bit_count);

x = bmp->header.width;

y = (bmp->header.height & 0x80000000) ? (-bmp->header.height):(bmp->header.height);

printf("bmp x = %x, bmp y = %x\n", x, y);

tmp_buffer = (char *)bmp_info->buffer;

bmp_data = (char *)(addr + bmp->header.data_offset);

if(bmp->header.height & 0x80000000)

{

if(zero_num == 0)

{

memcpy(tmp_buffer,bmp_data,x*y*bmp_bpix);

}

else

{

int i, line_bytes, real_line_byte;

char *src;

line_bytes = (x * bmp_bpix) + zero_num;

real_line_byte = x * bmp_bpix;

for(i=0; i

{

src = bmp_data + i*line_bytes;

memcpy(tmp_buffer, src, real_line_byte);

tmp_buffer += real_line_byte;

}

}

}

else

{

uint i, line_bytes, real_line_byte;

char *src;

line_bytes = (x * bmp_bpix) + zero_num;

real_line_byte = x * bmp_bpix;

for(i=0; i

{

src = bmp_data + (y - i - 1) * line_bytes;

memcpy(tmp_buffer, src, real_line_byte);

tmp_buffer += real_line_byte;

}

}

bmp_info->x = x;

bmp_info->y = y;

bmp_info->bit = bmp->header.bit_count;

flush_cache((uint)bmp_info->buffer, x * y * bmp_bpix);

然后就是送到顯示的地方了,因為解碼buffer的地址是確定的,只要在顯示layer的參數里掛上鉤就可以了,申請layer,設置參數,打開layer,順理成章!簡單代碼如下:

debug("begin to set framebuffer\n");

if(board_display_framebuffer_set(bmp_info.x, bmp_info.y, bmp_info.bit, (void *)bmp_info.buffer))

{

printf("sunxi bmp display error : set frame buffer error\n");

return -2;

}

debug("begin to show layer\n");

board_display_show(0);

debug("bmp display finish\n");board_display_layer_para_set();

board_display_layer_open();

整個流程確實就是這樣的,有深度的地方就是把各個部分有機的串聯起來,組織起來,不會做的事情都難,會做了的事情都不難!當然,我們不要在不懂的情況下就去評說這個事情難不難,難不難誰做誰知道!謙虛謹慎,低調潛行!

原文:http://blog.csdn.net/edsam49/article/details/42263231

總結

以上是生活随笔為你收集整理的android开机画面在uboot里吗,uboot里开机LOGO显示功能解析的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。