main: add character in EDID product name to indicate firewall

This commit is contained in:
King Kévin 2021-08-23 17:34:55 +02:00
parent eb4e30f79a
commit b895c75621
1 changed files with 26 additions and 0 deletions

26
main.c
View File

@ -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());
}