tdfxfb: coding style improvement

This patch contains coding style improvements to the tdfxfb driver (white
spaces, indentations, long lines).

It also moves fb_ops structure to the end of file, so forward declarations of
ops functions are redundant.

Signed-off-by: Krzysztof Helt <krzysztof.h1@wp.pl>
Signed-off-by: Antonino Daplas <adaplas@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Krzysztof Helt 2007-10-16 01:28:43 -07:00 committed by Linus Torvalds
parent 245a2c2c69
commit 8af1d50f7f
2 changed files with 505 additions and 490 deletions

View File

@ -149,48 +149,6 @@ static struct pci_driver tdfxfb_driver = {
MODULE_DEVICE_TABLE(pci, tdfxfb_id_table);
/*
* Frame buffer device API
*/
static int tdfxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *fb);
static int tdfxfb_set_par(struct fb_info *info);
static int tdfxfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
u_int transp, struct fb_info *info);
static int tdfxfb_blank(int blank, struct fb_info *info);
static int tdfxfb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info);
static int banshee_wait_idle(struct fb_info *info);
#ifdef CONFIG_FB_3DFX_ACCEL
static void tdfxfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect);
static void tdfxfb_copyarea(struct fb_info *info, const struct fb_copyarea *area);
static void tdfxfb_imageblit(struct fb_info *info, const struct fb_image *image);
#endif /* CONFIG_FB_3DFX_ACCEL */
static struct fb_ops tdfxfb_ops = {
.owner = THIS_MODULE,
.fb_check_var = tdfxfb_check_var,
.fb_set_par = tdfxfb_set_par,
.fb_setcolreg = tdfxfb_setcolreg,
.fb_blank = tdfxfb_blank,
.fb_pan_display = tdfxfb_pan_display,
.fb_sync = banshee_wait_idle,
#ifdef CONFIG_FB_3DFX_ACCEL
.fb_fillrect = tdfxfb_fillrect,
.fb_copyarea = tdfxfb_copyarea,
.fb_imageblit = tdfxfb_imageblit,
#else
.fb_fillrect = cfb_fillrect,
.fb_copyarea = cfb_copyarea,
.fb_imageblit = cfb_imageblit,
#endif
};
/*
* do_xxx: Hardware-specific functions
*/
static u32 do_calc_pll(int freq, int *freq_out);
static void do_write_regs(struct fb_info *info, struct banshee_reg *reg);
static unsigned long do_lfb_size(struct tdfx_par *par, unsigned short);
/*
* Driver data
*/
@ -203,36 +161,54 @@ static char *mode_option __devinitdata = NULL;
* ------------------------------------------------------------------------- */
#ifdef VGA_REG_IO
static inline u8 vga_inb(struct tdfx_par *par, u32 reg) { return inb(reg); }
static inline u8 vga_inb(struct tdfx_par *par, u32 reg)
{
return inb(reg);
}
static inline void vga_outb(struct tdfx_par *par, u32 reg, u8 val) { outb(val, reg); }
static inline void vga_outb(struct tdfx_par *par, u32 reg, u8 val)
{
outb(val, reg);
}
#else
static inline u8 vga_inb(struct tdfx_par *par, u32 reg) {
static inline u8 vga_inb(struct tdfx_par *par, u32 reg)
{
return inb(par->iobase + reg - 0x300);
}
static inline void vga_outb(struct tdfx_par *par, u32 reg, u8 val) {
static inline void vga_outb(struct tdfx_par *par, u32 reg, u8 val)
{
outb(val, par->iobase + reg - 0x300);
}
#endif
static inline void gra_outb(struct tdfx_par *par, u32 idx, u8 val) {
vga_outb(par, GRA_I, idx); vga_outb(par, GRA_D, val);
static inline void gra_outb(struct tdfx_par *par, u32 idx, u8 val)
{
vga_outb(par, GRA_I, idx);
vga_outb(par, GRA_D, val);
}
static inline void seq_outb(struct tdfx_par *par, u32 idx, u8 val) {
vga_outb(par, SEQ_I, idx); vga_outb(par, SEQ_D, val);
static inline void seq_outb(struct tdfx_par *par, u32 idx, u8 val)
{
vga_outb(par, SEQ_I, idx);
vga_outb(par, SEQ_D, val);
}
static inline u8 seq_inb(struct tdfx_par *par, u32 idx) {
vga_outb(par, SEQ_I, idx); return vga_inb(par, SEQ_D);
static inline u8 seq_inb(struct tdfx_par *par, u32 idx)
{
vga_outb(par, SEQ_I, idx);
return vga_inb(par, SEQ_D);
}
static inline void crt_outb(struct tdfx_par *par, u32 idx, u8 val) {
vga_outb(par, CRT_I, idx); vga_outb(par, CRT_D, val);
static inline void crt_outb(struct tdfx_par *par, u32 idx, u8 val)
{
vga_outb(par, CRT_I, idx);
vga_outb(par, CRT_D, val);
}
static inline u8 crt_inb(struct tdfx_par *par, u32 idx) {
vga_outb(par, CRT_I, idx); return vga_inb(par, CRT_D);
static inline u8 crt_inb(struct tdfx_par *par, u32 idx)
{
vga_outb(par, CRT_I, idx);
return vga_inb(par, CRT_D);
}
static inline void att_outb(struct tdfx_par *par, u32 idx, u8 val)
@ -297,7 +273,8 @@ static int banshee_wait_idle(struct fb_info *info)
while (1) {
i = (tdfx_inl(par, STATUS) & STATUS_BUSY) ? 0 : i + 1;
if(i == 3) break;
if (i == 3)
break;
}
return 0;
}
@ -444,8 +421,9 @@ static unsigned long do_lfb_size(struct tdfx_par *par, unsigned short dev_id)
if (dev_id < PCI_DEVICE_ID_3DFX_VOODOO5) {
/* Banshee/Voodoo3 */
has_sgram = draminit1 & DRAMINIT1_MEM_SDRAM;
chip_size = has_sgram ? ((draminit0 & DRAMINIT0_SGRAM_TYPE) ? 2 : 1)
: 2;
chip_size = 2;
if (has_sgram)
chip_size = (draminit0 & DRAMINIT0_SGRAM_TYPE) ? 2 : 1;
} else {
/* Voodoo4/5 */
has_sgram = 0;
@ -512,13 +490,15 @@ static int tdfxfb_check_var(struct fb_var_screeninfo *var,struct fb_info *info)
var->yres_virtual = info->fix.smem_len / lpitch;
if (var->yres_virtual < var->yres) {
DPRINTK("no memory for screen (%ux%ux%u)\n",
var->xres, var->yres_virtual, var->bits_per_pixel);
var->xres, var->yres_virtual,
var->bits_per_pixel);
return -EINVAL;
}
}
if (PICOS2KHZ(var->pixclock) > par->max_pixclock) {
DPRINTK("pixclock too high (%ldKHz)\n",PICOS2KHZ(var->pixclock));
DPRINTK("pixclock too high (%ldKHz)\n",
PICOS2KHZ(var->pixclock));
return -EINVAL;
}
@ -534,12 +514,8 @@ static int tdfxfb_check_var(struct fb_var_screeninfo *var,struct fb_info *info)
var->blue.offset = 0;
var->blue.length = 5;
break;
case 24:
var->red.offset=16;
var->green.offset=8;
var->blue.offset=0;
var->red.length = var->green.length = var->blue.length = 8;
case 32:
case 24:
var->red.offset=16;
var->green.offset=8;
var->blue.offset=0;
@ -550,7 +526,8 @@ static int tdfxfb_check_var(struct fb_var_screeninfo *var,struct fb_info *info)
var->accel_flags = FB_ACCELF_TEXT;
DPRINTK("Checking graphics mode at %dx%d depth %d\n", var->xres, var->yres, var->bits_per_pixel);
DPRINTK("Checking graphics mode at %dx%d depth %d\n",
var->xres, var->yres, var->bits_per_pixel);
return 0;
}
@ -569,7 +546,10 @@ static int tdfxfb_set_par(struct fb_info *info)
memset(&reg, 0, sizeof(reg));
cpp = (info->var.bits_per_pixel + 7) / 8;
reg.vidcfg = VIDCFG_VIDPROC_ENABLE | VIDCFG_DESK_ENABLE | VIDCFG_CURS_X11 | ((cpp - 1) << VIDCFG_PIXFMT_SHIFT) | (cpp != 1 ? VIDCFG_CLUT_BYPASS : 0);
reg.vidcfg = VIDCFG_VIDPROC_ENABLE | VIDCFG_DESK_ENABLE |
VIDCFG_CURS_X11 |
((cpp - 1) << VIDCFG_PIXFMT_SHIFT) |
(cpp != 1 ? VIDCFG_CLUT_BYPASS : 0);
/* PLL settings */
freq = PICOS2KHZ(info->var.pixclock);
@ -764,11 +744,13 @@ static int tdfxfb_set_par(struct fb_info *info)
do_write_regs(info, &reg);
/* Now change fb_fix_screeninfo according to changes in par */
info->fix.line_length = info->var.xres * ((info->var.bits_per_pixel + 7)>>3);
info->fix.line_length =
info->var.xres * ((info->var.bits_per_pixel + 7) >> 3);
info->fix.visual = (info->var.bits_per_pixel == 8)
? FB_VISUAL_PSEUDOCOLOR
: FB_VISUAL_TRUECOLOR;
DPRINTK("Graphics mode is now set at %dx%d depth %d\n", info->var.xres, info->var.yres, info->var.bits_per_pixel);
DPRINTK("Graphics mode is now set at %dx%d depth %d\n",
info->var.xres, info->var.yres, info->var.bits_per_pixel);
return 0;
}
@ -776,12 +758,14 @@ static int tdfxfb_set_par(struct fb_info *info)
#define CNVT_TOHW(val, width) ((((val)<<(width))+0x7FFF-(val))>>16)
static int tdfxfb_setcolreg(unsigned regno, unsigned red, unsigned green,
unsigned blue,unsigned transp,struct fb_info *info)
unsigned blue, unsigned transp,
struct fb_info *info)
{
struct tdfx_par *par = info->par;
u32 rgbcol;
if (regno >= info->cmap.len || regno > 255) return 1;
if (regno >= info->cmap.len || regno > 255)
return 1;
switch (info->fix.visual) {
case FB_VISUAL_PSEUDOCOLOR:
@ -882,7 +866,8 @@ static int tdfxfb_pan_display(struct fb_var_screeninfo *var,
/*
* FillRect 2D command (solidfill or invert (via ROP_XOR))
*/
static void tdfxfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
static void tdfxfb_fillrect(struct fb_info *info,
const struct fb_fillrect *rect)
{
struct tdfx_par *par = info->par;
u32 bpp = info->var.bits_per_pixel;
@ -910,7 +895,8 @@ static void tdfxfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect
/*
* Screen-to-Screen BitBlt 2D command (for the bmove fb op.)
*/
static void tdfxfb_copyarea(struct fb_info *info, const struct fb_copyarea *area)
static void tdfxfb_copyarea(struct fb_info *info,
const struct fb_copyarea *area)
{
struct tdfx_par *par = info->par;
u32 sx = area->sx, sy = area->sy, dx = area->dx, dy = area->dy;
@ -1004,10 +990,18 @@ static void tdfxfb_imageblit(struct fb_info *info, const struct fb_image *image)
banshee_make_room(par, 3);
i = size % 4;
switch (i) {
case 0: break;
case 1: tdfx_outl(par, LAUNCH_2D,*chardata); break;
case 2: tdfx_outl(par, LAUNCH_2D,*(u16*)chardata); break;
case 3: tdfx_outl(par, LAUNCH_2D,*(u16*)chardata | ((chardata[3]) << 24)); break;
case 0:
break;
case 1:
tdfx_outl(par, LAUNCH_2D, *chardata);
break;
case 2:
tdfx_outl(par, LAUNCH_2D, *(u16*)chardata);
break;
case 3:
tdfx_outl(par, LAUNCH_2D,
*(u16*)chardata | ((chardata[3]) << 24));
break;
}
}
#endif /* CONFIG_FB_3DFX_ACCEL */
@ -1023,7 +1017,8 @@ static int tdfxfb_cursor(struct fb_info *info, struct fb_cursor *cursor)
* current cursor state (if enable is set) or we want to query what
* we can do with the cursor (if enable is not set)
*/
if (!cursor->set) return 0;
if (!cursor->set)
return 0;
/* Too large of a cursor :-( */
if (cursor->image.width > 64 || cursor->image.height > 64)
@ -1151,6 +1146,25 @@ static int tdfxfb_cursor(struct fb_info *info, struct fb_cursor *cursor)
}
#endif
static struct fb_ops tdfxfb_ops = {
.owner = THIS_MODULE,
.fb_check_var = tdfxfb_check_var,
.fb_set_par = tdfxfb_set_par,
.fb_setcolreg = tdfxfb_setcolreg,
.fb_blank = tdfxfb_blank,
.fb_pan_display = tdfxfb_pan_display,
.fb_sync = banshee_wait_idle,
#ifdef CONFIG_FB_3DFX_ACCEL
.fb_fillrect = tdfxfb_fillrect,
.fb_copyarea = tdfxfb_copyarea,
.fb_imageblit = tdfxfb_imageblit,
#else
.fb_fillrect = cfb_fillrect,
.fb_copyarea = cfb_copyarea,
.fb_imageblit = cfb_imageblit,
#endif
};
/**
* tdfxfb_probe - Device Initializiation
*
@ -1197,7 +1211,8 @@ static int __devinit tdfxfb_probe(struct pci_dev *pdev,
tdfx_fix.mmio_start = pci_resource_start(pdev, 0);
tdfx_fix.mmio_len = pci_resource_len(pdev, 0);
default_par->regbase_virt = ioremap_nocache(tdfx_fix.mmio_start, tdfx_fix.mmio_len);
default_par->regbase_virt =
ioremap_nocache(tdfx_fix.mmio_start, tdfx_fix.mmio_len);
if (!default_par->regbase_virt) {
printk("fb: Can't remap %s register area.\n", tdfx_fix.id);
goto out_err;

View File

@ -82,15 +82,15 @@
#define BIT(x) (1UL << (x))
/* COMMAND_2D reg. values */
#define TDFX_ROP_COPY 0xcc // src
#define TDFX_ROP_INVERT 0x55 // NOT dst
#define TDFX_ROP_XOR 0x66 // src XOR dst
#define TDFX_ROP_COPY 0xcc /* src */
#define TDFX_ROP_INVERT 0x55 /* NOT dst */
#define TDFX_ROP_XOR 0x66 /* src XOR dst */
#define AUTOINC_DSTX BIT(10)
#define AUTOINC_DSTY BIT(11)
#define COMMAND_2D_FILLRECT 0x05
#define COMMAND_2D_S2S_BITBLT 0x01 // screen to screen
#define COMMAND_2D_H2S_BITBLT 0x03 // host to screen
#define COMMAND_2D_S2S_BITBLT 0x01 /* screen to screen */
#define COMMAND_2D_H2S_BITBLT 0x03 /* host to screen */
#define COMMAND_3D_NOP 0x00
#define STATUS_RETRACE BIT(6)