Skip to content

Commit 88fe4ce

Browse files
jwrdegoedebzolnier
authored andcommitted
efifb: BGRT: Do not copy the boot graphics for non native resolutions
On x86 some firmwares use a low non native resolution for the display when they have shown some text messages. While keeping the bgrt filled with info for the native resolution. If the bgrt image intended for the native resolution still fits, it will be displayed very close to the right edge of the display looking quite bad. This commits adds a (heuristics based) checks for this and makes efifb not show the boot graphics when this is the case. Signed-off-by: Hans de Goede <[email protected]> Signed-off-by: Bartlomiej Zolnierkiewicz <[email protected]>
1 parent 93de35c commit 88fe4ce

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

drivers/video/fbdev/efifb.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,46 @@ static void efifb_copy_bmp(u8 *src, u32 *dst, int width, struct screen_info *si)
111111
}
112112
}
113113

114+
#ifdef CONFIG_X86
115+
/*
116+
* On x86 some firmwares use a low non native resolution for the display when
117+
* they have shown some text messages. While keeping the bgrt filled with info
118+
* for the native resolution. If the bgrt image intended for the native
119+
* resolution still fits, it will be displayed very close to the right edge of
120+
* the display looking quite bad. This function checks for this.
121+
*/
122+
static bool efifb_bgrt_sanity_check(struct screen_info *si, u32 bmp_width)
123+
{
124+
static const int default_resolutions[][2] = {
125+
{ 800, 600 },
126+
{ 1024, 768 },
127+
{ 1280, 1024 },
128+
};
129+
u32 i, right_margin;
130+
131+
for (i = 0; i < ARRAY_SIZE(default_resolutions); i++) {
132+
if (default_resolutions[i][0] == si->lfb_width &&
133+
default_resolutions[i][1] == si->lfb_height)
134+
break;
135+
}
136+
/* If not a default resolution used for textmode, this should be fine */
137+
if (i >= ARRAY_SIZE(default_resolutions))
138+
return true;
139+
140+
/* If the right margin is 5 times smaller then the left one, reject */
141+
right_margin = si->lfb_width - (bgrt_tab.image_offset_x + bmp_width);
142+
if (right_margin < (bgrt_tab.image_offset_x / 5))
143+
return false;
144+
145+
return true;
146+
}
147+
#else
148+
static bool efifb_bgrt_sanity_check(struct screen_info *si, u32 bmp_width)
149+
{
150+
return true;
151+
}
152+
#endif
153+
114154
static void efifb_show_boot_graphics(struct fb_info *info)
115155
{
116156
u32 bmp_width, bmp_height, bmp_pitch, screen_pitch, dst_x, y, src_y;
@@ -169,6 +209,9 @@ static void efifb_show_boot_graphics(struct fb_info *info)
169209
(bgrt_tab.image_offset_y + bmp_height) > si->lfb_height)
170210
goto error;
171211

212+
if (!efifb_bgrt_sanity_check(si, bmp_width))
213+
goto error;
214+
172215
pr_info("efifb: showing boot graphics\n");
173216

174217
for (y = 0; y < si->lfb_height; y++, dst += si->lfb_linelength) {

0 commit comments

Comments
 (0)