Skip to content

Commit

Permalink
Fix EDID update
Browse files Browse the repository at this point in the history
  • Loading branch information
benbaker76 committed Jan 18, 2021
1 parent 6fce8b8 commit a1c781e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 23 deletions.
8 changes: 4 additions & 4 deletions Hackintool.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@
CODE_SIGN_INJECT_BASE_ENTITLEMENTS = NO;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 0351;
CURRENT_PROJECT_VERSION = 0352;
DEVELOPMENT_TEAM = 5LGHPJM9ZR;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_STRICT_OBJC_MSGSEND = NO;
Expand All @@ -732,7 +732,7 @@
INFOPLIST_FILE = "Hackintool/Hackintool-Info.plist";
LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks @executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.9;
MARKETING_VERSION = 3.5.1;
MARKETING_VERSION = 3.5.2;
PRODUCT_BUNDLE_IDENTIFIER = com.Headsoft.Hackintool;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -753,7 +753,7 @@
CODE_SIGN_INJECT_BASE_ENTITLEMENTS = NO;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 0351;
CURRENT_PROJECT_VERSION = 0352;
DEVELOPMENT_TEAM = 5LGHPJM9ZR;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_STRICT_OBJC_MSGSEND = NO;
Expand All @@ -768,7 +768,7 @@
INFOPLIST_FILE = "Hackintool/Hackintool-Info.plist";
LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks @executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.9;
MARKETING_VERSION = 3.5.1;
MARKETING_VERSION = 3.5.2;
PRODUCT_BUNDLE_IDENTIFIER = com.Headsoft.Hackintool;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
47 changes: 28 additions & 19 deletions Hackintool/FixEDID.m
Original file line number Diff line number Diff line change
Expand Up @@ -636,17 +636,17 @@ + (void)makeIOProviderMergeProperties:(NSMutableDictionary **)ioProviderMergePro
*ioProviderMergeProperties = [NSMutableDictionary dictionaryWithObjectsAndKeys:productName, @"DisplayProductName", @(productID), @"DisplayProductID", @(vendorID), @"DisplayVendorID", @(displaySerial), @"DisplaySerialNumber", edidData, @"IODisplayEDID", [NSData dataWithBytes:capabilityString length:strlen(capabilityString)], @"IODisplayCapabilityString", [NSData dataWithBytes:connectFlags length:4], @"IODisplayConnectFlags", [NSData dataWithBytes:controllerID length:4], @"IODisplayControllerID", [NSData dataWithBytes:firmwareLevel length:4], @"IODisplayFirmwareLevel", [NSData dataWithBytes:mccsVersion length:4], @"IODisplayMCCSVersion", [NSData dataWithBytes:technologyType length:4], @"IODisplayTechnologyType", [[display.prefsKey stringByDeletingLastPathComponent] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@-%x-%x", displayClass, vendorID, productID]], @"IODisplayPrefsKey", displayClass, @"IOClass", nil];
}

+ (void)getEDIDData:(Display *)display edidData:(NSData **)edidData
+ (void)getEDIDData:(Display *)display edidOrigData:(NSData *)edidOrigData edidData:(NSData **)edidData
{
EDID edid {};

if (display.eDID.bytes == nil)
if (edidOrigData.bytes == nil)
return;

if (display.eDID.length < sizeof(EDID))
if (edidOrigData.length < sizeof(EDID))
return;

memcpy(&edid, display.eDID.bytes, sizeof(EDID));
memcpy(&edid, edidOrigData.bytes, sizeof(EDID));

switch(display.eDIDIndex)
{
Expand Down Expand Up @@ -738,7 +738,7 @@ + (void)getEDIDData:(Display *)display edidData:(NSData **)edidData
break;
}

*edidData = [NSData dataWithBytes:display.eDID.bytes length:display.eDID.length];
*edidData = [NSData dataWithBytes:edidOrigData.bytes length:edidOrigData.length];

memcpy((void *)(*edidData).bytes, &edid, sizeof(EDID));
}
Expand All @@ -751,41 +751,50 @@ + (void)makeEDIDFiles:(Display *)display
NSString *productName = display.name;
NSNumber *productIDNumber = @0;
NSNumber *vendorIDNumber = @0;
NSData *edidData = nil;

[FixEDID getEDIDData:display edidData:&edidData];

if (edidData == nil)
EDID edid {};
NSData *edidOrigData = display.eDID, *edidData = nil;

if (edidOrigData == nil)
{
switch(display.eDIDIndex)
{
case 0: // Display
edidData = [NSData dataWithBytes:iMacRetina_EDID length:128];
memcpy(&edid, iMacRetina_EDID, 128);
break;
case 2: // iMac
edidData = [NSData dataWithBytes:iMac_EDID length:128];
memcpy(&edid, iMac_EDID, 128);
break;
case 3: // RetinaiMac
edidData = [NSData dataWithBytes:iMacRetina_EDID length:128];
memcpy(&edid, iMacRetina_EDID, 128);
break;
case 4: // MacbookPro
edidData = [NSData dataWithBytes:MBP_EDID length:128];
memcpy(&edid, MBP_EDID, 128);
break;
case 5: // MacbookAir
edidData = [NSData dataWithBytes:MBA_EDID length:128];
memcpy(&edid, MBA_EDID, 128);
break;
case 6: // CinemaHD
edidData = [NSData dataWithBytes:CHD_EDID length:128];
memcpy(&edid, CHD_EDID, 128);
break;
case 7: // Thunderbolt
edidData = [NSData dataWithBytes:TDB_EDID length:128];
memcpy(&edid, TDB_EDID, 128);
break;
case 8: // LEDCinema
edidData = [NSData dataWithBytes:LED_EDID length:128];
memcpy(&edid, LED_EDID, 128);
break;
}

edid.SerialInfo.VendorID[0] = display.vendorID >> 16;
edid.SerialInfo.VendorID[1] = display.vendorID & 0xFFFF;

edid.SerialInfo.ProductID[0] = display.productID & 0xFFFF;
edid.SerialInfo.ProductID[1] = display.productID >> 16;

edidOrigData = [NSData dataWithBytes:&edid length:128];
}

[FixEDID getEDIDData:display edidOrigData:edidOrigData edidData:&edidData];

switch(display.eDIDIndex)
{
case 0: // Display
Expand Down Expand Up @@ -967,7 +976,7 @@ + (void)makeEDIDFiles:(Display *)display
newDisplayOverridePath = [newDisplayOverridePath stringByAppendingPathComponent:[NSString stringWithFormat:@"DisplayProductID-%x", display.productID]];

[edidOverride writeToFile:newDisplayOverridePath atomically:YES];
[display.eDID writeToFile:edidOrigBinPath atomically:YES];
[edidOrigData writeToFile:edidOrigBinPath atomically:YES];
[edidData writeToFile:edidBinPath atomically:YES];

#ifdef USE_USBMERGENUB
Expand Down

0 comments on commit a1c781e

Please sign in to comment.