video: tegra: dc: clean up dynamic emc code
Jon Mayo [Thu, 7 Jul 2011 23:29:57 +0000 (16:29 -0700)]
refactor emc code and centralize it in one place.

Bug 850852

Original-Change-Id: Icddd270d1ea4f47de11aa3633dd2dbb205a15742
Reviewed-on: http://git-master/r/40131
Reviewed-by: Varun Colbert <vcolbert@nvidia.com>
Tested-by: Varun Colbert <vcolbert@nvidia.com>

Rebase-Id: R50b0fc763281d1ce1b0758caf5e42bfb2d4a3050

arch/arm/mach-tegra/include/mach/dc.h
drivers/video/tegra/dc/dc.c
drivers/video/tegra/dc/overlay.c
drivers/video/tegra/fb.c

index 4b25c64..ebc38b5 100644 (file)
@@ -436,7 +436,6 @@ u32 tegra_dc_incr_syncpt_max(struct tegra_dc *dc);
 void tegra_dc_incr_syncpt_min(struct tegra_dc *dc, u32 val);
 
 int tegra_dc_set_default_emc(struct tegra_dc *dc);
-int tegra_dc_set_dynamic_emc(struct tegra_dc_win *windows[], int n);
 
 /* tegra_dc_update_windows and tegra_dc_sync_windows do not support windows
  * with differenct dcs in one call
index 7457286..a2cd916 100644 (file)
@@ -736,7 +736,7 @@ static void tegra_dc_reduce_emc_worker(struct work_struct *work)
        mutex_unlock(&dc->lock);
 }
 
-int  tegra_dc_set_dynamic_emc(struct tegra_dc_win *windows[], int n)
+static int tegra_dc_set_dynamic_emc(struct tegra_dc_win *windows[], int n)
 {
        unsigned long new_rate;
        struct tegra_dc *dc;
@@ -746,13 +746,6 @@ int  tegra_dc_set_dynamic_emc(struct tegra_dc_win *windows[], int n)
 
        dc = windows[0]->dc;
 
-       mutex_lock(&dc->lock);
-
-       if (!dc->enabled) {
-               mutex_unlock(&dc->lock);
-               return -EFAULT;
-       }
-
        /* calculate the new rate based on this POST */
        new_rate = tegra_dc_get_emc_rate(windows, n);
 
@@ -770,12 +763,10 @@ int  tegra_dc_set_dynamic_emc(struct tegra_dc_win *windows[], int n)
                schedule_delayed_work(&dc->reduce_emc_clk_work,
                        msecs_to_jiffies(windows_idle_detection_time));
 
-       mutex_unlock(&dc->lock);
-
        return 0;
 }
 
-int  tegra_dc_set_default_emc(struct tegra_dc *dc)
+int tegra_dc_set_default_emc(struct tegra_dc *dc)
 {
        /*
         * POST happens whenever this function is called, we first delete any
@@ -820,6 +811,8 @@ int tegra_dc_update_windows(struct tegra_dc_win *windows[], int n)
                return -EFAULT;
        }
 
+       tegra_dc_set_dynamic_emc(windows, n);
+
        if (no_vsync)
                tegra_dc_writel(dc, WRITE_MUX_ACTIVE | READ_MUX_ACTIVE, DC_CMD_STATE_ACCESS);
        else
index ed45612..fc4b02a 100644 (file)
@@ -310,11 +310,9 @@ static void tegra_overlay_flip_worker(struct work_struct *work)
                        dcwins[i] = tegra_dc_get_window(overlay->dc, i);
 
                tegra_overlay_blend_reorder(&overlay->blend, dcwins);
-               tegra_dc_set_dynamic_emc(dcwins, DC_N_WINDOWS);
                tegra_dc_update_windows(dcwins, DC_N_WINDOWS);
                tegra_dc_sync_windows(dcwins, DC_N_WINDOWS);
        } else {
-               tegra_dc_set_dynamic_emc(wins, nr_win);
                tegra_dc_update_windows(wins, nr_win);
                /* TODO: implement swapinterval here */
                tegra_dc_sync_windows(wins, nr_win);
index 4b46fdf..0fdf6e0 100644 (file)
@@ -289,7 +289,6 @@ static int tegra_fb_pan_display(struct fb_var_screeninfo *var,
                /* TODO: update virt_addr */
 
                tegra_dc_set_default_emc(tegra_fb->win->dc);
-               tegra_dc_set_dynamic_emc(&tegra_fb->win, 1);
                tegra_dc_update_windows(&tegra_fb->win, 1);
                tegra_dc_sync_windows(&tegra_fb->win, 1);
        }
@@ -500,7 +499,6 @@ static void tegra_fb_flip_worker(struct work_struct *work)
 #endif
        }
 
-       tegra_dc_set_dynamic_emc(wins, nr_win);
        tegra_dc_update_windows(wins, nr_win);
        /* TODO: implement swapinterval here */
        tegra_dc_sync_windows(wins, nr_win);
@@ -861,7 +859,6 @@ struct tegra_fb_info *tegra_fb_register(struct nvhost_device *ndev,
 
        if (fb_data->flags & TEGRA_FB_FLIP_ON_PROBE) {
                tegra_dc_set_default_emc(tegra_fb->win->dc);
-               tegra_dc_set_dynamic_emc(&tegra_fb->win, 1);
                tegra_dc_update_windows(&tegra_fb->win, 1);
                tegra_dc_sync_windows(&tegra_fb->win, 1);
        }