sky2: Factor out code to calculate packet sizes
[safe/jmp/linux-2.6] / drivers / video / neofb.c
index 6249960..588527a 100644 (file)
@@ -426,11 +426,11 @@ static void vgaHWProtect(int on)
 {
        unsigned char tmp;
 
+       tmp = vga_rseq(NULL, 0x01);
        if (on) {
                /*
                 * Turn off screen and disable sequencer.
                 */
-               tmp = vga_rseq(NULL, 0x01);
                vga_wseq(NULL, 0x00, 0x01);             /* Synchronous Reset */
                vga_wseq(NULL, 0x01, tmp | 0x20);       /* disable the display */
 
@@ -439,7 +439,6 @@ static void vgaHWProtect(int on)
                /*
                 * Reenable sequencer, then turn on screen.
                 */
-               tmp = vga_rseq(NULL, 0x01);
                vga_wseq(NULL, 0x01, tmp & ~0x20);      /* reenable display */
                vga_wseq(NULL, 0x00, 0x03);             /* clear synchronousreset */
 
@@ -558,14 +557,12 @@ neofb_open(struct fb_info *info, int user)
 {
        struct neofb_par *par = info->par;
 
-       mutex_lock(&par->open_lock);
        if (!par->ref_count) {
                memset(&par->state, 0, sizeof(struct vgastate));
                par->state.flags = VGA_SAVE_MODE | VGA_SAVE_FONTS;
                save_vga(&par->state);
        }
        par->ref_count++;
-       mutex_unlock(&par->open_lock);
 
        return 0;
 }
@@ -575,16 +572,13 @@ neofb_release(struct fb_info *info, int user)
 {
        struct neofb_par *par = info->par;
 
-       mutex_lock(&par->open_lock);
-       if (!par->ref_count) {
-               mutex_unlock(&par->open_lock);
+       if (!par->ref_count)
                return -EINVAL;
-       }
+
        if (par->ref_count == 1) {
                restore_vga(&par->state);
        }
        par->ref_count--;
-       mutex_unlock(&par->open_lock);
 
        return 0;
 }
@@ -648,10 +642,10 @@ neofb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
        var->blue.msb_right = 0;
        var->transp.msb_right = 0;
 
+       var->transp.offset = 0;
+       var->transp.length = 0;
        switch (var->bits_per_pixel) {
        case 8:         /* PSEUDOCOLOUR, 256 */
-               var->transp.offset = 0;
-               var->transp.length = 0;
                var->red.offset = 0;
                var->red.length = 8;
                var->green.offset = 0;
@@ -661,8 +655,6 @@ neofb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
                break;
 
        case 16:                /* DIRECTCOLOUR, 64k */
-               var->transp.offset = 0;
-               var->transp.length = 0;
                var->red.offset = 11;
                var->red.length = 5;
                var->green.offset = 5;
@@ -672,8 +664,6 @@ neofb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
                break;
 
        case 24:                /* TRUECOLOUR, 16m */
-               var->transp.offset = 0;
-               var->transp.length = 0;
                var->red.offset = 16;
                var->red.length = 8;
                var->green.offset = 8;
@@ -704,8 +694,6 @@ neofb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
        if (vramlen > 4 * 1024 * 1024)
                vramlen = 4 * 1024 * 1024;
 
-       if (var->yres_virtual < var->yres)
-               var->yres_virtual = var->yres;
        if (var->xres_virtual < var->xres)
                var->xres_virtual = var->xres;
 
@@ -722,8 +710,6 @@ neofb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
           if it was possible. We should return -EINVAL, but I disagree */
        if (var->yres_virtual < var->yres)
                var->yres = var->yres_virtual;
-       if (var->xres_virtual < var->xres)
-               var->xres = var->xres_virtual;
        if (var->xoffset + var->xres > var->xres_virtual)
                var->xoffset = var->xres_virtual - var->xres;
        if (var->yoffset + var->yres > var->yres_virtual)
@@ -1467,7 +1453,8 @@ neo2200_imageblit(struct fb_info *info, const struct fb_image *image)
                         * is less than 16 bits wide. This is due to insufficient
                         * padding when writing the image. We need to adjust
                         * struct fb_pixmap. Not yet done. */
-                       return cfb_imageblit(info, image);
+                       cfb_imageblit(info, image);
+                       return;
                }
                bltCntl_flags = NEO_BC0_SRC_MONO;
        } else if (image->depth == info->var.bits_per_pixel) {
@@ -1475,7 +1462,8 @@ neo2200_imageblit(struct fb_info *info, const struct fb_image *image)
        } else {
                /* We don't currently support hardware acceleration if image
                 * depth is different from display */
-               return cfb_imageblit(info, image);
+               cfb_imageblit(info, image);
+               return;
        }
 
        switch (info->var.bits_per_pixel) {
@@ -1967,7 +1955,6 @@ static struct fb_info *__devinit neo_alloc_fb_info(struct pci_dev *dev, const st
 
        info->fix.accel = id->driver_data;
 
-       mutex_init(&par->open_lock);
        par->pci_burst = !nopciburst;
        par->lcd_stretch = !nostretch;
        par->libretto = libretto;