From 2f329d90071befc27fa18da8d7440fe7ae631b3f Mon Sep 17 00:00:00 2001 From: Jonathon Hall Date: Wed, 9 Aug 2023 16:06:08 -0400 Subject: [PATCH 1/7] 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 --- Makefile | 1 + initrd/bin/setconsolefont.sh | 31 +++++++++++++++++++++++++++++++ initrd/init | 3 +++ modules/kbd | 24 ++++++++++++++++++++++++ 4 files changed, 59 insertions(+) create mode 100755 initrd/bin/setconsolefont.sh create mode 100644 modules/kbd diff --git a/Makefile b/Makefile index 06b2913e6..0c5087a2e 100644 --- a/Makefile +++ b/Makefile @@ -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), \ diff --git a/initrd/bin/setconsolefont.sh b/initrd/bin/setconsolefont.sh new file mode 100755 index 000000000..b2fba59e7 --- /dev/null +++ b/initrd/bin/setconsolefont.sh @@ -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 diff --git a/initrd/init b/initrd/init index 7fd9c612a..17dc1c571 100755 --- a/initrd/init +++ b/initrd/init @@ -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 diff --git a/modules/kbd b/modules/kbd new file mode 100644 index 000000000..6067a9965 --- /dev/null +++ b/modules/kbd @@ -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) From a3798713b2ff20f9dd4db4dbaa3ae4cebb779428 Mon Sep 17 00:00:00 2001 From: Jonathon Hall Date: Wed, 9 Aug 2023 16:08:10 -0400 Subject: [PATCH 2/7] fbwhiptail: Update to hires_scale branch fbwhiptail scales its UI based on the display size. FBWHIPTAIL_SCALE can set a specific scale factor for testing. fbwhiptail no longer looks for a 1080p mode when the default mode is 2160p. Signed-off-by: Jonathon Hall --- modules/fbwhiptail | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/fbwhiptail b/modules/fbwhiptail index 879354de0..cca2afd32 100644 --- a/modules/fbwhiptail +++ b/modules/fbwhiptail @@ -2,11 +2,11 @@ modules-$(CONFIG_FBWHIPTAIL) += fbwhiptail fbwhiptail_depends := cairo $(musl_dep) -fbwhiptail_version := 99fe815fb35d7650873aa413a3024ef1496fe4a3 +fbwhiptail_version := f08ee9c05c8c9a4f32ef3fa9e53b46e06dd2949f fbwhiptail_dir := fbwhiptail-$(fbwhiptail_version) fbwhiptail_tar := fbwhiptail-$(fbwhiptail_version).tar.gz fbwhiptail_url := https://source.puri.sm/firmware/fbwhiptail/-/archive/$(fbwhiptail_version)/fbwhiptail-$(fbwhiptail_version).tar.gz -fbwhiptail_hash := bd210b52b0916eb081219a312a6fa1b3acd8582ca6198a196e232f8aa55bbce9 +fbwhiptail_hash := 4123bc97693f2e2170f0899453258f641c3694cbbb4c6d534e8cc6a94bfb0630 fbwhiptail_target := \ $(MAKE_JOBS) \ From ef859731098d4e4da0e4a9614e56fd0b1ce69a0c Mon Sep 17 00:00:00 2001 From: Jonathon Hall Date: Wed, 9 Aug 2023 16:10:02 -0400 Subject: [PATCH 3/7] librem_15v4: Include kbd, don't force eDP resolution in Heads kernel Include kbd so the console font can be enlarged based on the display resolution. Don't force 1080p on the eDP output in Heads. Signed-off-by: Jonathon Hall --- boards/librem_15v4/librem_15v4.config | 1 + config/coreboot-librem_15v4.config | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/boards/librem_15v4/librem_15v4.config b/boards/librem_15v4/librem_15v4.config index 28fbe5cba..15082f478 100644 --- a/boards/librem_15v4/librem_15v4.config +++ b/boards/librem_15v4/librem_15v4.config @@ -11,6 +11,7 @@ CONFIG_CRYPTSETUP2=y CONFIG_FLASHROM=y CONFIG_FLASHTOOLS=y CONFIG_GPG2=y +CONFIG_KBD=y CONFIG_KEXEC=y CONFIG_UTIL_LINUX=y CONFIG_LVM2=y diff --git a/config/coreboot-librem_15v4.config b/config/coreboot-librem_15v4.config index 26ab7cfd4..4dc5715f2 100644 --- a/config/coreboot-librem_15v4.config +++ b/config/coreboot-librem_15v4.config @@ -10,5 +10,5 @@ CONFIG_NO_GFX_INIT=y CONFIG_TPM_MEASURED_BOOT=y CONFIG_PAYLOAD_LINUX=y CONFIG_PAYLOAD_FILE="@BOARD_BUILD_DIR@/bzImage" -CONFIG_LINUX_COMMAND_LINE="iommu=pt quiet loglevel=2 video=eDP-1:1920x1080 drm_kms_helper.drm_leak_fbdev_smem=1 i915.enable_fbc=0" +CONFIG_LINUX_COMMAND_LINE="iommu=pt quiet loglevel=2 drm_kms_helper.drm_leak_fbdev_smem=1 i915.enable_fbc=0" CONFIG_LINUX_INITRD="@BOARD_BUILD_DIR@/initrd.cpio.xz" From d0d2ea9a779a0b83e0ad991e73f5ec5665153727 Mon Sep 17 00:00:00 2001 From: Jonathon Hall Date: Wed, 9 Aug 2023 16:11:10 -0400 Subject: [PATCH 4/7] librem_mini{,_v2}: Include kbd to set console font size Include the kbd module to enlarge the console font size based on the display resolution. Signed-off-by: Jonathon Hall --- boards/librem_mini/librem_mini.config | 1 + boards/librem_mini_v2/librem_mini_v2.config | 1 + 2 files changed, 2 insertions(+) diff --git a/boards/librem_mini/librem_mini.config b/boards/librem_mini/librem_mini.config index e438c27d6..81717efcb 100644 --- a/boards/librem_mini/librem_mini.config +++ b/boards/librem_mini/librem_mini.config @@ -12,6 +12,7 @@ CONFIG_FLASHROM=y CONFIG_FLASHTOOLS=y CONFIG_GPG2=y CONFIG_IOPORT=y +CONFIG_KBD=y CONFIG_KEXEC=y CONFIG_UTIL_LINUX=y CONFIG_LVM2=y diff --git a/boards/librem_mini_v2/librem_mini_v2.config b/boards/librem_mini_v2/librem_mini_v2.config index 30878ad0b..145cf3558 100644 --- a/boards/librem_mini_v2/librem_mini_v2.config +++ b/boards/librem_mini_v2/librem_mini_v2.config @@ -12,6 +12,7 @@ CONFIG_FLASHROM=y CONFIG_FLASHTOOLS=y CONFIG_GPG2=y CONFIG_IOPORT=y +CONFIG_KBD=y CONFIG_KEXEC=y CONFIG_UTIL_LINUX=y CONFIG_LVM2=y From 57f9d1635b32ffba858c9f30782e25042ce8a454 Mon Sep 17 00:00:00 2001 From: Jonathon Hall Date: Wed, 9 Aug 2023 16:11:57 -0400 Subject: [PATCH 5/7] x230-*-fhd_edp: Include kbd to set console font size Include the kbd module to set the console font size based on the display resolution. Signed-off-by: Jonathon Hall --- .../x230-hotp-maximized-fhd_edp.config | 1 + boards/x230-maximized-fhd_edp/x230-maximized-fhd_edp.config | 1 + 2 files changed, 2 insertions(+) diff --git a/boards/x230-hotp-maximized-fhd_edp/x230-hotp-maximized-fhd_edp.config b/boards/x230-hotp-maximized-fhd_edp/x230-hotp-maximized-fhd_edp.config index ded332601..117031853 100644 --- a/boards/x230-hotp-maximized-fhd_edp/x230-hotp-maximized-fhd_edp.config +++ b/boards/x230-hotp-maximized-fhd_edp/x230-hotp-maximized-fhd_edp.config @@ -33,6 +33,7 @@ CONFIG_CRYPTSETUP2=y CONFIG_FLASHROM=y CONFIG_FLASHTOOLS=y CONFIG_GPG2=y +CONFIG_KBD=y CONFIG_KEXEC=y CONFIG_UTIL_LINUX=y CONFIG_LVM2=y diff --git a/boards/x230-maximized-fhd_edp/x230-maximized-fhd_edp.config b/boards/x230-maximized-fhd_edp/x230-maximized-fhd_edp.config index 2c2f096a7..69724dfd8 100644 --- a/boards/x230-maximized-fhd_edp/x230-maximized-fhd_edp.config +++ b/boards/x230-maximized-fhd_edp/x230-maximized-fhd_edp.config @@ -33,6 +33,7 @@ CONFIG_CRYPTSETUP2=y CONFIG_FLASHROM=y CONFIG_FLASHTOOLS=y CONFIG_GPG2=y +CONFIG_KBD=y CONFIG_KEXEC=y CONFIG_UTIL_LINUX=y CONFIG_LVM2=y From 4d613dacbbac0ecf4d125ffb2ab98af46d8234b5 Mon Sep 17 00:00:00 2001 From: Jonathon Hall Date: Thu, 10 Aug 2023 09:05:24 -0400 Subject: [PATCH 6/7] fbwhiptail: Update to hires_scale based on 1.2 release hires_scale was rebased on 1.2. Signed-off-by: Jonathon Hall --- modules/fbwhiptail | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/fbwhiptail b/modules/fbwhiptail index cca2afd32..431013f48 100644 --- a/modules/fbwhiptail +++ b/modules/fbwhiptail @@ -2,11 +2,11 @@ modules-$(CONFIG_FBWHIPTAIL) += fbwhiptail fbwhiptail_depends := cairo $(musl_dep) -fbwhiptail_version := f08ee9c05c8c9a4f32ef3fa9e53b46e06dd2949f +fbwhiptail_version := 1b3ee5ca1e297a977d9ebab49df942c51d619ecd fbwhiptail_dir := fbwhiptail-$(fbwhiptail_version) fbwhiptail_tar := fbwhiptail-$(fbwhiptail_version).tar.gz fbwhiptail_url := https://source.puri.sm/firmware/fbwhiptail/-/archive/$(fbwhiptail_version)/fbwhiptail-$(fbwhiptail_version).tar.gz -fbwhiptail_hash := 4123bc97693f2e2170f0899453258f641c3694cbbb4c6d534e8cc6a94bfb0630 +fbwhiptail_hash := f7691a82dac3aca6592ca85cbd7ec116bd7c2eae5b834f95c76967532c9aec79 fbwhiptail_target := \ $(MAKE_JOBS) \ From 98fc0cb81a7b5bd8074041d674ebe3da9f9a2d8e Mon Sep 17 00:00:00 2001 From: Jonathon Hall Date: Fri, 11 Aug 2023 13:16:00 -0400 Subject: [PATCH 7/7] initrd/bin/setconsolefont.sh: Reduce threshold for 2x console to 1350 Based on feedback, 1440p displays can benefit from 2x console as well. Err toward a font too large rather than too small and lower the threshold to 1350, which is the threshold fbwhiptail uses for 1.5x. Signed-off-by: Jonathon Hall --- initrd/bin/setconsolefont.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/initrd/bin/setconsolefont.sh b/initrd/bin/setconsolefont.sh index b2fba59e7..1f2177414 100755 --- a/initrd/bin/setconsolefont.sh +++ b/initrd/bin/setconsolefont.sh @@ -19,7 +19,14 @@ fi CONSOLE_HEIGHT="$(cut -d, -f2 /sys/class/graphics/fb0/virtual_size)" -if [ "$CONSOLE_HEIGHT" -ge 1600 ]; then +# Deciding scale based on resolution is inherently heuristic, as the scale +# really depends on resolution, physical size, how close the display is to the +# user, and personal preference. +# +# fbwhiptail starts using 1.5x scale at 1350 lines, but we can only choose 1x +# or 2x (without shipping more fonts). Err toward making the console too large +# rather than too small and go to 2x at 1350 lines. +if [ "$CONSOLE_HEIGHT" -ge 1350 ]; 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)