Changed the rounding offsets used in vsync_bp calculation in cvt and
gtf timings. The results for vsync_bp should now match with results
from timing generator spreadsheets for cvt and gtf standards.

In the vsync_bp calculation for cvt, always round down the value of
(CVT_MIN_VSYNC_BP / h_period_est) and then add 1. It thus, reflects
the equation used in timing generator spreadsheet. Using 1999999 as
rounding offset, could pontentially lead to bumping up the vsync_bp
value by extra 1.

In the vsync_bp calculations for gtf, instead of round up or round
down, round the (CVT_MIN_VSYNC_BP / h_period_est) to the nearest
integer.

Cc: Hans Verkuil <hans.verk...@cisco.com>
Cc: Martin Bugge <marbu...@cisco.com>

Thanks to Martin Bugge <marbu...@cisco.com> for validating with
standards and suggestions on equations.

Signed-off-by: Prashant Laddha <prlad...@cisco.com>
---
 drivers/media/v4l2-core/v4l2-dv-timings.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-dv-timings.c 
b/drivers/media/v4l2-core/v4l2-dv-timings.c
index c0e9638..32aa25f 100644
--- a/drivers/media/v4l2-core/v4l2-dv-timings.c
+++ b/drivers/media/v4l2-core/v4l2-dv-timings.c
@@ -368,14 +368,14 @@ bool v4l2_detect_cvt(unsigned frame_height, unsigned 
hfreq, unsigned vsync,
        /* Vertical */
        if (reduced_blanking) {
                v_fp = CVT_RB_V_FPORCH;
-               v_bp = (CVT_RB_MIN_V_BLANK * hfreq + 1999999) / 1000000;
+               v_bp = (CVT_RB_MIN_V_BLANK * hfreq) / 1000000 + 1;
                v_bp -= vsync + v_fp;
 
                if (v_bp < CVT_RB_MIN_V_BPORCH)
                        v_bp = CVT_RB_MIN_V_BPORCH;
        } else {
                v_fp = CVT_MIN_V_PORCH_RND;
-               v_bp = (CVT_MIN_VSYNC_BP * hfreq + 1999999) / 1000000 - vsync;
+               v_bp = (CVT_MIN_VSYNC_BP * hfreq) / 1000000 + 1 - vsync;
 
                if (v_bp < CVT_MIN_V_BPORCH)
                        v_bp = CVT_MIN_V_BPORCH;
@@ -529,7 +529,8 @@ bool v4l2_detect_gtf(unsigned frame_height,
 
        /* Vertical */
        v_fp = GTF_V_FP;
-       v_bp = (GTF_MIN_VSYNC_BP * hfreq + 999999) / 1000000 - vsync;
+
+       v_bp = (GTF_MIN_VSYNC_BP * hfreq + 500000) / 1000000 - vsync;
        image_height = (frame_height - v_fp - vsync - v_bp + 1) & ~0x1;
 
        if (aspect.numerator == 0 || aspect.denominator == 0) {
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to