seems I cracked the riddle! Managed to do so by extracting
AppleGraphicsPolicy EFI driver from my firmware (
scap
file named after mac's model located at
<EFI volume>/EFI/APPLE/FIRMWARE
directory) and reverse-engineering it (I used Ghidra, but other tools like Hopper demo and IDA Home are also able to do it, although I found Ghidra's decompiled code the most comprehensible). Extracted the driver using wonderful
UEFITool.
The driver code revealed that there's one more NVRAM variable that's checked even before
gpu-power-prefs
: named
GfxMode
, and it's located under standard Apple's GUID (
7C436110-AB2A-4BBB-A880-FE41995C9F82
, its variables are displayed with
nvram -p
). To disable dGPU at boot time, this variable must be set either to
0 or
4 (can be plain character or 4-byte hex value):
- 0 value only makes iGPU drive the screen - 2/1/2 values are written to respective gmux ports
- 4 value in addition powers down dGPU - 0 value to 0x750 port
Other values that the driver checks are: 1-3, 5 (both hex and as character) and characters 'A' (3 value -
automatic?), 'D' (2 value -
discrete?), 'E' (1 value -
external?), 'I' (0 value -
integrated?). In the 3/A case code makes an additional check (don't understand what it does under the hood, I believe it decides which GPU to use). All the other values (i.e. except 0/I and 4) make dGPU drive the screen.
Example how to change the variable in macOS (you still need to do it either in Recovery mode or with SIP's NVRAM protection off / SIP completely off):
Bash:
nvram GfxMode=4
# or
nvram GfxMode=%04%00%00%00
Under 10.13 this still traditionally kills brightness controls as well as screen stays black after waking up from sleep, I'm yet to test how it behaves under 10.10 (have it on SD card for testing, should be fine I believe) and OCLP Big Sur. At least under Windows I can change brightness by using RW Everything program and adjusting the 4-byte value at gmux I/O port 0x774, I believe in macOS the same would work as well (or I could try AppleMuxControl driver from 10.12). Writing a program for that shouldn't be a big deal (for macOS
AMDGPUWakeHandler code can be adapted).
The effect of the NVRAM variable is basically identical to what you can achieve with mm commands in EFI shell/script before booting macOS (or Linux), but it's very important if you want to boot Windows in UEFI mode (as my machine doesn't officially support it, dunno about newer models): now Windows finally uses iGPU only, although installing iGPU driver still causes Windows to reboot immediately and then never boot again (spinning wheel never appears, boot is stuck at windows logo) until I delete the driver in safe mode.
P.S. I noticed that EFI Shell renders text way faster with iGPU than with dGPU, especially noticeable on "big" commands like
pci
.