Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set backlight to hard coded intensity on wakeup (and set repeatedly) for macOS High Sierra #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion AMDGPUWakeHandler/AMDGPUWakeHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,40 @@ void AMDGPUWakeHandler::stop(IOService *provider)
void AMDGPUWakeHandler::disableGPU()
{
IOLog("Disabling GPU\n");
// GMUX_PORT_SWITCH_DDC - 1=IGD, 2=DIS
outb(0x728, 0x1);
// GMUX_PORT_SWITCH_DISPLAY - 2=IGD, 3=DIS
outb(0x710, 0x2);
// GMUX_PORT_SWITCH_EXTERNAL - 2=IGD, 3=DIS
outb(0x740, 0x2);
// GMUX_PORT_DISCRETE_POWER - 0-3?
outb(0x750, 0x0);
}

void AMDGPUWakeHandler::setBacklight(uint32_t Intensity)
{
IOLog("Setting backlight to %u\n", Intensity);
// Write to GMUX_PORT_BRIGHTNESS -> GMUX_PORT_BRIGHTNESS+3
outb(0x774, Intensity & 0xff);
outb(0x775, (Intensity >> 8) & 0xff);
outb(0x776, (Intensity >> 16) & 0xff);
outb(0x777, (Intensity >> 24) & 0xff);
}

// Wakeup backlight intensity
#define BacklightIntensity 120000

IOReturn AMDGPUWakeHandler::setPowerState ( unsigned long whichState, IOService * whatDevice )
{
if ( kIOPMPowerOff != whichState ) {
IOLog("Waking up\n");
this->disableGPU();
// Disable GPU and set backlight several times after wakeup to make sure it sticks
// (and we aren't overruled by another driver?)
for(int i = 0; i < 20; i++){
this->disableGPU();
this->setBacklight(BacklightIntensity);
IOSleep(500);
}
}
return kIOPMAckImplied;
}
1 change: 1 addition & 0 deletions AMDGPUWakeHandler/AMDGPUWakeHandler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ class AMDGPUWakeHandler : public IOService
virtual IOReturn setPowerState(unsigned long whichState, IOService * whatDevice);
private:
virtual void disableGPU();
virtual void setBacklight(uint32_t Intensity);
};