All of lore.kernel.org
 help / color / mirror / Atom feed
From: Prashant Laddha <prladdha@cisco.com>
To: linux-media@vger.kernel.org
Cc: Hans Verkuil <hans.verkuil@cisco.com>,
	Prashant Laddha <prladdha@cisco.com>
Subject: [PATCH 1/2] v4l2-ctl-modes: fix hblank, hsync rounding in gtf calculation
Date: Mon,  4 May 2015 16:18:58 +0530	[thread overview]
Message-ID: <1430736539-28469-2-git-send-email-prladdha@cisco.com> (raw)
In-Reply-To: <1430736539-28469-1-git-send-email-prladdha@cisco.com>

In gtf modeline calculations, currently hblank and hsync are rounded
down. hblank needs to be rounded to nearest multiple of twice the
cell granularity. hsync needs to be rounded to nearest multiple of
cell granularity. Changed the rounding calculation to match it with
the equations in standards.

Cc: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Prashant Laddha <prladdha@cisco.com>
---
 utils/v4l2-ctl/v4l2-ctl-modes.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/utils/v4l2-ctl/v4l2-ctl-modes.cpp b/utils/v4l2-ctl/v4l2-ctl-modes.cpp
index c775bda..4689006 100644
--- a/utils/v4l2-ctl/v4l2-ctl-modes.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-modes.cpp
@@ -457,12 +457,13 @@ bool calc_gtf_modeline(int image_width, int image_height,
 
 	h_blank = active_h_pixel * ideal_blank_duty_cycle /
 			 (100 * HV_FACTOR - ideal_blank_duty_cycle);
-	h_blank -= h_blank % (2 * GTF_CELL_GRAN);
+	h_blank = ((h_blank + GTF_CELL_GRAN) / (2 * GTF_CELL_GRAN))
+			  * (2 * GTF_CELL_GRAN);
 
 	total_h_pixel = active_h_pixel + h_blank;
 
-	h_sync  = (total_h_pixel * GTF_HSYNC_PERCENT) / 100;
-	h_sync -= h_sync % GTF_CELL_GRAN;
+	h_sync = (total_h_pixel * GTF_HSYNC_PERCENT) / 100;
+	h_sync = ((h_sync + GTF_CELL_GRAN / 2) / GTF_CELL_GRAN) * GTF_CELL_GRAN;
 
 	h_fp = h_blank / 2 - h_sync;
 	h_bp = h_fp + h_sync;
@@ -509,6 +510,5 @@ bool calc_gtf_modeline(int image_width, int image_height,
 		gtf->flags |= V4L2_DV_FL_REDUCED_BLANKING;
 	} else
 		gtf->polarities = V4L2_DV_VSYNC_POS_POL;
-
 	return true;
 }
-- 
1.9.1


  reply	other threads:[~2015-05-04 11:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-04 10:48 [PATCH 0/2] rounding and overflow fix in cvt,gtf calculations Prashant Laddha
2015-05-04 10:48 ` Prashant Laddha [this message]
2015-05-04 10:48 ` [PATCH 2/2] v4l2-utils: fix overflow in cvt, gtf calculations Prashant Laddha

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=1430736539-28469-2-git-send-email-prladdha@cisco.com \
    --to=prladdha@cisco.com \
    --cc=hans.verkuil@cisco.com \
    --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.