intel_extreme: adjust brightness level for Gen4
preserve bits before Gen4 Change-Id: Icf80ec469c3682223f0db1744a5c923fb06bd7fd Reviewed-on: https://review.haiku-os.org/c/haiku/+/5190 Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org> Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
This commit is contained in:
parent
d271377590
commit
e5d9d907ee
@ -632,15 +632,24 @@ intel_set_brightness(float brightness)
|
||||
write32(intel_get_backlight_register(false), duty | (period << 16));
|
||||
} else {
|
||||
// On older devices there is a single register with both period and duty cycle
|
||||
uint32_t period = read32(intel_get_backlight_register(true)) >> 16;
|
||||
uint32 tmp = read32(intel_get_backlight_register(true));
|
||||
uint32_t period = tmp >> 16;
|
||||
|
||||
// The low bit must be masked out because
|
||||
// it is apparently used for something else on some Atom machines (no
|
||||
// reference to that in the documentation that I know of).
|
||||
uint32_t duty = (uint32_t)(period * brightness) & 0xfffe;
|
||||
uint32_t mask = 0xffff;
|
||||
uint32_t shift = 0;
|
||||
if (gInfo->shared_info->device_type.Generation() < 4) {
|
||||
// The low bit must be masked out because
|
||||
// it is apparently used for something else on some Atom machines (no
|
||||
// reference to that in the documentation that I know of).
|
||||
mask = 0xfffe;
|
||||
shift = 1;
|
||||
period = tmp >> 17;
|
||||
}
|
||||
uint32_t duty = (uint32_t)(period * brightness);
|
||||
duty = std::max(duty, (uint32_t)gInfo->shared_info->min_brightness);
|
||||
duty <<= shift;
|
||||
|
||||
write32(intel_get_backlight_register(false), duty | (period << 16));
|
||||
write32(intel_get_backlight_register(false), (duty & mask) | (tmp & ~mask));
|
||||
}
|
||||
|
||||
return B_OK;
|
||||
@ -664,6 +673,11 @@ intel_get_brightness(float* brightness)
|
||||
} else {
|
||||
period = read32(intel_get_backlight_register(true)) >> 16;
|
||||
duty = read32(intel_get_backlight_register(false)) & 0xffff;
|
||||
|
||||
if (gInfo->shared_info->device_type.Generation() < 4) {
|
||||
period >>= 1;
|
||||
duty >>= 1;
|
||||
}
|
||||
}
|
||||
*brightness = (float)duty / period;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user