fix crc extensions checking
This commit is contained in:
parent
7ba053d34f
commit
8bc856095e
16
main.c
16
main.c
|
@ -136,19 +136,21 @@ static uint16_t edid_length(const uint8_t* edid)
|
|||
|
||||
if (1 == edid[18]) { // EDID 1.3/1.4 128-byte structure
|
||||
if (checksum_ok(&edid[0], 128)) { // ensure checksum of base EDID is ok
|
||||
const uint16_t length = 128 + (1 + edid[126]) * 128; // get length with all extensions
|
||||
puts("(v1.4 ");
|
||||
const uint16_t length = 128 + edid[126] * 128; // get length with all extensions
|
||||
puts("(v1.3/1.4, ");
|
||||
putn(edid[126] / 100);
|
||||
putn((edid[126] / 10) % 10);
|
||||
putn(edid[126] % 10);
|
||||
puts(" extension) ");
|
||||
for (uint16_t i = 128; i < length && i < 256; i += 128) { // verify checksum of each extension (we actually only support one extension)
|
||||
if (!checksum_ok(&edid[i], 128)) {
|
||||
puts("extension CRC error\r\n");
|
||||
return 0; // EDID is broken
|
||||
if (edid[126]) { // extensions are present
|
||||
for (uint16_t i = 128; i < length && i < 256; i += 128) { // verify checksum of each extension (we actually only support one extension)
|
||||
if (!checksum_ok(&edid[i], 128)) {
|
||||
puts("extension CRC error\r\n");
|
||||
return 0; // EDID is broken
|
||||
}
|
||||
}
|
||||
}
|
||||
puts("CRC ok\r\n");
|
||||
puts("CRC OK\r\n");
|
||||
return length;
|
||||
} else {
|
||||
puts("base CRC error\r\n");
|
||||
|
|
Loading…
Reference in New Issue