aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntonino A. Daplas <adaplas@gmail.com>2006-01-09 23:53:11 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-10 11:01:46 -0500
commita807f618b62594467a52b488912bd77606af0572 (patch)
treec91985182777dadd852ef6d08346b0b1fc42250a
parent6772a2ee9d5992a712b46990f39249c500e0221f (diff)
[PATCH] fbdev: tdfxfb: Driver cleanups
- remove unneeded casts - move memory for pseudo_palette inside struct tdfxfb_par - whitespace changes Signed-off-by: Antonino Daplas <adaplas@pol.net> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--drivers/video/tdfxfb.c57
-rw-r--r--include/video/tdfx.h86
2 files changed, 74 insertions, 69 deletions
diff --git a/drivers/video/tdfxfb.c b/drivers/video/tdfxfb.c
index 9d53387e6a66..c88b5348c4ee 100644
--- a/drivers/video/tdfxfb.c
+++ b/drivers/video/tdfxfb.c
@@ -291,7 +291,7 @@ static inline void banshee_make_room(struct tdfx_par *par, int size)
291 291
292static int banshee_wait_idle(struct fb_info *info) 292static int banshee_wait_idle(struct fb_info *info)
293{ 293{
294 struct tdfx_par *par = (struct tdfx_par *) info->par; 294 struct tdfx_par *par = info->par;
295 int i = 0; 295 int i = 0;
296 296
297 banshee_make_room(par, 1); 297 banshee_make_room(par, 1);
@@ -364,7 +364,7 @@ static u32 do_calc_pll(int freq, int* freq_out)
364 364
365static void do_write_regs(struct fb_info *info, struct banshee_reg* reg) 365static void do_write_regs(struct fb_info *info, struct banshee_reg* reg)
366{ 366{
367 struct tdfx_par *par = (struct tdfx_par *) info->par; 367 struct tdfx_par *par = info->par;
368 int i; 368 int i;
369 369
370 banshee_wait_idle(info); 370 banshee_wait_idle(info);
@@ -469,7 +469,7 @@ static unsigned long do_lfb_size(struct tdfx_par *par, unsigned short dev_id)
469 469
470static int tdfxfb_check_var(struct fb_var_screeninfo *var,struct fb_info *info) 470static int tdfxfb_check_var(struct fb_var_screeninfo *var,struct fb_info *info)
471{ 471{
472 struct tdfx_par *par = (struct tdfx_par *) info->par; 472 struct tdfx_par *par = info->par;
473 u32 lpitch; 473 u32 lpitch;
474 474
475 if (var->bits_per_pixel != 8 && var->bits_per_pixel != 16 && 475 if (var->bits_per_pixel != 8 && var->bits_per_pixel != 16 &&
@@ -558,7 +558,7 @@ static int tdfxfb_check_var(struct fb_var_screeninfo *var,struct fb_info *info)
558 558
559static int tdfxfb_set_par(struct fb_info *info) 559static int tdfxfb_set_par(struct fb_info *info)
560{ 560{
561 struct tdfx_par *par = (struct tdfx_par *) info->par; 561 struct tdfx_par *par = info->par;
562 u32 hdispend, hsyncsta, hsyncend, htotal; 562 u32 hdispend, hsyncsta, hsyncend, htotal;
563 u32 hd, hs, he, ht, hbs, hbe; 563 u32 hd, hs, he, ht, hbs, hbe;
564 u32 vd, vs, ve, vt, vbs, vbe; 564 u32 vd, vs, ve, vt, vbs, vbe;
@@ -780,7 +780,7 @@ static int tdfxfb_set_par(struct fb_info *info)
780static int tdfxfb_setcolreg(unsigned regno, unsigned red, unsigned green, 780static int tdfxfb_setcolreg(unsigned regno, unsigned red, unsigned green,
781 unsigned blue,unsigned transp,struct fb_info *info) 781 unsigned blue,unsigned transp,struct fb_info *info)
782{ 782{
783 struct tdfx_par *par = (struct tdfx_par *) info->par; 783 struct tdfx_par *par = info->par;
784 u32 rgbcol; 784 u32 rgbcol;
785 785
786 if (regno >= info->cmap.len || regno > 255) return 1; 786 if (regno >= info->cmap.len || regno > 255) return 1;
@@ -794,11 +794,15 @@ static int tdfxfb_setcolreg(unsigned regno, unsigned red, unsigned green,
794 break; 794 break;
795 /* Truecolor has no hardware color palettes. */ 795 /* Truecolor has no hardware color palettes. */
796 case FB_VISUAL_TRUECOLOR: 796 case FB_VISUAL_TRUECOLOR:
797 rgbcol = (CNVT_TOHW( red, info->var.red.length) << info->var.red.offset) | 797 rgbcol = (CNVT_TOHW( red, info->var.red.length) <<
798 (CNVT_TOHW( green, info->var.green.length) << info->var.green.offset) | 798 info->var.red.offset) |
799 (CNVT_TOHW( blue, info->var.blue.length) << info->var.blue.offset) | 799 (CNVT_TOHW( green, info->var.green.length) <<
800 (CNVT_TOHW( transp, info->var.transp.length) << info->var.transp.offset); 800 info->var.green.offset) |
801 ((u32*)(info->pseudo_palette))[regno] = rgbcol; 801 (CNVT_TOHW( blue, info->var.blue.length) <<
802 info->var.blue.offset) |
803 (CNVT_TOHW( transp, info->var.transp.length) <<
804 info->var.transp.offset);
805 par->palette[regno] = rgbcol;
802 break; 806 break;
803 default: 807 default:
804 DPRINTK("bad depth %u\n", info->var.bits_per_pixel); 808 DPRINTK("bad depth %u\n", info->var.bits_per_pixel);
@@ -810,7 +814,7 @@ static int tdfxfb_setcolreg(unsigned regno, unsigned red, unsigned green,
810/* 0 unblank, 1 blank, 2 no vsync, 3 no hsync, 4 off */ 814/* 0 unblank, 1 blank, 2 no vsync, 3 no hsync, 4 off */
811static int tdfxfb_blank(int blank, struct fb_info *info) 815static int tdfxfb_blank(int blank, struct fb_info *info)
812{ 816{
813 struct tdfx_par *par = (struct tdfx_par *) info->par; 817 struct tdfx_par *par = info->par;
814 u32 dacmode, state = 0, vgablank = 0; 818 u32 dacmode, state = 0, vgablank = 0;
815 819
816 dacmode = tdfx_inl(par, DACMODE); 820 dacmode = tdfx_inl(par, DACMODE);
@@ -855,7 +859,7 @@ static int tdfxfb_blank(int blank, struct fb_info *info)
855static int tdfxfb_pan_display(struct fb_var_screeninfo *var, 859static int tdfxfb_pan_display(struct fb_var_screeninfo *var,
856 struct fb_info *info) 860 struct fb_info *info)
857{ 861{
858 struct tdfx_par *par = (struct tdfx_par *) info->par; 862 struct tdfx_par *par = info->par;
859 u32 addr; 863 u32 addr;
860 864
861 if (nopan || var->xoffset || (var->yoffset > var->yres_virtual)) 865 if (nopan || var->xoffset || (var->yoffset > var->yres_virtual))
@@ -878,7 +882,7 @@ static int tdfxfb_pan_display(struct fb_var_screeninfo *var,
878 */ 882 */
879static void tdfxfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect) 883static void tdfxfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
880{ 884{
881 struct tdfx_par *par = (struct tdfx_par *) info->par; 885 struct tdfx_par *par = info->par;
882 u32 bpp = info->var.bits_per_pixel; 886 u32 bpp = info->var.bits_per_pixel;
883 u32 stride = info->fix.line_length; 887 u32 stride = info->fix.line_length;
884 u32 fmt= stride | ((bpp+((bpp==8) ? 0 : 8)) << 13); 888 u32 fmt= stride | ((bpp+((bpp==8) ? 0 : 8)) << 13);
@@ -894,7 +898,7 @@ static void tdfxfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect
894 if (info->fix.visual == FB_VISUAL_PSEUDOCOLOR) { 898 if (info->fix.visual == FB_VISUAL_PSEUDOCOLOR) {
895 tdfx_outl(par, COLORFORE, rect->color); 899 tdfx_outl(par, COLORFORE, rect->color);
896 } else { /* FB_VISUAL_TRUECOLOR */ 900 } else { /* FB_VISUAL_TRUECOLOR */
897 tdfx_outl(par, COLORFORE, ((u32*)(info->pseudo_palette))[rect->color]); 901 tdfx_outl(par, COLORFORE, par->palette[rect->color]);
898 } 902 }
899 tdfx_outl(par, COMMAND_2D, COMMAND_2D_FILLRECT | (tdfx_rop << 24)); 903 tdfx_outl(par, COMMAND_2D, COMMAND_2D_FILLRECT | (tdfx_rop << 24));
900 tdfx_outl(par, DSTSIZE, rect->width | (rect->height << 16)); 904 tdfx_outl(par, DSTSIZE, rect->width | (rect->height << 16));
@@ -906,7 +910,7 @@ static void tdfxfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect
906 */ 910 */
907static void tdfxfb_copyarea(struct fb_info *info, const struct fb_copyarea *area) 911static void tdfxfb_copyarea(struct fb_info *info, const struct fb_copyarea *area)
908{ 912{
909 struct tdfx_par *par = (struct tdfx_par *) info->par; 913 struct tdfx_par *par = info->par;
910 u32 sx = area->sx, sy = area->sy, dx = area->dx, dy = area->dy; 914 u32 sx = area->sx, sy = area->sy, dx = area->dx, dy = area->dy;
911 u32 bpp = info->var.bits_per_pixel; 915 u32 bpp = info->var.bits_per_pixel;
912 u32 stride = info->fix.line_length; 916 u32 stride = info->fix.line_length;
@@ -938,7 +942,7 @@ static void tdfxfb_copyarea(struct fb_info *info, const struct fb_copyarea *area
938 942
939static void tdfxfb_imageblit(struct fb_info *info, const struct fb_image *image) 943static void tdfxfb_imageblit(struct fb_info *info, const struct fb_image *image)
940{ 944{
941 struct tdfx_par *par = (struct tdfx_par *) info->par; 945 struct tdfx_par *par = info->par;
942 int size = image->height * ((image->width * image->depth + 7)>>3); 946 int size = image->height * ((image->width * image->depth + 7)>>3);
943 int fifo_free; 947 int fifo_free;
944 int i, stride = info->fix.line_length; 948 int i, stride = info->fix.line_length;
@@ -961,8 +965,10 @@ static void tdfxfb_imageblit(struct fb_info *info, const struct fb_image *image)
961 break; 965 break;
962 case FB_VISUAL_TRUECOLOR: 966 case FB_VISUAL_TRUECOLOR:
963 default: 967 default:
964 tdfx_outl(par, COLORFORE, ((u32*)(info->pseudo_palette))[image->fg_color]); 968 tdfx_outl(par, COLORFORE,
965 tdfx_outl(par, COLORBACK, ((u32*)(info->pseudo_palette))[image->bg_color]); 969 par->palette[image->fg_color]);
970 tdfx_outl(par, COLORBACK,
971 par->palette[image->bg_color]);
966 } 972 }
967#ifdef __BIG_ENDIAN 973#ifdef __BIG_ENDIAN
968 srcfmt = 0x400000 | BIT(20); 974 srcfmt = 0x400000 | BIT(20);
@@ -1007,7 +1013,7 @@ static void tdfxfb_imageblit(struct fb_info *info, const struct fb_image *image)
1007#ifdef TDFX_HARDWARE_CURSOR 1013#ifdef TDFX_HARDWARE_CURSOR
1008static int tdfxfb_cursor(struct fb_info *info, struct fb_cursor *cursor) 1014static int tdfxfb_cursor(struct fb_info *info, struct fb_cursor *cursor)
1009{ 1015{
1010 struct tdfx_par *par = (struct tdfx_par *) info->par; 1016 struct tdfx_par *par = info->par;
1011 unsigned long flags; 1017 unsigned long flags;
1012 1018
1013 /* 1019 /*
@@ -1157,18 +1163,17 @@ static int __devinit tdfxfb_probe(struct pci_dev *pdev,
1157{ 1163{
1158 struct tdfx_par *default_par; 1164 struct tdfx_par *default_par;
1159 struct fb_info *info; 1165 struct fb_info *info;
1160 int size, err, lpitch; 1166 int err, lpitch;
1161 1167
1162 if ((err = pci_enable_device(pdev))) { 1168 if ((err = pci_enable_device(pdev))) {
1163 printk(KERN_WARNING "tdfxfb: Can't enable pdev: %d\n", err); 1169 printk(KERN_WARNING "tdfxfb: Can't enable pdev: %d\n", err);
1164 return err; 1170 return err;
1165 } 1171 }
1166 1172
1167 size = sizeof(struct tdfx_par)+256*sizeof(u32); 1173 info = framebuffer_alloc(sizeof(struct tdfx_par), &pdev->dev);
1168 1174
1169 info = framebuffer_alloc(size, &pdev->dev); 1175 if (!info)
1170 1176 return -ENOMEM;
1171 if (!info) return -ENOMEM;
1172 1177
1173 default_par = info->par; 1178 default_par = info->par;
1174 1179
@@ -1248,7 +1253,7 @@ static int __devinit tdfxfb_probe(struct pci_dev *pdev,
1248 1253
1249 info->fbops = &tdfxfb_ops; 1254 info->fbops = &tdfxfb_ops;
1250 info->fix = tdfx_fix; 1255 info->fix = tdfx_fix;
1251 info->pseudo_palette = (void *)(default_par + 1); 1256 info->pseudo_palette = default_par->palette;
1252 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN; 1257 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN;
1253#ifdef CONFIG_FB_3DFX_ACCEL 1258#ifdef CONFIG_FB_3DFX_ACCEL
1254 info->flags |= FBINFO_HWACCEL_FILLRECT | 1259 info->flags |= FBINFO_HWACCEL_FILLRECT |
@@ -1340,7 +1345,7 @@ void tdfxfb_setup(char *options)
1340static void __devexit tdfxfb_remove(struct pci_dev *pdev) 1345static void __devexit tdfxfb_remove(struct pci_dev *pdev)
1341{ 1346{
1342 struct fb_info *info = pci_get_drvdata(pdev); 1347 struct fb_info *info = pci_get_drvdata(pdev);
1343 struct tdfx_par *par = (struct tdfx_par *) info->par; 1348 struct tdfx_par *par = info->par;
1344 1349
1345 unregister_framebuffer(info); 1350 unregister_framebuffer(info);
1346 iounmap(par->regbase_virt); 1351 iounmap(par->regbase_virt);
diff --git a/include/video/tdfx.h b/include/video/tdfx.h
index 04237676b17c..c1cc94ba3fdd 100644
--- a/include/video/tdfx.h
+++ b/include/video/tdfx.h
@@ -140,52 +140,52 @@
140#ifdef __KERNEL__ 140#ifdef __KERNEL__
141 141
142struct banshee_reg { 142struct banshee_reg {
143 /* VGA rubbish */ 143 /* VGA rubbish */
144 unsigned char att[21]; 144 unsigned char att[21];
145 unsigned char crt[25]; 145 unsigned char crt[25];
146 unsigned char gra[ 9]; 146 unsigned char gra[ 9];
147 unsigned char misc[1]; 147 unsigned char misc[1];
148 unsigned char seq[ 5]; 148 unsigned char seq[ 5];
149 149
150 /* Banshee extensions */ 150 /* Banshee extensions */
151 unsigned char ext[2]; 151 unsigned char ext[2];
152 unsigned long vidcfg; 152 unsigned long vidcfg;
153 unsigned long vidpll; 153 unsigned long vidpll;
154 unsigned long mempll; 154 unsigned long mempll;
155 unsigned long gfxpll; 155 unsigned long gfxpll;
156 unsigned long dacmode; 156 unsigned long dacmode;
157 unsigned long vgainit0; 157 unsigned long vgainit0;
158 unsigned long vgainit1; 158 unsigned long vgainit1;
159 unsigned long screensize; 159 unsigned long screensize;
160 unsigned long stride; 160 unsigned long stride;
161 unsigned long cursloc; 161 unsigned long cursloc;
162 unsigned long curspataddr; 162 unsigned long curspataddr;
163 unsigned long cursc0; 163 unsigned long cursc0;
164 unsigned long cursc1; 164 unsigned long cursc1;
165 unsigned long startaddr; 165 unsigned long startaddr;
166 unsigned long clip0min; 166 unsigned long clip0min;
167 unsigned long clip0max; 167 unsigned long clip0max;
168 unsigned long clip1min; 168 unsigned long clip1min;
169 unsigned long clip1max; 169 unsigned long clip1max;
170 unsigned long srcbase; 170 unsigned long srcbase;
171 unsigned long dstbase; 171 unsigned long dstbase;
172 unsigned long miscinit0; 172 unsigned long miscinit0;
173}; 173};
174 174
175struct tdfx_par { 175struct tdfx_par {
176 u32 max_pixclock; 176 u32 max_pixclock;
177 177 u32 palette[16];
178 void __iomem *regbase_virt; 178 void __iomem *regbase_virt;
179 unsigned long iobase; 179 unsigned long iobase;
180 u32 baseline; 180 u32 baseline;
181 181
182 struct { 182 struct {
183 int w,u,d; 183 int w,u,d;
184 unsigned long enable,disable; 184 unsigned long enable,disable;
185 struct timer_list timer; 185 struct timer_list timer;
186 } hwcursor; 186 } hwcursor;
187 187
188 spinlock_t DAClock; 188 spinlock_t DAClock;
189}; 189};
190 190
191#endif /* __KERNEL__ */ 191#endif /* __KERNEL__ */