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

Subject: edid-decode: detect dummy serial number values
Author:  Hans Verkuil <hverkuil-ci...@xs4all.nl>
Date:    Fri Nov 24 12:01:26 2023 +0100

There is a list of known dummy serial number values that is
often used. Check if the S/N matches one of those and warn
if that is the case.

If you don't know the serial number, just set it to 0 and
don't report a fake S/N.

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

 edid-decode.h        |  5 +++--
 parse-base-block.cpp | 24 +++++++++++++++++++-----
 parse-cta-block.cpp  |  2 +-
 3 files changed, 23 insertions(+), 8 deletions(-)

---

diff --git a/edid-decode.h b/edid-decode.h
index bf6c6b6c2001..1f9bfbae1e45 100644
--- a/edid-decode.h
+++ b/edid-decode.h
@@ -151,11 +151,12 @@ struct edid_state {
                // Base block state
                base.edid_minor = 0;
                base.has_name_descriptor = base.has_display_range_descriptor =
-                       base.has_serial_number = base.has_serial_string =
+                       base.has_serial_string =
                        base.supports_continuous_freq = base.supports_gtf =
                        base.supports_cvt = base.seen_non_detailed_descriptor =
                        base.has_640x480p60_est_timing = base.has_spwg =
                        base.preferred_is_also_native = false;
+               base.serial_number = 0;
                base.supports_sec_gtf = false;
                base.sec_gtf_start_freq = 0;
                base.C = base.M = base.K = base.J = 0;
@@ -243,7 +244,7 @@ struct edid_state {
                unsigned edid_minor;
                bool has_name_descriptor;
                bool has_display_range_descriptor;
-               bool has_serial_number;
+               unsigned serial_number;
                bool has_serial_string;
                bool supports_continuous_freq;
                bool supports_gtf;
diff --git a/parse-base-block.cpp b/parse-base-block.cpp
index 9395bb0ff423..6bf9c120d33c 100644
--- a/parse-base-block.cpp
+++ b/parse-base-block.cpp
@@ -1336,9 +1336,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];
+       base.serial_number = x[0x0c] + (x[0x0d] << 8) +
+                       (x[0x0e] << 16) + (x[0x0f] << 24);
 
-       if (base.has_serial_number && replace_unique_ids) {
+       if (base.serial_number && replace_unique_ids) {
                // Replace by 123456
                x[0x0c] = 0x40;
                x[0x0d] = 0xe2;
@@ -1385,14 +1386,27 @@ void edid_state::parse_base_block(const unsigned char 
*x)
        printf("    Manufacturer: %s\n    Model: %u\n",
               manufacturer_name(x + 0x08),
               (unsigned short)(x[0x0a] + (x[0x0b] << 8)));
-       if (base.has_serial_number) {
-               unsigned sn = x[0x0c] + (x[0x0d] << 8) +
-                       (x[0x0e] << 16) + (x[0x0f] << 24);
+       if (base.serial_number) {
+               unsigned sn = base.serial_number;
 
                if (hide_serial_numbers)
                        printf("    Serial Number: ...\n");
                else
                        printf("    Serial Number: %u (0x%08x)\n", sn, sn);
+
+               // This is a list of known dummy values that are often used in 
EDIDs:
+               switch (sn) {
+               case 1:
+               case 0x01010101:
+               case 1010101:
+               case 0x5445:
+               case 0x80000000:
+               case 20000080:
+               case 8888:
+               case 6666:
+                       warn("The serial number is one of the known dummy 
values, it should probably be set to 0.\n");
+                       break;
+               }
        }
 
        time(&the_time);
diff --git a/parse-cta-block.cpp b/parse-cta-block.cpp
index 80464f4beb28..d1d6ca0f7991 100644
--- a/parse-cta-block.cpp
+++ b/parse-cta-block.cpp
@@ -2938,7 +2938,7 @@ void edid_state::parse_cta_block(const unsigned char *x)
        } while (0);
 
        data_block.clear();
-       if (base.has_serial_number && base.has_serial_string)
+       if (base.serial_number && base.has_serial_string)
                warn("Display Product Serial Number is set, so the Serial 
Number in the Base EDID should be 0.\n");
        if (!cta.has_vic_1 && !base.has_640x480p60_est_timing)
                fail("Required 640x480p60 timings are missing in the 
established timings"

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

Reply via email to