[PATCH 03/27] edid-decode: report picture aspect ratio

Hans Verkuil hverkuil at xs4all.nl
Thu Aug 31 11:40:56 UTC 2017


From: Hans Verkuil <hans.verkuil at cisco.com>

Signed-off-by: Hans Verkuil <hans.verkuil at cisco.com>
---
 edid-decode.c | 296 +++++++++++++++++++++++++++++++---------------------------
 1 file changed, 157 insertions(+), 139 deletions(-)

diff --git a/edid-decode.c b/edid-decode.c
index 4deceba4..31aca8aa 100644
--- a/edid-decode.c
+++ b/edid-decode.c
@@ -158,6 +158,7 @@ static int
 detailed_cvt_descriptor(unsigned char *x, int first)
 {
     const unsigned char empty[3] = { 0, 0, 0 };
+    const char *ratio;
     char *names[] = { "50", "60", "75", "85" };
     int width, height;
     int valid = 1;
@@ -173,13 +174,21 @@ detailed_cvt_descriptor(unsigned char *x, int first)
 
     switch (x[1] & 0x0c) {
     case 0x00:
-	width = (height * 4) / 3; break;
+	width = (height * 4) / 3;
+	ratio = "4:3";
+	break;
     case 0x04:
-	width = (height * 16) / 9; break;
+	width = (height * 16) / 9;
+	ratio = "16:9";
+	break;
     case 0x08:
-	width = (height * 16) / 10; break;
+	width = (height * 16) / 10;
+	ratio = "16:10";
+	break;
     case 0x0c:
-	width = (height * 15) / 9; break;
+	width = (height * 15) / 9;
+	ratio = "15:9";
+	break;
     }
 
     if (x[1] & 0x03)
@@ -198,12 +207,13 @@ detailed_cvt_descriptor(unsigned char *x, int first)
     if (!valid) {
 	printf("    (broken)\n");
     } else {
-	printf("    %dx%d @ ( %s%s%s%s%s) Hz (%s%s preferred)\n", width, height,
+	printf("    %dx%d @ ( %s%s%s%s%s) Hz %s (%s%s preferred)\n", width, height,
 		fifty ? "50 " : "",
 		sixty ? "60 " : "",
 		seventyfive ? "75 " : "",
 		eightyfive ? "85 " : "",
 		reduced ? "60RB " : "",
+		ratio,
 		names[(x[2] & 0x60) >> 5],
 		(((x[2] & 0x60) == 0x20) && reduced) ? "RB" : "");
     }
@@ -652,113 +662,113 @@ cea_audio_block(unsigned char *x)
 }
 
 static const char *edid_cea_modes[] = {
-    "640x480 at 60Hz",
-    "720x480 at 60Hz",
-    "720x480 at 60Hz",
-    "1280x720 at 60Hz",
-    "1920x1080i at 60Hz",
-    "1440x480i at 60Hz",
-    "1440x480i at 60Hz",
-    "1440x240 at 60Hz",
-    "1440x240 at 60Hz",
-    "2880x480i at 60Hz",
-    "2880x480i at 60Hz",
-    "2880x240 at 60Hz",
-    "2880x240 at 60Hz",
-    "1440x480 at 60Hz",
-    "1440x480 at 60Hz",
-    "1920x1080 at 60Hz",
-    "720x576 at 50Hz",
-    "720x576 at 50Hz",
-    "1280x720 at 50Hz",
-    "1920x1080i at 50Hz",
-    "1440x576i at 50Hz",
-    "1440x576i at 50Hz",
-    "1440x288 at 50Hz",
-    "1440x288 at 50Hz",
-    "2880x576i at 50Hz",
-    "2880x576i at 50Hz",
-    "2880x288 at 50Hz",
-    "2880x288 at 50Hz",
-    "1440x576 at 50Hz",
-    "1440x576 at 50Hz",
-    "1920x1080 at 50Hz",
-    "1920x1080 at 24Hz",
-    "1920x1080 at 25Hz",
-    "1920x1080 at 30Hz",
-    "2880x480 at 60Hz",
-    "2880x480 at 60Hz",
-    "2880x576 at 50Hz",
-    "2880x576 at 50Hz",
-    "1920x1080i at 50Hz",
-    "1920x1080i at 100Hz",
-    "1280x720 at 100Hz",
-    "720x576 at 100Hz",
-    "720x576 at 100Hz",
-    "1440x576 at 100Hz",
-    "1440x576 at 100Hz",
-    "1920x1080i at 120Hz",
-    "1280x720 at 120Hz",
-    "720x480 at 120Hz",
-    "720x480 at 120Hz",
-    "1440x480i at 120Hz",
-    "1440x480i at 120Hz",
-    "720x576 at 200Hz",
-    "720x576 at 200Hz",
-    "1440x576i at 200Hz",
-    "1440x576i at 200Hz",
-    "720x480 at 240Hz",
-    "720x480 at 240Hz",
-    "1440x480i at 240Hz",
-    "1440x480i at 240Hz",
-    "1280x720 at 24Hz",
-    "1280x720 at 25Hz",
-    "1280x720 at 30Hz",
-    "1920x1080 at 120Hz",
-    "1920x1080 at 100Hz",
-    "1280x720 at 24Hz",
-    "1280x720 at 25Hz",
-    "1280x720 at 30Hz",
-    "1280x720 at 50Hz",
-    "1280x720 at 60Hz",
-    "1280x720 at 100Hz",
-    "1280x720 at 120Hz",
-    "1920x1080 at 24Hz",
-    "1920x1080 at 25Hz",
-    "1920x1080 at 30Hz",
-    "1920x1080 at 50Hz",
-    "1920x1080 at 60Hz",
-    "1920x1080 at 100Hz",
-    "1920x1080 at 120Hz",
-    "1680x720 at 24Hz",
-    "1680x720 at 25Hz",
-    "1680x720 at 30Hz",
-    "1680x720 at 50Hz",
-    "1680x720 at 60Hz",
-    "1680x720 at 100Hz",
-    "1680x720 at 120Hz",
-    "2560x1080 at 24Hz",
-    "2560x1080 at 25Hz",
-    "2560x1080 at 30Hz",
-    "2560x1080 at 50Hz",
-    "2560x1080 at 60Hz",
-    "2560x1080 at 100Hz",
-    "2560x1080 at 120Hz",
-    "3840x2160 at 24Hz",
-    "3840x2160 at 25Hz",
-    "3840x2160 at 30Hz",
-    "3840x2160 at 50Hz",
-    "3840x2160 at 60Hz",
-    "4096x2160 at 24Hz",
-    "4096x2160 at 25Hz",
-    "4096x2160 at 30Hz",
-    "4096x2160 at 50Hz",
-    "4096x2160 at 60Hz",
-    "3840x2160 at 24Hz",
-    "3840x2160 at 25Hz",
-    "3840x2160 at 30Hz",
-    "3840x2160 at 50Hz",
-    "3840x2160 at 60Hz",
+    "640x480 at 60Hz 4:3",
+    "720x480 at 60Hz 4:3",
+    "720x480 at 60Hz 16:9",
+    "1280x720 at 60Hz 16:9",
+    "1920x1080i at 60Hz 16:9",
+    "1440x480i at 60Hz 4:3",
+    "1440x480i at 60Hz 16:9",
+    "1440x240 at 60Hz 4:3",
+    "1440x240 at 60Hz 16:9",
+    "2880x480i at 60Hz 4:3",
+    "2880x480i at 60Hz 16:9",
+    "2880x240 at 60Hz 4:3",
+    "2880x240 at 60Hz 16:9",
+    "1440x480 at 60Hz 4:3",
+    "1440x480 at 60Hz 16:9",
+    "1920x1080 at 60Hz 16:9",
+    "720x576 at 50Hz 4:3",
+    "720x576 at 50Hz 16:9",
+    "1280x720 at 50Hz 16:9",
+    "1920x1080i at 50Hz 16:9",
+    "1440x576i at 50Hz 4:3",
+    "1440x576i at 50Hz 16:9",
+    "1440x288 at 50Hz 4:3",
+    "1440x288 at 50Hz 16:9",
+    "2880x576i at 50Hz 4:3",
+    "2880x576i at 50Hz 16:9",
+    "2880x288 at 50Hz 4:3",
+    "2880x288 at 50Hz 16:9",
+    "1440x576 at 50Hz 4:3",
+    "1440x576 at 50Hz 16:9",
+    "1920x1080 at 50Hz 16:9",
+    "1920x1080 at 24Hz 16:9",
+    "1920x1080 at 25Hz 16:9",
+    "1920x1080 at 30Hz 16:9",
+    "2880x480 at 60Hz 4:3",
+    "2880x480 at 60Hz 16:9",
+    "2880x576 at 50Hz 4:3",
+    "2880x576 at 50Hz 16:9",
+    "1920x1080i at 50Hz 16:9",
+    "1920x1080i at 100Hz 16:9",
+    "1280x720 at 100Hz 16:9",
+    "720x576 at 100Hz 4:3",
+    "720x576 at 100Hz 16:9",
+    "1440x576 at 100Hz 4:3",
+    "1440x576 at 100Hz 16:9",
+    "1920x1080i at 120Hz 16:9",
+    "1280x720 at 120Hz 16:9",
+    "720x480 at 120Hz 4:3",
+    "720x480 at 120Hz 16:9",
+    "1440x480i at 120Hz 4:3",
+    "1440x480i at 120Hz 16:9",
+    "720x576 at 200Hz 4:3",
+    "720x576 at 200Hz 16:9",
+    "1440x576i at 200Hz 4:3",
+    "1440x576i at 200Hz 16:9",
+    "720x480 at 240Hz 4:3",
+    "720x480 at 240Hz 16:9",
+    "1440x480i at 240Hz 4:3",
+    "1440x480i at 240Hz 16:9",
+    "1280x720 at 24Hz 16:9",
+    "1280x720 at 25Hz 16:9",
+    "1280x720 at 30Hz 16:9",
+    "1920x1080 at 120Hz 16:9",
+    "1920x1080 at 100Hz 16:9",
+    "1280x720 at 24Hz 64:27",
+    "1280x720 at 25Hz 64:27",
+    "1280x720 at 30Hz 64:27",
+    "1280x720 at 50Hz 64:27",
+    "1280x720 at 60Hz 64:27",
+    "1280x720 at 100Hz 64:27",
+    "1280x720 at 120Hz 64:27",
+    "1920x1080 at 24Hz 64:27",
+    "1920x1080 at 25Hz 64:27",
+    "1920x1080 at 30Hz 64:27",
+    "1920x1080 at 50Hz 64:27",
+    "1920x1080 at 60Hz 64:27",
+    "1920x1080 at 100Hz 64:27",
+    "1920x1080 at 120Hz 64:27",
+    "1680x720 at 24Hz 64:27",
+    "1680x720 at 25Hz 64:27",
+    "1680x720 at 30Hz 64:27",
+    "1680x720 at 50Hz 64:27",
+    "1680x720 at 60Hz 64:27",
+    "1680x720 at 100Hz 64:27",
+    "1680x720 at 120Hz 64:27",
+    "2560x1080 at 24Hz 64:27",
+    "2560x1080 at 25Hz 64:27",
+    "2560x1080 at 30Hz 64:27",
+    "2560x1080 at 50Hz 64:27",
+    "2560x1080 at 60Hz 64:27",
+    "2560x1080 at 100Hz 64:27",
+    "2560x1080 at 120Hz 64:27",
+    "3840x2160 at 24Hz 16:9",
+    "3840x2160 at 25Hz 16:9",
+    "3840x2160 at 30Hz 16:9",
+    "3840x2160 at 50Hz 16:9",
+    "3840x2160 at 60Hz 16:9",
+    "4096x2160 at 24Hz 256:135",
+    "4096x2160 at 25Hz 256:135",
+    "4096x2160 at 30Hz 256:135",
+    "4096x2160 at 50Hz 256:135",
+    "4096x2160 at 60Hz 256:135",
+    "3840x2160 at 24Hz 64:27",
+    "3840x2160 at 25Hz 64:27",
+    "3840x2160 at 30Hz 64:27",
+    "3840x2160 at 50Hz 64:27",
+    "3840x2160 at 60Hz 64:27",
 };
 
 static void
@@ -839,10 +849,10 @@ cea_vfpdb(unsigned char *x)
 }
 
 static const char *edid_cea_hdmi_modes[] = {
-    "3840x2160 at 30Hz",
-    "3840x2160 at 25Hz",
-    "3840x2160 at 24Hz",
-    "4096x2160 at 24Hz",
+    "3840x2160 at 30Hz 16:9",
+    "3840x2160 at 25Hz 16:9",
+    "3840x2160 at 24Hz 16:9",
+    "4096x2160 at 24Hz 256:135",
 };
 
 static void
