]> git.proxmox.com Git - mirror_edk2.git/blame - Vlv2DeviceRefCodePkg/AcpiTablesPCAT/IgdOMOBF.ASL
Vlv2DeviceRefCodePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / Vlv2DeviceRefCodePkg / AcpiTablesPCAT / IgdOMOBF.ASL
CommitLineData
3cbfba02
DW
1/*++\r
2\r
3Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved\r
4\r
7ede8060 5 SPDX-License-Identifier: BSD-2-Clause-Patent\r
3cbfba02
DW
6\r
7\r
8\r
9Module Name:\r
10\r
11 IgdOMOBF.ASL\r
12\r
13Abstract:\r
14\r
15 IGD OpRegion/Software SCI Reference Code for the Baytrail Family.\r
16 This file contains ASL code with the purpose of handling events\r
17 i.e. hotkeys and other system interrupts.\r
18\r
19--*/\r
20\r
21\r
22// Notes:\r
23// 1. The following routines are to be called from the appropriate event\r
24// handlers.\r
25// 2. This code cannot comprehend the exact implementation in the OEM's BIOS.\r
26// Therefore, an OEM must call these methods from the existing event\r
27// handler infrastructure. Details on when/why to call each method is\r
28// included in the method header under the "usage" section.\r
29\r
30\r
31/************************************************************************;\r
32;* ACPI Notification Methods\r
33;************************************************************************/\r
34\r
35\r
36/************************************************************************;\r
37;*\r
38;* Name: PDRD\r
39;*\r
40;* Description: Check if the graphics driver is ready to process\r
41;* notifications and video extensions.\r
42;*\r
43;* Usage: This method is to be called prior to performing any\r
44;* notifications or handling video extensions.\r
45;* Ex: If (PDRD()) {Return (FAIL)}\r
46;*\r
47;* Input: None\r
48;*\r
49;* Output: None\r
50;*\r
51;* References: DRDY (Driver ready status), ASLP (Driver recommended\r
52;* sleep timeout value).\r
53;*\r
54;************************************************************************/\r
55\r
56Method(PDRD)\r
57{\r
58 If(LNot(DRDY))\r
59 {\r
60\r
61 // Sleep for ASLP milliseconds if the driver is not ready.\r
62\r
63 Sleep(ASLP)\r
64 }\r
65\r
66 // If DRDY is clear, the driver is not ready. If the return value is\r
67 // !=0, do not perform any notifications or video extension handling.\r
68\r
69 Return(LNot(DRDY))\r
70}\r
71\r
72\r
73/************************************************************************;\r
74;*\r
75;* Name: PSTS\r
76;*\r
77;* Description: Check if the graphics driver has completed the previous\r
78;* "notify" command.\r
79;*\r
80;* Usage: This method is called before every "notify" command. A\r
81;* "notify" should only be set if the driver has completed the\r
82;* previous command. Else, ignore the event and exit the parent\r
83;* method.\r
84;* Ex: If (PSTS()) {Return (FAIL)}\r
85;*\r
86;* Input: None\r
87;*\r
88;* Output: None\r
89;*\r
90;* References: CSTS (Notification status), ASLP (Driver recommended sleep\r
91;* timeout value).\r
92;*\r
93;************************************************************************/\r
94\r
95Method(PSTS)\r
96{\r
97 If(LGreater(CSTS, 2))\r
98 {\r
99 // Sleep for ASLP milliseconds if the status is not "success,\r
100 // failure, or pending"\r
101 //\r
102 Sleep(ASLP)\r
103 }\r
104\r
105 Return(LEqual(CSTS, 3)) // Return True if still Dispatched\r
106}\r
107\r
108\r
109/************************************************************************;\r
110;*\r
111;* Name: GNOT\r
112;*\r
113;* Description: Call the appropriate methods to query the graphics driver\r
114;* status. If all methods return success, do a notification of\r
115;* the graphics device.\r
116;*\r
117;* Usage: This method is to be called when a graphics device\r
118;* notification is required (display switch hotkey, etc).\r
119;*\r
120;* Input: Arg0 = Current event type:\r
121;* 1 = display switch\r
122;* 2 = lid\r
123;* 3 = dock\r
124;* Arg1 = Notification type:\r
125;* 0 = Re-enumeration\r
126;* 0x80 = Display switch\r
127;*\r
128;* Output: Returns 0 = success, 1 = failure\r
129;*\r
130;* References: PDRD and PSTS methods. OSYS (OS version)\r
131;*\r
132;************************************************************************/\r
133\r
134Method(GNOT, 2)\r
135{\r
136 // Check for 1. Driver loaded, 2. Driver ready.\r
137 // If any of these cases is not met, skip this event and return failure.\r
138 //\r
139 If(PDRD())\r
140 {\r
141 Return(0x1) // Return failure if driver not loaded.\r
142 }\r
143\r
144 Store(Arg0, CEVT) // Set up the current event value\r
145 Store(3, CSTS) // CSTS=BIOS dispatched an event\r
146\r
147 If(LAnd(LEqual(CHPD, 0), LEqual(Arg1, 0))) // Do not re-enum if driver supports hotplug\r
148 {\r
149 If(LOr(LGreater(OSYS, 2000), LLess(OSYS, 2006)))\r
150 {\r
151 //\r
152 // WINXP requires that the entire PCI Bridge be re-enumerated.\r
153 //\r
154 Notify(\_SB.PCI0, Arg1)\r
155 }\r
156 Else\r
157 {\r
158 //\r
159 // Re-enumerate the Graphics Device for non-XP operating systems.\r
160 //\r
161 Notify(\_SB.PCI0.GFX0, Arg1)\r
162 }\r
163 }\r
164\r
165 Notify(\_SB.PCI0.GFX0,0x80)\r
166\r
167\r
168 Return(0x0) // Return success\r
169}\r
170\r
171\r
172/************************************************************************;\r
173;*\r
174;* Name: GHDS\r
175;*\r
176;* Description: Handle a hotkey display switching event (performs a\r
177;* Notify(GFX0, 0).\r
178;*\r
179;* Usage: This method must be called when a hotkey event occurs and the\r
180;* purpose of that hotkey is to do a display switch.\r
181;*\r
182;* Input: Arg0 = Toggle table number.\r
183;*\r
184;* Output: Returns 0 = success, 1 = failure.\r
185;* CEVT and TIDX are indirect outputs.\r
186;*\r
187;* References: TIDX, GNOT\r
188;*\r
189;************************************************************************/\r
190\r
191Method(GHDS, 1)\r
192{\r
193 Store(Arg0, TIDX) // Store the table number\r
194\r
195 // Call GNOT for CEVT = 1 = hotkey, notify value = 0\r
196\r
197 Return(GNOT(1, 0)) // Return stats from GNOT\r
198}\r
199\r
200\r
201/************************************************************************;\r
202;*\r
203;* Name: GLID\r
204;*\r
205;* Description: Handle a lid event (performs the Notify(GFX0, 0), but not the\r
206;* lid notify).\r
207;*\r
208;* Usage: This method must be called when a lid event occurs. A\r
209;* Notify(LID0, 0x80) must follow the call to this method.\r
210;*\r
211;* Input: Arg0 = Lid state:\r
212;* 0 = All closed\r
213;* 1 = internal LFP lid open\r
214;* 2 = external lid open\r
215;* 3 = both external and internal open\r
216;*\r
217;* Output: Returns 0=success, 1=failure.\r
218;* CLID and CEVT are indirect outputs.\r
219;*\r
220;* References: CLID, GNOT\r
221;*\r
222;************************************************************************/\r
223\r
224Method(GLID, 1)\r
225{\r
226 Store(Arg0, CLID) // Store the current lid state\r
227\r
228 // Call GNOT for CEVT=2=Lid, notify value = 0\r
229\r
230 Return(GNOT(2, 0)) // Return stats from GNOT\r
231}\r
232\r
233\r
234/************************************************************************;\r
235;*\r
236;* Name: GDCK\r
237;*\r
238;* Description: Handle a docking event by updating the current docking status\r
239;* and doing a notification.\r
240;*\r
241;* Usage: This method must be called when a docking event occurs.\r
242;*\r
243;* Input: Arg0 = Docking state:\r
244;* 0 = Undocked\r
245;* 1 = Docked\r
246;*\r
247;* Output: Returns 0=success, 1=failure.\r
248;* CDCK and CEVT are indirect outputs.\r
249;*\r
250;* References: CDCK, GNOT\r
251;*\r
252;************************************************************************/\r
253\r
254Method(GDCK, 1)\r
255{\r
256 Store(Arg0, CDCK) // Store the current dock state\r
257\r
258 // Call GNOT for CEVT=4=Dock, notify value = 0\r
259\r
260 Return(GNOT(4, 0)) // Return stats from GNOT\r
261}\r
262\r
263\r
264/************************************************************************;\r
265;* ASLE Interrupt Methods\r
266;************************************************************************/\r
267\r
268\r
269/************************************************************************;\r
270;*\r
271;* Name: PARD\r
272;*\r
273;* Description: Check if the driver is ready to handle ASLE interrupts\r
274;* generate by the system BIOS.\r
275;*\r
276;* Usage: This method must be called before generating each ASLE\r
277;* interrupt.\r
278;*\r
279;* Input: None\r
280;*\r
281;* Output: Returns 0 = success, 1 = failure.\r
282;*\r
283;* References: ARDY (Driver readiness), ASLP (Driver recommended sleep\r
284;* timeout value)\r
285;*\r
286;************************************************************************/\r
287\r
288Method(PARD)\r
289{\r
290 If(LNot(ARDY))\r
291 {\r
292\r
293 // Sleep for ASLP milliseconds if the driver is not ready.\r
294\r
295 Sleep(ASLP)\r
296 }\r
297\r
298 // If ARDY is clear, the driver is not ready. If the return value is\r
299 // !=0, do not generate the ASLE interrupt.\r
300\r
301 Return(LNot(ARDY))\r
302}\r
303\r
304\r
305/************************************************************************;\r
306;*\r
307;* Name: AINT\r
308;*\r
309;* Description: Call the appropriate methods to generate an ASLE interrupt.\r
310;* This process includes ensuring the graphics driver is ready\r
311;* to process the interrupt, ensuring the driver supports the\r
312;* interrupt of interest, and passing information about the event\r
313;* to the graphics driver.\r
314;*\r
315;* Usage: This method must called to generate an ASLE interrupt.\r
316;*\r
317;* Input: Arg0 = ASLE command function code:\r
318;* 0 = Set ALS illuminance\r
319;* 1 = Set backlight brightness\r
320;* 2 = Do Panel Fitting\r
321;* Arg1 = If Arg0 = 0, current ALS reading:\r
322;* 0 = Reading below sensor range\r
323;* 1-0xFFFE = Current sensor reading\r
324;* 0xFFFF = Reading above sensor range\r
325;* Arg1 = If Arg0 = 1, requested backlight percentage\r
326;*\r
327;* Output: Returns 0 = success, 1 = failure\r
328;*\r
329;* References: PARD method.\r
330;*\r
331;************************************************************************/\r
332\r
333Method(AINT, 2)\r
334{\r
335\r
336 // Return failure if the requested feature is not supported by the\r
337 // driver.\r
338\r
339 If(LNot(And(TCHE, ShiftLeft(1, Arg0))))\r
340 {\r
341 Return(0x1)\r
342 }\r
343\r
344 // Return failure if the driver is not ready to handle an ASLE\r
345 // interrupt.\r
346\r
347 If(PARD())\r
348 {\r
349 Return(0x1)\r
350 }\r
351\r
352 // Evaluate the first argument (Panel fitting, backlight brightness, or ALS).\r
353\r
354 If(LEqual(Arg0, 2)) // Arg0 = 2, so request a panel fitting mode change.\r
355 {\r
356 If(CPFM) // If current mode field is non-zero use it.\r
357 {\r
358 And(CPFM, 0x0F, Local0) // Create variables without reserved\r
359 And(EPFM, 0x0F, Local1) // or valid bits.\r
360\r
361 If(LEqual(Local0, 1)) // If current mode is centered,\r
362 {\r
363 If(And(Local1, 6)) // and if stretched is enabled,\r
364 {\r
365 Store(6, PFIT) // request stretched.\r
366 }\r
367 Else // Otherwise,\r
368 {\r
369 If(And(Local1, 8)) // if aspect ratio is enabled,\r
370 {\r
371 Store(8, PFIT) // request aspect ratio.\r
372 }\r
373 Else // Only centered mode is enabled\r
374 {\r
375 Store(1, PFIT) // so request centered. (No change.)\r
376 }\r
377 }\r
378 }\r
379 If(LEqual(Local0, 6)) // If current mode is stretched,\r
380 {\r
381 If(And(Local1, 8)) // and if aspect ratio is enabled,\r
382 {\r
383 Store(8, PFIT) // request aspect ratio.\r
384 }\r
385 Else // Otherwise,\r
386 {\r
387 If(And(Local1, 1)) // if centered is enabled,\r
388 {\r
389 Store(1, PFIT) // request centered.\r
390 }\r
391 Else // Only stretched mode is enabled\r
392 {\r
393 Store(6, PFIT) // so request stretched. (No change.)\r
394 }\r
395 }\r
396 }\r
397 If(LEqual(Local0, 8)) // If current mode is aspect ratio,\r
398 {\r
399 If(And(Local1, 1)) // and if centered is enabled,\r
400 {\r
401 Store(1, PFIT) // request centered.\r
402 }\r
403 Else // Otherwise,\r
404 {\r
405 If(And(Local1, 6)) // if stretched is enabled,\r
406 {\r
407 Store(6, PFIT) // request stretched.\r
408 }\r
409 Else // Only aspect ratio mode is enabled\r
410 {\r
411 Store(8, PFIT) // so request aspect ratio. (No change.)\r
412 }\r
413 }\r
414 }\r
415 }\r
416\r
417 // The following code for panel fitting (within the Else condition) is retained for backward compatiblity.\r
418\r
419 Else // If CFPM field is zero use PFIT and toggle the\r
420 {\r
421 Xor(PFIT,7,PFIT) // mode setting between stretched and centered only.\r
422 }\r
423\r
424 Or(PFIT,0x80000000,PFIT) // Set the valid bit for all cases.\r
425\r
426 Store(4, ASLC) // Store "Panel fitting event" to ASLC[31:1]\r
427 }\r
428 Else\r
429 {\r
430 If(LEqual(Arg0, 1)) // Arg0=1, so set the backlight brightness.\r
431 {\r
432 Store(Divide(Multiply(Arg1, 255), 100), BCLP) // Convert from percent to 0-255.\r
433\r
434 Or(BCLP, 0x80000000, BCLP) // Set the valid bit.\r
435\r
436 Store(2, ASLC) // Store "Backlight control event" to ASLC[31:1]\r
437 }\r
438 Else\r
439 {\r
440 If(LEqual(Arg0, 0)) // Arg0=0, so set the ALS illuminace\r
441 {\r
442 Store(Arg1, ALSI)\r
443\r
444 Store(1, ASLC) // Store "ALS event" to ASLC[31:1]\r
445 }\r
446 Else\r
447 {\r
448 Return(0x1) // Unsupported function\r
449 }\r
450 }\r
451 }\r
452\r
453 Store(0x01, ASLE) // Generate ASLE interrupt\r
454 Return(0x0) // Return success\r
455}\r
456\r
457\r
458/************************************************************************;\r
459;*\r
460;* Name: SCIP\r
461;*\r
462;* Description: Checks the presence of the OpRegion and SCI\r
463;*\r
464;* Usage: This method is called before other OpRegion methods. The\r
465;* former "GSMI True/False is not always valid. This method\r
466;* checks if the OpRegion Version is non-zero and if non-zero,\r
467;* (present and readable) then checks the GSMI flag.\r
468;*\r
469;* Input: None\r
470;*\r
471;* Output: Boolean True = SCI present.\r
472;*\r
473;* References: None\r
474;*\r
475;************************************************************************/\r
476\r
477Method(SCIP)\r
478{\r
479 If(LNotEqual(OVER,0)) // If OpRegion Version not 0.\r
480 {\r
481 Return(LNot(GSMI)) // Return True if SCI.\r
482 }\r
483\r
484 Return(0) // Else Return False.\r
485}\r