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

Next file: linux/drivers/video/chipsfb.c
Previous file: linux/drivers/video/atafb.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.13/linux/drivers/video/atyfb.c linux/drivers/video/atyfb.c
@@ -386,11 +386,11 @@
      *  Interface used by the world
      */
 
-void atyfb_init(void);
+int atyfb_init(void);
 #ifdef CONFIG_FB_OF
 void atyfb_of_init(struct device_node *dp);
 #endif
-void atyfb_setup(char *options, int *ints);
+int atyfb_setup(char*);
 
 static int currcon = 0;
 
@@ -411,6 +411,7 @@
 static u32 default_vram __initdata = 0;
 static int default_pll __initdata = 0;
 static int default_mclk __initdata = 0;
+static const char *mode_option __initdata = NULL;
 
 #if defined(CONFIG_PPC)
 static int default_vmode __initdata = VMODE_NVRAM;
@@ -479,10 +480,10 @@
 
 #if defined(__powerpc__)
     temp = info->ati_regbase;
-    asm("lwbrx %0,%1,%2" : "=r"(val) : "b" (regindex), "r" (temp));
+    asm volatile("lwbrx %0,%1,%2" : "=r"(val) : "b" (regindex), "r" (temp));
 #elif defined(__sparc_v9__)
     temp = info->ati_regbase + regindex;
-    asm("lduwa [%1] %2, %0" : "=r" (val) : "r" (temp), "i" (ASI_PL));
+    asm volatile("lduwa [%1] %2, %0" : "=r" (val) : "r" (temp), "i" (ASI_PL));
 #else
     temp = info->ati_regbase+regindex;
     val = le32_to_cpu(*((volatile u32 *)(temp)));
@@ -497,11 +498,11 @@
 
 #if defined(__powerpc__)
     temp = info->ati_regbase;
-    asm("stwbrx %0,%1,%2" : : "r" (val), "b" (regindex), "r" (temp) :
+    asm volatile("stwbrx %0,%1,%2" : : "r" (val), "b" (regindex), "r" (temp) :
 	"memory");
 #elif defined(__sparc_v9__)
     temp = info->ati_regbase + regindex;
-    asm("stwa %0, [%1] %2" : : "r" (val), "r" (temp), "i" (ASI_PL) : "memory");
+    asm volatile("stwa %0, [%1] %2" : : "r" (val), "r" (temp), "i" (ASI_PL) : "memory");
 #else
     temp = info->ati_regbase+regindex;
     *((volatile u32 *)(temp)) = cpu_to_le32(val);
@@ -2218,7 +2219,6 @@
 static int atyfb_ioctl(struct inode *inode, struct file *file, u_int cmd,
 		       u_long arg, int con, struct fb_info *info2)
 {
-    struct fb_info_aty *info = (struct fb_info_aty *)info2;
 #ifdef __sparc__
     struct fbtype fbtyp;
     struct display *disp;
@@ -2734,32 +2734,55 @@
 	    info->total_vram -= GUI_RESERVE;
 	}
 
+    disp = &info->disp;
+
+    strcpy(info->fb_info.modename, atyfb_name);
+    info->fb_info.node = -1;
+    info->fb_info.fbops = &atyfb_ops;
+    info->fb_info.disp = disp;
+    strcpy(info->fb_info.fontname, fontname);
+    info->fb_info.changevar = NULL;
+    info->fb_info.switch_con = &atyfbcon_switch;
+    info->fb_info.updatevar = &atyfbcon_updatevar;
+    info->fb_info.blank = &atyfbcon_blank;
+    info->fb_info.flags = FBINFO_FLAG_DEFAULT;
+
+#ifdef MODULE
+    var = default_var;
+#else /* !MODULE */
 #if defined(CONFIG_PPC)
-    if (default_vmode == VMODE_NVRAM) {
-	default_vmode = nvram_read_byte(NV_VMODE);
+    if (mode_option) {
+	if (!mac_find_mode(&var, &info->fb_info, mode_option, 8))
+	    var = default_var;
+    } else {
+	if (default_vmode == VMODE_NVRAM) {
+	    default_vmode = nvram_read_byte(NV_VMODE);
+	    if (default_vmode <= 0 || default_vmode > VMODE_MAX)
+		default_vmode = VMODE_CHOOSE;
+	}
+	if (default_vmode == VMODE_CHOOSE) {
+	    if (Gx == LG_CHIP_ID)
+		/* G3 PowerBook with 1024x768 LCD */
+		default_vmode = VMODE_1024_768_60;
+	    else {
+		sense = read_aty_sense(info);
+		default_vmode = mac_map_monitor_sense(sense);
+	    }
+	}
 	if (default_vmode <= 0 || default_vmode > VMODE_MAX)
-	    default_vmode = VMODE_CHOOSE;
+	    default_vmode = VMODE_640_480_60;
+	if (default_cmode == CMODE_NVRAM)
+	    default_cmode = nvram_read_byte(NV_CMODE);
+	if (default_cmode < CMODE_8 || default_cmode > CMODE_32)
+	    default_cmode = CMODE_8;
+	if (mac_vmode_to_var(default_vmode, default_cmode, &var))
+	    var = default_var;
     }
-    if (default_vmode == VMODE_CHOOSE) {
-	if (Gx == LG_CHIP_ID)
-	    /* G3 PowerBook with 1024x768 LCD */
-	    default_vmode = VMODE_1024_768_60;
-	else {
-	    sense = read_aty_sense(info);
-	    default_vmode = mac_map_monitor_sense(sense);
-	}
-    }
-    if (default_vmode <= 0 || default_vmode > VMODE_MAX)
-	default_vmode = VMODE_640_480_60;
-    if (default_cmode == CMODE_NVRAM)
-	default_cmode = nvram_read_byte(NV_CMODE);
-    if (default_cmode < CMODE_8 || default_cmode > CMODE_32)
-	default_cmode = CMODE_8;
-    if (mac_vmode_to_var(default_vmode, default_cmode, &var))
-	var = default_var;
 #else /* !CONFIG_PPC */
-    var = default_var;
+    if (!fb_find_mode(&var, &info->fb_info, mode_option, NULL, 0, NULL, 8))
+	var = default_var;
 #endif /* !CONFIG_PPC */
+#endif /* !MODULE */
     if (noaccel)
         var.accel_flags &= ~FB_ACCELF_TEXT;
     else
@@ -2777,19 +2800,6 @@
 	return 0;
     }
 
-    disp = &info->disp;
-
-    strcpy(info->fb_info.modename, atyfb_name);
-    info->fb_info.node = -1;
-    info->fb_info.fbops = &atyfb_ops;
-    info->fb_info.disp = disp;
-    strcpy(info->fb_info.fontname, fontname);
-    info->fb_info.changevar = NULL;
-    info->fb_info.switch_con = &atyfbcon_switch;
-    info->fb_info.updatevar = &atyfbcon_updatevar;
-    info->fb_info.blank = &atyfbcon_blank;
-    info->fb_info.flags = FBINFO_FLAG_DEFAULT;
-
 #ifdef __sparc__
     atyfb_save_palette(&info->fb_info, 0);
 #endif
@@ -2821,7 +2831,7 @@
     return 1;
 }
 
