tegra: dc: Fix div by zero in frame time computation.
Raghavendra VK [Mon, 27 Aug 2012 18:00:12 +0000 (11:00 -0700)]
- Set frame duration to 0 in NULL modeset.

bug 1039104

Change-Id: I2b7d5a8a7c1748d8d582505946014e002326cbee
Signed-off-by: Raghavendra VK <rvk@nvidia.com>
Reviewed-on: http://git-master/r/127603
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Robert Morell <rmorell@nvidia.com>
Reviewed-by: Jon Mayo <jmayo@nvidia.com>

Rebase-Id: R46793c4eae68c60a976767ef7b5f8b4ebe5194a7

drivers/video/tegra/dc/dc.c
drivers/video/tegra/dc/mode.c

index d76064b..ef33dcf 100644 (file)
@@ -1351,11 +1351,13 @@ static void tegra_dc_continuous_irq(struct tegra_dc *dc, unsigned long status)
 /* XXX: Not sure if we limit look ahead to 1 frame */
 bool tegra_dc_is_within_n_vsync(struct tegra_dc *dc, s64 ts)
 {
+       BUG_ON(!dc->frametime_ns);
        return ((ts - dc->frame_end_timestamp) < dc->frametime_ns);
 }
 
 bool tegra_dc_does_vsync_separate(struct tegra_dc *dc, s64 new_ts, s64 old_ts)
 {
+       BUG_ON(!dc->frametime_ns);
        return (((new_ts - old_ts) > dc->frametime_ns)
                || (div_s64((new_ts - dc->frame_end_timestamp), dc->frametime_ns)
                        != div_s64((old_ts - dc->frame_end_timestamp),
index 6a17e3e..963ced6 100644 (file)
@@ -144,7 +144,8 @@ static s64 calc_frametime_ns(const struct tegra_dc_mode *m)
                m->h_sync_width;
        v_total = m->v_active + m->v_front_porch + m->v_back_porch +
                m->v_sync_width;
-       return (s64)(div_s64(((s64)h_total * v_total * 1000000000ULL), m->pclk));
+       return (!m->pclk) ? 0 : (s64)(div_s64(((s64)h_total * v_total *
+                                       1000000000ULL), m->pclk));
 }
 
 /* return in 1000ths of a Hertz */