This is an automatic generated email to let you know that the following patch were queued:
Subject: edid-decode: specify checksum position for do_checksum() Author: Hans Verkuil <hverkuil-ci...@xs4all.nl> Date: Wed Jul 31 15:59:01 2024 +0200 This prepares for the upcoming InfoFrame parser where the checksum isn't at the end. So explicitly pass the checksum position to do_checksum(). Signed-off-by: Hans Verkuil <hverkuil-ci...@xs4all.nl> edid-decode.cpp | 13 ++++++++----- edid-decode.h | 3 ++- parse-base-block.cpp | 2 +- parse-displayid-block.cpp | 2 +- 4 files changed, 12 insertions(+), 8 deletions(-) --- diff --git a/edid-decode.cpp b/edid-decode.cpp index ce4f1fd5a4af..4f39ee544598 100644 --- a/edid-decode.cpp +++ b/edid-decode.cpp @@ -249,14 +249,17 @@ void replace_checksum(unsigned char *x, size_t len) x[len - 1] = -sum & 0xff; } -void do_checksum(const char *prefix, const unsigned char *x, size_t len, unsigned unused_bytes) +void do_checksum(const char *prefix, const unsigned char *x, size_t len, size_t checksum_pos, + unsigned unused_bytes) { - unsigned char check = x[len - 1]; + unsigned char check = x[checksum_pos]; unsigned char sum = 0; unsigned i; - for (i = 0; i < len - 1; i++) - sum += x[i]; + for (i = 0; i < len; i++) { + if (i != checksum_pos) + sum += x[i]; + } printf("%sChecksum: 0x%02hhx", prefix, check); if ((unsigned char)(check + sum) != 0) { @@ -1232,7 +1235,7 @@ void edid_state::parse_extension(const unsigned char *x) } data_block.clear(); - do_checksum("", x, EDID_PAGE_SIZE, unused_bytes); + do_checksum("", x, EDID_PAGE_SIZE, EDID_PAGE_SIZE - 1, unused_bytes); } void edid_state::print_preferred_timings() diff --git a/edid-decode.h b/edid-decode.h index 0a06b17a2122..2a06563f0c0b 100644 --- a/edid-decode.h +++ b/edid-decode.h @@ -554,7 +554,8 @@ bool memchk(const unsigned char *x, unsigned len, unsigned char v = 0); void hex_block(const char *prefix, const unsigned char *x, unsigned length, bool show_ascii = true, unsigned step = 16); std::string block_name(unsigned char block); -void do_checksum(const char *prefix, const unsigned char *x, size_t len, unsigned unused_bytes = 0); +void do_checksum(const char *prefix, const unsigned char *x, size_t len, size_t checksum_pos, + unsigned unused_bytes = 0); void replace_checksum(unsigned char *x, size_t len); void calc_ratio(struct timings *t); const char *oui_name(unsigned oui, unsigned *ouinum = NULL); diff --git a/parse-base-block.cpp b/parse-base-block.cpp index 6565932f24a7..e97dad42539b 100644 --- a/parse-base-block.cpp +++ b/parse-base-block.cpp @@ -1753,7 +1753,7 @@ void edid_state::parse_base_block(const unsigned char *x) block = block_name(0x00); data_block.clear(); - do_checksum("", x, EDID_PAGE_SIZE); + do_checksum("", x, EDID_PAGE_SIZE, EDID_PAGE_SIZE - 1); if (base.edid_minor >= 3) { if (!base.has_name_descriptor) msg(base.edid_minor >= 4, "Missing Display Product Name.\n"); diff --git a/parse-displayid-block.cpp b/parse-displayid-block.cpp index 54a691be0cb0..f4c8fc047737 100644 --- a/parse-displayid-block.cpp +++ b/parse-displayid-block.cpp @@ -2153,7 +2153,7 @@ void edid_state::parse_displayid_block(const unsigned char *x) * (excluding DisplayID-in-EDID magic byte) */ data_block.clear(); - do_checksum(" ", x + 1, x[2] + 5); + do_checksum(" ", x + 1, x[2] + 5, x[2] + 4); unused_bytes = 0x7f - (1 + x[2] + 5); if (!memchk(x + 1 + x[2] + 5, unused_bytes)) {