3 Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved
5 SPDX-License-Identifier: BSD-2-Clause-Patent
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.
23 // 1. The following routines are to be called from the appropriate event
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.
31 /************************************************************************;
32 ;* ACPI Notification Methods
33 ;************************************************************************/
36 /************************************************************************;
40 ;* Description: Check if the graphics driver is ready to process
41 ;* notifications and video extensions.
43 ;* Usage: This method is to be called prior to performing any
44 ;* notifications or handling video extensions.
45 ;* Ex: If (PDRD()) {Return (FAIL)}
51 ;* References: DRDY (Driver ready status), ASLP (Driver recommended
52 ;* sleep timeout value).
54 ;************************************************************************/
61 // Sleep for ASLP milliseconds if the driver is not ready.
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.
73 /************************************************************************;
77 ;* Description: Check if the graphics driver has completed the previous
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
84 ;* Ex: If (PSTS()) {Return (FAIL)}
90 ;* References: CSTS (Notification status), ASLP (Driver recommended sleep
93 ;************************************************************************/
99 // Sleep for ASLP milliseconds if the status is not "success,
100 // failure, or pending"
105 Return(LEqual(CSTS, 3)) // Return True if still Dispatched
109 /************************************************************************;
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.
117 ;* Usage: This method is to be called when a graphics device
118 ;* notification is required (display switch hotkey, etc).
120 ;* Input: Arg0 = Current event type:
121 ;* 1 = display switch
124 ;* Arg1 = Notification type:
125 ;* 0 = Re-enumeration
126 ;* 0x80 = Display switch
128 ;* Output: Returns 0 = success, 1 = failure
130 ;* References: PDRD and PSTS methods. OSYS (OS version)
132 ;************************************************************************/
136 // Check for 1. Driver loaded, 2. Driver ready.
137 // If any of these cases is not met, skip this event and return failure.
141 Return(0x1) // Return failure if driver not loaded.
144 Store(Arg0, CEVT) // Set up the current event value
145 Store(3, CSTS) // CSTS=BIOS dispatched an event
147 If(LAnd(LEqual(CHPD, 0), LEqual(Arg1, 0))) // Do not re-enum if driver supports hotplug
149 If(LOr(LGreater(OSYS, 2000), LLess(OSYS, 2006)))
152 // WINXP requires that the entire PCI Bridge be re-enumerated.
154 Notify(\_SB.PCI0, Arg1)
159 // Re-enumerate the Graphics Device for non-XP operating systems.
161 Notify(\_SB.PCI0.GFX0, Arg1)
165 Notify(\_SB.PCI0.GFX0,0x80)
168 Return(0x0) // Return success
172 /************************************************************************;
176 ;* Description: Handle a hotkey display switching event (performs a
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.
182 ;* Input: Arg0 = Toggle table number.
184 ;* Output: Returns 0 = success, 1 = failure.
185 ;* CEVT and TIDX are indirect outputs.
187 ;* References: TIDX, GNOT
189 ;************************************************************************/
193 Store(Arg0, TIDX) // Store the table number
195 // Call GNOT for CEVT = 1 = hotkey, notify value = 0
197 Return(GNOT(1, 0)) // Return stats from GNOT
201 /************************************************************************;
205 ;* Description: Handle a lid event (performs the Notify(GFX0, 0), but not the
208 ;* Usage: This method must be called when a lid event occurs. A
209 ;* Notify(LID0, 0x80) must follow the call to this method.
211 ;* Input: Arg0 = Lid state:
213 ;* 1 = internal LFP lid open
214 ;* 2 = external lid open
215 ;* 3 = both external and internal open
217 ;* Output: Returns 0=success, 1=failure.
218 ;* CLID and CEVT are indirect outputs.
220 ;* References: CLID, GNOT
222 ;************************************************************************/
226 Store(Arg0, CLID) // Store the current lid state
228 // Call GNOT for CEVT=2=Lid, notify value = 0
230 Return(GNOT(2, 0)) // Return stats from GNOT
234 /************************************************************************;
238 ;* Description: Handle a docking event by updating the current docking status
239 ;* and doing a notification.
241 ;* Usage: This method must be called when a docking event occurs.
243 ;* Input: Arg0 = Docking state:
247 ;* Output: Returns 0=success, 1=failure.
248 ;* CDCK and CEVT are indirect outputs.
250 ;* References: CDCK, GNOT
252 ;************************************************************************/
256 Store(Arg0, CDCK) // Store the current dock state
258 // Call GNOT for CEVT=4=Dock, notify value = 0
260 Return(GNOT(4, 0)) // Return stats from GNOT
264 /************************************************************************;
265 ;* ASLE Interrupt Methods
266 ;************************************************************************/
269 /************************************************************************;
273 ;* Description: Check if the driver is ready to handle ASLE interrupts
274 ;* generate by the system BIOS.
276 ;* Usage: This method must be called before generating each ASLE
281 ;* Output: Returns 0 = success, 1 = failure.
283 ;* References: ARDY (Driver readiness), ASLP (Driver recommended sleep
286 ;************************************************************************/
293 // Sleep for ASLP milliseconds if the driver is not ready.
298 // If ARDY is clear, the driver is not ready. If the return value is
299 // !=0, do not generate the ASLE interrupt.
305 /************************************************************************;
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.
315 ;* Usage: This method must called to generate an ASLE interrupt.
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
327 ;* Output: Returns 0 = success, 1 = failure
329 ;* References: PARD method.
331 ;************************************************************************/
336 // Return failure if the requested feature is not supported by the
339 If(LNot(And(TCHE, ShiftLeft(1, Arg0))))
344 // Return failure if the driver is not ready to handle an ASLE
352 // Evaluate the first argument (Panel fitting, backlight brightness, or ALS).
354 If(LEqual(Arg0, 2)) // Arg0 = 2, so request a panel fitting mode change.
356 If(CPFM) // If current mode field is non-zero use it.
358 And(CPFM, 0x0F, Local0) // Create variables without reserved
359 And(EPFM, 0x0F, Local1) // or valid bits.
361 If(LEqual(Local0, 1)) // If current mode is centered,
363 If(And(Local1, 6)) // and if stretched is enabled,
365 Store(6, PFIT) // request stretched.
369 If(And(Local1, 8)) // if aspect ratio is enabled,
371 Store(8, PFIT) // request aspect ratio.
373 Else // Only centered mode is enabled
375 Store(1, PFIT) // so request centered. (No change.)
379 If(LEqual(Local0, 6)) // If current mode is stretched,
381 If(And(Local1, 8)) // and if aspect ratio is enabled,
383 Store(8, PFIT) // request aspect ratio.
387 If(And(Local1, 1)) // if centered is enabled,
389 Store(1, PFIT) // request centered.
391 Else // Only stretched mode is enabled
393 Store(6, PFIT) // so request stretched. (No change.)
397 If(LEqual(Local0, 8)) // If current mode is aspect ratio,
399 If(And(Local1, 1)) // and if centered is enabled,
401 Store(1, PFIT) // request centered.
405 If(And(Local1, 6)) // if stretched is enabled,
407 Store(6, PFIT) // request stretched.
409 Else // Only aspect ratio mode is enabled
411 Store(8, PFIT) // so request aspect ratio. (No change.)
417 // The following code for panel fitting (within the Else condition) is retained for backward compatiblity.
419 Else // If CFPM field is zero use PFIT and toggle the
421 Xor(PFIT,7,PFIT) // mode setting between stretched and centered only.
424 Or(PFIT,0x80000000,PFIT) // Set the valid bit for all cases.
426 Store(4, ASLC) // Store "Panel fitting event" to ASLC[31:1]
430 If(LEqual(Arg0, 1)) // Arg0=1, so set the backlight brightness.
432 Store(Divide(Multiply(Arg1, 255), 100), BCLP) // Convert from percent to 0-255.
434 Or(BCLP, 0x80000000, BCLP) // Set the valid bit.
436 Store(2, ASLC) // Store "Backlight control event" to ASLC[31:1]
440 If(LEqual(Arg0, 0)) // Arg0=0, so set the ALS illuminace
444 Store(1, ASLC) // Store "ALS event" to ASLC[31:1]
448 Return(0x1) // Unsupported function
453 Store(0x01, ASLE) // Generate ASLE interrupt
454 Return(0x0) // Return success
458 /************************************************************************;
462 ;* Description: Checks the presence of the OpRegion and SCI
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.
471 ;* Output: Boolean True = SCI present.
475 ;************************************************************************/
479 If(LNotEqual(OVER,0)) // If OpRegion Version not 0.
481 Return(LNot(GSMI)) // Return True if SCI.
484 Return(0) // Else Return False.