]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/video/s3c2410fb.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/lethal/sh-2.6.24
[linux-2.6-omap-h63xx.git] / drivers / video / s3c2410fb.c
index 09d19633d3bcd8f1d7cfa199b8b2fef03a492d47..5857ccf5f6b15208f64a7221405063f280b2d44a 100644 (file)
@@ -56,7 +56,7 @@
  *     - Add support for different devices
  *     - Backlight support
  *
- * 2004-09-05: Herbert Pötzl <herbert@13thfloor.at>
+ * 2004-09-05: Herbert Pötzl <herbert@13thfloor.at>
  *     - added clock (de-)allocation code
  *     - added fixem fbmem option
  *
@@ -64,7 +64,7 @@
  *     - code cleanup
  *     - added a forgotten return in h1940fb_init
  *
- * 2004-07-19: Herbert Pötzl <herbert@13thfloor.at>
+ * 2004-07-19: Herbert Pötzl <herbert@13thfloor.at>
  *     - code cleanup and extended debugging
  *
  * 2004-07-15: Arnaud Patard <arnaud.patard@rtp-net.org>
@@ -172,19 +172,28 @@ static int s3c2410fb_check_var(struct fb_var_screeninfo *var,
        struct s3c2410fb_info *fbi = info->par;
        struct s3c2410fb_mach_info *mach_info = fbi->dev->platform_data;
        struct s3c2410fb_display *display = NULL;
+       struct s3c2410fb_display *default_display = mach_info->displays +
+                                                   mach_info->default_display;
+       int type = default_display->type;
        unsigned i;
 
        dprintk("check_var(var=%p, info=%p)\n", var, info);
 
        /* validate x/y resolution */
-
-       for (i = 0; i < mach_info->num_displays; i++)
-               if (var->yres == mach_info->displays[i].yres &&
-                   var->xres == mach_info->displays[i].xres &&
-                   var->bits_per_pixel == mach_info->displays[i].bpp) {
-                       display = mach_info->displays + i;
-                       break;
-               }
+       /* choose default mode if possible */
+       if (var->yres == default_display->yres &&
+           var->xres == default_display->xres &&
+           var->bits_per_pixel == default_display->bpp)
+               display = default_display;
+       else
+               for (i = 0; i < mach_info->num_displays; i++)
+                       if (type == mach_info->displays[i].type &&
+                           var->yres == mach_info->displays[i].yres &&
+                           var->xres == mach_info->displays[i].xres &&
+                           var->bits_per_pixel == mach_info->displays[i].bpp) {
+                               display = mach_info->displays + i;
+                               break;
+                       }
 
        if (!display) {
                dprintk("wrong resolution or depth %dx%d at %d bpp\n",
@@ -199,6 +208,7 @@ static int s3c2410fb_check_var(struct fb_var_screeninfo *var,
        var->width = display->width;
 
        /* copy lcd settings */
+       var->pixclock = display->pixclock;
        var->left_margin = display->left_margin;
        var->right_margin = display->right_margin;
        var->upper_margin = display->upper_margin;
@@ -206,11 +216,9 @@ static int s3c2410fb_check_var(struct fb_var_screeninfo *var,
        var->vsync_len = display->vsync_len;
        var->hsync_len = display->hsync_len;
 
-       fbi->regs.lcdcon1 = display->lcdcon1;
        fbi->regs.lcdcon5 = display->lcdcon5;
        /* set display type */
-       fbi->regs.lcdcon1 &= ~S3C2410_LCDCON1_TFT;
-       fbi->regs.lcdcon1 |= display->type;
+       fbi->regs.lcdcon1 = display->type;
 
        var->transp.offset = 0;
        var->transp.length = 0;
@@ -297,15 +305,9 @@ static void s3c2410fb_calculate_stn_lcd_regs(const struct fb_info *info,
        unsigned wdly = (var->left_margin >> 4) - 1;
        unsigned wlh = (var->hsync_len >> 4) - 1;
 
-       dprintk("%s: var->xres  = %d\n", __FUNCTION__, var->xres);
-       dprintk("%s: var->yres  = %d\n", __FUNCTION__, var->yres);
-       dprintk("%s: var->bpp   = %d\n", __FUNCTION__, var->bits_per_pixel);
-
        if (type != S3C2410_LCDCON1_STN4)
                hs >>= 1;
 
-       regs->lcdcon1 &= ~S3C2410_LCDCON1_MODEMASK;
-
        switch (var->bits_per_pixel) {
        case 1:
                regs->lcdcon1 |= S3C2410_LCDCON1_STN1BPP;
@@ -359,12 +361,6 @@ static void s3c2410fb_calculate_tft_lcd_regs(const struct fb_info *info,
        const struct s3c2410fb_info *fbi = info->par;
        const struct fb_var_screeninfo *var = &info->var;
 
-       dprintk("%s: var->xres  = %d\n", __FUNCTION__, var->xres);
-       dprintk("%s: var->yres  = %d\n", __FUNCTION__, var->yres);
-       dprintk("%s: var->bpp   = %d\n", __FUNCTION__, var->bits_per_pixel);
-
-       regs->lcdcon1 &= ~S3C2410_LCDCON1_MODEMASK;
-
        switch (var->bits_per_pixel) {
        case 1:
                regs->lcdcon1 |= S3C2410_LCDCON1_TFT1BPP;
@@ -427,28 +423,24 @@ static void s3c2410fb_activate_var(struct fb_info *info)
        void __iomem *regs = fbi->io;
        int type = fbi->regs.lcdcon1 & S3C2410_LCDCON1_TFT;
        struct fb_var_screeninfo *var = &info->var;
+       int clkdiv = s3c2410fb_calc_pixclk(fbi, var->pixclock) / 2;
 
-       if (var->pixclock > 0) {
-               int clkdiv = s3c2410fb_calc_pixclk(fbi, var->pixclock);
-
-               if (type == S3C2410_LCDCON1_TFT) {
-                       clkdiv = (clkdiv / 2) - 1;
-                       if (clkdiv < 0)
-                               clkdiv = 0;
-               } else {
-                       clkdiv = (clkdiv / 2);
-                       if (clkdiv < 2)
-                               clkdiv = 2;
-               }
-
-               fbi->regs.lcdcon1 &= ~S3C2410_LCDCON1_CLKVAL(0x3ff);
-               fbi->regs.lcdcon1 |=  S3C2410_LCDCON1_CLKVAL(clkdiv);
-       }
+       dprintk("%s: var->xres  = %d\n", __FUNCTION__, var->xres);
+       dprintk("%s: var->yres  = %d\n", __FUNCTION__, var->yres);
+       dprintk("%s: var->bpp   = %d\n", __FUNCTION__, var->bits_per_pixel);
 
-       if (type == S3C2410_LCDCON1_TFT)
+       if (type == S3C2410_LCDCON1_TFT) {
                s3c2410fb_calculate_tft_lcd_regs(info, &fbi->regs);
-       else
+               --clkdiv;
+               if (clkdiv < 0)
+                       clkdiv = 0;
+       } else {
                s3c2410fb_calculate_stn_lcd_regs(info, &fbi->regs);
+               if (clkdiv < 2)
+                       clkdiv = 2;
+       }
+
+       fbi->regs.lcdcon1 |=  S3C2410_LCDCON1_CLKVAL(clkdiv);
 
        /* write new registers */