| 1 |
/* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 |
|
| 3 |
#include <amdblocks/alib.h> |
| 4 |
|
| 5 |
/* The ALIB method object is defined in an SSDT */ |
| 6 |
External(\_SB.ALIB, MethodObj) |
| 7 |
|
| 8 |
/* Wrapper method that calls ALIB function 1 to report current AC/DC state. */ |
| 9 |
Method (WAL1) |
| 10 |
{ |
| 11 |
/* Send ALIB Function 1 the AC/DC state */ |
| 12 |
Local0 = Buffer (0x03) {} |
| 13 |
CreateWordField (Local0, 0, F1SZ) |
| 14 |
CreateByteField (Local0, 2, F1DA) |
| 15 |
|
| 16 |
/* First argument is size i.e. 3 bytes */ |
| 17 |
F1SZ = 3 |
| 18 |
|
| 19 |
/* |
| 20 |
* Second argument is power state i.e. AC or DC. |
| 21 |
* ALIB expects AC = 0, DC = 1. |
| 22 |
* PWRS reports AC = 1, DC = 0. |
| 23 |
* |
| 24 |
* Hence, need to invert the state of PWRS. |
| 25 |
*/ |
| 26 |
F1DA = \PWRS ^ 1 |
| 27 |
|
| 28 |
Printf ("ALIB call: func 1 params %o", Local0) |
| 29 |
\_SB.ALIB (ALIB_FUNCTION_REPORT_AC_DC_STATE, Local0) |
| 30 |
} |