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

Subject: edid-decode: support multiple DTDs with serial numbers
Author:  Hans Verkuil <hverkuil-ci...@xs4all.nl>
Date:    Mon Jan 29 12:53:30 2024 +0100

Both the base block and the CTA extension blocks can contain
DTDs with serial numbers. Correctly process those and warn if
multiple serial number DTDs are encountered.

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

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

---

diff --git a/edid-decode.h b/edid-decode.h
index 9afc9b5e2f86..50abfcbb7bb5 100644
--- a/edid-decode.h
+++ b/edid-decode.h
@@ -147,17 +147,17 @@ struct edid_state {
                hide_serial_numbers = false;
                replace_unique_ids = false;
                image_width = image_height = diagonal = 0;
+               serial_string_cnt = 0;
+               serial_strings.clear();
 
                // Base block state
                base.edid_minor = 0;
                base.has_name_descriptor = base.has_display_range_descriptor =
-                       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.serial_string[0] = 0;
                base.supports_sec_gtf = false;
                base.sec_gtf_start_freq = 0;
                base.C = base.M = base.K = base.J = 0;
@@ -225,6 +225,8 @@ struct edid_state {
        bool has_dispid;
        bool hide_serial_numbers;
        bool replace_unique_ids;
+       std::vector<std::string> serial_strings;
+       unsigned serial_string_cnt;
 
        unsigned min_hor_freq_hz;
        unsigned max_hor_freq_hz;
@@ -248,8 +250,6 @@ struct edid_state {
                bool has_name_descriptor;
                bool has_display_range_descriptor;
                unsigned serial_number;
-               char serial_string[14];
-               bool has_serial_string;
                bool supports_continuous_freq;
                bool supports_gtf;
                bool supports_sec_gtf;
diff --git a/parse-base-block.cpp b/parse-base-block.cpp
index 192b6896c006..b58998cd0623 100644
--- a/parse-base-block.cpp
+++ b/parse-base-block.cpp
@@ -1119,7 +1119,9 @@ bool edid_state::preparse_detailed_block(unsigned char *x)
                }
                break;
        case 0xff:
-               strcpy(base.serial_string, extract_string(x + 5, 13));
+               data_block = "Display Product Serial Number";
+               serial_strings.push_back(extract_string(x + 5, 13));
+               data_block.clear();
                if (replace_unique_ids) {
                        // Replace with 123456
                        static const unsigned char sernum[13] = {
@@ -1318,29 +1320,30 @@ void edid_state::detailed_block(const unsigned char *x)
                };
 
                data_block = "Display Product Serial Number";
-               char *sn = extract_string(x + 5, 13);
+               const char *sn = serial_strings[serial_string_cnt++].c_str();
                if (hide_serial_numbers)
                        printf("    %s: ...\n", data_block.c_str());
+               else if (replace_unique_ids)
+                       printf("    %s: '123456'\n", data_block.c_str());
                else
                        printf("    %s: '%s'\n", data_block.c_str(), sn);
-               base.has_serial_string = 1;
                bool dummy = true;
                // Any serial numbers consisting only of spaces, 0, and/or 1
                // characters are always considered dummy values.
-               for (unsigned i = 0; i < strlen(base.serial_string); i++) {
-                       if (!strchr(" 01", base.serial_string[i])) {
+               for (unsigned i = 0; i < strlen(sn); i++) {
+                       if (!strchr(" 01", sn[i])) {
                                dummy = false;
                                break;
                        }
                }
                // In addition, check against a list of known dummy S/Ns
                for (unsigned i = 0; !dummy && dummy_sn[i]; i++) {
-                       if (!strcmp(base.serial_string, dummy_sn[i])) {
+                       if (!strcmp(sn, dummy_sn[i])) {
                                dummy = true;
                                break;
                        }
                }
-               if (dummy && base.serial_string[0])
+               if (dummy && sn[0])
                        warn("The serial number is one of the known dummy 
values, is that intended?\n");
                return;
        }
@@ -1815,4 +1818,7 @@ void edid_state::check_base_block(const unsigned char *x)
                fail("EDID 1.3 requires a Block Map Extension in Block 128 if 
there are more than 128 blocks in the EDID.\n");
        if (block_map.saw_block_128 && num_blocks > 255)
                fail("If there is a Block Map Extension in Block 128 then the 
maximum number of blocks is 255.\n");
+
+       if (serial_strings.size() > 1)
+               warn("Multiple Display Product Serial Numbers are specified, is 
that intended?\n");
 }
diff --git a/parse-cta-block.cpp b/parse-cta-block.cpp
index 060cbdb65d1c..e26579a5171a 100644
--- a/parse-cta-block.cpp
+++ b/parse-cta-block.cpp
@@ -2764,14 +2764,18 @@ void edid_state::preparse_cta_block(unsigned char *x)
        unsigned offset = x[2];
 
        if (offset >= 4) {
-               const unsigned char *detailed;
+               unsigned char *detailed;
+               bool update_checksum = false;
 
                for (detailed = x + offset; detailed + 17 < x + 127; detailed 
+= 18) {
                        if (memchk(detailed, 18))
                                break;
+                       update_checksum |= preparse_detailed_block(detailed);
                        if (detailed[0] || detailed[1])
                                cta.preparsed_total_dtds++;
                }
+               if (update_checksum)
+                       replace_checksum(x, EDID_PAGE_SIZE);
        }
 
        if (version < 3)
@@ -2966,7 +2970,7 @@ void edid_state::parse_cta_block(const unsigned char *x)
        } while (0);
 
        data_block.clear();
-       if (base.serial_number && base.has_serial_string)
+       if (base.serial_number && serial_strings.size())
                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
To unsubscribe send an email to linuxtv-commits-le...@linuxtv.org
%(web_page_url)slistinfo/%(_internal_name)s

Reply via email to