Skip to content

Commit

Permalink
OcConsoleLib: Add AppleEg2Info protocol and make rotation configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
vit9696 committed May 8, 2021
1 parent b787e77 commit 479a5b1
Show file tree
Hide file tree
Showing 21 changed files with 411 additions and 81 deletions.
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ OpenCore Changelog
==================
#### v0.7.0
- Fixed NVRAM reset on firmware with write-protected `BootOptionSupport`
- Improved direct GOP renderer performance for certain cases
- Added support for display rotation in direct GOP renderer

#### v0.6.9
- Fixed out-of-sync cursor movement rectangle when loading e.g. CrScreenshotDxe
Expand Down
Binary file modified Docs/Configuration.pdf
Binary file not shown.
19 changes: 19 additions & 0 deletions Docs/Configuration.tex
Original file line number Diff line number Diff line change
Expand Up @@ -4431,6 +4431,11 @@ \subsection{Recommended Variables}\label{nvramvarsrec}
\break
One-byte data defining \texttt{boot.efi} user interface scaling. Should be \textbf{01} for normal
screens and \textbf{02} for HiDPI screens.
\item
\texttt{7C436110-AB2A-4BBB-A880-FE41995C9F82:ForceDisplayRotationInEFI}
\break
32-bit integer defining display rotation. Can be \textbf{0} for no rotation
or any of \texttt{90}, \texttt{180}, \texttt{270} for matching rotation in degrees.
\item
\texttt{4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14:DefaultBackgroundColor}
\break
Expand Down Expand Up @@ -6776,6 +6781,9 @@ \subsection{Output Properties}\label{uefioutputprops}
performance or fix rendering issues. However, this option is not recommended unless
there is an obvious benefit as it may result in issues such as slower scrolling.

This renderer fully supports \texttt{AppleEg2Info} protocol and will provide
screen rotation for all EFI applications.

\item
\texttt{GopPassThrough}\\
\textbf{Type}: \texttt{plist\ boolean}\\
Expand Down Expand Up @@ -6905,6 +6913,17 @@ \subsection{ProtocolOverrides Properties}\label{uefiprotoprops}
\textbf{Description}: Replaces the Apple Debug Log protocol with a builtin
version.

\item
\texttt{AppleEg2Info}\\
\textbf{Type}: \texttt{plist\ boolean}\\
\textbf{Failsafe}: \texttt{false}\\
\textbf{Description}: Replaces the Apple EFI Graphics 2 protocol with a builtin
version.

\emph{Note}: This protocol allows newer \texttt{EfiBoot} versions (at least 10.15)
to expose screen rotation to macOS. Refer to \texttt{ForceDisplayRotationInEFI}
variable description on how to set screen rotation angle.

\item
\texttt{AppleFramebufferInfo}\\
\textbf{Type}: \texttt{plist\ boolean}\\
Expand Down
Binary file modified Docs/Differences/Differences.pdf
Binary file not shown.
32 changes: 27 additions & 5 deletions Docs/Differences/Differences.tex
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
\documentclass[]{article}
%DIF LATEXDIFF DIFFERENCE FILE
%DIF DEL PreviousConfiguration.tex Fri May 7 10:26:40 2021
%DIF ADD ../Configuration.tex Sat May 8 13:13:39 2021
%DIF ADD ../Configuration.tex Sun May 9 00:12:30 2021

