当前位置:网站首页>Uboot supports LCD and HDMI to display different logo images
Uboot supports LCD and HDMI to display different logo images
2022-07-27 05:54:00 【android framework】
stay lcd Vertical screen ,hdmi When the horizontal screen is displayed , If by default uboot Show the frame , Only guarantee lcd perhaps hdmi One of the pictures shown above is positive , The other is rotating 90 Appearance of degree .
In order to be lcd and hdmi At the same time, it supports the display of positive pictures , Need to be right uboot Modify the framework of . If the hardware supports the rotation function , You can use hardware rotation directly , No software is needed to adjust .
For project reasons , Toss this process , Record the specific implementation :
1: Because the hardware does not support rotation function , The method used in the software is to prepare two logo resources , After parsing, send the two data to different display devices for display .
In parsing logo You need to parse two resources :
static int splash_image_load(void)
{
int ret;
char *filename,*filename_hdmi;
void *splash_image_addr,*splash_image_hdmi_addr;
char splash_image_char[16], splash_image_hdmi_char[16];
// Assigned to lcd The address of the resource
splash_image_addr = memalign(128, CONFIG_SYS_VIDEO_LOGO_MAX_SIZE);
if(splash_image_addr == NULL) {
printk(“Malloc size for splash image failed!\n”);
return -1;
}
// Assigned to hdmi resources logo The address of
splash_image_hdmi_addr = memalign(128, CONFIG_SYS_VIDEO_LOGO_MAX_SIZE);
if(splash_image_hdmi_addr == NULL) {
printk(“Malloc size for splash image hdmi failed!\n”);
return -1;
}
filename = splash_image_select();
filename_hdmi = CONFIG_SYS_VIDEO_LOGO_HDMI_NAME;
if (!filename) {
printk("No splash image loaded\n");
return -1;
}
// Get lcd Of logo
ret = file_fat_read(filename, splash_image_addr, CONFIG_SYS_VIDEO_LOGO_MAX_SIZE);
if(ret < 0) {
printk("Fail to load splash image\n");
free(splash_image_addr);
return -1;
}
// Get hdmi Of logo
ret = file_fat_read(filename_hdmi, splash_image_hdmi_addr, CONFIG_SYS_VIDEO_LOGO_MAX_SIZE);
if(ret < 0) {
printk("Fail to load splash hdmi image\n");
free(splash_image_hdmi_addr);
return -1;
}
sprintf(splash_image_char, "%x", (unsigned int) splash_image_addr);
sprintf(splash_image_hdmi_char, "%x", (unsigned int) splash_image_hdmi_addr);
// Save the resolved address to env in , You need to read it later
setenv("splashimage", splash_image_char);
setenv("splashimagehdmi", splash_image_hdmi_char);
return 0;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
2: Add pair hdmi Driver support and in cfb_console.c Add support for parsing pictures
static int video_init(void)
{
unsigned char color8;
pGD = video_hw_init();
if (pGD == NULL)
return -1;
// Get the hdmi Of fb Information about video_hw_hdmi_init stay fb In the driver of
pGD_HDMI = video_hw_hdmi_init();
if (pGD_HDMI == NULL)
return -1;
...
}
static void *video_logo(void)
{
char info[128];
int space, len;
__maybe_unused int y_off = 0;
__maybe_unused ulong addr;
__maybe_unused char *s,*s_hdmi;
splash_get_pos(&video_logo_xpos, &video_logo_ypos);
//splash_get_pos(&video_logo_xpos, &video_logo_ypos);
video_hdmi_logo_xpos = BMP_ALIGN_CENTER; //init xpos and ypos
video_hdmi_logo_ypos = BMP_ALIGN_CENTER;
#ifdef CONFIG_SPLASH_SCREEN
// from env Get in the lcd and hdmi The address of the picture
s = getenv(“splashimage”);
s_hdmi = getenv(“splashimagehdmi”);
if (s != NULL) {
splash_screen_prepare();
addr = simple_strtoul(s, NULL, 16);
// analysis lcd Of logo Resources become data for presentation
if (video_display_bitmap(addr,
video_logo_xpos,
video_logo_ypos) == 0) {
video_logo_height = 0;
//return ((void *) (video_fb_address));
}
}
if (s_hdmi != NULL) {
//printf("xieshsh debug video display\n");
splash_screen_prepare();
addr = simple_strtoul(s_hdmi, NULL, 16);
// analysis lcd Of hdmi Resources become data for presentation
if (video_display_hdmi_bitmap(addr,
video_hdmi_logo_xpos,
video_hdmi_logo_ypos) == 0) {
video_hdmi_logo_ypos = 0;
return ((void *) (video_fb_address));
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
3: Next, you need to add pairs hdmi logo Analysis into fb The data of
int video_display_hdmi_bitmap(ulong bmp_image, int x, int y)
{
ushort xcount, ycount;
uchar *fb;
bmp_image_t *bmp = (bmp_image_t *) bmp_image;
uchar *bmap;
ushort padded_line;
unsigned long width, height, bpp;
unsigned colors;
unsigned long compression;
bmp_color_table_entry_t cte;
#ifdef CONFIG_VIDEO_BMP_GZIP
unsigned char *dst = NULL;
ulong len;
#endif
WATCHDOG_RESET();
if (!((bmp->header.signature[0] == 'B') &&
(bmp->header.signature[1] == 'M'))) {
#ifdef CONFIG_VIDEO_BMP_GZIP
/*
* Could be a gzipped bmp image, try to decrompress…
/
len = CONFIG_SYS_VIDEO_LOGO_MAX_SIZE;
dst = malloc(CONFIG_SYS_VIDEO_LOGO_MAX_SIZE);
if (dst == NULL) {
printf(“Error: malloc in gunzip failed!\n”);
return 1;
}
/
* NB: we need to force offset of +2
* See doc/README.displaying-bmps
*/
if (gunzip(dst+2, CONFIG_SYS_VIDEO_LOGO_MAX_SIZE-2,
(uchar *) bmp_image,
&len) != 0) {
printf(“Error: no valid bmp or bmp.gz image at %lx\n”,
bmp_image);
free(dst);
return 1;
}
if (len == CONFIG_SYS_VIDEO_LOGO_MAX_SIZE) {
printf("Image could be truncated "
“(increase CONFIG_SYS_VIDEO_LOGO_MAX_SIZE)!\n”);
}
/*
* Set addr to decompressed image
*/
bmp = (bmp_image_t *)(dst+2);
if (!((bmp->header.signature[0] == 'B') &&
(bmp->header.signature[1] == 'M'))) {
printf("Error: no valid bmp.gz image at %lx\n",
bmp_image);
free(dst);
return 1;
}
#else
printf(“Error: no valid bmp image at %lx\n”, bmp_image);
return 1;
#endif /* CONFIG_VIDEO_BMP_GZIP */
}
width = le32_to_cpu(bmp->header.width);
height = le32_to_cpu(bmp->header.height);
bpp = le16_to_cpu(bmp->header.bit_count);
colors = le32_to_cpu(bmp->header.colors_used);
compression = le32_to_cpu(bmp->header.compression);
debug("Display-bmp: %ld x %ld with %d colors\n",
width, height, colors);
if (compression != BMP_BI_RGB
#ifdef CONFIG_VIDEO_BMP_RLE8
&& compression != BMP_BI_RLE8
#endif
) {
printf(“Error: compression type %ld not supported\n”,
compression);
#ifdef CONFIG_VIDEO_BMP_GZIP
if (dst)
free(dst);
#endif
return 1;
}
padded_line = (((width * bpp + 7) / 8) + 3) & ~0x3;
#ifdef CONFIG_SPLASH_SCREEN_ALIGN
if (x == BMP_ALIGN_CENTER){
x = max(0, (int)(VIDEO_HDMI_VISIBLE_COLS - width) / 2);
printf(“VVVVVVVVx=%d”,x);
}
else if (x < 0)
x = max(0, (int)(VIDEO_HDMI_VISIBLE_COLS - width + x + 1));
if (y == BMP_ALIGN_CENTER)
y = max(0, (int)(VIDEO_HDMI_VISIBLE_ROWS - height) / 2);
else if (y < 0)
y = max(0, (int)(VIDEO_HDMI_VISIBLE_ROWS - height + y + 1));
#endif /* CONFIG_SPLASH_SCREEN_ALIGN */
/*
* Just ignore elements which are completely beyond screen
* dimensions.
*/
if ((x >= VIDEO_HDMI_VISIBLE_COLS) || (y >= VIDEO_HDMI_VISIBLE_ROWS))
return 0;
if ((x + width) > VIDEO_HDMI_VISIBLE_COLS)
width = VIDEO_HDMI_VISIBLE_COLS - x;
if ((y + height) > VIDEO_HDMI_VISIBLE_ROWS)
height = VIDEO_HDMI_VISIBLE_ROWS - y;
bmap = (uchar *) bmp + le32_to_cpu(bmp->header.data_offset);
fb = (uchar *) (video_hdmi_fb_address +
((y + height - 1) * VIDEO_HDMI_VISIBLE_COLS * VIDEO_HDMI_PIXEL_SIZE) +
x * VIDEO_HDMI_PIXEL_SIZE);
/* We handle only 4, 8, or 24 bpp bitmaps */
switch (le16_to_cpu(bmp->header.bit_count)) {
case 24:
padded_line -= 3 * width;
ycount = height;
//printf("xiessh----VIDEO_DATA_FORMAT = %d\n",VIDEO_HDMI_DATA_FORMAT);
switch (VIDEO_HDMI_DATA_FORMAT) {
case GDF_32BIT_X888RGB:
while (ycount--) {
WATCHDOG_RESET();
xcount = width;
while (xcount--) {
FILL_32BIT_X888RGB(bmap[2], bmap[1],
bmap[0]);
bmap += 3;
}
bmap += padded_line;
fb -= (VIDEO_HDMI_VISIBLE_COLS + width) *
VIDEO_PIXEL_SIZE;
}
break;
default:
printf("Error: 24 bits/pixel bitmap incompatible "
"with current video mode\n");
break;
}
break;
default:
printf("Error: %d bit/pixel bitmaps not supported by U-Boot\n",
le16_to_cpu(bmp->header.bit_count));
break;
}
#ifdef CONFIG_VIDEO_BMP_GZIP
if (dst) {
free(dst);
}
#endif
if (cfb_do_flush_cache)
flush_cache(VIDEO_FB_ADRS, VIDEO_SIZE);
return (0);
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
After realizing the above content , The next step is to uboot Of fb Do a good job in mapping , Mainly is to fb0 Corresponding logo Of resources to lcd、fb1 Corresponding logo Resource delivery hdmi Show , The specific code is platform related .
The impact of this will make uboot Double the memory of the stage display , Only one picture was used before , Now I use two pictures , So the memory will double .
When android When it comes to systems , because lcd It's a vertical screen ,lcd The content above rotates 90 Degrees are used as horizontal screen mode ,hdmi It's a horizontal screen , Can cause android The first half of the animation is hdmi As shown above android The words become vertical , know android Of display Of java After the service starts ,android Our display system recognizes hdmi equipment , The system displays normal .
In this case ,hdmi The abnormal display of the first half of , Because the hardware cannot rotation, It can only be solved in an evasive way , It will start up logo Until android The upper display system recognizes hdmi after , To release boot logo Resources for , Before this , Always show logo Pictures of the . The specific implementation method is platform related , The code is not posted .
————————————————
Copyright notice : This paper is about CSDN Blogger 「xieshsh_8756」 The original article of , follow CC 4.0 BY-SA Copyright agreement , For reprint, please attach the original source link and this statement .
Link to the original text :https://blog.csdn.net/u010865783/article/details/54953315
边栏推荐
- Jenkins build image automatic deployment
- 2021中大厂php+go面试题(1)
- Inno setup package jar + H5 + MySQL + redis into exe
- 使用Docker部署Redis进行高可用主从复制
- PHP的CI框架学习
- 3.分类问题---手写数字识别初体验
- Day 2. Depressive symptoms, post-traumatic stress symptoms and suicide risk among graduate students
- NFT new opportunity, multimedia NFT aggregation platform okaleido will be launched soon
- ES对比两个索引的数据差
- Day 3. Suicidal ideation and behavior in institutions of higher learning: A latent class analysis
猜你喜欢

9.高阶操作

How can I get the lowest handling charge for opening a futures account?

如果在线上遇到了OOM,该如何解决?

DDD领域驱动设计笔记

新冠时空分析——Global evidence of expressed sentiment alterations during the COVID-19 pandemic

Graph node deployment

How to apply for the return of futures account opening company?

Day 6.重大医疗伤害事件网络舆情能量传播过程分析*———以“魏则西事件”为例

基于深度神经网络的社交媒体用户级心理压力检测

You should negotiate the handling fee before opening a futures account
随机推荐
Move protocol launched a beta version, and you can "0" participate in p2e
Dimitra and ocean protocol interpret the secrets behind agricultural data
Day14. 用可解释机器学习方法鉴别肠结核和克罗恩病
GBase 8c产品简介
GBASE 8C——SQL参考6 sql语法(5)
How to choose a good futures company for futures account opening?
The NFT market pattern has not changed. Can okaleido set off a new round of waves?
Specific matters of opening accounts of futures companies
Day 11. Evidence for a mental health crisis in graduate education
9.高阶操作
GBASE 8C——SQL参考6 sql语法(4)
How MySQL and redis ensure data consistency
GBASE 8C——SQL参考6 sql语法(14)
11.感知机的梯度推导
Which futures company do you go to and how do you open an account?
GBase 8c核心技术
GBASE 8C——SQL参考6 sql语法(11)
andorid检测GPU呈现速度和过度绘制
Personal collection code cannot be used for business collection
2021中大厂php+go面试题(2)