-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPower Supply Ratings, Power Status (ECWR) and Power Mode Switching Request Handling.txt
259 lines (247 loc) · 8.75 KB
/
Power Supply Ratings, Power Status (ECWR) and Power Mode Switching Request Handling.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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
// Try C# syntax highlighting on this document (and other ASL files), it looks good (don't turn on Intellisense tho)
// All available power supply ratings
Name (PWL1, 0x41) // 65W
Name (PWL2, 0x5A) // 90W
Name (PWL3, 0x5F) // 95W
Name (PWL4, 0x64) // 100W
Name (PWL5, 0xB4) // 180W
Name (PWL6, 0xE6) // 230W
Name (PWL7, 0x014A) // 330W
/*
ECWR (EC memory 0x60)
Values:
0x02 (00000010): Just unplugged (wasn't charging) -> 0x0A
0x03 (00000011): Plugged in and NOT charging
0x06 (00000110): Just unplugged (was charging) -> 0x0A
0x07 (00000111): Plugged in and charging
0x0A (00001010): Normal unplugged usage
0x0B (00001011): Just plugged in -> 0x03 or 0x07
0x83 (10000011): Powered by Thunderbolt and NOT charging
0x8* (1000....): Same things apply.
Bit masks:
00000001: Plugged in (BOTH DC barrel jack AND Thunderbolt counts)
00000010: Battery present (I removed the battery for this lol)
00000100: Battery charging
00001000: Powered by (i.e. draining) battery
10000000: Powered by Thunderbolt
This bit appears with 00000001 so change the most significant 4 bits in the Values part to 1000 (8) and the explanations still work.
*/
Method (APTY, 0, Serialized)
{
If (((ECWR & One) == One))
{
Local7 = One // Plugged in
}
If (((ECWR & One) == Zero))
{
Local7 = 0x02 // Not plugged in
}
If (((ECWR & 0x83) == 0x83))
{
Local7 = 0x03 // Powered by Thunderbolt (Note that this is bitwise AND)
}
Return (Local7)
}
// TODO: Analyze this method!
Method (THMD, 0, Serialized)
{
If (((ECWR & One) == One))
{
Local7 = One // Plugged in
}
If (((ECWR & One) == Zero))
{
Local7 = 0x02 // Not plugged in
}
If (((ECWR & 0x80) == 0x80))
{
Local7 = 0x03 // Powered by Thunderbolt
}
If (((Local7 == One) || (APTY () == 0x03))) // Plugged in OR powered by Thunderbolt (Why?)
{
Local0 = (ECRD (RefOf (AWHG)) << 0x08)
Local0 += ECRD (RefOf (AWLW)) // Local0: Power supply rating
If ((Local0 < PWL5)) // Power supply rating < 180W
{
If ((Local0 < PWL1)){} // Power supply rating < 65W, don't set ODV0 (so what?)
Else
{
ODV0 = 0x02 // 65W <= Power supply rating < 180W
}
ODV5 = 0x02 // This is only for running on a not-so-beefy power supply (< 180W). Not even used for batteries.
^^^WMID.EVBU [Zero] = One
^^^WMID.EVBU [One] = 0x16
^^^WMID.EVBU [0x02] = 0x02
Notify (WMID, 0x20) // HID_EVENT20, 0x01 0x16 0x02 0x00 0x00 0x00 0x00 0x00
}
ElseIf ((Local0 >= PWL5)) // Power supply rating >= 180W
{
If ((ECRD (RefOf (ITSM)) == Zero)) // TURBO mode
{
ODV0 = Zero
^^^WMID.EVBU [Zero] = One
^^^WMID.EVBU [One] = 0x16
^^^WMID.EVBU [0x02] = 0x03
Notify (WMID, 0x20) // HID_EVENT20, 0x01 0x16 0x03 0x00 0x00 0x00 0x00 0x00
}
ElseIf ((ECRD (RefOf (ITSM)) == One)) // BALANCED mode
{
ODV0 = One
^^^WMID.EVBU [Zero] = One
^^^WMID.EVBU [One] = 0x16
^^^WMID.EVBU [0x02] = One
Notify (WMID, 0x20) // HID_EVENT20, 0x01 0x16 0x01 0x00 0x00 0x00 0x00 0x00
}
ElseIf ((ECRD (RefOf (ITSM)) == 0x02)) // SILENCE mode
{
ODV0 = 0x02
^^^WMID.EVBU [Zero] = One
^^^WMID.EVBU [One] = 0x16
^^^WMID.EVBU [0x02] = 0x02
Notify (WMID, 0x20) // HID_EVENT20, 0x01 0x16 0x02 0x00 0x00 0x00 0x00 0x00
}
ElseIf ((ECRD (RefOf (ITSM)) == 0x03)) // My laptop didn't come with this power mode so...
{
ODV0 = 0x03
^^^WMID.EVBU [Zero] = One
^^^WMID.EVBU [One] = 0x16
^^^WMID.EVBU [0x02] = 0x04
Notify (WMID, 0x20) // HID_EVENT20, 0x01 0x16 0x04 0x00 0x00 0x00 0x00 0x00
}
}
}
// Not plugged in
ElseIf ((ECRD (RefOf (ITSM)) == 0x02)) // SILENCE mode
{
ODV0 = 0x02
If ((GSTS == Zero)){} // How useless
Else
{
}
^^^WMID.EVBU [Zero] = One
^^^WMID.EVBU [One] = 0x16
^^^WMID.EVBU [0x02] = 0x02
Notify (WMID, 0x20) // HID_EVENT20, 0x01 0x16 0x02 0x00 0x00 0x00 0x00 0x00
}
// The other power mode when not plugged in is BALANCED mode.
Else
{
ODV0 = One
If ((GSTS == Zero)){} // Why??
Else
{
}
^^^WMID.EVBU [Zero] = One
^^^WMID.EVBU [One] = 0x16
^^^WMID.EVBU [0x02] = One
Notify (WMID, 0x20) // HID_EVENT20, 0x01 0x16 0x01 0x00 0x00 0x00 0x00 0x00
}
// I suppose we shouldn't care since no specialized Xiaomi drivers are loaded on Windows to handle these events,
// and WMI doesn't expose them, either.
Notify (IETM, 0x88) // Device-Specific
Notify (NPCF, 0xC0) // Hardware-Specific
FNKF = One // What?
}
// --------------------------------------------------------------------------------------------------------------------------------
// Snippet from WMAA to set power mode via WMI
Local0 = (\_SB.PC00.LPCB.H_EC.ECRD (RefOf (\_SB.PC00.LPCB.H_EC.AWHG)) << 0x08)
Local0 += \_SB.PC00.LPCB.H_EC.ECRD (RefOf (\_SB.PC00.LPCB.H_EC.AWLW))
Local1 = \_SB.PC00.LPCB.H_EC.APTY ()
SGER = 0x8000
If (((GPUT == One) || (GPUT == 0x03))) // GPU Type? Because obviously these two types consume much more power. This crap first occurs in SSDT12: `CreateBitField (Arg3, 0x08, GPUT)` in `\_SB.PC00.PEG1.PEGP.GPS` method.
{
If (((Local1 == 0x03) || (Local1 == One))) // Plugged in
{
If ((Local0 < PWL6)) // Power supply rating < 230W
{
// No modes other than Silent for you
If ((FUN3 == 0x02))
{
\_SB.PC00.LPCB.H_EC.ECWT (FUN3, RefOf (\_SB.PC00.LPCB.H_EC.ITSM))
}
Else
{
SGER = 0xE000
}
}
ElseIf ((Local0 >= PWL6)) // Power supply rating >= 230W
{
If ((Local0 < PWL7)) // Power supply rating == 230W
{
// No 0x04 for you
If ((FUN3 == 0x04))
{
SGER = 0xE000
}
// 0x03 is the equivalent of 0x00
ElseIf ((FUN3 == 0x03))
{
\_SB.PC00.LPCB.H_EC.ECWT (Zero, RefOf (\_SB.PC00.LPCB.H_EC.ITSM))
}
Else
{
\_SB.PC00.LPCB.H_EC.ECWT (FUN3, RefOf (\_SB.PC00.LPCB.H_EC.ITSM))
}
}
ElseIf ((Local0 >= PWL7)) // Power supply rating == 330W
{
// 0x03 is the equivalent of 0x00
If ((FUN3 == 0x03))
{
\_SB.PC00.LPCB.H_EC.ECWT (Zero, RefOf (\_SB.PC00.LPCB.H_EC.ITSM))
}
// 0x04 is the equivalent of 0x03 (what the fuck)
ElseIf ((FUN3 == 0x04))
{
\_SB.PC00.LPCB.H_EC.ECWT (0x03, RefOf (\_SB.PC00.LPCB.H_EC.ITSM))
}
Else
{
\_SB.PC00.LPCB.H_EC.ECWT (FUN3, RefOf (\_SB.PC00.LPCB.H_EC.ITSM))
}
}
}
}
// Not plugged in, 0x03 and 0x04 not available
ElseIf ((FUN3 == 0x03)){}
ElseIf ((FUN3 == 0x04)){}
// But 0x00 is still available...?
Else
{
\_SB.PC00.LPCB.H_EC.ECWT (FUN3, RefOf (\_SB.PC00.LPCB.H_EC.ITSM))
}
}
ElseIf (((Local1 == 0x03) || (Local1 == One))) // Plugged in
{
If ((Local0 <= PWL4)) // Power supply rating <= 100W
{
// No modes other than Silent for you
\_SB.PC00.LPCB.H_EC.ECWT (0x02, RefOf (\_SB.PC00.LPCB.H_EC.ITSM))
If (((FUN3 == One) || (FUN3 == Zero)))
{
SGER = 0xE000
}
}
ElseIf ((Local0 > PWL4)) // Power supply rating > 100W
{
// 0x03 is the equivalent of 0x00
If ((FUN3 == 0x03))
{
\_SB.PC00.LPCB.H_EC.ECWT (Zero, RefOf (\_SB.PC00.LPCB.H_EC.ITSM))
}
Else
{
\_SB.PC00.LPCB.H_EC.ECWT (FUN3, RefOf (\_SB.PC00.LPCB.H_EC.ITSM))
}
}
}
// Not plugged in, 0x03 not available
ElseIf ((FUN3 == 0x03)){}
// Dude 0x00 is available in this case, too! What?
// Setting power mode to 0x00 when unplugged doesn't throw 0xE000 though, so I guess this makes sense now.
Else
{
\_SB.PC00.LPCB.H_EC.ECWT (FUN3, RefOf (\_SB.PC00.LPCB.H_EC.ITSM))
}
\_SB.PC00.LPCB.H_EC.THMD () // Set actual power parameters according to ITSM
Break