public inbox for linux-fbdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] efifb: BGRT: Do not copy the boot graphics for non native resolutions
@ 2018-07-16 13:45 ` Hans de Goede
  2018-07-24 17:09   ` Bartlomiej Zolnierkiewicz
  0 siblings, 1 reply; 2+ messages in thread
From: Hans de Goede @ 2018-07-16 13:45 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz; +Cc: Hans de Goede, linux-fbdev, dri-devel

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 <hdegoede@redhat.com>
---
 drivers/video/fbdev/efifb.c | 43 +++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/drivers/video/fbdev/efifb.c b/drivers/video/fbdev/efifb.c
index fa01eecc0a55..52bf39f93888 100644
--- a/drivers/video/fbdev/efifb.c
+++ b/drivers/video/fbdev/efifb.c
@@ -111,6 +111,46 @@ static void efifb_copy_bmp(u8 *src, u32 *dst, int width, struct screen_info *si)
 	}
 }
 
+#ifdef CONFIG_X86
+/*
+ * 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 function checks for this.
+ */
+static bool efifb_bgrt_sanity_check(struct screen_info *si, u32 bmp_width)
+{
+	static const int default_resolutions[][2] = {
+		{  800,  600 },
+		{ 1024,  768 },
+		{ 1280, 1024 },
+	};
+	u32 i, right_margin;
+
+	for (i = 0; i < ARRAY_SIZE(default_resolutions); i++) {
+		if (default_resolutions[i][0] = si->lfb_width &&
+		    default_resolutions[i][1] = si->lfb_height)
+			break;
+	}
+	/* If not a default resolution used for textmode, this should be fine */
+	if (i >= ARRAY_SIZE(default_resolutions))
+		return true;
+
+	/* If the right margin is 5 times smaller then the left one, reject */
+	right_margin = si->lfb_width - (bgrt_tab.image_offset_x + bmp_width);
+	if (right_margin < (bgrt_tab.image_offset_x / 5))
+		return false;
+
+	return true;
+}
+#else
+static bool efifb_bgrt_sanity_check(struct screen_info *si, u32 bmp_width)
+{
+	return true;
+}
+#endif
+
 static void efifb_show_boot_graphics(struct fb_info *info)
 {
 	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)
 	    (bgrt_tab.image_offset_y + bmp_height) > si->lfb_height)
 		goto error;
 
+	if (!efifb_bgrt_sanity_check(si, bmp_width))
+		goto error;
+
 	pr_info("efifb: showing boot graphics\n");
 
 	for (y = 0; y < si->lfb_height; y++, dst += si->lfb_linelength) {
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] efifb: BGRT: Do not copy the boot graphics for non native resolutions
  2018-07-16 13:45 ` [PATCH] efifb: BGRT: Do not copy the boot graphics for non native resolutions Hans de Goede
@ 2018-07-24 17:09   ` Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 2+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2018-07-24 17:09 UTC (permalink / raw)
  To: Hans de Goede; +Cc: linux-fbdev, dri-devel

On Monday, July 16, 2018 03:45:43 PM Hans de Goede wrote:
> 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 <hdegoede@redhat.com>

Patch queued for 4.19, thanks.

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-07-24 17:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CGME20180716134549epcas2p4d829ac8115d54ef324bce42821536dd2@epcas2p4.samsung.com>
2018-07-16 13:45 ` [PATCH] efifb: BGRT: Do not copy the boot graphics for non native resolutions Hans de Goede
2018-07-24 17:09   ` Bartlomiej Zolnierkiewicz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox