diff options
author | Paul Kocialkowski <contact@paulk.fr> | 2017-07-23 16:05:47 +0300 |
---|---|---|
committer | Martin Roth <martinroth@google.com> | 2017-08-03 20:37:07 +0000 |
commit | d85e485c5892f2d96e8c5d10828c13af154a5481 (patch) | |
tree | 38a90e1b5efaae53430068ba823ee95044262459 /payloads | |
parent | 1c0b603673a3132a1554905dbcfe95c8fadb501e (diff) |
libpayload: video: Add support for font scaling with a factor
This introduces support for font scaling with a factor provided via
Kconfig. In practice, the font itself is not scaled at any point in
memory and only the logic to determine whether a pixel should be filled
or not is changed.
Thus, it should not significantly impact either the access time or
memory use.
Change-Id: Idff210617c9ec08c6034aef107cfdb34c7cdf029
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
Reviewed-on: https://review.coreboot.org/20709
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Diffstat (limited to 'payloads')
-rw-r--r-- | payloads/libpayload/Kconfig | 8 | ||||
-rw-r--r-- | payloads/libpayload/drivers/video/corebootfb.c | 2 | ||||
-rw-r--r-- | payloads/libpayload/drivers/video/font.c | 14 | ||||
-rw-r--r-- | payloads/libpayload/drivers/video/font.h | 5 | ||||
-rw-r--r-- | payloads/libpayload/drivers/video/geodelx.c | 2 |
5 files changed, 24 insertions, 7 deletions
diff --git a/payloads/libpayload/Kconfig b/payloads/libpayload/Kconfig index 63cc1527b6..8fd6a9c763 100644 --- a/payloads/libpayload/Kconfig +++ b/payloads/libpayload/Kconfig @@ -321,6 +321,14 @@ config COREBOOT_VIDEO_CONSOLE Say Y here if coreboot switched to a graphics mode and your payload wants to use it. +config FONT_SCALE_FACTOR + int "Scale factor for the included font" + depends on GEODELX_VIDEO_CONSOLE || COREBOOT_VIDEO_CONSOLE + default 0 + help + By default (value of 0), the scale factor is automatically + calculated to ensure at least 130 columns (when possible). + config PC_KEYBOARD bool "Allow input from a PC keyboard" default y if ARCH_X86 # uses IO diff --git a/payloads/libpayload/drivers/video/corebootfb.c b/payloads/libpayload/drivers/video/corebootfb.c index 69aa1d7f65..b5ad1a511d 100644 --- a/payloads/libpayload/drivers/video/corebootfb.c +++ b/payloads/libpayload/drivers/video/corebootfb.c @@ -238,7 +238,7 @@ static int corebootfb_init(void) if (fbaddr == 0) return -1; - font_init(); + font_init(FI->x_resolution); coreboot_video_console.columns = FI->x_resolution / font_width; coreboot_video_console.rows = FI->y_resolution / font_height; diff --git a/payloads/libpayload/drivers/video/font.c b/payloads/libpayload/drivers/video/font.c index 59d476dacf..8758a9646e 100644 --- a/payloads/libpayload/drivers/video/font.c +++ b/payloads/libpayload/drivers/video/font.c @@ -27,14 +27,22 @@ * SUCH DAMAGE. */ +#include <libpayload.h> #include "font8x16.h" #include "font.h" +#define COLS_MIN 130 + int font_width; int font_height; +int font_scale; -void font_init(void) +void font_init(int width) { - font_width = FONT_WIDTH; - font_height = FONT_HEIGHT; + font_scale = CONFIG_LP_FONT_SCALE_FACTOR; + if (!font_scale) + font_scale = MAX(width / (FONT_WIDTH * COLS_MIN), 1); + + font_width = FONT_WIDTH * font_scale; + font_height = FONT_HEIGHT * font_scale; } diff --git a/payloads/libpayload/drivers/video/font.h b/payloads/libpayload/drivers/video/font.h index a5e0b85c02..9ea328c78d 100644 --- a/payloads/libpayload/drivers/video/font.h +++ b/payloads/libpayload/drivers/video/font.h @@ -34,13 +34,14 @@ extern int font_width; extern int font_height; +extern int font_scale; inline int font_glyph_filled(unsigned int ch, int x, int y) { unsigned char *glyph = font8x16 + ((ch & 0xFF) * FONT_HEIGHT); - return glyph[y] & (1 << x); + return glyph[y/font_scale] & (1 << x/font_scale); } -void font_init(void); +void font_init(int width); #endif diff --git a/payloads/libpayload/drivers/video/geodelx.c b/payloads/libpayload/drivers/video/geodelx.c index 46fa833ec1..e14a96b332 100644 --- a/payloads/libpayload/drivers/video/geodelx.c +++ b/payloads/libpayload/drivers/video/geodelx.c @@ -268,7 +268,7 @@ static int geodelx_init(void) dcaddr = pci_read_resource(dev, 2); vgaddr = pci_read_resource(dev, 3); - font_init(); + font_init(vga_mode.hactive); init_video_mode(); |