Skip to content

Commit

Permalink
fix(X6000FB): Don't set brightness scratch register
Browse files Browse the repository at this point in the history
[Why]
The driver is already doing this, we're interfering with the driver.
  • Loading branch information
VisualEhrmanntraut committed Aug 19, 2024
1 parent de6b80b commit e6aeeb6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
17 changes: 3 additions & 14 deletions NootedRed/X6000FB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,6 @@ bool X6000FB::processKext(KernelPatcher &patcher, size_t id, mach_vm_address_t s
MachInfo::setKernelWriting(false, KernelPatcher::kernelWriteLock);
DBGLOG("X6000FB", "Applied DDI Caps patches");

this->biosScratchReg = NRed::callback->getVBIOSDataTable<AtomFirmwareInfo>(0x4)->biosScratchRegStartAddr;
DBGLOG("X6000FB", "BIOS Scratch Reg = 0x%X", this->biosScratchReg);

return true;
}

Expand Down Expand Up @@ -341,24 +338,16 @@ IOReturn X6000FB::wrapSetAttributeForConnection(IOService *framebuffer, IOIndex
// dc_link_set_backlight_level_nits doesn't print the new backlight level, so we'll do it
DBGLOG("X6000FB", "setAttributeForConnection: New AUX brightness: %d millinits (%d nits)", auxValue,
(auxValue / 1000));
// Save the brightness value so the driver can restore it on its own on some specific occasions.
// For instance, when waking from sleep.
NRed::callback->writeReg32(callback->biosScratchReg + 2, auxValue);
success = callback->orgDcLinkSetBacklightLevelNits(callback->embeddedPanelLink, true, auxValue, 15000);
} else {
UInt32 pwmValue = percentage >= 100 ? 0x1FF00 : ((percentage * 0xFF) / 100) << 8U;
DBGLOG("X6000FB", "setAttributeForConnection: New PWM brightness: 0x%X", pwmValue);
// Ditto.
NRed::callback->writeReg32(callback->biosScratchReg + 2, pwmValue);
success = callback->orgDcLinkSetBacklightLevel(callback->embeddedPanelLink, pwmValue, 0);
}

if (success) {
return kIOReturnSuccess;
} else {
DBGLOG("X6000FB", "Failed to set backlight level");
return kIOReturnDeviceError;
}
if (success) { return kIOReturnSuccess; }

return kIOReturnDeviceError;
}

IOReturn X6000FB::wrapGetAttributeForConnection(IOService *framebuffer, IOIndex connectIndex, IOSelect attribute,
Expand Down
1 change: 0 additions & 1 deletion NootedRed/X6000FB.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class X6000FB {

private:
mach_vm_address_t orgSetAttributeForConnection {0}, orgGetAttributeForConnection {0};
UInt32 biosScratchReg {0};
UInt32 curPwmBacklightLvl {0}, maxPwmBacklightLvl {0xFFFF};
UInt32 maxOLED {1000 * 512};
void *embeddedPanelLink {nullptr};
Expand Down

0 comments on commit e6aeeb6

Please sign in to comment.