aboutsummaryrefslogtreecommitdiff
path: root/src/ec/starlabs/merlin/acpi/hid.asl
blob: 5449807e0f50dd0a60566830897401280fb374e8 (plain)
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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
/* SPDX-License-Identifier: GPL-2.0-only */

Device (HIDD)							// HID Device
{
	Name (_HID, "INTC1051")					// Intel Ultrabook HID Platform Event Driver.
	Name (HBSY, 0)						// HID Busy
	Name (HIDX, 0)						// HID Index
	Name (HMDE, 0)						// HID Mode
	Name (HRDY, 0)						// HID Ready
	Name (BTLD, 0)						// Button Driver Loaded
	Name (BTS1, 0)						// Button Status
	Method (_STA, 0, Serialized)				// Status Method
	{
		// Usually, ACPI will check if the OS is 0x07DD (2013 - Windows 8.1ish)
		// before showing the HID event filter. Seeing as we use Linux we show
		// it regardless.
		Return (0x0F)
	}
	//
	// HID Driver Descriptor Method - Called by HID Driver during initialization
	// to obtain HID Descriptor information.
	//
	// Input:
	// None
	//
	// Output:
	// Package containing a complete HID Descriptor information.
	//
	Name(DPKG, Package(4)
	{
		0x11111111,
		0x22222222,
		0x33333333,
		0x44444444,
	})
	Method (HDDM, 0, Serialized)
	{
		Return(DPKG)
	}
	//
	// HID Driver Event Method - Called by HID Driver to get the specific
	// platform event.
	//
	// Input:
	// None
	//
	// Output:
	// Mode 0 = Index of HID Input Report, per pre-defined Table.
	// Mode 1 = Package containing a complete HID Input Report.
	//
	Method (HDEM, 0, Serialized)
	{
		HBSY = 0x00						// Clear HID Busy.
		// Simple Mode is hardcoded for now.  Return Simple Mode HID Index Value.
		If (HMDE == 0x00)
		{
			Return(HIDX)
		}
		Return(HMDE)
	}
	//
	// HID Driver Mode Method - Called by HID Driver during initialization to get
	// the platform mode of operation.
	//
	// Input:
	// None
	//
	// Output:
	// 0 = Simple Mode.
	// 1 = Advanced Mode.
	//
	Method (HDMM, 0, Serialized)
	{
		Return(HMDE)						// Return Mode of operation.
	}
	//
	// HID Driver Status Method - called by HID Driver to report platform readiness status.
	//
	// Input: Driver Status.
	// 0 = Driver Unloaded.
	// 1 = Driver Loaded and Ready.
	//
	// Output: None
	//
	Method (HDSM, 1, Serialized)
	{
		HRDY = Arg0						// Store HID Ready Status.
		// Eventually code will communicate to platform the Driver status (enabled/disabled).
	}
	//
	// HID Platform Event Method - called by Platform to communicate HID Event to Driver.
	//
	// Input:
	// Mode 0 = Index of HID Event.
	// Mode 1 = Package containing a complete HID Report.
	//
	Method (HPEM, 1, Serialized)					// HID Platform Event Method.
	{
		HBSY = 0x01						// Set HID Busy.
		// Simple Mode is hardcoded for now.  Simply store HID Index value.
		If (HMDE == 0x00)
		{
			HIDX = Arg0
		} Else {
			HIDX = Arg0
		}
		Notify (\_SB.HIDD, 0xC0)				// Notify Driver to get HID Event.
		Local0 = 0x00						// Initialize Local0 as a timeout counter.
		While((Local0 < 250) && HBSY)			// Wait <= 1 second for Driver to ACK success.
		{
			Sleep (4)					// Delay 4 ms.
			Local0++					// Increment Timeout.
		}
		If (HBSY == 0x01)						// Failure?
		{
			HBSY = 0x00					// Yes.  Clear HID Busy Flag.
			HIDX = 0x00					// Set HID Simple Mode Index = 0 = Undefined.
			Return (0x01)					// Return Failure.
		} Else {
			Return (0x00)					// Return Success.
		}
	}
	//
	// HID Button Load Method - called by Platform to say HID driver is capable of receiving
	// 5-button array notifications.
	//
	// Input:
	// None
	//
	// Output:
	// None
	//
	Method (BTNL, 0, Serialized)					// HID Button Enable/Disable Method
	{
		BTS1 = 0x00
	}
	//
	// HID Button Enable/Disable Method - called by Platform to disable/enable notification based
	// on button press
	//
	// Input:
	// Arg0 = Bit mask of buttons to Enable or Disable:
	// 1 == Button should be Enabled
	// 0 == Button should be Disabled
	//   Bits[0]: Power Button N/A to disable
	//   Bits[1]: Windows Button
	//   Bits[2]: Volume Up Button
	//   Bits[3]: Volume Down Button
	//   Bits[4]: Rotation Lock Button
	//   Bits[5:31]: Reserved
	//
	// Output:
	// None
	//
	Method (BTNE, 1, Serialized)					// HID Button Enable/Disable Method
	{
		Return (BTS1)
	}
	//
	// HID Button Status - called by Platform to get what buttons are enabled and disabled
	//
	// Input:
	// None
	//
	// Output:
	// Bit mask of buttons' current status:
	// 1 == Button is Enabled
	// 0 == Button is Disabled
	//   Bits[0]: Power Button N/A to disable
	//   Bits[1]: Windows Button
	//   Bits[2]: Volume Up Button
	//   Bits[3]: Volume Down Button
	//   Bits[4]: Rotation Lock Button
	//   Bits[5:31]: Reserved
	//
	Method (BTNS, 0, Serialized)
	{
		Return (BTS1)
	}
	//
	// HID Button Capabilities Method - called by Platform to determine what buttons are supported
	//
	// Input:
	// None
	//
	// Output:
	// Bit mask of buttons supported:
	// 1 == Button is Supported
	// 0 == Button is not Supported
	//   Bits[0]: Power Button (Must be 1)
	//   Bits[1]: Windows Button
	//   Bits[2]: Volume Up Button
	//   Bits[3]: Volume Down Button
	//   Bits[4]: Rotation Lock Button
	//   Bits[5:31]: Reserved
	//
	Method (BTNC, 0, Serialized)					// HID Button Capabilities Method
	{
		Return(0x1F)
	}

	//
	// HEBC: HID Event Base Capabilities [31:0]- To specify the base button capabilities supported
	// on platform by returning a ULONG value with the following bit level definition
	//
	// Input:
	// None
	//
	// 0 = Button not supported
	// 1 = Button supported
	// Output:
	// Bits [0] - Windows Button (Windows 8.1 supported), Rotation Lock (Windows 8.1 supported):
	//	      Num Lock, Home, End, Page Up, Page Down
	// Bits [1] - Wireless Radio Control
	// Bits [2] - System Power Down (Windows 8.1 supported)
	// Bits [3] - System Hibernate
	// Bits [4] - System Sleep/ System Wake
	// Bits [5] - Scan Next Track
	// Bits [6] - Scan Previous Track
	// Bits [7] - Stop
	// Bits [8] - Play/Pause
	// Bits [9] - Mute
	// Bits [10] - Volume Increment (Windows 8.1 supported)
	// Bits [11] - Volume Decrement (Windows 8.1 supported)
	// Bits [12] - Display Brightness Increment
	// Bits [13] - Display Brightness Decrement
	// Bits [14] - Lock Tablet
	// Bits [15] - Release Tablet
	// Bits [16] - Toggle Bezel
	// Bits [17] - 5 button array (Windows 10 supported):
	//	       (Power, Windows Home, Volume Up, Volume Down, Rotation Lock)
	// Bits [18] - Button 1
	// Bits [19] - Button 2
	// Bits [20] - Button 3
	// Bits [21] - Button 4
	// Bits [22] - Button 5
	// Bits [23-31] - reserved
	//
	// Modify below table if the target platform has different capabilities. Each bit
	// corresponding the above table definition.
	//
	Name (HEB2, 0)							// Extended 32bit capability definition for future enhancements.
	Method (HEBC, 0, Serialized) {
		// It's possible to return (\HEB1)
		Return (0x00)
	}
	Method (H2BC, 0, Serialized) {
		// It's possible to return (\HEB1)
		Return (0x00)
	}
	//
	// HEEC- Hid Event Extended Capabilities [32:63]
	//
	Method (HEEC, 0, Serialized) {
		// It's possible to return (\HEB2)
		Return(0x00)
	}
	//
	// HIDD _DSM
	// _DSM : Device Specific Method for the Windows Compatible Button Array.
	//
	// Arg0: UUID Unique function identifier
	// Arg1: Integer Revision Level
	// Arg2: Integer Function Index
	// Arg3: Package Parameters
	//
	Method (_DSM, 4, Serialized, 0, UnknownObj, {BuffObj, IntObj, IntObj, PkgObj})
	{
		// Compare passed in UUID to supported UUID.
		If (Arg0 == ToUUID ("EEEC56B3-4442-408F-A792-4EDD4D758054"))
		{
			If (0x01 == ToInteger(Arg1))				// Revision 1.
			{
				Switch (ToInteger(Arg2))			// Switch to Function Index.
				{
					//
					// Function 0, Query of supported functions.
					//
					Case (0x00)
					{
						Return (Buffer() {0xFF, 0x03})		// Total 9 function indices are supported including this.
					}
					//
					// Function 1, BTNL. Button Load Method. No Input/Output.
					//
					Case (0x01)
					{
						BTNL()
					}
					//
					// Function 2, HDMM. HID Driver Mode Method.
					// Input:None
					// Output:HDMM output. See HDMM
					//
					Case (0x02)
					{
						Return (HDMM())
					}
					//
					// Function 3, HDSM. HID Driver Status Method.
					// Input: 0 - The driver is not available. 1 - The driver is available.
					// Output: None
					//
					Case (0x03)
					{
						HDSM (DeRefOf(Arg3[0]))
					}
					//
					// Function 4, HDEM. HID Driver Event Method.
					// Input: None.
					// Output: Package contains Supported Keys (Mode 0)
					//
					Case (0x04)
					{
						Return (HDEM())
					}
					//
					// Function 5 BTNS. Button Status Method.
					// Input: None.
					// Output: Int32 which contains a bit map of Buttons' enable/disable states
					//
					Case (0x05)
					{
						Return (BTNS())
					}
					//
					// Function 6 BTNE. Button Enable/Disable Method.
					// Input: Int32 Bit mask of buttons enable/disable control:
					//	  1 = Button should be Enabled
					//	  0 = Button should be Disabled
					// Output: None.
					//
					Case (0x06)
					{
						BTNE (DeRefOf(Arg3[0]))
					}
					//
					// Function 7 HEBC. Button implemented state.
					// Input: None
					// Output: Int32 Bit map which shows what buttons are implemented on this system.
					//
					Case (0x07)
					{
						Return (HEBC())
					}
					//
					// Function 8 VGBS. Virtual GPIO Button Status.
					// Input: None
					// Output: Intger Bit map which shows what Virtual GPIO Button status. Currently only
					// Dock/Slate modes are supported.
					//
					Case (0x08)
					{
						Return (0x00)
					}
					//
					// Function 9 H2BC. Button implemented state.
					// Input: None
					// Output: Int32 Bit map which shows what buttons are implemented on this system.
					//
					Case (0x09)
					{
						Return (H2BC())
					}
				}
			}
		}
		// If the code falls through to this point, just return a buffer of 0.
		Return (Buffer() {0x00})
	}
}