From 3d36b194d1732bc92df128559b5d577614674535 Mon Sep 17 00:00:00 2001 From: Liav A Date: Fri, 10 Jun 2022 22:36:43 +0300 Subject: [PATCH] Kernel/Graphics: Ensure generic EDID always has correct checksum --- Kernel/Graphics/DisplayConnector.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Kernel/Graphics/DisplayConnector.cpp b/Kernel/Graphics/DisplayConnector.cpp index 4365575475..bd353f1115 100644 --- a/Kernel/Graphics/DisplayConnector.cpp +++ b/Kernel/Graphics/DisplayConnector.cpp @@ -155,6 +155,14 @@ ErrorOr 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 {}; }