Skip to content

Commit

Permalink
Initial CFL support
Browse files Browse the repository at this point in the history
  • Loading branch information
vit9696 committed Jul 17, 2018
1 parent 4b5eb44 commit 9dd645c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
15 changes: 13 additions & 2 deletions Lilu/Headers/kern_devinfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,13 @@ class DeviceInfo {
*/
static constexpr const char *ReportedFrameIdArg = "igfxframe";

/**
* The boot-arg to override the reported AAPL,ig-platform-id to Intel drivers.
* Sets VESA framebuffer id (0xFFFFFFFF).
* For user configuration only! Use reportedFramebufferId!
*/
static constexpr const char *ReportedVesaIdArg = "-igfxvesa";

/**
* The property to set your platform id for Intel drivers (Ivy and newer).
* For user configuration only! Use reportedFramebufferName!
Expand All @@ -155,6 +162,7 @@ class DeviceInfo {
*/
static constexpr uint32_t DefaultSkylakePlatformId {0x19120000};
static constexpr uint32_t DefaultKabyLakePlatformId {0x59160000};
static constexpr uint32_t DefaultCoffeeLakePlatformId {0x3EA50000};

/**
* Framebuffers without any ports used for hardware acceleration only
Expand All @@ -173,17 +181,20 @@ class DeviceInfo {
static constexpr uint32_t ConnectorLessSkylakePlatformId4 {0x19320001};
static constexpr uint32_t ConnectorLessKabyLakePlatformId1 {0x59180002};
static constexpr uint32_t ConnectorLessKabyLakePlatformId2 {0x59120003};
static constexpr uint32_t ConnectorLessCoffeeLakePlatformId1 {0x3E920003};
static constexpr uint32_t ConnectorLessCoffeeLakePlatformId2 {0x3E910003};

public:
/**
* Invalid framebuffer identifier
* Vesa framebuffer identifier
*/
static constexpr uint32_t DefaultInvalidPlatformId {0xFFFFFFFF};
static constexpr uint32_t DefaultVesaPlatformId {0xFFFFFFFF};

/**
* Framebuffer id to be reported to IGPU.
* This follows the standard convention initially found in IntelGraphicsFixup:
* igfxframe=X boot-arg has highest priority and overrides any other value.
* -igfxvesa forces 0xFFFFFFFF frame to get into VESA mode.
* Manually specified AAPL,ig-platform-id or AAPL,snb-platform-id go next.
* On Sandy Bridge processors a default AAPL,snb-platform-id will be tried afterwards.
* On Skylake and Kaby Lake processors some default id will be tried afterwards.
Expand Down
23 changes: 17 additions & 6 deletions Lilu/Sources/kern_devinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,14 @@ void DeviceInfo::updateFramebufferId() {

if (PE_parse_boot_argn(ReportedFrameIdArg, &reportedFramebufferId, sizeof(reportedFramebufferId))) {
DBGLOG("dev", "found boot-arg frame id override to %08X", reportedFramebufferId);
} else if (checkKernelArgument(ReportedVesaIdArg)) {
DBGLOG("dev", "found vesa boot-arg frame id");
reportedFramebufferId = DefaultVesaPlatformId;
} else if (WIOKit::getOSDataValue(videoBuiltin, reportedFramebufferName, reportedFramebufferId)) {
DBGLOG("dev", "found property frame id override to %d", reportedFramebufferId);
} else {
auto legacy = getLegacyFramebufferId();
if (gen == CPUInfo::CpuGeneration::SandyBridge && legacy != DefaultInvalidPlatformId) {
if (gen == CPUInfo::CpuGeneration::SandyBridge && legacy != DefaultVesaPlatformId) {
reportedFramebufferId = getLegacyFramebufferId();
} else {
if (videoExternal.size() > 0 && gen != CPUInfo::CpuGeneration::Broadwell) {
Expand All @@ -52,8 +55,10 @@ void DeviceInfo::updateFramebufferId() {
reportedFramebufferId = ConnectorLessSkylakePlatformId3;
else if (gen == CPUInfo::CpuGeneration::KabyLake)
reportedFramebufferId = ConnectorLessKabyLakePlatformId2;
else if (gen == CPUInfo::CpuGeneration::CoffeeLake)
reportedFramebufferId = ConnectorLessCoffeeLakePlatformId2;
else
reportedFramebufferId = DefaultInvalidPlatformId;
reportedFramebufferId = DefaultVesaPlatformId;
} else {
// These are really failsafe defaults, you should NOT rely on them.
auto model = WIOKit::getComputerModel();
Expand All @@ -70,8 +75,10 @@ void DeviceInfo::updateFramebufferId() {
reportedFramebufferId = 0x19160000;
else if (gen == CPUInfo::CpuGeneration::KabyLake)
reportedFramebufferId = 0x591B0000;
else if (gen == CPUInfo::CpuGeneration::CoffeeLake)
reportedFramebufferId = 0x3EA50009;
else
reportedFramebufferId = DefaultInvalidPlatformId;
reportedFramebufferId = DefaultVesaPlatformId;
} else {
if (gen == CPUInfo::CpuGeneration::SandyBridge)
reportedFramebufferId = 0x00030010;
Expand All @@ -85,8 +92,10 @@ void DeviceInfo::updateFramebufferId() {
reportedFramebufferId = DefaultSkylakePlatformId;
else if (gen == CPUInfo::CpuGeneration::KabyLake)
reportedFramebufferId = DefaultKabyLakePlatformId;
else if (gen == CPUInfo::CpuGeneration::CoffeeLake)
reportedFramebufferId = DefaultCoffeeLakePlatformId;
else
reportedFramebufferId = DefaultInvalidPlatformId;
reportedFramebufferId = DefaultVesaPlatformId;
}
}
}
Expand Down Expand Up @@ -168,7 +177,7 @@ uint32_t DeviceInfo::getLegacyFramebufferId() {
SYSLOG("dev", "failed to obtain board-id");
}

return DefaultInvalidPlatformId;
return DefaultVesaPlatformId;
}

bool DeviceInfo::isConnectorLessPlatformId(uint32_t id) {
Expand All @@ -184,7 +193,9 @@ bool DeviceInfo::isConnectorLessPlatformId(uint32_t id) {
id == ConnectorLessSkylakePlatformId3 ||
id == ConnectorLessSkylakePlatformId4 ||
id == ConnectorLessKabyLakePlatformId1 ||
id == ConnectorLessKabyLakePlatformId2;
id == ConnectorLessKabyLakePlatformId2 ||
id == ConnectorLessCoffeeLakePlatformId1 ||
id == ConnectorLessCoffeeLakePlatformId2;
}

void DeviceInfo::grabDevicesFromPciRoot(IORegistryEntry *pciRoot) {
Expand Down

0 comments on commit 9dd645c

Please sign in to comment.