summaryrefslogtreecommitdiff
path: root/payloads
diff options
context:
space:
mode:
Diffstat (limited to 'payloads')
-rw-r--r--payloads/libpayload/Kconfig7
-rw-r--r--payloads/libpayload/drivers/video/corebootfb.c23
2 files changed, 28 insertions, 2 deletions
diff --git a/payloads/libpayload/Kconfig b/payloads/libpayload/Kconfig
index f7501e36b0..36f4af5215 100644
--- a/payloads/libpayload/Kconfig
+++ b/payloads/libpayload/Kconfig
@@ -315,6 +315,13 @@ config COREBOOT_VIDEO_CONSOLE
Say Y here if coreboot switched to a graphics mode and
your payload wants to use it.
+config COREBOOT_VIDEO_CENTERED
+ bool "Center a classic 80x25 console on bigger screens"
+ depends on COREBOOT_VIDEO_CONSOLE
+ help
+ Say 'y' here if your payload is hardcoded to a 80x25 console. Otherwise
+ its output would look squeezed into the upper-left corner of the screen.
+
config FONT_SCALE_FACTOR
int "Scale factor for the included font"
depends on GEODELX_VIDEO_CONSOLE || COREBOOT_VIDEO_CONSOLE
diff --git a/payloads/libpayload/drivers/video/corebootfb.c b/payloads/libpayload/drivers/video/corebootfb.c
index c4b50480dd..8e7ac11540 100644
--- a/payloads/libpayload/drivers/video/corebootfb.c
+++ b/payloads/libpayload/drivers/video/corebootfb.c
@@ -236,8 +236,16 @@ static int corebootfb_init(void)
font_init(FI->x_resolution);
- coreboot_video_console.columns = FI->x_resolution / font_width;
- coreboot_video_console.rows = FI->y_resolution / font_height;
+ /* Draw centered on the framebuffer if requested and feasible, */
+ const int center =
+ IS_ENABLED(CONFIG_LP_COREBOOT_VIDEO_CENTERED)
+ && coreboot_video_console.columns * font_width <= FI->x_resolution
+ && coreboot_video_console.rows * font_height <= FI->y_resolution;
+ /* adapt to the framebuffer size, otherwise. */
+ if (!center) {
+ coreboot_video_console.columns = FI->x_resolution / font_width;
+ coreboot_video_console.rows = FI->y_resolution / font_height;
+ }
chars = malloc(coreboot_video_console.rows *
coreboot_video_console.columns * 2);
@@ -246,6 +254,17 @@ static int corebootfb_init(void)
// clear boot splash screen if there is one.
corebootfb_clear();
+
+ if (center) {
+ FI->physical_address +=
+ (FI->x_resolution - coreboot_video_console.columns * font_width)
+ / 2 * FI->bits_per_pixel / 8
+ + (FI->y_resolution - coreboot_video_console.rows * font_height)
+ / 2 * FI->bytes_per_line;
+ FI->x_resolution = coreboot_video_console.columns * font_width;
+ FI->y_resolution = coreboot_video_console.rows * font_height;
+ }
+
return 0;
}