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 AMD iGPU detection via device-id (V2) #98

Merged
merged 22 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
2e1816b
Change AMD iGPU detection
Zormeister Mar 12, 2023
1d0b5f7
Merge branch 'acidanthera:master' into master
Zormeister Jun 14, 2023
a53c1bb
Merge branch 'acidanthera:master' into master
Zormeister Jul 14, 2023
e455f32
Merge branch 'acidanthera:master' into master
Zormeister Aug 17, 2023
17c3c6c
Proper Device ID detection rather than just marking all AMD devices a…
Zormeister Nov 25, 2023
9ac77d1
remove the etxra 0x9800 check
Zormeister Mar 25, 2024
3f0191b
Merge branch 'acidanthera:master' into master
Zormeister Jun 11, 2024
363b2a6
Merge branch 'acidanthera:master' into master
Zormeister Aug 8, 2024
2417095
Fixup typo
Zormeister Aug 8, 2024
8f688b5
revert formatting changes from the first iGPU detection change commit
Zormeister Aug 8, 2024
52f9370
convert generic integers to constants
Zormeister Aug 17, 2024
76e4505
Merge branch 'acidanthera:master' into master
Zormeister Aug 20, 2024
aebdbe5
Merge branch 'acidanthera:master' into master
Zormeister Aug 27, 2024
4a02d26
attempt to fix Ryzen iGPU detection
Zormeister Aug 27, 2024
3565599
wrong object, it's pciobj
Zormeister Aug 27, 2024
95299fc
Update comments
Zormeister Aug 27, 2024
e46f4f7
change some variable names, fix the name print, also print what gener…
Zormeister Aug 28, 2024
c786014
remove some debugging information and fixup the formatting
Zormeister Aug 28, 2024
7e7ba3f
fix indentation at line 284
Zormeister Aug 28, 2024
147c098
remove comment
Zormeister Aug 28, 2024
a0438bc
what?
Zormeister Aug 28, 2024
6dd0782
relocate duplicated code to a standalone function
Zormeister Aug 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions Lilu/Headers/kern_devinfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,41 @@ class DeviceInfo {
static constexpr uint32_t ConnectorLessCoffeeLakePlatformId5 {0x9BC50003};
static constexpr uint32_t ConnectorLessCoffeeLakePlatformId6 {0x9BC40003};

/**
* Kaveri, and also catches the new Granite Ridge rDNA 2 iGPU.
*/
static constexpr uint32_t GenericAMDKvGr = 0x1300;

/**
* Kabini, Mullins, Carrizo, Stoney Ridge, Wrestler.
*/
static constexpr uint32_t GenericAMDKbMlCzStnWr = 0x9800;

/**
* Raven/Raven2, Picasso, Barcelo, Phoenix & Phoenix 2 (?)
*/
static constexpr uint32_t GenericAMDRvPcBcPhn = 0x1500;

/**
* Renoir, Cezanne, Lucienne, Van Gogh, Rembrandt, Raphael.
*/
static constexpr uint32_t GenericAMDRnCznLcVghRmbRph = 0x1600;

/**
* Trinity
*/
static constexpr uint32_t GenericAMDTrinity = 0x9900;

/**
* Sumo & Sumo2?
*/
static constexpr uint32_t GenericAMDSumo = 0x9600;

/**
* Phoenix.
*/
static constexpr uint32_t GenericAMDPhoenix2 = 0x1900;

public:
/**
* Vesa framebuffer identifier
Expand Down
47 changes: 43 additions & 4 deletions Lilu/Sources/kern_devinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,25 @@ 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;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you make this one a function? I do not like it being copy-pasted below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can do.

WIOKit::getOSDataValue(obj, "device-id", dev);
dev &= 0xFF00;
switch (dev) {
case GenericAMDKvGr:
case GenericAMDRvPcBcPhn:
case GenericAMDRnCznLcVghRmbRph:
case GenericAMDPhoenix2:
case GenericAMDSumo:
case GenericAMDKbMlCzStnWr:
case GenericAMDTrinity:
DBGLOG("dev", "found IGPU device %s", safeString(name));
videoBuiltin = obj;
requestedExternalSwitchOff |= videoBuiltin->getProperty(RequestedExternalSwitchOffName) != nullptr;
break;
default:
break;
}
} 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 @@ -245,6 +264,30 @@ void DeviceInfo::grabDevicesFromPciRoot(IORegistryEntry *pciRoot) {
pcicode == WIOKit::ClassCode::VGAController ||
pcicode == WIOKit::ClassCode::Ex3DController ||
pcicode == WIOKit::ClassCode::XGAController) {
if (pcivendor == WIOKit::VendorID::ATIAMD) {
// The iGPU can live in places other than the root bridge.
// This can be seen in Ryzen Mobile.
// This may be why the older iGPUs had issues, as the device seemingly lives under the root bridge on those platforms.
uint32_t pcidev = 0;
// change to read from PCI config space?
WIOKit::getOSDataValue(pciobj, "device-id", pcidev);
pcidev &= 0xFF00;
switch (pcidev) {
case GenericAMDKvGr:
case GenericAMDRvPcBcPhn:
case GenericAMDRnCznLcVghRmbRph:
case GenericAMDPhoenix2:
case GenericAMDSumo:
case GenericAMDKbMlCzStnWr:
case GenericAMDTrinity:
DBGLOG("dev", "found IGPU device %s at %s", safeString(pciobj->getName()), safeString(name));
videoBuiltin = pciobj;
requestedExternalSwitchOff |= videoBuiltin->getProperty(RequestedExternalSwitchOffName) != nullptr;
continue;
default:
break;
}
}
DBGLOG("dev", "found GFX0 device %s at %s by %04X",
safeString(pciobj->getName()), safeString(name), pcivendor);
v.video = pciobj;
Expand Down Expand Up @@ -272,10 +315,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