提交 0701d155 编写于 作者: V vit9696

OcMainLib: Implement automatic scaling factor detection

closes acidanthera/bugtracker#1717
上级 a41d4806
......@@ -2,6 +2,7 @@ OpenCore Changelog
==================
#### v0.7.6
- Fixed stack canary support when compiling with GCC
- Added automatic scaling factor detection
#### v0.7.5
- Revised OpenLinuxBoot documentation
......
......@@ -7366,6 +7366,21 @@ with the boot menu.
On all known affected systems, \texttt{ConsoleMode} must be set to
an empty string for this option to work.
\item
\texttt{UIScale}\\
\textbf{Type}: \texttt{plist\ integer}, 8 bit\\
\textbf{Failsafe}: \texttt{-1}\\
\textbf{Description}: User interface scaling factor.
Corresponds to \texttt{4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14:UIScale} variable.
\begin{itemize}
\tightlist
\item \texttt{1} --- 1x scaling, corresponds to normal displays.
\item \texttt{2} --- 2x scaling, corresponds to HiDPI displays.
\item \texttt{-1} --- leaves the current variable unchanged.
\item \texttt{0} --- automatically chooses scaling based on the current resolution.
\end{itemize}
\item
\texttt{UgaPassThrough}\\
\textbf{Type}: \texttt{plist\ boolean}\\
......
\documentclass[]{article}
%DIF LATEXDIFF DIFFERENCE FILE
%DIF DEL PreviousConfiguration.tex Tue Nov 2 10:35:43 2021
%DIF ADD ../Configuration.tex Tue Nov 2 10:37:48 2021
%DIF DEL PreviousConfiguration.tex Wed Nov 3 14:16:04 2021
%DIF ADD ../Configuration.tex Thu Nov 4 18:02:19 2021
\usepackage{lmodern}
\usepackage{amssymb,amsmath}
......@@ -7425,6 +7425,24 @@ with the boot menu.
\emph{Note}: This option only applies to the \texttt{System} renderer.
On all known affected systems, \texttt{ConsoleMode} must be set to
an empty string for this option to work.
\DIFaddbegin
\item
\texttt{\DIFadd{UIScale}}\\
\textbf{\DIFadd{Type}}\DIFadd{: }\texttt{\DIFadd{plist\ integer}}\DIFadd{, 8 bit}\\
\textbf{\DIFadd{Failsafe}}\DIFadd{: }\texttt{\DIFadd{-1}}\\
\textbf{\DIFadd{Description}}\DIFadd{: User interface scaling factor.
}
\DIFadd{Corresponds to }\texttt{\DIFadd{4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14:UIScale}} \DIFadd{variable.
}\begin{itemize}
\tightlist
\item \texttt{\DIFadd{1}} \DIFadd{--- 1x scaling, corresponds to normal displays.
}\item \texttt{\DIFadd{2}} \DIFadd{--- 2x scaling, corresponds to HiDPI displays.
}\item \texttt{\DIFadd{-1}} \DIFadd{--- leaves the current variable unchanged.
}\item \texttt{\DIFadd{0}} \DIFadd{--- automatically chooses scaling based on the current resolution.
}\end{itemize}
\DIFaddend
\item
\texttt{UgaPassThrough}\\
......
......@@ -1132,8 +1132,6 @@
<dict>
<key>DefaultBackgroundColor</key>
<data>AAAAAA==</data>
<key>UIScale</key>
<data>AQ==</data>
</dict>
<key>4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102</key>
<dict>
......@@ -1160,7 +1158,6 @@
<dict>
<key>4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14</key>
<array>
<string>UIScale</string>
<string>DefaultBackgroundColor</string>
</array>
<key>4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102</key>
......@@ -1513,6 +1510,8 @@
<false/>
<key>TextRenderer</key>
<string>BuiltinGraphics</string>
<key>UIScale</key>
<integer>0</integer>
<key>UgaPassThrough</key>
<false/>
</dict>
......
......@@ -1132,8 +1132,6 @@
<dict>
<key>DefaultBackgroundColor</key>
<data>AAAAAA==</data>
<key>UIScale</key>
<data>AQ==</data>
</dict>
<key>4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102</key>
<dict>
......@@ -1158,7 +1156,6 @@
<dict>
<key>4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14</key>
<array>
<string>UIScale</string>
<string>DefaultBackgroundColor</string>
</array>
<key>4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102</key>
......@@ -1851,6 +1848,8 @@
<false/>
<key>TextRenderer</key>
<string>BuiltinGraphics</string>
<key>UIScale</key>
<integer>0</integer>
<key>UgaPassThrough</key>
<false/>
</dict>
......
......@@ -651,6 +651,7 @@ typedef enum {
_(BOOLEAN , ReplaceTabWithSpace , , FALSE , ()) \
_(BOOLEAN , ReconnectOnResChange , , FALSE , ()) \
_(BOOLEAN , SanitiseClearScreen , , FALSE , ()) \
_(INT8 , UIScale , , -1 , ()) \
_(BOOLEAN , UgaPassThrough , , FALSE , ()) \
_(BOOLEAN , DirectGopRendering , , FALSE , ()) \
_(BOOLEAN , ForceResolution , , FALSE , ())
......
......@@ -40,6 +40,7 @@ OcVariableInit (
EFI_VARIABLE_AUTHENTICATION_2 descriptor below. In this case the DataSize will not
be zero since the EFI_VARIABLE_AUTHENTICATION_2 descriptor will be populated).
@param[in] Data The contents for the variable.
@param[in] VendorGuid Variable GUID, defaults to gOcVendorVariableGuid if NULL.
@retval EFI_SUCCESS The firmware has successfully stored the variable and its data as
defined by the Attributes.
......@@ -57,10 +58,11 @@ OcVariableInit (
**/
EFI_STATUS
OcSetSystemVariable (
IN CHAR16 *VariableName,
IN UINT32 Attributes,
IN UINTN DataSize,
IN VOID *Data
IN CHAR16 *VariableName,
IN UINT32 Attributes,
IN UINTN DataSize,
IN VOID *Data,
IN EFI_GUID *VendorGuid OPTIONAL
);
#endif // OC_VARIABLE_LIB_H
......@@ -786,6 +786,7 @@ mUefiOutputSchema[] = {
OC_SCHEMA_STRING_IN ("Resolution", OC_GLOBAL_CONFIG, Uefi.Output.Resolution),
OC_SCHEMA_BOOLEAN_IN ("SanitiseClearScreen", OC_GLOBAL_CONFIG, Uefi.Output.SanitiseClearScreen),
OC_SCHEMA_STRING_IN ("TextRenderer", OC_GLOBAL_CONFIG, Uefi.Output.TextRenderer),
OC_SCHEMA_INTEGER_IN ("UIScale", OC_GLOBAL_CONFIG, Uefi.Output.UIScale),
OC_SCHEMA_BOOLEAN_IN ("UgaPassThrough", OC_GLOBAL_CONFIG, Uefi.Output.UgaPassThrough),
};
......
......@@ -69,7 +69,8 @@ OcStoreLoadPath (
OC_LOG_VARIABLE_PATH,
OPEN_CORE_NVRAM_ATTR,
AsciiStrSize (OutPath),
OutPath
OutPath,
NULL
);
DEBUG ((
......@@ -659,7 +660,8 @@ OcMiscMiddleInit (
OC_BOOT_PROTECT_VARIABLE_NAME,
OPEN_CORE_INT_NVRAM_ATTR,
sizeof (BootProtectFlag),
&BootProtectFlag
&BootProtectFlag,
NULL
);
}
......@@ -981,6 +983,7 @@ OcMiscUefiQuirksLoaded (
OC_SCAN_POLICY_VARIABLE_NAME,
OPEN_CORE_INT_NVRAM_ATTR,
sizeof (Config->Misc.Security.ScanPolicy),
&Config->Misc.Security.ScanPolicy
&Config->Misc.Security.ScanPolicy,
NULL
);
}
......@@ -91,14 +91,16 @@ OcReportVersion (
OC_VERSION_VARIABLE_NAME,
OPEN_CORE_NVRAM_ATTR,
AsciiStrLen (Version),
(VOID *) Version
(VOID *) Version,
NULL
);
} else {
OcSetSystemVariable (
OC_VERSION_VARIABLE_NAME,
OPEN_CORE_NVRAM_ATTR,
L_STR_LEN ("UNK-000-0000-00-00"),
"UNK-000-0000-00-00"
"UNK-000-0000-00-00",
NULL
);
}
}
......
......@@ -858,7 +858,8 @@ OcLoadUefiSupport (
OC_BOOT_REDIRECT_VARIABLE_NAME,
OPEN_CORE_INT_NVRAM_ATTR,
sizeof (Config->Uefi.Quirks.RequestBootVarRouting),
&Config->Uefi.Quirks.RequestBootVarRouting
&Config->Uefi.Quirks.RequestBootVarRouting,
NULL
);
if (Config->Uefi.Quirks.UnblockFsConnect) {
......
......@@ -16,6 +16,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Guid/OcVariable.h>
#include <Guid/GlobalVariable.h>
#include <Guid/AppleVariable.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
......@@ -40,6 +41,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/OcMiscLib.h>
#include <Library/OcSmcLib.h>
#include <Library/OcOSInfoLib.h>
#include <Library/OcVariableLib.h>
#include <Library/PrintLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiLib.h>
......@@ -182,14 +184,16 @@ OcLoadUefiOutputSupport (
IN OC_GLOBAL_CONFIG *Config
)
{
EFI_STATUS Status;
CONST CHAR8 *AsciiRenderer;
CONST CHAR8 *GopPassThrough;
OC_CONSOLE_RENDERER Renderer;
UINT32 Width;
UINT32 Height;
UINT32 Bpp;
BOOLEAN SetMax;
EFI_STATUS Status;
CONST CHAR8 *AsciiRenderer;
CONST CHAR8 *GopPassThrough;
EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop;
OC_CONSOLE_RENDERER Renderer;
UINT32 Width;
UINT32 Height;
UINT32 Bpp;
BOOLEAN SetMax;
UINT8 UIScale;
GopPassThrough = OC_BLOB_GET (&Config->Uefi.Output.GopPassThrough);
if (AsciiStrCmp (GopPassThrough, "Enabled") == 0) {
......@@ -273,6 +277,40 @@ OcLoadUefiOutputSupport (
}
}
if (Config->Uefi.Output.UIScale >= 0 && Config->Uefi.Output.UIScale <= 2) {
if (Config->Uefi.Output.UIScale == 0) {
Status = gBS->HandleProtocol (
gST->ConsoleOutHandle,
&gEfiGraphicsOutputProtocolGuid,
(VOID **) &Gop
);
if (!EFI_ERROR (Status)) {
UIScale = (UINT64) Gop->Mode->Info->HorizontalResolution
* Gop->Mode->Info->VerticalResolution >= 4000000 ? 2 : 1;
DEBUG ((
DEBUG_INFO,
"OC: Selected UIScale %d based on %ux%u resolution\n",
UIScale,
Gop->Mode->Info->HorizontalResolution,
Gop->Mode->Info->VerticalResolution
));
} else {
UIScale = 1;
}
} else {
UIScale = (UINT8) Config->Uefi.Output.UIScale;
}
Status = OcSetSystemVariable (
APPLE_UI_SCALE_VARIABLE_NAME,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
sizeof (UIScale),
&UIScale,
&gAppleVendorVariableGuid
);
DEBUG ((DEBUG_INFO, "OC: Setting UIScale to %d - %r\n", UIScale, Status));
}
AsciiRenderer = OC_BLOB_GET (&Config->Uefi.Output.TextRenderer);
if (AsciiRenderer[0] == '\0' || AsciiStrCmp (AsciiRenderer, "BuiltinGraphics") == 0) {
......
......@@ -2348,7 +2348,8 @@ OcSmbiosExtractOemInfo (
OC_OEM_PRODUCT_VARIABLE_NAME,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
AsciiStrLen (SmProductName),
(VOID *) SmProductName
(VOID *) SmProductName,
NULL
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO, "OCSMB: Cannot write OEM product\n"));
......@@ -2360,7 +2361,8 @@ OcSmbiosExtractOemInfo (
OC_OEM_VENDOR_VARIABLE_NAME,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
AsciiStrLen (SmManufacturer),
(VOID *) SmManufacturer
(VOID *) SmManufacturer,
NULL
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO, "OCSMB: Cannot write OEM board manufacturer - %r\n", Status));
......@@ -2370,7 +2372,8 @@ OcSmbiosExtractOemInfo (
OC_OEM_BOARD_VARIABLE_NAME,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
AsciiStrLen (SmBoard),
(VOID *) SmBoard
(VOID *) SmBoard,
NULL
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO, "OCSMB: Cannot write OEM board - %r\n", Status));
......
......@@ -575,7 +575,8 @@ ExportStatusKey (
VIRTUALSMC_STATUS_KEY,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
sizeof (StatusBuffer),
StatusBuffer
StatusBuffer,
NULL
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO, "OCSMC: Failed to create status - %r\n", Status));
......
......@@ -33,10 +33,11 @@ OcVariableInit (
EFI_STATUS
OcSetSystemVariable (
IN CHAR16 *VariableName,
IN UINT32 Attributes,
IN UINTN DataSize,
IN VOID *Data
IN CHAR16 *VariableName,
IN UINT32 Attributes,
IN UINTN DataSize,
IN VOID *Data,
IN EFI_GUID *VendorGuid OPTIONAL
)
{
EFI_STATUS Status;
......@@ -47,6 +48,10 @@ OcSetSystemVariable (
UINT8 StackBuffer[256];
if (VendorGuid == NULL) {
VendorGuid = &gOcVendorVariableGuid;
}
DEBUG_CODE_BEGIN ();
ASSERT (mDebugInitialized);
DEBUG_CODE_END ();
......@@ -68,7 +73,7 @@ OcSetSystemVariable (
Status = gRT->GetVariable (
VariableName,
&gOcVendorVariableGuid,
VendorGuid,
NULL,
&OldDataSize,
OldData
......@@ -81,7 +86,7 @@ OcSetSystemVariable (
if (OldData != NULL) {
Status = gRT->GetVariable (
VariableName,
&gOcVendorVariableGuid,
VendorGuid,
NULL,
&OldDataSize,
OldData
......@@ -123,7 +128,7 @@ OcSetSystemVariable (
return gRT->SetVariable (
VariableName,
&gOcVendorVariableGuid,
VendorGuid,
Attributes,
DataSize,
Data
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册