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

Subject: edid-decode: add --diagonal option
Author:  Hans Verkuil <hverkuil-ci...@xs4all.nl>
Date:    Thu Nov 4 14:01:14 2021 +0100

If specified, this will enable additional checks against the image size.

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

 edid-decode.1   |  5 +++++
 edid-decode.cpp | 50 +++++++++++++++++++++++++++++++++++++++++++++-----
 edid-decode.h   |  4 +++-
 3 files changed, 53 insertions(+), 6 deletions(-)

---

diff --git a/edid-decode.1 b/edid-decode.1
index a304aa8fab2d..f298e9529577 100644
--- a/edid-decode.1
+++ b/edid-decode.1
@@ -195,6 +195,11 @@ depending on whether the Source only parses Block 0 (e.g. 
DVI outputs), or Block
 and the CTA-861 Extension Blocks (HDMI), or Block 0 and the DisplayID 
Extension Blocks
 (typical for DisplayPort).
 .TP
+\fB\-\-diagonal\fR \fI<inches>\fR
+Specify the diagonal of the display in inches. This will enable additional 
checks
+for the image size, checking if it corresponds to the diagonal. This assumes
+square pixels.
+.TP
 \fB\-P\fR, \fB\-\-physical\-address\fR
 Just report the HDMI Source Physical Address and nothing else. Reports f.f.f.f
 if the EDID could not be parsed, or if there was no CTA-861 Vendor-Specific 
Data Block
diff --git a/edid-decode.cpp b/edid-decode.cpp
index f6f4a40695b9..2c49dc3cca09 100644
--- a/edid-decode.cpp
+++ b/edid-decode.cpp
@@ -58,6 +58,7 @@ enum Option {
        OptSkipSHA = 128,
        OptHideSerialNumbers,
        OptVersion,
+       OptDiag,
        OptSTD,
        OptDMT,
        OptVIC,
@@ -92,6 +93,7 @@ static struct option long_options[] = {
        { "xmodeline", no_argument, 0, OptXModeLineTimings },
        { "fbmode", no_argument, 0, OptFBModeTimings },
        { "v4l2-timings", no_argument, 0, OptV4L2Timings },
+       { "diagonal", required_argument, 0, OptDiag },
        { "std", required_argument, 0, OptSTD },
        { "dmt", required_argument, 0, OptDMT },
        { "vic", required_argument, 0, OptVIC },
@@ -114,7 +116,7 @@ static void usage(void)
               "                        if the output filename is '-'.\n"
               "\nOptions:\n"
               "  -o, --output-format <fmt>\n"
-              "                        If [out] is specified, then write the 
EDID in this format\n"
+              "                        If [out] is specified, then write the 
EDID in this format.\n"
               "                        <fmt> is one of:\n"
               "                        hex:    hex numbers in ascii text 
(default for stdout)\n"
               "                        raw:    binary data (default unless 
writing to stdout)\n"
@@ -136,8 +138,9 @@ static void usage(void)
               "  -s, --skip-hex-dump   Skip the initial hex dump of the 
EDID.\n"
               "  -H, --only-hex-dump   Only output the hex dump of the EDID.\n"
               "  --skip-sha            Skip the SHA report.\n"
-              "  --hide-serial-numbers Replace serial numbers with '...'\n"
-              "  --version             show the edid-decode version (SHA)\n"
+              "  --hide-serial-numbers Replace serial numbers with '...'.\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"
               "  --dmt <dmt>           Show the timings for the DMT with the 
given DMT ID.\n"
               "  --vic <vic>           Show the timings for this VIC.\n"
@@ -1383,6 +1386,41 @@ void edid_state::print_native_res()
                }
        }
 
+       if (diagonal) {
+               if (image_width) {
+                       double w = image_width;
+                       double h = image_height;
+                       double d = sqrt(w * w + h * h) / 254.0;
+
+                       if (fabs(diagonal - d) >= 0.1)
+                               warn("Specified diagonal is %.1f\", calculated 
diagonal is %.1f\".\n",
+                                    diagonal, d);
+               }
+               if (native_width) {
+                       double w = native_width;
+                       double h = native_height;
+                       double d = diagonal * 254.0;
+                       double c = sqrt((d * d) / (w * w + h * h));
+
+                       w *= c;
+                       h *= c;
+
+                       if (image_width) {
+                               if (fabs((double)image_width - w) >= 100.0 ||
+                                   fabs((double)image_height - h) >= 100.0)
+                                       warn("Calculated image size is 
%.1fx%.1fmm, EDID image size is %.1fx%.1fmm.\n",
+                                            w / 10.0, h / 10.0,
+                                            image_width / 10.0, image_height / 
10.0);
+                       } else {
+                               warn("No image size was specified, but it is 
calculated as %.1fx%.1fmm.\n",
+                                    w / 10.0, h / 10.0);
+                       }
+               }
+       }
+
+       if (!options[OptNativeResolution])
+               return;
+
        if (native_width == 0 && native_width_int == 0) {
                printf("\n----------------\n");
                printf("\nNo Native Video Resolution was defined.\n");
@@ -1474,8 +1512,7 @@ int edid_state::parse_edid()
        if (options[OptPreferredTimings])
                print_preferred_timings();
 
-       if (options[OptNativeResolution])
-               print_native_res();
+       print_native_res();
 
        if (!options[OptCheck] && !options[OptCheckInline])
                return 0;
@@ -1832,6 +1869,9 @@ int main(int argc, char **argv)
                                exit(1);
                        }
                        break;
+               case OptDiag:
+                       state.diagonal = strtod(optarg, NULL);
+                       break;
                case OptSTD: {
                        unsigned char byte1, byte2 = 0;
                        char *endptr;
diff --git a/edid-decode.h b/edid-decode.h
index 67e681a99e26..fdd0d413c46c 100644
--- a/edid-decode.h
+++ b/edid-decode.h
@@ -130,7 +130,7 @@ struct edid_state {
                warnings = failures = 0;
                has_cta = has_dispid = false;
                hide_serial_numbers = false;
-               image_width = image_height = 0;
+               image_width = image_height = diagonal = 0;
 
                // Base block state
                base.edid_minor = 0;
@@ -206,6 +206,8 @@ struct edid_state {
 
        // in 0.1 mm units
        unsigned image_width, image_height;
+       // in inches
+       double diagonal;
 
        unsigned warnings;
        unsigned failures;

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

Reply via email to