Skip to content

Commit

Permalink
Revert "Fix colour banding issue caused by AGDC logic error"
Browse files Browse the repository at this point in the history
This reverts commit da6376b.
  • Loading branch information
VisualEhrmanntraut committed May 4, 2024
1 parent 2cf2ad6 commit 904b038
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 28 deletions.
21 changes: 0 additions & 21 deletions NootedRed/X6000FB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ bool X6000FB::processKext(KernelPatcher &patcher, size_t id, mach_vm_address_t s
{"__ZNK32AMDRadeonX6000_AmdAsicInfoNavi1027getEnumeratedRevisionNumberEv", wrapGetEnumeratedRevision},
{"__ZNK22AmdAtomObjectInfo_V1_421getNumberOfConnectorsEv", wrapGetNumberOfConnectors,
this->orgGetNumberOfConnectors, kGetNumberOfConnectorsPattern, kGetNumberOfConnectorsMask},
{"__ZN18AmdDalFbTranslator23translateFbToCrtcTimingEP14dc_crtc_timingPK28AmdDetailedTimingInformation",
wrapTranslateFbToCrtcTiming, this->orgTranslateFbToCrtcTiming, kTranslateFbToCrtcTimingPattern,
kTranslateFbToCrtcTimingMask},
};
PANIC_COND(!RouteRequestPlus::routeAll(patcher, id, requests, slide, size), "X6000FB",
"Failed to route symbols");
Expand Down Expand Up @@ -467,21 +464,3 @@ void *X6000FB::wrapLinkCreate(void *data) {
}
return ret;
}

//! Work around colour banding caused by incorrect colour space selection in AGDC.
//! Fixing this properly would most likely involve fixing AGDC.
//! However, as ADGC is mostly stripped and avoids including useful strings,
//! I'd rather not have to indulge in understanding of its decompilation
//! in order to fix this issue, so this will do for now.
//! Thanks Apple, very cool.
IOReturn X6000FB::wrapTranslateFbToCrtcTiming(void *crtcTiming, const void *timing) {
auto ret = FunctionCast(wrapTranslateFbToCrtcTiming, callback->orgTranslateFbToCrtcTiming)(crtcTiming, timing);
auto &depthIndex = getMember<UInt32>(crtcTiming, 0x44);
auto fbColourDepth = *reinterpret_cast<const UInt16 *>(static_cast<const UInt8 *>(timing) + 0x8A);
//! If Depth Index is 2 (10 BPC), but colour space is 888 (8 BPC, 3 components)
if (depthIndex == 2 && fbColourDepth == 2) {
//! Set Depth Index to 1 which is 8 BPC
depthIndex = 1;
}
return ret;
}
7 changes: 0 additions & 7 deletions NootedRed/X6000FB.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class X6000FB {
mach_vm_address_t orgLinkCreate {0};
t_DcLinkSetBacklightLevel orgDcLinkSetBacklightLevel {0};
t_DcLinkSetBacklightLevelNits orgDcLinkSetBacklightLevelNits {0};
mach_vm_address_t orgTranslateFbToCrtcTiming {0};

static bool OnAppleBacklightDisplayLoad(void *target, void *refCon, IOService *newService, IONotifier *notifier);
void registerDispMaxBrightnessNotif();
Expand All @@ -53,7 +52,6 @@ class X6000FB {
static UInt32 wrapControllerPowerUp(void *that);
static void wrapDpReceiverPowerCtrl(void *link, bool power_on);
static void *wrapLinkCreate(void *data);
static IOReturn wrapTranslateFbToCrtcTiming(void *crtcTiming, const void *timing);
};

//------ Patterns ------//
Expand Down Expand Up @@ -110,11 +108,6 @@ static const UInt8 kDcLinkSetBacklightLevelNitsPattern[] = {0x55, 0x48, 0x89, 0x
static const UInt8 kDcLinkSetBacklightLevelNitsMask[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00,
0xFF, 0xFF, 0xFF, 0xFF, 0x00};

static const UInt8 kTranslateFbToCrtcTimingPattern[] = {0x55, 0x48, 0x89, 0xE5, 0x48, 0x85, 0xF6, 0x0F, 0x84, 0x00,
0x00, 0x00, 0x00, 0x48, 0x85, 0xFF, 0x0F, 0x84, 0x00, 0x00, 0x00, 0x00, 0x8B};
static const UInt8 kTranslateFbToCrtcTimingMask[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF};

//------ Patches ------//

//! Fix register read (0xD31 -> 0xD2F) and family ID (0x8F -> 0x8E).
Expand Down

0 comments on commit 904b038

Please sign in to comment.