aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/kyro
diff options
context:
space:
mode:
authorAntonino A. Daplas <adaplas@gmail.com>2006-01-09 23:53:08 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-10 11:01:45 -0500
commita26968df0110bc2117e5572a07e285b183e68736 (patch)
tree09aa54089508c0785ec6996709b5642c3b75f91c /drivers/video/kyro
parent94f9e09ce531d48b2e46208f9b1c8733a74c22de (diff)
[PATCH] fbdev: kyrofb: Driver cleanups
- remove unneeded casts - use framebuffer_alloc/framebuffer_release to allocate/free memory - the pseudo_palette is always u32 regardless of bpp if using generic drawing functions Signed-off-by: Antonino Daplas <adaplas@pol.net> Acked-by: Paul Mundt <lethal@linux-sh.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/video/kyro')
-rw-r--r--drivers/video/kyro/fbdev.c32
1 files changed, 14 insertions, 18 deletions
diff --git a/drivers/video/kyro/fbdev.c b/drivers/video/kyro/fbdev.c
index 5eb4d5c177bd..bcd359b6d4ff 100644
--- a/drivers/video/kyro/fbdev.c
+++ b/drivers/video/kyro/fbdev.c
@@ -73,8 +73,6 @@ static struct fb_var_screeninfo kyro_var __devinitdata = {
73 .vmode = FB_VMODE_NONINTERLACED, 73 .vmode = FB_VMODE_NONINTERLACED,
74}; 74};
75 75
76static struct kyrofb_info *currentpar;
77
78typedef struct { 76typedef struct {
79 STG4000REG __iomem *pSTGReg; /* Virtual address of PCI register region */ 77 STG4000REG __iomem *pSTGReg; /* Virtual address of PCI register region */
80 u32 ulNextFreeVidMem; /* Offset from start of vid mem to next free region */ 78 u32 ulNextFreeVidMem; /* Offset from start of vid mem to next free region */
@@ -309,7 +307,7 @@ enum {
309/* Accessors */ 307/* Accessors */
310static int kyro_dev_video_mode_set(struct fb_info *info) 308static int kyro_dev_video_mode_set(struct fb_info *info)
311{ 309{
312 struct kyrofb_info *par = (struct kyrofb_info *)info->par; 310 struct kyrofb_info *par = info->par;
313 311
314 /* Turn off display */ 312 /* Turn off display */
315 StopVTG(deviceInfo.pSTGReg); 313 StopVTG(deviceInfo.pSTGReg);
@@ -402,7 +400,7 @@ static inline unsigned long get_line_length(int x, int bpp)
402 400
403static int kyrofb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) 401static int kyrofb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
404{ 402{
405 struct kyrofb_info *par = (struct kyrofb_info *)info->par; 403 struct kyrofb_info *par = info->par;
406 404
407 if (var->bits_per_pixel != 16 && var->bits_per_pixel != 32) { 405 if (var->bits_per_pixel != 16 && var->bits_per_pixel != 32) {
408 printk(KERN_WARNING "kyrofb: depth not supported: %u\n", var->bits_per_pixel); 406 printk(KERN_WARNING "kyrofb: depth not supported: %u\n", var->bits_per_pixel);
@@ -478,7 +476,7 @@ static int kyrofb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
478 476
479static int kyrofb_set_par(struct fb_info *info) 477static int kyrofb_set_par(struct fb_info *info)
480{ 478{
481 struct kyrofb_info *par = (struct kyrofb_info *)info->par; 479 struct kyrofb_info *par = info->par;
482 unsigned long lineclock; 480 unsigned long lineclock;
483 unsigned long frameclock; 481 unsigned long frameclock;
484 482
@@ -536,20 +534,22 @@ static int kyrofb_set_par(struct fb_info *info)
536static int kyrofb_setcolreg(u_int regno, u_int red, u_int green, 534static int kyrofb_setcolreg(u_int regno, u_int red, u_int green,
537 u_int blue, u_int transp, struct fb_info *info) 535 u_int blue, u_int transp, struct fb_info *info)
538{ 536{
537 struct kyrofb_info *par = info->par;
538
539 if (regno > 255) 539 if (regno > 255)
540 return 1; /* Invalid register */ 540 return 1; /* Invalid register */
541 541
542 if (regno < 16) { 542 if (regno < 16) {
543 switch (info->var.bits_per_pixel) { 543 switch (info->var.bits_per_pixel) {
544 case 16: 544 case 16:
545 ((u16*)(info->pseudo_palette))[regno] = 545 par->palette[regno] =
546 (red & 0xf800) | 546 (red & 0xf800) |
547 ((green & 0xfc00) >> 5) | 547 ((green & 0xfc00) >> 5) |
548 ((blue & 0xf800) >> 11); 548 ((blue & 0xf800) >> 11);
549 break; 549 break;
550 case 32: 550 case 32:
551 red >>= 8; green >>= 8; blue >>= 8; transp >>= 8; 551 red >>= 8; green >>= 8; blue >>= 8; transp >>= 8;
552 ((u32*)(info->pseudo_palette))[regno] = 552 par->palette[regno] =
553 (transp << 24) | (red << 16) | (green << 8) | blue; 553 (transp << 24) | (red << 16) | (green << 8) | blue;
554 break; 554 break;
555 } 555 }
@@ -675,6 +675,7 @@ static int __devinit kyrofb_probe(struct pci_dev *pdev,
675 const struct pci_device_id *ent) 675 const struct pci_device_id *ent)
676{ 676{
677 struct fb_info *info; 677 struct fb_info *info;
678 struct kyrofb_info *currentpar;
678 unsigned long size; 679 unsigned long size;
679 int err; 680 int err;
680 681
@@ -683,14 +684,11 @@ static int __devinit kyrofb_probe(struct pci_dev *pdev,
683 return err; 684 return err;
684 } 685 }
685 686
686 size = sizeof(struct fb_info) + sizeof(struct kyrofb_info) + 16 * sizeof(u32); 687 info = framebuffer_alloc(sizeof(struct kyrofb_info), &pdev->dev);
687 info = kmalloc(size, GFP_KERNEL);
688 if (!info) 688 if (!info)
689 return -ENOMEM; 689 return -ENOMEM;
690 690
691 memset(info, 0, size); 691 currentpar = info->par;
692
693 currentpar = (struct kyrofb_info *)(info + 1);
694 692
695 kyro_fix.smem_start = pci_resource_start(pdev, 0); 693 kyro_fix.smem_start = pci_resource_start(pdev, 0);
696 kyro_fix.smem_len = pci_resource_len(pdev, 0); 694 kyro_fix.smem_len = pci_resource_len(pdev, 0);
@@ -716,8 +714,7 @@ static int __devinit kyrofb_probe(struct pci_dev *pdev,
716 714
717 info->fbops = &kyrofb_ops; 715 info->fbops = &kyrofb_ops;
718 info->fix = kyro_fix; 716 info->fix = kyro_fix;
719 info->par = currentpar; 717 info->pseudo_palette = currentpar->palette;
720 info->pseudo_palette = (void *)(currentpar + 1);
721 info->flags = FBINFO_DEFAULT; 718 info->flags = FBINFO_DEFAULT;
722 719
723 SetCoreClockPLL(deviceInfo.pSTGReg, pdev); 720 SetCoreClockPLL(deviceInfo.pSTGReg, pdev);
@@ -741,7 +738,6 @@ static int __devinit kyrofb_probe(struct pci_dev *pdev,
741 738
742 fb_memset(info->screen_base, 0, size); 739 fb_memset(info->screen_base, 0, size);
743 740
744 info->device = &pdev->dev;
745 if (register_framebuffer(info) < 0) 741 if (register_framebuffer(info) < 0)
746 goto out_unmap; 742 goto out_unmap;
747 743
@@ -757,7 +753,7 @@ static int __devinit kyrofb_probe(struct pci_dev *pdev,
757out_unmap: 753out_unmap:
758 iounmap(currentpar->regbase); 754 iounmap(currentpar->regbase);
759 iounmap(info->screen_base); 755 iounmap(info->screen_base);
760 kfree(info); 756 framebuffer_release(info);
761 757
762 return -EINVAL; 758 return -EINVAL;
763} 759}
@@ -765,7 +761,7 @@ out_unmap:
765static void __devexit kyrofb_remove(struct pci_dev *pdev) 761static void __devexit kyrofb_remove(struct pci_dev *pdev)
766{ 762{
767 struct fb_info *info = pci_get_drvdata(pdev); 763 struct fb_info *info = pci_get_drvdata(pdev);
768 struct kyrofb_info *par = (struct kyrofb_info *)info->par; 764 struct kyrofb_info *par = info->par;
769 765
770 /* Reset the board */ 766 /* Reset the board */
771 StopVTG(deviceInfo.pSTGReg); 767 StopVTG(deviceInfo.pSTGReg);
@@ -789,7 +785,7 @@ static void __devexit kyrofb_remove(struct pci_dev *pdev)
789 785
790 unregister_framebuffer(info); 786 unregister_framebuffer(info);
791 pci_set_drvdata(pdev, NULL); 787 pci_set_drvdata(pdev, NULL);
792 kfree(info); 788 framebuffer_release(info);
793} 789}
794 790
795static int __init kyrofb_init(void) 791static int __init kyrofb_init(void)