Merge branch 'master' into reload_when_modified

Updated branch to master
This commit is contained in:
hbriese 2020-08-11 10:05:24 +10:00
commit 49efc27c1e
2 changed files with 13 additions and 10 deletions

View file

@ -7,7 +7,7 @@ On systems where the EC doesn't reset the values (ex: ASUS Zenbook UX430UNR), th
### Tested hardware
Other users have confirmed that the tool is also working for these laptops:
- Lenovo T480, T480s, X1C5, X1C6, T580, L480, T470, X280, ThinkPad Anniversary Edition 25, E590 w/ RX 550X, P43s, E480, E580
- Lenovo T480, T480s, X1C5, X1C6, T580, L490, L480, T470, X280, ThinkPad Anniversary Edition 25, E590 w/ RX 550X, P43s, E480, E580
- Dell XPS 9365, 9370, Latitude 7390 2-in-1
- Microsoft Surface Book 2

View file

@ -30,7 +30,8 @@ TRIP_TEMP_RANGE = [40, 97]
UNDERVOLT_KEYS = ('UNDERVOLT', 'UNDERVOLT.AC', 'UNDERVOLT.BATTERY')
ICCMAX_KEYS = ('ICCMAX', 'ICCMAX.AC', 'ICCMAX.BATTERY')
power = {'source': None, 'method': 'polling'}
HWP_VALUE = 0x20
HWP_PERFORMANCE_VALUE = 0x20
HWP_DEFAULT_VALUE = 0x80
HWP_INTERVAL = 60
@ -517,16 +518,17 @@ def calc_reg_values(platform_info, config):
return regs
def set_hwp():
def set_hwp(performance_mode):
# set HWP energy performance preference
cur_val = readmsr(0x774, cpu=0)
new_val = (cur_val & 0xFFFFFFFF00FFFFFF) | (HWP_VALUE << 24)
hwp_mode = HWP_PERFORMANCE_VALUE if performance_mode else HWP_DEFAULT_VALUE
new_val = (cur_val & 0xFFFFFFFF00FFFFFF) | (hwp_mode << 24)
writemsr(0x774, new_val)
if args.debug:
read_value = readmsr(0x774, from_bit=24, to_bit=31)[0]
match = OK if HWP_VALUE == read_value else ERR
log('[D] HWP - write "{:#02x}" - read "{:#02x}" - match {}'.format(HWP_VALUE, read_value, match))
match = OK if hwp_mode == read_value else ERR
log('[D] HWP - write "{:#02x}" - read "{:#02x}" - match {}'.format(hwp_mode, read_value, match))
def set_disable_bdprochot():
@ -651,7 +653,7 @@ def power_thread(config, regs, exit_event):
or (power['method'] == 'polling' and not is_on_battery(config))
)
):
set_hwp()
set_hwp(enable_hwp_mode)
next_hwp_write = time() + HWP_INTERVAL
else:
@ -814,14 +816,15 @@ def main():
log('[I] Throttled is disabled in config file... Quitting. :(')
return
undervolt(config)
set_icc_max(config)
set_hwp(config.getboolean('AC', 'HWP_Mode', fallback=False))
exit_event = Event()
thread = Thread(target=power_thread, args=(config, regs, exit_event))
thread.daemon = True
thread.start()
undervolt(config)
set_icc_max(config)
# handle dbus events for applying undervolt/IccMax on resume from sleep/hybernate
def handle_sleep_callback(sleeping):
if not sleeping: