SHARE
TWEET

3000pnlf

Lizard1003 Sep 15th, 2017 298 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. into_all device label PNLF remove_entry;
  2. into_all device name_adr 0x00020000 code_regex (OperationRegion\s\(RMPC,\sPCI_Config[^\}]*\}) remove_matched;
  3. into device name_adr 0x00020000 insert
  4. begin
  5. OperationRegion (RMPC, PCI_Config, 0x10, 4)\n
  6. Field (RMPC, AnyAcc, NoLock, Preserve)\n
  7. {\n
  8.     BAR1,32,\n
  9. }\n
  10. Device (PNLF)\n
  11. {\n
  12.     // normal PNLF declares (note some of this probably not necessary)\n
  13.     Name (_ADR, Zero)\n
  14.     Name (_HID, EisaId ("APP0002"))\n
  15.     Name (_CID, "backlight")\n
  16.     Name (_UID, 10)\n
  17.     Name (_STA, 0x0B)\n
  18.     //define hardware register access for brightness\n
  19.     // lower nibble of BAR1 is status bits and not part of the address\n
  20.     OperationRegion (BRIT, SystemMemory, And(^BAR1, Not(0xF)), 0xe1184)\n
  21.     Field (BRIT, AnyAcc, Lock, Preserve)\n
  22.     {\n
  23.         Offset(0x48250),\n
  24.         LEV2, 32,\n
  25.         LEVL, 32,\n
  26.         Offset(0x70040),\n
  27.         P0BL, 32,\n
  28.         Offset(0xc8250),\n
  29.         LEVW, 32,\n
  30.         LEVX, 32,\n
  31.         Offset(0xe1180),\n
  32.         PCHL, 32,\n
  33.     }\n
  34.     // DEB1 special for setting KLVX at runtime...\n
  35.     //Method (DEB1, 1, NotSerialized)\n
  36.     //{\n
  37.     //    Store(Arg0, KLVX)\n
  38.     //}\n
  39.     // LMAX: use 0x710 to force OS X value\n
  40.     //       or use any arbitrary value\n
  41.     //       or use 0 to capture BIOS setting\n
  42.     Name (LMAX, 0x710)\n
  43.     // KMAX: defines the unscaled range in the _BCL table below\n
  44.     Name (KMAX, 0x710)\n
  45.     // KPCH: saved value for PCHL\n
  46.     //   use Ones if PCHL does not need to be set (normal)\n
  47.     //   use Zero if your laptop nees PCHL set on every brightness set\n
  48.     //   you can also use a custom value (not Ones, not Zero)\n
  49.     Name(KPCH, Ones)\n
  50.     // _INI deals with differences between native setting and desired\n
  51.     Method (_INI, 0, NotSerialized)\n
  52.     {\n
  53.         // save value of PCHL for later\n
  54.         If (LNot(KPCH)) { Store(PCHL, KPCH) }\n
  55.         // determine LMAX to use\n
  56.         If (LNot(LMAX)) { Store(ShiftRight(LEVX,16), LMAX) }\n
  57.         If (LNot(LMAX)) { Store(KMAX, LMAX) }\n
  58.         Store(ShiftLeft(LMAX,16), KLVX)\n
  59.         If (LNotEqual(LMAX, KMAX))\n
  60.         {\n
  61.             // Scale all the values in _BCL to the PWM max in use\n
  62.             Store(0, Local0)\n
  63.             While (LLess(Local0, SizeOf(_BCL)))\n
  64.             {\n
  65.                 Store(DerefOf(Index(_BCL,Local0)), Local1)\n
  66.                 Divide(Multiply(Local1,LMAX), KMAX,, Local1)\n
  67.                 Store(Local1, Index(_BCL,Local0))\n
  68.                 Increment(Local0)\n
  69.             }\n
  70.             // Also scale XRGL and XRGH values\n
  71.             Divide(Multiply(XRGL,LMAX), KMAX,, XRGL)\n
  72.             Divide(Multiply(XRGH,LMAX), KMAX,, XRGH)\n
  73.         }\n
  74.         // adjust values to desired LMAX\n
  75.         Store(ShiftRight(LEVX,16), Local1)\n
  76.         If (LNotEqual(Local1, LMAX))\n
  77.         {\n
  78.             Store(LEVL, Local0)\n
  79.             If (LOr(LNot(Local0),LNot(Local1))) { Store(LMAX, Local0) Store(LMAX, Local1) }\n
  80.             Divide(Multiply(Local0,LMAX), Local1,, Local0)\n
  81.             //REVIEW: wait for vblank before setting new PWM config\n
  82.             //Store(P0BL, Local7)\n
  83.             //While (LEqual (P0BL, Local7)) {}\n
  84.             If (LGreater(LEVL, LMAX))\n
  85.                 { Store(KLVX, LEVX) Store(Local0, LEVL) }\n
  86.             Else\n
  87.                 { Store(Local0, LEVL) Store(KLVX, LEVX) }\n
  88.         }\n
  89.     }\n
  90.     // _BCM/_BQC: set/get for brightness level\n
  91.     Method (_BCM, 1, NotSerialized)\n
  92.     {\n
  93.         // initialize for consistent backlight level before/after sleep\n
  94.         If (LAnd(LNotEqual(KPCH, Ones),LNotEqual(PCHL, KPCH))) { Store(KPCH, PCHL) }\n
  95.         If (LNotEqual(LEVW, 0x80000000)) { Store (0x80000000, LEVW) }\n
  96.         If (LNotEqual(LEVX, KLVX)) { Store (KLVX, LEVX) }\n
  97.         // store new backlight level\n
  98.         Store(Match(_BCL, MGE, Arg0, MTR, 0, 2), Local0)\n
  99.         If (LEqual(Local0, Ones)) { Subtract(SizeOf(_BCL), 1, Local0) }\n
  100.         If (LNotEqual(LEV2, 0x80000000)) { Store(0x80000000, LEV2) }\n
  101.         Store(DerefOf(Index(_BCL, Local0)), LEVL)\n
  102.     }\n
  103.     Method (_BQC, 0, NotSerialized)\n
  104.     {\n
  105.         Store(Match(_BCL, MGE, LEVL, MTR, 0, 2), Local0)\n
  106.         If (LEqual(Local0, Ones)) { Subtract(SizeOf(_BCL), 1, Local0) }\n
  107.         Return(DerefOf(Index(_BCL, Local0)))\n
  108.     }\n
  109.     Method (_DOS, 1, NotSerialized)\n
  110.     {\n
  111.         // Note: Some systems have this defined in DSDT, so uncomment\n
  112.         // the next line if that is the case.\n
  113.         //External(^^_DOS, MethodObj)\n
  114.         ^^_DOS(Arg0)\n
  115.     }\n
  116.     // extended _BCM/_BQC for setting "in between" levels\n
  117.     Method (XBCM, 1, NotSerialized)\n
  118.     {\n
  119.         // initialize for consistent backlight level before/after sleep\n
  120.         If (LAnd(LNotEqual(KPCH, Ones),LNotEqual(PCHL, KPCH))) { Store(KPCH, PCHL) }\n
  121.         If (LNotEqual(LEVW, 0x80000000)) { Store (0x80000000, LEVW) }\n
  122.         If (LNotEqual(LEVX, KLVX)) { Store (KLVX, LEVX) }\n
  123.         // store new backlight level\n
  124.         If (LGreater(Arg0, XRGH)) { Store(XRGH, Arg0) }\n
  125.         If (LAnd(Arg0, LLess(Arg0, XRGL))) { Store(XRGL, Arg0) }\n
  126.         If (LNotEqual(LEV2, 0x80000000)) { Store(0x80000000, LEV2) } \n
  127.         Store(Arg0, LEVL)\n
  128.     }\n
  129.     Method (XBQC, 0, NotSerialized)\n
  130.     {\n
  131.         Store(LEVL, Local0)\n
  132.         If (LGreater(Local0, XRGH)) { Store(XRGH, Local0) }\n
  133.         If (LAnd(Local0, LLess(Local0, XRGL))) { Store(XRGL, Local0) }\n
  134.         Return(Local0)\n
  135.     }\n
  136.     // Set XOPT bit 0 to disable smooth transitions\n
  137.     // Set XOPT bit 1 to wait for native BacklightHandler\n
  138.     // Set XOPT bit 2 to force use of native BacklightHandler\n
  139.     Name (XOPT, 0x02)\n
  140.     // XRGL/XRGH: defines the valid range\n
  141.     Name (XRGL, 40)\n
  142.     Name (XRGH, 1808)\n
  143.     // KLVX is initialization value for LEVX\n
  144.     Name (KLVX, 0x7100000)\n
  145.     // _BCL: returns list of valid brightness levels\n
  146.     // first two entries describe ac/battery power levels\n
  147.     Name (_BCL, Package()\n
  148.     {\n
  149.         1808,\n
  150.         479,\n
  151.         0,\n
  152.         53, 55, 57, 59,\n
  153.         62, 66, 71, 77,\n
  154.         83, 91, 99, 108,\n
  155.         119, 130, 142, 154,\n
  156.         168, 183, 198, 214,\n
  157.         232, 250, 269, 289,\n
  158.         309, 331, 354, 377,\n
  159.         401, 426, 453, 479,\n
  160.         507, 536, 566, 596,\n
  161.         627, 660, 693, 727,\n
  162.         762, 797, 834, 872,\n
  163.         910, 949, 990, 1031,\n
  164.         1073, 1115, 1159, 1204,\n
  165.         1249, 1296, 1343, 1391,\n
  166.         1440, 1490, 1541, 1592,\n
  167.         1645, 1698, 1753, 1808,\n
  168.     })\n
  169. }\n
  170. end;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top