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