patch-2.4.0-test5 linux/drivers/video/aty128fb.c

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

diff -u --recursive --new-file v2.4.0-test4/linux/drivers/video/aty128fb.c linux/drivers/video/aty128fb.c
@@ -209,9 +209,6 @@
 #ifndef MODULE
 static const char *mode_option __initdata = NULL;
 #endif
-#if !defined(CONFIG_PPC) && !defined(__sparc__)
-static void *bios_seg = NULL;
-#endif
 
 #ifdef CONFIG_PPC
 #ifdef CONFIG_NVRAM_NOT_DEFINED
@@ -277,7 +274,6 @@
     void *regbase;                      /* remapped mmio       */
     u32 frame_buffer_phys;              /* physical fb memory  */
     u32 frame_buffer;                   /* remaped framebuffer */
-    u32 io_base;                        /* unmapped io         */
     u32 vram_size;                      /* onboard video ram   */
     int chip_gen;
     const struct aty128_meminfo *mem;   /* onboard mem info    */
@@ -329,8 +325,6 @@
 			struct fb_info *info);
 static int aty128fb_pan_display(struct fb_var_screeninfo *var, int con,
 			   struct fb_info *fb);
-static int aty128fb_ioctl(struct inode *inode, struct file *file, u_int cmd,
-		     u_long arg, int con, struct fb_info *info);
 static int aty128fb_rasterimg(struct fb_info *info, int start);
 
 
@@ -367,8 +361,9 @@
 static struct fb_info_aty128 *aty128_board_list_add(struct fb_info_aty128
 				*board_list, struct fb_info_aty128 *new_node);
 #if !defined(CONFIG_PPC) && !defined(__sparc__)
-static void aty128_get_pllinfo(struct fb_info_aty128 *info);
-static int aty128find_ROM(struct fb_info_aty128 *info);
+static void __init aty128_get_pllinfo(struct fb_info_aty128 *info,
+			char *bios_seg);
+static char __init *aty128find_ROM(struct fb_info_aty128 *info);
 #endif
 static void aty128_timings(struct fb_info_aty128 *info);
 static void aty128_init_engine(const struct aty128fb_par *par, 
@@ -421,7 +416,6 @@
 	fb_get_cmap:	aty128fb_get_cmap,
 	fb_set_cmap:	aty128fb_set_cmap,
 	fb_pan_display:	aty128fb_pan_display,
-	fb_ioctl:	aty128fb_ioctl,
 	fb_rasterimg:	aty128fb_rasterimg,
 };
 
@@ -1590,17 +1584,6 @@
     return 0;                
 }
 
-    /*
-     *  Frame Buffer Specific ioctls
-     */
-
-static int
-aty128fb_ioctl(struct inode *inode, struct file *file, u_int cmd,
-		     u_long arg, int con, struct fb_info *info)
-{
-    return -EINVAL;
-}
-
 
 static int
 aty128fb_rasterimg(struct fb_info *info, int start)
