All of lore.kernel.org
 help / color / mirror / Atom feed
From: joevt <joevt@shaw.ca>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: linux-media@vger.kernel.org, joevt <joevt@shaw.ca>
Subject: [PATCH 01/10] edid-decode: change horizontal refresh rates to kHz
Date: Sat, 23 Nov 2019 08:45:55 -0800	[thread overview]
Message-ID: <20191123164604.268-2-joevt@shaw.ca> (raw)
In-Reply-To: <20191123164604.268-1-joevt@shaw.ca>

- Timings that show horizontal refresh rate should use kHz to distinguish them from vertical refresh rate (Hz) and pixel clock rate (MHz). Matches representation in Monitor ranges descriptor.
- Make vertical refresh rate floating point instead of integer in detailed timings descriptors. For example, NTSC modes use 59.94 Hz and should not be rounded to 60 Hz.
- Remove double space when "(native)" is not output for CTA VIC timings.

Signed-off-by: Joe van Tunen <joevt@shaw.ca>
---
 edid-decode.c | 39 ++++++++++++++++++++-------------------
 1 file changed, 20 insertions(+), 19 deletions(-)

diff --git a/edid-decode.c b/edid-decode.c
index 932dd20..4ba0808 100644
--- a/edid-decode.c
+++ b/edid-decode.c
@@ -489,7 +489,7 @@ static int detailed_cvt_descriptor(const unsigned char *x, int first)
 			edid_cvt_mode(width, height, 60, 1,
 				      &min_hfreq, &max_hfreq, &max_clock);
 
-		printf("    %ux%u @ ( %s%s%s%s%s) Hz %s (%s%s preferred) HorFreq: %u-%u Hz MaxClock: %.3f MHz\n",
+		printf("    %ux%u @ ( %s%s%s%s%s) Hz %s (%s%s preferred) HorFreq: %.3f-%.3f kHz MaxClock: %.3f MHz\n",
 		       width, height,
 		       fifty ? "50 " : "",
 		       sixty ? "60 " : "",
@@ -499,7 +499,7 @@ static int detailed_cvt_descriptor(const unsigned char *x, int first)
 		       ratio,
 		       names[(x[2] & 0x60) >> 5],
 		       (((x[2] & 0x60) == 0x20) && reduced) ? "RB" : "",
-		       min_hfreq, max_hfreq, max_clock / 1000000.0);
+		       min_hfreq / 1000.0, max_hfreq / 1000.0, max_clock / 1000000.0);
 	}
 
 	return valid;
@@ -709,9 +709,9 @@ static void print_standard_timing(uint8_t b1, uint8_t b2)
 		min_hor_freq_hz = min(min_hor_freq_hz, hor_freq_hz);
 		max_hor_freq_hz = max(max_hor_freq_hz, hor_freq_hz);
 		max_pixclk_khz = max(max_pixclk_khz, pixclk_khz);
