video: tegra: dsi: Remove spurious warnings
Animesh Kishore [Tue, 26 Feb 2013 12:07:06 +0000 (17:07 +0530)]
Change-Id: I40b55d66258f06c1eb19dddc2815153b4f8346ec
Signed-off-by: Animesh Kishore <ankishore@nvidia.com>
Reviewed-on: http://git-master/r/204178
Reviewed-by: Simone Willett <swillett@nvidia.com>
Tested-by: Simone Willett <swillett@nvidia.com>
(cherry picked from commit 95861c68d23f881985cc139ce6f8dcb8ebfcdf4a)
Reviewed-on: http://git-master/r/208365
Reviewed-by: Mandar Padmawar <mpadmawar@nvidia.com>
Tested-by: Mandar Padmawar <mpadmawar@nvidia.com>

drivers/video/tegra/dc/dc_priv.h
drivers/video/tegra/dc/dsi.c

index 38ff228..3861c06 100644 (file)
@@ -185,6 +185,21 @@ static inline u32 tegra_dc_unmask_interrupt(struct tegra_dc *dc, u32 int_val)
        return val;
 }
 
+static inline u32 tegra_dc_flush_interrupt(struct tegra_dc *dc, u32 int_val)
+{
+       u32 val;
+       unsigned long flag;
+
+       local_irq_save(flag);
+
+       val = tegra_dc_readl(dc, DC_CMD_INT_STATUS);
+       tegra_dc_writel(dc, (val | int_val), DC_CMD_INT_STATUS);
+
+       local_irq_restore(flag);
+
+       return val;
+}
+
 static inline u32 tegra_dc_mask_interrupt(struct tegra_dc *dc, u32 int_val)
 {
        u32 val;
index d494a63..a5d6dc2 100644 (file)
@@ -1569,13 +1569,13 @@ static void tegra_dsi_soft_reset(struct tegra_dc_dsi_data *dsi)
        u32 val;
        u32 frame_period = DIV_ROUND_UP(S_TO_MS(1), dsi->info.refresh_rate);
        struct tegra_dc_mode mode = dsi->dc->mode;
-       u32 line_period = DIV_ROUND_UP(
-                               MS_TO_US(frame_period),
-                               mode.v_sync_width + mode.v_back_porch +
-                               mode.v_active + mode.v_front_porch);
+       u32 tot_lines = mode.v_sync_width + mode.v_back_porch +
+                               mode.v_active + mode.v_front_porch;
+       u32 line_period = DIV_ROUND_UP(MS_TO_US(frame_period), tot_lines);
        u32 timeout_cnt = 0;
 
-#define DSI_IDLE_TIMEOUT       1000
+/* wait for 1 frame duration + few extra cycles for dsi to go idle */
+#define DSI_IDLE_TIMEOUT       (tot_lines + 5)
 
        val = tegra_dsi_readl(dsi, DSI_STATUS);
        while (!(val & DSI_STATUS_IDLE(0x1))) {
@@ -1632,6 +1632,9 @@ static void tegra_dsi_stop_dc_stream(struct tegra_dc *dc,
        dsi->status.dc_stream = DSI_DC_STREAM_DISABLE;
 }
 
+/* wait for frame end interrupt or (timeout_n_frames * 1 frame duration)
+ * whichever happens to occur first
+ */
 static int tegra_dsi_wait_frame_end(struct tegra_dc *dc,
                                struct tegra_dc_dsi_data *dsi,
                                u32 timeout_n_frames)
@@ -1651,6 +1654,7 @@ static int tegra_dsi_wait_frame_end(struct tegra_dc *dc,
 
        INIT_COMPLETION(dc->frame_end_complete);
 
+       tegra_dc_flush_interrupt(dc, FRAME_END_INT);
        /* unmask frame end interrupt */
        val = tegra_dc_unmask_interrupt(dc, FRAME_END_INT);
 
@@ -1671,18 +1675,12 @@ static void tegra_dsi_stop_dc_stream_at_frame_end(struct tegra_dc *dc,
                                                struct tegra_dc_dsi_data *dsi,
                                                u32 timeout_n_frames)
 {
-       long timeout;
-
        tegra_dsi_stop_dc_stream(dc, dsi);
 
-       timeout = tegra_dsi_wait_frame_end(dc, dsi, timeout_n_frames);
+       tegra_dsi_wait_frame_end(dc, dsi, timeout_n_frames);
 
        tegra_dsi_soft_reset(dsi);
 
-       if (timeout == 0)
-               dev_warn(&dc->ndev->dev,
-                       "DC doesn't stop at end of frame.\n");
-
        tegra_dsi_reset_underflow_overflow(dsi);
 }