\usepackage{lmodern}
\usepackage{amssymb,amsmath}
Expand Down Expand Up @@ -3663,8 +3663,8 @@ \subsection{Debug Properties}\label{miscdebugprops}
\item \texttt{OCA} ---- OcAcpiLib
\item \texttt{OCBP} --- OcAppleBootPolicyLib
\item \texttt{OCB} --- OcBootManagementLib
\DIFaddbegin \item \texttt{\DIFadd{OCLBT}} \DIFadd{--- OcBlitLib
}\DIFaddend \item \texttt{OCCL} --- OcAppleChunkListLib
\item \DIFaddbegin \texttt{\DIFadd{OCLBT}} \DIFadd{--- OcBlitLib
}\item \DIFaddend \texttt{OCCL} --- OcAppleChunkListLib
\item \texttt{OCCPU} --- OcCpuLib
\item \texttt{OCC} --- OcConsoleLib
\item \texttt{OCDC} --- OcDriverConnectionLib
Expand Down Expand Up @@ -4492,7 +4492,12 @@ \subsection{Recommended Variables}\label{nvramvarsrec}
One-byte data defining \texttt{boot.efi} user interface scaling. Should be \textbf{01} for normal
screens and \textbf{02} for HiDPI screens.
\item
\texttt{4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14:DefaultBackgroundColor}
\DIFaddbegin \texttt{\DIFadd{7C436110-AB2A-4BBB-A880-FE41995C9F82:ForceDisplayRotationInEFI}}
\break
\DIFadd{32-bit integer defining display rotation. Can be }\textbf{\DIFadd{0}} \DIFadd{for no rotation
or any of }\texttt{\DIFadd{90}}\DIFadd{, }\texttt{\DIFadd{180}}\DIFadd{, }\texttt{\DIFadd{270}} \DIFadd{for matching rotation in degrees.
}\item
\DIFaddend \texttt{4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14:DefaultBackgroundColor}
\break
Four-byte \texttt{BGRA} data defining \texttt{boot.efi} user interface background colour.
Standard colours include \textbf{BF BF BF 00} (Light Gray) and \textbf{00 00 00 00}
Expand Down Expand Up @@ -6836,7 +6841,11 @@ \subsection{Output Properties}\label{uefioutputprops}
performance or fix rendering issues. However, this option is not recommended unless
there is an obvious benefit as it may result in issues such as slower scrolling.

\item
\DIFaddbegin \DIFadd{This renderer fully supports }\texttt{\DIFadd{AppleEg2Info}} \DIFadd{protocol and will provide
screen rotation for all EFI applications.
}

\DIFaddend \item
\texttt{GopPassThrough}\\
\textbf{Type}: \texttt{plist\ boolean}\\
\textbf{Failsafe}: \texttt{false}\\
Expand Down Expand Up @@ -6963,7 +6972,20 @@ \subsection{ProtocolOverrides Properties}\label{uefiprotoprops}
\textbf{Type}: \texttt{plist\ boolean}\\
\textbf{Failsafe}: \texttt{false}\\
\textbf{Description}: Replaces the Apple Debug Log protocol with a builtin
version\DIFaddbegin \DIFadd{.
}

\item
\texttt{\DIFadd{AppleEg2Info}}\\
\textbf{\DIFadd{Type}}\DIFadd{: }\texttt{\DIFadd{plist\ boolean}}\\
\textbf{\DIFadd{Failsafe}}\DIFadd{: }\texttt{\DIFadd{false}}\\
\textbf{\DIFadd{Description}}\DIFadd{: Replaces the Apple EFI Graphics 2 protocol with a builtin
version.
}

\emph{\DIFadd{Note}}\DIFadd{: This protocol allows newer }\texttt{\DIFadd{EfiBoot}} \DIFadd{versions (at least 10.15)
to expose screen rotation to macOS. Refer to }\texttt{\DIFadd{ForceDisplayRotationInEFI}}
\DIFadd{variable description on how to set screen rotation angle}\DIFaddend .

\item
\texttt{AppleFramebufferInfo}\\
Expand Down
Binary file modified Docs/Errata/Errata.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion Docs/Errata/Errata.tex
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@

\section{Introduction}\label{introduction}

