Commit a26968df authored by Antonino A. Daplas's avatar Antonino A. Daplas Committed by Linus Torvalds

[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: default avatarAntonino Daplas <adaplas@pol.net>
Acked-by: default avatarPaul Mundt <lethal@linux-sh.org>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 94f9e09c
...@@ -73,8 +73,6 @@ static struct fb_var_screeninfo kyro_var __devinitdata = { ...@@ -73,8 +73,6 @@ static struct fb_var_screeninfo kyro_var __devinitdata = {
.vmode = FB_VMODE_NONINTERLACED, .vmode = FB_VMODE_NONINTERLACED,
}; };
static struct kyrofb_info *currentpar;
typedef struct { typedef struct {
STG4000REG __iomem *pSTGReg; /* Virtual address of PCI register region */ STG4000REG __iomem *pSTGReg; /* Virtual address of PCI register region */
u32 ulNextFreeVidMem; /* Offset from start of vid mem to next free region */ u32 ulNextFreeVidMem; /* Offset from start of vid mem to next free region */
...@@ -309,7 +307,7 @@ enum { ...@@ -309,7 +307,7 @@ enum {
/* Accessors */ /* Accessors */
static int kyro_dev_video_mode_set(struct fb_info *info) static int kyro_dev_video_mode_set(struct fb_info *info)
{ {
struct kyrofb_info *par = (struct kyrofb_info *)info->par; struct kyrofb_info *par = info->par;
/* Turn off display */ /* Turn off display */
StopVTG(deviceInfo.pSTGReg); StopVTG(deviceInfo.pSTGReg);
...@@ -402,7 +400,7 @@ static inline unsigned long get_line_length(int x, int bpp) ...@@ -402,7 +400,7 @@ static inline unsigned long get_line_length(int x, int bpp)
static int kyrofb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) static int kyrofb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
{ {
struct kyrofb_info *par = (struct kyrofb_info *)info->par; struct kyrofb_info *par = info->par;
if (var->bits_per_pixel != 16 && var->bits_per_pixel != 32) { if (var->bits_per_pixel != 16 && var->bits_per_pixel != 32) {
printk(KERN_WARNING "kyrofb: depth not supported: %u\n", var->bits_per_pixel); 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,7 +476,7 @@ static int kyrofb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
static int kyrofb_set_par(struct fb_info *info) static int kyrofb_set_par(struct fb_info *info)
{ {
struct kyrofb_info *par = (struct kyrofb_info *)info->par; struct kyrofb_info *par = info->par;
unsigned long lineclock; unsigned long lineclock;
unsigned long frameclock; unsigned long frameclock;
...@@ -536,20 +534,22 @@ static int kyrofb_set_par(struct fb_info *info) ...@@ -536,20 +534,22 @@ static int kyrofb_set_par(struct fb_info *info)
static int kyrofb_setcolreg(u_int regno, u_int red, u_int green, static int kyrofb_setcolreg(u_int regno, u_int red, u_int green,
u_int blue, u_int transp, struct fb_info *info) u_int blue, u_int transp, struct fb_info *info)
{ {
struct kyrofb_info *par = info->par;
if (regno > 255) if (regno > 255)
return 1; /* Invalid register */ return 1; /* Invalid register */
if (regno < 16) { if (regno < 16) {
switch (info->var.bits_per_pixel) { switch (info->var.bits_per_pixel) {
case 16: case 16:
((u16*)(info->pseudo_palette))[regno] = par->palette[regno] =
(red & 0xf800) | (red & 0xf800) |
((green & 0xfc00) >> 5) | ((green & 0xfc00) >> 5) |
((blue & 0xf800) >> 11); ((blue & 0xf800) >> 11);
break; break;
case 32: case 32:
red >>= 8; green >>= 8; blue >>= 8; transp >>= 8; red >>= 8; green >>= 8; blue >>= 8; transp >>= 8;
((u32*)(info->pseudo_palette))[regno] = par->palette[regno] =
(transp << 24) | (red << 16) | (green << 8) | blue; (transp << 24) | (red << 16) | (green << 8) | blue;
break; break;
} }
...@@ -675,6 +675,7 @@ static int __devinit kyrofb_probe(struct pci_dev *pdev, ...@@ -675,6 +675,7 @@ static int __devinit kyrofb_probe(struct pci_dev *pdev,
const struct pci_device_id *ent) const struct pci_device_id *ent)
{ {
struct fb_info *info; struct fb_info *info;
struct kyrofb_info *currentpar;
unsigned long size; unsigned long size;
int err; int err;
...@@ -683,14 +684,11 @@ static int __devinit kyrofb_probe(struct pci_dev *pdev, ...@@ -683,14 +684,11 @@ static int __devinit kyrofb_probe(struct pci_dev *pdev,
return err; return err;
} }
size = sizeof(struct fb_info) + sizeof(struct kyrofb_info) + 16 * sizeof(u32); info = framebuffer_alloc(sizeof(struct kyrofb_info), &pdev->dev);
info = kmalloc(size, GFP_KERNEL);
if (!info) if (!info)
return -ENOMEM; return -ENOMEM;
memset(info, 0, size); currentpar = info->par;
currentpar = (struct kyrofb_info *)(info + 1);
kyro_fix.smem_start = pci_resource_start(pdev, 0); kyro_fix.smem_start = pci_resource_start(pdev, 0);
kyro_fix.smem_len = pci_resource_len(pdev, 0); kyro_fix.smem_len = pci_resource_len(pdev, 0);
...@@ -716,8 +714,7 @@ static int __devinit kyrofb_probe(struct pci_dev *pdev, ...@@ -716,8 +714,7 @@ static int __devinit kyrofb_probe(struct pci_dev *pdev,
info->fbops = &kyrofb_ops; info->fbops = &kyrofb_ops;
info->fix = kyro_fix; info->fix = kyro_fix;
info->par = currentpar; info->pseudo_palette = currentpar->palette;
info->pseudo_palette = (void *)(currentpar + 1);
info->flags = FBINFO_DEFAULT; info->flags = FBINFO_DEFAULT;
SetCoreClockPLL(deviceInfo.pSTGReg, pdev); SetCoreClockPLL(deviceInfo.pSTGReg, pdev);
...@@ -741,7 +738,6 @@ static int __devinit kyrofb_probe(struct pci_dev *pdev, ...@@ -741,7 +738,6 @@ static int __devinit kyrofb_probe(struct pci_dev *pdev,
fb_memset(info->screen_base, 0, size); fb_memset(info->screen_base, 0, size);
info->device = &pdev->dev;
if (register_framebuffer(info) < 0) if (register_framebuffer(info) < 0)
goto out_unmap; goto out_unmap;
...@@ -757,7 +753,7 @@ static int __devinit kyrofb_probe(struct pci_dev *pdev, ...@@ -757,7 +753,7 @@ static int __devinit kyrofb_probe(struct pci_dev *pdev,
out_unmap: out_unmap:
iounmap(currentpar->regbase); iounmap(currentpar->regbase);
iounmap(info->screen_base); iounmap(info->screen_base);
kfree(info); framebuffer_release(info);
return -EINVAL; return -EINVAL;
} }
...@@ -765,7 +761,7 @@ out_unmap: ...@@ -765,7 +761,7 @@ out_unmap:
static void __devexit kyrofb_remove(struct pci_dev *pdev) static void __devexit kyrofb_remove(struct pci_dev *pdev)
{ {
struct fb_info *info = pci_get_drvdata(pdev); struct fb_info *info = pci_get_drvdata(pdev);
struct kyrofb_info *par = (struct kyrofb_info *)info->par; struct kyrofb_info *par = info->par;
/* Reset the board */ /* Reset the board */
StopVTG(deviceInfo.pSTGReg); StopVTG(deviceInfo.pSTGReg);
...@@ -789,7 +785,7 @@ static void __devexit kyrofb_remove(struct pci_dev *pdev) ...@@ -789,7 +785,7 @@ static void __devexit kyrofb_remove(struct pci_dev *pdev)
unregister_framebuffer(info); unregister_framebuffer(info);
pci_set_drvdata(pdev, NULL); pci_set_drvdata(pdev, NULL);
kfree(info); framebuffer_release(info);
} }
static int __init kyrofb_init(void) static int __init kyrofb_init(void)
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
struct kyrofb_info { struct kyrofb_info {
void __iomem *regbase; void __iomem *regbase;
u32 palette[16];
u32 HTot; /* Hor Total Time */ u32 HTot; /* Hor Total Time */
u32 HFP; /* Hor Front Porch */ u32 HFP; /* Hor Front Porch */
u32 HST; /* Hor Sync Time */ u32 HST; /* Hor Sync Time */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment