aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil-cisco@xs4all.nl>2021-10-12 11:39:53 +0200
committerHans Verkuil <hverkuil-cisco@xs4all.nl>2021-10-12 11:39:53 +0200
commit985024f0ccb7eb0014397f2d562ecebfdd340c3b (patch)
treed1add05516e6122b60d8c524c33b40b40136228a
parentb85a0568e388ef51c444de4ccc724eb76b84c967 (diff)
edid-decode: add CVT 2.0 vblank support
With CVT 2.0 you can select the vertical blank time as input parameter to the calculation. Range 460-705 (higher might not work). Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
-rw-r--r--calc-gtf-cvt.cpp11
-rw-r--r--edid-decode.16
-rw-r--r--edid-decode.cpp18
-rw-r--r--edid-decode.h5
4 files changed, 31 insertions, 9 deletions
diff --git a/calc-gtf-cvt.cpp b/calc-gtf-cvt.cpp
index 4ce098e..dc22ad5 100644
--- a/calc-gtf-cvt.cpp
+++ b/calc-gtf-cvt.cpp
@@ -132,7 +132,7 @@ void edid_state::edid_gtf_mode(unsigned refresh, struct timings &t)
timings edid_state::calc_cvt_mode(unsigned h_pixels, unsigned v_lines,
double ip_freq_rqd, unsigned rb, bool int_rqd,
bool margins_rqd, bool alt, unsigned rb_h_blank,
- bool early_vsync_rqd)
+ unsigned rb_v_blank, bool early_vsync_rqd)
{
timings t = {};
@@ -140,6 +140,9 @@ timings edid_state::calc_cvt_mode(unsigned h_pixels, unsigned v_lines,
t.vact = v_lines;
t.interlaced = int_rqd;
+ if (rb_v_blank < CVT_RB_MIN_VBLANK)
+ rb_v_blank = CVT_RB_MIN_VBLANK;
+
double cell_gran = rb == RB_CVT_V2 ? 1 : CELL_GRAN;
double h_pixels_rnd = floor(h_pixels / cell_gran) * cell_gran;
double v_lines_rnd = int_rqd ? floor(v_lines / 2.0) : v_lines;
@@ -153,7 +156,7 @@ timings edid_state::calc_cvt_mode(unsigned h_pixels, unsigned v_lines,
double h_blank = (rb == RB_CVT_V1 || (rb == RB_CVT_V3 && alt)) ? 160 : 80;
double rb_v_fporch = rb == RB_CVT_V1 ? 3 : 1;
double refresh_multiplier = (rb == RB_CVT_V2 && alt) ? 1000.0 / 1001.0 : 1;
- double rb_min_vblank = CVT_RB_MIN_VBLANK;
+ double rb_min_vblank = rb == RB_CVT_V3 ? rb_v_blank : CVT_RB_MIN_VBLANK;
double h_sync = 32;
double v_sync;
@@ -246,13 +249,13 @@ timings edid_state::calc_cvt_mode(unsigned h_pixels, unsigned v_lines,
}
void edid_state::edid_cvt_mode(unsigned refresh, struct timings &t, unsigned rb_h_blank,
- bool early_vsync_rqd)
+ unsigned rb_v_blank, bool early_vsync_rqd)
{
unsigned hratio = t.hratio;
unsigned vratio = t.vratio;
t = calc_cvt_mode(t.hact, t.vact, refresh, t.rb & ~RB_ALT, t.interlaced,
- false, t.rb & RB_ALT, rb_h_blank, early_vsync_rqd);
+ false, t.rb & RB_ALT, rb_h_blank, rb_v_blank, early_vsync_rqd);
t.hratio = hratio;
t.vratio = vratio;
}
diff --git a/edid-decode.1 b/edid-decode.1
index a9d7eae..a304aa8 100644
--- a/edid-decode.1
+++ b/edid-decode.1
@@ -266,7 +266,7 @@ Show the timings for this VIC.
Show the timings for this HDMI VIC.
.TP
\fB\-\-cvt\fR \fBw\fR=\fI<width>\fR,\fBh\fR=\fI<height>\fR,\fBfps\fR=\fI<fps>\fR[,\fBrb\fR=\fI<rb>\fR][,\fBinterlaced\fR][,\fBoverscan\fR]
-[,\fBalt\fR][,\fBhblank\fR=\fI<hblank>\fR][,\fBearly\-vsync\fR]
+[,\fBalt\fR][,\fBhblank\fR=\fI<hblank>\fR][,\fBvblank\fR=\fI<vblank>\fR][,\fBearly\-vsync\fR]
.br
Calculate the CVT timings for the given format.
@@ -289,6 +289,10 @@ is 160 instead of 80 pixels.
If \fBhblank\fR is given and \fI<rb>\fR=3, then the horizontal blanking
is \fI<hblank>\fR pixels (range of 80-200 and divisible by 8), overriding \fBalt\fR.
.br
+If \fBvblank\fR is given and \fI<rb>\fR=3, then the vertical blanking time
+is \fI<vblank>\fR microseconds (460 minimum, values > 705 might not be supported by
+all RBv3 timings compliant source devices.
+.br
If \fBearly\-vsync\fR is given and \fI<rb>\fR=3, then select an early vsync timing.
.TP
\fB\-\-gtf\fR \fBw\fR=\fI<width>\fR,\fBh\fR=\fI<height>\fR[,\fBfps\fR=\fI<fps>\fR][,\fBhorfreq\fR=\fI<horfreq>\fR][,\fBpixclk\fR=\fI<pixclk>\fR]
diff --git a/edid-decode.cpp b/edid-decode.cpp
index 84a59d3..fcae469 100644
--- a/edid-decode.cpp
+++ b/edid-decode.cpp
@@ -142,7 +142,7 @@ static void usage(void)
" --dmt <dmt> Show the timings for the DMT with the given DMT ID.\n"
" --vic <vic> Show the timings for this VIC.\n"
" --hdmi-vic <hdmivic> Show the timings for this HDMI VIC.\n"
- " --cvt w=<width>,h=<height>,fps=<fps>[,rb=<rb>][,interlaced][,overscan][,alt][,hblank=<hblank][,early-vsync]\n"
+ " --cvt w=<width>,h=<height>,fps=<fps>[,rb=<rb>][,interlaced][,overscan][,alt][,hblank=<hblank][,vblank=<vblank][,early-vsync]\n"
" Calculate the CVT timings for the given format.\n"
" <fps> is frames per second for progressive timings,\n"
" or fields per second for interlaced timings.\n"
@@ -156,6 +156,8 @@ static void usage(void)
" is 160 instead of 80 pixels.\n"
" If 'hblank' is given and <rb>=3, then the horizontal blanking\n"
" is <hblank> pixels (range of 80-200), overriding 'alt'.\n"
+ " If 'vblank' is given and <rb>=3, then the vertical blanking\n"
+ " time is <vblank> microseconds (range of 460-705).\n"
" If 'early-vsync' is given and <rb=3>, then select early vsync.\n"
" --gtf w=<width>,h=<height>[,fps=<fps>][,horfreq=<horfreq>][,pixclk=<pixclk>][,interlaced]\n"
" [,overscan][,secondary][,C=<c>][,M=<m>][,K=<k>][,J=<j>]\n"
@@ -1509,6 +1511,7 @@ enum cvt_opts {
CVT_RB,
CVT_ALT,
CVT_RB_H_BLANK,
+ CVT_RB_V_BLANK,
CVT_EARLY_VSYNC,
};
@@ -1526,6 +1529,7 @@ static int parse_cvt_subopt(char **subopt_str, double *value)
"rb",
"alt",
"hblank",
+ "vblank",
"early-vsync",
nullptr
};
@@ -1556,6 +1560,7 @@ static void parse_cvt(char *optarg)
double fps = 0;
unsigned rb = RB_NONE;
unsigned rb_h_blank = 0;
+ unsigned rb_v_blank = 460;
bool interlaced = false;
bool alt = false;
bool overscan = false;
@@ -1592,6 +1597,15 @@ static void parse_cvt(char *optarg)
case CVT_RB_H_BLANK:
rb_h_blank = opt_val;
break;
+ case CVT_RB_V_BLANK:
+ rb_v_blank = opt_val;
+ if (rb_v_blank < 460) {
+ fprintf(stderr, "vblank must be >= 460, set to 460.\n");
+ rb_v_blank = 460;
+ } else if (rb_v_blank > 705) {
+ fprintf(stderr, "warning: vblank values > 705 might not be supported by RBv3 compliant sources.\n");
+ }
+ break;
case CVT_EARLY_VSYNC:
early_vsync = true;
break;
@@ -1608,7 +1622,7 @@ static void parse_cvt(char *optarg)
if (interlaced)
fps /= 2;
timings t = state.calc_cvt_mode(w, h, fps, rb, interlaced, overscan, alt,
- rb_h_blank, early_vsync);
+ rb_h_blank, rb_v_blank, early_vsync);
state.print_timings("", &t, "CVT", "", true, false);
}
diff --git a/edid-decode.h b/edid-decode.h
index fad66fc..87cf662 100644
--- a/edid-decode.h
+++ b/edid-decode.h
@@ -318,9 +318,10 @@ struct edid_state {
timings calc_cvt_mode(unsigned h_pixels, unsigned v_lines,
double ip_freq_rqd, unsigned rb, bool int_rqd = false,
bool margins_rqd = false, bool alt = false,
- unsigned rb_h_blank = 0, bool early_vsync_rqd = false);
+ unsigned rb_h_blank = 0, unsigned rb_v_blank = 460,
+ bool early_vsync_rqd = false);
void edid_cvt_mode(unsigned refresh, struct timings &t, unsigned rb_h_blank = 0,
- bool early_vsync_rqd = false);
+ unsigned rb_v_blank = 460, bool early_vsync_rqd = false);
void detailed_cvt_descriptor(const char *prefix, const unsigned char *x, bool first);
void print_standard_timing(const char *prefix, unsigned char b1, unsigned char b2,
bool gtf_only = false, bool show_both = false);

Privacy Policy