summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPrashant Laddha <prladdha@cisco.com>2015-04-22 14:32:35 -0300
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2015-05-01 07:14:37 -0300
commitd7ed5a3ddaec19d866ffc05ed2733179fbe4da9e (patch)
tree7daa64db9626284e2a353fdd2323131c77c301d5
parentf67476589afc9a4a48bc342f1b5f505b508bd1ff (diff)
downloadlinux-stable-d7ed5a3ddaec19d866ffc05ed2733179fbe4da9e.tar.gz
linux-stable-d7ed5a3ddaec19d866ffc05ed2733179fbe4da9e.tar.bz2
linux-stable-d7ed5a3ddaec19d866ffc05ed2733179fbe4da9e.zip
[media] v4l2-dv-timings: fix rounding in hblank and hsync calculation
Changed the rounding calculation for hblank and hsync to match it to equations in cvt and gtf standards. In cvt calculation, hsync needs to be rounded down. In gtf calculations, hblank needs to be rounded to nearest multiple of twice the cell granularity and hsync needs to be rounded to the nearest multiple of cell granularity. Cc: Martin Bugge <marbugge@cisco.com> Signed-off-by: Prashant Laddha <prladdha@cisco.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
-rw-r--r--drivers/media/v4l2-core/v4l2-dv-timings.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/media/v4l2-core/v4l2-dv-timings.c b/drivers/media/v4l2-core/v4l2-dv-timings.c
index 32aa25fa560b..16c8ac5b5e0b 100644
--- a/drivers/media/v4l2-core/v4l2-dv-timings.c
+++ b/drivers/media/v4l2-core/v4l2-dv-timings.c
@@ -436,8 +436,8 @@ bool v4l2_detect_cvt(unsigned frame_height, unsigned hfreq, unsigned vsync,
h_bp = h_blank / 2;
frame_width = image_width + h_blank;
- hsync = (frame_width * 8 + 50) / 100;
- hsync = hsync - hsync % CVT_CELL_GRAN;
+ hsync = frame_width * 8 / 100;
+ hsync = (hsync / CVT_CELL_GRAN) * CVT_CELL_GRAN;
h_fp = h_blank - hsync - h_bp;
}
@@ -552,14 +552,15 @@ bool v4l2_detect_gtf(unsigned frame_height,
(hfreq * (100 - GTF_S_C_PRIME) + GTF_S_M_PRIME * 1000) / 2) /
(hfreq * (100 - GTF_S_C_PRIME) + GTF_S_M_PRIME * 1000);
- h_blank = h_blank - h_blank % (2 * GTF_CELL_GRAN);
+ h_blank = ((h_blank + GTF_CELL_GRAN) / (2 * GTF_CELL_GRAN)) *
+ (2 * GTF_CELL_GRAN);
frame_width = image_width + h_blank;
pix_clk = (image_width + h_blank) * hfreq;
pix_clk = pix_clk / GTF_PXL_CLK_GRAN * GTF_PXL_CLK_GRAN;
hsync = (frame_width * 8 + 50) / 100;
- hsync = hsync - hsync % GTF_CELL_GRAN;
+ hsync = ((hsync + GTF_CELL_GRAN / 2) / GTF_CELL_GRAN) * GTF_CELL_GRAN;
h_fp = h_blank / 2 - hsync;