IgdOMOBF.ASL 14 KB

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