-void __init atyfb_init(void)
+int __init atyfb_init(void)
 {
 #if defined(CONFIG_FB_OF)
     /* We don't want to be called like this. */
@@ -2841,7 +2851,7 @@
 
     /* Do not attach when we have a serial console. */
     if (!con_is_present())
-	return;
+	return -ENXIO;
 #else
     u16 tmp;
 #endif
@@ -2854,7 +2864,7 @@
 	    info = kmalloc(sizeof(struct fb_info_aty), GFP_ATOMIC);
 	    if (!info) {
 		printk("atyfb_init: can't alloc fb_info_aty\n");
-		return;
+		return -ENXIO;
 	    }
 	    memset(info, 0, sizeof(struct fb_info_aty));
 
@@ -2890,7 +2900,7 @@
 	    if (!info->mmap_map) {
 		printk("atyfb_init: can't alloc mmap_map\n");
 		kfree(info);
-		return;
+		return -ENXIO;
 	    }
 	    memset(info->mmap_map, 0, j * sizeof(*info->mmap_map));
 
@@ -2904,14 +2914,12 @@
 
 		io = (rp->flags & IORESOURCE_IOPORT);
 
+		size = rp->end - base + 1;
+		
 		pci_read_config_dword(pdev, breg, &pbase);
-		pci_write_config_dword(pdev, breg, 0xffffffff);
-		pci_read_config_dword(pdev, breg, &size);
-		pci_write_config_dword(pdev, breg, pbase);
 
 		if (io)
 			size &= ~1;
-		size = ~(size) + 1;
 
 		/*
 		 * Map the framebuffer a second time, this time without
@@ -3071,7 +3079,7 @@
 
 	    if(!info->ati_regbase) {
 		    kfree(info);
-		    return;
+		    return -ENOMEM;
 	    }
 
 	    info->ati_regbase_phys += 0xc00;
@@ -3098,7 +3106,7 @@
 
 	    if(!info->frame_buffer) {
 		    kfree(info);
-		    return;
+		    return -ENXIO;
 	    }
 
 #endif /* __sparc__ */
@@ -3107,7 +3115,7 @@
 		if (info->mmap_map)
 		    kfree(info->mmap_map);
 		kfree(info);
-		return;
+		return -ENXIO;
 	    }
 
 #ifdef __sparc__
@@ -3145,7 +3153,7 @@
 	info = kmalloc(sizeof(struct fb_info_aty), GFP_ATOMIC);
 	if (!info) {
 	    printk("atyfb_init: can't alloc fb_info_aty\n");
-	    return;
+	    return -ENOMEM;
 	}
 	memset(info, 0, sizeof(struct fb_info_aty));
 
@@ -3161,10 +3169,11 @@
 	if (!aty_init(info, "ISA bus")) {
 	    kfree(info);
 	    /* This is insufficient! kernel_map has added two large chunks!! */
-	    return;
+	    return -ENXIO;
 	}
     }
 #endif
+    return 0;
 }
 
 #ifdef CONFIG_FB_OF
@@ -3252,12 +3261,12 @@
 #endif /* CONFIG_FB_OF */
 
 
-void __init atyfb_setup(char *options, int *ints)
+int __init atyfb_setup(char *options)
 {
     char *this_opt;
 
     if (!options || !*options)
-	return;
+	return 0;
 
     for (this_opt = strtok(options, ","); this_opt;
 	 this_opt = strtok(NULL, ",")) {
@@ -3320,6 +3329,7 @@
 	}
 #endif
     }
+    return 0;
 }
 
 #ifdef CONFIG_ATARI

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