Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add proper AMD Integrated Graphics detection. #97

Merged
merged 12 commits into from
Aug 27, 2024
12 changes: 8 additions & 4 deletions Lilu/Sources/kern_devinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,14 @@ void DeviceInfo::grabDevicesFromPciRoot(IORegistryEntry *pciRoot) {
DBGLOG("dev", "found IGPU device %s", safeString(name));
videoBuiltin = obj;
requestedExternalSwitchOff |= videoBuiltin->getProperty(RequestedExternalSwitchOffName) != nullptr;
} else if (vendor == WIOKit::VendorID::ATIAMD && (code == WIOKit::ClassCode::DisplayController || code == WIOKit::ClassCode::VGAController)) {
uint32_t dev = 0;
WIOKit::getOSDataValue(obj, "device-id", dev);
dev = (dev & 0xFF00);
if ((dev == 0x1600 || dev == 0x1500) || (dev == 0x9800 || dev == 0x1300) || (dev == 0x9900 || dev == 0x9600)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we end up having this code, these numbers must become named constants, so that it is clear which id belongs to which family.

Copy link
Contributor Author

@Zormeister Zormeister Aug 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As for this, the &ing makes the Device ID range more generic so there isn’t a million cases.

0x1500 is commonly associated with AMD’s Raven line, 0x1600 catches devices from Renoir, Van Gogh and Rembrandt

0x1300 catches Kaveri (Spectre) and a certain Granite Ridge iGPU (0x13C0)

0x9800 catches Carrizo, Mullins (Godavari), Kabini (Kalindi) and Stoney

0x9600 and 0x9900 catch some of the legacy TeraScale iGPUs such as Trinity and Richland iirc

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This information must be in the code, not in the comments to the review. Unnamed numeric literals are plain bad, make them named constants.

Copy link
Contributor Author

@Zormeister Zormeister Aug 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was going to do this already, got caught up in other things
pushed out the changes now

lmk if the names need changing at all

DBGLOG("dev", "found IGPU device %s", safeString(name));
videoBuiltin = obj;
}
} else if (code == WIOKit::ClassCode::HDADevice || code == WIOKit::ClassCode::HDAMmDevice) {
if (vendor == WIOKit::VendorID::Intel && name && (!strcmp(name, "HDAU") || !strcmp(name, "B0D3"))) {
DBGLOG("dev", "found HDAU device %s", safeString(name));
Expand Down Expand Up @@ -272,10 +280,6 @@ void DeviceInfo::grabDevicesFromPciRoot(IORegistryEntry *pciRoot) {
// To distinguish the devices we use audio card presence as a marker.
DBGLOG("dev", "marking audio device as HDEF at %s", safeString(v.audio->getName()));
audioBuiltinAnalog = v.audio;

if (v.video && v.vendor == WIOKit::VendorID::ATIAMD) {
videoBuiltin = v.video;
}
}
}
}
Expand Down