diff --git a/src/add-ons/accelerants/intel_extreme/mode.cpp b/src/add-ons/accelerants/intel_extreme/mode.cpp index d9adc88f0d..e6d9bdf265 100644 --- a/src/add-ons/accelerants/intel_extreme/mode.cpp +++ b/src/add-ons/accelerants/intel_extreme/mode.cpp @@ -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;