Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / drivers / video / aty / mach64_ct.c
index e3325d5..e705693 100644 (file)
@@ -206,9 +206,7 @@ static int aty_valid_pll_ct(const struct fb_info *info, u32 vclk_per, struct pll
 {
        u32 q;
        struct atyfb_par *par = (struct atyfb_par *) info->par;
-#ifdef DEBUG
        int pllvclk;
-#endif
 
        /* FIXME: use the VTB/GTB /{3,6,12} post dividers if they're better suited */
        q = par->ref_clk_per * pll->pll_ref_div * 4 / vclk_per;
@@ -223,13 +221,26 @@ static int aty_valid_pll_ct(const struct fb_info *info, u32 vclk_per, struct pll
        pll->vclk_post_div_real = postdividers[pll->vclk_post_div];
        //    pll->vclk_post_div <<= 6;
        pll->vclk_fb_div = q * pll->vclk_post_div_real / 8;
-#ifdef DEBUG
        pllvclk = (1000000 * 2 * pll->vclk_fb_div) /
                (par->ref_clk_per * pll->pll_ref_div);
+#ifdef DEBUG
        printk("atyfb(%s): pllvclk=%d MHz, vclk=%d MHz\n",
                __FUNCTION__, pllvclk, pllvclk / pll->vclk_post_div_real);
 #endif
        pll->pll_vclk_cntl = 0x03; /* VCLK = PLL_VCLK/VCLKx_POST */
+
+       /* Set ECP (scaler/overlay clock) divider */
+       if (par->pll_limits.ecp_max) {
+               int ecp = pllvclk / pll->vclk_post_div_real;
+               int ecp_div = 0;
+
+               while (ecp > par->pll_limits.ecp_max && ecp_div < 2) {
+                       ecp >>= 1;
+                       ecp_div++;
+               }
+               pll->pll_vclk_cntl |= ecp_div << 4;
+       }
+
        return 0;
 }
 
@@ -359,7 +370,8 @@ void aty_set_pll_ct(const struct fb_info *info, const union aty_pll *pll)
 #endif
 }
 
-void __init aty_get_pll_ct(const struct fb_info *info, union aty_pll *pll)
+static void __init aty_get_pll_ct(const struct fb_info *info,
+                                 union aty_pll *pll)
 {
        struct atyfb_par *par = (struct atyfb_par *) info->par;
        u8 tmp, clock;
@@ -382,7 +394,9 @@ void __init aty_get_pll_ct(const struct fb_info *info, union aty_pll *pll)
        }
 }
 
-int __init aty_init_pll_ct(const struct fb_info *info, union aty_pll *pll) {
+static int __init aty_init_pll_ct(const struct fb_info *info,
+                                union aty_pll *pll)
+{
        struct atyfb_par *par = (struct atyfb_par *) info->par;
        u8 mpost_div, xpost_div, sclk_post_div_real, sclk_fb_div, spll_cntl2;
        u32 q, i, memcntl, trp;