summaryrefslogtreecommitdiff
path: root/drivers/media/v4l2-core/v4l2-dv-timings.c
diff options
context:
space:
mode:
authorPrashant Laddha <prladdha@cisco.com>2015-06-05 11:13:31 +0300
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2015-06-09 23:41:47 +0300
commitdc0cf4cfed89d3a784a8d1c5897fae8f6a137fa5 (patch)
tree4454f3fea0c3bbd00990217616dba826ca35bee1 /drivers/media/v4l2-core/v4l2-dv-timings.c
parent7a5d99e7c9702932c266cffb71afd4e1f2282b31 (diff)
downloadlinux-dc0cf4cfed89d3a784a8d1c5897fae8f6a137fa5.tar.xz
[media] v4l2-dv-timing: avoid rounding twice in gtf hblank calc
Currently, in gtf hblank calculations, the rounding is used twice, one at intermediate division and one at final state where hblank is rounded to nearest multiple of twice cell granularity. This error got introduced in 'commit d7ed5a3ddaec ("[media] v4l2-dv-timings: fix rounding in hblank and hsync calculation"), where it missed combining the rounding step. Correcting the same in this patch. 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>
Diffstat (limited to 'drivers/media/v4l2-core/v4l2-dv-timings.c')
-rw-r--r--drivers/media/v4l2-core/v4l2-dv-timings.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/media/v4l2-core/v4l2-dv-timings.c b/drivers/media/v4l2-core/v4l2-dv-timings.c
index 5792192bce6c..89866100a74a 100644
--- a/drivers/media/v4l2-core/v4l2-dv-timings.c
+++ b/drivers/media/v4l2-core/v4l2-dv-timings.c
@@ -561,20 +561,22 @@ bool v4l2_detect_gtf(unsigned frame_height,
num = ((image_width * GTF_D_C_PRIME * (u64)hfreq) -
((u64)image_width * GTF_D_M_PRIME * 1000));
- den = hfreq * (100 - GTF_D_C_PRIME) + GTF_D_M_PRIME * 1000;
+ den = (hfreq * (100 - GTF_D_C_PRIME) + GTF_D_M_PRIME * 1000) *
+ (2 * GTF_CELL_GRAN);
h_blank = div_u64((num + (den >> 1)), den);
+ h_blank *= (2 * GTF_CELL_GRAN);
} else {
u64 num;
u32 den;
num = ((image_width * GTF_S_C_PRIME * (u64)hfreq) -
((u64)image_width * GTF_S_M_PRIME * 1000));
- den = hfreq * (100 - GTF_S_C_PRIME) + GTF_S_M_PRIME * 1000;
+ den = (hfreq * (100 - GTF_S_C_PRIME) + GTF_S_M_PRIME * 1000) *
+ (2 * GTF_CELL_GRAN);
h_blank = div_u64((num + (den >> 1)), den);
+ 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;