aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/imsttfb.c
diff options
context:
space:
mode:
authorAntonino A. Daplas <adaplas@gmail.com>2006-01-09 23:53:07 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-10 11:01:45 -0500
commit94f9e09ce531d48b2e46208f9b1c8733a74c22de (patch)
tree5abef48d934736ce028e84c98b4e8d2bba68dd77 /drivers/video/imsttfb.c
parent1d204ef3e4ea61058e49453af393ca754b529b85 (diff)
[PATCH] fbdev: imsttfb: Driver cleanups
- remove unneeded casts - the pseudo_palette, if using the generic drawing functions, must always be u32 regardless of the bpp - use framebuffer_alloc/framebuffer_release to allocate memory Signed-off-by: Antonino Daplas <adaplas@pol.net> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/video/imsttfb.c')
-rw-r--r--drivers/video/imsttfb.c56
1 files changed, 27 insertions, 29 deletions
diff --git a/drivers/video/imsttfb.c b/drivers/video/imsttfb.c
index 7fbe24206b19..a5d813050db5 100644
--- a/drivers/video/imsttfb.c
+++ b/drivers/video/imsttfb.c
@@ -323,6 +323,7 @@ struct imstt_par {
323 unsigned long cmap_regs_phys; 323 unsigned long cmap_regs_phys;
324 __u8 *cmap_regs; 324 __u8 *cmap_regs;
325 __u32 ramdac; 325 __u32 ramdac;
326 __u32 palette[16];
326}; 327};
327 328
328enum { 329enum {
@@ -657,7 +658,7 @@ set_imstt_regvals_tvp (struct imstt_par *par, u_int bpp)
657static void 658static void
658set_imstt_regvals (struct fb_info *info, u_int bpp) 659set_imstt_regvals (struct fb_info *info, u_int bpp)
659{ 660{
660 struct imstt_par *par = (struct imstt_par *) info->par; 661 struct imstt_par *par = info->par;
661 struct imstt_regvals *init = &par->init; 662 struct imstt_regvals *init = &par->init;
662 __u32 ctl, pitch, byteswap, scr; 663 __u32 ctl, pitch, byteswap, scr;
663 664
@@ -749,7 +750,7 @@ set_imstt_regvals (struct fb_info *info, u_int bpp)
749static inline void 750static inline void
750set_offset (struct fb_var_screeninfo *var, struct fb_info *info) 751set_offset (struct fb_var_screeninfo *var, struct fb_info *info)
751{ 752{
752 struct imstt_par *par = (struct imstt_par *) info->par; 753 struct imstt_par *par = info->par;
753 __u32 off = var->yoffset * (info->fix.line_length >> 3) 754 __u32 off = var->yoffset * (info->fix.line_length >> 3)
754 + ((var->xoffset * (var->bits_per_pixel >> 3)) >> 3); 755 + ((var->xoffset * (var->bits_per_pixel >> 3)) >> 3);
755 write_reg_le32(par->dc_regs, SSR, off); 756 write_reg_le32(par->dc_regs, SSR, off);
@@ -863,7 +864,7 @@ imsttfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
863static int 864static int
864imsttfb_set_par(struct fb_info *info) 865imsttfb_set_par(struct fb_info *info)
865{ 866{
866 struct imstt_par *par = (struct imstt_par *) info->par; 867 struct imstt_par *par = info->par;
867 868
868 if (!compute_imstt_regvals(par, info->var.xres, info->var.yres)) 869 if (!compute_imstt_regvals(par, info->var.xres, info->var.yres))
869 return -EINVAL; 870 return -EINVAL;
@@ -881,7 +882,7 @@ static int
881imsttfb_setcolreg (u_int regno, u_int red, u_int green, u_int blue, 882imsttfb_setcolreg (u_int regno, u_int red, u_int green, u_int blue,
882 u_int transp, struct fb_info *info) 883 u_int transp, struct fb_info *info)
883{ 884{
884 struct imstt_par *par = (struct imstt_par *) info->par; 885 struct imstt_par *par = info->par;
885 u_int bpp = info->var.bits_per_pixel; 886 u_int bpp = info->var.bits_per_pixel;
886 887
887 if (regno > 255) 888 if (regno > 255)
@@ -905,14 +906,17 @@ imsttfb_setcolreg (u_int regno, u_int red, u_int green, u_int blue,
905 if (regno < 16) 906 if (regno < 16)
906 switch (bpp) { 907 switch (bpp) {
907 case 16: 908 case 16:
908 ((u16 *)info->pseudo_palette)[regno] = (regno << (info->var.green.length == 5 ? 10 : 11)) | (regno << 5) | regno; 909 par->palette[regno] =
910 (regno << (info->var.green.length ==
911 5 ? 10 : 11)) | (regno << 5) | regno;
909 break; 912 break;
910 case 24: 913 case 24:
911 ((u32 *)info->pseudo_palette)[regno] = (regno << 16) | (regno << 8) | regno; 914 par->palette[regno] =
915 (regno << 16) | (regno << 8) | regno;
912 break; 916 break;
913 case 32: { 917 case 32: {
914 int i = (regno << 8) | regno; 918 int i = (regno << 8) | regno;
915 ((u32 *)info->pseudo_palette)[regno] = (i << 16) | i; 919 par->palette[regno] = (i << 16) |i;
916 break; 920 break;
917 } 921 }
918 } 922 }
@@ -935,7 +939,7 @@ imsttfb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info)
935static int 939static int
936imsttfb_blank(int blank, struct fb_info *info) 940imsttfb_blank(int blank, struct fb_info *info)
937{ 941{
938 struct imstt_par *par = (struct imstt_par *) info->par; 942 struct imstt_par *par = info->par;
939 __u32 ctrl; 943 __u32 ctrl;
940 944
941 ctrl = read_reg_le32(par->dc_regs, STGCTL); 945 ctrl = read_reg_le32(par->dc_regs, STGCTL);
@@ -989,7 +993,7 @@ imsttfb_blank(int blank, struct fb_info *info)
989static void 993static void
990imsttfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect) 994imsttfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
991{ 995{
992 struct imstt_par *par = (struct imstt_par *) info->par; 996 struct imstt_par *par = info->par;
993 __u32 Bpp, line_pitch, bgc, dx, dy, width, height; 997 __u32 Bpp, line_pitch, bgc, dx, dy, width, height;
994 998
995 bgc = rect->color; 999 bgc = rect->color;
@@ -1033,7 +1037,7 @@ imsttfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
1033static void 1037static void
1034imsttfb_copyarea(struct fb_info *info, const struct fb_copyarea *area) 1038imsttfb_copyarea(struct fb_info *info, const struct fb_copyarea *area)
1035{ 1039{
1036 struct imstt_par *par = (struct imstt_par *) info->par; 1040 struct imstt_par *par = info->par;
1037 __u32 Bpp, line_pitch, fb_offset_old, fb_offset_new, sp, dp_octl; 1041 __u32 Bpp, line_pitch, fb_offset_old, fb_offset_new, sp, dp_octl;
1038 __u32 cnt, bltctl, sx, sy, dx, dy, height, width; 1042 __u32 cnt, bltctl, sx, sy, dx, dy, height, width;
1039 1043
@@ -1195,7 +1199,7 @@ imstt_set_cursor(struct imstt_par *par, struct fb_image *d, int on)
1195static int 1199static int
1196imsttfb_cursor(struct fb_info *info, struct fb_cursor *cursor) 1200imsttfb_cursor(struct fb_info *info, struct fb_cursor *cursor)
1197{ 1201{
1198 struct imstt_par *par = (struct imstt_par *) info->par; 1202 struct imstt_par *par = info->par;
1199 u32 flags = cursor->set, fg, bg, xx, yy; 1203 u32 flags = cursor->set, fg, bg, xx, yy;
1200 1204
1201 if (cursor->dest == NULL && cursor->rop == ROP_XOR) 1205 if (cursor->dest == NULL && cursor->rop == ROP_XOR)
@@ -1266,7 +1270,7 @@ static int
1266imsttfb_ioctl(struct inode *inode, struct file *file, u_int cmd, 1270imsttfb_ioctl(struct inode *inode, struct file *file, u_int cmd,
1267 u_long arg, struct fb_info *info) 1271 u_long arg, struct fb_info *info)
1268{ 1272{
1269 struct imstt_par *par = (struct imstt_par *) info->par; 1273 struct imstt_par *par = info->par;
1270 void __user *argp = (void __user *)arg; 1274 void __user *argp = (void __user *)arg;
1271 __u32 reg[2]; 1275 __u32 reg[2];
1272 __u8 idx[2]; 1276 __u8 idx[2];
@@ -1350,7 +1354,7 @@ static struct fb_ops imsttfb_ops = {
1350static void __devinit 1354static void __devinit
1351init_imstt(struct fb_info *info) 1355init_imstt(struct fb_info *info)
1352{ 1356{
1353 struct imstt_par *par = (struct imstt_par *) info->par; 1357 struct imstt_par *par = info->par;
1354 __u32 i, tmp, *ip, *end; 1358 __u32 i, tmp, *ip, *end;
1355 1359
1356 tmp = read_reg_le32(par->dc_regs, PRC); 1360 tmp = read_reg_le32(par->dc_regs, PRC);
@@ -1413,7 +1417,7 @@ init_imstt(struct fb_info *info)
1413 if ((info->var.xres * info->var.yres) * (info->var.bits_per_pixel >> 3) > info->fix.smem_len 1417 if ((info->var.xres * info->var.yres) * (info->var.bits_per_pixel >> 3) > info->fix.smem_len
1414 || !(compute_imstt_regvals(par, info->var.xres, info->var.yres))) { 1418 || !(compute_imstt_regvals(par, info->var.xres, info->var.yres))) {
1415 printk("imsttfb: %ux%ux%u not supported\n", info->var.xres, info->var.yres, info->var.bits_per_pixel); 1419 printk("imsttfb: %ux%ux%u not supported\n", info->var.xres, info->var.yres, info->var.bits_per_pixel);
1416 kfree(info); 1420 framebuffer_release(info);
1417 return; 1421 return;
1418 } 1422 }
1419 1423
@@ -1449,7 +1453,7 @@ init_imstt(struct fb_info *info)
1449 fb_alloc_cmap(&info->cmap, 0, 0); 1453 fb_alloc_cmap(&info->cmap, 0, 0);
1450 1454
1451 if (register_framebuffer(info) < 0) { 1455 if (register_framebuffer(info) < 0) {
1452 kfree(info); 1456 framebuffer_release(info);
1453 return; 1457 return;
1454 } 1458 }
1455 1459
@@ -1474,26 +1478,21 @@ imsttfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1474 printk(KERN_ERR "imsttfb: no OF node for pci device\n"); 1478 printk(KERN_ERR "imsttfb: no OF node for pci device\n");
1475#endif /* CONFIG_PPC_OF */ 1479#endif /* CONFIG_PPC_OF */
1476 1480
1477 size = sizeof(struct fb_info) + sizeof(struct imstt_par) + 1481 info = framebuffer_alloc(sizeof(struct imstt_par), &pdev->dev);
1478 sizeof(u32) * 16;
1479
1480 info = kmalloc(size, GFP_KERNEL);
1481 1482
1482 if (!info) { 1483 if (!info) {
1483 printk(KERN_ERR "imsttfb: Can't allocate memory\n"); 1484 printk(KERN_ERR "imsttfb: Can't allocate memory\n");
1484 return -ENOMEM; 1485 return -ENOMEM;
1485 } 1486 }
1486 1487
1487 memset(info, 0, size); 1488 par = info->par;
1488
1489 par = (struct imstt_par *) (info + 1);
1490 1489
1491 addr = pci_resource_start (pdev, 0); 1490 addr = pci_resource_start (pdev, 0);
1492 size = pci_resource_len (pdev, 0); 1491 size = pci_resource_len (pdev, 0);
1493 1492
1494 if (!request_mem_region(addr, size, "imsttfb")) { 1493 if (!request_mem_region(addr, size, "imsttfb")) {
1495 printk(KERN_ERR "imsttfb: Can't reserve memory region\n"); 1494 printk(KERN_ERR "imsttfb: Can't reserve memory region\n");
1496 kfree(info); 1495 framebuffer_release(info);
1497 return -ENODEV; 1496 return -ENODEV;
1498 } 1497 }
1499 1498
@@ -1516,14 +1515,13 @@ imsttfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1516 } 1515 }
1517 1516
1518 info->fix.smem_start = addr; 1517 info->fix.smem_start = addr;
1519 info->screen_base = (__u8 *)ioremap(addr, par->ramdac == IBM ? 0x400000 : 0x800000); 1518 info->screen_base = (__u8 *)ioremap(addr, par->ramdac == IBM ?
1519 0x400000 : 0x800000);
1520 info->fix.mmio_start = addr + 0x800000; 1520 info->fix.mmio_start = addr + 0x800000;
1521 par->dc_regs = ioremap(addr + 0x800000, 0x1000); 1521 par->dc_regs = ioremap(addr + 0x800000, 0x1000);
1522 par->cmap_regs_phys = addr + 0x840000; 1522 par->cmap_regs_phys = addr + 0x840000;
1523 par->cmap_regs = (__u8 *)ioremap(addr + 0x840000, 0x1000); 1523 par->cmap_regs = (__u8 *)ioremap(addr + 0x840000, 0x1000);
1524 info->par = par; 1524 info->pseudo_palette = par->palette;
1525 info->pseudo_palette = (void *) (par + 1);
1526 info->device = &pdev->dev;
1527 init_imstt(info); 1525 init_imstt(info);
1528 1526
1529 pci_set_drvdata(pdev, info); 1527 pci_set_drvdata(pdev, info);
@@ -1534,7 +1532,7 @@ static void __devexit
1534imsttfb_remove(struct pci_dev *pdev) 1532imsttfb_remove(struct pci_dev *pdev)
1535{ 1533{
1536 struct fb_info *info = pci_get_drvdata(pdev); 1534 struct fb_info *info = pci_get_drvdata(pdev);
1537 struct imstt_par *par = (struct imstt_par *) info->par; 1535 struct imstt_par *par = info->par;
1538 int size = pci_resource_len(pdev, 0); 1536 int size = pci_resource_len(pdev, 0);
1539 1537
1540 unregister_framebuffer(info); 1538 unregister_framebuffer(info);
@@ -1542,7 +1540,7 @@ imsttfb_remove(struct pci_dev *pdev)
1542 iounmap(par->dc_regs); 1540 iounmap(par->dc_regs);
1543 iounmap(info->screen_base); 1541 iounmap(info->screen_base);
1544 release_mem_region(info->fix.smem_start, size); 1542 release_mem_region(info->fix.smem_start, size);
1545 kfree(info); 1543 framebuffer_release(info);
1546} 1544}
1547 1545
1548#ifndef MODULE 1546#ifndef MODULE