From 25de7c1b120b83598170e6be810058447db802fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Wed, 8 May 2019 04:32:08 +0200 Subject: [PATCH] loader: VESA: make nvidia scaling fixup a driver setting Since not everyone likes the default, make it an option in the vesa settings file. Note setting a mode with the Screen prefs overwrites the file so it will discard the option. Also move the code to get_mode_from_settings() since we can't load driver settings as early as vesa_init(). Change-Id: I93080bd1fbc064dab053624ad37935268b1ed17d --- data/settings/kernel/drivers/vesa | 5 +++ src/system/boot/platform/bios_ia32/video.cpp | 47 ++++++++++++-------- 2 files changed, 34 insertions(+), 18 deletions(-) diff --git a/data/settings/kernel/drivers/vesa b/data/settings/kernel/drivers/vesa index 80a1366263..141193f28d 100644 --- a/data/settings/kernel/drivers/vesa +++ b/data/settings/kernel/drivers/vesa @@ -2,3 +2,8 @@ # mode {x-resolution} {y-resolution} {bitdepth}, # for example: #mode 1280 1024 32 + +# Set NVIDIA scaling mode +# 1: disable scaling completely +# other modes are available depending on the BIOS +#nvidia_scaling 1 diff --git a/src/system/boot/platform/bios_ia32/video.cpp b/src/system/boot/platform/bios_ia32/video.cpp index 4a719478f7..220db2d5a3 100644 --- a/src/system/boot/platform/bios_ia32/video.cpp +++ b/src/system/boot/platform/bios_ia32/video.cpp @@ -258,6 +258,33 @@ find_edid_mode(edid1_info& info, bool allowPalette) } +static void +vesa_fixups(void *settings) +{ + const char *oem_string = (const char *)sInfo.oem_string; + + if (!strcmp(oem_string, "NVIDIA")) { + const char *arg = NULL; + int32 scaling = -1; + + if (settings != NULL) + arg = get_driver_parameter(settings, "nvidia_scaling", NULL, "1"); + if (arg != NULL) + scaling = strtol(arg, NULL, 0); + + if (scaling > -1) { + dprintf("Setting nvidia scaling mode to %" B_PRId32 "\n", scaling); + struct bios_regs regs; + regs.eax = 0x4f14; + regs.ebx = 0x0102; + regs.ecx = scaling; + call_bios(0x10, ®s); + } + } + +} + + static bool get_mode_from_settings(void) { @@ -268,6 +295,8 @@ get_mode_from_settings(void) if (handle == NULL) return false; + vesa_fixups(handle); + bool found = false; const driver_settings *settings = get_driver_settings(handle); @@ -439,30 +468,12 @@ vesa_get_vbe_info_block(vbe_info_block *info) } -static void -vesa_fixups(vbe_info_block *info) -{ - const char *oem_string = (const char *)info->oem_string; - - if (!strcmp(oem_string, "NVIDIA")) { - dprintf("Disabling nvidia scaling.\n"); - struct bios_regs regs; - regs.eax = 0x4f14; - regs.ebx = 0x0102; - regs.ecx = 1; // centered unscaled - call_bios(0x10, ®s); - } -} - - static status_t vesa_init(vbe_info_block *info, video_mode **_standardMode) { if (vesa_get_vbe_info_block(info) != B_OK) return B_ERROR; - vesa_fixups(info); - // fill mode list and find standard video mode video_mode *standardMode = NULL;