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