-		printf("  %ux%u@%uHz %u:%u HorFreq: %u Hz Clock: %.3f MHz\n",
+		printf("  %ux%u@%uHz %u:%u HorFreq: %.3f kHz Clock: %.3f MHz\n",
 		       x, y, refresh, ratio_w, ratio_h,
-		       hor_freq_hz, pixclk_khz / 1000.0);
+		       hor_freq_hz / 1000.0, pixclk_khz / 1000.0);
 	} else {
 		printf("  %ux%u@%uHz %u:%u\n",
 		       x, y, refresh, ratio_w, ratio_h);
@@ -723,7 +723,8 @@ static int detailed_block(const unsigned char *x, int in_extension)
 {
 	unsigned ha, hbl, hso, hspw, hborder, va, vbl, vso, vspw, vborder;
 	unsigned hor_mm, vert_mm;
-	unsigned refresh, pixclk_khz;
+	unsigned pixclk_khz;
+	float refresh;
 	unsigned i;
 	char phsync, pvsync, *syncmethod, *stereo;
 
@@ -769,12 +770,12 @@ static int detailed_block(const unsigned char *x, int in_extension)
 			printf("Established timings III:\n");
 			for (i = 0; i < 44; i++) {
 				if (x[6 + i / 8] & (1 << (7 - i % 8))) {
-					printf("  %dx%d@%dHz %s%u:%u HorFreq: %d Hz Clock: %.3f MHz\n",
+					printf("  %dx%d@%dHz %s%u:%u HorFreq: %.3f kHz Clock: %.3f MHz\n",
 					       established_timings3[i].x,
 					       established_timings3[i].y, established_timings3[i].refresh,
 					       established_timings3[i].rb ? "RB " : "",
 					       established_timings3[i].ratio_w, established_timings3[i].ratio_h,
-					       established_timings3[i].hor_freq_hz,
+					       established_timings3[i].hor_freq_hz / 1000.0,
 					       established_timings3[i].pixclk_khz / 1000.0);
 					min_vert_freq_hz = min(min_vert_freq_hz, established_timings3[i].refresh);
 					max_vert_freq_hz = max(max_vert_freq_hz, established_timings3[i].refresh);
@@ -1078,20 +1079,20 @@ static int detailed_block(const unsigned char *x, int in_extension)
 	}
 
 	pixclk_khz = (x[0] + (x[1] << 8)) * 10;
-	refresh = (pixclk_khz * 1000) / ((ha + hbl) * (va + vbl));
+	refresh = (pixclk_khz * 1000.0) / ((ha + hbl) * (va + vbl));
 	hor_mm = x[12] + ((x[14] & 0xf0) << 4);
 	vert_mm = x[13] + ((x[14] & 0x0f) << 8);
 	printf("Detailed mode: Clock %.3f MHz, %u mm x %u mm\n"
 	       "               %4u %4u %4u %4u hborder %u\n"
 	       "               %4u %4u %4u %4u vborder %u\n"
 	       "               %chsync %cvsync%s%s %s\n"
-	       "               VertFreq: %u Hz, HorFreq: %u Hz\n",
+	       "               VertFreq: %.3f Hz, HorFreq: %.3f kHz\n",
 	       pixclk_khz / 1000.0,
 	       hor_mm, vert_mm,
 	       ha, ha + hso, ha + hso + hspw, ha + hbl, hborder,
 	       va, va + vso, va + vso + vspw, va + vbl, vborder,
-	       phsync, pvsync, syncmethod, x[17] & 0x80 ? " interlaced" : "",
-	       stereo, refresh, (pixclk_khz * 1000) / (ha + hbl)
+	       phsync, pvsync, syncmethod, x[17] & 0x80 ? " interlaced" : "", stereo,
+	       refresh, (float)pixclk_khz / (ha + hbl)
 	      );
 	if ((!max_display_width_mm && hor_mm) ||
 	    (!max_display_height_mm && vert_mm)) {
@@ -1505,8 +1506,8 @@ static void cta_svd(const unsigned char *x, unsigned n, int for_ycbcr420)
 			mode = "Unknown mode";
 		}
 
-		printf("    VIC %3u %s %s HorFreq: %u Hz Clock: %.3f MHz\n",
-		       vic, mode, native ? "(native)" : "", hfreq, clock_khz / 1000.0);
+		printf("VIC %3u %s%sHorFreq: %.3f kHz Clock: %.3f MHz",
+		       vic, mode, native ? " (native) " : " ", hfreq / 1000.0, clock_khz / 1000.0);
 		if (vic == 1)
 			has_cta861_vic_1 = 1;
 	}
@@ -1690,8 +1691,8 @@ static void cta_hdmi_block(const unsigned char *x, unsigned length)
 				mode = "Unknown mode";
 			}
 
-			printf("      HDMI VIC %u %s HorFreq: %u Hz Clock: %.3f MHz\n",
-			       vic, mode, hfreq, clock_khz / 1000.0);
+			printf("      HDMI VIC %u %s HorFreq: %.3f kHz Clock: %.3f MHz\n",
+			       vic, mode, hfreq / 1000.0, clock_khz / 1000.0);
 		}
 
 		b += len_vic;
@@ -2706,14 +2707,14 @@ static int parse_displayid(const unsigned char *x)
 			printf("Type 1 VESA DMT Timings Block\n");
 			for (i = 0; i < min(len, 10) * 8; i++) {
 				if (x[offset + 3 + i / 8] & (1 << (i % 8))) {
-					printf("  %ux%u%s@%uHz %s%u:%u HorFreq: %u Hz Clock: %.3f MHz\n",
+					printf("  %ux%u%s@%uHz %s%u:%u HorFreq: %.3f kHz Clock: %.3f MHz\n",
 					       displayid_vesa_dmt[i].x,
 					       displayid_vesa_dmt[i].y,
 					       displayid_vesa_dmt[i].interlaced ? "i" : "",
 					       displayid_vesa_dmt[i].refresh,
 					       displayid_vesa_dmt[i].rb ? "RB " : "",
 					       displayid_vesa_dmt[i].ratio_w, displayid_vesa_dmt[i].ratio_h,
-					       displayid_vesa_dmt[i].hor_freq_hz,
+					       displayid_vesa_dmt[i].hor_freq_hz / 1000.0,
 					       displayid_vesa_dmt[i].pixclk_khz / 1000.0);
 					min_vert_freq_hz = min(min_vert_freq_hz, displayid_vesa_dmt[i].refresh);
 					max_vert_freq_hz = max(max_vert_freq_hz, displayid_vesa_dmt[i].refresh);
@@ -3455,12 +3456,12 @@ static int edid_from_file(const char *from_file, const char *to_file,
 			min_hor_freq_hz = min(min_hor_freq_hz, established_timings[i].hor_freq_hz);
 			max_hor_freq_hz = max(max_hor_freq_hz, established_timings[i].hor_freq_hz);
 			max_pixclk_khz = max(max_pixclk_khz, established_timings[i].pixclk_khz);
-			printf("  %ux%u%s@%uHz %u:%u HorFreq: %d Hz Clock: %.3f MHz\n",
+			printf("  %ux%u%s@%uHz %u:%u HorFreq: %.3f kHz Clock: %.3f MHz\n",
 			       established_timings[i].x, established_timings[i].y,
 			       established_timings[i].interlaced ? "i" : "",
 			       established_timings[i].refresh,
 			       established_timings[i].ratio_w, established_timings[i].ratio_h,
-			       established_timings[i].hor_freq_hz,
+			       established_timings[i].hor_freq_hz / 1000.0,
 			       established_timings[i].pixclk_khz / 1000.0);
 		}
 	}
-- 
2.21.0 (Apple Git-122.2)


  reply	other threads:[~2019-11-23 16:46 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-23 16:45 [PATCH 00/10] edid-decode: bug fixes, additions, changes joevt
2019-11-23 16:45 ` joevt [this message]
2019-11-23 16:45 ` [PATCH 02/10] edid-decode: correct horizontal range in Monitor Ranges joevt
2019-11-23 16:45 ` [PATCH 03/10] edid-decode: correct calculation of DisplayID type 1 timings joevt
2019-11-23 16:45 ` [PATCH 04/10] edid-decode: add front porch, pulse width, and back porch joevt
2019-11-23 16:45 ` [PATCH 05/10] edid-decode: output timings for YCbCr 4:2:0 cmdb joevt
2019-11-24 10:26   ` Hans Verkuil
2019-11-25  6:32     ` Joe van Tunen
2019-11-25  8:20       ` Hans Verkuil
2019-11-23 16:46 ` [PATCH 06/10] edid-decode: Dump hex of unknown CTA Vendor-Specific blocks joevt
2019-11-23 16:46 ` [PATCH 07/10] edid-decode: cleanup printf format string compiler warnings joevt
2019-11-23 16:46 ` [PATCH 08/10] edid-decode: Dump hex of non-decoded extension blocks joevt
2019-11-23 16:46 ` [PATCH 09/10] edid-decode: DisplayID additions joevt
2019-11-24 10:03   ` Hans Verkuil
2019-11-25  6:30     ` Joe van Tunen
2019-11-25  9:15       ` Hans Verkuil
2019-11-23 16:46 ` [PATCH 10/10] edid-decode: add example EDIDs joevt
2019-11-24 11:10   ` Hans Verkuil
2019-11-24 11:12 ` [PATCH 00/10] edid-decode: bug fixes, additions, changes Hans Verkuil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191123164604.268-2-joevt@shaw.ca \
    --to=joevt@shaw.ca \
    --cc=hverkuil@xs4all.nl \
    --cc=linux-media@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.