aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil-cisco@xs4all.nl>2021-10-02 12:20:54 +0200
committerHans Verkuil <hverkuil-cisco@xs4all.nl>2021-10-03 12:37:45 +0200
commit84ddf9155376a6044f729ce6a0e60639c26aed2b (patch)
tree90b22844f28a1b55b490ac90661f7a32c1ca495f
parent46a55672e67541886c55830260e90924c7ecd94f (diff)
edid-decode: add --ntsc option
When this option is given any timings with vertical refresh rates that are a multiple of 6 will be shown with a reduced pixel clock (1000 / 1001) for NTSC-based video. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
-rw-r--r--edid-decode.15
-rw-r--r--edid-decode.cpp17
2 files changed, 18 insertions, 4 deletions
diff --git a/edid-decode.1 b/edid-decode.1
index 4a20993..5d87647 100644
--- a/edid-decode.1
+++ b/edid-decode.1
@@ -206,6 +206,11 @@ Report all video timings in a short format.
\fB\-L\fR, \fB\-\-long\-timings\fR
Report all video timings in a long format.
.TP
+\fB\-N\fR, \fB\-\-ntsc\fR
+Report the video timings with values suitable for NTSC-based video.
+E.g., this will show refresh rates of 29.97 Hz instead of 30 Hz.
+This is only done for timings with refresh rates that are a multiple of 6.
+.TP
\fB\-X\fR, \fB\-\-xmodeline\fR
Report all long video timings in the ModeLine format as defined in xorg.conf(5).
This ModeLine can be used in the xorg.conf file or passed to xrandr(1) with the
diff --git a/edid-decode.cpp b/edid-decode.cpp
index c274121..c2361b3 100644
--- a/edid-decode.cpp
+++ b/edid-decode.cpp
@@ -47,6 +47,7 @@ enum Option {
OptOnlyHexDump = 'H',
OptLongTimings = 'L',
OptNativeResolution = 'n',
+ OptNTSC = 'N',
OptOutputFormat = 'o',
OptPreferredTimings = 'p',
OptPhysicalAddress = 'P',
@@ -87,6 +88,7 @@ static struct option long_options[] = {
{ "check", no_argument, 0, OptCheck },
{ "short-timings", no_argument, 0, OptShortTimings },
{ "long-timings", no_argument, 0, OptLongTimings },
+ { "ntsc", no_argument, 0, OptNTSC },
{ "xmodeline", no_argument, 0, OptXModeLineTimings },
{ "fbmode", no_argument, 0, OptFBModeTimings },
{ "v4l2-timings", no_argument, 0, OptV4L2Timings },
@@ -127,6 +129,7 @@ static void usage(void)
" -P, --physical-address Only report the CEC physical address.\n"
" -S, --short-timings Report all video timings in a short format.\n"
" -L, --long-timings Report all video timings in a long format.\n"
+ " -N, --ntsc Report the video timings suitable for NTSC-based video.\n"
" -X, --xmodeline Report all long video timings in Xorg.conf format.\n"
" -F, --fbmode Report all long video timings in fb.modes format.\n"
" -V, --v4l2-timings Report all long video timings in v4l2-dv-timings.h format.\n"
@@ -538,7 +541,14 @@ bool edid_state::print_timings(const char *prefix, const struct timings *t,
else if (t->interlaced)
vtotal = vact + t->vfp + t->vsync + t->vbp + 0.5;
- double refresh = (double)t->pixclk_khz * 1000.0 / (htotal * vtotal);
+ double refresh = t->pixclk_khz * 1000.0 / (htotal * vtotal);
+ double pixclk = t->pixclk_khz * 1000.0;
+ if (options[OptNTSC] && fmod(refresh, 6.0) == 0) {
+ const double ntsc_fact = 1000.0 / 1001.0;
+ pixclk *= ntsc_fact;
+ refresh *= ntsc_fact;
+ out_hor_freq_khz *= ntsc_fact;
+ }
std::string s;
unsigned rb = t->rb & ~RB_ALT;
@@ -559,19 +569,18 @@ bool edid_state::print_timings(const char *prefix, const struct timings *t,
dtd_max_vsize_mm = t->vsize_mm;
if (!s.empty())
s = " (" + s + ")";
- unsigned out_pixclk_khz = t->pixclk_khz;
unsigned pixclk_khz = t->pixclk_khz / (t->ycbcr420 ? 2 : 1);
char buf[10];
sprintf(buf, "%u%s", t->vact, t->interlaced ? "i" : "");
- printf("%s%s: %5ux%-5s %7.3f Hz %3u:%-3u %8.3f kHz %10.3f MHz%s\n",
+ printf("%s%s: %5ux%-5s %10.6f Hz %3u:%-3u %8.3f kHz %13.6f MHz%s\n",
prefix, type,
t->hact, buf,
refresh,
t->hratio, t->vratio,
out_hor_freq_khz,
- out_pixclk_khz / 1000.0,
+ pixclk / 1000000.0,
s.c_str());
unsigned len = strlen(prefix) + 2;

Privacy Policy