forked from RehabMan/HP-ProBook-4x30s-DSDT-Patch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
04b_FanSmooth.txt
202 lines (201 loc) · 6.66 KB
/
04b_FanSmooth.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
##Maintained by: RehabMan for: HP Probook 4x30s/4x40s
#04b_FanSmooth.txt
#
# Original by Don_Grappler
# "04c_FanSmooth.txt"
# http://www.tonymacx86.com/hp-probook/72043-new-fan-control-dsdt-silent-fan-higher-temps-19.html#post635384
#
# A modification of "04b_FanQuietMod.txt" by RehabMan
# ( https://github.com/RehabMan/HP-ProBook-4x30s-DSDT-Patch/ )
# For HP Probook 4x30s/4x40s
#
# This fan patch provides enhanced fan control. It does so by tricking
# the system into thinking that the laptop is arbitrarily cool, such
# that it can override the default behavior and have complete control
# over the fan.
#
# This particular version, 04c_FanSmooth.txt, keeps the differences
# between available fan speeds as small as possible so that transitions
# are not (or just barely) noticeable and thus less distracting. This
# allows the fan to respond quicker to follow changes in temperature
# without annoying jumps in its noise.
#
# On a ProBook 4x30s it may be necessary to insert a couple of #1N4001
# diodes inline with the red/orange wire feeding power to the fan. This
# results in a fan system that is able to reach more low-RPM fan speeds
# than stock. More information on how this works is available at:
# http://www.tonymacx86.com/hp-probook/72043-new-fan-control-dsdt-silent-fan-higher-temps.html
#
# add fan readings and fan control
into device label SMCD remove_entry;
into definitionblock code_regex . insert
begin
Device (SMCD)\n
{\n
Name (_HID, "FAN00000") // _HID: Hardware ID\n
// ACPISensors.kext configuration\n
Name (TACH, Package()\n
{\n
"System Fan", "FAN0",\n
})\n
Name (TEMP, Package()\n
{\n
"CPU Heatsink", "TCPU",\n
"Ambient", "TAMB",\n
//"Mainboard", "TSYS",\n
//"CPU Proximity", "TCPP",\n
})\n
// Actual methods to implement fan/temp readings/control\n
Method (FAN0, 0, Serialized)\n
{\n
Store (\_TZ.GFRM (), Local0)\n
If (LEqual (0x03C4, Local0)) { Return (Zero) }\n
Return (Local0)\n
}\n
Method (TCPU, 0, Serialized)\n
{\n
Acquire (\_SB.PCI0.LPCB.EC0.ECMX, 0xFFFF)\n
Store (1, \_SB.PCI0.LPCB.EC0.CRZN)\n
Store (\_SB.PCI0.LPCB.EC0.DTMP, Local0)\n
Release (\_SB.PCI0.LPCB.EC0.ECMX)\n
Return (Local0)\n
}\n
Method (TAMB, 0, Serialized) // Ambient Temp\n
{\n
Return (Divide (Subtract (\_TZ.LOCZ._TMP, 2732), 10))\n
}\n
// Fan Control Table (pairs of temp, fan control byte)\n
Name (FTAB, Buffer()\n
{\n
35, 255, // This FTAB list modified by Don_Grappler \n
42, 128,\n
43, 127,\n
44, 126,\n
45, 125,\n
46, 124,\n
47, 123,\n
48, 122,\n
49, 121,\n
50, 120,\n
51, 119,\n
52, 118,\n
53, 117,\n
54, 116,\n
55, 115,\n
56, 113,\n
57, 111,\n
58, 109,\n
59, 107,\n
60, 105,\n
61, 102,\n
62, 99,\n
63, 96,\n
64, 93,\n
65, 90,\n
66, 86,\n
67, 82,\n
68, 78,\n
69, 74,\n
70, 70,\n
71, 65,\n
72, 60,\n
73, 55,\n
0xFF, 0\n
})\n
// Table to keep track of past temperatures (to track average)\n
Name (FHST, Buffer(16) { 0x0, 0, 0, 0, 0x0, 0, 0, 0, 0x0, 0, 0, 0, 0x0, 0, 0, 0 })\n
Name (FIDX, Zero) // current index in buffer above\n
Name (FNUM, Zero) // number of entries in above buffer to count in avg\n
Name (FSUM, Zero) // current sum of entries in buffer\n
// Keeps track of last fan speed set, and counter to set new one\n
Name (FLST, 0xFF) // last index for fan control\n
Name (FCNT, 0) // count of times it has been "wrong", 0 means no counter\n
Name (FCTU, 2) // timeout for changes (fan rpm going up) -- modified by Don_Grappler \n
Name (FCTD, 5) // timeout for changes (fan rpm going down) -- modified by Don_Grappler \n
\n
// Fan control for CPU -- expects to be evaluated 1-per second\n
Method (FCPU, 0, Serialized)\n
{\n
Acquire (\_SB.PCI0.LPCB.EC0.ECMX, 0xFFFF)\n
\n
// setup fake temperature (this is the key to controlling the fan!)\n
Store (1, \_SB.PCI0.LPCB.EC0.CRZN) // select CPU temp\n
Store (31, \_SB.PCI0.LPCB.EC0.TEMP) // write fake value there (31C)\n
\n
// get current temp into Local0 for eventual return\n
// Note: reading from DTMP here instead of TEMP because we wrote\n
// a fake temp to TEMP to trick the system into running the fan\n
// at a lower speed than it otherwise would.\n
Store (1, \_SB.PCI0.LPCB.EC0.CRZN) // select CPU temp\n
Store (\_SB.PCI0.LPCB.EC0.DTMP, Local0) // Local0 is current temp\n
\n
// calculate average temperature\n
Add (Local0, FSUM, Local1)\n
Store (FIDX, Local2)\n
Subtract (Local1, DerefOf (Index (FHST, Local2)), Local1)\n
Store (Local0, Index (FHST, Local2))\n
Store (Local1, FSUM) // Local1 is new sum\n
\n
// adjust current index into temp table\n
Increment (Local2)\n
if (LGreaterEqual (Local2, SizeOf(FHST))) { Store (0, Local2) }\n
Store (Local2, FIDX)\n
// adjust total items collected in temp table\n
Store (FNUM, Local2)\n
if (LNotEqual (Local2, SizeOf (FHST)))\n
{\n
Increment (Local2)\n
Store (Local2, FNUM)\n
}\n
\n
// Local1 is new sum, Local2 is number of entries in sum\n
Divide (Local1, Local2,, Local0) // Local0 is now average temp\n
\n
// table based search (use avg temperature to search)\n
if (LGreater (Local0, 255)) { Store (255, Local0) }\n
Store (Zero, Local2)\n
while (LGreater (Local0, DerefOf (Index (FTAB, Local2)))) { Add (Local2, 2, Local2) }\n
\n
// calculate difference between current and found index\n
if (LGreater (Local2, FLST))\n
{\n
Subtract(Local2, FLST, Local1)\n
Store(FCTU, Local4)\n
}\n
Else\n
{\n
Subtract(FLST, Local2, Local1)\n
Store(FCTD, Local4)\n
}\n
\n
// set new fan speed, if necessary\n
if (LEqual (Local1, 0))\n
{\n
// no difference, so leave current fan speed and reset count\n
Store (0, FCNT)\n
}\n
Else\n
{\n
// there is a difference, start/continue process of changing fan\n
Store (FCNT, Local3)\n
Increment (Local3)\n
Store (Local3, FCNT)\n
\n
// how long to wait depends on how big the difference\n
// 20 secs if diff is 2, 5 secs if diff is 4, etc.\n
Divide (ShiftLeft (Local4, 1), Local1,, Local1)\n
if (LGreaterEqual (Local3, Local1))\n
{\n
// timeout expired, so set new fan speed\n
Store (Local2, FLST)\n
Increment (Local2)\n
Store (DerefOf (Index (FTAB, Local2)), \_SB.PCI0.LPCB.EC0.FTGC)\n
Store (0, FCNT)\n
}\n
}\n
\n
Release (\_SB.PCI0.LPCB.EC0.ECMX)\n
return (Local0) // returns average temp\n
}\n
}\n
end;