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

[Suggestions] [Experimental] Ice Lake backlight fix. #97

Merged
merged 6 commits into from Jan 15, 2022
Merged
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
8 changes: 8 additions & 0 deletions WhateverGreen/kern_igfx_backlight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,14 @@ void IGFX::BacklightRegistersFix::wrapCFLWriteRegisterPWMDuty1(void *controller,
DBGLOG("igfx", "BLR: [CFL+] WriteRegister32<BXT_BLC_PWM_DUTY1>: Called with register 0x%x and value 0x%x.", reg, value);
PANIC_COND(reg != BXT_BLC_PWM_DUTY1, "igfx", "Fatal Error: Register should be BXT_BLC_PWM_DUTY1.");

if (value && callbackIGFX->modBacklightRegistersFix.driverBacklightFrequency == 0) {
// CFL+ backlight additional fix.
DBGLOG("igfx", "BLR: [CFL+] WriteRegister32<BXT_BLC_PWM_DUTY1>: Backlight additional fix was entered.");
uint32_t registerValue = callbackIGFX->readRegister32(controller, SFUSE_STRAP);
uint32_t selectedFreq = (registerValue & SFUSE_STRAP_RAW_FREQUENCY) ? ICL_FREQ_RAW : ICL_FREQ_NORMAL;
wrapCFLWriteRegisterPWMFreq1(controller, BXT_BLC_PWM_FREQ1, selectedFreq);
This conversation was marked as resolved.
Show resolved Hide resolved
}

if (callbackIGFX->modBacklightRegistersFix.driverBacklightFrequency && callbackIGFX->modBacklightRegistersFix.targetBacklightFrequency) {
// Translate the PWM duty cycle between the driver scale value and the HW scale value
uint32_t rescaledValue = static_cast<uint32_t>((value * static_cast<uint64_t>(callbackIGFX->modBacklightRegistersFix.targetBacklightFrequency)) / static_cast<uint64_t>(callbackIGFX->modBacklightRegistersFix.driverBacklightFrequency));
Expand Down
10 changes: 10 additions & 0 deletions WhateverGreen/kern_igfx_backlight.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ static constexpr uint32_t BXT_BLC_PWM_CTL1 = 0xC8250;
static constexpr uint32_t BXT_BLC_PWM_FREQ1 = 0xC8254;
static constexpr uint32_t BXT_BLC_PWM_DUTY1 = 0xC8258;

static constexpr uint32_t SFUSE_STRAP = 0xC2014;
static constexpr uint32_t SFUSE_STRAP_RAW_FREQUENCY = 1 << 8;

/**
* Ice Lake freq
* Copied from `AppleIntelFramebufferController::start()` function
*/
static constexpr uint32_t ICL_FREQ_NORMAL = 17777;
static constexpr uint32_t ICL_FREQ_RAW = 22222;

/**
* Represents a single brightness adjustment request
*/
Expand Down