diff --git a/Manual/SSDT-PNLF.dsl b/Manual/SSDT-PNLF.dsl
new file mode 100644
index 00000000..2a4354f3
--- /dev/null
+++ b/Manual/SSDT-PNLF.dsl
@@ -0,0 +1,51 @@
+// Adding PNLF device for WhateverGreen.kext and others.
+// This is a simplified PNLF version originally taken from RehabMan/OS-X-Clover-Laptop-Config repository:
+// https://raw.githubusercontent.com/RehabMan/OS-X-Clover-Laptop-Config/master/hotpatch/SSDT-PNLF.dsl
+// Rename GFX0 to anything else if your IGPU name is different.
+//
+// Licensed under GNU General Public License v2.0
+// https://github.com/RehabMan/OS-X-Clover-Laptop-Config/blob/master/License.md
+
+DefinitionBlock ("", "SSDT", 2, "ACDT", "PNLF", 0x00000000)
+{
+ External (_SB_.PCI0.GFX0, DeviceObj) // (from opcode)
+
+ Scope (\_SB.PCI0.GFX0)
+ {
+ // For backlight control
+ Device (PNLF)
+ {
+ // Name(_ADR, Zero)
+ Name (_HID, EisaId ("APP0002")) // _HID: Hardware ID
+ Name (_CID, "backlight") // _CID: Compatible ID
+ // _UID is set depending on PWMMax to match profiles in WhateverGreen.kext https://github.com/acidanthera/WhateverGreen/blob/1.4.7/WhateverGreen/kern_weg.cpp#L32
+ // 14: Sandy/Ivy 0x710
+ // 15: Haswell/Broadwell 0xad9
+ // 16: Skylake/KabyLake 0x56c (and some Haswell, example 0xa2e0008)
+ // 17: custom LMAX=0x7a1
+ // 18: custom LMAX=0x1499
+ // 19: CoffeeLake 0xffff
+ // 99: Other (requires custom profile using WhateverGreen.kext via DeviceProperties applbkl-name and applbkl-data)
+ Name (_UID, Zero) // _UID: Unique ID
+ Method (_STA, 0, NotSerialized) // _STA: Status
+ {
+ If (_OSI ("Darwin"))
+ {
+ Return (0x0B)
+ }
+ Else
+ {
+ Return (Zero)
+ }
+ }
+ }
+
+ Method (SUID, 1, NotSerialized)
+ {
+ ^PNLF._UID = ToInteger (Arg0)
+ // Return PNLF device name in case of conflict
+ Return ("PNLF")
+ }
+ }
+}
+
diff --git a/WhateverGreen/Info.plist b/WhateverGreen/Info.plist
index a25f305e..2d23e898 100644
--- a/WhateverGreen/Info.plist
+++ b/WhateverGreen/Info.plist
@@ -71,6 +71,8 @@
10.0.0
com.apple.kpi.unsupported
10.0.0
+ com.apple.iokit.IOACPIFamily
+ 1.0.0d1
com.apple.iokit.IOPCIFamily
1.0.0b1
as.vit9696.Lilu
diff --git a/WhateverGreen/kern_weg.cpp b/WhateverGreen/kern_weg.cpp
index ff99f15e..1178e051 100644
--- a/WhateverGreen/kern_weg.cpp
+++ b/WhateverGreen/kern_weg.cpp
@@ -11,6 +11,7 @@
#include
#include "kern_weg.hpp"
+#include
#include
// This is a hack to let us access protected properties.
@@ -375,6 +376,47 @@ void WEG::processKext(KernelPatcher &patcher, size_t index, mach_vm_address_t ad
return;
}
+uint32_t processUID(uint32_t deviceid) {
+ uint32_t uid = 0;
+ // list from SSDT-PNLF, use CpuGeneration instead?
+ switch (deviceid) {
+ // Sandy HD3000
+ case 0x010b: case 0x0102:
+ case 0x0106: case 0x1106: case 0x1601: case 0x0116: case 0x0126:
+ case 0x0112: case 0x0122:
+ // Ivy
+ case 0x0152: case 0x0156: case 0x0162: case 0x0166:
+ case 0x016a:
+ // Arrandale
+ case 0x0046: case 0x0042:
+ uid = 14;
+ break;
+
+ // CoffeeLake and Whiskey Lake and CometLake and IceLake
+ case 0x3e9b: case 0x3ea5: case 0x3e92: case 0x3e91: case 0x3ea0: case 0x3ea6: case 0x3e98:
+ case 0x9bc8: case 0x9bc5: case 0x9bc4: case 0xff05: case 0x8a70: case 0x8a71: case 0x8a51:
+ case 0x8a5c: case 0x8a5d: case 0x8a52: case 0x8a53: case 0x8a56: case 0x8a5a: case 0x8a5b:
+ case 0x9b41: case 0x9b21: case 0x9bca: case 0x9ba4:
+ uid = 19;
+ break;
+
+ // Haswell
+ case 0x0d26: case 0x0a26: case 0x0d22: case 0x0412: case 0x0416: case 0x0a16: case 0x0a1e: case 0x0a2e: case 0x041e: case 0x041a:
+ // Broadwell
+ case 0x0bd1: case 0x0bd2: case 0x0bd3: case 0x1606: case 0x160e: case 0x1616: case 0x161e: case 0x1626: case 0x1622: case 0x1612: case 0x162b:
+ uid = 15;
+ break;
+
+ // assume Skylake/KabyLake/KabyLake-R
+ // 0x1916, 0x191E, 0x1926, 0x1927, 0x1912, 0x1932, 0x1902, 0x1917, 0x191b,
+ // 0x5916, 0x5912, 0x591b, others...
+ default:
+ uid = 16;
+ break;
+ }
+ return uid;
+}
+
void WEG::processBuiltinProperties(IORegistryEntry *device, DeviceInfo *info) {
auto name = device->getName();
@@ -424,6 +466,34 @@ void WEG::processBuiltinProperties(IORegistryEntry *device, DeviceInfo *info) {
DBGLOG("weg", "hooked configRead read methods!");
}
}
+
+ // Set PNLF _UID by device-id
+ if (auto adev = OSDynamicCast(IOACPIPlatformDevice, obj->getProperty("acpi-device"))) {
+ if (adev->validateObject("SUID") == kIOReturnSuccess) {
+ uint32_t target = processUID(fakeDevice ?: realDevice);
+ OSObject *params[] = { OSNumber::withNumber(target, 32) };
+ OSObject *result;
+ if (adev->evaluateObject("SUID", &result, params, 1) == kIOReturnSuccess) {
+ DBGLOG("weg", "set PNLF _UID to 0x%x", target);
+ } else {
+ SYSLOG("weg", "set PNLF _UID failed");
+ }
+ params[0]->release();
+ // Override _UID property in ioreg with new value
+ OSString *path = OSDynamicCast(OSString, result);
+ auto child = adev->childFromPath(path ? path->getCStringNoCopy() : "PNLF", gIOACPIPlane);
+ if (auto pnlf = OSDynamicCast(IOACPIPlatformDevice, child)) {
+ OSObject *uid = nullptr;
+ if (pnlf->evaluateObject("_UID", &uid) == kIOReturnSuccess)
+ pnlf->setProperty("_UID", uid);
+ OSSafeReleaseNULL(uid);
+ }
+ OSSafeReleaseNULL(result);
+ OSSafeReleaseNULL(child);
+ } else {
+ DBGLOG("weg", "PNLF does not support _UID set");
+ }
+ }
} else {
SYSLOG("weg", "invalid IGPU device type");
}