@@ -1842,221 +1825,210 @@
 aty128_pci_register(struct pci_dev *pdev,
                                const struct aty128_chip_info *aci)
 {
-    struct fb_info_aty128 *info = NULL;
-    u32 fb_addr, reg_addr, io_addr = 0;
-    int err;
-
-    fb_addr = pci_resource_start(pdev, 0);
-    if (!request_mem_region(fb_addr, pci_resource_len(pdev, 0),
-                            "aty128fb FB")) {
-        printk(KERN_ERR "aty128fb: cannot reserve frame buffer memory\n");
-        goto err_free_fb;
-    }
-
-    reg_addr = pci_resource_start(pdev, 2);
-    if (!request_mem_region(reg_addr, pci_resource_len(pdev, 2),
-                            "aty128fb MMIO")) {
-        printk(KERN_ERR "aty128fb: cannot reserve MMIO region\n");
-        goto err_free_mmio;
-    }
+	struct fb_info_aty128 *info = NULL;
+	u32 fb_addr, reg_addr;
+	int err;
+#if !defined(CONFIG_PPC) && !defined(__sparc__)
+	char *bios_seg = NULL;
+#endif
 
-    /* We have the resources. Now virtualize them */
-    info = kmalloc(sizeof(struct fb_info_aty128), GFP_ATOMIC);
-    if(!info) {
-        printk(KERN_ERR "aty128fb: can't alloc fb_info_aty128\n");
-	goto err_unmap_out;
-    }
-    memset(info, 0, sizeof(struct fb_info_aty128));
+	/* Enable device in PCI config */
+	if ((err = pci_enable_device(pdev))) {
+		printk(KERN_ERR "aty128fb: Cannot enable PCI device: %d\n",
+				err);
+		goto err_out;
+	}
 
-    /* Copy PCI device info into info->pdev */
-    info->pdev = pdev;
+	fb_addr = pci_resource_start(pdev, 0);
+	if (!request_mem_region(fb_addr, pci_resource_len(pdev, 0),
+				"aty128fb FB")) {
+		printk(KERN_ERR "aty128fb: cannot reserve frame "
+				"buffer memory\n");
+		goto err_free_fb;
+	}
 
-    info->currcon = -1;
+	reg_addr = pci_resource_start(pdev, 2);
+	if (!request_mem_region(reg_addr, pci_resource_len(pdev, 2),
+				"aty128fb MMIO")) {
+		printk(KERN_ERR "aty128fb: cannot reserve MMIO region\n");
+		goto err_free_mmio;
+	}
 
-    /* Virtualize mmio region */
-    info->regbase_phys = reg_addr;
-    info->regbase = ioremap(reg_addr, 0x1FFF);
+	/* We have the resources. Now virtualize them */
+	if (!(info = kmalloc(sizeof(struct fb_info_aty128), GFP_ATOMIC))) {
+		printk(KERN_ERR "aty128fb: can't alloc fb_info_aty128\n");
+		goto err_unmap_out;
+	}
+	memset(info, 0, sizeof(struct fb_info_aty128));
 
-    if (!info->regbase)
-        goto err_free_info;
+	/* Copy PCI device info into info->pdev */
+	info->pdev = pdev;
 
-    /* Store io_base */
-    info->io_base = io_addr;
+	info->currcon = -1;
 
-    /* Grab memory size from the card */
-    info->vram_size = aty_ld_le32(CONFIG_MEMSIZE) & 0x03FFFFFF;
+	/* Virtualize mmio region */
+	info->regbase_phys = reg_addr;
+	info->regbase = ioremap(reg_addr, 0x1FFF);
 
-    /* Virtualize the framebuffer */
-    info->frame_buffer_phys = fb_addr;
-    info->frame_buffer = (u32)ioremap(fb_addr, info->vram_size);
+	if (!info->regbase)
+		goto err_free_info;
 
-    if (!info->frame_buffer) {
-        iounmap((void *)info->regbase);
-        goto err_free_info;
-    }
+	/* Grab memory size from the card */
+	info->vram_size = aty_ld_le32(CONFIG_MEMSIZE) & 0x03FFFFFF;
 
-    /* Enable device in PCI config */
-    err = pci_enable_device(pdev);
-    if (err) {
-        printk(KERN_ERR "aty128fb: Cannot enable PCI device: %d\n", err);
-        goto err_out;
-    }
+	/* Virtualize the framebuffer */
+	info->frame_buffer_phys = fb_addr;
+	info->frame_buffer = (u32)ioremap(fb_addr, info->vram_size);
+
+	if (!info->frame_buffer) {
+		iounmap((void *)info->regbase);
+		goto err_free_info;
+	}
 
-    /* If we can't test scratch registers, something is seriously wrong */
-    if (!register_test(info)) {
-        printk(KERN_ERR "aty128fb: Can't write to video register!\n");
-        goto err_out;
-    }
+	/* If we can't test scratch registers, something is seriously wrong */
+	if (!register_test(info)) {
+		printk(KERN_ERR "aty128fb: Can't write to video register!\n");
+		goto err_out;
+	}
 
 #if !defined(CONFIG_PPC) && !defined(__sparc__)
-    if (!aty128find_ROM(info))
-        printk(KERN_INFO "aty128fb: Rage128 BIOS not located. Guessing...\n");
-    else
-        aty128_get_pllinfo(info);
+	if (!(bios_seg = aty128find_ROM(info)))
+		printk(KERN_INFO "aty128fb: Rage128 BIOS not located. "
+					"Guessing...\n");
+	else {
+		printk(KERN_INFO "aty128fb: Rage128 BIOS located at "
+				"segment %4.4X\n", (unsigned int)bios_seg);
+		aty128_get_pllinfo(info, bios_seg);
+	}
 #endif
-    aty128_timings(info);
+	aty128_timings(info);
 
-    if (!aty128_init(info, "PCI"))
-        goto err_out;
+	if (!aty128_init(info, "PCI"))
+		goto err_out;
 
 #ifdef CONFIG_MTRR
-    if (mtrr) {
-        info->mtrr.vram = mtrr_add(info->frame_buffer_phys, info->vram_size,
-                                   MTRR_TYPE_WRCOMB, 1);
-        info->mtrr.vram_valid = 1;
-        /* let there be speed */
-        printk(KERN_INFO "aty128fb: Rage128 MTRR set to ON\n");
-    }
+	if (mtrr) {
+		info->mtrr.vram = mtrr_add(info->frame_buffer_phys,
+				info->vram_size, MTRR_TYPE_WRCOMB, 1);
+		info->mtrr.vram_valid = 1;
+		/* let there be speed */
+		printk(KERN_INFO "aty128fb: Rage128 MTRR set to ON\n");
+	}
 #endif /* CONFIG_MTRR */
 
-    return 0;
+	return 0;
 
 err_out:
-    iounmap((void *)info->frame_buffer);
-    iounmap((void *)info->regbase);
+	iounmap((void *)info->frame_buffer);
+	iounmap((void *)info->regbase);
 err_free_info:
-    kfree(info);
+	kfree(info);
 err_unmap_out:
-    release_mem_region(pci_resource_start(pdev, 2),
+	release_mem_region(pci_resource_start(pdev, 2),
 			pci_resource_len(pdev, 2));
 err_free_mmio:
-    release_mem_region(pci_resource_start(pdev, 0),
+	release_mem_region(pci_resource_start(pdev, 0),
 			pci_resource_len(pdev, 0));
 err_free_fb:
-    release_mem_region(pci_resource_start(pdev, 1),
+	release_mem_region(pci_resource_start(pdev, 1),
 			pci_resource_len(pdev, 1));
-    return -ENODEV;
+	return -ENODEV;
 }
 #endif /* CONFIG_PCI */
 
 
 /* PPC and Sparc cannot read video ROM */
 #if !defined(CONFIG_PPC) && !defined(__sparc__)
-static int __init
-aty128find_ROM(struct fb_info_aty128 *info)
+static char __init
+*aty128find_ROM(struct fb_info_aty128 *info)
 {
-    int  flag = 0;
-    u32  segstart;
-    char *rom_base;
-    char *rom;
-    int  stage;
-    int  i;
-    char aty_rom_sig[] = "761295520";   /* ATI ROM Signature      */
-    char R128_sig[] = "R128";           /* Rage128 ROM identifier */
-
-    for (segstart=0x000c0000; segstart<0x000f0000; segstart+=0x00001000) {
-        stage = 1;
-
-        rom_base = (char *) ioremap(segstart, 0x1000);
-
-        if ((*rom_base == 0x55) && (((*(rom_base + 1)) & 0xff) == 0xaa))
-            stage = 2;
-
-        if (stage != 2) {
-            iounmap(rom_base);
-            continue;
-        }
-        rom = rom_base;
-
-        for (i = 0; (i < 128 - strlen(aty_rom_sig)) && (stage != 3); i++) {
-            if (aty_rom_sig[0] == *rom) {
-                if (strncmp(aty_rom_sig, rom, strlen(aty_rom_sig)) == 0) {
-                    stage = 3;
-                }
-            }
-            rom++;
-        }
-        if (stage != 3) {
-            iounmap(rom_base);
-            continue;
-        }
-        rom = rom_base;
+	u32  segstart;
+	char *rom_base;
+	char *rom;
+	int  stage;
+	int  i;
+	char aty_rom_sig[] = "761295520";   /* ATI ROM Signature      */
+	char R128_sig[] = "R128";           /* Rage128 ROM identifier */
+
+	for (segstart=0x000c0000; segstart<0x000f0000; segstart+=0x00001000) {
+        	stage = 1;
+
+		rom_base = (char *)ioremap(segstart, 0x1000);
+
+		if ((*rom_base == 0x55) && (((*(rom_base + 1)) & 0xff) == 0xaa))
+			stage = 2;
+
+		if (stage != 2) {
+			iounmap(rom_base);
+			continue;
+		}
+		rom = rom_base;
+
+		for (i = 0; (i < 128 - strlen(aty_rom_sig)) && (stage != 3); i++) {
+			if (aty_rom_sig[0] == *rom)
+				if (strncmp(aty_rom_sig, rom,
+						strlen(aty_rom_sig)) == 0)
+					stage = 3;
+			rom++;
+		}
+		if (stage != 3) {
+			iounmap(rom_base);
+			continue;
+		}
+		rom = rom_base;
+
+		/* ATI signature found.  Let's see if it's a Rage128 */
+		for (i = 0; (i < 512) && (stage != 4); i++) {
+			if (R128_sig[0] == *rom)
+				if (strncmp(R128_sig, rom, 
+						strlen(R128_sig)) == 0)
+					stage = 4;
+			rom++;
+		}
+		if (stage != 4) {
+			iounmap(rom_base);
+			continue;
+		}
 
-        /* ATI signature found.  Let's see if it's a Rage128 */
-        for (i = 0; (i < 512) && (stage != 4); i++) {
-            if (R128_sig[0] == *rom) {
-                if (strncmp(R128_sig, rom, strlen(R128_sig)) == 0) {
-                    stage = 4;
-                }
-            }
-            rom++;
-        }
-        if (stage != 4) {
-            iounmap(rom_base);
-            continue;
-        }
+		return rom_base;
+	}
 
-        bios_seg = rom_base;
-        printk(KERN_INFO "aty128fb: Rage128 BIOS located at segment %4.4X\n",
-                         (unsigned int)rom_base);
-        flag = 1;
-        break;
-    }
-    return (flag);
+	return NULL;
 }
 
 
 static void __init
-aty128_get_pllinfo(struct fb_info_aty128 *info)
-{   
-    void *bios_header;
-    void *header_ptr;
-    u16 bios_header_offset, pll_info_offset;
-    PLL_BLOCK pll;
-
-    bios_header = bios_seg + 0x48L;
-    header_ptr  = bios_header;
-
-    bios_header_offset = readw(header_ptr);
-    bios_header = bios_seg + bios_header_offset;
-    bios_header += 0x30;
-
-    header_ptr = bios_header;
-    pll_info_offset = readw(header_ptr);
-    header_ptr = bios_seg + pll_info_offset;
-
-    memcpy_fromio(&pll, header_ptr, 50);
-
-    info->constants.ppll_max = pll.PCLK_max_freq;
-    info->constants.ppll_min = pll.PCLK_min_freq;
-    info->constants.xclk = (u32)pll.XCLK;
-    info->constants.ref_divider = (u32)pll.PCLK_ref_divider;
-    info->constants.dotclock = (u32)pll.PCLK_ref_freq;
+aty128_get_pllinfo(struct fb_info_aty128 *info, char *bios_seg)
+{
+	void *bios_header;
+	void *header_ptr;
+	u16 bios_header_offset, pll_info_offset;
+	PLL_BLOCK pll;
 
-    /* free up to be un-used resources. bios_seg is mapped by
-     * aty128find_ROM() and used by aty128_get_pllinfo()
-     *
-     * TODO: make more elegant. doesn't need to be global */
-    if (bios_seg)
-        iounmap(bios_seg);
+	bios_header = bios_seg + 0x48L;
+	header_ptr  = bios_header;
+
+	bios_header_offset = readw(header_ptr);
+	bios_header = bios_seg + bios_header_offset;
+	bios_header += 0x30;
+
+	header_ptr = bios_header;
+	pll_info_offset = readw(header_ptr);
+	header_ptr = bios_seg + pll_info_offset;
 
-    DBG("ppll_max %d ppll_min %d xclk %d "
-			"ref_divider %d dotclock %d\n",
+	memcpy_fromio(&pll, header_ptr, 50);
+
+	info->constants.ppll_max = pll.PCLK_max_freq;
+	info->constants.ppll_min = pll.PCLK_min_freq;
+	info->constants.xclk = (u32)pll.XCLK;
+	info->constants.ref_divider = (u32)pll.PCLK_ref_divider;
+	info->constants.dotclock = (u32)pll.PCLK_ref_freq;
+
+	DBG("ppll_max %d ppll_min %d xclk %d ref_divider %d dotclock %d\n",
 			info->constants.ppll_max, info->constants.ppll_min,
 			info->constants.xclk, info->constants.ref_divider,
 			info->constants.dotclock);
 
-    return;
 }           
 #endif /* !CONFIG_PPC */
 
@@ -2414,10 +2386,14 @@
 }
 
 static struct display_switch fbcon_aty128_8 = {
-    fbcon_cfb8_setup, fbcon_aty128_bmove, fbcon_cfb8_clear,
-    fbcon_aty8_putc, fbcon_aty8_putcs, fbcon_cfb8_revc, NULL, NULL,
-    fbcon_aty8_clear_margins,
-    FONTWIDTH(4)|FONTWIDTH(8)|FONTWIDTH(12)|FONTWIDTH(16)
+    setup:		fbcon_cfb8_setup,
+    bmove:		fbcon_aty128_bmove,
+    clear:		fbcon_cfb8_clear,
+    putc:		fbcon_aty8_putc,
+    putcs:		fbcon_aty8_putcs,
+    revc:		fbcon_cfb8_revc,
+    clear_margins:	fbcon_aty8_clear_margins,
+    fontwidthmask:	FONTWIDTH(4)|FONTWIDTH(8)|FONTWIDTH(12)|FONTWIDTH(16)
 };
 #endif
 #ifdef FBCON_HAS_CFB16
@@ -2458,10 +2434,14 @@
 }
 
 static struct display_switch fbcon_aty128_16 = {
-    fbcon_cfb16_setup, fbcon_aty128_bmove, fbcon_cfb16_clear,
-    fbcon_aty16_putc, fbcon_aty16_putcs, fbcon_cfb16_revc, NULL, NULL,
-    fbcon_aty16_clear_margins,
-    FONTWIDTH(4)|FONTWIDTH(8)|FONTWIDTH(12)|FONTWIDTH(16)
+    setup:		fbcon_cfb16_setup,
+    bmove:		fbcon_aty128_bmove,
+    clear:		fbcon_cfb16_clear,
+    putc:		fbcon_aty16_putc,
+    putcs:		fbcon_aty16_putcs,
+    revc:		fbcon_cfb16_revc,
+    clear_margins:	fbcon_aty16_clear_margins,
+    fontwidthmask:	FONTWIDTH(4)|FONTWIDTH(8)|FONTWIDTH(12)|FONTWIDTH(16)
 };
 #endif
 #ifdef FBCON_HAS_CFB24
@@ -2502,10 +2482,14 @@
 }
 
 static struct display_switch fbcon_aty128_24 = {
-    fbcon_cfb24_setup, fbcon_aty128_bmove, fbcon_cfb24_clear,
-    fbcon_aty24_putc, fbcon_aty24_putcs, fbcon_cfb24_revc, NULL, NULL,
-    fbcon_aty24_clear_margins,
-    FONTWIDTH(4)|FONTWIDTH(8)|FONTWIDTH(12)|FONTWIDTH(16)
+    setup:		fbcon_cfb24_setup,
+    bmove:		fbcon_aty128_bmove,
+    clear:		fbcon_cfb24_clear,
+    putc:		fbcon_aty24_putc,
+    putcs:		fbcon_aty24_putcs,
+    revc:		fbcon_cfb24_revc,
+    clear_margins:	fbcon_aty24_clear_margins,
+    fontwidthmask:	FONTWIDTH(4)|FONTWIDTH(8)|FONTWIDTH(12)|FONTWIDTH(16)
 };
 #endif
 #ifdef FBCON_HAS_CFB32
@@ -2546,10 +2530,14 @@
 }
 
 static struct display_switch fbcon_aty128_32 = {
-    fbcon_cfb32_setup, fbcon_aty128_bmove, fbcon_cfb32_clear,
-    fbcon_aty32_putc, fbcon_aty32_putcs, fbcon_cfb32_revc, NULL, NULL,
-    fbcon_aty32_clear_margins,
-    FONTWIDTH(4)|FONTWIDTH(8)|FONTWIDTH(12)|FONTWIDTH(16)
+    setup:		fbcon_cfb32_setup,
+    bmove:		fbcon_aty128_bmove,
+    clear:		fbcon_cfb32_clear,
+    putc:		fbcon_aty32_putc,
+    putcs:		fbcon_aty32_putcs,
+    revc:		fbcon_cfb32_revc,
+    clear_margins:	fbcon_aty32_clear_margins,
+    fontwidthmask:	FONTWIDTH(4)|FONTWIDTH(8)|FONTWIDTH(12)|FONTWIDTH(16)
 };
 #endif
 

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