From b895c7562197d90781ebccab0267c250398705fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?King=20K=C3=A9vin?= Date: Mon, 23 Aug 2021 17:34:55 +0200 Subject: [PATCH] main: add character in EDID product name to indicate firewall --- main.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/main.c b/main.c index 8c0c7d8..9d815c7 100644 --- a/main.c +++ b/main.c @@ -170,6 +170,32 @@ static void load_edid(void) // save EDID + extension in EEPROM static bool save_edid(void) { + // modify EDID to include the character indicating the firewall + const char firewall_indicator = '|'; // sun character to indicate the firewall + // ensure descriptor 4 is for Display name + if ((0 == edid[108]) && (0 == edid[109]) && (0 == edid[110]) && (0xfc == edid[111]) && (0 == edid[112])) { // ensure descriptor 4 is for Display name + uint8_t last_c; // position of last character + for (last_c = 113; last_c < 126 && edid[last_c] != '\n'; last_c++); // find position for inserting our character + if (firewall_indicator != edid[last_c - 1]) { // the last character is not yet the sun + if (last_c > 125) { // ensure we insert as the last possible character + last_c = 125; + } + edid[last_c++] = firewall_indicator; // insert sun + if (last_c < 126) { + edid[last_c++] = '\n'; // insert LF to terminate string + } + while (last_c < 126) { + edid[last_c++] = ' '; // insert padding space + } + // calculate new checksum + uint8_t checksum = 0; + for (uint8_t i = 0; i < 127; i++) { + checksum += edid[i]; + } + edid[127] = (256 - checksum); + } + } + return ram_eeprom_blockprog(edid, edid_length()); }