Advertisement
kradnozd

RehabMan Brightness Fix Haswell

Jan 27th, 2015
585
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.06 KB | None | 0 0
  1. #Maintained by: RehabMan for: Laptop Patches
  2. #graphics_PNLF_haswell.txt
  3.  
  4. # This patch enables the brightness slider in SysPrefs->Displays
  5. # and will also enable activation of sleep mode by closing
  6. # the laptop lid.
  7. #
  8. # This particular version is intended to be used with ACPIBacklight.kext
  9. # although it can also be used with AppleBacklight.kext,
  10. # provided AppleBacklight.kext is patched to recognize your
  11. # display or an injector is used to set brightness levels.
  12. #
  13. # See this thread for more information:
  14. # http://www.tonymacx86.com/hp-probook-mavericks/121031-native-brightness-working-without-blinkscreen-using-patched-applebacklight-kext.html
  15. # (also read any linked threads)
  16. #
  17. # Note: This patch should be applied to the DSDT or SSDT that defines
  18. # your integrated graphics device (always at _ADR 0x00020000)
  19. #
  20.  
  21. into_all device label PNLF remove_entry;
  22. into_all device name_adr 0x00020000 code_regex (OperationRegion\s\(RMPC,\sPCI_Config[^\}]*\}) remove_matched;
  23.  
  24. into device name_adr 0x00020000 insert
  25. begin
  26. OperationRegion (RMPC, PCI_Config, 0x10, 4)\n
  27. Field (RMPC, AnyAcc, NoLock, Preserve)\n
  28. {\n
  29. BAR1,32,\n
  30. }\n
  31. Device (PNLF)\n
  32. {\n
  33. // normal PNLF declares (note some of this probably not necessary)\n
  34. Name (_ADR, Zero)\n
  35. Name (_HID, EisaId ("APP0002"))\n
  36. Name (_CID, "backlight")\n
  37. Name (_UID, 15)\n
  38. Name (_STA, 0x0B)\n
  39. //define hardware register access for brightness\n
  40. // lower nibble of BAR1 is status bits and not part of the address\n
  41. OperationRegion (BRIT, SystemMemory, And(^BAR1, Not(0xF)), 0xe1184)\n
  42. Field (BRIT, AnyAcc, Lock, Preserve)\n
  43. {\n
  44. Offset(0x48250),\n
  45. LEV2, 32,\n
  46. LEVL, 32,\n
  47. Offset(0x70040),\n
  48. P0BL, 32,\n
  49. Offset(0xc8250),\n
  50. LEVW, 32,\n
  51. LEVX, 32,\n
  52. Offset(0xe1180),\n
  53. PCHL, 32,\n
  54. }\n
  55. // LMAX: use 0xad9/0x56c/0x5db to force OS X value\n
  56. // or use any arbitrary value\n
  57. // or use 0 to capture BIOS setting\n
  58. Name (LMAX, 0xad9)\n
  59. // KMAX: defines the unscaled range in the _BCL table below\n
  60. Name (KMAX, 0xad9)\n
  61. // _INI deals with differences between native setting and desired\n
  62. Method (_INI, 0, NotSerialized)\n
  63. {\n
  64. // This 0xC value comes from looking what OS X initializes this\n
  65. // register to after display sleep (using ACPIDebug/ACPIPoller)\n
  66. Store(0xC0000000, LEVW)\n
  67. // determine LMAX to use\n
  68. If (LNot(LMAX)) { Store(ShiftRight(LEVX,16), LMAX) }\n
  69. If (LNot(LMAX)) { Store(KMAX, LMAX) }\n
  70. If (LNotEqual(LMAX, KMAX))\n
  71. {\n
  72. // Scale all the values in _BCL to the PWM max in use\n
  73. Store(0, Local0)\n
  74. While (LLess(Local0, SizeOf(_BCL)))\n
  75. {\n
  76. Store(DerefOf(Index(_BCL,Local0)), Local1)\n
  77. Divide(Multiply(Local1,LMAX), KMAX,, Local1)\n
  78. Store(Local1, Index(_BCL,Local0))\n
  79. Increment(Local0)\n
  80. }\n
  81. // Also scale XRGL and XRGH values\n
  82. Divide(Multiply(XRGL,LMAX), KMAX,, XRGL)\n
  83. Divide(Multiply(XRGH,LMAX), KMAX,, XRGH)\n
  84. }\n
  85. // adjust values to desired LMAX\n
  86. Store(ShiftRight(LEVX,16), Local1)\n
  87. If (LNotEqual(Local1, LMAX))\n
  88. {\n
  89. Store(And(LEVX,0xFFFF), Local0)\n
  90. If (LOr(LNot(Local0),LNot(Local1))) { Store(LMAX, Local0) Store(LMAX, Local1) }\n
  91. Divide(Multiply(Local0,LMAX), Local1,, Local0)\n
  92. //REVIEW: wait for vblank before setting new PWM config\n
  93. //Store(P0BL, Local7)\n
  94. //While (LEqual (P0BL, Local7)) {}\n
  95. Store(Or(Local0,ShiftLeft(LMAX,16)), LEVX)\n
  96. }\n
  97. }\n
  98. // _BCM/_BQC: set/get for brightness level\n
  99. Method (_BCM, 1, NotSerialized)\n
  100. {\n
  101. // store new backlight level\n
  102. Store(Match(_BCL, MGE, Arg0, MTR, 0, 2), Local0)\n
  103. If (LEqual(Local0, Ones)) { Subtract(SizeOf(_BCL), 1, Local0) }\n
  104. Store(Or(DerefOf(Index(_BCL,Local0)),ShiftLeft(LMAX,16)), LEVX)\n
  105. }\n
  106. Method (_BQC, 0, NotSerialized)\n
  107. {\n
  108. Store(Match(_BCL, MGE, And(LEVX, 0xFFFF), MTR, 0, 2), Local0)\n
  109. If (LEqual(Local0, Ones)) { Subtract(SizeOf(_BCL), 1, Local0) }\n
  110. Return(DerefOf(Index(_BCL, Local0)))\n
  111. }\n
  112. Method (_DOS, 1, NotSerialized)\n
  113. {\n
  114. // Note: Some systems have this defined in DSDT, so uncomment\n
  115. // the next line if that is the case.\n
  116. //External(^^_DOS, MethodObj)\n
  117. ^^_DOS(Arg0)\n
  118. }\n
  119. // extended _BCM/_BQC for setting "in between" levels\n
  120. Method (XBCM, 1, NotSerialized)\n
  121. {\n
  122. // store new backlight level\n
  123. If (LGreater(Arg0, XRGH)) { Store(XRGH, Arg0) }\n
  124. If (LAnd(Arg0, LLess(Arg0, XRGL))) { Store(XRGL, Arg0) }\n
  125. Store(Or(Arg0,ShiftLeft(LMAX,16)), LEVX)\n
  126. }\n
  127. Method (XBQC, 0, NotSerialized)\n
  128. {\n
  129. Store(And(LEVX,0xFFFF), Local0)\n
  130. If (LGreater(Local0, XRGH)) { Store(XRGH, Local0) }\n
  131. If (LAnd(Local0, LLess(Local0, XRGL))) { Store(XRGL, Local0) }\n
  132. Return(Local0)\n
  133. }\n
  134. // Use XOPT=1 to disable smooth transitions\n
  135. Name (XOPT, Zero)\n
  136. // XRGL/XRGH: defines the valid range\n
  137. Name (XRGL, 25)\n
  138. Name (XRGH, 2777)\n
  139. // _BCL: returns list of valid brightness levels\n
  140. // first two entries describe ac/battery power levels\n
  141. Name (_BCL, Package()\n
  142. {\n
  143. 2777,\n
  144. 748,\n
  145. 0,\n
  146. 35, 39, 44, 50,\n
  147. 58, 67, 77, 88,\n
  148. 101, 115, 130, 147,\n
  149. 165, 184, 204, 226,\n
  150. 249, 273, 299, 326,\n
  151. 354, 383, 414, 446,\n
  152. 479, 514, 549, 587,\n
  153. 625, 665, 706, 748,\n
  154. 791, 836, 882, 930,\n
  155. 978, 1028, 1079, 1132,\n
  156. 1186, 1241, 1297, 1355,\n
  157. 1414, 1474, 1535, 1598,\n
  158. 1662, 1728, 1794, 1862,\n
  159. 1931, 2002, 2074, 2147,\n
  160. 2221, 2296, 2373, 2452,\n
  161. 2531, 2612, 2694, 2777,\n
  162. })\n
  163. }\n
  164. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement