patch-2.2.7 linux/drivers/video/atyfb.c

Next file: linux/drivers/video/creatorfb.c
Previous file: linux/drivers/usb/usb.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.2.6/linux/drivers/video/atyfb.c linux/drivers/video/atyfb.c
@@ -1,4 +1,4 @@
-/*  $Id: atyfb.c,v 1.103 1999/03/09 14:01:44 davem Exp $
+/*  $Id: atyfb.c,v 1.106 1999/04/16 11:20:49 geert Exp $
  *  linux/drivers/video/atyfb.c -- Frame buffer device for ATI Mach64
  *
  *	Copyright (C) 1997-1998  Geert Uytterhoeven
@@ -385,7 +385,6 @@
 #endif
 void atyfb_setup(char *options, int *ints);
 
-
 static int currcon = 0;
 
 static struct fb_ops atyfb_ops = {
@@ -779,7 +778,8 @@
 		return;
 
 #ifdef __sparc__
-	if (fb->mmaped && currcon == fb->vtconsole)
+	if (fb->mmaped && (!fb->fb_info.display_fg
+	    || fb->fb_info.display_fg->vc_num == fb->vtconsole))
 		return;
 #endif
 
@@ -806,7 +806,8 @@
 		return;
 
 #ifdef __sparc__
-	if (fb->mmaped && currcon == fb->vtconsole)
+	if (fb->mmaped && (!fb->fb_info.display_fg
+	    || fb->fb_info.display_fg->vc_num == fb->vtconsole))
 		return;
 #endif
 
@@ -840,7 +841,8 @@
 		return;
 
 #ifdef __sparc__
-	if (fb->mmaped && currcon == fb->vtconsole)
+	if (fb->mmaped && (!fb->fb_info.display_fg
+	    || fb->fb_info.display_fg->vc_num == fb->vtconsole))
 		return;
 #endif
 
@@ -910,7 +912,8 @@
 		return;
 
 #ifdef __sparc__
-	if (fb->mmaped && currcon == fb->vtconsole)
+	if (fb->mmaped && (!fb->fb_info.display_fg
+	    || fb->fb_info.display_fg->vc_num == fb->vtconsole))
 		return;
 #endif
 
@@ -1644,30 +1647,24 @@
     	pll_ext_cntl = mpostdiv;	/* xclk == mclk */
 
     switch (vclk_post_div) {
-	case 1:
-	    vpostdiv = 0;
-	    break;
 	case 2:
 	    vpostdiv = 1;
 	    break;
 	case 3:
-	    vpostdiv = 0;
 	    pll_ext_cntl |= 0x10;
+	case 1:
+	    vpostdiv = 0;
 	    break;
+	case 6:
+	    pll_ext_cntl |= 0x10;
 	case 4:
 	    vpostdiv = 2;
 	    break;
-	case 6:
-	    vpostdiv = 2;
+	case 12:
 	    pll_ext_cntl |= 0x10;
-	    break;
 	case 8:
 	    vpostdiv = 3;
 	    break;
-	case 12:
-	    vpostdiv = 3;
-	    pll_ext_cntl |= 0x10;
-	    break;
     }
     vclk_post_div = vpostdiv;
 
@@ -1690,7 +1687,7 @@
 	1, 2, 4, 8,
 	3, 0, 6, 12
     };
-    u8 vpostdiv = vclk_post_div_tab[((pll_ext_cntl & 0x10) >> 1) |
+    u8 vpostdiv = vclk_post_div_tab[((pll_ext_cntl & 0x10) >> 2) |
 				    (vclk_post_div & 3)];
     if (vpostdiv == 0)
 	return -EINVAL;
@@ -2114,7 +2111,8 @@
 	    if (info->fb_info.changevar)
 		(*info->fb_info.changevar)(con);
 	}
-	if (con == currcon)
+	if (!info->fb_info.display_fg ||
+	    info->fb_info.display_fg->vc_num == con)
 	    atyfb_set_par(&par, info);
 	if (oldbpp != var->bits_per_pixel) {
 	    if ((err = fb_alloc_cmap(&display->cmap, 0, 0)))
@@ -2159,7 +2157,7 @@
 static int atyfb_get_cmap(struct fb_cmap *cmap, int kspc, int con,
 			  struct fb_info *info)
 {
-    if (con == currcon) /* current console? */
+    if (!info->display_fg || con == info->display_fg->vc_num) /* current console? */
 	return fb_get_cmap(cmap, kspc, atyfb_getcolreg, info);
     else if (fb_display[con].cmap.len) /* non default colormap? */
 	fb_copy_cmap(&fb_display[con].cmap, cmap, kspc ? 0 : 2);
@@ -2178,16 +2176,21 @@
 			  struct fb_info *info)
 {
     int err;
+    struct display *disp;
 
-    if (!fb_display[con].cmap.len) {	/* no colormap allocated? */
-	int size = fb_display[con].var.bits_per_pixel == 16 ? 32 : 256;
-	if ((err = fb_alloc_cmap(&fb_display[con].cmap, size, 0)))
+    if (con >= 0)
+    	disp = &fb_display[con];
+    else
+        disp = info->disp;
+    if (!disp->cmap.len) {	/* no colormap allocated? */
+	int size = disp->var.bits_per_pixel == 16 ? 32 : 256;
+	if ((err = fb_alloc_cmap(&disp->cmap, size, 0)))
 	    return err;
     }
-    if (con == currcon)			/* current console? */
+    if (!info->display_fg || con == info->display_fg->vc_num)			/* current console? */
 	return fb_set_cmap(cmap, kspc, atyfb_setcolreg, info);
     else
-	fb_copy_cmap(cmap, &fb_display[con].cmap, kspc ? 0 : 1);
+	fb_copy_cmap(cmap, &disp->cmap, kspc ? 0 : 1);
     return 0;
 }
 
@@ -2198,6 +2201,12 @@
 #ifdef __sparc__
     struct fb_info_aty *fb = (struct fb_info_aty *)info;
     struct fbtype fbtyp;
+    struct display *disp;
+    
+    if (con >= 0)
+    	disp = &fb_display[con];
+    else
+        disp = info->disp;
 
     switch (cmd) {
     case FBIOGTYPE:
@@ -2205,7 +2214,7 @@
 	fbtyp.fb_width = fb->current_par.crtc.vxres;
 	fbtyp.fb_height = fb->current_par.crtc.vyres;
 	fbtyp.fb_depth = fb->current_par.crtc.bpp;
-	fbtyp.fb_cmsize = fb_display[con].cmap.len;
+	fbtyp.fb_cmsize = disp->cmap.len;
 	fbtyp.fb_size = fb->total_vram;
 	copy_to_user_ret((struct fbtype *)arg, &fbtyp, sizeof(fbtyp), -EFAULT);
 	break;
@@ -2785,7 +2794,7 @@
 	     */
 	    for (i = 0; i < 6 && pdev->base_address[i]; i++)
 		/* nothing */;
-	    j = i + 3;
+	    j = i + 4;
 
 	    info->mmap_map = kmalloc(j * sizeof(*info->mmap_map), GFP_ATOMIC);
 	    if (!info->mmap_map) {
@@ -2813,15 +2822,33 @@
 			size &= ~1;
 		size = ~(size) + 1;
 
+		/*
+		 * Map the framebuffer a second time, this time without
+		 * the braindead _PAGE_IE setting. This is used by the
+		 * fixed Xserver, but we need to maintain the old mapping
+		 * to stay compatible with older ones...
+		 */
+		if (base == addr) {
+		    info->mmap_map[j].voff = (pbase + 0x10000000) & PAGE_MASK;
+		    info->mmap_map[j].poff = __pa(base & PAGE_MASK);
+		    info->mmap_map[j].size = (size + ~PAGE_MASK) & PAGE_MASK;
+		    info->mmap_map[j].prot_mask = _PAGE_CACHE;
+		    info->mmap_map[j].prot_flag = _PAGE_E;
+		    j++;
+		}
+
+		/*
+		 * Here comes the old framebuffer mapping with _PAGE_IE
+		 * set for the big endian half of the framebuffer...
+		 */
 		if (base == addr) {
-			info->mmap_map[j].voff = (pbase + 0x800000) & PAGE_MASK;
-			info->mmap_map[j].poff = __pa((base + 0x800000)
-								& PAGE_MASK);
-			info->mmap_map[j].size = 0x800000;
-			info->mmap_map[j].prot_mask = _PAGE_CACHE;
-			info->mmap_map[j].prot_flag = _PAGE_E|_PAGE_IE;
-			size -= 0x800000;
-			j++;
+		    info->mmap_map[j].voff = (pbase + 0x800000) & PAGE_MASK;
+		    info->mmap_map[j].poff = __pa((base+0x800000) & PAGE_MASK);
+		    info->mmap_map[j].size = 0x800000;
+		    info->mmap_map[j].prot_mask = _PAGE_CACHE;
+		    info->mmap_map[j].prot_flag = _PAGE_E|_PAGE_IE;
+		    size -= 0x800000;
+		    j++;
 		}
 
 		info->mmap_map[j].voff = pbase & PAGE_MASK;
@@ -3556,7 +3583,8 @@
 #ifdef __sparc__
     struct fb_info_aty *fb = (struct fb_info_aty *)(p->fb_info);
 
-    if (fb->mmaped && currcon == fb->vtconsole)
+    if (fb->mmaped && (!fb->fb_info.display_fg
+	|| fb->fb_info.display_fg->vc_num == fb->vtconsole))
 	return;
 #endif
 
@@ -3578,7 +3606,8 @@
 #ifdef __sparc__
     struct fb_info_aty *fb = (struct fb_info_aty *)(p->fb_info);
 
-    if (fb->mmaped && currcon == fb->vtconsole)
+    if (fb->mmaped && (!fb->fb_info.display_fg
+	|| fb->fb_info.display_fg->vc_num == fb->vtconsole))
 	return;
 #endif
 
@@ -3602,7 +3631,8 @@
     struct fb_info_aty *fb = (struct fb_info_aty *)(p->fb_info);
 
 #ifdef __sparc__
-    if (fb->mmaped && currcon == fb->vtconsole)
+    if (fb->mmaped && (!fb->fb_info.display_fg
+	|| fb->fb_info.display_fg->vc_num == fb->vtconsole))
 	return;
 #endif
 
@@ -3618,7 +3648,8 @@
     struct fb_info_aty *fb = (struct fb_info_aty *)(p->fb_info);
 
 #ifdef __sparc__
-    if (fb->mmaped && currcon == fb->vtconsole)
+    if (fb->mmaped && (!fb->fb_info.display_fg
+	|| fb->fb_info.display_fg->vc_num == fb->vtconsole))
 	return;
 #endif
 
@@ -3633,7 +3664,8 @@
     struct fb_info_aty *fb = (struct fb_info_aty *)(p->fb_info);
 
 #ifdef __sparc__
-    if (fb->mmaped && currcon == fb->vtconsole)
+    if (fb->mmaped && (!fb->fb_info.display_fg
+	|| fb->fb_info.display_fg->vc_num == fb->vtconsole))
 	return;
 #endif
 
@@ -3656,7 +3688,8 @@
     struct fb_info_aty *fb = (struct fb_info_aty *)(p->fb_info);
 
 #ifdef __sparc__
-    if (fb->mmaped && currcon == fb->vtconsole)
+    if (fb->mmaped && (!fb->fb_info.display_fg
+	|| fb->fb_info.display_fg->vc_num == fb->vtconsole))
 	return;
 #endif
 
@@ -3672,7 +3705,8 @@
     struct fb_info_aty *fb = (struct fb_info_aty *)(p->fb_info);
 
 #ifdef __sparc__
-    if (fb->mmaped && currcon == fb->vtconsole)
+    if (fb->mmaped && (!fb->fb_info.display_fg
+	|| fb->fb_info.display_fg->vc_num == fb->vtconsole))
 	return;
 #endif
 
@@ -3687,7 +3721,8 @@
     struct fb_info_aty *fb = (struct fb_info_aty *)(p->fb_info);
 
 #ifdef __sparc__
-    if (fb->mmaped && currcon == fb->vtconsole)
+    if (fb->mmaped && (!fb->fb_info.display_fg
+	|| fb->fb_info.display_fg->vc_num == fb->vtconsole))
 	return;
 #endif
 
@@ -3710,7 +3745,8 @@
     struct fb_info_aty *fb = (struct fb_info_aty *)(p->fb_info);
 
 #ifdef __sparc__
-    if (fb->mmaped && currcon == fb->vtconsole)
+    if (fb->mmaped && (!fb->fb_info.display_fg
+	|| fb->fb_info.display_fg->vc_num == fb->vtconsole))
 	return;
 #endif
 
@@ -3726,7 +3762,8 @@
     struct fb_info_aty *fb = (struct fb_info_aty *)(p->fb_info);
 
 #ifdef __sparc__
-    if (fb->mmaped && currcon == fb->vtconsole)
+    if (fb->mmaped && (!fb->fb_info.display_fg
+	|| fb->fb_info.display_fg->vc_num == fb->vtconsole))
 	return;
 #endif
 
@@ -3741,7 +3778,8 @@
     struct fb_info_aty *fb = (struct fb_info_aty *)(p->fb_info);
 
 #ifdef __sparc__
-    if (fb->mmaped && currcon == fb->vtconsole)
+    if (fb->mmaped && (!fb->fb_info.display_fg
+	|| fb->fb_info.display_fg->vc_num == fb->vtconsole))
 	return;
 #endif
 
@@ -3764,7 +3802,8 @@
     struct fb_info_aty *fb = (struct fb_info_aty *)(p->fb_info);
 
 #ifdef __sparc__
-    if (fb->mmaped && currcon == fb->vtconsole)
+    if (fb->mmaped && (!fb->fb_info.display_fg
+	|| fb->fb_info.display_fg->vc_num == fb->vtconsole))
 	return;
 #endif
 
@@ -3780,7 +3819,8 @@
     struct fb_info_aty *fb = (struct fb_info_aty *)(p->fb_info);
 
 #ifdef __sparc__
-    if (fb->mmaped && currcon == fb->vtconsole)
+    if (fb->mmaped && (!fb->fb_info.display_fg
+	|| fb->fb_info.display_fg->vc_num == fb->vtconsole))
 	return;
 #endif
 
@@ -3795,7 +3835,8 @@
     struct fb_info_aty *fb = (struct fb_info_aty *)(p->fb_info);
 
 #ifdef __sparc__
-    if (fb->mmaped && currcon == fb->vtconsole)
+    if (fb->mmaped && (!fb->fb_info.display_fg
+	|| fb->fb_info.display_fg->vc_num == fb->vtconsole))
 	return;
 #endif
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)