From patchwork Thu Nov 7 11:43:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Po-Hsu Lin X-Patchwork-Id: 1191097 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4781ms4JJlz9sPk; Thu, 7 Nov 2019 22:45:32 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1iSgEA-0001pq-Qp; Thu, 07 Nov 2019 11:45:26 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1iSgE9-0001pB-3i for kernel-team@lists.ubuntu.com; Thu, 07 Nov 2019 11:45:25 +0000 Received: from mail-pl1-f198.google.com ([209.85.214.198]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1iSgE8-0005eZ-Qb for kernel-team@lists.ubuntu.com; Thu, 07 Nov 2019 11:45:24 +0000 Received: by mail-pl1-f198.google.com with SMTP id x9so1506046plv.2 for ; Thu, 07 Nov 2019 03:45:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=zv0TTSbeA+EL2vIjVhSZe7X2qwjvvH0lehxXQ7v0rps=; b=XDU8BGs6Df9VdMkOYnrpKMlqJOXHOawxY8seBhinK+t/4NI3urT7mYpqr/LBVCHx94 nXS7Q3FyOgaOJuCFNerVvB0OUBpcv7ICf0cQvgmxinKwuVWt8peqn75e1ORsW8DjbK3b zVtPha0OER0StnPDoQpN1jAJZ6v3H41W3bZ+OMQ9CXkYx5zFKqTO4+qWZx8S6gwGiC+O sdSDZ2JhOxdhDsNhtth+NCnVKbO6BPX72BKOcxOZfm/hiLCYULFgVQw0UbKItcdQnLLK FAMejFRTT5ocmoGKCUuVnbqXDGHseO7ty7KHy9uz6YD4PsT44YxYMqkls7Kpjl1zED5U LVVQ== X-Gm-Message-State: APjAAAXPjV0z7GMnD1ynaXPKFatGv449y0buRwYR62NHTZp0HEtIxOo0 AWB42Eze3tt/2buqVq7tuB4kJdntv4pIarg+dJoYU2cAisPXEeiIjf7xyKDBPcGNk8oNU8aG7v8 U+jSLNLu1C31TnyYbjQW5qMzqXjCdxM6majtgTZrZ X-Received: by 2002:a17:902:9a8d:: with SMTP id w13mr3287750plp.330.1573127123169; Thu, 07 Nov 2019 03:45:23 -0800 (PST) X-Google-Smtp-Source: APXvYqxZsbfBTfNbyntTr8far8jHef0FcxcN+pFD4fjMaemCC0J0MBGn71ChNI7frnwuIDiQodZAEw== X-Received: by 2002:a17:902:9a8d:: with SMTP id w13mr3287707plp.330.1573127122627; Thu, 07 Nov 2019 03:45:22 -0800 (PST) Received: from Leggiero.taipei.internal (61-220-137-37.HINET-IP.hinet.net. [61.220.137.37]) by smtp.gmail.com with ESMTPSA id m19sm1963377pgh.31.2019.11.07.03.45.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Nov 2019 03:45:21 -0800 (PST) From: Po-Hsu Lin To: kernel-team@lists.ubuntu.com Subject: [X/B/D][SRU][PATCH 1/2] fonts: Fix coding style Date: Thu, 7 Nov 2019 19:43:57 +0800 Message-Id: <20191107114358.21868-2-po-hsu.lin@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191107114358.21868-1-po-hsu.lin@canonical.com> References: <20191107114358.21868-1-po-hsu.lin@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Takashi Iwai BugLink: https://bugs.launchpad.net/bugs/1851623 Fix indentation, spaces, and move EXPORT_SYMBOL line to the appropriate place as a preliminary work. No actual code change. Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman (cherry picked from commit aa1d19f1f96764e72155235ece22461599d0e7ac) Signed-off-by: Po-Hsu Lin --- lib/fonts/fonts.c | 83 +++++++++++++++++++++++++++---------------------------- 1 file changed, 40 insertions(+), 43 deletions(-) diff --git a/lib/fonts/fonts.c b/lib/fonts/fonts.c index 9969358..269a829 100644 --- a/lib/fonts/fonts.c +++ b/lib/fonts/fonts.c @@ -25,51 +25,51 @@ static const struct font_desc *fonts[] = { #ifdef CONFIG_FONT_8x8 #undef NO_FONTS - &font_vga_8x8, + &font_vga_8x8, #endif #ifdef CONFIG_FONT_8x16 #undef NO_FONTS - &font_vga_8x16, + &font_vga_8x16, #endif #ifdef CONFIG_FONT_6x11 #undef NO_FONTS - &font_vga_6x11, + &font_vga_6x11, #endif #ifdef CONFIG_FONT_7x14 #undef NO_FONTS - &font_7x14, + &font_7x14, #endif #ifdef CONFIG_FONT_SUN8x16 #undef NO_FONTS - &font_sun_8x16, + &font_sun_8x16, #endif #ifdef CONFIG_FONT_SUN12x22 #undef NO_FONTS - &font_sun_12x22, + &font_sun_12x22, #endif #ifdef CONFIG_FONT_10x18 #undef NO_FONTS - &font_10x18, + &font_10x18, #endif #ifdef CONFIG_FONT_ACORN_8x8 #undef NO_FONTS - &font_acorn_8x8, + &font_acorn_8x8, #endif #ifdef CONFIG_FONT_PEARL_8x8 #undef NO_FONTS - &font_pearl_8x8, + &font_pearl_8x8, #endif #ifdef CONFIG_FONT_MINI_4x6 #undef NO_FONTS - &font_mini_4x6, + &font_mini_4x6, #endif #ifdef CONFIG_FONT_6x10 #undef NO_FONTS - &font_6x10, + &font_6x10, #endif #ifdef CONFIG_FONT_TER16x32 #undef NO_FONTS - &font_ter_16x32, + &font_ter_16x32, #endif }; @@ -90,16 +90,16 @@ static const struct font_desc *fonts[] = { * specified font. * */ - const struct font_desc *find_font(const char *name) { - unsigned int i; + unsigned int i; - for (i = 0; i < num_fonts; i++) - if (!strcmp(fonts[i]->name, name)) - return fonts[i]; - return NULL; + for (i = 0; i < num_fonts; i++) + if (!strcmp(fonts[i]->name, name)) + return fonts[i]; + return NULL; } +EXPORT_SYMBOL(find_font); /** @@ -116,44 +116,41 @@ const struct font_desc *find_font(const char *name) * chosen font. * */ - const struct font_desc *get_default_font(int xres, int yres, u32 font_w, u32 font_h) { - int i, c, cc; - const struct font_desc *f, *g; - - g = NULL; - cc = -10000; - for(i=0; ipref; + int i, c, cc; + const struct font_desc *f, *g; + + g = NULL; + cc = -10000; + for (i = 0; i < num_fonts; i++) { + f = fonts[i]; + c = f->pref; #if defined(__mc68000__) #ifdef CONFIG_FONT_PEARL_8x8 - if (MACH_IS_AMIGA && f->idx == PEARL8x8_IDX) - c = 100; + if (MACH_IS_AMIGA && f->idx == PEARL8x8_IDX) + c = 100; #endif #ifdef CONFIG_FONT_6x11 - if (MACH_IS_MAC && xres < 640 && f->idx == VGA6x11_IDX) - c = 100; + if (MACH_IS_MAC && xres < 640 && f->idx == VGA6x11_IDX) + c = 100; #endif #endif - if ((yres < 400) == (f->height <= 8)) - c += 1000; + if ((yres < 400) == (f->height <= 8)) + c += 1000; - if ((font_w & (1 << (f->width - 1))) && - (font_h & (1 << (f->height - 1)))) - c += 1000; + if ((font_w & (1 << (f->width - 1))) && + (font_h & (1 << (f->height - 1)))) + c += 1000; - if (c > cc) { - cc = c; - g = f; + if (c > cc) { + cc = c; + g = f; + } } - } - return g; + return g; } - -EXPORT_SYMBOL(find_font); EXPORT_SYMBOL(get_default_font); MODULE_AUTHOR("James Simmons "); From patchwork Thu Nov 7 11:43:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Po-Hsu Lin X-Patchwork-Id: 1191099 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4781mt0ldNz9sR1; Thu, 7 Nov 2019 22:45:32 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1iSgEB-0001qL-VO; Thu, 07 Nov 2019 11:45:27 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1iSgEA-0001pb-EL for kernel-team@lists.ubuntu.com; Thu, 07 Nov 2019 11:45:26 +0000 Received: from mail-pg1-f198.google.com ([209.85.215.198]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1iSgEA-0005en-5e for kernel-team@lists.ubuntu.com; Thu, 07 Nov 2019 11:45:26 +0000 Received: by mail-pg1-f198.google.com with SMTP id t28so1619213pgl.21 for ; Thu, 07 Nov 2019 03:45:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=48TDD4Wxxgzn1laK6h5AJJAkXHYQYNaMU8fMuuAB08s=; b=h8qjBghbkvla0DJkIdfwMesCuWFZSYycLGjiBeeSyhJu5QgLzgTM7LuAUatP4XmjkU kNxQDLMeBtGwQ9OPBagf7UgiSZeg/ELtmPBE20reyeaV8HeFWaOpcBawYe23rxRfLOkO 0TJSBl58yhG3SjagLzBlqlNWc2Pti2q+T9lL2c4MdxRVCu+Q+3HV2crNCCv8zTwD38Rg EEgDWgzpsN0WAluPOJcTC6bqVfES3Gy1glm5gFvUT0drNFRkeexpkFx5TV7WK+hT2GgS 9eiLjaicTDMfNC6u7SrtB8E0sESXPgC0Q8wLhUOfret9xJCWpnxyGmu8yQSXCTb72kPp G7vg== X-Gm-Message-State: APjAAAX6WIqU1vRtNVJgEf8evdc7CNES0Etrx1NcE1NNgEyucLLf3fno HHD05zzn6oKiCUD8+ZJ5IS3bmMUnzXKnqrTA6vG9outb5HkY1AyO7gW4jTGRoOr4uYSt4AOE7wJ 2SGJJpviZyWfLqt9TL/uRs/JrFXrWNe9JmLPrmE+i X-Received: by 2002:a17:90a:48:: with SMTP id 8mr4378887pjb.82.1573127124599; Thu, 07 Nov 2019 03:45:24 -0800 (PST) X-Google-Smtp-Source: APXvYqyy8krDTNAhRColm/DOvN6hvxr11oNvCaaTsspz6yfCaN7hoqQmMNr17JL+gbARcvhamf1GgQ== X-Received: by 2002:a17:90a:48:: with SMTP id 8mr4378840pjb.82.1573127124207; Thu, 07 Nov 2019 03:45:24 -0800 (PST) Received: from Leggiero.taipei.internal (61-220-137-37.HINET-IP.hinet.net. [61.220.137.37]) by smtp.gmail.com with ESMTPSA id m19sm1963377pgh.31.2019.11.07.03.45.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Nov 2019 03:45:23 -0800 (PST) From: Po-Hsu Lin To: kernel-team@lists.ubuntu.com Subject: [X/B/D][SRU][PATCH 2/2] fonts: Prefer a bigger font for high resolution screens Date: Thu, 7 Nov 2019 19:43:58 +0800 Message-Id: <20191107114358.21868-3-po-hsu.lin@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191107114358.21868-1-po-hsu.lin@canonical.com> References: <20191107114358.21868-1-po-hsu.lin@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Takashi Iwai BugLink: https://bugs.launchpad.net/bugs/1851623 Although we may have multiple fonts in kernel, the small 8x16 font is chosen as default usually unless user specify the boot option. This is suboptimal for monitors with high resolutions. This patch tries to assign a bigger font for such a high resolution by calculating some penalty value. This won't change anything for a standard monitor like Full HD (1920x1080), but for a high res monitor like UHD 4K, a bigger font like TER16x32 will be chosen once when enabled in Kconfig. Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman (cherry picked from commit dfd19a5004eff03755967086aa04254c3d91b8ec) Signed-off-by: Po-Hsu Lin --- lib/fonts/fonts.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/fonts/fonts.c b/lib/fonts/fonts.c index 269a829..0edd580 100644 --- a/lib/fonts/fonts.c +++ b/lib/fonts/fonts.c @@ -119,7 +119,7 @@ EXPORT_SYMBOL(find_font); const struct font_desc *get_default_font(int xres, int yres, u32 font_w, u32 font_h) { - int i, c, cc; + int i, c, cc, res; const struct font_desc *f, *g; g = NULL; @@ -140,6 +140,11 @@ const struct font_desc *get_default_font(int xres, int yres, u32 font_w, if ((yres < 400) == (f->height <= 8)) c += 1000; + /* prefer a bigger font for high resolution */ + res = (xres / f->width) * (yres / f->height) / 1000; + if (res > 20) + c += 20 - res; + if ((font_w & (1 << (f->width - 1))) && (font_h & (1 << (f->height - 1)))) c += 1000;