Set EDID checksum in constructor.

This commit is contained in:
Volker Ruppert 2021-05-13 17:58:57 +00:00
parent 18c8c4bd76
commit aa9045b63f
2 changed files with 21 additions and 13 deletions

View File

@ -149,7 +149,7 @@ const Bit8u vesa_EDID[128] = {
0x0A,
0x00, /* 0x007E Extension block count (none) */
0x94, /* 0x007F Checksum */
0x00, /* 0x007F Checksum (set by constructor) */
};
bx_ddc_c::bx_ddc_c(void)
@ -157,6 +157,7 @@ bx_ddc_c::bx_ddc_c(void)
int fd, ret;
struct stat stat_buf;
const char *path;
Bit8u checksum = 0;
put("DDC");
s.DCKhost = 1;
@ -196,6 +197,13 @@ bx_ddc_c::bx_ddc_c(void)
close(fd);
BX_INFO(("Monitor EDID read from image file '%s'.", path));
}
s.edid_data[127] = 0;
for (int i = 0; i < 128; i++) {
checksum += s.edid_data[i];
}
if (checksum != 0) {
s.edid_data[127] = (Bit8u)-checksum;
}
}
bx_ddc_c::~bx_ddc_c(void)

View File

@ -35,18 +35,18 @@ private:
Bit8u get_edid_byte(void);
struct {
Bit8u ddc_mode;
bool DCKhost;
bool DDAhost;
bool DDAmon;
Bit8u ddc_stage;
Bit8u ddc_bitshift;
bool ddc_ack;
bool ddc_rw;
Bit8u ddc_byte;
Bit8u edid_index;
bool edid_extblock;
Bit8u edid_data[256];
Bit8u ddc_mode;
bool DCKhost;
bool DDAhost;
bool DDAmon;
Bit8u ddc_stage;
Bit8u ddc_bitshift;
bool ddc_ack;
bool ddc_rw;
Bit8u ddc_byte;
Bit8u edid_index;
bool edid_extblock;
Bit8u edid_data[256];
} s; // state information
};