lxfb: set the H- and V-SYNC polarity of the flatpanel output
[safe/jmp/linux-2.6] / drivers / video / geode / lxfb_ops.c
index aaef916..bc35a95 100644 (file)
@@ -13,7 +13,7 @@
 #include <linux/fb.h>
 #include <linux/uaccess.h>
 #include <linux/delay.h>
-#include <asm/geode.h>
+#include <linux/cs5535.h>
 
 #include "lxfb.h"
 
@@ -274,7 +274,15 @@ static void lx_graphics_enable(struct fb_info *info)
                u32 msrlo, msrhi;
 
                write_fp(par, FP_PT1, 0);
-               write_fp(par, FP_PT2, FP_PT2_SCRC);
+               temp = FP_PT2_SCRC;
+
+               if (info->var.sync & FB_SYNC_HOR_HIGH_ACT)
+                       temp |= FP_PT2_HSP;
+
+               if (info->var.sync & FB_SYNC_VERT_HIGH_ACT)
+                       temp |= FP_PT2_VSP;
+
+               write_fp(par, FP_PT2, temp);
                write_fp(par, FP_DFC, FP_DFC_BC);
 
                msrlo = MSR_LX_MSR_PADSEL_TFT_SEL_LOW;
@@ -307,7 +315,7 @@ unsigned int lx_framebuffer_size(void)
 {
        unsigned int val;
 
-       if (!geode_has_vsa2()) {
+       if (!cs5535_has_vsa2()) {
                uint32_t hi, lo;
 
                /* The number of pages is (PMAX - PMIN)+1 */
@@ -517,25 +525,25 @@ void lx_set_palette_reg(struct fb_info *info, unsigned regno,
 int lx_blank_display(struct fb_info *info, int blank_mode)
 {
        struct lxfb_par *par = info->par;
-       u32 dcfg, fp_pm;
-       int blank, hsync, vsync, crt;
+       u32 dcfg, misc, fp_pm;
+       int blank, hsync, vsync;
 
        /* CRT power saving modes. */
        switch (blank_mode) {
        case FB_BLANK_UNBLANK:
-               blank = 0; hsync = 1; vsync = 1; crt = 1;
+               blank = 0; hsync = 1; vsync = 1;
                break;
        case FB_BLANK_NORMAL:
-               blank = 1; hsync = 1; vsync = 1; crt = 1;
+               blank = 1; hsync = 1; vsync = 1;
                break;
        case FB_BLANK_VSYNC_SUSPEND:
-               blank = 1; hsync = 1; vsync = 0; crt = 1;
+               blank = 1; hsync = 1; vsync = 0;
                break;
        case FB_BLANK_HSYNC_SUSPEND:
-               blank = 1; hsync = 0; vsync = 1; crt = 1;
+               blank = 1; hsync = 0; vsync = 1;
                break;
        case FB_BLANK_POWERDOWN:
-               blank = 1; hsync = 0; vsync = 0; crt = 0;
+               blank = 1; hsync = 0; vsync = 0;
                break;
        default:
                return -EINVAL;
@@ -545,15 +553,23 @@ int lx_blank_display(struct fb_info *info, int blank_mode)
        dcfg &= ~(VP_DCFG_DAC_BL_EN | VP_DCFG_HSYNC_EN | VP_DCFG_VSYNC_EN |
                        VP_DCFG_CRT_EN);
        if (!blank)
-               dcfg |= VP_DCFG_DAC_BL_EN;
+               dcfg |= VP_DCFG_DAC_BL_EN | VP_DCFG_CRT_EN;
        if (hsync)
                dcfg |= VP_DCFG_HSYNC_EN;
        if (vsync)
                dcfg |= VP_DCFG_VSYNC_EN;
-       if (crt)
-               dcfg |= VP_DCFG_CRT_EN;
+
        write_vp(par, VP_DCFG, dcfg);
 
+       misc = read_vp(par, VP_MISC);
+
+       if (vsync && hsync)
+               misc &= ~VP_MISC_DACPWRDN;
+       else
+               misc |= VP_MISC_DACPWRDN;
+
+       write_vp(par, VP_MISC, misc);
+
        /* Power on/off flat panel */
 
        if (par->output & OUTPUT_PANEL) {