Debian Codegraph @

src/ec/clevo/it5570e/acpi/hid.asl

raw
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 /* Minimal implementation of HID event filter device for airplane hotkey support */
4
5 Device (HIDD)
6 {
7 Name (_HID, "INTC1051")
8
9 Name (HRDY, 0)
10 Name (HBSY, 0)
11 Name (HIDX, 0)
12
13 /*
14 * Workaround:
15 * There was a bug in Linux' HID driver, making evaluation of function 2 fail.
16 * The driver falls back to legacy mode and evaluates integers instead of _DSM.
17 * A bugfix for this was merged to mainline and stable but not LTS-branches. Thus,
18 * let's keep this for some time.
19 * https://lore.kernel.org/r/[email protected]
20 */
21 Name (HDMM, 0)
22
23 Method (_STA)
24 {
25 Return (0x0f)
26 }
27
28 Method (_DSM, 4, Serialized)
29 {
30 If (Arg0 == ToUUID ("eeec56b3-4442-408f-a792-4edd4d758054"))
31 {
32 If (Arg1 == 1) /* Revision 1 */
33 {
34 Printf ("HIDD: _DSM called, fn=%o", ToDecimalString(Arg2))
35
36 Switch (ToInteger (Arg2))
37 {
38 Case (0)
39 {
40 /* Supported functions: 0, 2, 3, 4, 7 */
41 Return (Buffer () {0x9d, 0x00})
42 }
43 Case (2)
44 {
45 /* Simple mode */
46 Return (0)
47 }
48 Case (3)
49 {
50 /* Driver status */
51 HRDY = DeRefOf (Arg3[0])
52 }
53 Case (4)
54 {
55 /* HID driver calls this to get event */
56 HBSY = 0
57 Return (HIDX)
58 }
59 Case (7)
60 {
61 /* Only airplane mode button implemented */
62 Return (1 << 1)
63 }
64 }
65 }
66 }
67
68 Return (Buffer () {0})
69 }
70
71 /*
72 * HID Platform Event Method
73 * Called to trigger HID event.
74 */
75 Method (HPEM, 1, Serialized)
76 {
77 Printf ("HIDD: HPEM called, event=%o", ToHexString (Arg0))
78
79 If (!HRDY)
80 {
81 Printf ("HIDD: HID driver not ready. Ignoring event.")
82 }
83
84 HBSY = 1
85 HIDX = Arg0
86
87 Notify (HIDD, 0xc0)
88
89 /* Wait max. 1 second for HID driver */
90 Local0 = 0
91 While ((Local0 < 250) && HBSY)
92 {
93 Sleep (4)
94 Local0++
95 }
96
97 If (HBSY)
98 {
99 Printf ("HIDD: HPEM timeout")
100
101 HBSY = 0
102 HIDX = 0
103
104 Return (1) /* Timeout */
105 }
106
107 Return (0)
108 }
109 }