kbd: Add setfont from kbd to set large console font on large displays

Build kbd and ship setfont if enabled with CONFIG_KBD.

When CONFIG_KBD is enabled, setconsolefont.sh will double the console
font size on large displays (>1600 lines tall as a heuristic).

Signed-off-by: Jonathon Hall <jonathon.hall@puri.sm>
This commit is contained in:
Jonathon Hall 2023-08-09 16:06:08 -04:00
parent 68f707baad
commit 2f329d9007
No known key found for this signature in database
GPG Key ID: 1E9C3CA91AE25114
4 changed files with 59 additions and 0 deletions

View File

@ -518,6 +518,7 @@ bin_modules-$(CONFIG_BASH) += bash
bin_modules-$(CONFIG_POWERPC_UTILS) += powerpc-utils
bin_modules-$(CONFIG_IO386) += io386
bin_modules-$(CONFIG_IOPORT) += ioport
bin_modules-$(CONFIG_KBD) += kbd
bin_modules-$(CONFIG_ZSTD) += zstd
$(foreach m, $(bin_modules-y), \

31
initrd/bin/setconsolefont.sh Executable file
View File

@ -0,0 +1,31 @@
#!/bin/bash
set -eo pipefail
. /etc/functions
TRACE "Under /bin/setconsolefont.sh"
# If the board ships setfont, and the console size is >=1600 lines tall,
# increase the console font size.
if [ ! -x /bin/setfont ]; then
DEBUG "Board does not ship setfont, not checking console font"
exit 0
fi
if [ ! -f /sys/class/graphics/fb0/virtual_size ]; then
DEBUG "fb0 virtual size is not known"
exit 0
fi
CONSOLE_HEIGHT="$(cut -d, -f2 /sys/class/graphics/fb0/virtual_size)"
if [ "$CONSOLE_HEIGHT" -ge 1600 ]; then
DEBUG "Double console font size due to framebuffer height $CONSOLE_HEIGHT"
# Double the default font size by reading it out, then applying it again
# with setfont's -d option (double font size)
setfont -O /tmp/default_font
setfont -d /tmp/default_font
rm /tmp/default_font
else
DEBUG "Keep default console font size due to framebuffer height $CONSOLE_HEIGHT"
fi

View File

@ -153,6 +153,9 @@ if [ ! -z "$CONFIG_BOOT_DEV" ]; then
echo >> /etc/fstab "$CONFIG_BOOT_DEV /boot auto defaults,ro 0 0"
fi
# Set the console font if needed
[ -x /bin/bash ] && setconsolefont.sh
if [ "$CONFIG_BASIC" = "y" ]; then
CONFIG_BOOTSCRIPT=/bin/gui-init-basic
export CONFIG_HOTPKEY=n

24
modules/kbd Normal file
View File

@ -0,0 +1,24 @@
modules-$(CONFIG_KBD) += kbd
kbd_version := 2.6.1
kbd_dir := kbd-$(kbd_version)
kbd_tar := kbd-$(kbd_version).tar.gz
kbd_url := https://www.kernel.org/pub/linux/utils/kbd/$(kbd_tar)
kbd_hash := aaed530a1490d63d041448372e2ad4f38c3179042903251000b71d527c46e945
kbd_configure := CFLAGS=-Os ./configure \
$(CROSS_TOOLS) \
--prefix "" \
--host i386-elf-linux \
--disable-optional-progs \
--disable-libkeymap \
--disable-libkfont \
--disable-vlock \
kbd_target := \
$(MAKE_JOBS) $(CROSS_TOOLS)
kbd_output := \
src/setfont
kbd_depends := $(musl_dep)