This is an automatic generated email to let you know that the following patch 
were queued:

Subject: edid-decode: replace Container IDs as well
Author:  Hans Verkuil <hverkuil-ci...@xs4all.nl>
Date:    Thu Jun 16 11:50:14 2022 +0200

Rename --replace-serial-numbers with --replace-unique-ids: this will
also replace Container IDs with a fixed value (all zeroes).

Signed-off-by: Hans Verkuil <hverkuil-ci...@xs4all.nl>

 edid-decode.1             | 10 ++++++----
 edid-decode.cpp           | 14 +++++---------
 edid-decode.h             |  6 +++---
 parse-base-block.cpp      | 24 ++++++++++++++++--------
 parse-cta-block.cpp       |  4 ++++
 parse-displayid-block.cpp | 22 ++++++++++++++++------
 parse-ls-ext-block.cpp    |  3 ++-
 7 files changed, 52 insertions(+), 31 deletions(-)

---

diff --git a/edid-decode.1 b/edid-decode.1
index 85d0fc399dc4..eab70948d1be 100644
--- a/edid-decode.1
+++ b/edid-decode.1
@@ -255,14 +255,16 @@ Hide any serial numbers in the human readable output by 
'...'.
 Note that they are still easily extracted from the EDID hex dump at
 the start.
 .TP
-\fB\-\-replace\-serial\-numbers\fR
-Replaces any serial numbers in the EDID by '123456'. This will
+\fB\-\-replace\-unique\-ids\fR
+Replaces any unique IDs in the EDID by fixed values. Serial numbers will be
+replaced by '123456' and Container IDs by all zeroes. This will
 also update any checksums in the EDID and update the EDID hex dump at
 the start of the output. Note that since this will update checksums, any
 checksum errors present in the original EDID will no longer be detected.
 
-Serial numbers appear in the Base Block, DisplayID Extension Blocks and
-Localized String Extension Blocks.
+Serial numbers can appear in the Base Block, DisplayID Extension Blocks and
+Localized String Extension Blocks. Container IDs can appear in the DisplayID
+and CTA-861 Extension Blocks.
 .TP
 \fB\-\-version\fR
 Show the SHA hash and the last commit date.
diff --git a/edid-decode.cpp b/edid-decode.cpp
index c8baacc04376..f6efe338f4d7 100644
--- a/edid-decode.cpp
+++ b/edid-decode.cpp
@@ -57,7 +57,7 @@ enum Option {
        OptXModeLineTimings = 'X',
        OptSkipSHA = 128,
        OptHideSerialNumbers,
-       OptReplaceSerialNumbers,
+       OptReplaceUniqueIDs,
        OptVersion,
        OptDiag,
        OptSTD,
@@ -89,7 +89,7 @@ static struct option long_options[] = {
        { "only-hex-dump", no_argument, 0, OptOnlyHexDump },
        { "skip-sha", no_argument, 0, OptSkipSHA },
        { "hide-serial-numbers", no_argument, 0, OptHideSerialNumbers },
-       { "replace-serial-numbers", no_argument, 0, OptReplaceSerialNumbers },
+       { "replace-unique-ids", no_argument, 0, OptReplaceUniqueIDs },
        { "version", no_argument, 0, OptVersion },
        { "check-inline", no_argument, 0, OptCheckInline },
        { "check", no_argument, 0, OptCheck },
@@ -148,7 +148,7 @@ static void usage(void)
               "  -H, --only-hex-dump   Only output the hex dump of the EDID.\n"
               "  --skip-sha            Skip the SHA report.\n"
               "  --hide-serial-numbers Hide serial numbers with '...'.\n"
-              "  --replace-serial-numbers Replace serial numbers in EDID with 
123456.\n"
+              "  --replace-unique-ids  Replace unique IDs (serial numbers, 
Container IDs) with fixed values.\n"
               "  --version             Show the edid-decode version (SHA).\n"
               "  --diagonal <inches>   Set the display's diagonal in inches.\n"
               "  --std <byte1>,<byte2> Show the standard timing represented by 
these two bytes.\n"
@@ -1161,14 +1161,10 @@ void edid_state::preparse_extension(unsigned char *x)
                break;
        case 0x50:
                preparse_ls_ext_block(x);
-               if (replace_serial_numbers)
-                       replace_checksum(x, EDID_PAGE_SIZE);
                break;
        case 0x70:
                has_dispid = true;
                preparse_displayid_block(x);
-               if (replace_serial_numbers)
-                       replace_checksum(x, EDID_PAGE_SIZE);
                break;
        }
 }
