Skip to content

Commit

Permalink
add fan_mode and suspend support
Browse files Browse the repository at this point in the history
  • Loading branch information
YoyPa committed Jun 13, 2019
1 parent ecc5277 commit dcf0b30
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
19 changes: 16 additions & 3 deletions etc/isw.conf
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
# [...]
#
# Some fan_speed value are ignored by laptops, they will trigger the closest valid RPM speed, isw can't see it.
# fan_mode can be 140, 76 or 12, for Advanced, Basic or Auto. Advanced seems to work better with suspend/hibernate.
# You can find a better explanation of how ec work at:
# https://github.com/YoyPa/isw/wiki/How-EC-work-(for-GS40-6QE-at-least)
# You can help me support your laptop (mainly MSI) by openning an issue and providing 'isw -c' output.

[GE62_6QE_DEFAULT]
address_profile = MSI_ADDRESS_DEFAULT
fan_mode = 140
# CPU
cpu_temp_0 = 55
cpu_temp_1 = 61
Expand Down Expand Up @@ -55,6 +57,7 @@ gpu_fan_speed_6 = 69

[GE62_7RE_DEFAULT]
address_profile = MSI_ADDRESS_DEFAULT
fan_mode = 140
# CPU
cpu_temp_0 = 55
cpu_temp_1 = 61
Expand Down Expand Up @@ -86,6 +89,7 @@ gpu_fan_speed_6 = 86

[GF63_8RD_DEFAULT]
address_profile = MSI_ADDRESS_DEFAULT
fan_mode = 140
# CPU
cpu_temp_0 = 40
cpu_temp_1 = 50
Expand Down Expand Up @@ -117,6 +121,7 @@ gpu_fan_speed_6 = 62

[GL63_8RD_DEFAULT]
address_profile = MSI_ADDRESS_DEFAULT
fan_mode = 140
# CPU
cpu_temp_0 = 50
cpu_temp_1 = 57
Expand Down Expand Up @@ -148,6 +153,7 @@ gpu_fan_speed_6 = 83

[GS40_6QE_DEFAULT]
address_profile = MSI_ADDRESS_DEFAULT
fan_mode = 140
# CPU
cpu_temp_0 = 58
cpu_temp_1 = 63
Expand Down Expand Up @@ -179,6 +185,7 @@ gpu_fan_speed_6 = 90

[GS65_8RF_DEFAULT]
address_profile = MSI_ADDRESS_DEFAULT
fan_mode = 140
# CPU
cpu_temp_0 = 55
cpu_temp_1 = 64
Expand Down Expand Up @@ -210,6 +217,7 @@ gpu_fan_speed_6 = 78

[GS65_8SG_DEFAULT]
address_profile = MSI_ADDRESS_DEFAULT
fan_mode = 140
# CPU
cpu_temp_0 = 55
cpu_temp_1 = 64
Expand Down Expand Up @@ -241,6 +249,7 @@ gpu_fan_speed_6 = 90

[GT60_2PE_DEFAULT]
address_profile = MSI_ADDRESS_DEFAULT
fan_mode = 140
# CPU
cpu_temp_0 = 52
cpu_temp_1 = 64
Expand Down Expand Up @@ -272,6 +281,7 @@ gpu_fan_speed_6 = 100

[MSI_16L13_DEFAULT]
address_profile = MSI_ADDRESS_DEFAULT
fan_mode = 140
# CPU
cpu_temp_0 = 10
cpu_temp_1 = 20
Expand Down Expand Up @@ -302,6 +312,9 @@ gpu_fan_speed_5 = 62
gpu_fan_speed_6 = 100

[MSI_ADDRESS_DEFAULT]
address_profile = MSI_ADDRESS_DEFAULT
fan_mode_address = 0xf4
# CPU
cpu_temp_address_0 = 0x6a
cpu_temp_address_1 = 0x6b
cpu_temp_address_2 = 0x6c
Expand All @@ -315,6 +328,9 @@ cpu_fan_speed_address_3 = 0x75
cpu_fan_speed_address_4 = 0x76
cpu_fan_speed_address_5 = 0x77
cpu_fan_speed_address_6 = 0x78
realtime_cpu_temp_address = 0x68
realtime_cpu_fan_speed_address = 0x71
# GPU
gpu_temp_address_0 = 0x82
gpu_temp_address_1 = 0x83
gpu_temp_address_2 = 0x84
Expand All @@ -328,8 +344,5 @@ gpu_fan_speed_address_3 = 0x8d
gpu_fan_speed_address_4 = 0x8e
gpu_fan_speed_address_5 = 0x8f
gpu_fan_speed_address_6 = 0x90
realtime_cpu_temp_address = 0x68
realtime_cpu_fan_speed_address = 0x71
realtime_gpu_temp_address = 0x80
realtime_gpu_fan_speed_address = 0x89
address_profile = MSI_ADDRESS_DEFAULT
8 changes: 6 additions & 2 deletions isw
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def ec_read(value):
with open(CFG_FILE) as cfgfile:
cfgp=configparser.ConfigParser()
cfgp.read_file(cfgfile)
# c=cpu g=gpu t=temp fs=fanspeed a=address p=profile r=realtime
# c=cpu g=gpu t=temp f=fan s=speed a=address p=profile r=realtime m=mode
ap = cfgp.get(value, 'address_profile')
rcta = int(cfgp.get(ap, 'realtime_cpu_temp_address'),16)
rcfsa = int(cfgp.get(ap, 'realtime_cpu_fan_speed_address'),16)
Expand Down Expand Up @@ -106,7 +106,7 @@ def ec_write(value):
with open(CFG_FILE) as cfgfile:
cfgp=configparser.ConfigParser()
cfgp.read_file(cfgfile)
# c=cpu g=gpu t=temp fs=fanspeed a=address p=profile r=realtime
# c=cpu g=gpu t=temp f=fan s=speed a=address p=profile r=realtime m=mode
list_cta = []
list_ct = []
list_cfsa = []
Expand All @@ -116,6 +116,8 @@ def ec_write(value):
list_gfsa = []
list_gfs = []
ap = cfgp.get(value, 'address_profile')
fma = int(cfgp.get(ap, 'fan_mode_address'),16)
fm = int(cfgp.get(value, 'fan_mode'))
for i in range(7):
if i<6:
list_cta.append(int(cfgp.get(ap, 'cpu_temp_address_'+str(i)),16))
Expand All @@ -127,6 +129,8 @@ def ec_write(value):
list_gfsa.append(int(cfgp.get(ap, 'gpu_fan_speed_address_'+str(i)),16))
list_gfs.append(int(cfgp.get(value, 'gpu_fan_speed_'+str(i))))
with open(EC_IO_FILE,"r+b") as file:
file.seek(fma)
file.write(bytes((fm,)))
for i in range(6):
file.seek(list_cta[i])
file.write(bytes((list_ct[i],)))
Expand Down
4 changes: 3 additions & 1 deletion usr/lib/systemd/system/[email protected]
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
[Unit]
Description=ISW fan control service
After=sleep.target

[Service]
ExecStartPre=/usr/bin/sleep 2
ExecStart=/usr/bin/isw -w %I
Type=oneshot

[Install]
WantedBy=multi-user.target
WantedBy=multi-user.target sleep.target

0 comments on commit dcf0b30

Please sign in to comment.