@@ -1759,28 +1769,28 @@ extract_edid(int fd)
 }
 
 static const struct {
-  int x, y, refresh;
+  int x, y, refresh, ratio_w, ratio_h;
 } established_timings[] = {
   /* 0x23 bit 7 - 0 */
-  {720, 400, 70},
-  {720, 400, 88},
-  {640, 480, 60},
-  {640, 480, 67},
-  {640, 480, 72},
-  {640, 480, 75},
-  {800, 600, 56},
-  {800, 600, 60},
+  {720, 400, 70, 9, 5},
+  {720, 400, 88, 9, 5},
+  {640, 480, 60, 4, 3},
+  {640, 480, 67, 4, 3},
+  {640, 480, 72, 4, 3},
+  {640, 480, 75, 4, 3},
+  {800, 600, 56, 4, 3},
+  {800, 600, 60, 4, 3},
   /* 0x24 bit 7 - 0 */
-  {800, 600, 72},
-  {800, 600, 75},
-  {832, 624, 75},
-  {1280, 768, 87},
-  {1024, 768, 60},
-  {1024, 768, 70},
-  {1024, 768, 75},
-  {1280, 1024, 75},
+  {800, 600, 72, 4, 3},
+  {800, 600, 75, 4, 3},
+  {832, 624, 75, 4, 3},
+  {1280, 768, 87, 5, 3},
+  {1024, 768, 60, 4, 3},
+  {1024, 768, 70, 4, 3},
+  {1024, 768, 75, 4, 3},
+  {1280, 1024, 75, 5, 4},
   /* 0x25 bit 7*/
-  {1152, 870, 75},
+  {1152, 870, 75, 192, 145},
 };
 
 static void print_subsection(char *name, unsigned char *edid, int start,
@@ -2066,13 +2076,15 @@ int main(int argc, char **argv)
     printf("Established timings supported:\n");
     for (i = 0; i < 17; i++) {
       if (edid[0x23 + i / 8] & (1 << (7 - i % 8))) {
-	printf("  %dx%d@%dHz\n", established_timings[i].x,
-	       established_timings[i].y, established_timings[i].refresh);
+	printf("  %dx%d@%dHz %u:%u\n", established_timings[i].x,
+	       established_timings[i].y, established_timings[i].refresh,
+	       established_timings[i].ratio_w, established_timings[i].ratio_h);
       }
     }
 
     printf("Standard timings supported:\n");
     for (i = 0; i < 8; i++) {
+      const char *ratio;
       uint8_t b1 = edid[0x26 + i * 2], b2 = edid[0x26 + i * 2 + 1];
       unsigned int x, y, refresh;
 
@@ -2086,24 +2098,30 @@ int main(int argc, char **argv)
       x = (b1 + 31) * 8;
       switch ((b2 >> 6) & 0x3) {
       case 0x00:
-	if (claims_one_point_three)
+	if (claims_one_point_three) {
 	  y = x * 10 / 16;
-	else
+	  ratio = "16:10";
+	} else {
 	  y = x;
+	  ratio = "1:1";
+	}
 	break;
       case 0x01:
 	y = x * 3 / 4;
+	ratio = "4:3";
 	break;
       case 0x02:
 	y = x * 4 / 5;
+	ratio = "5:4";
 	break;
       case 0x03:
 	y = x * 9 / 16;
+	ratio = "16:9";
 	break;
       }
       refresh = 60 + (b2 & 0x3f);
 
-      printf("  %dx%d@%dHz\n", x, y, refresh);
+      printf("  %dx%d@%dHz %s\n", x, y, refresh, ratio);
     }
 
     /* detailed timings */
-- 
2.14.1



More information about the xorg-devel mailing list