@@ -1423,10 +1419,10 @@ void edid_state::print_native_res()
 int edid_state::parse_edid()
 {
        hide_serial_numbers = options[OptHideSerialNumbers];
-       replace_serial_numbers = options[OptReplaceSerialNumbers];
+       replace_unique_ids = options[OptReplaceUniqueIDs];
 
        preparse_base_block(edid);
-       if (replace_serial_numbers)
+       if (replace_unique_ids)
                replace_checksum(edid, EDID_PAGE_SIZE);
 
        for (unsigned i = 1; i < num_blocks; i++)
diff --git a/edid-decode.h b/edid-decode.h
index 6f37e4522b36..0f8a7753adfe 100644
--- a/edid-decode.h
+++ b/edid-decode.h
@@ -145,7 +145,7 @@ struct edid_state {
                warnings = failures = 0;
                has_cta = has_dispid = false;
                hide_serial_numbers = false;
-               replace_serial_numbers = false;
+               replace_unique_ids = false;
                image_width = image_height = diagonal = 0;
 
                // Base block state
@@ -216,7 +216,7 @@ struct edid_state {
        bool has_cta;
        bool has_dispid;
        bool hide_serial_numbers;
-       bool replace_serial_numbers;
+       bool replace_unique_ids;
 
        unsigned min_hor_freq_hz;
        unsigned max_hor_freq_hz;
@@ -371,7 +371,7 @@ struct edid_state {
        void detailed_epi(const unsigned char *x);
        void detailed_timings(const char *prefix, const unsigned char *x,
                              bool base_or_cta = true);
-       void preparse_detailed_block(unsigned char *x);
+       bool preparse_detailed_block(unsigned char *x);
        void preparse_base_block(unsigned char *x);
        void detailed_block(const unsigned char *x);
        void parse_base_block(const unsigned char *x);
diff --git a/parse-base-block.cpp b/parse-base-block.cpp
index 56583c150f69..9644577bab70 100644
--- a/parse-base-block.cpp
+++ b/parse-base-block.cpp
@@ -1089,10 +1089,10 @@ void edid_state::detailed_timings(const char *prefix, 
const unsigned char *x,
        }
 }
 
-void edid_state::preparse_detailed_block(unsigned char *x)
+bool edid_state::preparse_detailed_block(unsigned char *x)
 {
        if (x[0] || x[1])
-               return;
+               return false;
 
        switch (x[3]) {
        case 0xfd:
@@ -1119,16 +1119,18 @@ void edid_state::preparse_detailed_block(unsigned char 
*x)
                }
                break;
        case 0xff:
-               if (replace_serial_numbers) {
+               if (replace_unique_ids) {
                        // Replace with 123456
                        static const unsigned char sernum[13] = {
                                '1', '2', '3', '4', '5', '6',
                                '\n', ' ', ' ', ' ', ' ', ' ', ' '
                        };
                        memcpy(x + 5, sernum, sizeof(sernum));
+                       return true;
                }
                break;
        }
+       return false;
 }
 
 void edid_state::detailed_block(const unsigned char *x)
@@ -1330,24 +1332,30 @@ static const unsigned char srgb_chromaticity[10] = {
 
 void edid_state::preparse_base_block(unsigned char *x)
 {
+       bool update_checksum = false;
+
        base.has_serial_number = x[0x0c] || x[0x0d] || x[0x0e] || x[0x0f];
 
-       if (base.has_serial_number && replace_serial_numbers) {
+       if (base.has_serial_number && replace_unique_ids) {
                // Replace by 123456
                x[0x0c] = 0x40;
                x[0x0d] = 0xe2;
                x[0x0e] = 0x01;
                x[0x0f] = 0x00;
+               update_checksum = true;
        }
 
        /*
         * Need to find the Display Range Limit info before reading
         * the standard timings.
         */
-       preparse_detailed_block(x + 0x36);
-       preparse_detailed_block(x + 0x48);
-       preparse_detailed_block(x + 0x5a);
-       preparse_detailed_block(x + 0x6c);
+       update_checksum |= preparse_detailed_block(x + 0x36);
+       update_checksum |= preparse_detailed_block(x + 0x48);
+       update_checksum |= preparse_detailed_block(x + 0x5a);
+       update_checksum |= preparse_detailed_block(x + 0x6c);
+
+       if (update_checksum)
+               replace_checksum(x, EDID_PAGE_SIZE);
 }
 
 void edid_state::parse_base_block(const unsigned char *x)
diff --git a/parse-cta-block.cpp b/parse-cta-block.cpp
index 2e163dc019f6..4ce2d143a33d 100644
--- a/parse-cta-block.cpp
+++ b/parse-cta-block.cpp
@@ -2560,6 +2560,10 @@ void edid_state::preparse_cta_block(unsigned char *x)
                        if (oui == 0x000c03) {
                                cta.has_hdmi = true;
                                cta.preparsed_phys_addr = (x[i + 4] << 8) | x[i 
+ 5];
+                       } else if ((oui == 0xca125c || oui == 0x5c12ca) &&
+                                  (x[i] & 0x1f) == 0x15 && replace_unique_ids) 
{
+                               memset(x + i + 6, 0, 16);
+                               replace_checksum(x, EDID_PAGE_SIZE);
                        }
                        break;
                case 0x06:
diff --git a/parse-displayid-block.cpp b/parse-displayid-block.cpp
index dd8afb8b7d52..a754483b3b73 100644
--- a/parse-displayid-block.cpp
+++ b/parse-displayid-block.cpp
@@ -1684,13 +1684,13 @@ std::string edid_state::product_type(unsigned char x, 
bool heading)
 
 void edid_state::preparse_displayid_block(unsigned char *x)
 {
+       bool update_checksum = false;
        unsigned length = x[2];
+       unsigned offset = 5;
 
        if (length > 121)
                length = 121;
 
-       unsigned offset = 5;
-
        dispid.preparsed_displayid_blocks++;
        while (length > 0) {
                unsigned tag = x[offset];
@@ -1699,7 +1699,7 @@ void edid_state::preparse_displayid_block(unsigned char 
*x)
                switch (tag) {
                case 0x00:
                case 0x20:
-                       if (replace_serial_numbers &&
+                       if (replace_unique_ids &&
                            (x[offset + 0x08] || x[offset + 0x09] ||
                             x[offset + 0x0a] || x[offset + 0x0b])) {
                                // Replace by 123456
@@ -1707,12 +1707,12 @@ void edid_state::preparse_displayid_block(unsigned char 
*x)
                                x[offset + 0x09] = 0xe2;
                                x[offset + 0x0a] = 0x01;
                                x[offset + 0x0b] = 0x00;
-                               replace_checksum(x + 1, x[2] + 5);
+                               update_checksum = true;
                        }
                        break;
                case 0x12:
                case 0x28:
-                       if (replace_serial_numbers &&
+                       if (replace_unique_ids &&
                            (x[offset + 0x15] || x[offset + 0x16] ||
                             x[offset + 0x17] || x[offset + 0x18])) {
                                // Replace by 123456
@@ -1720,7 +1720,13 @@ void edid_state::preparse_displayid_block(unsigned char 
*x)
                                x[offset + 0x16] = 0xe2;
                                x[offset + 0x17] = 0x01;
                                x[offset + 0x18] = 0x00;
-                               replace_checksum(x + 1, x[2] + 5);
+                               update_checksum = true;
+                       }
+                       break;
+               case 0x29:
+                       if (replace_unique_ids) {
+                               update_checksum = true;
+                               memset(x + offset + 3, 0, 16);
                        }
                        break;
                case 0x02:
@@ -1745,6 +1751,10 @@ void edid_state::preparse_displayid_block(unsigned char 
*x)
                length -= len + 3;
                offset += len + 3;
        }
+       if (update_checksum) {
+               replace_checksum(x + 1, x[2] + 5);
+               replace_checksum(x, EDID_PAGE_SIZE);
+       }
 }
 
 unsigned edid_state::displayid_block(const unsigned version, const unsigned 
char *x, unsigned length)
diff --git a/parse-ls-ext-block.cpp b/parse-ls-ext-block.cpp
index 1eaaacd74835..1b74baad5642 100644
--- a/parse-ls-ext-block.cpp
+++ b/parse-ls-ext-block.cpp
@@ -64,7 +64,7 @@ void edid_state::preparse_ls_ext_block(unsigned char *x)
 {
        unsigned char *orig = x;
 
-       if (!replace_serial_numbers)
+       if (!replace_unique_ids)
                return;
 
        x += 5;
@@ -86,6 +86,7 @@ void edid_state::preparse_ls_ext_block(unsigned char *x)
                        s[i + width - 1] = idx < 6 ? '1' + idx : ' ';
                }
        }
+       replace_checksum(orig, EDID_PAGE_SIZE);
 }
 
 void edid_state::parse_ls_ext_block(const unsigned char *x)

_______________________________________________
linuxtv-commits mailing list
linuxtv-commits@linuxtv.org
https://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to