Skip to content

Commit

Permalink
Merge pull request #1459 from JonathonHall-Purism/hires_scale
Browse files Browse the repository at this point in the history
Scale fbwhiptail and console font for high resolution displays
  • Loading branch information
tlaurion authored Aug 11, 2023
2 parents f42070a + 98fc0cb commit 59972f3
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 3 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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), \
Expand Down
1 change: 1 addition & 0 deletions boards/librem_15v4/librem_15v4.config
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions boards/librem_mini/librem_mini.config
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions boards/librem_mini_v2/librem_mini_v2.config
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion config/coreboot-librem_15v4.config
Original file line number Diff line number Diff line change
Expand Up @@ -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"
38 changes: 38 additions & 0 deletions initrd/bin/setconsolefont.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/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)"

# 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)
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
3 changes: 3 additions & 0 deletions initrd/init
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions modules/fbwhiptail
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ modules-$(CONFIG_FBWHIPTAIL) += fbwhiptail

fbwhiptail_depends := cairo $(musl_dep)

fbwhiptail_version := 99fe815fb35d7650873aa413a3024ef1496fe4a3
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 := bd210b52b0916eb081219a312a6fa1b3acd8582ca6198a196e232f8aa55bbce9
fbwhiptail_hash := f7691a82dac3aca6592ca85cbd7ec116bd7c2eae5b834f95c76967532c9aec79

fbwhiptail_target := \
$(MAKE_JOBS) \
Expand Down
24 changes: 24 additions & 0 deletions modules/kbd
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 59972f3

Please sign in to comment.