Skip to content

Commit

Permalink
Avoid breaking backlight on latops with AMD GPUs
Browse files Browse the repository at this point in the history
  • Loading branch information
vit9696 committed Dec 24, 2018
1 parent e6cb093 commit 3534466
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
WhateverGreen Changelog
=======================
#### v1.2.6
- Added `-applbkloff` boot argument to termporarily disable `AppleBacklight` patching code
- Added `applbkl=0` boot argument to termporarily disable `AppleBacklight` patching code
- Fixed AMD Verde CAIL injection logic
- Fixed breaking backlight on Apple hardware and on 10.11 or earlier
- Fixed breaking backlight on Apple hardware, on laptops with AMD GPUs, and on 10.11 or earlier
- Changed CFL backlight patches to enable by default on CFL drivers only (avoids issues with faux "KBL" 8xxx CPUs)

#### v1.2.5
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Read [FAQs](https://github.com/acidanthera/WhateverGreen/blob/master/Manual/) an
- `-igfxdump` to dump IGPU framebuffer kext to `/AppleIntelFramebuffer_X_Y` (available in DEBUG binaries).
- `-igfxfbdump` to dump native and patched framebuffer table to ioreg at IOService:/IOResources/WhateverGreen
- `igfxcflbklt=1` boot argument (and `enable-cfl-backlight-fix` property) to enable CFL backlight patch
- `applbkl=0` boot argument to disable AppleBacklight.kext patches for IGPU

#### Credits
- [Apple](https://www.apple.com) for macOS
Expand Down
13 changes: 10 additions & 3 deletions WhateverGreen/kern_weg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ void WEG::init() {
lilu.onKextLoad(&kextAGDPolicy);

// Disable backlight patches if asked specifically.
if (!checkKernelArgument("-applbkloff"))
PE_parse_boot_argn("applbkl", &appleBacklightPatch, sizeof(appleBacklightPatch));
if (appleBacklightPatch != APPLBKL_OFF)
lilu.onKextLoad(&kextBacklight);

igfx.init();
Expand Down Expand Up @@ -164,7 +165,13 @@ void WEG::processKernel(KernelPatcher &patcher) {
resetFramebuffer = FB_COPY;
}

// Note, disabled Optimus will make videoExternal 0, so this case checks for active IGPU only.
size_t extNum = devInfo->videoExternal.size();
if (appleBacklightPatch == APPLBKL_DETECT && (devInfo->videoBuiltin == nullptr || extNum > 0)) {
// Either a builtin IGPU is not available, or some external GPU is available.
kextBacklight.switchOff();
}

for (size_t i = 0; i < extNum; i++) {
auto &v = devInfo->videoExternal[i];
processExternalProperties(v.video, devInfo, v.vendor);
Expand All @@ -179,8 +186,8 @@ void WEG::processKernel(KernelPatcher &patcher) {

if (devInfo->managementEngine)
processManagementEngineProperties(devInfo->managementEngine);
} else {
// Do not patch AppleBacklight on Apple HW!
} else if (appleBacklightPatch != APPLBKL_ON){
// Do not patch AppleBacklight on Apple HW, unless forced.
kextBacklight.switchOff();
}

Expand Down
16 changes: 16 additions & 0 deletions WhateverGreen/kern_weg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,22 @@ class WEG {
*/
uint32_t resetFramebuffer {FB_DETECT};

/**
* APPLBKL_OFF disables AppleBacklight patches.
* APPLBKL_ON enforces AppleBacklight patches.
* APPLBKL_DETECT enables AppleBacklight patches for IGPU-only non-Apple setups.
*/
enum BacklightPatchMode {
APPLBKL_OFF = 0,
APPLBKL_ON = 1,
APPLBKL_DETECT = 2
};

/**
* applbkkl boot-arg controlled AppleBacklight kext patch
*/
uint32_t appleBacklightPatch {APPLBKL_DETECT};

/**
* Console info structure, taken from osfmk/console/video_console.h
* Last updated from XNU 4570.1.46.
Expand Down

4 comments on commit 3534466

@luckbacknow
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hello, I can not speed up my radeon 7950 his on hackintosh, could they help me? always show me 7mb of vram

follows my machine settings:
CPU: intel g4560
Motherboard: Gigabyte H110 m.2
Mojave Software 10.14

@luckbacknow
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

@luckbacknow
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after a lot of head banging, made a change in the clover by injecting ATIcard with fake id 0x679a and changing FB from Futomaki to Hamachi which made the system go up. now I do not have vram acceleration only 3mb do you think it has solution?

@vandroiy2013
Copy link
Collaborator

@vandroiy2013 vandroiy2013 commented on 3534466 Jan 7, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This not a support forum.
You should visit https://www.insanelymac.com/forum/ or https://applelife.ru

Please sign in to comment.