This document provides information on select issues discovered in the relesed
This document provides information on select issues discovered in the released
versions of \href{https://github.com/acidanthera/OpenCorePkg}{OpenCore}
and provides workarounds whenever possible. This document is updated
after OpenCore is released and is thus not contained in the binary packages.
Expand Down
5 changes: 5 additions & 0 deletions Docs/Sample.plist
Original file line number Diff line number Diff line change
Expand Up @@ -1142,6 +1142,8 @@
<data>cnUtUlU6MjUy</data>
<key>run-efi-updater</key>
<string>No</string>
<key>ForceDisplayRotationInEFI</key>
<integer>0</integer>
</dict>
</dict>
<key>Delete</key>
Expand All @@ -1158,6 +1160,7 @@
<key>7C436110-AB2A-4BBB-A880-FE41995C9F82</key>
<array>
<string>boot-args</string>
<string>ForceDisplayRotationInEFI</string>
</array>
</dict>
<key>LegacyEnable</key>
Expand Down Expand Up @@ -1363,6 +1366,8 @@
<false/>
<key>AppleDebugLog</key>
<false/>
<key>AppleEg2Info</key>
<false/>
<key>AppleFramebufferInfo</key>
<false/>
<key>AppleImageConversion</key>
Expand Down
2 changes: 2 additions & 0 deletions Docs/SampleCustom.plist
Original file line number Diff line number Diff line change
Expand Up @@ -1704,6 +1704,8 @@
<false/>
<key>AppleDebugLog</key>
<false/>
<key>AppleEg2Info</key>
<false/>
<key>AppleFramebufferInfo</key>
<false/>
<key>AppleImageConversion</key>
Expand Down
1 change: 1 addition & 0 deletions Include/Acidanthera/Library/OcConfigurationLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,7 @@ typedef enum {
_(BOOLEAN , AppleAudio , , FALSE , ()) \
_(BOOLEAN , AppleBootPolicy , , FALSE , ()) \
_(BOOLEAN , AppleDebugLog , , FALSE , ()) \
_(BOOLEAN , AppleEg2Info , , FALSE , ()) \
_(BOOLEAN , AppleFramebufferInfo , , FALSE , ()) \
_(BOOLEAN , AppleImageConversion , , FALSE , ()) \
_(BOOLEAN , AppleImg4Verification , , FALSE , ()) \
Expand Down
18 changes: 16 additions & 2 deletions Include/Acidanthera/Library/OcConsoleLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include <Protocol/ConsoleControl.h>
#include <Protocol/AppleFramebufferInfo.h>
#include <Protocol/AppleEg2Info.h>

/**
Console renderer to use.
Expand Down Expand Up @@ -158,8 +159,7 @@ OcReconnectConsole (
**/
EFI_STATUS
OcUseDirectGop (
IN INT32 CacheType,
IN UINT32 Rotation
IN INT32 CacheType
);

/**
Expand Down Expand Up @@ -209,4 +209,18 @@ OcAppleFbInfoInstallProtocol (
IN BOOLEAN Reinstall
);

/**
Install and initialise Apple EG2 Info protocol
on top of GOP protocol. For newer EfiBoot this is the way
to obtain screen rotation angle.
@param[in] Reinstall Overwrite installed protocol.
@retval installed or located protocol or NULL.
**/
APPLE_EG2_INFO_PROTOCOL *
OcAppleEg2InfoInstallProtocol (
IN BOOLEAN Reinstall
);

#endif // OC_CONSOLE_LIB_H
7 changes: 7 additions & 0 deletions Include/Apple/Guid/AppleVariable.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,13 @@ typedef enum {
///
#define APPLE_PANIC_INFO_NO_VARIABLE_NAME L"AAPL,PanicInfo%04x"

///
/// Set display rotation angle.
/// UINT32: 0, 90, 180, 270.
/// gAppleBootVariableGuid
///
#define APPLE_FORCE_DISPLAY_ROTATION_VARIABLE_NAME L"ForceDisplayRotationInEFI"

///
/// BootCampt device path.
/// UEFI Device Path.
Expand Down
50 changes: 0 additions & 50 deletions Include/Apple/Protocol/AppleDisplayInfo.h

This file was deleted.

101 changes: 101 additions & 0 deletions Include/Apple/Protocol/AppleEg2Info.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/** @file
Copyright (C) 2020, vit9696. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License which accompanies this
distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/

#ifndef APPLE_EG2_INFO_H
#define APPLE_EG2_INFO_H

///
/// The GUID of the APPLE_EG2_INFO_PROTOCOL_GUID.
/// 63FAECF2-E7EE-4CB9-8A0C-11CE5E89E33C
///
#define APPLE_EG2_INFO_PROTOCOL_GUID \
{ 0x63FAECF2, 0xE7EE, 0x4CB9, \
{ 0x8A, 0x0C, 0x11, 0xCE, 0x5E, 0x89, 0xE3, 0x3C } }

#define APPLE_EG2_INFO_PROTOCOL_REVISION 0x10002

typedef struct APPLE_EG2_INFO_PROTOCOL_ APPLE_EG2_INFO_PROTOCOL;

enum {
AppleDisplayRotate0 = 0,
AppleDisplayRotate90 = 1,
AppleDisplayRotate180 = 2,
AppleDisplayRotate270 = 3,
AppleDisplayRotateMax = 4
};

/**
Returns EFI_UNSUPPORTED for Apple.
**/
typedef
EFI_STATUS
(EFIAPI *APPLE_EG2_INFO_UNKNOWN1) (
IN APPLE_EG2_INFO_PROTOCOL *This,
IN EFI_HANDLE GpuHandle
);

/**
Used for e.g. ATY,PlatformInfo.
**/
typedef
EFI_STATUS
(EFIAPI *APPLE_EG2_INFO_GET_PLATFORM_INFO) (
IN APPLE_EG2_INFO_PROTOCOL *This,
IN EFI_HANDLE GpuHandle,
OUT VOID *Data,
OUT UINTN *Size
);

/**
Seems to enable display over a specified connector.
Can return EFI_NOT_FOUND or EFI_UNSUPPORTED.
**/
typedef
EFI_STATUS
(EFIAPI *APPLE_EG2_INFO_STARTUP_DISPLAY) (
IN APPLE_EG2_INFO_PROTOCOL *This,
IN EFI_HANDLE GpuHandle,
OUT VOID *Unk1,
OUT VOID *Unk2,
OUT VOID *Unk3
);

/**
Used for e.g. EFI,hibwake.
**/
typedef
EFI_STATUS
(EFIAPI *APPLE_EG2_INFO_GET_HIBERNATION) (
IN APPLE_EG2_INFO_PROTOCOL *This,
OUT BOOLEAN *Hibernated
);

typedef
EFI_STATUS
(EFIAPI *APPLE_EG2_INFO_GET_ROTATION) (
IN APPLE_EG2_INFO_PROTOCOL *This,
OUT UINT32 *Rotation
);

struct APPLE_EG2_INFO_PROTOCOL_ {
UINT32 Revision;
VOID *Unused;
APPLE_EG2_INFO_UNKNOWN1 Unknown1;
APPLE_EG2_INFO_GET_PLATFORM_INFO GetPlatformInfo;
APPLE_EG2_INFO_STARTUP_DISPLAY StartupDisplay;
APPLE_EG2_INFO_GET_HIBERNATION GetHibernation;
APPLE_EG2_INFO_GET_ROTATION GetRotation;
};

extern EFI_GUID gAppleEg2InfoProtocolGuid;

#endif // APPLE_EG2_INFO_H
1 change: 1 addition & 0 deletions Library/OcConfigurationLib/OcConfigurationLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,7 @@ mUefiProtocolOverridesSchema[] = {
OC_SCHEMA_BOOLEAN_IN ("AppleAudio", OC_GLOBAL_CONFIG, Uefi.ProtocolOverrides.AppleAudio),
OC_SCHEMA_BOOLEAN_IN ("AppleBootPolicy", OC_GLOBAL_CONFIG, Uefi.ProtocolOverrides.AppleBootPolicy),
OC_SCHEMA_BOOLEAN_IN ("AppleDebugLog", OC_GLOBAL_CONFIG, Uefi.ProtocolOverrides.AppleDebugLog),
OC_SCHEMA_BOOLEAN_IN ("AppleEg2Info", OC_GLOBAL_CONFIG, Uefi.ProtocolOverrides.AppleEg2Info),
OC_SCHEMA_BOOLEAN_IN ("AppleFramebufferInfo", OC_GLOBAL_CONFIG, Uefi.ProtocolOverrides.AppleFramebufferInfo),
OC_SCHEMA_BOOLEAN_IN ("AppleImageConversion", OC_GLOBAL_CONFIG, Uefi.ProtocolOverrides.AppleImageConversion),
OC_SCHEMA_BOOLEAN_IN ("AppleImg4Verification", OC_GLOBAL_CONFIG, Uefi.ProtocolOverrides.AppleImg4Verification),
Expand Down
Loading

0 comments on commit 479a5b1

Please sign in to comment.