From patchwork Mon Jul 16 13:45:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 10526827 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 053F46020A for ; Mon, 16 Jul 2018 13:45:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB5A4285EA for ; Mon, 16 Jul 2018 13:45:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DFB5028B15; Mon, 16 Jul 2018 13:45:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 687B5285EA for ; Mon, 16 Jul 2018 13:45:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727479AbeGPONS (ORCPT ); Mon, 16 Jul 2018 10:13:18 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:56344 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727203AbeGPONS (ORCPT ); Mon, 16 Jul 2018 10:13:18 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0D96140201A3; Mon, 16 Jul 2018 13:45:46 +0000 (UTC) Received: from shalem.localdomain.com (ovpn-117-56.ams2.redhat.com [10.36.117.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 102241C589; Mon, 16 Jul 2018 13:45:44 +0000 (UTC) From: Hans de Goede To: Bartlomiej Zolnierkiewicz Cc: Hans de Goede , dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org Subject: [PATCH] efifb: BGRT: Do not copy the boot graphics for non native resolutions Date: Mon, 16 Jul 2018 15:45:43 +0200 Message-Id: <20180716134543.26091-1-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Mon, 16 Jul 2018 13:45:46 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Mon, 16 Jul 2018 13:45:46 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'hdegoede@redhat.com' RCPT:'' Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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) {