From 0edd198d8b608b396f7716d56f21e8d6342f4481 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Fri, 12 Mar 2021 07:53:13 +0100 Subject: edid-decode: introduce containerid2s() Format the container IDs consistently. Signed-off-by: Hans Verkuil --- edid-decode.cpp | 13 +++++++++++++ edid-decode.h | 1 + parse-cta-block.cpp | 2 +- parse-displayid-block.cpp | 7 +------ 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/edid-decode.cpp b/edid-decode.cpp index 78119ae..78398d0 100644 --- a/edid-decode.cpp +++ b/edid-decode.cpp @@ -586,6 +586,19 @@ bool edid_state::print_timings(const char *prefix, const struct timings *t, return ok; } +std::string containerid2s(const unsigned char *x) +{ + char buf[40]; + + sprintf(buf, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", + x[0], x[1], x[2], x[3], + x[4], x[5], + x[6], x[7], + x[8], x[9], + x[10], x[11], x[12], x[13], x[14], x[15]); + return buf; +} + std::string utohex(unsigned char x) { char buf[10]; diff --git a/edid-decode.h b/edid-decode.h index 94f0c0a..f9f7064 100644 --- a/edid-decode.h +++ b/edid-decode.h @@ -445,6 +445,7 @@ void msg(bool is_warn, const char *fmt, ...); void do_checksum(const char *prefix, const unsigned char *x, size_t len); std::string utohex(unsigned char x); std::string ouitohex(unsigned oui); +std::string containerid2s(const unsigned char *x); 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); diff --git a/parse-cta-block.cpp b/parse-cta-block.cpp index e7ea01b..124b3e6 100644 --- a/parse-cta-block.cpp +++ b/parse-cta-block.cpp @@ -1101,7 +1101,7 @@ static void cta_microsoft(const unsigned char *x, unsigned length) } printf(" Display Product Primary Use Case: %u (%s)\n", x[1] & 0x1f, display_use_case(x[1] & 0x1f).c_str()); - hex_block(" Container ID: ", x + 2, length - 2, false, 16); + printf(" Container ID: %s\n", containerid2s(x + 2).c_str()); } static void cta_hdr10plus(const unsigned char *x, unsigned length) diff --git a/parse-displayid-block.cpp b/parse-displayid-block.cpp index b11b0c5..5bd9734 100644 --- a/parse-displayid-block.cpp +++ b/parse-displayid-block.cpp @@ -1360,12 +1360,7 @@ void edid_state::parse_displayid_ContainerID(const unsigned char *x) if (check_displayid_datablock_length(x, 16, 16)) { x += 3; - printf(" %02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\n", - x[0], x[1], x[2], x[3], - x[4], x[5], - x[6], x[7], - x[8], x[9], - x[10], x[11], x[12], x[13], x[14], x[15]); + printf(" Container ID: %s\n", containerid2s(x).c_str()); } } -- cgit v1.2.1