未验证 提交 d815a83b 编写于 作者: M Michael Belyaev 提交者: GitHub

OpenCanopy: Basic audio assist support (#74)

Co-authored-by: NMichael Belyaev <usrsse2@me.com>
Co-authored-by: Nvit9696 <vit9696@users.noreply.github.com>
上级 2b98adfb
......@@ -5,6 +5,7 @@ OpenCore Changelog
- Updated underlying EDK II package to edk2-stable202011
- Updated builtin firmware versions for SMBIOS and the rest
- Fixed macrecovery server protocol compatibility
- Added basic audio assistant support in OpenCanopy
#### v0.6.4
- Added `BlacklistAppleUpdate` to fix macOS 11 broken update optout
......
......@@ -541,6 +541,50 @@ INTN
OUT BOOLEAN *SetDefault OPTIONAL
);
/**
Play audio file for context.
**/
typedef
EFI_STATUS
(EFIAPI *OC_PLAY_AUDIO_FILE) (
IN OC_PICKER_CONTEXT *Context,
IN UINT32 File,
IN BOOLEAN Fallback
);
/**
Generate cycles of beep signals for context with silence afterwards, blocking.
**/
typedef
EFI_STATUS
(EFIAPI *OC_PLAY_AUDIO_BEEP) (
IN OC_PICKER_CONTEXT *Context,
IN UINT32 ToneCount,
IN UINT32 ToneLength,
IN UINT32 SilenceLength
);
/**
Play audio entry for context.
**/
typedef
EFI_STATUS
(EFIAPI *OC_PLAY_AUDIO_ENTRY) (
IN OC_PICKER_CONTEXT *Context,
IN OC_BOOT_ENTRY *Entry
);
/**
Toggle VoiceOver support.
**/
typedef
VOID
(EFIAPI *OC_TOGGLE_VOICE_OVER) (
IN OC_PICKER_CONTEXT *Context,
IN UINT32 File OPTIONAL
);
/**
Picker behaviour action.
**/
......@@ -680,6 +724,22 @@ struct OC_PICKER_CONTEXT_ {
//
APPLE_BEEP_GEN_PROTOCOL *BeepGen;
//
// Play audio file function.
//
OC_PLAY_AUDIO_FILE PlayAudioFile;
//
// Play audio beep function.
//
OC_PLAY_AUDIO_BEEP PlayAudioBeep;
//
// Play audio entry function.
//
OC_PLAY_AUDIO_ENTRY PlayAudioEntry;
//
// Toggle VoiceOver function.
//
OC_TOGGLE_VOICE_OVER ToggleVoiceOver;
//
// Recovery initiator if present.
//
EFI_DEVICE_PATH_PROTOCOL *RecoveryInitiator;
......@@ -1234,6 +1294,7 @@ OcRunFirmwareApplication (
@retval EFI_SUCCESS on success or when unnecessary.
**/
EFI_STATUS
EFIAPI
OcPlayAudioFile (
IN OC_PICKER_CONTEXT *Context,
IN UINT32 File,
......@@ -1251,6 +1312,7 @@ OcPlayAudioFile (
@retval EFI_SUCCESS on success or when unnecessary.
**/
EFI_STATUS
EFIAPI
OcPlayAudioBeep (
IN OC_PICKER_CONTEXT *Context,
IN UINT32 ToneCount,
......@@ -1259,7 +1321,7 @@ OcPlayAudioBeep (
);
/**
Play audio file for context.
Play audio entry for context.
@param[in] Context Picker context.
@param[in] Entry Entry to play.
......@@ -1267,6 +1329,7 @@ OcPlayAudioBeep (
@retval EFI_SUCCESS on success or when unnecessary.
**/
EFI_STATUS
EFIAPI
OcPlayAudioEntry (
IN OC_PICKER_CONTEXT *Context,
IN OC_BOOT_ENTRY *Entry
......@@ -1279,6 +1342,7 @@ OcPlayAudioEntry (
@param[in] File File to play after enabling VoiceOver.
**/
VOID
EFIAPI
OcToggleVoiceOver (
IN OC_PICKER_CONTEXT *Context,
IN UINT32 File OPTIONAL
......
......@@ -49,6 +49,7 @@
#include <Library/UefiLib.h>
EFI_STATUS
EFIAPI
OcPlayAudioFile (
IN OC_PICKER_CONTEXT *Context,
IN UINT32 File,
......@@ -138,6 +139,7 @@ OcPlayAudioFile (
}
EFI_STATUS
EFIAPI
OcPlayAudioBeep (
IN OC_PICKER_CONTEXT *Context,
IN UINT32 ToneCount,
......@@ -170,6 +172,7 @@ OcPlayAudioBeep (
}
EFI_STATUS
EFIAPI
OcPlayAudioEntry (
IN OC_PICKER_CONTEXT *Context,
IN OC_BOOT_ENTRY *Entry
......@@ -207,6 +210,7 @@ OcPlayAudioEntry (
}
VOID
EFIAPI
OcToggleVoiceOver (
IN OC_PICKER_CONTEXT *Context,
IN UINT32 File OPTIONAL
......
......@@ -7,6 +7,8 @@
objects = {
/* Begin PBXBuildFile section */
35081D4A248177E4006EB0EB /* InputSimTextIn.c in Sources */ = {isa = PBXBuildFile; fileRef = 350857D82421373F005A0D86 /* InputSimTextIn.c */; };
35081D4B248177ED006EB0EB /* InputSimAbsPtr.c in Sources */ = {isa = PBXBuildFile; fileRef = 350857D92421373F005A0D86 /* InputSimAbsPtr.c */; };
350857EC24216525005A0D86 /* OcUnicodeLib.c in Sources */ = {isa = PBXBuildFile; fileRef = 35366A95240C213400D54CBB /* OcUnicodeLib.c */; };
350857ED24220712005A0D86 /* GuiApp.c in Sources */ = {isa = PBXBuildFile; fileRef = 350857D42421373F005A0D86 /* GuiApp.c */; };
350857EE2422071A005A0D86 /* OpenCanopy.h in Headers */ = {isa = PBXBuildFile; fileRef = 350857DA2421373F005A0D86 /* OpenCanopy.h */; };
......@@ -1955,6 +1957,7 @@
3511D59323FDB2A800CC3B17 /* OpenCoreMisc.c in Sources */,
35366C04240C213500D54CBB /* DataHub.c in Sources */,
3511D59523FDB2A800CC3B17 /* OpenCoreDevProps.c in Sources */,
35081D4A248177E4006EB0EB /* InputSimTextIn.c in Sources */,
35366CCC240C213500D54CBB /* OcXmlLib.c in Sources */,
35366CC1240C213500D54CBB /* FileProtocol.c in Sources */,
35366C95240C213500D54CBB /* OcAppleDiskImageLib.c in Sources */,
......@@ -2046,6 +2049,7 @@
35366C00240C213500D54CBB /* OcPng.c in Sources */,
35366C27240C213500D54CBB /* Sha1.c in Sources */,
35366C91240C213500D54CBB /* AIM.c in Sources */,
35081D4B248177ED006EB0EB /* InputSimAbsPtr.c in Sources */,
35366CE1240C213500D54CBB /* OcAppleRamDiskLib.c in Sources */,
35366CC7240C213500D54CBB /* AppleCpuSupport.c in Sources */,
35366CC3240C213500D54CBB /* LocateFileSystem.c in Sources */,
......
......@@ -333,8 +333,6 @@ InternalContextConstruct (
+ Context->BackgroundColor.Pixel.Blue * 114U) >= 186000;
}
Context->BootEntry = NULL;
Status = EFI_SUCCESS;
for (Index = 0; Index < ICON_NUM_TOTAL; ++Index) {
......
......@@ -80,9 +80,12 @@ typedef struct _BOOT_PICKER_GUI_CONTEXT {
BOOLEAN Refresh;
BOOLEAN LightBackground;
BOOLEAN DoneIntroAnimation;
BOOLEAN ReadyToBoot;
UINT8 Scale;
UINT32 CursorDefaultX;
UINT32 CursorDefaultY;
INT32 AudioPlaybackTimeout;
OC_PICKER_CONTEXT *PickerContext;
} BOOT_PICKER_GUI_CONTEXT;
EFI_STATUS
......@@ -95,7 +98,7 @@ BootPickerViewInitialize (
EFI_STATUS
BootPickerEntriesAdd (
IN OC_PICKER_CONTEXT *Context,
IN CONST BOOT_PICKER_GUI_CONTEXT *GuiContext,
IN BOOT_PICKER_GUI_CONTEXT *GuiContext,
IN OC_BOOT_ENTRY *Entry,
IN BOOLEAN Default
);
......
......@@ -50,8 +50,11 @@ OcShowMenuByOc (
*ChosenBootEntry = NULL;
mGuiContext.BootEntry = NULL;
mGuiContext.ReadyToBoot = FALSE;
mGuiContext.HideAuxiliary = BootContext->PickerContext->HideAuxiliary;
mGuiContext.Refresh = FALSE;
mGuiContext.PickerContext = BootContext->PickerContext;
mGuiContext.AudioPlaybackTimeout = -1;
Status = GuiLibConstruct (
BootContext->PickerContext,
......@@ -67,6 +70,13 @@ OcShowMenuByOc (
//
gST->ConOut->TestString (gST->ConOut, OC_CONSOLE_MARK_CONTROLLED);
//
// Do not play intro animation for blind.
//
if (BootContext->PickerContext->PickerAudioAssist) {
mGuiContext.DoneIntroAnimation = TRUE;
}
Status = BootPickerViewInitialize (
&mDrawContext,
&mGuiContext,
......@@ -90,6 +100,35 @@ OcShowMenuByOc (
}
}
GuiRedrawAndFlushScreen (&mDrawContext);
if (BootContext->PickerContext->PickerAudioAssist) {
BootContext->PickerContext->PlayAudioFile (
BootContext->PickerContext,
OcVoiceOverAudioFileChooseOS,
FALSE
);
for (Index = 0; Index < BootContext->BootEntryCount; ++Index) {
BootContext->PickerContext->PlayAudioEntry (
BootContext->PickerContext,
BootEntries[Index]
);
if (BootContext->PickerContext->TimeoutSeconds > 0 && BootContext->DefaultEntry->EntryIndex - 1 == Index) {
BootContext->PickerContext->PlayAudioFile (
BootContext->PickerContext,
OcVoiceOverAudioFileDefault,
FALSE
);
}
}
BootContext->PickerContext->PlayAudioBeep (
BootContext->PickerContext,
OC_VOICE_OVER_SIGNALS_NORMAL,
OC_VOICE_OVER_SIGNAL_NORMAL_MS,
OC_VOICE_OVER_SILENCE_NORMAL_MS
);
}
GuiDrawLoop (&mDrawContext, BootContext->PickerContext->TimeoutSeconds);
ASSERT (mGuiContext.BootEntry != NULL || mGuiContext.Refresh);
......
......@@ -36,12 +36,6 @@ typedef struct {
UINT32 MaxY;
} GUI_DRAW_REQUEST;
//
// Variables to assign the picked volume automatically once menu times out
//
extern BOOT_PICKER_GUI_CONTEXT mGuiContext;
extern GUI_VOLUME_PICKER mBootPicker;
//
// I/O contexts
//
......@@ -1143,13 +1137,14 @@ GuiDrawLoop (
CONST LIST_ENTRY *AnimEntry;
CONST GUI_ANIMATION *Animation;
UINT64 LoopStartTsc;
UINT64 LastTsc;
UINT64 NewLastTsc;
ASSERT (DrawContext != NULL);
mNumValidDrawReqs = 0;
HoldObject = NULL;
GuiRedrawAndFlushScreen (DrawContext);
//
// Clear previous inputs.
//
......@@ -1160,7 +1155,7 @@ GuiDrawLoop (
//
// Main drawing loop, time and derieve sub-frequencies as required.
//
LoopStartTsc = mStartTsc = AsmReadTsc ();
LastTsc = LoopStartTsc = mStartTsc = AsmReadTsc ();
do {
if (mPointerContext != NULL) {
//
......@@ -1252,17 +1247,37 @@ GuiDrawLoop (
//
GuiFlushScreen (DrawContext);
NewLastTsc = AsmReadTsc ();
if (DrawContext->GuiContext->AudioPlaybackTimeout >= 0
&& DrawContext->GuiContext->PickerContext->PickerAudioAssist) {
DrawContext->GuiContext->AudioPlaybackTimeout -= (INT32) (DivU64x32 (
GetTimeInNanoSecond (NewLastTsc - LastTsc),
1000000
));
if (DrawContext->GuiContext->AudioPlaybackTimeout <= 0) {
DrawContext->GuiContext->PickerContext->PlayAudioFile (
DrawContext->GuiContext->PickerContext,
OcVoiceOverAudioFileSelected,
FALSE
);
DrawContext->GuiContext->PickerContext->PlayAudioEntry (
DrawContext->GuiContext->PickerContext,
DrawContext->GuiContext->BootEntry
);
}
}
//
// Exit early if reach timer timeout and timer isn't disabled due to key event
//
if (TimeOutSeconds > 0
&& GetTimeInNanoSecond (AsmReadTsc () - LoopStartTsc) >= TimeOutSeconds * 1000000000ULL) {
//
// FIXME: There should be view function or alike.
//
mGuiContext.BootEntry = mBootPicker.SelectedEntry->Context;
&& GetTimeInNanoSecond (NewLastTsc - LoopStartTsc) >= TimeOutSeconds * 1000000000ULL) {
DrawContext->GuiContext->ReadyToBoot = TRUE;
break;
}
LastTsc = NewLastTsc;
} while (!DrawContext->ExitLoop (DrawContext->GuiContext));
}
......
......@@ -131,7 +131,7 @@ struct GUI_DRAWING_CONTEXT_ {
GUI_CURSOR_GET_IMAGE GetCursorImage;
GUI_EXIT_LOOP ExitLoop;
LIST_ENTRY Animations;
VOID *GuiContext;
BOOT_PICKER_GUI_CONTEXT *GuiContext;
UINT8 Scale;
};
......@@ -250,6 +250,11 @@ GuiViewCurrentCursor (
IN OUT GUI_DRAWING_CONTEXT *DrawContext
);
VOID
GuiRedrawAndFlushScreen (
IN OUT GUI_DRAWING_CONTEXT *DrawContext
);
VOID
GuiDrawLoop (
IN OUT GUI_DRAWING_CONTEXT *DrawContext,
......
......@@ -210,6 +210,7 @@ InternalBootPickerChangeEntry (
//
PrevEntry = This->SelectedEntry;
InternalBootPickerSelectEntry (This, NewEntry);
//
// To redraw the entry *and* the selector, draw the entire height of the
// Picker object. For this, the height just reach from the top of the entries
......@@ -232,6 +233,12 @@ InternalBootPickerChangeEntry (
This->Hdr.Obj.Height,
TRUE
);
//
// Set voice timeout to N frames from now.
//
DrawContext->GuiContext->AudioPlaybackTimeout = OC_VOICE_OVER_IDLE_TIMEOUT_MS;
DrawContext->GuiContext->BootEntry = This->SelectedEntry->Context;
}
VOID
......@@ -288,7 +295,8 @@ InternalBootPickerKeyEvent (
} else if (Key == OC_INPUT_CONTINUE) {
ASSERT (Picker->SelectedEntry != NULL);
Picker->SelectedEntry->Context->SetDefault = Modifier;
GuiContext->BootEntry = Picker->SelectedEntry->Context;
GuiContext->ReadyToBoot = TRUE;
ASSERT (GuiContext->BootEntry == Picker->SelectedEntry->Context);
} else if (mBootPickerOpacity != 0xFF) {
//
// FIXME: Other keys are not allowed when boot picker is partially transparent.
......@@ -299,8 +307,23 @@ InternalBootPickerKeyEvent (
if (Key == OC_INPUT_MORE) {
GuiContext->HideAuxiliary = FALSE;
GuiContext->Refresh = TRUE;
DrawContext->GuiContext->PickerContext->PlayAudioFile (
DrawContext->GuiContext->PickerContext,
OcVoiceOverAudioFileShowAuxiliary,
FALSE
);
} else if (Key == OC_INPUT_ABORTED) {
GuiContext->Refresh = TRUE;
DrawContext->GuiContext->PickerContext->PlayAudioFile (
DrawContext->GuiContext->PickerContext,
OcVoiceOverAudioFileReloading,
FALSE
);
} else if (Key == OC_INPUT_VOICE_OVER) {
DrawContext->GuiContext->PickerContext->ToggleVoiceOver (
DrawContext->GuiContext->PickerContext,
0
);
}
}
......@@ -715,7 +738,7 @@ CopyLabel (
EFI_STATUS
BootPickerEntriesAdd (
IN OC_PICKER_CONTEXT *Context,
IN CONST BOOT_PICKER_GUI_CONTEXT *GuiContext,
IN BOOT_PICKER_GUI_CONTEXT *GuiContext,
IN OC_BOOT_ENTRY *Entry,
IN BOOLEAN Default
)
......@@ -935,6 +958,7 @@ BootPickerEntriesAdd (
if (Default) {
InternalBootPickerSelectEntry (&mBootPicker, VolumeEntry);
GuiContext->BootEntry = Entry;
}
return EFI_SUCCESS;
......@@ -963,7 +987,7 @@ InternalBootPickerExitLoop (
{
ASSERT (Context != NULL);
return Context->BootEntry != NULL || Context->Refresh;
return Context->ReadyToBoot || Context->Refresh;
}
STATIC GUI_INTERPOLATION mBpAnimInfoOpacity;
......
......@@ -870,6 +870,10 @@ OcMiscBoot (
Context->GetEntryLabelImage = OcGetBootEntryLabelImage;
Context->GetEntryIcon = OcGetBootEntryIcon;
Context->GetKeyIndex = OcGetAppleKeyIndex;
Context->PlayAudioFile = OcPlayAudioFile;
Context->PlayAudioBeep = OcPlayAudioBeep;
Context->PlayAudioEntry = OcPlayAudioEntry;
Context->ToggleVoiceOver = OcToggleVoiceOver;
Context->PickerMode = PickerMode;
Context->ConsoleAttributes = Config->Misc.Boot.ConsoleAttributes;
Context->PickerAttributes = Config->Misc.Boot.PickerAttributes;
......
......@@ -22,6 +22,7 @@ extern EFI_GUID gAppleBlessedSystemFolderInfoGuid;
extern EFI_GUID gAppleBootPolicyProtocolGuid;
extern EFI_GUID gAppleVendorVariableGuid;
extern EFI_GUID gAppleImg4VerificationProtocolGuid;
extern EFI_GUID gAppleBeepGenProtocolGuid;
extern const CHAR8 *gEfiCallerBaseName;
extern EFI_GUID gEfiGraphicsOutputProtocolGuid;
......@@ -60,5 +61,6 @@ extern EFI_GUID gEfiSmbiosTableGuid;
extern EFI_GUID gOcVendorVariableGuid;
extern EFI_GUID gOcCustomSmbios3TableGuid;
extern EFI_GUID gOcCustomSmbiosTableGuid;
extern EFI_GUID gOcAudioProtocolGuid;
#endif // OC_USER_GLOBAL_VAR_H
......@@ -17,6 +17,7 @@ EFI_GUID gAppleBlessedSystemFolderInfoGuid = { 0x7BD1F02D, 0x9C2F, 0x4581, { 0xB
EFI_GUID gAppleBootPolicyProtocolGuid = { 0x62257758, 0x350C, 0x4D0A, { 0xB0, 0xBD, 0xF6, 0xBE, 0x2E, 0x1E, 0x27, 0x2C }};
EFI_GUID gAppleVendorVariableGuid = { 0x4D1EDE05, 0x38C7, 0x4A6A, { 0x9C, 0xC6, 0x4B, 0xCC, 0xA8, 0xB3, 0x8C, 0x14 }};
EFI_GUID gAppleImg4VerificationProtocolGuid = { 0x314735F0, 0x26FE, 0x11E8, { 0xA4, 0x70, 0xB8, 0xE8, 0x56, 0x2C, 0xBA, 0xFA }};
EFI_GUID gAppleBeepGenProtocolGuid = { 0xC32332DF, 0xFC56, 0x4FE1, { 0x93, 0x58, 0xBA, 0x0D, 0x52, 0x9B, 0x24, 0xCD }};
const CHAR8 *gEfiCallerBaseName = "OpenCore";
EFI_GUID gEfiGraphicsOutputProtocolGuid = { 0x9042A9DE, 0x23DC, 0x4A38, { 0x96, 0xFB, 0x7A, 0xDE, 0xD0, 0x80, 0x51, 0x6A }};
......@@ -55,3 +56,5 @@ EFI_GUID gEfiSmbiosTableGuid = { 0xEB9D2D31, 0x2D88, 0x11D3, { 0x9A, 0x16, 0x00,
EFI_GUID gOcVendorVariableGuid = { 0x4D1FDA02, 0x38C7, 0x4A6A, { 0x9C, 0xC6, 0x4B, 0xCC, 0xA8, 0xB3, 0x01, 0x02 }};
EFI_GUID gOcCustomSmbios3TableGuid = { 0xF2FD1545, 0x9794, 0x4A2C, { 0x99, 0x2E, 0xE5, 0xBB, 0xCF, 0x20, 0xE3, 0x94 }};
EFI_GUID gOcCustomSmbiosTableGuid = { 0xEB9D2D35, 0x2D88, 0x11D3, { 0x9A, 0x16, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }};
EFI_GUID gOcAudioProtocolGuid = { 0x4B228577, 0x6274, 0x4A48, { 0x82, 0xAE, 0x07, 0x13, 0xA1, 0x17, 0x19, 0x87 }};
......@@ -13,7 +13,7 @@ OBJS += BitmapFont.o OpenCanopy.o InputSimTextIn.o InputSimAbsPtr.o OutputStGo
#
# From OpenCore.
#
OBJS += OcPng.o lodepng.o OcCompressionLib.o OcTimerLib.o OcAppleKeyMapLib.o HotKeySupport.o BootArguments.o BootEntryInfo.o OcAppleBootPolicyLib.o OcDevicePathLib.o DebugPrint.o GetFileInfo.o GetVolumeLabel.o ReadFile.o OpenFile.o FileProtocol.o OcStorageLib.o
OBJS += OcPng.o lodepng.o OcCompressionLib.o OcTimerLib.o OcAppleKeyMapLib.o HotKeySupport.o BootArguments.o BootEntryInfo.o OcAppleBootPolicyLib.o OcDevicePathLib.o DebugPrint.o GetFileInfo.o GetVolumeLabel.o ReadFile.o OpenFile.o FileProtocol.o OcStorageLib.o BootAudio.o
VPATH = ../../Platform/OpenCanopy:$\
../../Platform/OpenCanopy/Input:$\
......
#!/bin/bash
CONFIGURATION=DEBUG
source edksetup.sh
build -a X64 -p OpenCorePkg/OpenCorePkg.dsc -t XCODE5 -b RELEASE
build -a X64 -p OpenCorePkg/OpenCorePkg.dsc -t XCODE5 -b $CONFIGURATION
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册