Used at OS start if EFI_SUCCESS then result in gSettings.CustomEDID != NULL first priority is CustomEDID second is UEFI EDID from EdidDiscoveredProtocol
| 101 | // first priority is CustomEDID |
| 102 | // second is UEFI EDID from EdidDiscoveredProtocol |
| 103 | EFI_STATUS GetEdidDiscovered(VOID) |
| 104 | { |
| 105 | EFI_STATUS Status = EFI_SUCCESS; |
| 106 | UINTN N = 0; |
| 107 | UINT8 NewChecksum; |
| 108 | //gEDID = NULL; |
| 109 | |
| 110 | if (gSettings.CustomEDID) { |
| 111 | N = gSettings.CustomEDIDsize; |
| 112 | DebugDumpEDID("--- Custom EDID Table", N); |
| 113 | } else { |
| 114 | Status = gBS->LocateProtocol (&gEfiEdidDiscoveredProtocolGuid, NULL, (VOID **)&EdidDiscovered); |
| 115 | if (!EFI_ERROR(Status)) { //discovered |
| 116 | N = EdidDiscovered->SizeOfEdid; |
| 117 | if (!GlobalConfig.DebugLog) { |
| 118 | DBG("EdidDiscovered size=%llu\n", N); |
| 119 | } |
| 120 | if (N == 0) { |
| 121 | return EFI_NOT_FOUND; |
| 122 | } |
| 123 | gSettings.CustomEDID = (__typeof__(gSettings.CustomEDID))AllocateAlignedPages(EFI_SIZE_TO_PAGES(N), 128); |
| 124 | CopyMem(gSettings.CustomEDID, EdidDiscovered->Edid, N); |
| 125 | DebugDumpEDID("--- Discovered EDID Table", N); |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | if (gSettings.CustomEDID) { |
| 130 | // begin patching result |
| 131 | if (gSettings.VendorEDID) { |
| 132 | DBG(" VendorID = 0x%04hx changed to 0x%04hx\n", ((UINT16*)gSettings.CustomEDID)[4], gSettings.VendorEDID); |
| 133 | ((UINT16*)gSettings.CustomEDID)[4] = gSettings.VendorEDID; |
| 134 | } |
| 135 | |
| 136 | if (gSettings.ProductEDID) { |
| 137 | DBG(" ProductID = 0x%04hx changed to 0x%04hx\n", ((UINT16*)gSettings.CustomEDID)[5], gSettings.ProductEDID); |
| 138 | ((UINT16*)gSettings.CustomEDID)[5] = gSettings.ProductEDID; |
| 139 | } |
| 140 | |
| 141 | if (gSettings.EdidFixHorizontalSyncPulseWidth) { |
| 142 | DBG(" HorizontalSyncPulseWidth = 0x%02hhx changed to 0x%02hx\n", ((UINT8*)gSettings.CustomEDID)[63], gSettings.EdidFixHorizontalSyncPulseWidth); |
| 143 | UINT8 LsBits, MsBits; |
| 144 | LsBits = gSettings.EdidFixHorizontalSyncPulseWidth & 0xff; |
| 145 | MsBits = (gSettings.EdidFixHorizontalSyncPulseWidth >> 8) & 0x03; |
| 146 | ((UINT8*)gSettings.CustomEDID)[63] = LsBits; |
| 147 | LsBits = ((UINT8*)gSettings.CustomEDID)[65] & ~0x30; |
| 148 | ((UINT8*)gSettings.CustomEDID)[65] = LsBits | (MsBits << 4); |
| 149 | } |
| 150 | |
| 151 | if (gSettings.EdidFixVideoInputSignal) { |
| 152 | DBG(" VideoInputSignal = 0x%02hhx changed to 0x%02hhx\n", ((UINT8*)gSettings.CustomEDID)[20], gSettings.EdidFixVideoInputSignal); |
| 153 | ((UINT8*)gSettings.CustomEDID)[20] = gSettings.EdidFixVideoInputSignal; |
| 154 | } |
| 155 | |
| 156 | NewChecksum = (UINT8)(256 - Checksum8(gSettings.CustomEDID, 127)); |
| 157 | if ((gSettings.VendorEDID) || (gSettings.ProductEDID) || (gSettings.EdidFixHorizontalSyncPulseWidth) || (gSettings.EdidFixVideoInputSignal)) { |
| 158 | ((UINT8*)gSettings.CustomEDID)[127] = NewChecksum; |
| 159 | DebugDumpEDID("--- Patched EDID Table", N); |
| 160 | } else if (((UINT8*)gSettings.CustomEDID)[127] != NewChecksum) { |
no test coverage detected