Kernel/Graphics: Ensure generic EDID always has correct checksum

This commit is contained in:
Liav A 2022-06-10 22:36:43 +03:00 committed by Linus Groh
parent 938d579d16
commit 3d36b194d1
Notes: sideshowbarker 2024-07-17 10:19:51 +09:00

View file

@ -155,6 +155,14 @@ ErrorOr<void> DisplayConnector::initialize_edid_for_generic_monitor()
0x00, /* number of extensions */
0x00 /* checksum goes here */
};
// Note: Fix checksum to avoid warnings about checksum mismatch.
size_t checksum = 0;
// Note: Read all 127 bytes to add them to the checksum. Byte 128 is zeroed so
// we could technically add it to the sum result, but it could lead to an error if it contained
// a non-zero value, so we are not using it.
for (size_t index = 0; index < sizeof(virtual_monitor_edid) - 1; index++)
checksum += virtual_monitor_edid[index];
virtual_monitor_edid[127] = 0x100 - checksum;
set_edid_bytes(virtual_monitor_edid);
return {};
}