Commit 7304ada2 authored by Linus Torvalds's avatar Linus Torvalds

Merge http://fbdev.bkbits.net:8080/fbdev-2.5

into home.transmeta.com:/home/torvalds/v2.5/linux
parents cdac1baf 1ecd8afb
Tridentfb is a framebuffer driver for some Trident chip based cards.
The following list of chips is thought to be supported although not all are
tested:
those from the Image series with Cyber in their names - accelerated
those with Blade in their names (Blade3D,CyberBlade...) - accelerated
the newer CyberBladeXP family - nonaccelerated
Only PCI/AGP based cards are supported, none of the older Tridents.
How to use it?
==============
Just do your usual console work :)
When booting you can pass the following parameters
==================================================
noaccel - turns off acceleration (when it doesn't work for your card)
accel - force text acceleration (for boards which by default are noacceled)
fp - use flat panel related stuff
crt - assume monitor is present instead of fp
center - for flat panels and resolutions smaller than native size center the
image, otherwise use
stretch
memsize - integer value in Kb, use if your card's memory size is misdetected.
look at the driver output to see what it says when initializing.
memdiff - integer value in Kb,should be nonzero if your card reports
more memory than it actually has.For instance mine is 192K less than
detection says in all three BIOS selectable situations 2M, 4M, 8M.
Only use if your video memory is taken from main memory hence of
configurable size.Otherwise use memsize.
If in some modes which barely fit the memory you see garbage at the bottom
this might help by not letting change to that mode anymore.
nativex - the width in pixels of the flat panel.If you know it (usually 1024
800 or 1280) and it is not what the driver seems to detect use it.
bpp - bits per pixel (8,16 or 32)
mode - a mode name like 800x600 (as described in Documentation/fb/modedb.txt)
Using insane values for the above parameters will probably result in driver
misbehaviour so take care(for instance memsize=12345678 or memdiff=23784 or
nativex=93)
Contact: jani@astechnix.ro
......@@ -10,9 +10,6 @@ bool 'Support for frame buffer devices (EXPERIMENTAL)' CONFIG_FB
if [ "$CONFIG_FB" = "y" ]; then
define_bool CONFIG_DUMMY_CONSOLE y
if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
if [ "$CONFIG_PCI" = "y" ]; then
tristate ' nVidia Riva support (EXPERIMENTAL)' CONFIG_FB_RIVA
fi
if [ "$CONFIG_AMIGA" = "y" -o "$CONFIG_PCI" = "y" ]; then
tristate ' Cirrus Logic support (EXPERIMENTAL)' CONFIG_FB_CLGEN
tristate ' Permedia2 support (EXPERIMENTAL)' CONFIG_FB_PM2
......@@ -127,6 +124,7 @@ if [ "$CONFIG_FB" = "y" ]; then
fi
if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
if [ "$CONFIG_PCI" != "n" ]; then
tristate ' nVidia Riva support (EXPERIMENTAL)' CONFIG_FB_RIVA
tristate ' Matrox acceleration (EXPERIMENTAL)' CONFIG_FB_MATROX
if [ "$CONFIG_FB_MATROX" != "n" ]; then
bool ' Millennium I/II support' CONFIG_FB_MATROX_MILLENIUM
......@@ -156,6 +154,8 @@ if [ "$CONFIG_FB" = "y" ]; then
tristate ' NeoMagic display support (EXPERIMENTAL)' CONFIG_FB_NEOMAGIC
tristate ' 3Dfx Banshee/Voodoo3 display support (EXPERIMENTAL)' CONFIG_FB_3DFX
tristate ' 3Dfx Voodoo Graphics (sst1) support (EXPERIMENTAL)' CONFIG_FB_VOODOO1
tristate ' Trident support (EXPERIMENTAL)' CONFIG_FB_TRIDENT
tristate ' Permedia3 support (EXPERIMENTAL)' CONFIG_FB_PM3
fi
fi
if [ "$ARCH" = "sparc" -o "$ARCH" = "sparc64" ]; then
......@@ -220,6 +220,7 @@ if [ "$CONFIG_FB" = "y" ]; then
tristate ' 16 bpp packed pixels support' CONFIG_FBCON_CFB16
tristate ' 24 bpp packed pixels support' CONFIG_FBCON_CFB24
tristate ' 32 bpp packed pixels support' CONFIG_FBCON_CFB32
tristate ' Hardware acceleration support' CONFIG_FBCON_ACCEL
tristate ' Amiga bitplanes support' CONFIG_FBCON_AFB
tristate ' Amiga interleaved bitplanes support' CONFIG_FBCON_ILBM
tristate ' Atari interleaved bitplanes (2 planes) support' CONFIG_FBCON_IPLAN2P2
......@@ -235,29 +236,25 @@ if [ "$CONFIG_FB" = "y" ]; then
if [ "$CONFIG_FB_ACORN" = "y" -o "$CONFIG_FB_AMIGA" = "y" -o \
"$CONFIG_FB_ATARI" = "y" -o "$CONFIG_FB_CYBER" = "y" -o \
"$CONFIG_FB_MAC" = "y" -o "$CONFIG_FB_RETINAZ3" = "y" -o \
"$CONFIG_FB_VIRGE" = "y" -o "$CONFIG_FB_VIRTUAL" = "y" -o \
"$CONFIG_FB_BWTWO" = "y" -o "$CONFIG_FB_CLGEN" = "y" -o \
"$CONFIG_FB_TX3912" = "y" ]; then
"$CONFIG_FB_VIRGE" = "y" -o "$CONFIG_FB_TX3912" = "y" -o \
"$CONFIG_FB_BWTWO" = "y" -o "$CONFIG_FB_CLGEN" = "y" ]; then
define_tristate CONFIG_FBCON_MFB y
else
if [ "$CONFIG_FB_ACORN" = "m" -o "$CONFIG_FB_AMIGA" = "m" -o \
"$CONFIG_FB_ATARI" = "m" -o "$CONFIG_FB_CYBER" = "m" -o \
"$CONFIG_FB_MAC" = "m" -o "$CONFIG_FB_RETINAZ3" = "m" -o \
"$CONFIG_FB_VIRGE" = "m" -o "$CONFIG_FB_VIRTUAL" = "m" -o \
"$CONFIG_FB_BWTWO" = "m" -o "$CONFIG_FB_CLGEN" = "m" -o \
"$CONFIG_FB_TX3912" = "m" ]; then
"$CONFIG_FB_VIRGE" = "m" -o "$CONFIG_FB_TX3912" = "m" -o \
"$CONFIG_FB_BWTWO" = "m" -o "$CONFIG_FB_CLGEN" = "m" ]; then
define_tristate CONFIG_FBCON_MFB m
fi
fi
if [ "$CONFIG_FB_ACORN" = "y" -o "$CONFIG_FB_MAC" = "y" -o \
"$CONFIG_FB_SA1100" = "y" -o "$CONFIG_FB_VIRTUAL" = "y" -o \
"$CONFIG_FB_TX3912" = "y" ]; then
"$CONFIG_FB_SA1100" = "y" -o "$CONFIG_FB_TX3912" = "y" ]; then
define_tristate CONFIG_FBCON_CFB2 y
define_tristate CONFIG_FBCON_CFB4 y
else
if [ "$CONFIG_FB_ACORN" = "m" -o "$CONFIG_FB_MAC" = "m" -o \
"$CONFIG_FB_SA1100" = "m" -o "$CONFIG_FB_VIRTUAL" = "m" -o \
"$CONFIG_FB_TX3912" = "m" ]; then
"$CONFIG_FB_SA1100" = "m" -o "$CONFIG_FB_TX3912" = "m" ]; then
define_tristate CONFIG_FBCON_CFB2 m
define_tristate CONFIG_FBCON_CFB4 m
fi
......@@ -265,10 +262,10 @@ if [ "$CONFIG_FB" = "y" ]; then
if [ "$CONFIG_FB_ACORN" = "y" -o "$CONFIG_FB_ATARI" = "y" -o \
"$CONFIG_FB_ATY" = "y" -o "$CONFIG_FB_MAC" = "y" -o \
"$CONFIG_FB_OF" = "y" -o "$CONFIG_FB_TGA" = "y" -o \
"$CONFIG_FB_VESA" = "y" -o "$CONFIG_FB_VIRTUAL" = "y" -o \
"$CONFIG_FB_NEOMAGIC" = "y" -o "$CONFIG_FB_PM3" = "y" -o \
"$CONFIG_FB_TCX" = "y" -o "$CONFIG_FB_CGTHREE" = "y" -o \
"$CONFIG_FB_CONTROL" = "y" -o "$CONFIG_FB_CLGEN" = "y" -o \
"$CONFIG_FB_CGFOURTEEN" = "y" -o "$CONFIG_FB_G364" = "y" -o \
"$CONFIG_FB_CGFOURTEEN" = "y" -o "$CONFIG_FB_TRIDENT" = "y" -o \
"$CONFIG_FB_VIRGE" = "y" -o "$CONFIG_FB_CYBER" = "y" -o \
"$CONFIG_FB_VALKYRIE" = "y" -o "$CONFIG_FB_PLATINUM" = "y" -o \
"$CONFIG_FB_IGA" = "y" -o "$CONFIG_FB_MATROX" = "y" -o \
......@@ -276,53 +273,50 @@ if [ "$CONFIG_FB" = "y" ]; then
"$CONFIG_FB_P9100" = "y" -o "$CONFIG_FB_ATY128" = "y" -o \
"$CONFIG_FB_RIVA" = "y" -o "$CONFIG_FB_RADEON" = "y" -o \
"$CONFIG_FB_SGIVW" = "y" -o "$CONFIG_FB_CYBER2000" = "y" -o \
"$CONFIG_FB_SA1100" = "y" -o "$CONFIG_FB_3DFX" = "y" -o \
"$CONFIG_FB_SA1100" = "y" -o "$CONFIG_FB_SIS" = "y" -o \
"$CONFIG_FB_PMAG_BA" = "y" -o "$CONFIG_FB_PMAGB_B" = "y" -o \
"$CONFIG_FB_MAXINE" = "y" -o "$CONFIG_FB_TX3912" = "y" -o \
"$CONFIG_FB_SIS" = "y" -o "$CONFIG_FB_NEOMAGIC" = "y" ]; then
"$CONFIG_FB_MAXINE" = "y" -o "$CONFIG_FB_TX3912" = "y" ]; then
define_tristate CONFIG_FBCON_CFB8 y
else
if [ "$CONFIG_FB_ACORN" = "m" -o "$CONFIG_FB_ATARI" = "m" -o \
"$CONFIG_FB_ATY" = "m" -o "$CONFIG_FB_MAC" = "m" -o \
"$CONFIG_FB_OF" = "m" -o "$CONFIG_FB_TGA" = "m" -o \
"$CONFIG_FB_VESA" = "m" -o "$CONFIG_FB_VIRTUAL" = "m" -o \
"$CONFIG_FB_NEOMAGIC" = "m" -o "$CONFIG_FB_PM3" = "m" -o \
"$CONFIG_FB_TCX" = "m" -o "$CONFIG_FB_CGTHREE" = "m" -o \
"$CONFIG_FB_CONTROL" = "m" -o "$CONFIG_FB_CLGEN" = "m" -o \
"$CONFIG_FB_CGFOURTEEN" = "m" -o "$CONFIG_FB_G364" = "m" -o \
"$CONFIG_FB_CGFOURTEEN" = "m" -o "$CONFIG_FB_TRIDENT" = "m" -o \
"$CONFIG_FB_VIRGE" = "m" -o "$CONFIG_FB_CYBER" = "m" -o \
"$CONFIG_FB_VALKYRIE" = "m" -o "$CONFIG_FB_PLATINUM" = "m" -o \
"$CONFIG_FB_IGA" = "m" -o "$CONFIG_FB_MATROX" = "m" -o \
"$CONFIG_FB_CT65550" = "m" -o "$CONFIG_FB_PM2" = "m" -o \
"$CONFIG_FB_P9100" = "m" -o "$CONFIG_FB_ATY128" = "m" -o \
"$CONFIG_FB_RIVA" = "m" -o "$CONFIG_FB_3DFX" = "m" -o \
"$CONFIG_FB_RIVA" = "m" -o "$CONFIG_FB_TX3912" = "m" -o \
"$CONFIG_FB_SGIVW" = "m" -o "$CONFIG_FB_CYBER2000" = "m" -o \
"$CONFIG_FB_PMAG_BA" = "m" -o "$CONFIG_FB_PMAGB_B" = "m" -o \
"$CONFIG_FB_MAXINE" = "m" -o "$CONFIG_FB_RADEON" = "m" -o \
"$CONFIG_FB_SA1100" = "m" -o "$CONFIG_FB_SIS" = "m" -o \
"$CONFIG_FB_TX3912" = "m" -o "$CONFIG_FB_NEOMAGIC" = "m" ]; then
"$CONFIG_FB_SA1100" = "m" -o "$CONFIG_FB_SIS" = "m" ]; then
define_tristate CONFIG_FBCON_CFB8 m
fi
fi
if [ "$CONFIG_FB_ATARI" = "y" -o "$CONFIG_FB_ATY" = "y" -o \
"$CONFIG_FB_MAC" = "y" -o "$CONFIG_FB_VESA" = "y" -o \
"$CONFIG_FB_VIRTUAL" = "y" -o "$CONFIG_FB_TBOX" = "y" -o \
"$CONFIG_FB_Q40" = "y" -o "$CONFIG_FB_RADEON" = "y" -o \
"$CONFIG_FB_MAC" = "y" -o "$CONFIG_FB_NEOMAGIC" = "y" -o \
"$CONFIG_FB_TRIDENT" = "y" -o "$CONFIG_FB_TBOX" = "y" -o \
"$CONFIG_FB_VOODOO1" = "y" -o "$CONFIG_FB_RADEON" = "y" -o \
"$CONFIG_FB_CONTROL" = "y" -o "$CONFIG_FB_CLGEN" = "y" -o \
"$CONFIG_FB_VIRGE" = "y" -o "$CONFIG_FB_CYBER" = "y" -o \
"$CONFIG_FB_VALKYRIE" = "y" -o "$CONFIG_FB_PLATINUM" = "y" -o \
"$CONFIG_FB_CT65550" = "y" -o "$CONFIG_FB_MATROX" = "y" -o \
"$CONFIG_FB_PM2" = "y" -o "$CONFIG_FB_SGIVW" = "y" -o \
"$CONFIG_FB_RIVA" = "y" -o "$CONFIG_FB_ATY128" = "y" -o \
"$CONFIG_FB_CYBER2000" = "y" -o "$CONFIG_FB_3DFX" = "y" -o \
"$CONFIG_FB_CYBER2000" = "y" -o "$CONFIG_FB_PM3" = "y" -o \
"$CONFIG_FB_SIS" = "y" -o "$CONFIG_FB_SA1100" = "y" -o \
"$CONFIG_FB_PVR2" = "y" -o "$CONFIG_FB_VOODOO1" = "y" -o \
"$CONFIG_FB_NEOMAGIC" = "y" ]; then
"$CONFIG_FB_PVR2" = "y" ]; then
define_tristate CONFIG_FBCON_CFB16 y
else
if [ "$CONFIG_FB_ATARI" = "m" -o "$CONFIG_FB_ATY" = "m" -o \
"$CONFIG_FB_MAC" = "m" -o "$CONFIG_FB_VESA" = "m" -o \
"$CONFIG_FB_VIRTUAL" = "m" -o "$CONFIG_FB_TBOX" = "m" -o \
"$CONFIG_FB_Q40" = "m" -o "$CONFIG_FB_3DFX" = "m" -o \
"$CONFIG_FB_MAC" = "m" -o "$CONFIG_FB_NEOMAGIC" = "m" -o \
"$CONFIG_FB_TRIDENT" = "m" -o "$CONFIG_FB_TBOX" = "m" -o \
"$CONFIG_FB_VOODOO1" = "m" -o "$CONFIG_FB_PM3" = "m" -o \
"$CONFIG_FB_CONTROL" = "m" -o "$CONFIG_FB_CLGEN" = "m" -o \
"$CONFIG_FB_VIRGE" = "m" -o "$CONFIG_FB_CYBER" = "m" -o \
"$CONFIG_FB_VALKYRIE" = "m" -o "$CONFIG_FB_PLATINUM" = "m" -o \
......@@ -331,8 +325,7 @@ if [ "$CONFIG_FB" = "y" ]; then
"$CONFIG_FB_RIVA" = "m" -o "$CONFIG_FB_ATY128" = "m" -o \
"$CONFIG_FB_CYBER2000" = "m" -o "$CONFIG_FB_SIS" = "m" -o \
"$CONFIG_FB_SA1100" = "m" -o "$CONFIG_FB_RADEON" = "m" -o \
"$CONFIG_FB_PVR2" = "m" -o "$CONFIG_FB_VOODOO1" = "m" -o \
"$CONFIG_FB_NEOMAGIC" = "m" ]; then
"$CONFIG_FB_PVR2" = "m" ]; then
define_tristate CONFIG_FBCON_CFB16 m
fi
fi
......@@ -354,29 +347,42 @@ if [ "$CONFIG_FB" = "y" ]; then
fi
fi
if [ "$CONFIG_FB_ATARI" = "y" -o "$CONFIG_FB_ATY" = "y" -o \
"$CONFIG_FB_VESA" = "y" -o "$CONFIG_FB_VIRTUAL" = "y" -o \
"$CONFIG_FB_VOODOO1" = "y" -o "$CONFIG_FB_TRIDENT" = "y" -o \
"$CONFIG_FB_CONTROL" = "y" -o "$CONFIG_FB_CLGEN" = "y" -o \
"$CONFIG_FB_TGA" = "y" -o "$CONFIG_FB_PLATINUM" = "y" -o \
"$CONFIG_FB_MATROX" = "y" -o "$CONFIG_FB_PM2" = "y" -o \
"$CONFIG_FB_RIVA" = "y" -o "$CONFIG_FB_ATY128" = "y" -o \
"$CONFIG_FB_FM2" = "y" -o "$CONFIG_FB_SGIVW" = "y" -o \
"$CONFIG_FB_SIS" = "y" -o "$CONFIG_FB_SGIVW" = "y" -o \
"$CONFIG_FB_RADEON" = "y" -o "$CONFIG_FB_PVR2" = "y" -o \
"$CONFIG_FB_3DFX" = "y" -o "$CONFIG_FB_SIS" = "y" -o \
"$CONFIG_FB_VOODOO1" = "y" ]; then
"$CONFIG_FB_PM3" = "y" ]; then
define_tristate CONFIG_FBCON_CFB32 y
else
if [ "$CONFIG_FB_ATARI" = "m" -o "$CONFIG_FB_ATY" = "m" -o \
"$CONFIG_FB_VESA" = "m" -o "$CONFIG_FB_VIRTUAL" = "m" -o \
"$CONFIG_FB_VOODOO1" = "m" -o "$CONFIG_FB_TRIDENT" = "m" -o \
"$CONFIG_FB_CONTROL" = "m" -o "$CONFIG_FB_CLGEN" = "m" -o \
"$CONFIG_FB_TGA" = "m" -o "$CONFIG_FB_PLATINUM" = "m" -o \
"$CONFIG_FB_MATROX" = "m" -o "$CONFIG_FB_PM2" = "m" -o \
"$CONFIG_FB_RIVA" = "m" -o "$CONFIG_FB_ATY128" = "m" -o \
"$CONFIG_FB_3DFX" = "m" -o "$CONFIG_FB_RADEON" = "m" -o \
"$CONFIG_FB_PM3" = "m" -o "$CONFIG_FB_RADEON" = "m" -o \
"$CONFIG_FB_SGIVW" = "m" -o "$CONFIG_FB_SIS" = "m" -o \
"$CONFIG_FB_PVR2" = "m" -o "$CONFIG_FB_VOODOO1" = "m" ]; then
"$CONFIG_FB_PVR2" = "m" ]; then
define_tristate CONFIG_FBCON_CFB32 m
fi
fi
if [ "$CONFIG_FB_NEOMAGIC" = "y" -o "$CONFIG_FB_VESA" = "y" -o \
"$CONFIG_FB_FM2" = "y" -o "$CONFIG_FB_HIT" = "y" -o \
"$CONFIG_FB_HP300" = "y" -o "$CONFIG_FB_Q40" = "y" -o \
"$CONFIG_FB_ANAKIN" = "y" -o "$CONFIG_FB_G364" = "y" -o \
"$CONFIG_FB_VIRTUAL" = "y" -o "$CONFIG_FB_CLPS711X" = "y" -o \
"$CONFIG_FB_3DFX" = "y" ]; then
define_tristate CONFIG_FBCON_ACCEL y
else
if [ "$CONFIG_FB_NEOMAGIC" = "m" -o "$CONFIG_FB_HIT" = "m" -o \
"$CONFIG_FB_G364" = "m" -o "$CONFIG_FB_VIRTUAL" = "m" -o \
"$CONFIG_FB_CLPS711X" = "m" -o "$CONFIG_FB_3DFX" = "m" ]; then
define_tristate CONFIG_FBCON_ACCEL m
fi
fi
if [ "$CONFIG_FB_AMIGA" = "y" ]; then
define_tristate CONFIG_FBCON_AFB y
define_tristate CONFIG_FBCON_ILBM y
......@@ -399,10 +405,10 @@ if [ "$CONFIG_FB" = "y" ]; then
# define_tristate CONFIG_FBCON_IPLAN2P16 m
fi
fi
if [ "$CONFIG_FB_MAC" = "y" -o "$CONFIG_FB_VIRTUAL" = "y" ]; then
if [ "$CONFIG_FB_MAC" = "y" ]; then
define_tristate CONFIG_FBCON_MAC y
else
if [ "$CONFIG_FB_MAC" = "m" -o "$CONFIG_FB_VIRTUAL" = "m" ]; then
if [ "$CONFIG_FB_MAC" = "m" ]; then
define_tristate CONFIG_FBCON_MAC m
fi
fi
......
......@@ -44,8 +44,9 @@ endif
obj-$(CONFIG_FB_ACORN) += acornfb.o
obj-$(CONFIG_FB_AMIGA) += amifb.o
obj-$(CONFIG_FB_PM2) += pm2fb.o
obj-$(CONFIG_FB_PM3) += pm3fb.o
obj-$(CONFIG_FB_APOLLO) += dnfb.o
obj-$(CONFIG_FB_Q40) += q40fb.o
obj-$(CONFIG_FB_Q40) += q40fb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
obj-$(CONFIG_FB_ATARI) += atafb.o
obj-$(CONFIG_FB_ATY128) += aty128fb.o
obj-$(CONFIG_FB_RADEON) += radeonfb.o
......@@ -56,24 +57,25 @@ obj-$(CONFIG_FB_PLATINUM) += platinumfb.o
obj-$(CONFIG_FB_VALKYRIE) += valkyriefb.o
obj-$(CONFIG_FB_CT65550) += chipsfb.o
obj-$(CONFIG_FB_ANAKIN) += anakinfb.o
obj-$(CONFIG_FB_CLPS711X) += clps711xfb.o
obj-$(CONFIG_FB_CLPS711X) += clps711xfb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
obj-$(CONFIG_FB_CYBER) += cyberfb.o
obj-$(CONFIG_FB_CYBER2000) += cyber2000fb.o
obj-$(CONFIG_FB_SGIVW) += sgivwfb.o
obj-$(CONFIG_FB_3DFX) += tdfxfb.o
obj-$(CONFIG_FB_MAC) += macfb.o macmodes.o
obj-$(CONFIG_FB_HP300) += hpfb.o
obj-$(CONFIG_FB_HP300) += hpfb.o cfbfillrect.o cfbimgblt.o
obj-$(CONFIG_FB_OF) += offb.o
obj-$(CONFIG_FB_IMSTT) += imsttfb.o
obj-$(CONFIG_FB_RETINAZ3) += retz3fb.o
obj-$(CONFIG_FB_CLGEN) += clgenfb.o
obj-$(CONFIG_FB_TRIDENT) += tridentfb.o
obj-$(CONFIG_FB_S3TRIO) += S3triofb.o
obj-$(CONFIG_FB_TGA) += tgafb.o
obj-$(CONFIG_FB_VESA) += vesafb.o
obj-$(CONFIG_FB_VESA) += vesafb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
obj-$(CONFIG_FB_VGA16) += vga16fb.o fbcon-vga-planes.o
obj-$(CONFIG_FB_VIRGE) += virgefb.o
obj-$(CONFIG_FB_G364) += g364fb.o
obj-$(CONFIG_FB_FM2) += fm2fb.o
obj-$(CONFIG_FB_G364) += g364fb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
obj-$(CONFIG_FB_FM2) += fm2fb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
obj-$(CONFIG_FB_CREATOR) += creatorfb.o sbusfb.o
obj-$(CONFIG_FB_CGSIX) += cgsixfb.o sbusfb.o
obj-$(CONFIG_FB_BWTWO) += bwtwofb.o sbusfb.o
......@@ -97,8 +99,8 @@ obj-$(CONFIG_FB_SUN3) += sun3fb.o
obj-$(CONFIG_FB_BWTWO) += bwtwofb.o
obj-$(CONFIG_FB_HGA) += hgafb.o
obj-$(CONFIG_FB_SA1100) += sa1100fb.o
obj-$(CONFIG_FB_VIRTUAL) += vfb.o
obj-$(CONFIG_FB_HIT) += hitfb.o
obj-$(CONFIG_FB_VIRTUAL) += vfb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
obj-$(CONFIG_FB_HIT) += hitfb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
obj-$(CONFIG_FB_E1355) += epson1355fb.o
obj-$(CONFIG_FB_PVR2) += pvr2fb.o
obj-$(CONFIG_FB_VOODOO1) += sstfb.o
......@@ -122,6 +124,7 @@ obj-$(CONFIG_FBCON_MFB) += fbcon-mfb.o
obj-$(CONFIG_FBCON_VGA) += fbcon-vga.o
obj-$(CONFIG_FBCON_HGA) += fbcon-hga.o
obj-$(CONFIG_FBCON_STI) += fbcon-sti.o
obj-$(CONFIG_FBCON_ACCEL) += fbcon-accel.o
include $(TOPDIR)/Rules.make
......
......@@ -23,23 +23,34 @@
#include <video/fbcon.h>
#include <video/fbcon-cfb16.h>
static u16 colreg[16];
static u32 colreg[16];
static struct fb_info fb_info;
static struct display display;
static int
anakinfb_getcolreg(u_int regno, u_int *red, u_int *green, u_int *blue,
u_int *transp, struct fb_info *info)
{
if (regno > 15)
return 1;
static struct fb_var_screeninfo anakinfb_var = {
xres: 400,
yres: 234,
xres_virtual: 400,
yres_virtual: 234,
bits_per_pixel: 16,
red: { 11, 5, 0 },
green: { 5, 6, 0 },
blue: { 0, 5, 0 },
activate: FB_ACTIVATE_NOW,
height: -1,
width: -1,
vmode: FB_VMODE_NONINTERLACED,
};
*red = colreg[regno] & 0xf800;
*green = colreg[regno] & 0x7e0 << 5;
*blue = colreg[regno] & 0x1f << 11;
*transp = 0;
return 0;
}
static struct fb_fix_screeninfo anakinfb_fix = {
id: "AnakinFB",
smem_start: VGA_START,
smem_len: VGA_SIZE,
type: FB_TYPE_PACKED_PIXELS,
visual: FB_VISUAL_TRUECOLOR,
line_length: 400*2,
accel: FB_ACCEL_NONE,
};
static int
anakinfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
......@@ -53,153 +64,48 @@ anakinfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
return 0;
}
static int
anakinfb_get_fix(struct fb_fix_screeninfo *fix, int con, struct fb_info *info)
{
memset(fix, 0, sizeof(struct fb_fix_screeninfo));
strcpy(fix->id, "AnakinFB");
fix->smem_start = VGA_START;
fix->smem_len = VGA_SIZE;
fix->type = FB_TYPE_PACKED_PIXELS;
fix->type_aux = 0;
fix->visual = FB_VISUAL_TRUECOLOR;
fix->xpanstep = 0;
fix->ypanstep = 0;
fix->ywrapstep = 0;
fix->line_length = 400 * 2;
fix->accel = FB_ACCEL_NONE;
return 0;
}
static int
anakinfb_get_var(struct fb_var_screeninfo *var, int con, struct fb_info *info)
{
memset(var, 0, sizeof(struct fb_var_screeninfo));
var->xres = 400;
var->yres = 234;
var->xres_virtual = 400;
var->yres_virtual = 234;
var->xoffset = 0;
var->yoffset = 0;
var->bits_per_pixel = 16;
var->grayscale = 0;
var->red.offset = 11;
var->red.length = 5;
var->green.offset = 5;
var->green.length = 6;
var->blue.offset = 0;
var->blue.length = 5;
var->transp.offset = 0;
var->transp.length = 0;
var->nonstd = 0;
var->activate = FB_ACTIVATE_NOW;
var->height = -1;
var->width = -1;
var->pixclock = 0;
var->left_margin = 0;
var->right_margin = 0;
var->upper_margin = 0;
var->lower_margin = 0;
var->hsync_len = 0;
var->vsync_len = 0;
var->sync = 0;
var->vmode = FB_VMODE_NONINTERLACED;
return 0;
}
static int
anakinfb_set_var(struct fb_var_screeninfo *var, int con, struct fb_info *info)
{
return -EINVAL;
}
static int
anakinfb_get_cmap(struct fb_cmap *cmap, int kspc, int con,
struct fb_info *info)
{
if (con == info->currcon)
return fb_get_cmap(cmap, kspc, anakinfb_getcolreg, info);
else if (fb_display[con].cmap.len)
fb_copy_cmap(&fb_display[con].cmap, cmap, kspc ? 0 : 2);
else
fb_copy_cmap(fb_default_cmap(16), cmap, kspc ? 0 : 2);
return 0;
}
static int
anakinfb_switch_con(int con, struct fb_info *info)
{
info->currcon = con;
return 0;
}
static int
anakinfb_updatevar(int con, struct fb_info *info)
{
return 0;
}
static void
anakinfb_blank(int blank, struct fb_info *info)
{
/*
* TODO: use I2C to blank/unblank the screen
*/
}
static struct fb_ops anakinfb_ops = {
owner: THIS_MODULE,
fb_get_fix: anakinfb_get_fix,
fb_get_var: anakinfb_get_var,
fb_set_var: anakinfb_set_var,
fb_get_cmap: anakinfb_get_cmap,
fb_get_fix: gen_get_fix,
fb_get_var: gen_get_var,
fb_set_var: gen_set_var,
fb_get_cmap: gen_get_cmap,
fb_set_cmap: gen_set_cmap,
fb_setcolreg: anakinfb_setcolreg,
fb_blank: anakinfb_blank,
fb_fillrect: cfb_fillrect,
fb_copyarea: cfb_copyarea,
fb_imageblit: cfb_imageblit,
};
int __init
anakinfb_init(void)
{
memset(&fb_info, 0, sizeof(struct fb_info));
strcpy(fb_info.modename, "AnakinFB");
fb_info.node = NODEV;
memset(&display, 0, sizeof(struct display));
strcpy(fb_info.modename, anakinfb_fix.id);
fb_info.node = fb_info.currcon = -1;
fb_info.flags = FBINFO_FLAG_DEFAULT;
fb_info.fbops = &anakinfb_ops;
fb_info.currcon = -1;
fb_info.var = anakinfb_var;
fb_info.fix = anakinfb_fix;
fb_info.disp = &display;
strcpy(fb_info.fontname, "VGA8x16");
fb_info.changevar = NULL;
fb_info.switch_con = &anakinfb_switch_con;
fb_info.updatevar = &anakinfb_updatevar;
memset(&display, 0, sizeof(struct display));
anakinfb_get_var(&display.var, 0, &fb_info);
fb_info.switch_con = gen_switch_con;
fb_info.updatevar = gen_update_var;
if (!(request_mem_region(VGA_START, VGA_SIZE, "vga")))
return -ENOMEM;
if (!(fb_info.screen_base = ioremap(VGA_START, VGA_SIZE))) {
if (fb_info.screen_base = ioremap(VGA_START, VGA_SIZE)) {
release_mem_region(VGA_START, VGA_SIZE);
return -EIO;
}
display.visual = FB_VISUAL_TRUECOLOR;
display.type = FB_TYPE_PACKED_PIXELS;
display.type_aux = 0;
display.ypanstep = 0;
display.ywrapstep = 0;
display.line_length = 400 * 2;
display.can_soft_blank = 1;
display.inverse = 0;
#ifdef FBCON_HAS_CFB16
display.dispsw = &fbcon_cfb16;
display.dispsw_data = colreg;
#else
display.dispsw = &fbcon_dummy;
#endif
fb_alloc_cmap(&fb_info.cmap, 16, 0);
gen_set_disp(-1, &fb_info);
if (register_framebuffer(&fb_info) < 0) {
iounmap(fb_info.screen_base);
iounmap(display.screen_base);
release_mem_region(VGA_START, VGA_SIZE);
return -EINVAL;
}
......
/*
* Generic function for frame buffer with packed pixels of any depth.
*
* Copyright (C) June 1999 James Simmons
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file COPYING in the main directory of this archive for
* more details.
*
* NOTES:
*
* This is for cfb packed pixels. Iplan and such are incorporated in the
* drivers that need them.
*
* FIXME
* The code for 24 bit is horrible. It copies byte by byte size instead of
* longs like the other sizes. Needs to be optimized.
*
* Also need to add code to deal with cards endians that are different than
* the native cpu endians. I also need to deal with MSB position in the word.
*
*/
#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/fb.h>
#include <linux/slab.h>
#include <asm/types.h>
#include <asm/io.h>
#include <video/fbcon.h>
void cfb_copyarea(struct fb_info *p, struct fb_copyarea *area)
{
int x2, y2, lineincr, shift, shift_right, shift_left, old_dx, old_dy;
int n, j, linesize = p->fix.line_length, bpl = sizeof(unsigned long);
unsigned long start_index, end_index, start_mask, end_mask, last;
unsigned long *dst = NULL, *src = NULL;
char *src1, *dst1;
int tmp, height;
/* clip the destination */
old_dx = area->dx;
old_dy = area->dy;
/*
* We could use hardware clipping but on many cards you get around
* hardware clipping by writing to framebuffer directly.
*/
x2 = area->dx + area->width;
y2 = area->dy + area->height;
area->dx = area->dx > 0 ? area->dx : 0;
area->dy = area->dy > 0 ? area->dy : 0;
x2 = x2 < p->var.xres_virtual ? x2 : p->var.xres_virtual;
y2 = y2 < p->var.yres_virtual ? y2 : p->var.yres_virtual;
area->width = x2 - area->dx;
area->height = y2 - area->dy;
/* update sx1,sy1 */
area->sx += (area->dx - old_dx);
area->sy += (area->dy - old_dy);
height = area->height;
/* the source must be completely inside the virtual screen */
if (area->sx < 0 || area->sy < 0 ||
(area->sx + area->width) > p->var.xres_virtual ||
(area->sy + area->height) > p->var.yres_virtual)
return;
if (area->dy < area->sy
|| (area->dy == area->sy && area->dx < area->sx)) {
/* start at the top */
src1 = p->screen_base + area->sy * linesize +
((area->sx * p->var.bits_per_pixel) >> 3);
dst1 = p->screen_base + area->dy * linesize +
((area->dx * p->var.bits_per_pixel) >> 3);
lineincr = linesize;
} else {
/* start at the bottom */
src1 = p->screen_base + (area->sy + area->height-1) * linesize
+ (((area->sx + area->width - 1) * p->var.bits_per_pixel) >> 3);
dst1 = p->screen_base + (area->dy + area->height-1) * linesize
+ (((area->dx + area->width - 1) * p->var.bits_per_pixel) >> 3);
lineincr = -linesize;
}
if ((BITS_PER_LONG % p->var.bits_per_pixel) == 0) {
int ppw = BITS_PER_LONG / p->var.bits_per_pixel;
int n = ((area->width * p->var.bits_per_pixel) >> 3);
start_index = ((unsigned long) src1 & (bpl - 1));
end_index = ((unsigned long) (src1 + n) & (bpl - 1));
shift = ((unsigned long) dst1 & (bpl - 1)) -
((unsigned long) src1 & (bpl - 1));
start_mask = end_mask = 0;
if (start_index) {
start_mask = -1 >> (start_index << 3);
n -= (bpl - start_index);
}
if (end_index) {
end_mask = -1 << ((bpl - end_index) << 3);
n -= end_index;
}
n = n / bpl;
if (n <= 0) {
if (start_mask) {
if (end_mask)
end_mask &= start_mask;
else
end_mask = start_mask;
start_mask = 0;
}
n = 0;
}
if (shift) {
if (shift > 0) {
/* dest is over to right more */
shift_right =
shift * p->var.bits_per_pixel;
shift_left =
(ppw - shift) * p->var.bits_per_pixel;
} else {
/* source is to the right more */
shift_right =
(ppw + shift) * p->var.bits_per_pixel;
shift_left =
-shift * p->var.bits_per_pixel;
}
/* general case, positive increment */
if (lineincr > 0) {
if (shift < 0)
n++;
do {
dst = (unsigned long *) dst1;
src = (unsigned long *) src1;
last = (fb_readl(src) & start_mask);
if (shift > 0)
fb_writel(fb_readl(dst) | (last >> shift_right), dst);
for (j = 0; j < n; j++) {
dst++;
tmp = fb_readl(src);
src++;
fb_writel((last << shift_left) | (tmp >> shift_right), dst);
last = tmp;
src++;
}
fb_writel(fb_readl(dst) | (last << shift_left), dst);
src1 += lineincr;
dst1 += lineincr;
} while (--height);
} else {
/* general case, negative increment */
if (shift > 0)
n++;
do {
dst = (unsigned long *) dst1;
src = (unsigned long *) src1;
last = (fb_readl(src) & end_mask);
if (shift < 0)
fb_writel(fb_readl(dst) | (last >> shift_right), dst);
for (j = 0; j < n; j++) {
dst--;
tmp = fb_readl(src);
src--;
fb_writel((tmp << shift_left) | (last >> shift_right), dst);
last = tmp;
src--;
}
fb_writel(fb_readl(dst) | (last >> shift_right), dst);
src1 += lineincr;
dst1 += lineincr;
} while (--height);
}
} else {
/* no shift needed */
if (lineincr > 0) {
/* positive increment */
do {
dst = (unsigned long *) (dst1 - start_index);
src = (unsigned long *) (src1 - start_index);
if (start_mask)
fb_writel(fb_readl(src) | start_mask, dst);
for (j = 0; j < n; j++) {
fb_writel(fb_readl(src), dst);
dst++;
src++;
}
if (end_mask)
fb_writel(fb_readl(src) | end_mask, dst);
src1 += lineincr;
dst1 += lineincr;
} while (--height);
} else {
/* negative increment */
do {
dst = (unsigned long *) dst1;
src = (unsigned long *) src1;
if (start_mask)
fb_writel(fb_readl(src) | start_mask, dst);
for (j = 0; j < n; j++) {
fb_writel(fb_readl(src), dst);
dst--;
src--;
}
src1 += lineincr;
dst1 += lineincr;
} while (--height);
}
}
}
}
/*
* Generic fillrect for frame buffers with packed pixels of any depth.
*
* Copyright (C) 2000 James Simmons (jsimmons@linux-fbdev.org)
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file COPYING in the main directory of this archive for
* more details.
*
* NOTES:
*
* The code for depths like 24 that don't have integer number of pixels per
* long is broken and needs to be fixed. For now I turned these types of
* mode off.
*
* Also need to add code to deal with cards endians that are different than
* the native cpu endians. I also need to deal with MSB position in the word.
*
*/
#include <linux/string.h>
#include <linux/fb.h>
#include <asm/types.h>
#include <video/fbcon.h>
void cfb_fillrect(struct fb_info *p, struct fb_fillrect *rect)
{
unsigned long start_index, end_index, start_mask = 0, end_mask = 0;
unsigned long height, ppw, fg, fgcolor;
int i, n, x2, y2, linesize = p->fix.line_length;
int bpl = sizeof(unsigned long);
unsigned long *dst;
char *dst1;
if (!rect->width || !rect->height)
return;
/* We could use hardware clipping but on many cards you get around
* hardware clipping by writing to framebuffer directly. */
x2 = rect->dx + rect->width;
y2 = rect->dy + rect->height;
x2 = x2 < p->var.xres_virtual ? x2 : p->var.xres_virtual;
y2 = y2 < p->var.yres_virtual ? y2 : p->var.yres_virtual;
rect->width = x2 - rect->dx;
height = y2 - rect->dy;
/* Size of the scanline in bytes */
n = (rect->width * (p->var.bits_per_pixel >> 3));
ppw = BITS_PER_LONG / p->var.bits_per_pixel;
dst1 = p->screen_base + (rect->dy * linesize) +
(rect->dx * (p->var.bits_per_pixel >> 3));
start_index = ((unsigned long) dst1 & (bpl - 1));
end_index = ((unsigned long) (dst1 + n) & (bpl - 1));
if (p->fix.visual == FB_VISUAL_TRUECOLOR)
fg = fgcolor = ((u32 *) (p->pseudo_palette))[rect->color];
else
fg = fgcolor = rect->color;
for (i = 0; i < ppw - 1; i++) {
fg <<= p->var.bits_per_pixel;
fg |= fgcolor;
}
if (start_index) {
start_mask = fg << (start_index << 3);
n -= (bpl - start_index);
}
if (end_index) {
end_mask = fg >> ((bpl - end_index) << 3);
n -= end_index;
}
n = n / bpl;
if (n <= 0) {
if (start_mask) {
if (end_mask)
end_mask &= start_mask;
else
end_mask = start_mask;
start_mask = 0;
}
n = 0;
}
if ((BITS_PER_LONG % p->var.bits_per_pixel) == 0) {
switch (rect->rop) {
case ROP_COPY:
do {
/* Word align to increases performace :-) */
dst = (unsigned long *) (dst1 - start_index);
if (start_mask) {
#if BITS_PER_LONG == 32
fb_writel(fb_readl(dst) |
start_mask, dst);
#else
fb_writeq(fb_readq(dst) |
start_mask, dst);
#endif
dst++;
}
for (i = 0; i < n; i++) {
#if BITS_PER_LONG == 32
fb_writel(fg, dst);
#else
fb_writeq(fg, dst);
#endif
dst++;
}
if (end_mask)
#if BITS_PER_LONG == 32
fb_writel(fb_readl(dst) | end_mask,
dst);
#else
fb_writeq(fb_readq(dst) | end_mask,
dst);
#endif
dst1 += linesize;
} while (--height);
break;
case ROP_XOR:
do {
dst = (unsigned long *) (dst1 - start_index);
if (start_mask) {
#if BITS_PER_LONG == 32
fb_writel(fb_readl(dst) ^
start_mask, dst);
#else
fb_writeq(fb_readq(dst) ^
start_mask, dst);
#endif
dst++;
}
for (i = 0; i < n; i++) {
#if BITS_PER_LONG == 32
fb_writel(fb_readl(dst) ^ fg, dst);
#else
fb_writeq(fb_readq(dst) ^ fg, dst);
#endif
dst++;
}
if (end_mask) {
#if BITS_PER_LONG == 32
fb_writel(fb_readl(dst) ^ end_mask,
dst);
#else
fb_writeq(fb_readq(dst) ^ end_mask,
dst);
#endif
}
dst1 += linesize;
} while (--height);
break;
}
} else {
/* Odd modes like 24 or 80 bits per pixel */
start_mask = fg >> (start_index * p->var.bits_per_pixel);
end_mask = fg << (end_index * p->var.bits_per_pixel);
/* start_mask =& PFILL24(x1,fg);
end_mask_or = end_mask & PFILL24(x1+width-1,fg); */
n = (rect->width - start_index - end_index) / ppw;
switch (rect->rop) {
case ROP_COPY:
do {
dst = (unsigned long *) dst1;
if (start_mask)
*dst |= start_mask;
if ((start_index + rect->width) > ppw)
dst++;
/* XXX: slow */
for (i = 0; i < n; i++) {
*dst++ = fg;
}
if (end_mask)
*dst |= end_mask;
dst1 += linesize;
} while (--height);
break;
case ROP_XOR:
do {
dst = (unsigned long *) dst1;
if (start_mask)
*dst ^= start_mask;
if ((start_mask + rect->width) > ppw)
dst++;
for (i = 0; i < n; i++) {
*dst++ ^= fg; /* PFILL24(fg,x1+i); */
}
if (end_mask)
*dst ^= end_mask;
dst1 += linesize;
} while (--height);
break;
}
}
return;
}
/*
* Generic BitBLT function for frame buffer with packed pixels of any depth.
*
* Copyright (C) June 1999 James Simmons
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file COPYING in the main directory of this archive for
* more details.
*
* NOTES:
*
* This function copys a image from system memory to video memory. The
* image can be a bitmap where each 0 represents the background color and
* each 1 represents the foreground color. Great for font handling. It can
* also be a color image. This is determined by image_depth. The color image
* must be laid out exactly in the same format as the framebuffer. Yes I know
* their are cards with hardware that coverts images of various depths to the
* framebuffer depth. But not every card has this. All images must be rounded
* up to the nearest byte. For example a bitmap 12 bits wide must be two
* bytes width.
*
* FIXME
* The code for 24 bit is horrible. It copies byte by byte size instead of
* longs like the other sizes. Needs to be optimized.
*
* Also need to add code to deal with cards endians that are different than
* the native cpu endians. I also need to deal with MSB position in the word.
*
*/
#include <linux/string.h>
#include <linux/fb.h>
#include <asm/types.h>
#include <video/fbcon.h>
#define DEBUG
#ifdef DEBUG
#define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt,__FUNCTION__,## args)
#else
#define DPRINTK(fmt, args...)
#endif
void cfb_imageblit(struct fb_info *p, struct fb_image *image)
{
int pad, ppw, shift, shift_right, shift_left, x2, y2, n, i, j, k, l = 7;
unsigned long tmp = ~0 << (BITS_PER_LONG - p->var.bits_per_pixel);
unsigned long fgx, bgx, fgcolor, bgcolor, eorx;
unsigned long end_index, end_mask;
unsigned long *dst = NULL;
u8 *dst1, *src;
/*
* We could use hardware clipping but on many cards you get around hardware
* clipping by writing to framebuffer directly like we are doing here.
*/
x2 = image->dx + image->width;
y2 = image->dy + image->height;
image->dx = image->dx > 0 ? image->dx : 0;
image->dy = image->dy > 0 ? image->dy : 0;
x2 = x2 < p->var.xres_virtual ? x2 : p->var.xres_virtual;
y2 = y2 < p->var.yres_virtual ? y2 : p->var.yres_virtual;
image->width = x2 - image->dx;
image->height = y2 - image->dy;
dst1 = p->screen_base + image->dy * p->fix.line_length +
((image->dx * p->var.bits_per_pixel) >> 3);
ppw = BITS_PER_LONG/p->var.bits_per_pixel;
src = image->data;
if (image->depth == 1) {
if (p->fix.visual == FB_VISUAL_TRUECOLOR) {
fgx = fgcolor = ((u32 *)(p->pseudo_palette))[image->fg_color];
bgx = bgcolor = ((u32 *)(p->pseudo_palette))[image->bg_color];
} else {
fgx = fgcolor = image->fg_color;
bgx = bgcolor = image->bg_color;
}
for (i = 0; i < ppw-1; i++) {
fgx <<= p->var.bits_per_pixel;
bgx <<= p->var.bits_per_pixel;
fgx |= fgcolor;
bgx |= bgcolor;
}
eorx = fgx ^ bgx;
n = ((image->width + 7) >> 3);
pad = (n << 3) - image->width;
n = image->width % ppw;
for (i = 0; i < image->height; i++) {
dst = (unsigned long *) dst1;
for (j = image->width/ppw; j > 0; j--) {
end_mask = 0;
for (k = ppw; k > 0; k--) {
if (test_bit(l, src))
end_mask |= (tmp >> (p->var.bits_per_pixel*(k-1)));
l--;
if (l < 0) { l = 7; src++; }
}
fb_writel((end_mask & eorx)^bgx, dst);
dst++;
}
if (n) {
for (j = n; j > 0; j--) {
end_mask = 0;
if (test_bit(l, src))
end_mask |= (tmp >> (p->var.bits_per_pixel*(k-1)));
l--;
if (l < 0) { l = 7; src++; }
}
fb_writel((end_mask & eorx)^bgx, dst);
dst++;
}
l -= pad;
dst1 += p->fix.line_length;
}
} else {
/* Draw the penguin */
n = ((image->width * p->var.bits_per_pixel) >> 3);
//shift = ((unsigned long) dst1 & (bpl -1));
end_mask = 0;
// n = n/bpl;
}
}
......@@ -74,10 +74,10 @@ struct fb_info_chips {
#define write_ind(num, val, ap, dp) do { \
outb((num), (ap)); outb((val), (dp)); \
} while (0);
} while (0)
#define read_ind(num, var, ap, dp) do { \
outb((num), (ap)); var = inb((dp)); \
} while (0);
} while (0)
/* extension registers */
#define write_xr(num, val) write_ind(num, val, 0x3d6, 0x3d7)
......
......@@ -27,7 +27,6 @@
#include <linux/proc_fs.h>
#include <video/fbcon.h>
#include <video/fbcon-cfb4.h>
#include <asm/hardware.h>
#include <asm/mach-types.h>
......@@ -89,40 +88,11 @@ clps7111fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
}
/*
* Set the User Defined Part of the Display
* Validate the purposed mode.
*/
static int
clps7111fb_set_var(struct fb_var_screeninfo *var, int con,
struct fb_info *info)
clps7111fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
{
struct display *display;
unsigned int lcdcon, syscon;
int chgvar = 0;
if (var->activate & FB_ACTIVATE_TEST)
return 0;
if ((var->activate & FB_ACTIVATE_MASK) != FB_ACTIVATE_NOW)
return -EINVAL;
if (info->var.xres != var->xres)
chgvar = 1;
if (info->var.yres != var->yres)
chgvar = 1;
if (info->var.xres_virtual != var->xres_virtual)
chgvar = 1;
if (info->var.yres_virtual != var->yres_virtual)
chgvar = 1;
if (info->var.bits_per_pixel != var->bits_per_pixel)
chgvar = 1;
if (con < 0) {
display = info->disp;
chgvar = 0;
} else {
display = fb_display + con;
}
var->transp.msb_right = 0;
var->transp.offset = 0;
var->transp.length = 0;
......@@ -132,70 +102,37 @@ clps7111fb_set_var(struct fb_var_screeninfo *var, int con,
var->green = var->red;
var->blue = var->red;
if (var->bits_per_pixel > 4)
return -EINVAL;
}
/*
* Set the hardware state.
*/
static int
clps7111fb_set_par(struct fb_info *info)
{
unsigned int lcdcon, syscon;
switch (var->bits_per_pixel) {
#ifdef FBCON_HAS_MFB
case 1:
info->fix.visual = FB_VISUAL_MONO01;
display->dispsw = &fbcon_mfb;
display->dispsw_data = NULL;
break;
#endif
#ifdef FBCON_HAS_CFB2
case 2:
info->fix.visual = FB_VISUAL_PSEUDOCOLOR;
display->dispsw = &fbcon_cfb2;
display->dispsw_data = NULL;
break;
#endif
#ifdef FBCON_HAS_CFB4
case 4:
info->fix.visual = FB_VISUAL_PSEUDOCOLOR;
display->dispsw = &fbcon_cfb4;
display->dispsw_data = NULL;
break;
#endif
default:
return -EINVAL;
}
display->next_line = var->xres_virtual * var->bits_per_pixel / 8;
info->fix.line_length = display->next_line;
display->line_length = info->fix.line_length;
display->visual = info->fix.visual;
display->type = info->fix.type;
display->type_aux = info->fix.type_aux;
display->ypanstep = info->fix.ypanstep;
display->ywrapstep = info->fix.ywrapstep;
display->can_soft_blank = 1;
display->inverse = 0;
info->var = *var;
info->var.activate &= ~FB_ACTIVATE_ALL;
/*
* Update the old var. The fbcon drivers still use this.
* Once they are using cfb->var, this can be dropped.
* --rmk
*/
display->var = info->var;
/*
* If we are setting all the virtual consoles, also set the
* defaults used to create new consoles.
*/
if (var->activate & FB_ACTIVATE_ALL)
info->disp->var = info->var;
if (chgvar && info && info->changevar)
info->changevar(con);
info->fix.line_length = info->var.xres_virtual * info->var.bits_per_pixel / 8;
/*
* LCDCON must only be changed while the LCD is disabled
*/
lcdcon = (var->xres_virtual * var->yres_virtual * var->bits_per_pixel) / 128 - 1;
lcdcon |= ((var->xres_virtual / 16) - 1) << 13;
lcdcon = (info->var.xres_virtual * info->var.yres_virtual * info->var.bits_per_pixel) / 128 - 1;
lcdcon |= ((info->var.xres_virtual / 16) - 1) << 13;
lcdcon |= 2 << 19;
lcdcon |= 13 << 25;
lcdcon |= LCDCON_GSEN;
......@@ -205,9 +142,6 @@ clps7111fb_set_var(struct fb_var_screeninfo *var, int con,
clps_writel(syscon & ~SYSCON1_LCDEN, SYSCON1);
clps_writel(lcdcon, LCDCON);
clps_writel(syscon | SYSCON1_LCDEN, SYSCON1);
fb_set_cmap(&info->cmap, 1, info);
return 0;
}
......@@ -260,7 +194,9 @@ static int clps7111fb_blank(int blank, struct fb_info *info)
static struct fb_ops clps7111fb_ops = {
owner: THIS_MODULE,
fb_set_var: clps7111fb_set_var,
fb_check_var: clps7111fb_check_var,
fb_set_par: clps7111fb_set_par,
fb_set_var: gen_set_var,
fb_set_cmap: gen_set_cmap,
fb_get_fix: gen_get_fix,
fb_get_var: gen_get_var,
......@@ -269,50 +205,6 @@ static struct fb_ops clps7111fb_ops = {
fb_blank: clps7111fb_blank,
};
static int clps7111fb_switch(int con, struct fb_info *info)
{
struct display *disp;
struct fb_cmap *cmap;
if (info->currcon >= 0) {
disp = fb_display + info->currcon;
/*
* Save the old colormap and video mode.
*/
disp->var = info->var;
if (disp->cmap.len)
fb_copy_cmap(&info->cmap, &disp->cmap, 0);
}
info->currcon = con;
disp = fb_display + con;
/*
* Install the new colormap and change the video mode. By default,
* fbcon sets all the colormaps and video modes to the default
* values at bootup.
*/
if (disp->cmap.len)
cmap = &disp->cmap;
else
cmap = fb_default_cmap(CMAP_SIZE);
fb_copy_cmap(cmap, &info->cmap, 0);
info->var = disp->var;
info->var.activate = FB_ACTIVATE_NOW;
clps7111fb_set_var(&info->var, con, info);
return 0;
}
static int clps7111fb_updatevar(int con, struct fb_info *info)
{
return -EINVAL;
}
static int
clps7111fb_proc_backlight_read(char *page, char **start, off_t off,
int count, int *eof, void *data)
......@@ -395,8 +287,8 @@ int __init clps711xfb_init(void)
cfb->fbops = &clps7111fb_ops;
cfb->changevar = NULL;
cfb->switch_con = clps7111fb_switch;
cfb->updatevar = clps7111fb_updatevar;
cfb->switch_con = gen_switch;
cfb->updatevar = gen_update_var;
cfb->flags = FBINFO_FLAG_DEFAULT;
cfb->disp = (struct display *)(cfb + 1);
......@@ -439,7 +331,7 @@ int __init clps711xfb_init(void)
clps_writeb(clps_readb(PDDR) | EDB_PD3_LCDBL, PDDR);
}
clps7111fb_set_var(&cfb->var, -1, cfb);
gen_set_var(&cfb->var, -1, cfb);
err = register_framebuffer(cfb);
out: return err;
......
......@@ -1729,9 +1729,8 @@ static int cyberpro_pci_resume(struct pci_dev *dev)
}
static struct pci_device_id cyberpro_pci_table[] __devinitdata = {
// Not yet
// { PCI_VENDOR_ID_INTERG, PCI_DEVICE_ID_INTERG_1682,
// PCI_ANY_ID, PCI_ANY_ID, 0, 0, ID_IGA_1682 },
{ PCI_VENDOR_ID_INTERG, PCI_DEVICE_ID_INTERG_1682,
PCI_ANY_ID, PCI_ANY_ID, 0, 0, ID_IGA_1682 },
{ PCI_VENDOR_ID_INTERG, PCI_DEVICE_ID_INTERG_2000,
PCI_ANY_ID, PCI_ANY_ID, 0, 0, ID_CYBERPRO_2000 },
{ PCI_VENDOR_ID_INTERG, PCI_DEVICE_ID_INTERG_2010,
......
......@@ -152,7 +152,7 @@ void fb_copy_cmap(struct fb_cmap *from, struct fb_cmap *to, int fsfromto)
size = to->len-tooff;
if (size > from->len-fromoff)
size = from->len-fromoff;
if (size < 0)
if (size <= 0)
return;
size *= sizeof(u16);
......
......@@ -158,7 +158,7 @@ struct display_switch fbcon_accel = {
putcs: fbcon_accel_putcs,
revc: fbcon_accel_revc,
clear_margins: fbcon_accel_clear_margins,
fontwidthmask: FONTWIDTHRANGE(1, 32)
fontwidthmask: FONTWIDTHRANGE(1, 16)
};
#ifdef MODULE
......
......@@ -61,6 +61,8 @@ extern int cyberfb_init(void);
extern int cyberfb_setup(char*);
extern int pm2fb_init(void);
extern int pm2fb_setup(char*);
extern int pm3fb_init(void);
extern int pm3fb_setup(char*);
extern int clps711xfb_init(void);
extern int cyber2000fb_init(void);
extern int cyber2000fb_setup(char*);
......@@ -120,10 +122,16 @@ extern int rivafb_init(void);
extern int rivafb_setup(char*);
extern int tdfxfb_init(void);
extern int tdfxfb_setup(char*);
extern int tridentfb_init(void);
extern int tridentfb_setup(char*);
extern int sisfb_init(void);
extern int sisfb_setup(char*);
extern int stifb_init(void);
extern int stifb_setup(char*);
extern int pmagbafb_init(void);
extern int pmagbbfb_init(void);
extern void maxinefb_init(void);
extern int tx3912fb_init(void);
extern int radeonfb_init(void);
extern int radeonfb_setup(char*);
extern int e1355fb_init(void);
......@@ -172,6 +180,9 @@ static struct {
#ifdef CONFIG_FB_PM2
{ "pm2fb", pm2fb_init, pm2fb_setup },
#endif
#ifdef CONFIG_FB_PM3
{ "pm3fb", pm3fb_init, pm3fb_setup },
#endif
#ifdef CONFIG_FB_CLGEN
{ "clgen", clgenfb_init, clgenfb_setup },
#endif
......@@ -220,6 +231,9 @@ static struct {
#ifdef CONFIG_FB_SIS
{ "sisfb", sisfb_init, sisfb_setup },
#endif
#ifdef CONFIG_FB_TRIDENT
{ "trident", tridentfb_init, tridentfb_setup },
#endif
/*
* Generic drivers that are used as fallbacks
......@@ -285,12 +299,24 @@ static struct {
#ifdef CONFIG_FB_HIT
{ "hitfb", hitfb_init, NULL },
#endif
#ifdef CONFIG_FB_TX3912
{ "tx3912", tx3912fb_init, NULL },
#endif
#ifdef CONFIG_FB_E1355
{ "e1355fb", e1355fb_init, e1355fb_setup },
#endif
#ifdef CONFIG_FB_PVR2
{ "pvr2", pvr2fb_init, pvr2fb_setup },
#endif
#ifdef CONFIG_FB_PMAG_BA
{ "pmagbafb", pmagbafb_init, NULL },
#endif
#ifdef CONFIG_FB_PMAGB_B
{ "pmagbbfb", pmagbbfb_init, NULL },
#endif
#ifdef CONFIG_FB_MAXINE
{ "maxinefb", maxinefb_init, NULL },
#endif
#ifdef CONFIG_FB_VOODOO1
{ "sst", sstfb_init, sstfb_setup },
#endif
......
......@@ -7,6 +7,7 @@
*
* Written for 2.0.x by Steffen A. Mork
* Ported to 2.1.x by Geert Uytterhoeven
* Ported to new api by James Simmons
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file COPYING in the main directory of this archive for
......@@ -18,12 +19,9 @@
#include <linux/fb.h>
#include <linux/init.h>
#include <linux/zorro.h>
#include <asm/io.h>
#include <video/fbcon.h>
#include <video/fbcon-cfb32.h>
/*
* Some technical notes:
......@@ -117,7 +115,6 @@
*
*/
/*
* definitions
*/
......@@ -130,29 +127,22 @@
#define FRAMEMASTER_COMPL 4
#define FRAMEMASTER_ROM 8
struct FrameMaster_fb_par
{
int xres;
int yres;
int bpp;
int pixclock;
};
static unsigned long fm2fb_mem_phys;
static void *fm2fb_mem;
static unsigned long fm2fb_reg_phys;
static volatile unsigned char *fm2fb_reg;
static struct display disp;
static struct fb_info fb_info;
static struct { u_char red, green, blue, pad; } palette[16];
#ifdef FBCON_HAS_CFB32
static u32 fbcon_cfb32_cmap[16];
#endif
#define arraysize(x) (sizeof(x)/sizeof(*(x)))
static struct fb_fix_screeninfo fb_fix;
static struct fb_var_screeninfo fb_var;
static struct fb_info fb_info;
static u32 pseudo_palette[17];
static struct display display;
static struct fb_fix_screeninfo fb_fix __initdata = {
smem_len: FRAMEMASTER_REG,
type: FB_TYPE_PACKED_PIXELS,
visual: FB_VISUAL_TRUECOLOR,
line_length: (768 << 2),
mmio_len: (8),
accel: FB_ACCEL_NONE,
};
static int fm2fb_mode __initdata = -1;
......@@ -175,123 +165,56 @@ static struct fb_var_screeninfo fb_var_modes[] __initdata = {
}
};
/*
* Interface used by the world
*/
int fm2fb_init(void);
static int fm2fb_get_fix(struct fb_fix_screeninfo *fix, int con,
struct fb_info *info);
static int fm2fb_get_var(struct fb_var_screeninfo *var, int con,
struct fb_info *info);
static int fm2fb_set_var(struct fb_var_screeninfo *var, int con,
struct fb_info *info);
static int fm2fb_get_cmap(struct fb_cmap *cmap, int kspc, int con,
struct fb_info *info);
static int fm2fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
u_int transp, struct fb_info *info);
static int fm2fb_blank(int blank, struct fb_info *info);
/*
* Interface to the low level console driver
*/
int fm2fb_init(void);
static int fm2fbcon_switch(int con, struct fb_info *info);
static int fm2fbcon_updatevar(int con, struct fb_info *info);
/*
* Internal routines
*/
static int fm2fb_getcolreg(u_int regno, u_int *red, u_int *green, u_int *blue,
u_int *transp, struct fb_info *info);
static struct fb_ops fm2fb_ops = {
owner: THIS_MODULE,
fb_get_fix: fm2fb_get_fix,
fb_get_var: fm2fb_get_var,
fb_set_var: fm2fb_set_var,
fb_get_cmap: fm2fb_get_cmap,
fb_get_fix: gen_get_fix,
fb_get_var: gen_get_var,
fb_set_var: gen_set_var,
fb_get_cmap: gen_get_cmap,
fb_set_cmap: gen_set_cmap,
fb_setcolreg: fm2fb_setcolreg,
fb_blank: fm2fb_blank,
fb_fillrect: cfb_fillrect,
fb_copyarea: cfb_copyarea,
fb_imageblit: cfb_imageblit,
};
/*
* Get the Fixed Part of the Display
* Blank the display.
*/
static int fm2fb_get_fix(struct fb_fix_screeninfo *fix, int con,
struct fb_info *info)
static int fm2fb_blank(int blank, struct fb_info *info)
{
memcpy(fix, &fb_fix, sizeof(fb_fix));
return 0;
}
/*
* Get the User Defined Part of the Display
*/
unsigned char t = FRAMEMASTER_ROM;
static int fm2fb_get_var(struct fb_var_screeninfo *var, int con,
struct fb_info *info)
{
memcpy(var, &fb_var, sizeof(fb_var));
return 0;
if (!blank)
t |= FRAMEMASTER_ENABLE | FRAMEMASTER_NOLACE;
fm2fb_reg[0] = t;
}
/*
* Set the User Defined Part of the Display
* Set a single color register. The values supplied are already
* rounded down to the hardware's capabilities (according to the
* entries in the var structure). Return != 0 for invalid regno.
*/
static int fm2fb_set_var(struct fb_var_screeninfo *var, int con,
struct fb_info *info)
static int fm2fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
u_int transp, struct fb_info *info)
{
struct display *display;
int oldbpp = -1, err;
if (con >= 0)
display = &fb_display[con];
else
display = &disp; /* used during initialization */
if (var->xres > fb_var.xres || var->yres > fb_var.yres ||
var->xres_virtual > fb_var.xres_virtual ||
var->yres_virtual > fb_var.yres_virtual ||
var->bits_per_pixel > fb_var.bits_per_pixel ||
var->nonstd ||
(var->vmode & FB_VMODE_MASK) != FB_VMODE_NONINTERLACED)
return -EINVAL;
memcpy(var, &fb_var, sizeof(fb_var));
if ((var->activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW) {
oldbpp = display->var.bits_per_pixel;
display->var = *var;
}
if (oldbpp != var->bits_per_pixel) {
if ((err = fb_alloc_cmap(&display->cmap, 0, 0)))
return err;
do_install_cmap(con, info);
}
return 0;
}
/*
* Get the Colormap
*/
if (regno > 15)
return 1;
red >>= 8;
green >>= 8;
blue >>= 8;
static int fm2fb_get_cmap(struct fb_cmap *cmap, int kspc, int con,
struct fb_info *info)
{
if (con == info->currcon) /* current console? */
return fb_get_cmap(cmap, kspc, fm2fb_getcolreg, info);
else if (fb_display[con].cmap.len) /* non default colormap? */
fb_copy_cmap(&fb_display[con].cmap, cmap, kspc ? 0 : 2);
else
fb_copy_cmap(fb_default_cmap(256), cmap, kspc ? 0 : 2);
((u32*)(info->pseudo_palette))[regno] = (red << 16) | (green << 8) | blue;
return 0;
}
......@@ -301,9 +224,9 @@ static int fm2fb_get_cmap(struct fb_cmap *cmap, int kspc, int con,
int __init fm2fb_init(void)
{
int is_fm;
struct zorro_dev *z = NULL;
unsigned long *ptr;
int is_fm;
int x, y;
while ((z = zorro_find_device(ZORRO_WILDCARD, z))) {
......@@ -313,84 +236,58 @@ int __init fm2fb_init(void)
is_fm = 0;
else
continue;
if (!request_mem_region(z->resource.start, FRAMEMASTER_SIZE, "fm2fb"))
continue;
/* assigning memory to kernel space */
fm2fb_mem_phys = z->resource.start;
fm2fb_mem = ioremap(fm2fb_mem_phys, FRAMEMASTER_SIZE);
fm2fb_reg_phys = fm2fb_mem_phys+FRAMEMASTER_REG;
fm2fb_reg = (unsigned char *)(fm2fb_mem+FRAMEMASTER_REG);
fb_fix.smem_start = z->resource.start;
fb_info.screen_base = ioremap(fb_fix.smem_start, FRAMEMASTER_SIZE);
fb_fix.mmio_start = fb_fix.smem_start + FRAMEMASTER_REG;
fm2fb_reg = (unsigned char *)(fb_info.screen_base+FRAMEMASTER_REG);
strcpy(fb_fix.id, is_fm ? "FrameMaster II" : "Rainbow II");
/* make EBU color bars on display */
ptr = (unsigned long *)fm2fb_mem;
ptr = (unsigned long *)fb_fix.smem_start;
for (y = 0; y < 576; y++) {
for (x = 0; x < 96; x++) *ptr++ = 0xffffff; /* white */
for (x = 0; x < 96; x++) *ptr++ = 0xffff00; /* yellow */
for (x = 0; x < 96; x++) *ptr++ = 0x00ffff; /* cyan */
for (x = 0; x < 96; x++) *ptr++ = 0x00ff00; /* green */
for (x = 0; x < 96; x++) *ptr++ = 0xff00ff; /* magenta */
for (x = 0; x < 96; x++) *ptr++ = 0xff0000; /* red */
for (x = 0; x < 96; x++) *ptr++ = 0x0000ff; /* blue */
for (x = 0; x < 96; x++) *ptr++ = 0x000000; /* black */
for (x = 0; x < 96; x++) *ptr++ = 0xffffff;/* white */
for (x = 0; x < 96; x++) *ptr++ = 0xffff00;/* yellow */
for (x = 0; x < 96; x++) *ptr++ = 0x00ffff;/* cyan */
for (x = 0; x < 96; x++) *ptr++ = 0x00ff00;/* green */
for (x = 0; x < 96; x++) *ptr++ = 0xff00ff;/* magenta */
for (x = 0; x < 96; x++) *ptr++ = 0xff0000;/* red */
for (x = 0; x < 96; x++) *ptr++ = 0x0000ff;/* blue */
for (x = 0; x < 96; x++) *ptr++ = 0x000000;/* black */
}
fm2fb_blank(0, NULL);
if (fm2fb_mode == -1)
fm2fb_mode = FM2FB_MODE_PAL;
fb_var = fb_var_modes[fm2fb_mode];
strcpy(fb_fix.id, is_fm ? "FrameMaster II" : "Rainbow II");
fb_fix.smem_start = fm2fb_mem_phys;
fb_fix.smem_len = FRAMEMASTER_REG;
fb_fix.type = FB_TYPE_PACKED_PIXELS;
fb_fix.type_aux = 0;
fb_fix.visual = FB_VISUAL_TRUECOLOR;
fb_fix.line_length = 768<<2;
fb_fix.mmio_start = fm2fb_reg_phys;
fb_fix.mmio_len = 8;
fb_fix.accel = FB_ACCEL_NONE;
disp.var = fb_var;
disp.cmap.start = 0;
disp.cmap.len = 0;
disp.cmap.red = disp.cmap.green = disp.cmap.blue = disp.cmap.transp = NULL;
disp.visual = fb_fix.visual;
disp.type = fb_fix.type;
disp.type_aux = fb_fix.type_aux;
disp.ypanstep = 0;
disp.ywrapstep = 0;
disp.line_length = fb_fix.line_length;
disp.can_soft_blank = 1;
disp.inverse = 0;
#ifdef FBCON_HAS_CFB32
disp.dispsw = &fbcon_cfb32;
disp.dispsw_data = &fbcon_cfb32_cmap;
#else
disp.dispsw = &fbcon_dummy;
#endif
disp.scrollmode = SCROLL_YREDRAW;
strcpy(fb_info.modename, fb_fix.id);
fb_info.node = NODEV;
fb_info.fbops = &fm2fb_ops;
fb_info.screen_base = (char *)fm2fb_mem;
fb_info.currcon = -1;
fb_info.disp = &disp;
fb_info.fontname[0] = '\0';
fb_info.changevar = NULL;
fb_info.switch_con = &fm2fbcon_switch;
fb_info.updatevar = &fm2fbcon_updatevar;
fb_info.var = fb_var_modes[fm2fb_mode];
fb_info.screen_base = (char *)fb_fix.smem_start;
fb_info.pseudo_palette = pseudo_palette;
fb_info.fix = fb_fix;
fb_info.flags = FBINFO_FLAG_DEFAULT;
fm2fb_set_var(&fb_var, -1, &fb_info);
/* The below feilds will go away !!!! */
fb_info.currcon = -1;
strcpy(fb_info.modename, fb_info.fix.id);
fb_info.disp = &display;
fb_info.switch_con = gen_switch;
fb_info.updatevar = gen_update_var;
fb_alloc_cmap(&fb_info.cmap, 16, 0);
gen_set_disp(-1, &fb_info);
if (register_framebuffer(&fb_info) < 0)
return -EINVAL;
printk("fb%d: %s frame buffer device\n", GET_FB_IDX(fb_info.node),
fb_fix.id);
printk("fb%d: %s frame buffer device\n", GET_FB_IDX(fb_info.node), fb_fix.id);
return 0;
}
return -ENXIO;
......@@ -412,83 +309,4 @@ int __init fm2fb_setup(char *options)
return 0;
}
static int fm2fbcon_switch(int con, struct fb_info *info)
{
/* Do we have to save the colormap? */
if (fb_display[info->currcon].cmap.len)
fb_get_cmap(&fb_display[info->currcon].cmap, 1, fm2fb_getcolreg, info);
info->currcon = con;
/* Install new colormap */
do_install_cmap(con, info);
return 0;
}
/*
* Update the `var' structure (called by fbcon.c)
*/
static int fm2fbcon_updatevar(int con, struct fb_info *info)
{
/* Nothing */
return 0;
}
/*
* Blank the display.
*/
static int fm2fb_blank(int blank, struct fb_info *info)
{
unsigned char t = FRAMEMASTER_ROM;
if (!blank)
t |= FRAMEMASTER_ENABLE | FRAMEMASTER_NOLACE;
fm2fb_reg[0] = t;
return 0;
}
/*
* Read a single color register and split it into
* colors/transparent. Return != 0 for invalid regno.
*/
static int fm2fb_getcolreg(u_int regno, u_int *red, u_int *green, u_int *blue,
u_int *transp, struct fb_info *info)
{
if (regno > 15)
return 1;
*red = (palette[regno].red<<8) | palette[regno].red;
*green = (palette[regno].green<<8) | palette[regno].green;
*blue = (palette[regno].blue<<8) | palette[regno].blue;
*transp = 0;
return 0;
}
/*
* Set a single color register. The values supplied are already
* rounded down to the hardware's capabilities (according to the
* entries in the var structure). Return != 0 for invalid regno.
*/
static int fm2fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
u_int transp, struct fb_info *info)
{
if (regno > 15)
return 1;
red >>= 8;
green >>= 8;
blue >>= 8;
palette[regno].red = red;
palette[regno].green = green;
palette[regno].blue = blue;
#ifdef FBCON_HAS_CFB32
fbcon_cfb32_cmap[regno] = (red << 16) | (green << 8) | blue;
#endif
return 0;
}
MODULE_LICENSE("GPL");
......@@ -28,13 +28,10 @@
#include <linux/fb.h>
#include <linux/init.h>
#include <linux/pci.h>
#include <linux/selection.h>
#include <linux/console.h>
#include <asm/io.h>
#include <asm/jazz.h>
#include <video/fbcon.h>
#include <video/fbcon-cfb8.h>
/*
* Various defines for the G364
......@@ -79,56 +76,61 @@
static struct display disp;
static struct fb_info fb_info;
static struct { u_char red, green, blue, pad; } palette[256];
static struct fb_fix_screeninfo fb_fix = { { "G364 8plane", } };
static struct fb_var_screeninfo fb_var = { 0, };
static struct fb_fix_screeninfo fb_fix __initdata = {
id: "G364 8plane",
smem_start: 0x40000000, /* physical address */
type: FB_TYPE_PACKED_PIXELS,
visual: FB_VISUAL_PSEUDOCOLOR,
ypanstep: 1,
accel: FB_ACCEL_NONE,
};
static struct fb_var_screeninfo fb_var __initdata = {
bits_per_pixel: 8,
red: { 0, 8, 0 },
green: { 0, 8, 0 },
blue: { 0, 8, 0 },
activate: FB_ACTIVATE_NOW,
height: -1,
width: -1,
pixclock: 39722,
left_margin: 40,
right_margin: 24,
upper_margin: 32,
lower_margin: 11,
hsync_len: 96,
vsync_len: 2,
vmode: FB_VMODE_NONINTERLACED,
};
/*
* Interface used by the world
*/
static int g364fb_get_fix(struct fb_fix_screeninfo *fix, int con,
struct fb_info *info);
static int g364fb_get_var(struct fb_var_screeninfo *var, int con,
struct fb_info *info);
static int g364fb_set_var(struct fb_var_screeninfo *var, int con,
struct fb_info *info);
int g364fb_init(void);
static int g364fb_pan_display(struct fb_var_screeninfo *var, int con,
struct fb_info *info);
static int g364fb_get_cmap(struct fb_cmap *cmap, int kspc, int con,
static int g364fb_setcolreg(u_int regno, u_int red, u_int green,
u_int blue, u_int transp,
struct fb_info *info);
static int g364fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
u_int transp, struct fb_info *info);
static int g364fb_blank(int blank, struct fb_info *info);
/*
* Interface to the low level console driver
*/
int g364fb_init(void);
static int g364fbcon_switch(int con, struct fb_info *info);
static int g364fbcon_updatevar(int con, struct fb_info *info);
/*
* Internal routines
*/
static int g364fb_getcolreg(u_int regno, u_int *red, u_int *green, u_int *blue,
u_int *transp, struct fb_info *info);
static struct fb_ops g364fb_ops = {
owner: THIS_MODULE,
fb_get_fix: g364fb_get_fix,
fb_get_var: g364fb_get_var,
fb_set_var: g364fb_set_var,
fb_get_cmap: g364fb_get_cmap,
fb_get_fix: gen_get_fix,
fb_get_var: gen_get_var,
fb_set_var: gen_set_var,
fb_get_cmap: gen_get_cmap,
fb_set_cmap: gen_set_cmap,
fb_setcolreg: g364fb_setcolreg,
fb_pan_display: g364fb_pan_display,
fb_blank: g364fb_blank,
fb_fillrect: cfb_fillrect,
fb_copyarea: cfb_copyarea,
fb_imageblit: cfb_imageblit,
};
void fbcon_g364fb_cursor(struct display *p, int mode, int x, int y)
{
switch (mode) {
......@@ -139,111 +141,57 @@ void fbcon_g364fb_cursor(struct display *p, int mode, int x, int y)
case CM_MOVE:
case CM_DRAW:
*(unsigned int *) CTLA_REG &= ~CURS_TOGGLE;
*(unsigned int *) CURS_POS_REG = ((x * fontwidth(p)) << 12) | ((y * fontheight(p))-p->var.yoffset);
*(unsigned int *) CURS_POS_REG =
((x * fontwidth(p)) << 12) | ((y * fontheight(p)) -
p->var.yoffset);
break;
}
}
static struct display_switch fbcon_g364cfb8 = {
setup: fbcon_cfb8_setup,
bmove: fbcon_cfb8_bmove,
clear: fbcon_cfb8_clear,
putc: fbcon_cfb8_putc,
putcs: fbcon_cfb8_putcs,
revc: fbcon_cfb8_revc,
cursor: fbcon_g364fb_cursor,
clear_margins: fbcon_cfb8_clear_margins,
fontwidthmask: FONTWIDTH(8)
};
/*
* Get the Fixed Part of the Display
* Pan or Wrap the Display
*
* This call looks only at xoffset, yoffset and the FB_VMODE_YWRAP flag
*/
static int g364fb_get_fix(struct fb_fix_screeninfo *fix, int con,
static int g364fb_pan_display(struct fb_var_screeninfo *var, int con,
struct fb_info *info)
{
memcpy(fix, &fb_fix, sizeof(fb_fix));
return 0;
}
if (var->xoffset || var->yoffset + var->yres > var->yres_virtual)
return -EINVAL;
/*
* Get the User Defined Part of the Display
*/
static int g364fb_get_var(struct fb_var_screeninfo *var, int con,
struct fb_info *info)
{
memcpy(var, &fb_var, sizeof(fb_var));
*(unsigned int *) TOP_REG = var->yoffset * var->xres;
return 0;
}
/*
* Set the User Defined Part of the Display
* Blank the display.
*/
static int g364fb_set_var(struct fb_var_screeninfo *var, int con,
struct fb_info *info)
static int g364fb_blank(int blank, struct fb_info *info)
{
struct display *display;
int oldbpp = -1, err;
if (con >= 0)
display = &fb_display[con];
if (blank)
*(unsigned int *) CTLA_REG |= FORCE_BLANK;
else
display = &disp; /* used during initialization */
if (var->xres > fb_var.xres || var->yres > fb_var.yres ||
var->xres_virtual > fb_var.xres_virtual ||
var->yres_virtual > fb_var.yres_virtual ||
var->bits_per_pixel > fb_var.bits_per_pixel ||
var->nonstd ||
(var->vmode & FB_VMODE_MASK) != FB_VMODE_NONINTERLACED)
return -EINVAL;
memcpy(var, &fb_var, sizeof(fb_var));
if ((var->activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW) {
oldbpp = display->var.bits_per_pixel;
display->var = *var;
*(unsigned int *)TOP_REG = var->yoffset * var->xres;
}
if (oldbpp != var->bits_per_pixel) {
if ((err = fb_alloc_cmap(&display->cmap, 0, 0)))
return err;
do_install_cmap(con, info);
}
*(unsigned int *) CTLA_REG &= ~FORCE_BLANK;
return 0;
}
/*
* Pan or Wrap the Display
*
* This call looks only at xoffset, yoffset and the FB_VMODE_YWRAP flag
* Set a single color register. Return != 0 for invalid regno.
*/
static int g364fb_pan_display(struct fb_var_screeninfo *var, int con,
struct fb_info *info)
static int g364fb_setcolreg(u_int regno, u_int red, u_int green,
u_int blue, u_int transp, struct fb_info *info)
{
if (var->xoffset || var->yoffset+var->yres > var->yres_virtual)
return -EINVAL;
volatile unsigned int *ptr = (volatile unsigned int *) CLR_PAL_REG;
*(unsigned int *)TOP_REG = var->yoffset * var->xres;
return 0;
}
if (regno > 255)
return 1;
red >>= 8;
green >>= 8;
blue >>= 8;
ptr[regno << 1] = (red << 16) | (green << 8) | blue;
/*
* Get the Colormap
*/
static int g364fb_get_cmap(struct fb_cmap *cmap, int kspc, int con,
struct fb_info *info)
{
if (con == info->currcon) /* current console? */
return fb_get_cmap(cmap, kspc, g364fb_getcolreg, info);
else if (fb_display[con].cmap.len) /* non default colormap? */
fb_copy_cmap(&fb_display[con].cmap, cmap, kspc ? 0 : 2);
else
fb_copy_cmap(fb_default_cmap(1<<fb_display[con].var.bits_per_pixel),
cmap, kspc ? 0 : 2);
return 0;
}
......@@ -252,28 +200,21 @@ static int g364fb_get_cmap(struct fb_cmap *cmap, int kspc, int con,
*/
int __init g364fb_init(void)
{
int i,j;
volatile unsigned int *pal_ptr = (volatile unsigned int *) CLR_PAL_REG;
volatile unsigned int *curs_pal_ptr = (volatile unsigned int *) CURS_PAL_REG;
unsigned int xres, yres;
int mem;
volatile unsigned int *pal_ptr =
(volatile unsigned int *) CLR_PAL_REG;
volatile unsigned int *curs_pal_ptr =
(volatile unsigned int *) CURS_PAL_REG;
int mem, i, j;
/* TBD: G364 detection */
/* get the resolution set by ARC console */
*(volatile unsigned int *)CTLA_REG &= ~ENABLE_VTG;
xres = (*((volatile unsigned int*)DISPLAY_REG) & 0x00ffffff) * 4;
yres = (*((volatile unsigned int*)VDISPLAY_REG) & 0x00ffffff) / 2;
*(volatile unsigned int *)CTLA_REG |= ENABLE_VTG;
/* initialise color palette */
for (i = 0; i < 16; i++) {
j = color_table[i];
palette[i].red=default_red[j];
palette[i].green=default_grn[j];
palette[i].blue=default_blu[j];
pal_ptr[i << 1] = (palette[i].red << 16) | (palette[i].green << 8) | palette[i].blue;
}
*(volatile unsigned int *) CTLA_REG &= ~ENABLE_VTG;
fb_var.xres =
(*((volatile unsigned int *) DISPLAY_REG) & 0x00ffffff) * 4;
fb_var.yres =
(*((volatile unsigned int *) VDISPLAY_REG) & 0x00ffffff) / 2;
*(volatile unsigned int *) CTLA_REG |= ENABLE_VTG;
/* setup cursor */
curs_pal_ptr[0] |= 0x00ffffff;
......@@ -284,171 +225,45 @@ int __init g364fb_init(void)
* first set the whole cursor to transparent
*/
for (i = 0; i < 512; i++)
*(unsigned short *)(CURS_PAT_REG+i*8) = 0;
*(unsigned short *) (CURS_PAT_REG + i * 8) = 0;
/*
* switch the last two lines to cursor palette 3
* we assume here, that FONTSIZE_X is 8
*/
*(unsigned short *)(CURS_PAT_REG + 14*64) = 0xffff;
*(unsigned short *)(CURS_PAT_REG + 15*64) = 0xffff;
fb_var.bits_per_pixel = 8;
fb_var.xres = fb_var.xres_virtual = xres;
fb_var.yres = yres;
*(unsigned short *) (CURS_PAT_REG + 14 * 64) = 0xffff;
*(unsigned short *) (CURS_PAT_REG + 15 * 64) = 0xffff;
fb_var.xres_virtual = fbvar.xres;
fb_fix.line_length = (xres / 8) * fb_var.bits_per_pixel;
fb_fix.smem_start = 0x40000000; /* physical address */
/* get size of video memory; this is special for the JAZZ hardware */
mem = (r4030_read_reg32(JAZZ_R4030_CONFIG) >> 8) & 3;
fb_fix.smem_len = (1 << (mem*2)) * 512 * 1024;
fb_fix.type = FB_TYPE_PACKED_PIXELS;
fb_fix.type_aux = 0;
fb_fix.visual = FB_VISUAL_PSEUDOCOLOR;
fb_fix.xpanstep = 0;
fb_fix.ypanstep = 1;
fb_fix.ywrapstep = 0;
fb_fix.mmio_start = 0;
fb_fix.mmio_len = 0;
fb_fix.accel = FB_ACCEL_NONE;
fb_var.yres_virtual = fb_fix.smem_len / xres;
fb_var.xoffset = fb_var.yoffset = 0;
fb_var.grayscale = 0;
fb_var.red.offset = 0;
fb_var.green.offset = 0;
fb_var.blue.offset = 0;
fb_var.red.length = fb_var.green.length = fb_var.blue.length = 8;
fb_var.red.msb_right = fb_var.green.msb_right = fb_var.blue.msb_right = 0;
fb_var.transp.offset = fb_var.transp.length = fb_var.transp.msb_right = 0;
fb_var.nonstd = 0;
fb_var.activate = 0;
fb_var.height = fb_var.width = -1;
fb_var.accel_flags = 0;
fb_var.pixclock = 39722;
fb_var.left_margin = 40;
fb_var.right_margin = 24;
fb_var.upper_margin = 32;
fb_var.lower_margin = 11;
fb_var.hsync_len = 96;
fb_var.vsync_len = 2;
fb_var.sync = 0;
fb_var.vmode = FB_VMODE_NONINTERLACED;
disp.var = fb_var;
disp.cmap.start = 0;
disp.cmap.len = 0;
disp.cmap.red = disp.cmap.green = disp.cmap.blue = disp.cmap.transp = NULL;
disp.visual = fb_fix.visual;
disp.type = fb_fix.type;
disp.type_aux = fb_fix.type_aux;
disp.ypanstep = fb_fix.ypanstep;
disp.ywrapstep = fb_fix.ywrapstep;
disp.line_length = fb_fix.line_length;
disp.can_soft_blank = 1;
disp.inverse = 0;
disp.dispsw = &fbcon_g364cfb8;
fb_fix.smem_len = (1 << (mem * 2)) * 512 * 1024;
fb_var.yres_virtual = fb_fix.smem_len / fb_var.xres;
strcpy(fb_info.modename, fb_fix.id);
fb_info.node = NODEV;
fb_info.fbops = &g364fb_ops;
fb_info.screen_base = (char *)G364_MEM_BASE; /* virtual kernel address */
fb_info.screen_base = (char *) G364_MEM_BASE; /* virtual kernel address */
fb_info.var = fb_var;
fb_info.fix = fb_fix;
fb_info.flags = FBINFO_FLAG_DEFAULT;
fb_info.disp = &disp;
fb_info.currcon = -1;
fb_info.fontname[0] = '\0';
fb_info.changevar = NULL;
fb_info.switch_con = &g364fbcon_switch;
fb_info.updatevar = &g364fbcon_updatevar;
fb_info.flags = FBINFO_FLAG_DEFAULT;
fb_info.switch_con = gen_switch;
fb_info.updatevar = gen_update_var;
g364fb_set_var(&fb_var, -1, &fb_info);
fb_alloc_cmap(&fb_info.cmap, 255, 0);
gen_set_disp(-1, &fb_info);
if (register_framebuffer(&fb_info) < 0)
return -EINVAL;
printk("fb%d: %s frame buffer device\n", GET_FB_IDX(fb_info.node),
fb_fix.id);
return 0;
}
static int g364fbcon_switch(int con, struct fb_info *info)
{
/* Do we have to save the colormap? */
if (fb_display[info->currcon].cmap.len)
fb_get_cmap(&fb_display[info->currcon].cmap, 1, g364fb_getcolreg, info);
info->currcon = con;
/* Install new colormap */
do_install_cmap(con, info);
g364fbcon_updatevar(con, info);
return 0;
}
/*
* Update the `var' structure (called by fbcon.c)
*/
static int g364fbcon_updatevar(int con, struct fb_info *info)
{
if (con == info->currcon) {
struct fb_var_screeninfo *var = &fb_display[info->currcon].var;
/* hardware scrolling */
*(unsigned int *)TOP_REG = var->yoffset * var->xres;
}
return 0;
}
/*
* Blank the display.
*/
static int g364fb_blank(int blank, struct fb_info *info)
{
if (blank)
*(unsigned int *) CTLA_REG |= FORCE_BLANK;
else
*(unsigned int *) CTLA_REG &= ~FORCE_BLANK;
return 0;
}
/*
* Read a single color register and split it into
* colors/transparent. Return != 0 for invalid regno.
*/
static int g364fb_getcolreg(u_int regno, u_int *red, u_int *green, u_int *blue,
u_int *transp, struct fb_info *info)
{
if (regno > 255)
return 1;
*red = (palette[regno].red << 8) | palette[regno].red;
*green = (palette[regno].green << 8) | palette[regno].green;
*blue = (palette[regno].blue << 8) | palette[regno].blue;
*transp = 0;
return 0;
}
/*
* Set a single color register. Return != 0 for invalid regno.
*/
static int g364fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
u_int transp, struct fb_info *info)
{
volatile unsigned int *ptr = (volatile unsigned int *) CLR_PAL_REG;
if (regno > 255)
return 1;
red >>= 8;
green >>= 8;
blue >>=8;
palette[regno].red = red;
palette[regno].green = green;
palette[regno].blue = blue;
ptr[regno << 1] = (red << 16) | (green << 8) | blue;
fb_info.fix.id);
return 0;
}
......
......@@ -386,44 +386,6 @@ static int __init hga_card_detect(void)
*
* ------------------------------------------------------------------------- */
/**
* hga_get_fix - get the fixed part of the display
* @fix:struct fb_fix_screeninfo to fill in
* @con:unused
* @info:pointer to fb_info object containing info for current hga board
*
* This wrapper function copies @info->fix to @fix.
* A zero is returned on success and %-EINVAL for failure.
*/
int hga_get_fix(struct fb_fix_screeninfo *fix, int con, struct fb_info *info)
{
CHKINFO(-EINVAL);
DPRINTK("hga_get_fix: con:%d, info:%x, fb_info:%x\n", con, (unsigned)info, (unsigned)&fb_info);
*fix = info->fix;
return 0;
}
/**
* hga_get_var - get the user defined part of the display
* @var:struct fb_var_screeninfo to fill in
* @con:unused
* @info:pointer to fb_info object containing info for current hga board
*
* This wrapper function copies @info->var to @var.
* A zero is returned on success and %-EINVAL for failure.
*/
int hga_get_var(struct fb_var_screeninfo *var, int con, struct fb_info *info)
{
CHKINFO(-EINVAL);
DPRINTK("hga_get_var: con:%d, info:%x, fb_info:%x\n", con, (unsigned)info, (unsigned)&fb_info);
*var = info->var;
return 0;
}
/**
* hga_set_var - set the user defined part of the display
* @var:new video mode
......@@ -596,8 +558,8 @@ static int hgafb_blank(int blank_mode, struct fb_info *info)
static struct fb_ops hgafb_ops = {
owner: THIS_MODULE,
fb_get_fix: hga_get_fix,
fb_get_var: hga_get_var,
fb_get_fix: gen_get_fix,
fb_get_var: gen_get_var,
fb_set_var: hga_set_var,
fb_get_cmap: hga_get_cmap,
fb_set_cmap: gen_set_cmap,
......
......@@ -21,6 +21,7 @@
#include <linux/delay.h>
#include <linux/nubus.h>
#include <linux/init.h>
#include <linux/fb.h>
#include <asm/machvec.h>
#include <asm/uaccess.h>
......@@ -28,156 +29,32 @@
#include <asm/io.h>
#include <asm/hd64461.h>
#include <linux/fb.h>
#include <video/fbcon.h>
#include <video/fbcon-cfb8.h>
#include <video/fbcon-cfb16.h>
struct hitfb_par
{
int x, y;
int bpp;
static struct fb_var_screeninfo hitfb_var __initdata = {
activate: FB_ACTIVATE_NOW,
height: -1,
width: -1,
vmode: FB_VMODE_NONINTERLACED,
};
struct hitfb_info {
struct fb_info_gen gen;
struct display disp;
struct hitfb_par current_par;
struct fb_var_screeninfo default_var;
int current_par_valid;
unsigned long hit_videobase, hit_videosize;
union {
#ifdef FBCON_HAS_CFB16
u16 cfb16[16];
#endif
} fbcon_cmap;
} fb_info = {
{},
{},
{},
{},
0, 0, 0,
{},
static struct fb_fix_screeninfo hitfb_fix __initdata = {
id: "Hitachi HD64461",
type: FB_TYPE_PACKED_PIXELS,
visual: FB_VISUAL_TRUECOLOR,
accel_flags: FB_ACCEL_NONE,
};
static u16 pseudo_palette[17];
static struct display display;
struct fb_info fb_info;
static void hitfb_set_par(const void *fb_par, struct fb_info_gen *info);
static int hitfb_encode_var(struct fb_var_screeninfo *var, const void *fb_par,
struct fb_info_gen *info);
static void hitfb_detect(void)
{
struct hitfb_par par;
unsigned short lcdclor, ldr3, ldvntr;
fb_info.hit_videobase = CONFIG_HD64461_IOBASE + 0x02000000;
fb_info.hit_videosize = (MACH_HP680 || MACH_HP690) ? 1024*1024 : 512*1024;
lcdclor = inw(HD64461_LCDCLOR);
ldvntr = inw(HD64461_LDVNTR);
ldr3 = inw(HD64461_LDR3);
switch(ldr3&15) {
default:
case 4:
par.bpp = 8;
par.x = lcdclor;
break;
case 8:
par.bpp = 16;
par.x = lcdclor/2;
break;
}
par.y = ldvntr+1;
hitfb_set_par(&par, NULL);
hitfb_encode_var(&fb_info.default_var, &par, NULL);
}
static int hitfb_encode_fix(struct fb_fix_screeninfo *fix, const void *fb_par,
struct fb_info_gen *info)
static int hitfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
{
const struct hitfb_par *par = fb_par;
memset(fix, 0, sizeof(struct fb_fix_screeninfo));
strcpy(fix->id, "Hitachi HD64461");
fix->smem_start = fb_info.hit_videobase;
fix->smem_len = fb_info.hit_videosize;
fix->type = FB_TYPE_PACKED_PIXELS;
fix->type_aux = 0;
fix->visual = (par->bpp == 8) ?
FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR;
fix->xpanstep = 0;
fix->ypanstep = 0;
fix->ywrapstep = 0;
switch(par->bpp) {
default:
case 8:
fix->line_length = par->x;
break;
case 16:
fix->line_length = par->x*2;
break;
}
return 0;
}
static int hitfb_decode_var(const struct fb_var_screeninfo *var, void *fb_par,
struct fb_info_gen *info)
{
struct hitfb_par *par = fb_par;
par->x = var->xres;
par->y = var->yres;
par->bpp = var->bits_per_pixel;
return 0;
}
static int hitfb_encode_var(struct fb_var_screeninfo *var, const void *fb_par,
struct fb_info_gen *info)
{
const struct hitfb_par *par = fb_par;
memset(var, 0, sizeof(*var));
var->xres = par->x;
var->yres = par->y;
var->xres_virtual = var->xres;
var->yres_virtual = var->yres;
var->xoffset = 0;
var->yoffset = 0;
var->bits_per_pixel = par->bpp;
var->grayscale = 0;
var->transp.offset = 0;
var->transp.length = 0;
var->transp.msb_right = 0;
var->nonstd = 0;
var->activate = 0;
var->height = -1;
var->width = -1;
var->vmode = FB_VMODE_NONINTERLACED;
var->pixclock = 0;
var->sync = 0;
var->left_margin = 0;
var->right_margin = 0;
var->upper_margin = 0;
var->lower_margin = 0;
var->hsync_len = 0;
var->vsync_len = 0;
switch (var->bits_per_pixel) {
case 8:
var->red.offset = 0;
var->red.length = 8;
......@@ -188,7 +65,6 @@ static int hitfb_encode_var(struct fb_var_screeninfo *var, const void *fb_par,
var->transp.offset = 0;
var->transp.length = 0;
break;
case 16: /* RGB 565 */
var->red.offset = 11;
var->red.length = 5;
......@@ -200,47 +76,26 @@ static int hitfb_encode_var(struct fb_var_screeninfo *var, const void *fb_par,
var->transp.length = 0;
break;
}
var->red.msb_right = 0;
var->green.msb_right = 0;
var->blue.msb_right = 0;
var->transp.msb_right = 0;
return 0;
}
static void hitfb_get_par(void *par, struct fb_info_gen *info)
{
*(struct hitfb_par *)par = fb_info.current_par;
}
static void hitfb_set_par(const void *fb_par, struct fb_info_gen *info)
{
const struct hitfb_par *par = fb_par;
fb_info.current_par = *par;
fb_info.current_par_valid = 1;
}
static int hitfb_getcolreg(unsigned regno, unsigned *red, unsigned *green,
unsigned *blue, unsigned *transp,
struct fb_info *info)
static int hitfb_set_par(struct fb_info *info)
{
if (regno > 255)
return 1;
outw(regno<<8, HD64461_CPTRAR);
*red = inw(HD64461_CPTRDR)<<10;
*green = inw(HD64461_CPTRDR)<<10;
*blue = inw(HD64461_CPTRDR)<<10;
*transp = 0;
info->fix.visual = (info->var.bits_per_pixel == 8) ?
FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR;
switch(info->var.bits_per_pixel) {
default:
case 8:
info->fix.line_length = info->var.xres;
break;
case 16:
info->fix.line_length = info->var.xres*2;
break;
}
return 0;
}
static int hitfb_setcolreg(unsigned regno, unsigned red, unsigned green,
unsigned blue, unsigned transp,
struct fb_info *info)
......@@ -248,16 +103,16 @@ static int hitfb_setcolreg(unsigned regno, unsigned red, unsigned green,
if (regno > 255)
return 1;
outw(regno<<8, HD64461_CPTWAR);
outw(red>>10, HD64461_CPTWDR);
outw(green>>10, HD64461_CPTWDR);
outw(blue>>10, HD64461_CPTWDR);
outw(regno << 8, HD64461_CPTWAR);
outw(red >> 10, HD64461_CPTWDR);
outw(green >> 10, HD64461_CPTWDR);
outw(blue >> 10, HD64461_CPTWDR);
if(regno<16) {
switch(fb_info.current_par.bpp) {
if (regno < 16) {
switch(info->var.bits_per_pixel) {
#ifdef FBCON_HAS_CFB16
case 16:
fb_info.fbcon_cmap.cfb16[regno] =
((u16 *)(info->pseudo_palette))[regno] =
((red & 0xf800) ) |
((green & 0xfc00) >> 5) |
((blue & 0xf800) >> 11);
......@@ -265,109 +120,73 @@ static int hitfb_setcolreg(unsigned regno, unsigned red, unsigned green,
#endif
}
}
return 0;
}
static int hitfb_pan_display(const struct fb_var_screeninfo *var,
struct fb_info_gen *info)
{
if (!fb_info.current_par_valid)
return -EINVAL;
return 0;
}
static struct fb_ops hitfb_ops = {
owner: THIS_MODULE,
fb_get_fix: gen_get_fix,
fb_get_var: gen_get_var,
fb_set_var: gen_set_var,
fb_get_cmap: gen_get_cmap,
fb_set_cmap: gen_set_cmap,
fb_check_var: hitfb_check_var,
fb_set_par: hitfb_set_par,
fb_setcolreg: hitfb_setcolreg,
fb_fillrect: cfb_fillrect,
fb_copyarea: cfb_copyarea,
fb_imageblit: cfb_imageblit,
};
static int hitfb_blank(int blank_mode, struct fb_info_gen *info)
int __init hitfb_init(void)
{
if (!fb_info.current_par_valid)
return 1;
return 0;
}
unsigned short lcdclor, ldr3, ldvntr;
static void hitfb_set_disp(const void *fb_par, struct display *disp,
struct fb_info_gen *info)
{
const struct hitfb_par *par = fb_par;
hitfb_fix.smem_start = CONFIG_HD64461_IOBASE + 0x02000000;
hitfb_fix.smem_len = (MACH_HP680 || MACH_HP690) ? 1024*1024 : 512*1024;
disp->scrollmode = SCROLL_YREDRAW;
lcdclor = inw(HD64461_LCDCLOR);
ldvntr = inw(HD64461_LDVNTR);
ldr3 = inw(HD64461_LDR3);
switch(((struct hitfb_par *)par)->bpp) {
#ifdef FBCON_HAS_CFB8
case 8:
disp->dispsw = &fbcon_cfb8;
switch (ldr3&15) {
default:
case 4:
hitfb_var.bits_per_pixel = 8;
hitfb_var.xres = lcdclor;
break;
#endif
#ifdef FBCON_HAS_CFB16
case 16:
disp->dispsw = &fbcon_cfb16;
disp->dispsw_data = fb_info.fbcon_cmap.cfb16;
case 8:
hitfb_var.bits_per_pixel = 16;
hitfb_var.xres = lcdclor/2;
break;
#endif
default:
disp->dispsw = &fbcon_dummy;
}
}
hitfb_var.yres = ldvntr+1;
fb_info.node = NODEV;
fb_info.fbops = &hitfb_ops;
fb_info.var = hitfb_var;
fb_info.fix = hitfb_fix;
fb_info.pseudo_palette = pseudo_palette;
fb_info.flags = FBINFO_FLAG_DEFAULT;
struct fbgen_hwswitch hitfb_switch = {
hitfb_detect,
hitfb_encode_fix,
hitfb_decode_var,
hitfb_encode_var,
hitfb_get_par,
hitfb_set_par,
hitfb_getcolreg,
hitfb_pan_display,
hitfb_blank,
hitfb_set_disp
};
strcpy(fb_info.modename, fb_info.fix.id);
fb_info.currcon = -1;
fb_info.disp = &display;
fb_info.changevar = NULL;
fb_info.switch_con = gen_switch;
fb_info.updatevar = gen_update_var;
fb_info.screen_base = (void *) hitfb_fix.smem_start;
static struct fb_ops hitfb_ops = {
owner: THIS_MODULE,
fb_get_fix: fbgen_get_fix,
fb_get_var: fbgen_get_var,
fb_set_var: fbgen_set_var,
fb_get_cmap: fbgen_get_cmap,
fb_set_cmap: fbgen_set_cmap,
fb_setcolreg: hitfb_setcolreg,
fb_pan_display: fbgen_pan_display,
fb_blank: fbgen_blank,
};
size = (fb_info.var.bits_per_pixel == 8) ? 256 : 16;
fb_alloc_cmap(&fb_info.cmap, size, 0);
gen_set_var(&fb_info.var, -1, &fb_info);
int __init hitfb_init(void)
{
strcpy(fb_info.gen.info.modename, "Hitachi HD64461");
fb_info.gen.info.node = NODEV;
fb_info.gen.info.flags = FBINFO_FLAG_DEFAULT;
fb_info.gen.info.fbops = &hitfb_ops;
fb_info.gen.info.disp = &fb_info.disp;
fb_info.gen.info.currcon = 1;
fb_info.gen.info.changevar = NULL;
fb_info.gen.info.switch_con = &fbgen_switch;
fb_info.gen.info.updatevar = &fbgen_update_var;
fb_info.gen.parsize = sizeof(struct hitfb_par);
fb_info.gen.fbhw = &hitfb_switch;
fb_info.gen.fbhw->detect();
fb_info.screen_base = (void *)fb_info.hit_videobase;
fbgen_get_var(&fb_info.disp.var, -1, &fb_info.gen.info);
fb_info.disp.var.activate = FB_ACTIVATE_NOW;
fbgen_do_set_var(&fb_info.disp.var, 1, &fb_info.gen);
fbgen_set_disp(-1, &fb_info.gen);
do_install_cmap(0, &fb_info.gen);
if(register_framebuffer(&fb_info.gen.info)<0) return -EINVAL;
if (register_framebuffer(&fb_info) < 0)
return -EINVAL;
printk(KERN_INFO "fb%d: %s frame buffer device\n",
GET_FB_IDX(fb_info.gen.info.node), fb_info.gen.info.modename);
GET_FB_IDX(fb_info.node), fb_info.fix.id);
return 0;
}
......@@ -392,7 +211,6 @@ void cleanup_module(void)
}
#endif
/*
* Local variables:
* c-basic-offset: 4
......
/*
* HP300 Topcat framebuffer support (derived from macfb of all things)
* Phil Blundell <philb@gnu.org> 1998
*
* Should this be moved to drivers/dio/video/ ? -- Peter Maydell
* No! -- Jes
*/
#include <linux/module.h>
......@@ -23,15 +20,9 @@
#include <asm/hwtest.h>
#include <video/fbcon.h>
#include <video/fbcon-mfb.h>
#include <video/fbcon-cfb2.h>
#include <video/fbcon-cfb4.h>
#include <video/fbcon-cfb8.h>
static struct display disp;
static struct fb_info fb_info;
unsigned long fb_start, fb_size = 1024*768, fb_line_length = 1024;
unsigned long fb_regs;
unsigned char fb_bitmask;
......@@ -51,216 +42,77 @@ unsigned char fb_bitmask;
#define WWIDTH 0x4102
#define WMOVE 0x409c
static struct fb_var_screeninfo hpfb_defined = {
0,0,0,0, /* W,H, W, H (virtual) load xres,xres_virtual*/
0,0, /* virtual -> visible no offset */
0, /* depth -> load bits_per_pixel */
0, /* greyscale ? */
{0,2,0}, /* R */
{0,2,0}, /* G */
{0,2,0}, /* B */
{0,0,0}, /* transparency */
0, /* standard pixel format */
FB_ACTIVATE_NOW,
274,195, /* 14" monitor */
FB_ACCEL_NONE,
0L,0L,0L,0L,0L,
0L,0L,0, /* No sync info */
FB_VMODE_NONINTERLACED,
{0,0,0,0,0,0}
};
static struct fb_fix_screeninfo hpfb_fix __initdata = {
id: "HP300 Topcat",
smem_len: 1024*768,
type: FB_TYPE_PACKED_PIXELS,
visual: FB_VISUAL_PSEUDOCOLOR,
line_length: 1024,
accel: FB_ACCEL_NONE,
struct hpfb_par
{
static struct fb_var_screeninfo hpfb_defined = {
xres: 1024,
yres: 768,
xres_virtual: 1024,
yres_virtual: 786,
bits_per_pixel: 1,
red: {0,2,0}, /* R */
green: {0,2,0}, /* G */
blue: {0,2,0}, /* B */
activate: FB_ACTIVATE_NOW,
height: 274,
width: 195, /* 14" monitor */
accel_flags: FB_ACCEL_NONE,
vmode: FB_VMODE_NONINTERLACED,
};
struct hpfb_par current_par;
static void hpfb_encode_var(struct fb_var_screeninfo *var,
struct hpfb_par *par)
{
int i=0;
var->xres=1024;
var->yres=768;
var->xres_virtual=1024;
var->yres_virtual=768;
var->xoffset=0;
var->yoffset=0;
var->bits_per_pixel = 1;
var->grayscale=0;
var->transp.offset=0;
var->transp.length=0;
var->transp.msb_right=0;
var->nonstd=0;
var->activate=0;
var->height= -1;
var->width= -1;
var->vmode=FB_VMODE_NONINTERLACED;
var->pixclock=0;
var->sync=0;
var->left_margin=0;
var->right_margin=0;
var->upper_margin=0;
var->lower_margin=0;
var->hsync_len=0;
var->vsync_len=0;
for(i=0;i<ARRAY_SIZE(var->reserved);i++)
var->reserved[i]=0;
}
static void hpfb_get_par(struct hpfb_par *par)
{
*par=current_par;
}
static int fb_update_var(int con, struct fb_info *info)
{
return 0;
}
static int do_fb_set_var(struct fb_var_screeninfo *var, int isactive)
{
struct hpfb_par par;
hpfb_get_par(&par);
hpfb_encode_var(var, &par);
return 0;
}
static int hpfb_get_cmap(struct fb_cmap *cmap, int kspc, int con,
struct fb_info *info)
{
return 0;
}
static struct display display;
/*
* Set the palette. This may not work on all boards but only experimentation will tell.
* Set the palette. This may not work on all boards but only experimentation
* will tell.
* XXX Doesn't work at all.
*/
static int hpfb_set_cmap(struct fb_cmap *cmap, int kspc, int con,
static int hpfb_setcolreg(unsigned regno, unsigned red, unsigned green,
unsigned blue, unsigned transp,
struct fb_info *info)
{
unsigned int i;
for (i = 0; i < cmap->len; i++)
{
while (readw(fb_regs + 0x6002) & 0x4) udelay(1);
writew(0, fb_regs + 0x60f0);
writew(cmap->start + i, fb_regs + 0x60b8);
writew(cmap->red[i], fb_regs + 0x60b2);
writew(cmap->green[i], fb_regs + 0x60b4);
writew(cmap->blue[i], fb_regs + 0x60b6);
writew(regno, fb_regs + 0x60b8);
writew(red, fb_regs + 0x60b2);
writew(green, fb_regs + 0x60b4);
writew(blue, fb_regs + 0x60b6);
writew(0xff, fb_regs + 0x60f0);
udelay(100);
}
writew(0xffff, fb_regs + 0x60ba);
return 0;
}
static int hpfb_get_var(struct fb_var_screeninfo *var, int con,
struct fb_info *info)
{
struct hpfb_par par;
if(con==-1)
{
hpfb_get_par(&par);
hpfb_encode_var(var, &par);
}
else
*var=fb_display[con].var;
return 0;
}
static int hpfb_set_var(struct fb_var_screeninfo *var, int con,
struct fb_info *info)
{
int err;
if ((err=do_fb_set_var(var, 1)))
return err;
return 0;
}
static void hpfb_encode_fix(struct fb_fix_screeninfo *fix,
struct hpfb_par *par)
{
memset(fix, 0, sizeof(struct fb_fix_screeninfo));
strcpy(fix->id, "HP300 Topcat");
/*
* X works, but screen wraps ...
*/
fix->smem_start=fb_start;
fix->smem_len=fb_size;
fix->type = FB_TYPE_PACKED_PIXELS;
fix->visual = FB_VISUAL_PSEUDOCOLOR;
fix->xpanstep=0;
fix->ypanstep=0;
fix->ywrapstep=0;
fix->line_length=fb_line_length;
}
static int hpfb_get_fix(struct fb_fix_screeninfo *fix, int con,
struct fb_info *info)
{
struct hpfb_par par;
hpfb_get_par(&par);
hpfb_encode_fix(fix, &par);
return 0;
}
static void topcat_blit(int x0, int y0, int x1, int y1, int w, int h)
void hpfb_copyarea(struct fb_info *info, struct fb_copyarea *area)
{
while (readb(fb_regs + BUSY) & fb_bitmask);
writeb(0x3, fb_regs + WMRR);
writew(x0, fb_regs + SOURCE_X);
writew(y0, fb_regs + SOURCE_Y);
writew(x1, fb_regs + DEST_X);
writew(y1, fb_regs + DEST_Y);
writew(h, fb_regs + WHEIGHT);
writew(w, fb_regs + WWIDTH);
writew(area->sx, fb_regs + SOURCE_X);
writew(area->sy, fb_regs + SOURCE_Y);
writew(area->dx, fb_regs + DEST_X);
writew(area->dy, fb_regs + DEST_Y);
writew(area->height, fb_regs + WHEIGHT);
writew(area->width, fb_regs + WWIDTH);
writeb(fb_bitmask, fb_regs + WMOVE);
}
static int hpfb_switch(int con, struct fb_info *info)
{
do_fb_set_var(&fb_display[con].var,1);
info->currcon = con;
return 0;
}
static void hpfb_set_disp(int con)
{
struct fb_fix_screeninfo fix;
struct display *display;
if (con >= 0)
display = &fb_display[con];
else
display = &disp; /* used during initialization */
hpfb_get_fix(&fix, con, 0);
display->visual = fix.visual;
display->type = fix.type;
display->type_aux = fix.type_aux;
display->ypanstep = fix.ypanstep;
display->ywrapstep = fix.ywrapstep;
display->line_length = fix.line_length;
display->next_line = fix.line_length;
display->can_soft_blank = 0;
display->inverse = 0;
display->dispsw = &fbcon_cfb8;
}
static struct fb_ops hpfb_ops = {
owner: THIS_MODULE,
fb_get_fix: hpfb_get_fix,
fb_get_var: hpfb_get_var,
fb_set_var: hpfb_set_var,
fb_get_cmap: hpfb_get_cmap,
fb_set_cmap: hpfb_set_cmap,
fb_get_fix: gen_get_fix,
fb_get_var: gen_get_var,
fb_set_var: gen_set_var,
fb_get_cmap: gen_get_cmap,
fb_set_cmap: gen_set_cmap,
fb_setcolreg: hpfb_setcolreg,
fb_fillrect: cfb_fillrect,
fb_copyarea: hpfb_copyarea,
fb_imageblit: cfb_imageblit,
};
#define TOPCAT_FBOMSB 0x5d
......@@ -273,7 +125,7 @@ int __init hpfb_init_one(unsigned long base)
fboff = (readb(base + TOPCAT_FBOMSB) << 8)
| readb(base + TOPCAT_FBOLSB);
fb_start = 0xf0000000 | (readb(base + fboff) << 16);
hpfb_fix.smem_start = 0xf0000000 | (readb(base + fboff) << 16);
fb_regs = base;
#if 0
......@@ -285,17 +137,6 @@ int __init hpfb_init_one(unsigned long base)
writeb(0, base+0x4516);
writeb(0x90, base+0x4206);
#endif
/*
* Fill in the available video resolution
*/
hpfb_defined.xres = 1024;
hpfb_defined.yres = 768;
hpfb_defined.xres_virtual = 1024;
hpfb_defined.yres_virtual = 768;
hpfb_defined.bits_per_pixel = 8;
/*
* Give the hardware a bit of a prod and work out how many bits per
* pixel are supported.
......@@ -303,8 +144,8 @@ int __init hpfb_init_one(unsigned long base)
writeb(0xff, base + TC_WEN);
writeb(0xff, base + TC_FBEN);
writeb(0xff, fb_start);
fb_bitmask = readb(fb_start);
writeb(0xff, hpfb_fix.smem_start);
fb_bitmask = readb(hpfb_fix.smem_start);
/*
* Enable reading/writing of all the planes.
......@@ -317,24 +158,25 @@ int __init hpfb_init_one(unsigned long base)
/*
* Let there be consoles..
*/
strcpy(fb_info.modename, "Topcat");
fb_info.changevar = NULL;
fb_info.node = NODEV;
fb_info.fbops = &hpfb_ops;
fb_info.screen_base = fb_start;
fb_info.disp = &disp;
fb_info.currcon = -1;
fb_info.switch_con = &hpfb_switch;
fb_info.updatevar = &fb_update_var;
fb_info.flags = FBINFO_FLAG_DEFAULT;
do_fb_set_var(&hpfb_defined, 1);
fb_info.var = hpfb_defined;
fb_info.fix = hpfb_fix;
fb_info.screen_base = hpfb_fix.smem_start;
/* The below feilds will go away !!!! */
fb_info.currcon = -1;
strcpy(fb_info.modename, fb_info.fix.id);
fb_info.disp = &display;
fb_info.switch_con = gen_switch;
fb_info.updatevar = gen_update_var;
fb_alloc_cmap(&fb_info.cmap, 256, 0);
hpfb_get_var(&disp.var, -1, &fb_info);
hpfb_set_disp(-1);
gen_set_disp(-1, &fb_info);
if (register_framebuffer(&fb_info) < 0)
return 1;
return 0;
}
......@@ -364,29 +206,25 @@ int __init hpfb_init(void)
*/
#define INTFBADDR 0xf0560000
if (hwreg_present((void *)INTFBADDR) && (DIO_ID(INTFBADDR) == DIO_ID_FBUFFER)
&& topcat_sid_ok(sid = DIO_SECID(INTFBADDR)))
{
if (hwreg_present((void *)INTFBADDR) &&
(DIO_ID(INTFBADDR) == DIO_ID_FBUFFER) &&
topcat_sid_ok(sid = DIO_SECID(INTFBADDR))) {
printk("Internal Topcat found (secondary id %02x)\n", sid);
hpfb_init_one(INTFBADDR);
}
else
{
} else {
int sc = dio_find(DIO_ID_FBUFFER);
if (sc)
{
if (sc) {
unsigned long addr = (unsigned long)dio_scodetoviraddr(sc);
unsigned int sid = DIO_SECID(addr);
if (topcat_sid_ok(sid))
{
if (topcat_sid_ok(sid)) {
printk("Topcat found at DIO select code %02x "
"(secondary id %02x)\n", sc, sid);
hpfb_init_one(addr);
}
}
}
return 0;
}
......
......@@ -67,9 +67,6 @@
#define DPRINTK(a,b...)
#endif
#define PICOS2KHZ(a) (1000000000UL/(a))
#define KHZ2PICOS(a) (1000000000UL/(a))
/*
* The _DEFINITIVE_ memory mapping/unmapping functions.
* This is due to the fact that they're changing soooo often...
......
This source diff could not be displayed because it is too large. You can view the blob instead.
/*
* linux/drivers/video/pm3fb.h -- 3DLabs Permedia3 frame buffer device
*
* Copyright (C) 2001 Romain Dolbeau <dolbeau@irisa.fr>
* Copyright (C) 2001 Sven Luther, <luther@dpt-info.u-strasbg.fr>
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file COPYING in the main directory of this archive for
* more details.
*
* $Header: /cvsroot/linux/drivers/video/pm3fb.h,v 1.1 2002/02/25 19:11:06 marcelo Exp $
*
*/
#ifndef PM3FB_H
#define PM3FB_H
/**********************************************
* GLINT Permedia3 Control Status registers *
***********************************************/
/* Control Status Registers */
#define PM3ResetStatus 0x0000
#define PM3IntEnable 0x0008
#define PM3IntFlags 0x0010
#define PM3InFIFOSpace 0x0018
#define PM3OutFIFOWords 0x0020
#define PM3DMAAddress 0x0028
#define PM3DMACount 0x0030
#define PM3ErrorFlags 0x0038
#define PM3VClkCtl 0x0040
#define PM3TestRegister 0x0048
#define PM3Aperture0 0x0050
#define PM3Aperture1 0x0058
#define PM3DMAControl 0x0060
#define PM3FIFODis 0x0068
#define PM3ChipConfig 0x0070
#define PM3AGPControl 0x0078
#define PM3GPOutDMAAddress 0x0080
#define PM3PCIFeedbackCount 0x0088
#define PM3PCIAbortStatus 0x0090
#define PM3PCIAbortAddress 0x0098
#define PM3PCIPLLStatus 0x00f0
#define PM3HostTextureAddress 0x0100
#define PM3TextureDownloadControl 0x0108
#define PM3TextureOperation 0x0110
#define PM3LogicalTexturePage 0x0118
#define PM3TexDMAAddress 0x0120
#define PM3TexFIFOSpace 0x0128
/**********************************************
* GLINT Permedia3 Region 0 Bypass Controls *
***********************************************/
#define PM3ByAperture1Mode 0x0300
#define PM3ByApertureMode_BYTESWAP_ABCD (0<<0)
#define PM3ByApertureMode_BYTESWAP_BADC (1<<0)
#define PM3ByApertureMode_BYTESWAP_CDAB (2<<0)
#define PM3ByApertureMode_BYTESWAP_DCBA (3<<0)
#define PM3ByApertureMode_PATCH_DISABLE (0<<2)
#define PM3ByApertureMode_PATCH_ENABLE (1<<2)
#define PM3ByApertureMode_FORMAT_RAW (0<<3)
#define PM3ByApertureMode_FORMAT_YUYV (1<<3)
#define PM3ByApertureMode_FORMAT_UYVY (2<<3)
#define PM3ByApertureMode_PIXELSIZE_8BIT (0<<5)
#define PM3ByApertureMode_PIXELSIZE_16BIT (1<<5)
#define PM3ByApertureMode_PIXELSIZE_32BIT (2<<5)
#define PM3ByApertureMode_PIXELSIZE_MASK (3<<5)
#define PM3ByApertureMode_EFFECTIVE_STRIDE_1024 (0<<7)
#define PM3ByApertureMode_EFFECTIVE_STRIDE_2048 (1<<7)
#define PM3ByApertureMode_EFFECTIVE_STRIDE_4096 (2<<7)
#define PM3ByApertureMode_EFFECTIVE_STRIDE_8192 (3<<7)
#define PM3ByApertureMode_PATCH_OFFSET_X(off) (((off)&7f)<<9)
#define PM3ByApertureMode_PATCH_OFFSET_Y(off) (((off)&7f)<<16)
#define PM3ByApertureMode_FRAMEBUFFER (0<<21)
#define PM3ByApertureMode_LOCALBUFFER (1<<21)
#define PM3ByApertureMode_DOUBLE_WRITE_OFF (0<<22)
#define PM3ByApertureMode_DOUBLE_WRITE_1MB (1<<22)
#define PM3ByApertureMode_DOUBLE_WRITE_2MB (2<<22)
#define PM3ByApertureMode_DOUBLE_WRITE_4MB (3<<22)
#define PM3ByApertureMode_DOUBLE_WRITE_8MB (4<<22)
#define PM3ByApertureMode_DOUBLE_WRITE_16MB (5<<22)
#define PM3ByApertureMode_DOUBLE_WRITE_32MB (6<<22)
#define PM3ByAperture2Mode 0x0328
/**********************************************
* GLINT Permedia3 Memory Control (0x1000) *
***********************************************/
#define PM3MemCounter 0x1000
#define PM3MemBypassWriteMask 0x1008
#define PM3MemScratch 0x1010
#define PM3LocalMemCaps 0x1018
#define PM3LocalMemCaps_NoWriteMask (1 << 28)
#define PM3LocalMemTimings 0x1020
#define PM3LocalMemControl 0x1028
#define PM3LocalMemRefresh 0x1030
#define PM3LocalMemPowerDown 0x1038
#define PM3RemoteMemControl 0x1100
/**********************************************
* GLINT Permedia3 Video Control (0x3000) *
***********************************************/
#define PM3ScreenBase 0x3000
#define PM3ScreenStride 0x3008
#define PM3HTotal 0x3010
#define PM3HgEnd 0x3018
#define PM3HbEnd 0x3020
#define PM3HsStart 0x3028
#define PM3HsEnd 0x3030
#define PM3VTotal 0x3038
#define PM3VbEnd 0x3040
#define PM3VsStart 0x3048
#define PM3VsEnd 0x3050
#define PM3VideoControl 0x3058
#define PM3VideoControl_DISABLE (0<<0)
#define PM3VideoControl_ENABLE (1<<0)
#define PM3VideoControl_BLANK_ACTIVE_HIGH (0<<1)
#define PM3VideoControl_BLANK_ACTIVE_LOW (1<<1)
#define PM3VideoControl_LINE_DOUBLE_OFF (0<<2)
#define PM3VideoControl_LINE_DOUBLE_ON (1<<2)
#define PM3VideoControl_HSYNC_FORCE_HIGH (0<<3)
#define PM3VideoControl_HSYNC_ACTIVE_HIGH (1<<3)
#define PM3VideoControl_HSYNC_FORCE_LOW (2<<3)
#define PM3VideoControl_HSYNC_ACTIVE_LOW (3<<3)
#define PM3VideoControl_HSYNC_MASK (3<<3)
#define PM3VideoControl_VSYNC_FORCE_HIGH (0<<5)
#define PM3VideoControl_VSYNC_ACTIVE_HIGH (1<<5)
#define PM3VideoControl_VSYNC_FORCE_LOW (2<<5)
#define PM3VideoControl_VSYNC_ACTIVE_LOW (3<<5)
#define PM3VideoControl_VSYNC_MASK (3<<5)
#define PM3VideoControl_BYTE_DOUBLE_OFF (0<<7)
#define PM3VideoControl_BYTE_DOUBLE_ON (1<<7)
#define PM3VideoControl_BUFFER_SWAP_SYNCON_FRAMEBLANK (0<<9)
#define PM3VideoControl_BUFFER_SWAP_FREE_RUNNING (1<<9)
#define PM3VideoControl_BUFFER_SWAP_LIMITETO_FRAMERATE (2<<9)
#define PM3VideoControl_STEREO_DISABLE (0<<11)
#define PM3VideoControl_STEREO_ENABLE (1<<11)
#define PM3VideoControl_RIGHT_EYE_ACTIVE_HIGH (0<<12)
#define PM3VideoControl_RIGHT_EYE_ACTIVE_LOW (1<<12)
#define PM3VideoControl_VIDEO_EXT_LOW (0<<14)
#define PM3VideoControl_VIDEO_EXT_HIGH (1<<14)
#define PM3VideoControl_SYNC_MODE_INDEPENDENT (0<<16)
#define PM3VideoControl_SYNC_MODE_SYNCTO_VSA (1<<16)
#define PM3VideoControl_SYNC_MODE_SYNCTO_VSB (2<<16)
#define PM3VideoControl_PATCH_DISABLE (0<<18)
#define PM3VideoControl_PATCH_ENABLE (1<<18)
#define PM3VideoControl_PIXELSIZE_8BIT (0<<19)
#define PM3VideoControl_PIXELSIZE_16BIT (1<<19)
#define PM3VideoControl_PIXELSIZE_32BIT (2<<19)
#define PM3VideoControl_DISPLAY_DISABLE (0<<21)
#define PM3VideoControl_DISPLAY_ENABLE (1<<21)
#define PM3VideoControl_PATCH_OFFSET_X(off) (((off)&0x3f)<<22)
#define PM3VideoControl_PATCH_OFFSET_Y(off) (((off)&0x3f)<<28)
#define PM3InterruptLine 0x3060
#define PM3DisplayData 0x3068
#define PM3VerticalLineCount 0x3070
#define PM3FifoControl 0x3078
#define PM3ScreenBaseRight 0x3080
#define PM3MiscControl 0x3088
#define PM3VideoOverlayUpdate 0x3100
#define PM3VideoOverlayUpdate_DISABLE (0<<0)
#define PM3VideoOverlayUpdate_ENABLE (1<<0)
#define PM3VideoOverlayMode 0x3108
#define PM3VideoOverlayMode_DISABLE (0<<0)
#define PM3VideoOverlayMode_ENABLE (1<<0)
#define PM3VideoOverlayMode_BUFFERSYNC_MANUAL (0<<1)
#define PM3VideoOverlayMode_BUFFERSYNC_VIDEOSTREAMA (1<<1)
#define PM3VideoOverlayMode_BUFFERSYNC_VIDEOSTREAMB (2<<1)
#define PM3VideoOverlayMode_FIELDPOLARITY_NORMAL (0<<4)
#define PM3VideoOverlayMode_FIELDPOLARITY_INVERT (1<<4)
#define PM3VideoOverlayMode_PIXELSIZE_8BIT (0<<5)
#define PM3VideoOverlayMode_PIXELSIZE_16BIT (1<<5)
#define PM3VideoOverlayMode_PIXELSIZE_32BIT (2<<5)
#define PM3VideoOverlayMode_COLORFORMAT_RGB8888 ((0<<7)|(1<<12)|(2<<5))
#define PM3VideoOverlayMode_COLORFORMAT_RGB4444 ((1<<7)|(1<<12)|(1<<5))
#define PM3VideoOverlayMode_COLORFORMAT_RGB5551 ((2<<7)|(1<<12)|(1<<5))
#define PM3VideoOverlayMode_COLORFORMAT_RGB565 ((3<<7)|(1<<12)|(1<<5))
#define PM3VideoOverlayMode_COLORFORMAT_RGB332 ((4<<7)|(1<<12)|(0<<5))
#define PM3VideoOverlayMode_COLORFORMAT_BGR8888 ((0<<7)|(2<<5))
#define PM3VideoOverlayMode_COLORFORMAT_BGR4444 ((1<<7)|(1<<5))
#define PM3VideoOverlayMode_COLORFORMAT_BGR5551 ((2<<7)|(1<<5))
#define PM3VideoOverlayMode_COLORFORMAT_BGR565 ((3<<7)|(1<<5))
#define PM3VideoOverlayMode_COLORFORMAT_BGR332 ((4<<7)|(0<<5))
#define PM3VideoOverlayMode_COLORFORMAT_CI8 ((5<<7)|(1<<12)|(0<<5))
#define PM3VideoOverlayMode_COLORFORMAT_VUY444 ((2<<10)|(1<<12)|(2<<5))
#define PM3VideoOverlayMode_COLORFORMAT_YUV444 ((2<<10)|(2<<5))
#define PM3VideoOverlayMode_COLORFORMAT_VUY422 ((1<<10)|(1<<12)|(1<<5))
#define PM3VideoOverlayMode_COLORFORMAT_YUV422 ((1<<10)|(1<<5))
#define PM3VideoOverlayMode_COLORORDER_BGR (0<<12)
#define PM3VideoOverlayMode_COLORORDER_RGB (1<<12)
#define PM3VideoOverlayMode_LINEARCOLOREXT_OFF (0<<13)
#define PM3VideoOverlayMode_LINEARCOLOREXT_ON (1<<13)
#define PM3VideoOverlayMode_FILTER_MASK (3<<14)
#define PM3VideoOverlayMode_FILTER_OFF (0<<14)
#define PM3VideoOverlayMode_FILTER_FULL (1<<14)
#define PM3VideoOverlayMode_FILTER_PARTIAL (2<<14)
#define PM3VideoOverlayMode_DEINTERLACE_OFF (0<<16)
#define PM3VideoOverlayMode_DEINTERLACE_BOB (1<<16)
#define PM3VideoOverlayMode_PATCHMODE_OFF (0<<18)
#define PM3VideoOverlayMode_PATCHMODE_ON (1<<18)
#define PM3VideoOverlayMode_FLIP_VIDEO (0<<20)
#define PM3VideoOverlayMode_FLIP_VIDEOSTREAMA (1<<20)
#define PM3VideoOverlayMode_FLIP_VIDEOSTREAMB (2<<20)
#define PM3VideoOverlayMode_MIRROR_MASK (3<<23)
#define PM3VideoOverlayMode_MIRRORX_OFF (0<<23)
#define PM3VideoOverlayMode_MIRRORX_ON (1<<23)
#define PM3VideoOverlayMode_MIRRORY_OFF (0<<24)
#define PM3VideoOverlayMode_MIRRORY_ON (1<<24)
#define PM3VideoOverlayFifoControl 0x3110
#define PM3VideoOverlayIndex 0x3118
#define PM3VideoOverlayBase0 0x3120
#define PM3VideoOverlayBase1 0x3128
#define PM3VideoOverlayBase2 0x3130
#define PM3VideoOverlayStride 0x3138
#define PM3VideoOverlayStride_STRIDE(s) (((s)&0xfff)<<0)
#define PM3VideoOverlayWidth 0x3140
#define PM3VideoOverlayWidth_WIDTH(w) (((w)&0xfff)<<0)
#define PM3VideoOverlayHeight 0x3148
#define PM3VideoOverlayHeight_HEIGHT(h) (((h)&0xfff)<<0)
#define PM3VideoOverlayOrigin 0x3150
#define PM3VideoOverlayOrigin_XORIGIN(x) (((x)&0xfff)<<0)
#define PM3VideoOverlayOrigin_YORIGIN(y) (((y)&0xfff)<<16)
#define PM3VideoOverlayShrinkXDelta 0x3158
#define PM3VideoOverlayShrinkXDelta_NONE (1<<16)
#define PM3VideoOverlayShrinkXDelta_DELTA(s,d) \
((((s)<<16)/(d))&0x0ffffff0)
#define PM3VideoOverlayZoomXDelta 0x3160
#define PM3VideoOverlayZoomXDelta_NONE (1<<16)
#define PM3VideoOverlayZoomXDelta_DELTA(s,d) \
((((s)<<16)/(d))&0x0001fff0)
#define PM3VideoOverlayYDelta 0x3168
#define PM3VideoOverlayYDelta_NONE (1<<16)
#define PM3VideoOverlayYDelta_DELTA(s,d) \
((((s)<<16)/(d))&0x0ffffff0)
#define PM3VideoOverlayFieldOffset 0x3170
#define PM3VideoOverlayStatus 0x3178
/**********************************************
* GLINT Permedia3 RAMDAC Registers (0x4000) *
***********************************************/
/* Direct Registers */
#define PM3RD_PaletteWriteAddress 0x4000
#define PM3RD_PaletteData 0x4008
#define PM3RD_PixelMask 0x4010
#define PM3RD_PaletteReadAddress 0x4018
#define PM3RD_IndexLow 0x4020
#define PM3RD_IndexHigh 0x4028
#define PM3RD_IndexedData 0x4030
#define PM3RD_IndexControl 0x4038
#define PM3RD_IndexControl_AUTOINCREMENT_ENABLE (1<<0)
#define PM3RD_IndexControl_AUTOINCREMENT_DISABLE (0<<0)
/* Indirect Registers */
#define PM3RD_MiscControl 0x000
#define PM3RD_MiscControl_HIGHCOLOR_RES_DISABLE (0<<0)
#define PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE (1<<0)
#define PM3RD_MiscControl_PIXELDOUBLE_DISABLE (0<<1)
#define PM3RD_MiscControl_PIXELDOUBLE_ENABLE (1<<1)
#define PM3RD_MiscControl_LASTREAD_ADDR_DISABLE (0<<2)
#define PM3RD_MiscControl_LASTREAD_ADDR_ENABLE (1<<2)
#define PM3RD_MiscControl_DIRECTCOLOR_DISABLE (0<<3)
#define PM3RD_MiscControl_DIRECTCOLOR_ENABLE (1<<3)
#define PM3RD_MiscControl_OVERLAY_DISABLE (0<<4)
#define PM3RD_MiscControl_OVERLAY_ENABLE (1<<4)
#define PM3RD_MiscControl_PIXELDOUBLE_BUFFER_DISABLE (0<<5)
#define PM3RD_MiscControl_PIXELDOUBLE_BUFFER_ENABLE (1<<5)
#define PM3RD_MiscControl_VSB_OUTPUT_DISABLE (0<<6)
#define PM3RD_MiscControl_VSB_OUTPUT_ENABLE (1<<6)
#define PM3RD_MiscControl_STEREODOUBLE_BUFFER_DISABLE (0<<7)
#define PM3RD_MiscControl_STEREODOUBLE_BUFFER_ENABLE (1<<7)
#define PM3RD_SyncControl 0x001
#define PM3RD_SyncControl_HSYNC_ACTIVE_LOW (0<<0)
#define PM3RD_SyncControl_HSYNC_ACTIVE_HIGH (1<<0)
#define PM3RD_SyncControl_HSYNC_FORCE_ACTIVE (3<<0)
#define PM3RD_SyncControl_HSYNC_FORCE_INACTIVE (4<<0)
#define PM3RD_SyncControl_HSYNC_TRI_STATE (2<<0)
#define PM3RD_SyncControl_VSYNC_ACTIVE_LOW (0<<3)
#define PM3RD_SyncControl_VSYNC_ACTIVE_HIGH (1<<3)
#define PM3RD_SyncControl_VSYNC_TRI_STATE (2<<3)
#define PM3RD_SyncControl_VSYNC_FORCE_ACTIVE (3<<3)
#define PM3RD_SyncControl_VSYNC_FORCE_INACTIVE (4<<3)
#define PM3RD_SyncControl_HSYNC_OVERRIDE_SETBY_HSYNC (0<<6)
#define PM3RD_SyncControl_HSYNC_OVERRIDE_FORCE_HIGH (1<<6)
#define PM3RD_SyncControl_VSYNC_OVERRIDE_SETBY_VSYNC (0<<7)
#define PM3RD_SyncControl_VSYNC_OVERRIDE_FORCE_HIGH (1<<7)
#define PM3RD_DACControl 0x002
#define PM3RD_DACControl_DAC_POWER_ON (0<<0)
#define PM3RD_DACControl_DAC_POWER_OFF (1<<0)
#define PM3RD_DACControl_SYNC_ON_GREEN_DISABLE (0<<3)
#define PM3RD_DACControl_SYNC_ON_GREEN_ENABLE (1<<3)
#define PM3RD_DACControl_BLANK_RED_DAC_DISABLE (0<<4)
#define PM3RD_DACControl_BLANK_RED_DAC_ENABLE (1<<4)
#define PM3RD_DACControl_BLANK_GREEN_DAC_DISABLE (0<<5)
#define PM3RD_DACControl_BLANK_GREEN_DAC_ENABLE (1<<5)
#define PM3RD_DACControl_BLANK_BLUE_DAC_DISABLE (0<<6)
#define PM3RD_DACControl_BLANK_BLUE_DAC_ENABLE (1<<6)
#define PM3RD_DACControl_BLANK_PEDESTAL_DISABLE (0<<7)
#define PM3RD_DACControl_BLANK_PEDESTAL_ENABLE (1<<7)
#define PM3RD_PixelSize 0x003
#define PM3RD_PixelSize_24_BIT_PIXELS (4<<0)
#define PM3RD_PixelSize_32_BIT_PIXELS (2<<0)
#define PM3RD_PixelSize_16_BIT_PIXELS (1<<0)
#define PM3RD_PixelSize_8_BIT_PIXELS (0<<0)
#define PM3RD_ColorFormat 0x004
#define PM3RD_ColorFormat_LINEAR_COLOR_EXT_ENABLE (1<<6)
#define PM3RD_ColorFormat_LINEAR_COLOR_EXT_DISABLE (0<<6)
#define PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW (1<<5)
#define PM3RD_ColorFormat_COLOR_ORDER_RED_LOW (0<<5)
#define PM3RD_ColorFormat_COLOR_FORMAT_MASK (0x1f<<0)
#define PM3RD_ColorFormat_8888_COLOR (0<<0)
#define PM3RD_ColorFormat_5551_FRONT_COLOR (1<<0)
#define PM3RD_ColorFormat_4444_COLOR (2<<0)
#define PM3RD_ColorFormat_332_FRONT_COLOR (5<<0)
#define PM3RD_ColorFormat_332_BACK_COLOR (6<<0)
#define PM3RD_ColorFormat_2321_FRONT_COLOR (9<<0)
#define PM3RD_ColorFormat_2321_BACK_COLOR (10<<0)
#define PM3RD_ColorFormat_232_FRONTOFF_COLOR (11<<0)
#define PM3RD_ColorFormat_232_BACKOFF_COLOR (12<<0)
#define PM3RD_ColorFormat_5551_BACK_COLOR (13<<0)
#define PM3RD_ColorFormat_CI8_COLOR (14<<0)
#define PM3RD_ColorFormat_565_FRONT_COLOR (16<<0)
#define PM3RD_ColorFormat_565_BACK_COLOR (17<<0)
#define PM3RD_CursorMode 0x005
#define PM3RD_CursorMode_CURSOR_DISABLE (0<<0)
#define PM3RD_CursorMode_CURSOR_ENABLE (1<<0)
#define PM3RD_CursorMode_FORMAT_64x64_2BPE_P0123 (0<<2)
#define PM3RD_CursorMode_FORMAT_32x32_2BPE_P0 (1<<2)
#define PM3RD_CursorMode_FORMAT_32x32_2BPE_P1 (2<<2)
#define PM3RD_CursorMode_FORMAT_32x32_2BPE_P2 (3<<2)
#define PM3RD_CursorMode_FORMAT_32x32_2BPE_P3 (4<<2)
#define PM3RD_CursorMode_FORMAT_32x32_4BPE_P01 (5<<2)
#define PM3RD_CursorMode_FORMAT_32x32_4BPE_P23 (6<<2)
#define PM3RD_CursorMode_TYPE_MS (0<<4)
#define PM3RD_CursorMode_TYPE_X (1<<4)
#define PM3RD_CursorMode_REVERSE_PIXEL_ORDER_DISABLE (0<<6)
#define PM3RD_CursorMode_REVERSE_PIXEL_ORDER_ENABLE (1<<6)
#define PM3RD_CursorMode_REVERSE_PIXEL_ORDER_3_COLOR (2<<6)
#define PM3RD_CursorMode_REVERSE_PIXEL_ORDER_15_COLOR (3<<6)
#define PM3RD_CursorControl 0x006
#define PM3RD_CursorControl_DOUBLE_X_DISABLED (0<<0)
#define PM3RD_CursorControl_DOUBLE_X_ENABLED (1<<0)
#define PM3RD_CursorControl_DOUBLE_Y_DISABLED (0<<1)
#define PM3RD_CursorControl_DOUBLE_Y_ENABLED (1<<1)
#define PM3RD_CursorControl_READBACK_POS_DISABLED (0<<2)
#define PM3RD_CursorControl_READBACK_POS_ENABLED (1<<2)
#define PM3RD_CursorXLow 0x007
#define PM3RD_CursorXHigh 0x008
#define PM3RD_CursorYLow 0x009
#define PM3RD_CursorYHigh 0x00a
#define PM3RD_CursorHotSpotX 0x00b
#define PM3RD_CursorHotSpotY 0x00c
#define PM3RD_OverlayKey 0x00d
#define PM3RD_Pan 0x00e
#define PM3RD_Pan_DISABLE (0<<0)
#define PM3RD_Pan_ENABLE (1<<0)
#define PM3RD_Pan_GATE_DISABLE (0<<1)
#define PM3RD_Pan_GATE_ENABLE (1<<1)
#define PM3RD_Sense 0x00f
#define PM3RD_CheckControl 0x018
#define PM3RD_CheckControl_PIXEL_DISABLED (0<<0)
#define PM3RD_CheckControl_PIXEL_ENABLED (1<<0)
#define PM3RD_CheckControl_LUT_DISABLED (0<<1)
#define PM3RD_CheckControl_LUT_ENABLED (1<<1)
#define PM3RD_CheckPixelRed 0x019
#define PM3RD_CheckPixelGreen 0x01a
#define PM3RD_CheckPixelBlue 0x01b
#define PM3RD_CheckLUTRed 0x01c
#define PM3RD_CheckLUTGreen 0x01d
#define PM3RD_CheckLUTBlue 0x01e
#define PM3RD_Scratch 0x01f
#define PM3RD_VideoOverlayControl 0x020
#define PM3RD_VideoOverlayControl_DISABLE (0<<0)
#define PM3RD_VideoOverlayControl_ENABLE (1<<0)
#define PM3RD_VideoOverlayControl_MODE_MASK (3<<1)
#define PM3RD_VideoOverlayControl_MODE_MAINKEY (0<<1)
#define PM3RD_VideoOverlayControl_MODE_OVERLAYKEY (1<<1)
#define PM3RD_VideoOverlayControl_MODE_ALWAYS (2<<1)
#define PM3RD_VideoOverlayControl_MODE_BLEND (3<<1)
#define PM3RD_VideoOverlayControl_DIRECTCOLOR_DISABLED (0<<3)
#define PM3RD_VideoOverlayControl_DIRECTCOLOR_ENABLED (1<<3)
#define PM3RD_VideoOverlayControl_BLENDSRC_MAIN (0<<4)
#define PM3RD_VideoOverlayControl_BLENDSRC_REGISTER (1<<4)
#define PM3RD_VideoOverlayControl_KEY_COLOR (0<<5)
#define PM3RD_VideoOverlayControl_KEY_ALPHA (1<<5)
#define PM3RD_VideoOverlayXStartLow 0x021
#define PM3RD_VideoOverlayXStartHigh 0x022
#define PM3RD_VideoOverlayYStartLow 0x023
#define PM3RD_VideoOverlayYStartHigh 0x024
#define PM3RD_VideoOverlayXEndLow 0x025
#define PM3RD_VideoOverlayXEndHigh 0x026
#define PM3RD_VideoOverlayYEndLow 0x027
#define PM3RD_VideoOverlayYEndHigh 0x028
#define PM3RD_VideoOverlayKeyR 0x029
#define PM3RD_VideoOverlayKeyG 0x02a
#define PM3RD_VideoOverlayKeyB 0x02b
#define PM3RD_VideoOverlayBlend 0x02c
#define PM3RD_VideoOverlayBlend_FACTOR_0_PERCENT (0<<6)
#define PM3RD_VideoOverlayBlend_FACTOR_25_PERCENT (1<<6)
#define PM3RD_VideoOverlayBlend_FACTOR_75_PERCENT (2<<6)
#define PM3RD_VideoOverlayBlend_FACTOR_100_PERCENT (3<<6)
#define PM3RD_DClkSetup1 0x1f0
#define PM3RD_DClkSetup2 0x1f1
#define PM3RD_KClkSetup1 0x1f2
#define PM3RD_KClkSetup2 0x1f3
#define PM3RD_DClkControl 0x200
#define PM3RD_DClkControl_SOURCE_PLL (0<<4)
#define PM3RD_DClkControl_SOURCE_VSA (1<<4)
#define PM3RD_DClkControl_SOURCE_VSB (2<<4)
#define PM3RD_DClkControl_SOURCE_EXT (3<<4)
#define PM3RD_DClkControl_STATE_RUN (2<<2)
#define PM3RD_DClkControl_STATE_HIGH (1<<2)
#define PM3RD_DClkControl_STATE_LOW (0<<2)
#define PM3RD_DClkControl_LOCKED (1<<1)
#define PM3RD_DClkControl_NOT_LOCKED (0<<1)
#define PM3RD_DClkControl_ENABLE (1<<0)
#define PM3RD_DClkControl_DISABLE (0<<0)
#define PM3RD_DClk0PreScale 0x201
#define PM3RD_DClk0FeedbackScale 0x202
#define PM3RD_DClk0PostScale 0x203
#define PM3_REF_CLOCK 14318
#define PM3RD_DClk1PreScale 0x204
#define PM3RD_DClk1FeedbackScale 0x205
#define PM3RD_DClk1PostScale 0x206
#define PM3RD_DClk2PreScale 0x207
#define PM3RD_DClk2FeedbackScale 0x208
#define PM3RD_DClk2PostScale 0x209
#define PM3RD_DClk3PreScale 0x20a
#define PM3RD_DClk3FeedbackScale 0x20b
#define PM3RD_DClk3PostScale 0x20c
#define PM3RD_KClkControl 0x20d
#define PM3RD_KClkControl_DISABLE (0<<0)
#define PM3RD_KClkControl_ENABLE (1<<0)
#define PM3RD_KClkControl_NOT_LOCKED (0<<1)
#define PM3RD_KClkControl_LOCKED (1<<1)
#define PM3RD_KClkControl_STATE_LOW (0<<2)
#define PM3RD_KClkControl_STATE_HIGH (1<<2)
#define PM3RD_KClkControl_STATE_RUN (2<<2)
#define PM3RD_KClkControl_STATE_LOW_POWER (3<<2)
#define PM3RD_KClkControl_SOURCE_PCLK (0<<4)
#define PM3RD_KClkControl_SOURCE_HALF_PCLK (1<<4)
#define PM3RD_KClkControl_SOURCE_PLL (2<<4)
#define PM3RD_KClkPreScale 0x20e
#define PM3RD_KClkFeedbackScale 0x20f
#define PM3RD_KClkPostScale 0x210
#define PM3RD_MClkControl 0x211
#define PM3RD_MClkControl_DISABLE (0<<0)
#define PM3RD_MClkControl_ENABLE (1<<0)
#define PM3RD_MClkControl_NOT_LOCKED (0<<1)
#define PM3RD_MClkControl_LOCKED (1<<1)
#define PM3RD_MClkControl_STATE_LOW (0<<2)
#define PM3RD_MClkControl_STATE_HIGH (1<<2)
#define PM3RD_MClkControl_STATE_RUN (2<<2)
#define PM3RD_MClkControl_STATE_LOW_POWER (3<<2)
#define PM3RD_MClkControl_SOURCE_PCLK (0<<4)
#define PM3RD_MClkControl_SOURCE_HALF_PCLK (1<<4)
#define PM3RD_MClkControl_SOURCE_HALF_EXT (3<<4)
#define PM3RD_MClkControl_SOURCE_EXT (4<<4)
#define PM3RD_MClkControl_SOURCE_HALF_KCLK (5<<4)
#define PM3RD_MClkControl_SOURCE_KCLK (6<<4)
#define PM3RD_MClkPreScale 0x212
#define PM3RD_MClkFeedbackScale 0x213
#define PM3RD_MClkPostScale 0x214
#define PM3RD_SClkControl 0x215
#define PM3RD_SClkControl_DISABLE (0<<0)
#define PM3RD_SClkControl_ENABLE (1<<0)
#define PM3RD_SClkControl_NOT_LOCKED (0<<1)
#define PM3RD_SClkControl_LOCKED (1<<1)
#define PM3RD_SClkControl_STATE_LOW (0<<2)
#define PM3RD_SClkControl_STATE_HIGH (1<<2)
#define PM3RD_SClkControl_STATE_RUN (2<<2)
#define PM3RD_SClkControl_STATE_LOW_POWER (3<<2)
#define PM3RD_SClkControl_SOURCE_PCLK (0<<4)
#define PM3RD_SClkControl_SOURCE_HALF_PCLK (1<<4)
#define PM3RD_SClkControl_SOURCE_HALF_EXT (3<<4)
#define PM3RD_SClkControl_SOURCE_EXT (4<<4)
#define PM3RD_SClkControl_SOURCE_HALF_KCLK (5<<4)
#define PM3RD_SClkControl_SOURCE_KCLK (6<<4)
#define PM3RD_SClkPreScale 0x216
#define PM3RD_SClkFeedbackScale 0x217
#define PM3RD_SClkPostScale 0x218
#define PM3RD_CursorPalette(p) (0x303+(p))
#define PM3RD_CursorPattern(p) (0x400+(p))
/******************************************************
* GLINT Permedia3 Video Streaming Registers (0x5000) *
*******************************************************/
#define PM3VSConfiguration 0x5800
/**********************************************
* GLINT Permedia3 Core Registers (0x8000+) *
***********************************************/
#define PM3AALineWidth 0x94c0
#define PM3AAPointsize 0x94a0
#define PM3AlphaBlendAlphaMode 0xafa8
#define PM3AlphaBlendAlphaModeAnd 0xad30
#define PM3AlphaBlendAlphaModeOr 0xad38
#define PM3AlphaBlendColorMode 0xafa0
#define PM3AlphaBlendColorModeAnd 0xacb0
#define PM3AlphaBlendColorModeOr 0xacb8
#define PM3AlphaDestColor 0xaf88
#define PM3AlphaSourceColor 0xaf80
#define PM3AlphaTestMode 0x8800
#define PM3AlphaTestModeAnd 0xabf0
#define PM3AlphaTestModeOr 0xabf8
#define PM3AntialiasMode 0x8808
#define PM3AntialiasModeAnd 0xac00
#define PM3AntialiasModeOr 0xac08
/* ... */
#define PM3BackgroundColor 0xb0c8
/* ... */
#define PM3ColorDDAMode 0x87e0
#define PM3ColorDDAModeAnd 0xabe0
#define PM3ColorDDAModeOr 0xabe8
#define PM3CommandInterrupt 0xa990
#define PM3ConstantColorDDA 0xafb0
#define PM3ConstantColorDDA_R(r) ((r)&0xff)
#define PM3ConstantColorDDA_G(g) (((g)&0xff)<<8)
#define PM3ConstantColorDDA_B(b) (((b)&0xff)<<16)
#define PM3ConstantColorDDA_A(a) (((a)&0xff)<<24)
#define PM3ContextData 0x8dd0
#define PM3ContextDump 0x8dc0
#define PM3ContextRestore 0x8dc8
#define PM3Continue 0x8058
#define PM3ContinueNewDom 0x8048
#define PM3ContinueNewLine 0x8040
#define PM3ContinueNewSub 0x8050
#define PM3Count 0x8030
/* ... */
#define PM3DeltaControl 0x9350
#define PM3DeltaControlAnd 0xab20
#define PM3DeltaControlOr 0xab28
#define PM3DeltaMode 0x9300
#define PM3DeltaModeAnd 0xaad0
#define PM3DeltaModeOr 0xaad8
/* ... */
#define PM3DitherMode 0x8818
#define PM3DitherModeAnd 0xacd0
#define PM3DitherModeOr 0xacd8
/* ... */
#define PM3dXDom 0x8008
#define PM3dXSub 0x8018
#define PM3dY 0x8028
/* ... */
#define PM3FBBlockColor 0x8ac8
#define PM3FBBlockColor0 0xb060
#define PM3FBBlockColor1 0xb068
#define PM3FBBlockColor2 0xb070
#define PM3FBBlockColor3 0xb078
#define PM3FBBlockColorBack 0xb0a0
#define PM3FBBlockColorBack0 0xb080
#define PM3FBBlockColorBack1 0xb088
#define PM3FBBlockColorBack2 0xb090
#define PM3FBBlockColorBack3 0xb098
#define PM3FBColor 0x8a98
#define PM3FBDestReadBufferAddr0 0xae80
#define PM3FBDestReadBufferAddr1 0xae88
#define PM3FBDestReadBufferAddr2 0xae90
#define PM3FBDestReadBufferAddr3 0xae98
#define PM3FBDestReadBufferOffset0 0xaea0
#define PM3FBDestReadBufferOffset1 0xaea8
#define PM3FBDestReadBufferOffset2 0xaeb0
#define PM3FBDestReadBufferOffset3 0xaeb8
#define PM3FBDestReadBufferOffset_XOffset(x) ((x)&0xffff)
#define PM3FBDestReadBufferOffset_YOffset(y) (((y)&0xffff)<<16)
#define PM3FBDestReadBufferWidth0 0xaec0
#define PM3FBDestReadBufferWidth1 0xaec8
#define PM3FBDestReadBufferWidth2 0xaed0
#define PM3FBDestReadBufferWidth3 0xaed8
#define PM3FBDestReadBufferWidth_Width(w) ((w)&0x0fff)
#define PM3FBDestReadEnables 0xaee8
#define PM3FBDestReadEnablesAnd 0xad20
#define PM3FBDestReadEnablesOr 0xad28
#define PM3FBDestReadEnables_E(e) ((e)&0xff)
#define PM3FBDestReadEnables_E0 1<<0
#define PM3FBDestReadEnables_E1 1<<1
#define PM3FBDestReadEnables_E2 1<<2
#define PM3FBDestReadEnables_E3 1<<3
#define PM3FBDestReadEnables_E4 1<<4
#define PM3FBDestReadEnables_E5 1<<5
#define PM3FBDestReadEnables_E6 1<<6
#define PM3FBDestReadEnables_E7 1<<7
#define PM3FBDestReadEnables_R(r) (((r)&0xff)<<8)
#define PM3FBDestReadEnables_R0 1<<8
#define PM3FBDestReadEnables_R1 1<<9
#define PM3FBDestReadEnables_R2 1<<10
#define PM3FBDestReadEnables_R3 1<<11
#define PM3FBDestReadEnables_R4 1<<12
#define PM3FBDestReadEnables_R5 1<<13
#define PM3FBDestReadEnables_R6 1<<14
#define PM3FBDestReadEnables_R7 1<<15
#define PM3FBDestReadEnables_ReferenceAlpha(a) (((a)&0xff)<<24)
#define PM3FBDestReadMode 0xaee0
#define PM3FBDestReadModeAnd 0xac90
#define PM3FBDestReadModeOr 0xac98
#define PM3FBDestReadMode_ReadDisable 0<<0
#define PM3FBDestReadMode_ReadEnable 1<<0
#define PM3FBDestReadMode_StripePitch(sp) (((sp)&0x7)<<2
#define PM3FBDestReadMode_StripeHeight(sh) (((sh)&0x7)<<7
#define PM3FBDestReadMode_Enable0 1<<8
#define PM3FBDestReadMode_Enable1 1<<9
#define PM3FBDestReadMode_Enable2 1<<10
#define PM3FBDestReadMode_Enable3 1<<11
#define PM3FBDestReadMode_Layout0(l) (((l)&0x3)<<12
#define PM3FBDestReadMode_Layout1(l) (((l)&0x3)<<14
#define PM3FBDestReadMode_Layout2(l) (((l)&0x3)<<16
#define PM3FBDestReadMode_Layout3(l) (((l)&0x3)<<18
#define PM3FBDestReadMode_Origin0 1<<20
#define PM3FBDestReadMode_Origin1 1<<21
#define PM3FBDestReadMode_Origin2 1<<22
#define PM3FBDestReadMode_Origin3 1<<23
#define PM3FBDestReadMode_Blocking 1<<24
#define PM3FBDestReadMode_UseReadEnabled 1<<26
#define PM3FBDestReadMode_AlphaFiltering 1<<27
#define PM3FBHardwareWriteMask 0x8ac0
#define PM3FBSoftwareWriteMask 0x8820
#define PM3FBData 0x8aa0
#define PM3FBSourceData 0x8aa8
#define PM3FBSourceReadBufferAddr 0xaf08
#define PM3FBSourceReadBufferOffset 0xaf10
#define PM3FBSourceReadBufferOffset_XOffset(x) ((x)&0xffff)
#define PM3FBSourceReadBufferOffset_YOffset(y) (((y)&0xffff)<<16)
#define PM3FBSourceReadBufferWidth 0xaf18
#define PM3FBSourceReadBufferWidth_Width(w) ((w)&0x0fff)
#define PM3FBSourceReadMode 0xaf00
#define PM3FBSourceReadModeAnd 0xaca0
#define PM3FBSourceReadModeOr 0xaca8
#define PM3FBSourceReadMode_ReadDisable (0<<0)
#define PM3FBSourceReadMode_ReadEnable (1<<0)
#define PM3FBSourceReadMode_StripePitch(sp) (((sp)&0x7)<<2
#define PM3FBSourceReadMode_StripeHeight(sh) (((sh)&0x7)<<7
#define PM3FBSourceReadMode_Layout(l) (((l)&0x3)<<8
#define PM3FBSourceReadMode_Origin 1<<10
#define PM3FBSourceReadMode_Blocking 1<<11
#define PM3FBSourceReadMode_UserTexelCoord 1<<13
#define PM3FBSourceReadMode_WrapXEnable 1<<14
#define PM3FBSourceReadMode_WrapYEnable 1<<15
#define PM3FBSourceReadMode_WrapX(w) (((w)&0xf)<<16
#define PM3FBSourceReadMode_WrapY(w) (((w)&0xf)<<20
#define PM3FBSourceReadMode_ExternalSourceData 1<<24
#define PM3FBWriteBufferAddr0 0xb000
#define PM3FBWriteBufferAddr1 0xb008
#define PM3FBWriteBufferAddr2 0xb010
#define PM3FBWriteBufferAddr3 0xb018
#define PM3FBWriteBufferOffset0 0xb020
#define PM3FBWriteBufferOffset1 0xb028
#define PM3FBWriteBufferOffset2 0xb030
#define PM3FBWriteBufferOffset3 0xb038
#define PM3FBWriteBufferOffset_XOffset(x) ((x)&0xffff)
#define PM3FBWriteBufferOffset_YOffset(y) (((y)&0xffff)<<16)
#define PM3FBWriteBufferWidth0 0xb040
#define PM3FBWriteBufferWidth1 0xb048
#define PM3FBWriteBufferWidth2 0xb050
#define PM3FBWriteBufferWidth3 0xb058
#define PM3FBWriteBufferWidth_Width(w) ((w)&0x0fff)
#define PM3FBWriteMode 0x8ab8
#define PM3FBWriteModeAnd 0xacf0
#define PM3FBWriteModeOr 0xacf8
#define PM3FBWriteMode_WriteDisable 0<<0
#define PM3FBWriteMode_WriteEnable 1<<0
#define PM3FBWriteMode_Replicate 1<<4
#define PM3FBWriteMode_OpaqueSpan 1<<5
#define PM3FBWriteMode_StripePitch(p) (((p)&0x7)<<6)
#define PM3FBWriteMode_StripeHeight(h) (((h)&0x7)<<9)
#define PM3FBWriteMode_Enable0 1<<12
#define PM3FBWriteMode_Enable1 1<<13
#define PM3FBWriteMode_Enable2 1<<14
#define PM3FBWriteMode_Enable3 1<<15
#define PM3FBWriteMode_Layout0(l) (((l)&0x3)<<16)
#define PM3FBWriteMode_Layout1(l) (((l)&0x3)<<18)
#define PM3FBWriteMode_Layout2(l) (((l)&0x3)<<20)
#define PM3FBWriteMode_Layout3(l) (((l)&0x3)<<22)
#define PM3FBWriteMode_Origin0 1<<24
#define PM3FBWriteMode_Origin1 1<<25
#define PM3FBWriteMode_Origin2 1<<26
#define PM3FBWriteMode_Origin3 1<<27
#define PM3ForegroundColor 0xb0c0
/* ... */
#define PM3GIDMode 0xb538
#define PM3GIDModeAnd 0xb5b0
#define PM3GIDModeOr 0xb5b8
/* ... */
#define PM3LBDestReadBufferAddr 0xb510
#define PM3LBDestReadBufferOffset 0xb518
#define PM3LBDestReadEnables 0xb508
#define PM3LBDestReadEnablesAnd 0xb590
#define PM3LBDestReadEnablesOr 0xb598
#define PM3LBDestReadMode 0xb500
#define PM3LBDestReadModeAnd 0xb580
#define PM3LBDestReadModeOr 0xb588
#define PM3LBDestReadMode_Disable 0<<0
#define PM3LBDestReadMode_Enable 1<<0
#define PM3LBDestReadMode_StripePitch(p) (((p)&0x7)<<2)
#define PM3LBDestReadMode_StripeHeight(h) (((h)&0x7)<<5)
#define PM3LBDestReadMode_Layout 1<<8
#define PM3LBDestReadMode_Origin 1<<9
#define PM3LBDestReadMode_UserReadEnables 1<<10
#define PM3LBDestReadMode_Packed16 1<<11
#define PM3LBDestReadMode_Width(w) (((w)&0xfff)<<12)
#define PM3LBReadFormat 0x8888
#define PM3LBReadFormat_DepthWidth(w) (((w)&0x3)<<0)
#define PM3LBReadFormat_StencilWidth(w) (((w)&0xf)<<2)
#define PM3LBReadFormat_StencilPosition(p) (((p)&0x1f)<<6)
#define PM3LBReadFormat_FCPWidth(w) (((w)&0xf)<<11)
#define PM3LBReadFormat_FCPPosition(p) (((p)&0x1f)<<15)
#define PM3LBReadFormat_GIDWidth(w) (((w)&0x7)<<20)
#define PM3LBReadFormat_GIDPosition(p) (((p)&0x1f)<<23)
#define PM3LBSourceReadBufferAddr 0xb528
#define PM3LBSourceReadBufferOffset 0xb530
#define PM3LBSourceReadMode 0xb520
#define PM3LBSourceReadModeAnd 0xb5a0
#define PM3LBSourceReadModeOr 0xb5a8
#define PM3LBSourceReadMode_Enable 1<<0
#define PM3LBSourceReadMode_StripePitch(p) (((p)&0x7)<<2)
#define PM3LBSourceReadMode_StripeHeight(h) (((h)&0x7)<<5)
#define PM3LBSourceReadMode_Layout 1<<8
#define PM3LBSourceReadMode_Origin 1<<9
#define PM3LBSourceReadMode_Packed16 1<<10
#define PM3LBSourceReadMode_Width(w) (((w)&0xfff)<<11)
#define PM3LBStencil 0x88a8
#define PM3LBWriteBufferAddr 0xb540
#define PM3LBWriteBufferOffset 0xb548
#define PM3LBWriteFormat 0x88c8
#define PM3LBWriteFormat_DepthWidth(w) (((w)&0x3)<<0)
#define PM3LBWriteFormat_StencilWidth(w) (((w)&0xf)<<2)
#define PM3LBWriteFormat_StencilPosition(p) (((p)&0x1f)<<6)
#define PM3LBWriteFormat_GIDWidth(w) (((w)&0x7)<<20)
#define PM3LBWriteFormat_GIDPosition(p) (((p)&0x1f)<<23)
#define PM3LBWriteMode 0x88c0
#define PM3LBWriteModeAnd 0xac80
#define PM3LBWriteModeOr 0xac88
#define PM3LBWriteMode_WriteDisable 0<<0
#define PM3LBWriteMode_WriteEnable 1<<0
#define PM3LBWriteMode_StripePitch(p) (((p)&0x7)<<3)
#define PM3LBWriteMode_StripeHeight(h) (((h)&0x7)<<6)
#define PM3LBWriteMode_Layout 1<<9
#define PM3LBWriteMode_Origin 1<<10
#define PM3LBWriteMode_Packed16 1<<11
#define PM3LBWriteMode_Width(w) (((w)&0xfff)<<12)
/* ... */
#define PM3LineStippleMode 0x81a8
#define PM3LineStippleModeAnd 0xabc0
#define PM3LineStippleModeOr 0xabc8
#define PM3LoadLineStippleCounters 0x81b0
/* ... */
#define PM3LogicalOpMode 0x8828
#define PM3LogicalOpModeAnd 0xace0
#define PM3LogicalOpModeOr 0xace8
#define PM3LogicalOpMode_Disable (0<<0)
#define PM3LogicalOpMode_Enable (1<<0)
#define PM3LogicalOpMode_LogicOp(op) (((op)&0xf)<<1)
#define PM3LogicalOpMode_UseConstantWriteData_Disable (0<<5)
#define PM3LogicalOpMode_UseConstantWriteData_Enable (1<<5)
#define PM3LogicalOpMode_Background_Disable (0<<6)
#define PM3LogicalOpMode_Background_Enable (1<<6)
#define PM3LogicalOpMode_Background_LogicOp(op) (((op)&0xf)<<7)
#define PM3LogicalOpMode_UseConstantSource_Disable (0<<11)
#define PM3LogicalOpMode_UseConstantSource_Enable (1<<11)
/* ... */
#define PM3LUT 0x8e80
/* ... */
#define PM3LUT 0x8e80
#define PM3LUTAddress 0x84d0
#define PM3LUTData 0x84c8
#define PM3LUTIndex 0x84c0
#define PM3LUTMode 0xb378
#define PM3LUTModeAnd 0xad70
#define PM3LUTModeOr 0xad78
#define PM3LUTTransfer 0x84d8
/* ... */
#define PM3PixelSize 0x80c0
#define PM3PixelSize_GLOBAL_32BIT (0<<0)
#define PM3PixelSize_GLOBAL_16BIT (1<<0)
#define PM3PixelSize_GLOBAL_8BIT (2<<0)
#define PM3PixelSize_RASTERIZER_32BIT (0<<2)
#define PM3PixelSize_RASTERIZER_16BIT (1<<2)
#define PM3PixelSize_RASTERIZER_8BIT (2<<2)
#define PM3PixelSize_SCISSOR_AND_STIPPLE_32BIT (0<<4)
#define PM3PixelSize_SCISSOR_AND_STIPPLE_16BIT (1<<4)
#define PM3PixelSize_SCISSOR_AND_STIPPLE_8BIT (2<<4)
#define PM3PixelSize_TEXTURE_32BIT (0<<6)
#define PM3PixelSize_TEXTURE_16BIT (1<<6)
#define PM3PixelSize_TEXTURE_8BIT (2<<6)
#define PM3PixelSize_LUT_32BIT (0<<8)
#define PM3PixelSize_LUT_16BIT (1<<8)
#define PM3PixelSize_LUT_8BIT (2<<8)
#define PM3PixelSize_FRAMEBUFFER_32BIT (0<<10)
#define PM3PixelSize_FRAMEBUFFER_16BIT (1<<10)
#define PM3PixelSize_FRAMEBUFFER_8BIT (2<<10)
#define PM3PixelSize_LOGICAL_OP_32BIT (0<<12)
#define PM3PixelSize_LOGICAL_OP_16BIT (1<<12)
#define PM3PixelSize_LOGICAL_OP_8BIT (2<<12)
#define PM3PixelSize_LOCALBUFFER_32BIT (0<<14)
#define PM3PixelSize_LOCALBUFFER_16BIT (1<<14)
#define PM3PixelSize_LOCALBUFFER_8BIT (2<<14)
#define PM3PixelSize_SETUP_32BIT (0<<16)
#define PM3PixelSize_SETUP_16BIT (1<<16)
#define PM3PixelSize_SETUP_8BIT (2<<16)
#define PM3PixelSize_GLOBAL (0<<31)
#define PM3PixelSize_INDIVIDUAL (1<<31)
/* ... */
#define PM3Render 0x8038
#define PM3Render_AreaStipple_Disable (0<<0)
#define PM3Render_AreaStipple_Enable (1<<0)
#define PM3Render_LineStipple_Disable (0<<1)
#define PM3Render_LineStipple_Enable (1<<1)
#define PM3Render_ResetLine_Disable (0<<2)
#define PM3Render_ResetLine_Enable (1<<2)
#define PM3Render_FastFill_Disable (0<<3)
#define PM3Render_FastFill_Enable (1<<3)
#define PM3Render_Primitive_Line (0<<6)
#define PM3Render_Primitive_Trapezoid (1<<6)
#define PM3Render_Primitive_Point (2<<6)
#define PM3Render_Antialias_Disable (0<<8)
#define PM3Render_Antialias_Enable (1<<8)
#define PM3Render_Antialias_SubPixelRes_4x4 (0<<9)
#define PM3Render_Antialias_SubPixelRes_8x8 (1<<9)
#define PM3Render_UsePointTable_Disable (0<<10)
#define PM3Render_UsePointTable_Enable (1<<10)
#define PM3Render_SyncOnbitMask_Disable (0<<11)
#define PM3Render_SyncOnBitMask_Enable (1<<11)
#define PM3Render_SyncOnHostData_Disable (0<<12)
#define PM3Render_SyncOnHostData_Enable (1<<12)
#define PM3Render_Texture_Disable (0<<13)
#define PM3Render_Texture_Enable (1<<13)
#define PM3Render_Fog_Disable (0<<14)
#define PM3Render_Fog_Enable (1<<14)
#define PM3Render_Coverage_Disable (0<<15)
#define PM3Render_Coverage_Enable (1<<15)
#define PM3Render_SubPixelCorrection_Disable (0<<16)
#define PM3Render_SubPixelCorrection_Enable (1<<16)
#define PM3Render_SpanOperation_Disable (0<<18)
#define PM3Render_SpanOperation_Enable (1<<18)
#define PM3Render_FBSourceRead_Disable (0<<27)
#define PM3Render_FBSourceRead_Enable (1<<27)
#define PM3RasterizerMode 0x80a0
#define PM3RasterizerModeAnd 0xaba0
#define PM3RasterizerModeOr 0xabb8
#define PM3RectangleHeight 0x94e0
#define PM3Render 0x8038
#define PM3RepeatLine 0x9328
#define PM3ResetPickResult 0x8c20
#define PM3RLEMask 0x8c48
#define PM3RouterMode 0x8840
#define PM3RStart 0x8780
#define PM3S1Start 0x8400
#define PM3aveLineStippleCounters 0x81c0
#define PM3ScissorMaxXY 0x8190
#define PM3ScissorMinXY 0x8188
#define PM3ScissorMode 0x8180
#define PM3ScissorModeAnd 0xabb0
#define PM3ScissorModeOr 0xabb8
#define PM3ScreenSize 0x8198
#define PM3Security 0x8908
#define PM3SetLogicalTexturePage 0xb360
#define PM3SizeOfFramebuffer 0xb0a8
#define PM3SStart 0x8388
#define PM3StartXDom 0x8000
#define PM3StartXSub 0x8010
#define PM3StartY 0x8020
/* ... */
#define PM3SpanColorMask 0x8168
/* ... */
#define PM3TextureApplicationMode 0x8680
#define PM3TextureApplicationModeAnd 0xac50
#define PM3TextureApplicationModeOr 0xac58
#define PM3TextureBaseAddr 0x8500
#define PM3TextureCacheControl 0x8490
#define PM3TextureChromaLower0 0x84f0
#define PM3TextureChromaLower1 0x8608
#define PM3TextureChromaUpper0 0x84e8
#define PM3TextureChromaUpper1 0x8600
#define PM3TextureCompositeAlphaMode0 0xb310
#define PM3TextureCompositeAlphaMode0And 0xb390
#define PM3TextureCompositeAlphaMode0Or 0xb398
#define PM3TextureCompositeAlphaMode1 0xb320
#define PM3TextureCompositeAlphaMode1And 0xb3b0
#define PM3TextureCompositeAlphaMode1Or 0xb3b8
#define PM3TextureCompositeColorMode0 0xb308
#define PM3TextureCompositeColorMode0And 0xb380
#define PM3TextureCompositeColorMode0Or 0xb388
#define PM3TextureCompositeColorMode1 0xb318
#define PM3TextureCompositeColorMode1And 0xb3a0
#define PM3TextureCompositeColorMode1Or 0xb3a8
#define PM3TextureCompositeFactor0 0xb328
#define PM3TextureCompositeFactor1 0xb330
#define PM3TextureCompositeMode 0xb300
#define PM3TextureCoordMode 0x8380
#define PM3TextureCoordModeAnd 0xac20
#define PM3TextureCoordModeOr 0xac28
#define PM3TextureData 0x88e8
/*
#define PM3TextureDownloadControl 0x0108
*/
#define PM3TextureDownloadOffset 0x88f0
#define PM3TextureEnvColor 0x8688
#define PM3TextureFilterMode 0x84e0
#define PM3TextureFilterModeAnd 0xad50
#define PM3TextureFilterModeOr 0xad58
#define PM3TextureIndexMode0 0xb338
#define PM3TextureIndexMode0And 0xb3c0
#define PM3TextureIndexMode0Or 0xb3c8
#define PM3TextureIndexMode1 0xb340
#define PM3TextureIndexMode1And 0xb3d0
#define PM3TextureIndexMode1Or 0xb3d8
/* ... */
#define PM3TextureMapSize 0xb428
#define PM3TextureMapWidth0 0x8580
#define PM3TextureMapWidth1 0x8588
#define PM3TextureMapWidth_Width(w) ((w&0xfff)<<0)
#define PM3TextureMapWidth_BorderLayout (1<<12)
#define PM3TextureMapWidth_Layout_Linear (0<<13)
#define PM3TextureMapWidth_Layout_Patch64 (1<<13)
#define PM3TextureMapWidth_Layout_Patch32_2 (2<<13)
#define PM3TextureMapWidth_Layout_Patch2 (3<<13)
#define PM3TextureMapWidth_HostTexture (1<<15)
#define PM3TextureReadMode0 0xb400
#define PM3TextureReadMode0And 0xac30
#define PM3TextureReadMode0Or 0xac38
#define PM3TextureReadMode1 0xb408
#define PM3TextureReadMode1And 0xad40
#define PM3TextureReadMode1Or 0xad48
/* ... */
#define PM3WaitForCompletion 0x80b8
#define PM3Window 0x8980
#define PM3Window_ForceLBUpdate 1<<3
#define PM3Window_LBUpdateSource 1<<4
#define PM3Window_FrameCount(c) (((c)&0xff)<<9
#define PM3Window_StencilFCP 1<<17
#define PM3Window_DepthFCP 1<<18
#define PM3Window_OverrideWriteFiltering 1<<19
#define PM3WindowAnd 0xab80
#define PM3WindowOr 0xab88
#define PM3WindowOrigin 0x81c8
#define PM3XBias 0x9480
#define PM3YBias 0x9488
#define PM3YLimits 0x80a8
#define PM3UVMode 0x8f00
#define PM3ZFogBias 0x86b8
#define PM3ZStart 0xadd8
#define PM3ZStartL 0x89b8
#define PM3ZStartU 0x89b0
/**********************************************
* GLINT Permedia3 2D setup Unit *
***********************************************/
#define PM3Config2D 0xb618
#define PM3Config2D_OpaqueSpan 1<<0
#define PM3Config2D_MultiRXBlit 1<<1
#define PM3Config2D_UserScissorEnable 1<<2
#define PM3Config2D_FBDestReadEnable 1<<3
#define PM3Config2D_AlphaBlendEnable 1<<4
#define PM3Config2D_DitherEnable 1<<5
#define PM3Config2D_ForegroundROPEnable 1<<6
#define PM3Config2D_ForegroundROP(rop) (((rop)&0xf)<<7)
#define PM3Config2D_BackgroundROPEnable 1<<11
#define PM3Config2D_BackgroundROP(rop) (((rop)&0xf)<<12)
#define PM3Config2D_UseConstantSource 1<<16
#define PM3Config2D_FBWriteEnable 1<<17
#define PM3Config2D_Blocking 1<<18
#define PM3Config2D_ExternalSourceData 1<<19
#define PM3Config2D_LUTModeEnable 1<<20
#define PM3DownloadGlyphwidth 0xb658
#define PM3DownloadGlyphwidth_GlyphWidth(gw) ((gw)&0xffff)
#define PM3DownloadTarget 0xb650
#define PM3DownloadTarget_TagName(tag) ((tag)&0x1fff)
#define PM3GlyphData 0xb660
#define PM3GlyphPosition 0xb608
#define PM3GlyphPosition_XOffset(x) ((x)&0xffff)
#define PM3GlyphPosition_YOffset(y) (((y)&0xffff)<<16)
#define PM3Packed4Pixels 0xb668
#define PM3Packed8Pixels 0xb630
#define PM3Packed16Pixels 0xb638
#define PM3RectanglePosition 0xb600
#define PM3RectanglePosition_XOffset(x) ((x)&0xffff)
#define PM3RectanglePosition_YOffset(y) (((y)&0xffff)<<16)
#define PM3Render2D 0xb640
#define PM3Render2D_Width(w) ((w)&0x0fff)
#define PM3Render2D_Operation_Normal 0<<12
#define PM3Render2D_Operation_SyncOnHostData 1<<12
#define PM3Render2D_Operation_SyncOnBitMask 2<<12
#define PM3Render2D_Operation_PatchOrderRendering 3<<12
#define PM3Render2D_FBSourceReadEnable 1<<14
#define PM3Render2D_SpanOperation 1<<15
#define PM3Render2D_Height(h) (((h)&0x0fff)<<16)
#define PM3Render2D_XPositive 1<<28
#define PM3Render2D_YPositive 1<<29
#define PM3Render2D_AreaStippleEnable 1<<30
#define PM3Render2D_TextureEnable 1<<31
#define PM3Render2DGlyph 0xb648
#define PM3Render2DGlyph_Width(w) ((w)&0x7f)
#define PM3Render2DGlyph_Height(h) (((h)&0x7f)<<7)
#define PM3Render2DGlyph_XOffset(x) (((x)&0x1ff)<<14)
#define PM3Render2DGlyph_YOffset(y) (((y)&0x1ff)<<23)
#define PM3RenderPatchOffset 0xb610
#define PM3RenderPatchOffset_XOffset(x) ((x)&0xffff)
#define PM3RenderPatchOffset_YOffset(y) (((y)&0xffff)<<16)
#define PM3RLCount 0xb678
#define PM3RLCount_Count(c) ((c)&0x0fff)
#define PM3RLData 0xb670
/**********************************************
* GLINT Permedia3 Alias Register *
***********************************************/
#define PM3FillBackgroundColor 0x8330
#define PM3FillConfig2D0 0x8338
#define PM3FillConfig2D1 0x8360
#define PM3FillConfig2D_OpaqueSpan 1<<0
#define PM3FillConfig2D_MultiRXBlit 1<<1
#define PM3FillConfig2D_UserScissorEnable 1<<2
#define PM3FillConfig2D_FBDestReadEnable 1<<3
#define PM3FillConfig2D_AlphaBlendEnable 1<<4
#define PM3FillConfig2D_DitherEnable 1<<5
#define PM3FillConfig2D_ForegroundROPEnable 1<<6
#define PM3FillConfig2D_ForegroundROP(rop) (((rop)&0xf)<<7)
#define PM3FillConfig2D_BackgroundROPEnable 1<<11
#define PM3FillConfig2D_BackgroundROP(rop) (((rop)&0xf)<<12)
#define PM3FillConfig2D_UseConstantSource 1<<16
#define PM3FillConfig2D_FBWriteEnable 1<<17
#define PM3FillConfig2D_Blocking 1<<18
#define PM3FillConfig2D_ExternalSourceData 1<<19
#define PM3FillConfig2D_LUTModeEnable 1<<20
#define PM3FillFBDestReadBufferAddr 0x8310
#define PM3FillFBSourceReadBufferAddr 0x8308
#define PM3FillFBSourceReadBufferOffset 0x8340
#define PM3FillFBSourceReadBufferOffset_XOffset(x) ((x)&0xffff)
#define PM3FillFBSourceReadBufferOffset_YOffset(y) (((y)&0xffff)<<16)
#define PM3FillFBWriteBufferAddr 0x8300
#define PM3FillForegroundColor0 0x8328
#define PM3FillForegroundColor1 0x8358
#define PM3FillGlyphPosition 0x8368
#define PM3FillGlyphPosition_XOffset(x) ((x)&0xffff)
#define PM3FillGlyphPosition_YOffset(y) (((y)&0xffff)<<16)
#define PM3FillRectanglePosition 0x8348
#define PM3FillRectanglePosition_XOffset(x) ((x)&0xffff)
#define PM3FillRectanglePosition_YOffset(y) (((y)&0xffff)<<16)
#define PM3_REGS_SIZE 0x10000
#define PM3_MAX_PIXCLOCK 300000
/* a few more useful registers & regs value... */
#define PM3Sync 0x8c40
#define PM3Sync_Tag 0x188
#define PM3FilterMode 0x8c00
#define PM3FilterModeSync 0x400
#define PM3OutputFifo 0x2000
#define PM3StatisticMode 0x8c08
#define PM3AreaStippleMode 0x81a0
#define AreaStipplePattern0 (0x8200)
#define AreaStipplePattern1 (0x8208)
#define AreaStipplePattern2 (0x8210)
#define AreaStipplePattern3 (0x8218)
#define AreaStipplePattern4 (0x8220)
#define AreaStipplePattern5 (0x8228)
#define AreaStipplePattern6 (0x8230)
#define AreaStipplePattern7 (0x8238)
#define AreaStipplePattern8 (0x8240)
#define AreaStipplePattern9 (0x8248)
#define AreaStipplePattern10 (0x8250)
#define AreaStipplePattern11 (0x8258)
#define AreaStipplePattern12 (0x8260)
#define AreaStipplePattern13 (0x8268)
#define AreaStipplePattern14 (0x8270)
#define AreaStipplePattern15 (0x8278)
#define AreaStipplePattern16 (0x8280)
#define AreaStipplePattern17 (0x8288)
#define AreaStipplePattern18 (0x8290)
#define AreaStipplePattern19 (0x8298)
#define AreaStipplePattern20 (0x82a0)
#define AreaStipplePattern21 (0x82a8)
#define AreaStipplePattern22 (0x82b0)
#define AreaStipplePattern23 (0x82b8)
#define AreaStipplePattern24 (0x82c0)
#define AreaStipplePattern25 (0x82c8)
#define AreaStipplePattern26 (0x82d0)
#define AreaStipplePattern27 (0x82d8)
#define AreaStipplePattern28 (0x82eo)
#define AreaStipplePattern29 (0x82e8)
#define AreaStipplePattern30 (0x82f0)
#define AreaStipplePattern31 (0x82f8)
#define AreaStipplePattern_indexed(i) (0x8200 + ((i) * 0x8))
#define PM3DepthMode 0x89a0
#define PM3StencilMode 0x8988
#define PM3StencilData 0x8990
#define PM3TextureReadMode 0x8670
#define PM3FogMode 0x8690
#define PM3ChromaTestMode 0x8f18
#define PM3YUVMode 0x8f00
#define PM3BitMaskPattern 0x8068
/* ***************************** */
/* ***** pm3fb IOCTL const ***** */
/* ***************************** */
/* debug-only IOCTL */
#define PM3FBIO_CLEARMEMORY 0x504D3300 /* 'PM3\000' */
#define PM3FBIO_CLEARCMAP 0x504D3301 /* 'PM3\001' */
/* common use IOCTL */
#define PM3FBIO_RESETCHIP 0x504D33FF /* 'PM3\377' */
/* ***************************************** */
/* ***** pm3fb useful define and macro ***** */
/* ***************************************** */
/* kernel -specific definitions */
/* what kernel is this ? */
#if ((LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)))
#define KERNEL_2_5
#endif
#if ((LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)))
#define KERNEL_2_4
#endif
#if ((LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)))
#define KERNEL_2_2
/* pci_resource_start, available in 2.2.18 */
#include <linux/kcomp.h>
#ifdef CONFIG_FB_OF
#define SUPPORT_FB_OF
#endif
#endif
#if (!defined(KERNEL_2_2)) && (!defined(KERNEL_2_4)) && (!defined(KERNEL_2_5))
#error "Only kernel 2.2.x, kernel 2.4.y and kernel 2.5.z might work"
#endif
/* not sure if/why it's needed. doesn't work without on my PowerMac... */
#ifdef __BIG_ENDIAN
#define MUST_BYTESWAP
#endif
/* for compatibility between 2.5, 2.4 and 2.2 */
#ifndef B_FREE
#define B_FREE -1
#endif
/* permedia3 -specific definitions */
#define PM3_SCALE_TO_CLOCK(pr, fe, po) ((2 * PM3_REF_CLOCK * fe) / (pr * (1 << (po))))
/* in case it's not in linux/pci.h */
#ifndef PCI_DEVICE_ID_3DLABS_PERMEDIA3
#define PCI_DEVICE_ID_3DLABS_PERMEDIA3 0x000a
#endif
/* max number of simultaneous board */
/* warning : make sure module array def's are coherent with PM3_MAX_BOARD */
#define PM3_MAX_BOARD 4
#define PM3_MAX_BOARD_MODULE_ARRAY_SHORT "1-4h"
#define PM3_MAX_BOARD_MODULE_ARRAY_STRING "1-4s"
/* max size of options */
#define PM3_OPTIONS_SIZE 256
/* max size of font name */
#define PM3_FONTNAME_SIZE 40
/* do we want accelerated console */
#define PM3FB_USE_ACCEL 1
/* useful ? */
#define CHAR_IS_NUM(a) ((((a) >= '0') && ((a) <= '9')) ? 1 : 0)
/* for driver debugging ONLY */
/* 0 = assert only, 1 = error, 2 = info, 3+ = verbose */
/* define PM3FB_MASTER_DEBUG 1 */
#if defined(PM3FB_MASTER_DEBUG) && (PM3FB_MASTER_DEBUG >= 3)
#define PM3FB_TRACE
#endif /* defined(PM3FB_MASTER_DEBUG) && (PM3FB_MASTER_DEBUG >= 3) */
#ifdef PM3FB_MASTER_DEBUG
#define DPRINTK(l,a,b...) do { if ((l) <= PM3FB_MASTER_DEBUG) printk("pm3fb: %s: " a, __FUNCTION__ , ## b); } while (0)
#define DASSERT(t,a,b...) do { if (!(t)) printk("pm3fb: _assert failed: %s: " a, __FUNCTION__ , ## b); } while (0)
#ifdef PM3FB_TRACE
#define DTRACE printk("pm3fb: _enter %s\n", __FUNCTION__)
#else /* PM3FB_TRACE */
#define DTRACE
#endif /* PM3FB_TRACE */
#else /* PM3FB_MASTER_DEBUG */
#define DPRINTK(l,a,b...)
#define DASSERT(t,a,b...)
#define DTRACE
#endif /* PM3FB_MASTER_DEBUG */
#if defined(PM3FB_MASTER_DEBUG) && (PM3FB_MASTER_DEBUG >= 2)
#define PM3_SHOW_CUR_MODE pm3fb_show_cur_mode(l_fb_info)
#else
#define PM3_SHOW_CUR_MODE /* pm3fb_show_cur_mode() */
#endif
/* ******************************************** */
/* ***** A bunch of register-access macro ***** */
/* ******************************************** */
#ifdef KERNEL_2_2
#ifdef MUST_BYTESWAP /* we are writing big_endian to big_endian through a little_endian macro */
#define PM3_READ_REG(r) __swab32(readl((l_fb_info->vIOBase + r)))
#define PM3_WRITE_REG(r, v) writel(__swab32(v), (l_fb_info->vIOBase + r))
#else /* MUST_BYTESWAP */
#define PM3_WRITE_REG(r, v) writel(v, (l_fb_info->vIOBase + r))
#define PM3_READ_REG(r) readl((l_fb_info->vIOBase + r))
#endif /* MUST_BYTESWAP */
#endif /* KERNEL_2_2 */
#if (defined KERNEL_2_4) || (defined KERNEL_2_5) /* native-endian access */
#define PM3_WRITE_REG(r, v) fb_writel(v, (l_fb_info->vIOBase + r))
#define PM3_READ_REG(r) fb_readl((l_fb_info->vIOBase + r))
#endif /* KERNEL_2_4 or KERNEL_2_5 */
#define depth2bpp(d) ((d + 7L) & ~7L)
#define depth2ByPP(d) (depth2bpp(d) / 8)
#define depth_supported(d) ((d == 8) || (d == 12) || (d == 15) || (d == 16) || (d==32))
#define PM3_WAIT(n) \
do{ \
while(PM3_READ_REG(PM3InFIFOSpace)<(n)); \
} while(0)
#define PM3_DELAY(x) do { \
int delay = x; \
unsigned char tmp; \
while(delay--){tmp = PM3_READ_REG(PM3InFIFOSpace);}; \
} while(0)
#define PM3_SLOW_WRITE_REG(r,v) \
do{ \
DASSERT((l_fb_info->vIOBase != (unsigned char*)(-1)), "l_fb_info->vIOBase mapped in slow write\n"); \
mb(); \
PM3_WAIT(1); \
mb(); \
PM3_WRITE_REG(r,v); \
} while(0)
#define PM3_SET_INDEX(index) \
do{ \
PM3_SLOW_WRITE_REG(PM3RD_IndexHigh,(((index)>>8)&0xff)); \
PM3_SLOW_WRITE_REG(PM3RD_IndexLow,((index)&0xff)); \
} while(0)
#define PM3_WRITE_DAC_REG(r, v) \
do { \
DASSERT((l_fb_info->vIOBase != (unsigned char*)(-1)), "l_fb_info->vIOBase mapped in write dac reg\n"); \
PM3_SET_INDEX(r); \
mb(); \
PM3_WRITE_REG(PM3RD_IndexedData, v); \
} while (0)
/* next one is really a function, added as a macro to be consistent */
#define PM3_READ_DAC_REG(r) pm3fb_read_dac_reg(l_fb_info, r)
#define PM3_COLOR(c) \
do { \
if (l_fb_info->current_par->depth == 8) \
{ \
c = (c & 0xFF); \
c = c | (c << 8); \
} \
if ((l_fb_info->current_par->depth == 8) || (depth2bpp(l_fb_info->current_par->depth) == 16)) \
{ \
c = (c & 0xFFFF); \
c = c | (c << 16); \
} \
} while (0)
#endif PM3FB_H
/*
* linux/drivers/video/q40fb.c -- Q40 frame buffer device
*
* Copyright (C) 2001
*
* Richard Zidlicky <Richard.Zidlicky@stud.informatik.uni-erlangen.de>
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file COPYING in the main directory of this archive for
* more details.
*/
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/string.h>
......@@ -9,181 +21,68 @@
#include <asm/uaccess.h>
#include <asm/setup.h>
#include <asm/segment.h>
#include <asm/system.h>
/*#include <asm/irq.h>*/
#include <asm/q40_master.h>
#include <linux/fb.h>
#include <linux/module.h>
#include <asm/pgtable.h>
#include <video/fbcon.h>
#include <video/fbcon-cfb16.h>
#define FBIOSETSCROLLMODE 0x4611
#define Q40_PHYS_SCREEN_ADDR 0xFE800000
static u16 fbcon_cmap_cfb16[16];
static u32 pseudo_palette[17];
static struct fb_info fb_info;
static struct display display;
static struct fb_fix_screeninfo q40fb_fix __initdata = {
id: "Q40",
smem_len: 1024*1024,
type: FB_TYPE_PACKED_PIXELS,
visual: FB_VISUAL_TRUECOLOR,
line_length: 1024*2,
accel_flags: FB_ACCEL_NONE,
};
static struct fb_var_screeninfo q40fb_var __initdata = {
xres: 1024,
yres: 512,
xres_virtual: 1024,
yres_virtual: 512,
bits_per_pixel: 16,
red: {6, 5, 0},
green: {11, 5, 0},
blue: {0, 6, 0},
activate: FB_ACTIVATE_NOW,
height: 230,
width: 300,
vmode: FB_VMODE_NONINTERLACED,
};
/* frame buffer operations */
int q40fb_init(void);
static int q40fb_get_fix(struct fb_fix_screeninfo *fix, int con,
struct fb_info *info);
static int q40fb_get_var(struct fb_var_screeninfo *var, int con,
struct fb_info *info);
static int q40fb_set_var(struct fb_var_screeninfo *var, int con,
struct fb_info *info);
static int q40fb_get_cmap(struct fb_cmap *cmap,int kspc,int con,
struct fb_info *info);
static int q40fb_set_cmap(struct fb_cmap *cmap,int kspc,int con,
struct fb_info *info);
static int q40fb_setcolreg(unsigned regno, unsigned red, unsigned green,
unsigned blue, unsigned transp,
const struct fb_info *info);
static int q40con_switch(int con, struct fb_info *info);
static int q40con_updatevar(int con, struct fb_info *info);
static void q40fb_set_disp(int con, struct fb_info *info);
struct fb_info *info);
static struct display disp[MAX_NR_CONSOLES];
static struct fb_info fb_info;
static struct fb_ops q40fb_ops = {
owner: THIS_MODULE,
fb_get_fix: q40fb_get_fix,
fb_get_var: q40fb_get_var,
fb_set_var: q40fb_set_var,
fb_get_cmap: q40fb_get_cmap,
fb_set_cmap: q40fb_set_cmap,
fb_get_fix: gen_get_fix,
fb_get_var: gen_get_var,
fb_set_var: gen_set_var,
fb_get_cmap: gen_get_cmap,
fb_set_cmap: gen_set_cmap,
fb_setcolreg: q40fb_setcolreg,
fb_fillrect: cfb_fillrect,
fb_copyarea: cfb_copyarea,
fb_imageblit: cfb_imageblit,
};
static char q40fb_name[]="Q40";
static int q40fb_get_fix(struct fb_fix_screeninfo *fix, int con,
struct fb_info *info)
{
memset(fix, 0, sizeof(struct fb_fix_screeninfo));
strcpy(fix->id,"Q40");
fix->smem_start = info->screen_base;
fix->smem_len=1024*1024;
fix->type=FB_TYPE_PACKED_PIXELS;
fix->type_aux=0;
fix->visual=FB_VISUAL_TRUECOLOR; /* good approximation so far ..*/;
fix->xpanstep=0;
fix->ypanstep=0;
fix->ywrapstep=0;
fix->line_length=1024*2;
/* no mmio,accel ...*/
return 0;
}
static int q40fb_get_var(struct fb_var_screeninfo *var, int con,
struct fb_info *info)
{
memset(var, 0, sizeof(struct fb_var_screeninfo));
var->xres=1024;
var->yres=512;
var->xres_virtual=1024;
var->yres_virtual=512;
var->xoffset=0;
var->yoffset=0;
var->bits_per_pixel=16;
var->grayscale=0;
var->nonstd=0;
var->activate=FB_ACTIVATE_NOW;
var->height=230; /* approx for my 17" monitor, more important */
var->width=300; /* than the absolute values is the unusual aspect ratio*/
var->red.offset=6; /*6*/
var->red.length=5;
var->green.offset=11; /*11*/
var->green.length=5;
var->blue.offset=0;
var->blue.length=6;
var->transp.length=0;
var->pixclock=0;
var->left_margin=0;
var->right_margin=0;
var->hsync_len=0;
var->vsync_len=0;
var->sync=0;
var->vmode=FB_VMODE_NONINTERLACED;
return 0;
}
static int q40fb_set_var(struct fb_var_screeninfo *var, int con,
struct fb_info *info)
{
if(var->xres!=1024)
return -EINVAL;
if(var->yres!=512)
return -EINVAL;
if(var->xres_virtual!=1024)
return -EINVAL;
if(var->yres_virtual!=512)
return -EINVAL;
if(var->xoffset!=0)
return -EINVAL;
if(var->yoffset!=0)
return -EINVAL;
if(var->bits_per_pixel!=16)
return -EINVAL;
if(var->grayscale!=0)
return -EINVAL;
if(var->nonstd!=0)
return -EINVAL;
if(var->activate!=FB_ACTIVATE_NOW)
return -EINVAL;
if(var->pixclock!=0)
return -EINVAL;
if(var->left_margin!=0)
return -EINVAL;
if(var->right_margin!=0)
return -EINVAL;
if(var->hsync_len!=0)
return -EINVAL;
if(var->vsync_len!=0)
return -EINVAL;
if(var->sync!=0)
return -EINVAL;
if(var->vmode!=FB_VMODE_NONINTERLACED)
return -EINVAL;
return 0;
}
static int q40_getcolreg(unsigned regno, unsigned *red, unsigned *green,
unsigned *blue, unsigned *transp,
struct fb_info *info)
{
/*
* Read a single color register and split it into colors/transparent.
* The return values must have a 16 bit magnitude.
* Return != 0 for invalid regno.
*/
if (regno>=16) return 1;
*transp=0;
*green = ((fbcon_cmap_cfb16[regno]>>11) & 31)<<11;
*red = ((fbcon_cmap_cfb16[regno]>>6) & 31)<<11;
*blue = ((fbcon_cmap_cfb16[regno]) & 63)<<10;
return 0;
}
static int q40fb_setcolreg(unsigned regno, unsigned red, unsigned green,
unsigned blue, unsigned transp,
const struct fb_info *info)
struct fb_info *info)
{
/*
* Set a single color register. The values supplied have a 16 bit
......@@ -196,119 +95,43 @@ static int q40fb_setcolreg(unsigned regno, unsigned red, unsigned green,
blue>>=10;
if (regno < 16) {
fbcon_cmap_cfb16[regno] = ((red & 31) <<6) |
info->pseudo_palette[regno] = ((red & 31) <<6) |
((green & 31) << 11) |
(blue & 63);
}
return 0;
}
static int q40fb_get_cmap(struct fb_cmap *cmap, int kspc, int con,
struct fb_info *info)
{
#if 1
if (con == info->currcon) /* current console? */
return fb_get_cmap(cmap, kspc, q40_getcolreg, info);
else if (fb_display[con].cmap.len) /* non default colormap? */
fb_copy_cmap(&fb_display[con].cmap, cmap, kspc ? 0 : 2);
else
fb_copy_cmap(fb_default_cmap(1<<fb_display[con].var.bits_per_pixel),
cmap, kspc ? 0 : 2);
return 0;
#else
printk(KERN_ERR "get cmap not supported\n");
return -EINVAL;
#endif
}
static int q40fb_set_cmap(struct fb_cmap *cmap, int kspc, int con,
struct fb_info *info)
int q40fb_init(void)
{
#if 1
int err;
if (!fb_display[con].cmap.len) { /* no colormap allocated? */
if ((err = fb_alloc_cmap(&fb_display[con].cmap,
1<<fb_display[con].var.bits_per_pixel,
0)))
return err;
}
if (con == info->currcon) /* current console? */
return fb_set_cmap(cmap, kspc, info);
else
fb_copy_cmap(cmap, &fb_display[con].cmap, kspc ? 0 : 1);
return 0;
#else
printk(KERN_ERR "set cmap not supported\n");
return -EINVAL;
#endif
}
static void q40fb_set_disp(int con, struct fb_info *info)
{
struct fb_fix_screeninfo fix;
struct display *display;
q40fb_get_fix(&fix, con, info);
if (con>=0)
display = &fb_display[con];
else
display = &disp[0];
if (con<0) con=0;
display->visual = fix.visual;
display->type = fix.type;
display->type_aux = fix.type_aux;
display->ypanstep = fix.ypanstep;
display->ywrapstep = fix.ywrapstep;
display->can_soft_blank = 0;
display->inverse = 0;
display->line_length = fix.line_length;
display->scrollmode = SCROLL_YREDRAW;
#ifdef FBCON_HAS_CFB16
display->dispsw = &fbcon_cfb16;
disp->dispsw_data = fbcon_cmap_cfb16;
#else
display->dispsw = &fbcon_dummy;
#endif
}
int __init q40fb_init(void)
{
if ( !MACH_IS_Q40)
return -ENXIO;
#if 0
fb_info.screen_base = kernel_map(Q40_PHYS_SCREEN_ADDR, 1024*1024,
KERNELMAP_NO_COPYBACK, NULL);
#else
fb_info.screen_base = Q40_PHYS_SCREEN_ADDR; /* mapped in q40/config.c */
#endif
fb_info.changevar=NULL;
strcpy(&fb_info.modename[0],q40fb_name);
fb_info.fontname[0]=0;
fb_info.disp=disp;
fb_info.currcon = -1;
fb_info.switch_con=&q40con_switch;
fb_info.updatevar=&q40con_updatevar;
/* mapped in q40/config.c */
q40fb_fix.smem_start = Q40_PHYS_SCREEN_ADDR;
fb_info.var = q40fb_var;
fb_info.fix = q40fb_fix;
fb_info.node = NODEV;
fb_info.fbops = &q40fb_ops;
fb_info.flags = FBINFO_FLAG_DEFAULT; /* not as module for now */
fb_info.pseudo_palette = pseudo_palette;
fb_info.screen_base = (char *) q40fb_fix.smem_start;
/* The below feilds will go away !!!! */
fb_info.currcon = -1;
strcpy(fb_info.modename, fb_info.fix.id);
fb_info.disp = &display;
fb_info.switch_con = gen_switch;
fb_info.updatevar = gen_update_var;
fb_alloc_cmap(&fb_info.cmap, 16, 0);
master_outb(3,DISPLAY_CONTROL_REG);
gen_set_disp(-1, &fb_info);
q40fb_get_var(&disp[0].var, 0, &fb_info);
q40fb_set_disp(-1, &fb_info);
master_outb(3, DISPLAY_CONTROL_REG);
if (register_framebuffer(&fb_info) < 0) {
printk(KERN_ERR "unable to register Q40 frame buffer\n");
printk(KERN_ERR "Unable to register Q40 frame buffer\n");
return -EINVAL;
}
......@@ -317,16 +140,4 @@ int __init q40fb_init(void)
return 0;
}
static int q40con_switch(int con, struct fb_info *info)
{
info->currcon=con;
return 0;
}
static int q40con_updatevar(int con, struct fb_info *info)
{
return 0;
}
MODULE_LICENSE("GPL");
/*
* linux/drivers/video/skeletonfb.c -- Skeleton for a frame buffer device
*
* Modified to new api Jan 2001 by James Simmons (jsimmons@transvirtual.com)
*
* Created 28 Dec 1997 by Geert Uytterhoeven
*
*
* I have started rewriting this driver as a example of the upcoming new API
* The primary goal is to remove the console code from fbdev and place it
* into fbcon.c. This reduces the code and makes writing a new fbdev driver
* easy since the author doesn't need to worry about console internals. It
* also allows the ability to run fbdev without a console/tty system on top
* of it.
*
* First the roles of struct fb_info and struct display have changed. Struct
* display will go away. The way the the new framebuffer console code will
* work is that it will act to translate data about the tty/console in
* struct vc_data to data in a device independent way in struct fb_info. Then
* various functions in struct fb_ops will be called to store the device
* dependent state in the par field in struct fb_info and to change the
* hardware to that state. This allows a very clean seperation of the fbdev
* layer from the console layer. It also allows one to use fbdev on its own
* which is a bounus for embedded devices. The reason this approach works is
* for each framebuffer device when used as a tty/console device is allocated
* a set of virtual terminals to it. Only one virtual terminal can be active
* per framebuffer device. We already have all the data we need in struct
* vc_data so why store a bunch of colormaps and other fbdev specific data
* per virtual terminal.
*
* As you can see doing this makes the con parameter pretty much useless
* for struct fb_ops functions, as it should be. Also having struct
* fb_var_screeninfo and other data in fb_info pretty much eliminates the
* need for get_fix and get_var. Once all drivers use the fix, var, and cmap
* fbcon can be written around these fields. This will also eliminate the
* need to regenerate struct fb_var_screeninfo, struct fb_fix_screeninfo
* struct fb_cmap every time get_var, get_fix, get_cmap functions are called
* as many drivers do now.
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file COPYING in the main directory of this archive
* for more details.
* License. See the file COPYING in the main directory of this archive for
* more details.
*/
#include <linux/module.h>
......@@ -19,9 +53,6 @@
#include <linux/fb.h>
#include <linux/init.h>
#include <video/fbcon.h>
/*
* This is just simple sample code.
*
......@@ -29,310 +60,410 @@
* Even less warranty that it actually works :-)
*/
struct xxxfb_info {
/*
* Choose _one_ of the two alternatives:
*
* 1. Use the generic frame buffer operations (fbgen_*).
/*
* If your driver supports multiple boards, you should make the
* below data types arrays, or allocate them dynamically (using kmalloc()).
*/
struct fb_info_gen gen;
/*
* 2. Provide your own frame buffer operations.
/*
* This structure defines the hardware state of the graphics card. Normally
* you place this in a header file in linux/include/video. This file usually
* also includes register information. That allows other driver subsystems
* and userland applications the ability to use the same header file to
* avoid duplicate work and easy porting of software.
*/
struct fb_info info;
struct xxx_par;
/* Here starts the frame buffer device dependent part */
/* You can use this to store e.g. the board number if you support */
/* multiple boards */
/*
* Here we define the default structs fb_fix_screeninfo and fb_var_screeninfo
* if we don't use modedb. If we do use modedb see xxxfb_init how to use it
* to get a fb_var_screeninfo. Otherwise define a default var as well.
*/
static struct fb_fix_screeninfo xxxfb_fix __initdata = {
id: "FB's name",
type: FB_TYPE_PACKED_PIXELS,
visual: FB_VISUAL_PSEUDOCOLOR,
xpanstep: 1,
ypanstep: 1,
ywrapstep: 1,
accel: FB_ACCEL_NONE,
};
struct xxxfb_par {
/*
* The hardware specific data in this structure uniquely defines a video
* mode.
*
* If your hardware supports only one video mode, you can leave it empty.
* Modern graphical hardware not only supports pipelines but some
* also support multiple monitors where each display can have its
* its own unique data. In this case each display could be
* represented by a seperate framebuffer device thus a seperate
* struct fb_info. Now the struct xxx_par represents the graphics
* hardware state thus only one exist per card. In this case the
* struct xxx_par for each graphics card would be shared between
* every struct fb_info that represents a framebuffer on that card.
* This allows when one display changes it video resolution (info->var)
* the other displays know instantly. Each display can always be
* aware of the entire hardware state that affects it because they share
* the same xxx_par struct. The other side of the coin is multiple
* graphics cards that pass data around until it is finally displayed
* on one monitor. Such examples are the voodoo 1 cards and high end
* NUMA graphics servers. For this case we have a bunch of pars, each
* one that represents a graphics state, that belong to one struct
* fb_info. Their you would want to have *par point to a array of device
* states and have each struct fb_ops function deal with all those
* states. I hope this covers every possible hardware design. If not
* feel free to send your ideas at jsimmons@users.sf.net
*/
};
/*
* If your driver supports multiple boards or it supports multiple
* framebuffers, you should make these arrays, or allocate them
* dynamically (using kmalloc()).
*/
static struct fb_info info;
/*
* If your driver supports multiple boards, you should make these arrays,
* or allocate them dynamically (using kmalloc()).
* Each one represents the a state of the hardware. Most hardware have
* just one hardware state. These here represent the default state(s).
*/
static struct xxx_par __initdata current_par;
static struct xxxfb_info fb_info;
static struct xxxfb_par current_par;
static int current_par_valid = 0;
/* To go away in the near future */
static struct display disp;
static struct fb_var_screeninfo default_var;
static int inverse = 0;
int xxxfb_init(void);
int xxxfb_setup(char*);
/* ------------------- chipset specific functions -------------------------- */
static void xxx_detect(void)
{
/*
* This function should detect the current video mode settings and store
* it as the default video mode
/**
* xxxfb_check_var - Optional function. Validates a var passed in.
* @var: frame buffer variable screen structure
* @info: frame buffer structure that represents a single frame buffer
*
* Checks to see if the hardware supports the state requested by
* var passed in. This function does not alter the hardware state!!!
* This means the data stored in struct fb_info and struct xxx_par do
* not change. This includes the var inside of struct fb_info.
* Do NOT change these. This function can be called on its own if we
* intent to only test a mode and not actually set it. The stuff in
* modedb.c is a example of this. If the var passed in is slightly
* off by what the hardware can support then we alter the var PASSED in
* to what we can do. If the hardware doesn't support mode change
* a -EINVAL will be returned by the upper layers. You don't need to
* implement this function then.
*
* Returns negative errno on error, or zero on success.
*/
struct xxxfb_par par;
/* ... */
xxx_get_par(&par);
xxx_encode_var(&default_var, &par);
}
static int xxx_encode_fix(struct fb_fix_screeninfo *fix, struct xxxfb_par *par,
const struct fb_info *info)
static int xxxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
{
/*
* This function should fill in the 'fix' structure based on the values
* in the `par' structure.
*/
const struct xxx_par *par = (const struct xxx_par *) info->par;
/* ... */
return 0;
}
static int xxx_decode_var(struct fb_var_screeninfo *var, struct xxxfb_par *par,
const struct fb_info *info)
{
/*
* Get the video params out of 'var'. If a value doesn't fit, round it up,
* if it's too big, return -EINVAL.
/**
* xxxfb_set_par - Optional function. Alters the hardware state.
* @info: frame buffer structure that represents a single frame buffer
*
* Using the fb_var_screeninfo in fb_info we set the resolution of the
* this particular framebuffer. This function alters the par AND the
* fb_fix_screeninfo stored in fb_info. It doesn't not alter var in
* fb_info since we are using that data. This means we depend on the
* data in var inside fb_info to be supported by the hardware.
* xxxfb_check_var is always called before xxxfb_set_par to ensure this.
*
* Suggestion: Round up in the following order: bits_per_pixel, xres,
* yres, xres_virtual, yres_virtual, xoffset, yoffset, grayscale,
* bitfields, horizontal timing, vertical timing.
*/
/* ... */
/* pixclock in picos, htotal in pixels, vtotal in scanlines */
if (!fbmon_valid_timings(pixclock, htotal, vtotal, info))
return -EINVAL;
return 0;
}
static int xxx_encode_var(struct fb_var_screeninfo *var, struct xxxfb_par *par,
const struct fb_info *info)
static int xxxfb_set_par(struct fb_info *info)
{
/*
* Fill the 'var' structure based on the values in 'par' and maybe other
* values read out of the hardware.
*/
struct xxx_par *par = (struct xxx_par *) info->par;
/* ... */
return 0;
}
static void xxx_get_par(struct xxxfb_par *par, const struct fb_info *info)
{
/*
* Fill the hardware's 'par' structure.
*/
if (current_par_valid)
*par = current_par;
else {
/* ... */
}
}
static void xxx_set_par(struct xxxfb_par *par, const struct fb_info *info)
{
/*
* Set the hardware according to 'par'.
*/
current_par = *par;
current_par_valid = 1;
/* ... */
}
static int xxx_getcolreg(unsigned regno, unsigned *red, unsigned *green,
unsigned *blue, unsigned *transp,
const struct fb_info *info)
{
/*
* Read a single color register and split it into colors/transparent.
* The return values must have a 16 bit magnitude.
* Return != 0 for invalid regno.
/**
* xxxfb_setcolreg - Optional function. Sets a color register.
* @regno: boolean, 0 copy local, 1 get_user() function
* @red: frame buffer colormap structure
* @green: The green value which can be up to 16 bits wide
* @blue: The blue value which can be up to 16 bits wide.
* @transp: If supported the alpha value which can be up to 16 bits wide.
* @info: frame buffer info structure
*
* Set a single color register. The values supplied have a 16 bit
* magnitude which needs to be scaled in this function for the hardware.
* Things to take into consideration are how many color registers, if
* any, are supported with the current color visual. With truecolor mode
* no color palettes are supported. Here a psuedo palette is created
* which we store the value in pseudo_palette in struct fb_info. For
* pseudocolor mode we have a limited color palette. To deal with this
* we can program what color is displayed for a particular pixel value.
* DirectColor is similar in that we can program each color field. If
* we have a static colormap we don't need to implement this function.
*
* Returns negative errno on error, or zero on success.
*/
/* ... */
return 0;
}
static int xxxfb_setcolreg(unsigned regno, unsigned red, unsigned green,
unsigned blue, unsigned transp,
const struct fb_info *info)
{
if (regno >= 256) /* no. of hw registers */
return 1;
/*
* Set a single color register. The values supplied have a 16 bit
* magnitude.
* Return != 0 for invalid regno.
* Program hardware... do anything you want with transp
*/
if (regno < 16) {
/*
* Make the first 16 colors of the palette available to fbcon
/* grayscale works only partially under directcolor */
if (info->var.grayscale) {
/* grayscale = 0.30*R + 0.59*G + 0.11*B */
red = green = blue = (red * 77 + green * 151 + blue * 28) >> 8;
}
/* Directcolor:
* var->{color}.offset contains start of bitfield
* var->{color}.length contains length of bitfield
* {hardwarespecific} contains width of DAC
* cmap[X] is programmed to (X << red.offset) | (X << green.offset) | (X << blue.offset)
* RAMDAC[X] is programmed to (red, green, blue)
*
* Pseudocolor:
* uses offset = 0 && length = DAC register width.
* var->{color}.offset is 0
* var->{color}.length contains widht of DAC
* cmap is not used
* DAC[X] is programmed to (red, green, blue)
* Truecolor:
* does not use RAMDAC (usually has 3 of them).
* var->{color}.offset contains start of bitfield
* var->{color}.length contains length of bitfield
* cmap is programmed to (red << red.offset) | (green << green.offset) |
* (blue << blue.offset) | (transp << transp.offset)
* RAMDAC does not exist
*/
if (is_cfb15) /* RGB 555 */
...fbcon_cmap.cfb16[regno] = ((red & 0xf800) >> 1) |
((green & 0xf800) >> 6) |
((blue & 0xf800) >> 11);
if (is_cfb16) /* RGB 565 */
...fbcon_cmap.cfb16[regno] = (red & 0xf800) |
((green & 0xfc00) >> 5) |
((blue & 0xf800) >> 11);
if (is_cfb24) /* RGB 888 */
...fbcon_cmap.cfb24[regno] = ((red & 0xff00) << 8) |
(green & 0xff00) |
((blue & 0xff00) >> 8);
if (is_cfb32) /* RGBA 8888 */
...fbcon_cmap.cfb32[regno] = ((red & 0xff00) << 16) |
((green & 0xff00) << 8) |
(blue & 0xff00) |
((transp & 0xff00) >> 8);
#define CNVT_TOHW(val,width) ((((val)<<(width))+0x7FFF-(val))>>16)
switch (info->fix.visual) {
case FB_VISUAL_TRUECOLOR:
case FB_VISUAL_PSEUDOCOLOR:
red = CNVT_TOHW(red, info->var.red.length);
green = CNVT_TOHW(green, info->var.green.length);
blue = CNVT_TOHW(blue, info->var.blue.length);
transp = CNVT_TOHW(transp, info->var.transp.length);
break;
case FB_VISUAL_DIRECTCOLOR:
/* example here assumes 8 bit DAC. Might be different
* for your hardware */
red = CNVT_TOHW(red, 8);
green = CNVT_TOHW(green, 8);
blue = CNVT_TOHW(blue, 8);
/* hey, there is bug in transp handling... */
transp = CNVT_TOHW(transp, 8);
break;
}
#undef CNVT_TOHW
/* Truecolor has hardware independent palette */
if (info->fix.visual == FB_VISUAL_TRUECOLOR) {
u32 v;
if (regno >= 16)
return 1;
v = (red << info->var.red.offset) |
(green << info->var.green.offset) |
(blue << info->var.blue.offset) |
(transp << info->var.transp.offset);
switch (info->var.bits_per_pixel) {
case 8:
/* Yes some hand held devices have this. */
((u8*)(info->pseudo_palette))[regno] = v;
break;
case 16:
((u16*)(info->pseudo_palette))[regno] = v;
break;
case 24:
case 32:
((u32*)(info->pseudo_palette))[regno] = v;
break;
}
return 0;
}
/* ... */
return 0;
}
static int xxx_pan_display(struct fb_var_screeninfo *var,
struct xxxfb_par *par, const struct fb_info *info)
{
/*
/**
* xxxfb_pan_display - NOT a required function. Pans the display.
* @var: frame buffer variable screen structure
* @info: frame buffer structure that represents a single frame buffer
*
* Pan (or wrap, depending on the `vmode' field) the display using the
* `xoffset' and `yoffset' fields of the `var' structure.
* If the values don't fit, return -EINVAL.
*
* Returns negative errno on error, or zero on success.
*
*/
static int xxxfb_pan_display(struct fb_var_screeninfo *var,
const struct fb_info *info)
{
/* ... */
return 0;
}
static int xxx_blank(int blank_mode, const struct fb_info *info)
{
/*
* Blank the screen if blank_mode != 0, else unblank. If blank == NULL
* then the caller blanks by setting the CLUT (Color Look Up Table) to all
* black. Return 0 if blanking succeeded, != 0 if un-/blanking failed due
* to e.g. a video mode which doesn't support it. Implements VESA suspend
/**
* xxxfb_blank - NOT a required function. Blanks the display.
* @blank_mode: the blank mode we want.
* @info: frame buffer structure that represents a single frame buffer
*
* Blank the screen if blank_mode != 0, else unblank. Return 0 if
* blanking succeeded, != 0 if un-/blanking failed due to e.g. a
* video mode which doesn't support it. Implements VESA suspend
* and powerdown modes on hardware that supports disabling hsync/vsync:
* blank_mode == 2: suspend vsync
* blank_mode == 3: suspend hsync
* blank_mode == 4: powerdown
*
* Returns negative errno on error, or zero on success.
*
*/
static int xxxfb_blank(int blank_mode, const struct fb_info *info)
{
/* ... */
return 0;
}
static void xxx_set_disp(const void *par, struct display *disp,
struct fb_info_gen *info)
/* ------------ Accelerated Functions --------------------- */
/*
* We provide our own functions if we have hardware acceleration
* or non packed pixel format layouts. If we have no hardware
* acceleration, we use a generic unaccelerated function. If using
* a pack pixel format just use the functions in cfb*.c. Each file
* has one of the three different accel functions we support. You
* can use these functions as fallbacks if hardware unsupported
* action is requested. Also if you have non pack pixel modes and
* non accelerated cards you have to provide your own functions.
*/
/**
* xxxfb_fillrect - REQUIRED function. Can use generic routines if
* non acclerated hardware and packed pixel based.
* Draws a rectangle on the screen.
*
* @info: frame buffer structure that represents a single frame buffer
* @x1: The x and y corrdinates of the upper left hand corner of the
* @y1: area we want to draw to.
* @width: How wide the rectangle is we want to draw.
* @height: How tall the rectangle is we want to draw.
* @color: The color to fill in the rectangle with.
* @rop: The rater operation. We can draw the rectangle with a COPY
* of XOR which provides erasing effect.
*
* This drawing operation places/removes a retangle on the screen
* depending on the rastering operation with the value of color which
* is in the current color depth format.
*/
void xxxfb_fillrect(struct fb_info *p, struct fb_fillrect *region)
{
/*
* Fill in a pointer with the virtual address of the mapped frame buffer.
* Fill in a pointer to appropriate low level text console operations (and
* optionally a pointer to help data) for the video mode `par' of your
* video hardware. These can be generic software routines, or hardware
* accelerated routines specifically tailored for your hardware.
* If you don't have any appropriate operations, you must fill in a
* pointer to dummy operations, and there will be no text output.
}
/**
* xxxfb_copyarea - REQUIRED function. Can use generic routines if
* non acclerated hardware and packed pixel based.
* Copies on area of the screen to another area.
*
* @info: frame buffer structure that represents a single frame buffer
* @sx: The x and y corrdinates of the upper left hand corner of the
* @sy: source area on the screen.
* @width: How wide the rectangle is we want to copy.
* @height: How tall the rectangle is we want to copy.
* @dx: The x and y coordinates of the destination area on the screen.
*
* This drawing operation copies a rectangular area from one area of the
* screen to another area.
*/
#ifdef FBCON_HAS_CFB8
if (is_cfb8) {
disp->dispsw = fbcon_cfb8;
} else
#endif
#ifdef FBCON_HAS_CFB16
if (is_cfb16) {
disp->dispsw = fbcon_cfb16;
disp->dispsw_data = ...fbcon_cmap.cfb16; /* console palette */
} else
#endif
#ifdef FBCON_HAS_CFB24
if (is_cfb24) {
disp->dispsw = fbcon_cfb24;
disp->dispsw_data = ...fbcon_cmap.cfb24; /* console palette */
} else
#endif
#ifdef FBCON_HAS_CFB32
if (is_cfb32) {
disp->dispsw = fbcon_cfb32;
disp->dispsw_data = ...fbcon_cmap.cfb32; /* console palette */
} else
#endif
disp->dispsw = &fbcon_dummy;
void xxxfb_copyarea(struct fb_info *p, struct fb_copyarea *area)
{
}
/**
* xxxfb_imageblit - REQUIRED function. Can use generic routines if
* non acclerated hardware and packed pixel based.
* Copies a image from system memory to the screen.
*
* @info: frame buffer structure that represents a single frame buffer
* @image: structure defining the image.
*
* This drawing operation draws a image on the screen. It can be a
* mono image (needed for font handling) or a color image (needed for
* tux).
*/
void xxxfb_imageblit(struct fb_info *p, struct fb_image *image)
{
}
/* ------------ Interfaces to hardware functions ------------ */
/* ------------ Hardware Independent Functions ------------ */
/*
* Initialization
*/
struct fbgen_hwswitch xxx_switch = {
xxx_detect, xxx_encode_fix, xxx_decode_var, xxx_encode_var, xxx_get_par,
xxx_set_par, xxx_getcolreg, xxx_pan_display, xxx_blank,
xxx_set_disp
};
int __init xxxfb_init(void)
{
int cmap_len, retval;
/*
* Here we set the screen_base to the vitrual memory address
* for the framebuffer. Usually we obtain the resource address
* from the bus layer and then translate it to virtual memory
* space via ioremap. Consult ioport.h.
*/
info.screen_base = framebuffer_virtual_memory;
info.node = NODEV;
info.fbops = &xxxfb_ops;
info.fix = xxxfb_fix;
info.pseudo_palette = pseudo_palette;
info.flags = FBINFO_FLAG_DEFAULT;
info.par = current_par;
/* The following has to be set but in th efuture will go away */
strcpy(info.modename, xxxfb_fix.id);
info.changevar = NULL;
info.currcon = -1;
info.disp = &disp;
info.switch_con = gen_switch;
info.updatevar = gen_update_var;
/* ------------ Hardware Independent Functions ------------ */
/*
* This should give a reasonable default video mode. The following is
* done when we can set a video mode.
*/
if (!mode_option)
mode_option = "640x480@60";
retval = fb_find_mode(&info.var, &info, mode_option, NULL, 0, NULL, 8);
if (!retval || retval == 4)
return -EINVAL;
/* This has to been done !!! */
fb_alloc_cmap(&info.cmap, cmap_len, 0);
/*
* Initialization
* The following is done in the case of having hardware with a static
* mode. If we are setting the mode ourselves we don't call this.
*/
info.var = xxxfb_var;
gen_set_disp(-1, &fb_info);
int __init xxxfb_init(void)
{
fb_info.gen.fbhw = &xxx_switch;
fb_info.gen.fbhw->detect();
strcpy(fb_info.gen.info.modename, "XXX");
fb_info.gen.info.changevar = NULL;
fb_info.gen.info.node = NODEV;
fb_info.gen.info.fbops = &xxxfb_ops;
fb_info.gen.info.screen_base = virtual_frame_buffer_address;
fb_info.gen.info.disp = &disp;
fb_info.gen.info.currcon = -1;
fb_info.gen.info.switch_con = &xxxfb_switch;
fb_info.gen.info.updatevar = &xxxfb_update_var;
fb_info.gen.info.flags = FBINFO_FLAG_DEFAULT;
/* This should give a reasonable default video mode */
fbgen_get_var(&disp.var, -1, &fb_info.gen.info);
fbgen_do_set_var(&disp.var, 1, &fb_info.gen);
fbgen_set_disp(-1, &fb_info.gen);
do_install_cmap(0, &fb_info.gen);
if (register_framebuffer(&fb_info.gen.info) < 0)
if (register_framebuffer(&info) < 0)
return -EINVAL;
printk(KERN_INFO "fb%d: %s frame buffer device\n", GET_FB_IDX(fb_info.gen.info.node),
fb_info.gen.info.modename);
/* uncomment this if your driver cannot be unloaded */
/* MOD_INC_USE_COUNT; */
printk(KERN_INFO "fb%d: %s frame buffer device\n", GET_FB_IDX(info.node),
info.fix.id);
return 0;
}
/*
* Cleanup
*/
void xxxfb_cleanup(struct fb_info *info)
static void __exit xxxfb_cleanup(void)
{
/*
* If your driver supports multiple boards, you should unregister and
......@@ -343,11 +474,14 @@ void xxxfb_cleanup(struct fb_info *info)
/* ... */
}
/*
* Setup
*/
/*
* Only necessary if your driver takes special options,
* otherwise we fall back on the generic fb_setup().
*/
int __init xxxfb_setup(char *options)
{
/* Parse user speficied options (`video=xxxfb:') */
......@@ -356,7 +490,6 @@ int __init xxxfb_setup(char *options)
/* ------------------------------------------------------------------------- */
/*
* Frame buffer operations
*/
......@@ -373,28 +506,29 @@ static int xxxfb_release(const struct fb_info *info, int user)
return 0;
}
/*
* In most cases the `generic' routines (fbgen_*) should be satisfactory.
* However, you're free to fill in your own replacements.
*/
static struct fb_ops xxxfb_ops = {
owner: THIS_MODULE,
fb_open: xxxfb_open, /* only if you need it to do something */
fb_release: xxxfb_release, /* only if you need it to do something */
fb_get_fix: fbgen_get_fix,
fb_get_var: fbgen_get_var,
fb_set_var: fbgen_set_var,
fb_get_cmap: fbgen_get_cmap,
/* Stuff to go away. Use generic functions for now */
fb_get_fix: gen_get_fix,
fb_get_var: gen_get_var,
fb_set_var: gen_set_var,
fb_get_cmap: gen_get_cmap,
fb_set_cmap: gen_set_cmap,
fb_check_var: xxxfb_check_var,
fb_set_par: xxxfb_set_par, /* optional */
fb_setcolreg: xxxfb_setcolreg,
fb_pan_display: fbgen_pan_display,
fb_blank: fbgen_blank,
fb_blank: xxxfb_blank, /* optional */
fb_pan_display: xxxfb_pan_display, /* optional */
fb_fillrect: xxxfb_fillrect,
fb_copyarea: xxxfb_copyarea,
fb_imageblit: xxxfb_imageblit,
fb_ioctl: xxxfb_ioctl, /* optional */
fb_mmap: xxxfb_mmap, /* optional */
};
/* ------------------------------------------------------------------------- */
......@@ -403,14 +537,8 @@ static struct fb_ops xxxfb_ops = {
*/
#ifdef MODULE
MODULE_LICENSE("GPL");
int init_module(void)
{
return xxxfb_init();
}
module_init(xxxfb_init);
#endif
module_exit(xxxfb_cleanup);
void cleanup_module(void)
{
xxxfb_cleanup(void);
}
#endif /* MODULE */
MODULE_LICENSE("GPL");
......@@ -43,6 +43,8 @@
*
* Version history:
*
* 0.1.4 (released 2002-05-28) ported over to new fbdev api by James Simmons
*
* 0.1.3 (released 1999-11-02) added Attila's panning support, code
* reorg, hwcursor address page size alignment
* (for mmaping both frame buffer and regs),
......@@ -64,174 +66,32 @@
#include <linux/mm.h>
#include <linux/tty.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/delay.h>
#include <linux/interrupt.h>
#include <linux/fb.h>
#include <linux/selection.h>
#include <linux/console.h>
#include <linux/init.h>
#include <linux/pci.h>
#include <linux/nvram.h>
#include <linux/kd.h>
#include <linux/vt_kern.h>
#include <asm/io.h>
#include <linux/timer.h>
#include <linux/spinlock.h>
#include <linux/kd.h>
#include <linux/console.h>
#include <linux/selection.h>
#include <linux/vt_kern.h>
#ifdef CONFIG_MTRR
#include <asm/mtrr.h>
#endif
#include <video/tdfx.h>
#include <video/fbcon.h>
#include <video/fbcon-cfb8.h>
#include <video/fbcon-cfb16.h>
#include <video/fbcon-cfb24.h>
#include <video/fbcon-cfb32.h>
#include <linux/spinlock.h>
#ifndef PCI_DEVICE_ID_3DFX_VOODOO5
#define PCI_DEVICE_ID_3DFX_VOODOO5 0x0009
#endif
/* membase0 register offsets */
#define STATUS 0x00
#define PCIINIT0 0x04
#define SIPMONITOR 0x08
#define LFBMEMORYCONFIG 0x0c
#define MISCINIT0 0x10
#define MISCINIT1 0x14
#define DRAMINIT0 0x18
#define DRAMINIT1 0x1c
#define AGPINIT 0x20
#define TMUGBEINIT 0x24
#define VGAINIT0 0x28
#define VGAINIT1 0x2c
#define DRAMCOMMAND 0x30
#define DRAMDATA 0x34
/* reserved 0x38 */
/* reserved 0x3c */
#define PLLCTRL0 0x40
#define PLLCTRL1 0x44
#define PLLCTRL2 0x48
#define DACMODE 0x4c
#define DACADDR 0x50
#define DACDATA 0x54
#define RGBMAXDELTA 0x58
#define VIDPROCCFG 0x5c
#define HWCURPATADDR 0x60
#define HWCURLOC 0x64
#define HWCURC0 0x68
#define HWCURC1 0x6c
#define VIDINFORMAT 0x70
#define VIDINSTATUS 0x74
#define VIDSERPARPORT 0x78
#define VIDINXDELTA 0x7c
#define VIDININITERR 0x80
#define VIDINYDELTA 0x84
#define VIDPIXBUFTHOLD 0x88
#define VIDCHRMIN 0x8c
#define VIDCHRMAX 0x90
#define VIDCURLIN 0x94
#define VIDSCREENSIZE 0x98
#define VIDOVRSTARTCRD 0x9c
#define VIDOVRENDCRD 0xa0
#define VIDOVRDUDX 0xa4
#define VIDOVRDUDXOFF 0xa8
#define VIDOVRDVDY 0xac
/* ... */
#define VIDOVRDVDYOFF 0xe0
#define VIDDESKSTART 0xe4
#define VIDDESKSTRIDE 0xe8
#define VIDINADDR0 0xec
#define VIDINADDR1 0xf0
#define VIDINADDR2 0xf4
#define VIDINSTRIDE 0xf8
#define VIDCUROVRSTART 0xfc
#define INTCTRL (0x00100000 + 0x04)
#define CLIP0MIN (0x00100000 + 0x08)
#define CLIP0MAX (0x00100000 + 0x0c)
#define DSTBASE (0x00100000 + 0x10)
#define DSTFORMAT (0x00100000 + 0x14)
#define SRCBASE (0x00100000 + 0x34)
#define COMMANDEXTRA_2D (0x00100000 + 0x38)
#define CLIP1MIN (0x00100000 + 0x4c)
#define CLIP1MAX (0x00100000 + 0x50)
#define SRCFORMAT (0x00100000 + 0x54)
#define SRCSIZE (0x00100000 + 0x58)
#define SRCXY (0x00100000 + 0x5c)
#define COLORBACK (0x00100000 + 0x60)
#define COLORFORE (0x00100000 + 0x64)
#define DSTSIZE (0x00100000 + 0x68)
#define DSTXY (0x00100000 + 0x6c)
#define COMMAND_2D (0x00100000 + 0x70)
#define LAUNCH_2D (0x00100000 + 0x80)
#define COMMAND_3D (0x00200000 + 0x120)
/* register bitfields (not all, only as needed) */
#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 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_3D_NOP 0x00
#define STATUS_RETRACE BIT(6)
#define STATUS_BUSY BIT(9)
#define MISCINIT1_CLUT_INV BIT(0)
#define MISCINIT1_2DBLOCK_DIS BIT(15)
#define DRAMINIT0_SGRAM_NUM BIT(26)
#define DRAMINIT0_SGRAM_TYPE BIT(27)
#define DRAMINIT1_MEM_SDRAM BIT(30)
#define VGAINIT0_VGA_DISABLE BIT(0)
#define VGAINIT0_EXT_TIMING BIT(1)
#define VGAINIT0_8BIT_DAC BIT(2)
#define VGAINIT0_EXT_ENABLE BIT(6)
#define VGAINIT0_WAKEUP_3C3 BIT(8)
#define VGAINIT0_LEGACY_DISABLE BIT(9)
#define VGAINIT0_ALT_READBACK BIT(10)
#define VGAINIT0_FAST_BLINK BIT(11)
#define VGAINIT0_EXTSHIFTOUT BIT(12)
#define VGAINIT0_DECODE_3C6 BIT(13)
#define VGAINIT0_SGRAM_HBLANK_DISABLE BIT(22)
#define VGAINIT1_MASK 0x1fffff
#define VIDCFG_VIDPROC_ENABLE BIT(0)
#define VIDCFG_CURS_X11 BIT(1)
#define VIDCFG_HALF_MODE BIT(4)
#define VIDCFG_DESK_ENABLE BIT(7)
#define VIDCFG_CLUT_BYPASS BIT(10)
#define VIDCFG_2X BIT(26)
#define VIDCFG_HWCURSOR_ENABLE BIT(27)
#define VIDCFG_PIXFMT_SHIFT 18
#define DACMODE_2X BIT(0)
/* VGA rubbish, need to change this for multihead support */
#define MISC_W 0x3c2
#define MISC_R 0x3cc
#define SEQ_I 0x3c4
#define SEQ_D 0x3c5
#define CRT_I 0x3d4
#define CRT_D 0x3d5
#define ATT_IW 0x3c0
#define IS1_R 0x3da
#define GRA_I 0x3ce
#define GRA_D 0x3cf
#ifndef FB_ACCEL_3DFX_BANSHEE
#define FB_ACCEL_3DFX_BANSHEE 31
#endif
#define TDFXF_HSYNC_ACT_HIGH 0x01
#define TDFXF_HSYNC_ACT_LOW 0x02
#define TDFXF_VSYNC_ACT_HIGH 0x04
......@@ -249,46 +109,10 @@
#define DPRINTK(a,b...)
#endif
#define PICOS2KHZ(a) (1000000000UL/(a))
#define KHZ2PICOS(a) (1000000000UL/(a))
#define BANSHEE_MAX_PIXCLOCK 270000.0
#define VOODOO3_MAX_PIXCLOCK 300000.0
#define VOODOO5_MAX_PIXCLOCK 350000.0
struct banshee_reg {
/* VGA rubbish */
unsigned char att[21];
unsigned char crt[25];
unsigned char gra[ 9];
unsigned char misc[1];
unsigned char seq[ 5];
/* Banshee extensions */
unsigned char ext[2];
unsigned long vidcfg;
unsigned long vidpll;
unsigned long mempll;
unsigned long gfxpll;
unsigned long dacmode;
unsigned long vgainit0;
unsigned long vgainit1;
unsigned long screensize;
unsigned long stride;
unsigned long cursloc;
unsigned long curspataddr;
unsigned long cursc0;
unsigned long cursc1;
unsigned long startaddr;
unsigned long clip0min;
unsigned long clip0max;
unsigned long clip1min;
unsigned long clip1max;
unsigned long srcbase;
unsigned long dstbase;
unsigned long miscinit0;
};
struct tdfxfb_par {
u32 pixclock;
......@@ -331,7 +155,9 @@ struct fb_info_tdfx {
unsigned long bufbase_size;
unsigned long iobase;
struct { unsigned red, green, blue, pad; } palette[256];
struct {
unsigned red, green, blue, pad;
} palette[256];
struct tdfxfb_par default_par;
struct tdfxfb_par current_par;
struct display disp;
......@@ -351,9 +177,9 @@ struct fb_info_tdfx {
struct {
int type;
int state;
int w,u,d;
int x,y,redraw;
unsigned long enable,disable;
int w, u, d;
int x, y, redraw;
unsigned long enable, disable;
unsigned long cursorimage;
struct timer_list timer;
} cursor;
......@@ -367,152 +193,136 @@ struct fb_info_tdfx {
/*
* Frame buffer device API
*/
static int tdfxfb_get_fix(struct fb_fix_screeninfo* fix,
int con,
struct fb_info* fb);
static int tdfxfb_get_var(struct fb_var_screeninfo* var,
int con,
struct fb_info* fb);
static int tdfxfb_set_var(struct fb_var_screeninfo* var,
int con,
struct fb_info* fb);
static int tdfxfb_get_fix(struct fb_fix_screeninfo *fix,
int con, struct fb_info *fb);
static int tdfxfb_get_var(struct fb_var_screeninfo *var,
int con, struct fb_info *fb);
static int tdfxfb_set_var(struct fb_var_screeninfo *var,
int con, struct fb_info *fb);
static int tdfxfb_setcolreg(u_int regno,
u_int red,
u_int green,
u_int blue,
u_int transp,
struct fb_info* fb);
static int tdfxfb_pan_display(struct fb_var_screeninfo* var,
int con,
struct fb_info* fb);
u_int blue, u_int transp, struct fb_info *fb);
static int tdfxfb_pan_display(struct fb_var_screeninfo *var,
int con, struct fb_info *fb);
static int tdfxfb_get_cmap(struct fb_cmap *cmap,
int kspc,
int con,
struct fb_info* info);
static int tdfxfb_set_cmap(struct fb_cmap* cmap,
int kspc,
int con,
struct fb_info* info);
int kspc, int con, struct fb_info *info);
static int tdfxfb_set_cmap(struct fb_cmap *cmap,
int kspc, int con, struct fb_info *info);
/*
* Interface to the low level console driver
*/
static int tdfxfb_switch_con(int con,
struct fb_info* fb);
static int tdfxfb_updatevar(int con,
struct fb_info* fb);
static int tdfxfb_blank(int blank,
struct fb_info* fb);
static int tdfxfb_switch_con(int con, struct fb_info *fb);
static int tdfxfb_updatevar(int con, struct fb_info *fb);
static int tdfxfb_blank(int blank, struct fb_info *fb);
/*
* Internal routines
*/
static void tdfxfb_set_par(const struct tdfxfb_par* par,
struct fb_info_tdfx*
info);
static void tdfxfb_set_par(const struct tdfxfb_par *par,
struct fb_info_tdfx *info);
static int tdfxfb_decode_var(const struct fb_var_screeninfo *var,
struct tdfxfb_par *par,
const struct fb_info_tdfx *info);
static int tdfxfb_encode_var(struct fb_var_screeninfo* var,
const struct tdfxfb_par* par,
const struct fb_info_tdfx* info);
static int tdfxfb_encode_fix(struct fb_fix_screeninfo* fix,
const struct tdfxfb_par* par,
const struct fb_info_tdfx* info);
static void tdfxfb_set_dispsw(struct display* disp,
struct fb_info_tdfx* info,
int bpp,
int accel);
static int tdfxfb_encode_var(struct fb_var_screeninfo *var,
const struct tdfxfb_par *par,
const struct fb_info_tdfx *info);
static int tdfxfb_encode_fix(struct fb_fix_screeninfo *fix,
const struct tdfxfb_par *par,
const struct fb_info_tdfx *info);
static void tdfxfb_set_dispsw(struct display *disp,
struct fb_info_tdfx *info,
int bpp, int accel);
static int tdfxfb_getcolreg(u_int regno,
u_int* red,
u_int* green,
u_int* blue,
u_int* transp,
struct fb_info* fb);
u_int * red,
u_int * green,
u_int * blue,
u_int * transp, struct fb_info *fb);
static void tdfxfb_hwcursor_init(void);
static void tdfxfb_createcursorshape(struct display* p);
static void tdfxfb_createcursor(struct display * p);
static void tdfxfb_createcursorshape(struct display *p);
static void tdfxfb_createcursor(struct display *p);
/*
* do_xxx: Hardware-specific functions
*/
static void do_pan_var(struct fb_var_screeninfo* var, struct fb_info_tdfx *i);
static void do_pan_var(struct fb_var_screeninfo *var,
struct fb_info_tdfx *i);
static void do_flashcursor(unsigned long ptr);
static void do_bitblt(u32 curx, u32 cury, u32 dstx,u32 dsty,
u32 width, u32 height,u32 stride,u32 bpp);
static void do_fillrect(u32 x, u32 y, u32 w,u32 h,
u32 color,u32 stride,u32 bpp,u32 rop);
static void do_putc(u32 fgx, u32 bgx,struct display *p,
int c, int yy,int xx);
static void do_putcs(u32 fgx, u32 bgx,struct display *p,
const unsigned short *s,int count, int yy,int xx);
static u32 do_calc_pll(int freq, int* freq_out);
static void do_write_regs(struct banshee_reg* reg);
static void do_bitblt(u32 curx, u32 cury, u32 dstx, u32 dsty,
u32 width, u32 height, u32 stride, u32 bpp);
static void do_fillrect(u32 x, u32 y, u32 w, u32 h,
u32 color, u32 stride, u32 bpp, u32 rop);
static void do_putc(u32 fgx, u32 bgx, struct display *p,
int c, int yy, int xx);
static void do_putcs(u32 fgx, u32 bgx, struct display *p,
const unsigned short *s, int count, int yy, int xx);
static u32 do_calc_pll(int freq, int *freq_out);
static void do_write_regs(struct banshee_reg *reg);
static unsigned long do_lfb_size(void);
/*
* Interface used by the world
*/
int tdfxfb_init(void);
void tdfxfb_setup(char *options,
int *ints);
void tdfxfb_setup(char *options, int *ints);
/*
* PCI driver prototypes
*/
static int tdfxfb_probe(struct pci_dev *pdev, const struct pci_device_id *id);
static int tdfxfb_probe(struct pci_dev *pdev,
const struct pci_device_id *id);
static void tdfxfb_remove(struct pci_dev *pdev);
static struct fb_ops tdfxfb_ops = {
owner: THIS_MODULE,
fb_get_fix: tdfxfb_get_fix,
fb_get_var: tdfxfb_get_var,
fb_set_var: tdfxfb_set_var,
fb_get_cmap: tdfxfb_get_cmap,
fb_set_cmap: tdfxfb_set_cmap,
fb_setcolreg: tdfxfb_setcolreg,
fb_pan_display: tdfxfb_pan_display,
fb_blank: tdfxfb_blank,
owner:THIS_MODULE,
fb_get_fix:tdfxfb_get_fix,
fb_get_var:tdfxfb_get_var,
fb_set_var:tdfxfb_set_var,
fb_get_cmap:tdfxfb_get_cmap,
fb_set_cmap:tdfxfb_set_cmap,
fb_setcolreg:tdfxfb_setcolreg,
fb_pan_display:tdfxfb_pan_display,
fb_blank:tdfxfb_blank,
};
static struct pci_device_id tdfxfb_id_table[] __devinitdata = {
{ PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_BANSHEE,
{PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_BANSHEE,
PCI_ANY_ID, PCI_ANY_ID, PCI_BASE_CLASS_DISPLAY << 16,
0xff0000, 0 },
{ PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_VOODOO3,
0xff0000, 0},
{PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_VOODOO3,
PCI_ANY_ID, PCI_ANY_ID, PCI_BASE_CLASS_DISPLAY << 16,
0xff0000, 0 },
{ PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_VOODOO5,
0xff0000, 0},
{PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_VOODOO5,
PCI_ANY_ID, PCI_ANY_ID, PCI_BASE_CLASS_DISPLAY << 16,
0xff0000, 0 },
{ 0, }
0xff0000, 0},
{0,}
};
static struct pci_driver tdfxfb_driver = {
name: "tdfxfb",
id_table: tdfxfb_id_table,
probe: tdfxfb_probe,
remove: __devexit_p(tdfxfb_remove),
name:"tdfxfb",
id_table:tdfxfb_id_table,
probe:tdfxfb_probe,
remove:__devexit_p(tdfxfb_remove),
};
MODULE_DEVICE_TABLE(pci, tdfxfb_id_table);
struct mode {
char* name;
char *name;
struct fb_var_screeninfo var;
} mode;
/* 2.3.x kernels have a fb mode database, so supply only one backup default */
struct mode default_mode[] = {
{ "640x480-8@60", /* @ 60 Hz */
{"640x480-8@60", /* @ 60 Hz */
{
640, 480, 640, 1024, 0, 0, 8, 0,
{0, 8, 0}, {0, 8, 0}, {0, 8, 0}, {0, 0, 0},
0, FB_ACTIVATE_NOW, -1, -1, FB_ACCELF_TEXT,
39722, 40, 24, 32, 11, 96, 2,
0, FB_VMODE_NONINTERLACED
}
0, FB_VMODE_NONINTERLACED}
}
};
......@@ -534,74 +344,113 @@ static char *mode_option __initdata = NULL;
* ------------------------------------------------------------------------- */
#ifdef VGA_REG_IO
static inline u8 vga_inb(u32 reg) { return inb(reg); }
static inline u16 vga_inw(u32 reg) { return inw(reg); }
static inline u16 vga_inl(u32 reg) { return inl(reg); }
static inline u8 vga_inb(u32 reg)
{
return inb(reg);
}
static inline u16 vga_inw(u32 reg)
{
return inw(reg);
}
static inline u16 vga_inl(u32 reg)
{
return inl(reg);
}
static inline void vga_outb(u32 reg, u8 val) { outb(val, reg); }
static inline void vga_outw(u32 reg, u16 val) { outw(val, reg); }
static inline void vga_outl(u32 reg, u32 val) { outl(val, reg); }
static inline void vga_outb(u32 reg, u8 val)
{
outb(val, reg);
}
static inline void vga_outw(u32 reg, u16 val)
{
outw(val, reg);
}
static inline void vga_outl(u32 reg, u32 val)
{
outl(val, reg);
}
#else
static inline u8 vga_inb(u32 reg) {
static inline u8 vga_inb(u32 reg)
{
return inb(fb_info.iobase + reg - 0x300);
}
static inline u16 vga_inw(u32 reg) {
static inline u16 vga_inw(u32 reg)
{
return inw(fb_info.iobase + reg - 0x300);
}
static inline u16 vga_inl(u32 reg) {
static inline u16 vga_inl(u32 reg)
{
return inl(fb_info.iobase + reg - 0x300);
}
static inline void vga_outb(u32 reg, u8 val) {
static inline void vga_outb(u32 reg, u8 val)
{
outb(val, fb_info.iobase + reg - 0x300);
}
static inline void vga_outw(u32 reg, u16 val) {
static inline void vga_outw(u32 reg, u16 val)
{
outw(val, fb_info.iobase + reg - 0x300);
}
static inline void vga_outl(u32 reg, u32 val) {
static inline void vga_outl(u32 reg, u32 val)
{
outl(val, fb_info.iobase + reg - 0x300);
}
#endif
static inline void gra_outb(u32 idx, u8 val) {
vga_outb(GRA_I, idx); vga_outb(GRA_D, val);
static inline void gra_outb(u32 idx, u8 val)
{
vga_outb(GRA_I, idx);
vga_outb(GRA_D, val);
}
static inline u8 gra_inb(u32 idx) {
vga_outb(GRA_I, idx); return vga_inb(GRA_D);
static inline u8 gra_inb(u32 idx)
{
vga_outb(GRA_I, idx);
return vga_inb(GRA_D);
}
static inline void seq_outb(u32 idx, u8 val) {
vga_outb(SEQ_I, idx); vga_outb(SEQ_D, val);
static inline void seq_outb(u32 idx, u8 val)
{
vga_outb(SEQ_I, idx);
vga_outb(SEQ_D, val);
}
static inline u8 seq_inb(u32 idx) {
vga_outb(SEQ_I, idx); return vga_inb(SEQ_D);
static inline u8 seq_inb(u32 idx)
{
vga_outb(SEQ_I, idx);
return vga_inb(SEQ_D);
}
static inline void crt_outb(u32 idx, u8 val) {
vga_outb(CRT_I, idx); vga_outb(CRT_D, val);
static inline void crt_outb(u32 idx, u8 val)
{
vga_outb(CRT_I, idx);
vga_outb(CRT_D, val);
}
static inline u8 crt_inb(u32 idx) {
vga_outb(CRT_I, idx); return vga_inb(CRT_D);
static inline u8 crt_inb(u32 idx)
{
vga_outb(CRT_I, idx);
return vga_inb(CRT_D);
}
static inline void att_outb(u32 idx, u8 val) {
static inline void att_outb(u32 idx, u8 val)
{
unsigned char tmp;
tmp = vga_inb(IS1_R);
vga_outb(ATT_IW, idx);
vga_outb(ATT_IW, val);
}
static inline u8 att_inb(u32 idx) {
static inline u8 att_inb(u32 idx)
{
unsigned char tmp;
tmp = vga_inb(IS1_R);
vga_outb(ATT_IW, idx);
return vga_inb(ATT_IW);
}
static inline void vga_disable_video(void) {
static inline void vga_disable_video(void)
{
unsigned char s;
s = seq_inb(0x01) | 0x20;
seq_outb(0x00, 0x01);
......@@ -609,7 +458,8 @@ static inline void vga_disable_video(void) {
seq_outb(0x00, 0x03);
}
static inline void vga_enable_video(void) {
static inline void vga_enable_video(void)
{
unsigned char s;
s = seq_inb(0x01) & 0xdf;
seq_outb(0x00, 0x01);
......@@ -617,52 +467,65 @@ static inline void vga_enable_video(void) {
seq_outb(0x00, 0x03);
}
static inline void vga_disable_palette(void) {
static inline void vga_disable_palette(void)
{
vga_inb(IS1_R);
vga_outb(ATT_IW, 0x00);
}
static inline void vga_enable_palette(void) {
static inline void vga_enable_palette(void)
{
vga_inb(IS1_R);
vga_outb(ATT_IW, 0x20);
}
static inline u32 tdfx_inl(unsigned int reg) {
static inline u32 tdfx_inl(unsigned int reg)
{
return readl(fb_info.regbase_virt + reg);
}
static inline void tdfx_outl(unsigned int reg, u32 val) {
static inline void tdfx_outl(unsigned int reg, u32 val)
{
writel(val, fb_info.regbase_virt + reg);
}
static inline void banshee_make_room(int size) {
while((tdfx_inl(STATUS) & 0x1f) < size);
static inline void banshee_make_room(int size)
{
while ((tdfx_inl(STATUS) & 0x1f) < size);
}
static inline void banshee_wait_idle(void) {
static inline void banshee_wait_idle(void)
{
int i = 0;
banshee_make_room(1);
tdfx_outl(COMMAND_3D, COMMAND_3D_NOP);
while(1) {
while (1) {
i = (tdfx_inl(STATUS) & STATUS_BUSY) ? 0 : i + 1;
if(i == 3) break;
if (i == 3)
break;
}
}
/*
* Set the color of a palette entry in 8bpp mode
*/
static inline void do_setpalentry(unsigned regno, u32 c) {
banshee_make_room(2); tdfx_outl(DACADDR, regno); tdfx_outl(DACDATA, c); }
static inline void do_setpalentry(unsigned regno, u32 c)
{
banshee_make_room(2);
tdfx_outl(DACADDR, regno);
tdfx_outl(DACDATA, c);
}
/*
* Set the starting position of the visible screen to var->yoffset
*/
static void do_pan_var(struct fb_var_screeninfo* var, struct fb_info_tdfx *i)
static void do_pan_var(struct fb_var_screeninfo *var,
struct fb_info_tdfx *i)
{
u32 addr;
addr = var->yoffset*i->current_par.lpitch;
addr = var->yoffset * i->current_par.lpitch;
banshee_make_room(1);
tdfx_outl(VIDDESKSTART, addr);
}
......@@ -672,13 +535,14 @@ static void do_pan_var(struct fb_var_screeninfo* var, struct fb_info_tdfx *i)
*/
static void do_flashcursor(unsigned long ptr)
{
struct fb_info_tdfx* i=(struct fb_info_tdfx *)ptr;
struct fb_info_tdfx *i = (struct fb_info_tdfx *) ptr;
unsigned long flags;
spin_lock_irqsave(&i->DAClock, flags);
banshee_make_room(1);
tdfx_outl( VIDPROCCFG, tdfx_inl(VIDPROCCFG) ^ VIDCFG_HWCURSOR_ENABLE );
i->cursor.timer.expires=jiffies+HZ/2;
tdfx_outl(VIDPROCCFG,
tdfx_inl(VIDPROCCFG) ^ VIDCFG_HWCURSOR_ENABLE);
i->cursor.timer.expires = jiffies + HZ / 2;
add_timer(&i->cursor.timer);
spin_unlock_irqrestore(&i->DAClock, flags);
}
......@@ -687,9 +551,10 @@ static void do_flashcursor(unsigned long ptr)
* FillRect 2D command (solidfill or invert (via ROP_XOR))
*/
static void do_fillrect(u32 x, u32 y, u32 w, u32 h,
u32 color, u32 stride, u32 bpp, u32 rop) {
u32 color, u32 stride, u32 bpp, u32 rop)
{
u32 fmt= stride | ((bpp+((bpp==8) ? 0 : 8)) << 13);
u32 fmt = stride | ((bpp + ((bpp == 8) ? 0 : 8)) << 13);
banshee_make_room(5);
tdfx_outl(DSTFORMAT, fmt);
......@@ -707,26 +572,23 @@ static void do_fillrect(u32 x, u32 y, u32 w, u32 h,
static void do_bitblt(u32 curx,
u32 cury,
u32 dstx,
u32 dsty,
u32 width,
u32 height,
u32 stride,
u32 bpp) {
u32 dsty, u32 width, u32 height, u32 stride, u32 bpp)
{
u32 blitcmd = COMMAND_2D_S2S_BITBLT | (TDFX_ROP_COPY << 24);
u32 fmt= stride | ((bpp+((bpp==8) ? 0 : 8)) << 13);
u32 fmt = stride | ((bpp + ((bpp == 8) ? 0 : 8)) << 13);
if (curx <= dstx) {
//-X
blitcmd |= BIT(14);
curx += width-1;
dstx += width-1;
curx += width - 1;
dstx += width - 1;
}
if (cury <= dsty) {
//-Y
blitcmd |= BIT(15);
cury += height-1;
dsty += height-1;
cury += height - 1;
dsty += height - 1;
}
banshee_make_room(6);
......@@ -741,56 +603,67 @@ static void do_bitblt(u32 curx,
}
static void do_putc(u32 fgx, u32 bgx,
struct display *p,
int c, int yy,int xx)
struct display *p, int c, int yy, int xx)
{
int i;
int stride=fb_info.current_par.lpitch;
u32 bpp=fb_info.current_par.bpp;
int fw=(fontwidth(p)+7)>>3;
u8 *chardata=p->fontdata+(c&p->charmask)*fontheight(p)*fw;
u32 fmt= stride | ((bpp+((bpp==8) ? 0 : 8)) << 13);
int stride = fb_info.current_par.lpitch;
u32 bpp = fb_info.current_par.bpp;
int fw = (fontwidth(p) + 7) >> 3;
u8 *chardata =
p->fontdata + (c & p->charmask) * fontheight(p) * fw;
u32 fmt = stride | ((bpp + ((bpp == 8) ? 0 : 8)) << 13);
xx *= fontwidth(p);
yy *= fontheight(p);
banshee_make_room(8+((fontheight(p)*fw+3)>>2) );
banshee_make_room(8 + ((fontheight(p) * fw + 3) >> 2));
tdfx_outl(COLORFORE, fgx);
tdfx_outl(COLORBACK, bgx);
tdfx_outl(SRCXY, 0);
tdfx_outl(DSTXY, xx | (yy << 16));
tdfx_outl(COMMAND_2D, COMMAND_2D_H2S_BITBLT | (TDFX_ROP_COPY << 24));
tdfx_outl(COMMAND_2D,
COMMAND_2D_H2S_BITBLT | (TDFX_ROP_COPY << 24));
tdfx_outl(SRCFORMAT, 0x400000);
tdfx_outl(DSTFORMAT, fmt);
tdfx_outl(DSTSIZE, fontwidth(p) | (fontheight(p) << 16));
i=fontheight(p);
i = fontheight(p);
switch (fw) {
case 1:
while (i>=4) {
tdfx_outl(LAUNCH_2D,*(u32*)chardata);
chardata+=4;
i-=4;
while (i >= 4) {
tdfx_outl(LAUNCH_2D, *(u32 *) chardata);
chardata += 4;
i -= 4;
}
switch (i) {
case 0: break;
case 1: tdfx_outl(LAUNCH_2D,*chardata); break;
case 2: tdfx_outl(LAUNCH_2D,*(u16*)chardata); break;
case 3: tdfx_outl(LAUNCH_2D,*(u16*)chardata | ((chardata[3]) << 24)); break;
case 0:
break;
case 1:
tdfx_outl(LAUNCH_2D, *chardata);
break;
case 2:
tdfx_outl(LAUNCH_2D, *(u16 *) chardata);
break;
case 3:
tdfx_outl(LAUNCH_2D,
*(u16 *) chardata | ((chardata[3]) <<
24));
break;
}
break;
case 2:
while (i>=2) {
tdfx_outl(LAUNCH_2D,*(u32*)chardata);
chardata+=4;
i-=2;
while (i >= 2) {
tdfx_outl(LAUNCH_2D, *(u32 *) chardata);
chardata += 4;
i -= 2;
}
if (i) tdfx_outl(LAUNCH_2D,*(u16*)chardata);
if (i)
tdfx_outl(LAUNCH_2D, *(u16 *) chardata);
break;
default:
// Is there a font with width more that 16 pixels ?
for (i=fontheight(p);i>0;i--) {
tdfx_outl(LAUNCH_2D,*(u32*)chardata);
chardata+=4;
for (i = fontheight(p); i > 0; i--) {
tdfx_outl(LAUNCH_2D, *(u32 *) chardata);
chardata += 4;
}
break;
}
......@@ -799,20 +672,19 @@ static void do_putc(u32 fgx, u32 bgx,
static void do_putcs(u32 fgx, u32 bgx,
struct display *p,
const unsigned short *s,
int count, int yy,int xx)
const unsigned short *s, int count, int yy, int xx)
{
int i;
int stride=fb_info.current_par.lpitch;
u32 bpp=fb_info.current_par.bpp;
int fw=(fontwidth(p)+7)>>3;
int w=fontwidth(p);
int h=fontheight(p);
int regsneed=1+((h*fw+3)>>2);
u32 fmt= stride | ((bpp+((bpp==8) ? 0 : 8)) << 13);
int stride = fb_info.current_par.lpitch;
u32 bpp = fb_info.current_par.bpp;
int fw = (fontwidth(p) + 7) >> 3;
int w = fontwidth(p);
int h = fontheight(p);
int regsneed = 1 + ((h * fw + 3) >> 2);
u32 fmt = stride | ((bpp + ((bpp == 8) ? 0 : 8)) << 13);
xx *= w;
yy = (yy*h) << 16;
yy = (yy * h) << 16;
banshee_make_room(8);
tdfx_outl(COMMAND_3D, COMMAND_3D_NOP);
......@@ -822,43 +694,55 @@ static void do_putcs(u32 fgx, u32 bgx,
tdfx_outl(DSTFORMAT, fmt);
tdfx_outl(DSTSIZE, w | (h << 16));
tdfx_outl(SRCXY, 0);
tdfx_outl(COMMAND_2D, COMMAND_2D_H2S_BITBLT | (TDFX_ROP_COPY << 24));
tdfx_outl(COMMAND_2D,
COMMAND_2D_H2S_BITBLT | (TDFX_ROP_COPY << 24));
while (count--) {
u8 *chardata=p->fontdata+(scr_readw(s++) & p->charmask)*h*fw;
u8 *chardata =
p->fontdata + (scr_readw(s++) & p->charmask) * h * fw;
banshee_make_room(regsneed);
tdfx_outl(DSTXY, xx | yy);
xx+=w;
xx += w;
i=h;
i = h;
switch (fw) {
case 1:
while (i>=4) {
tdfx_outl(LAUNCH_2D,*(u32*)chardata);
chardata+=4;
i-=4;
while (i >= 4) {
tdfx_outl(LAUNCH_2D, *(u32 *) chardata);
chardata += 4;
i -= 4;
}
switch (i) {
case 0: break;
case 1: tdfx_outl(LAUNCH_2D,*chardata); break;
case 2: tdfx_outl(LAUNCH_2D,*(u16*)chardata); break;
case 3: tdfx_outl(LAUNCH_2D,*(u16*)chardata | ((chardata[3]) << 24)); break;
case 0:
break;
case 1:
tdfx_outl(LAUNCH_2D, *chardata);
break;
case 2:
tdfx_outl(LAUNCH_2D, *(u16 *) chardata);
break;
case 3:
tdfx_outl(LAUNCH_2D,
*(u16 *) chardata |
((chardata[3]) << 24));
break;
}
break;
case 2:
while (i>=2) {
tdfx_outl(LAUNCH_2D,*(u32*)chardata);
chardata+=4;
i-=2;
while (i >= 2) {
tdfx_outl(LAUNCH_2D, *(u32 *) chardata);
chardata += 4;
i -= 2;
}
if (i) tdfx_outl(LAUNCH_2D,*(u16*)chardata);
if (i)
tdfx_outl(LAUNCH_2D, *(u16 *) chardata);
break;
default:
// Is there a font with width more that 16 pixels ?
for (;i>0;i--) {
tdfx_outl(LAUNCH_2D,*(u32*)chardata);
chardata+=4;
for (; i > 0; i--) {
tdfx_outl(LAUNCH_2D, *(u32 *) chardata);
chardata += 4;
}
break;
}
......@@ -866,7 +750,8 @@ static void do_putcs(u32 fgx, u32 bgx,
banshee_wait_idle();
}
static u32 do_calc_pll(int freq, int* freq_out) {
static u32 do_calc_pll(int freq, int *freq_out)
{
int m, n, k, best_m, best_n, best_k, f_cur, best_error;
int fref = 14318;
......@@ -874,12 +759,13 @@ static u32 do_calc_pll(int freq, int* freq_out) {
255*63*4 = 64260 iterations is silly */
best_error = freq;
best_n = best_m = best_k = 0;
for(n = 1; n < 256; n++) {
for(m = 1; m < 64; m++) {
for(k = 0; k < 4; k++) {
f_cur = fref*(n + 2)/(m + 2)/(1 << k);
if(abs(f_cur - freq) < best_error) {
best_error = abs(f_cur-freq);
for (n = 1; n < 256; n++) {
for (m = 1; m < 64; m++) {
for (k = 0; k < 4; k++) {
f_cur =
fref * (n + 2) / (m + 2) / (1 << k);
if (abs(f_cur - freq) < best_error) {
best_error = abs(f_cur - freq);
best_n = n;
best_m = m;
best_k = k;
......@@ -890,12 +776,13 @@ static u32 do_calc_pll(int freq, int* freq_out) {
n = best_n;
m = best_m;
k = best_k;
*freq_out = fref*(n + 2)/(m + 2)/(1 << k);
*freq_out = fref * (n + 2) / (m + 2) / (1 << k);
return (n << 8) | (m << 2) | k;
}
static void do_write_regs(struct banshee_reg* reg) {
static void do_write_regs(struct banshee_reg *reg)
{
int i;
banshee_wait_idle();
......@@ -915,16 +802,16 @@ static void do_write_regs(struct banshee_reg* reg) {
vga_outb(MISC_W, reg->misc[0x00] | 0x01);
for(i = 0; i < 5; i++)
for (i = 0; i < 5; i++)
seq_outb(i, reg->seq[i]);
for(i = 0; i < 25; i++)
for (i = 0; i < 25; i++)
crt_outb(i, reg->crt[i]);
for(i = 0; i < 9; i++)
for (i = 0; i < 9; i++)
gra_outb(i, reg->gra[i]);
for(i = 0; i < 21; i++)
for (i = 0; i < 21; i++)
att_outb(i, reg->att[i]);
crt_outb(0x1a, reg->ext[0]);
......@@ -965,7 +852,8 @@ static void do_write_regs(struct banshee_reg* reg) {
banshee_wait_idle();
}
static unsigned long do_lfb_size(void) {
static unsigned long do_lfb_size(void)
{
u32 draminit0 = 0;
u32 draminit1 = 0;
u32 miscinit1 = 0;
......@@ -981,8 +869,8 @@ static unsigned long do_lfb_size(void) {
lfbsize = sgram_p ?
(((draminit0 & DRAMINIT0_SGRAM_NUM) ? 2 : 1) *
((draminit0 & DRAMINIT0_SGRAM_TYPE) ? 8 : 4) * 1024 * 1024) :
16 * 1024 * 1024;
((draminit0 & DRAMINIT0_SGRAM_TYPE) ? 8 : 4) * 1024 *
1024) : 16 * 1024 * 1024;
} else {
/* Voodoo4/5 */
u32 chips, psize, banks;
......@@ -1013,163 +901,153 @@ static unsigned long do_lfb_size(void) {
#define tdfx_cfb24_putcs tdfx_cfb32_putcs
#define tdfx_cfb24_clear tdfx_cfb32_clear
static void tdfx_cfbX_clear_margins(struct vc_data* conp, struct display* p,
int bottom_only)
static void tdfx_cfbX_clear_margins(struct vc_data *conp,
struct display *p, int bottom_only)
{
unsigned int cw=fontwidth(p);
unsigned int ch=fontheight(p);
unsigned int rw=p->var.xres % cw; // it be in a non-standard mode or not?
unsigned int bh=p->var.yres % ch;
unsigned int rs=p->var.xres - rw;
unsigned int bs=p->var.yres - bh;
unsigned int cw = fontwidth(p);
unsigned int ch = fontheight(p);
unsigned int rw = p->var.xres % cw; // it be in a non-standard mode or not?
unsigned int bh = p->var.yres % ch;
unsigned int rs = p->var.xres - rw;
unsigned int bs = p->var.yres - bh;
if (!bottom_only && rw) {
do_fillrect( p->var.xoffset+rs, 0,
do_fillrect(p->var.xoffset + rs, 0,
rw, p->var.yres_virtual, 0,
fb_info.current_par.lpitch,
fb_info.current_par.bpp, TDFX_ROP_COPY);
}
if (bh) {
do_fillrect( p->var.xoffset, p->var.yoffset+bs,
do_fillrect(p->var.xoffset, p->var.yoffset + bs,
rs, bh, 0,
fb_info.current_par.lpitch,
fb_info.current_par.bpp, TDFX_ROP_COPY);
}
}
static void tdfx_cfbX_bmove(struct display* p,
static void tdfx_cfbX_bmove(struct display *p,
int sy,
int sx,
int dy,
int dx,
int height,
int width) {
do_bitblt(fontwidth(p)*sx,
fontheight(p)*sy,
fontwidth(p)*dx,
fontheight(p)*dy,
fontwidth(p)*width,
fontheight(p)*height,
fb_info.current_par.lpitch,
fb_info.current_par.bpp);
}
static void tdfx_cfb8_putc(struct vc_data* conp,
struct display* p,
int c, int yy,int xx)
int sx, int dy, int dx, int height, int width)
{
u32 fgx,bgx;
fgx=attr_fgcol(p, c);
bgx=attr_bgcol(p, c);
do_putc( fgx,bgx,p,c,yy,xx );
do_bitblt(fontwidth(p) * sx,
fontheight(p) * sy,
fontwidth(p) * dx,
fontheight(p) * dy,
fontwidth(p) * width,
fontheight(p) * height,
fb_info.current_par.lpitch, fb_info.current_par.bpp);
}
static void tdfx_cfb8_putc(struct vc_data *conp,
struct display *p, int c, int yy, int xx)
{
u32 fgx, bgx;
fgx = attr_fgcol(p, c);
bgx = attr_bgcol(p, c);
do_putc(fgx, bgx, p, c, yy, xx);
}
static void tdfx_cfb16_putc(struct vc_data* conp,
struct display* p,
int c, int yy,int xx)
static void tdfx_cfb16_putc(struct vc_data *conp,
struct display *p, int c, int yy, int xx)
{
u32 fgx,bgx;
fgx=((u16*)p->dispsw_data)[attr_fgcol(p,c)];
bgx=((u16*)p->dispsw_data)[attr_bgcol(p,c)];
do_putc( fgx,bgx,p,c,yy,xx );
u32 fgx, bgx;
fgx = ((u16 *) p->dispsw_data)[attr_fgcol(p, c)];
bgx = ((u16 *) p->dispsw_data)[attr_bgcol(p, c)];
do_putc(fgx, bgx, p, c, yy, xx);
}
static void tdfx_cfb32_putc(struct vc_data* conp,
struct display* p,
int c, int yy,int xx)
static void tdfx_cfb32_putc(struct vc_data *conp,
struct display *p, int c, int yy, int xx)
{
u32 fgx,bgx;
fgx=((u32*)p->dispsw_data)[attr_fgcol(p,c)];
bgx=((u32*)p->dispsw_data)[attr_bgcol(p,c)];
do_putc( fgx,bgx,p,c,yy,xx );
u32 fgx, bgx;
fgx = ((u32 *) p->dispsw_data)[attr_fgcol(p, c)];
bgx = ((u32 *) p->dispsw_data)[attr_bgcol(p, c)];
do_putc(fgx, bgx, p, c, yy, xx);
}
static void tdfx_cfb8_putcs(struct vc_data* conp,
struct display* p,
const unsigned short *s,int count,int yy,int xx)
static void tdfx_cfb8_putcs(struct vc_data *conp,
struct display *p,
const unsigned short *s, int count, int yy,
int xx)
{
u16 c = scr_readw(s);
u32 fgx = attr_fgcol(p, c);
u32 bgx = attr_bgcol(p, c);
do_putcs( fgx,bgx,p,s,count,yy,xx );
do_putcs(fgx, bgx, p, s, count, yy, xx);
}
static void tdfx_cfb16_putcs(struct vc_data* conp,
struct display* p,
const unsigned short *s,int count,int yy,int xx)
static void tdfx_cfb16_putcs(struct vc_data *conp,
struct display *p,
const unsigned short *s, int count, int yy,
int xx)
{
u16 c = scr_readw(s);
u32 fgx = ((u16*)p->dispsw_data)[attr_fgcol(p, c)];
u32 bgx = ((u16*)p->dispsw_data)[attr_bgcol(p, c)];
do_putcs( fgx,bgx,p,s,count,yy,xx );
u32 fgx = ((u16 *) p->dispsw_data)[attr_fgcol(p, c)];
u32 bgx = ((u16 *) p->dispsw_data)[attr_bgcol(p, c)];
do_putcs(fgx, bgx, p, s, count, yy, xx);
}
static void tdfx_cfb32_putcs(struct vc_data* conp,
struct display* p,
const unsigned short *s,int count,int yy,int xx)
static void tdfx_cfb32_putcs(struct vc_data *conp,
struct display *p,
const unsigned short *s, int count, int yy,
int xx)
{
u16 c = scr_readw(s);
u32 fgx = ((u32*)p->dispsw_data)[attr_fgcol(p, c)];
u32 bgx = ((u32*)p->dispsw_data)[attr_bgcol(p, c)];
do_putcs( fgx,bgx,p,s,count,yy,xx );
u32 fgx = ((u32 *) p->dispsw_data)[attr_fgcol(p, c)];
u32 bgx = ((u32 *) p->dispsw_data)[attr_bgcol(p, c)];
do_putcs(fgx, bgx, p, s, count, yy, xx);
}
static void tdfx_cfb8_clear(struct vc_data* conp,
struct display* p,
int sy,
int sx,
int height,
int width) {
static void tdfx_cfb8_clear(struct vc_data *conp,
struct display *p,
int sy, int sx, int height, int width)
{
u32 bg;
bg = attr_bgcol_ec(p,conp);
do_fillrect(fontwidth(p)*sx,
fontheight(p)*sy,
fontwidth(p)*width,
fontheight(p)*height,
bg = attr_bgcol_ec(p, conp);
do_fillrect(fontwidth(p) * sx,
fontheight(p) * sy,
fontwidth(p) * width,
fontheight(p) * height,
bg,
fb_info.current_par.lpitch,
fb_info.current_par.bpp, TDFX_ROP_COPY);
}
static void tdfx_cfb16_clear(struct vc_data* conp,
struct display* p,
int sy,
int sx,
int height,
int width) {
static void tdfx_cfb16_clear(struct vc_data *conp,
struct display *p,
int sy, int sx, int height, int width)
{
u32 bg;
bg = ((u16*)p->dispsw_data)[attr_bgcol_ec(p,conp)];
do_fillrect(fontwidth(p)*sx,
fontheight(p)*sy,
fontwidth(p)*width,
fontheight(p)*height,
bg = ((u16 *) p->dispsw_data)[attr_bgcol_ec(p, conp)];
do_fillrect(fontwidth(p) * sx,
fontheight(p) * sy,
fontwidth(p) * width,
fontheight(p) * height,
bg,
fb_info.current_par.lpitch,
fb_info.current_par.bpp, TDFX_ROP_COPY);
}
static void tdfx_cfb32_clear(struct vc_data* conp,
struct display* p,
int sy,
int sx,
int height,
int width) {
static void tdfx_cfb32_clear(struct vc_data *conp,
struct display *p,
int sy, int sx, int height, int width)
{
u32 bg;
bg = ((u32*)p->dispsw_data)[attr_bgcol_ec(p,conp)];
do_fillrect(fontwidth(p)*sx,
fontheight(p)*sy,
fontwidth(p)*width,
fontheight(p)*height,
bg = ((u32 *) p->dispsw_data)[attr_bgcol_ec(p, conp)];
do_fillrect(fontwidth(p) * sx,
fontheight(p) * sy,
fontwidth(p) * width,
fontheight(p) * height,
bg,
fb_info.current_par.lpitch,
fb_info.current_par.bpp, TDFX_ROP_COPY);
}
static void tdfx_cfbX_revc(struct display *p, int xx, int yy)
{
int bpp=fb_info.current_par.bpp;
int bpp = fb_info.current_par.bpp;
do_fillrect( xx * fontwidth(p), yy * fontheight(p),
do_fillrect(xx * fontwidth(p), yy * fontheight(p),
fontwidth(p), fontheight(p),
(bpp==8) ? 0x0f : 0xffffffff,
(bpp == 8) ? 0x0f : 0xffffffff,
fb_info.current_par.lpitch, bpp, TDFX_ROP_XOR);
}
......@@ -1177,16 +1055,16 @@ static void tdfx_cfbX_cursor(struct display *p, int mode, int x, int y)
{
unsigned long flags;
int tip;
struct fb_info_tdfx *info=(struct fb_info_tdfx *)p->fb_info;
struct fb_info_tdfx *info = (struct fb_info_tdfx *) p->fb_info;
tip=p->conp->vc_cursor_type & CUR_HWMASK;
if (mode==CM_ERASE) {
tip = p->conp->vc_cursor_type & CUR_HWMASK;
if (mode == CM_ERASE) {
if (info->cursor.state != CM_ERASE) {
spin_lock_irqsave(&info->DAClock,flags);
info->cursor.state=CM_ERASE;
spin_lock_irqsave(&info->DAClock, flags);
info->cursor.state = CM_ERASE;
del_timer(&(info->cursor.timer));
tdfx_outl(VIDPROCCFG,info->cursor.disable);
spin_unlock_irqrestore(&info->DAClock,flags);
tdfx_outl(VIDPROCCFG, info->cursor.disable);
spin_unlock_irqrestore(&info->DAClock, flags);
}
return;
}
......@@ -1195,13 +1073,12 @@ static void tdfx_cfbX_cursor(struct display *p, int mode, int x, int y)
x *= fontwidth(p);
y *= fontheight(p);
y -= p->var.yoffset;
spin_lock_irqsave(&info->DAClock,flags);
if ((x!=info->cursor.x) ||
(y!=info->cursor.y) ||
(info->cursor.redraw)) {
info->cursor.x=x;
info->cursor.y=y;
info->cursor.redraw=0;
spin_lock_irqsave(&info->DAClock, flags);
if ((x != info->cursor.x) ||
(y != info->cursor.y) || (info->cursor.redraw)) {
info->cursor.x = x;
info->cursor.y = y;
info->cursor.redraw = 0;
x += 63;
y += 63;
banshee_make_room(2);
......@@ -1212,70 +1089,72 @@ static void tdfx_cfbX_cursor(struct display *p, int mode, int x, int y)
tdfx_outl(HWCURC1, 0xffffff);
}
info->cursor.state = CM_DRAW;
mod_timer(&info->cursor.timer,jiffies+HZ/2);
mod_timer(&info->cursor.timer, jiffies + HZ / 2);
banshee_make_room(1);
tdfx_outl(VIDPROCCFG, info->cursor.enable);
spin_unlock_irqrestore(&info->DAClock,flags);
spin_unlock_irqrestore(&info->DAClock, flags);
return;
}
#ifdef FBCON_HAS_CFB8
static struct display_switch fbcon_banshee8 = {
setup: fbcon_cfb8_setup,
bmove: tdfx_cfbX_bmove,
clear: tdfx_cfb8_clear,
putc: tdfx_cfb8_putc,
putcs: tdfx_cfb8_putcs,
revc: tdfx_cfbX_revc,
cursor: tdfx_cfbX_cursor,
clear_margins: tdfx_cfbX_clear_margins,
fontwidthmask: FONTWIDTHRANGE(8, 12)
setup:fbcon_cfb8_setup,
bmove:tdfx_cfbX_bmove,
clear:tdfx_cfb8_clear,
putc:tdfx_cfb8_putc,
putcs:tdfx_cfb8_putcs,
revc:tdfx_cfbX_revc,
cursor:tdfx_cfbX_cursor,
clear_margins:tdfx_cfbX_clear_margins,
fontwidthmask:FONTWIDTHRANGE(8, 12)
};
#endif
#ifdef FBCON_HAS_CFB16
static struct display_switch fbcon_banshee16 = {
setup: fbcon_cfb16_setup,
bmove: tdfx_cfbX_bmove,
clear: tdfx_cfb16_clear,
putc: tdfx_cfb16_putc,
putcs: tdfx_cfb16_putcs,
revc: tdfx_cfbX_revc,
cursor: tdfx_cfbX_cursor,
clear_margins: tdfx_cfbX_clear_margins,
fontwidthmask: FONTWIDTHRANGE(8, 12)
setup:fbcon_cfb16_setup,
bmove:tdfx_cfbX_bmove,
clear:tdfx_cfb16_clear,
putc:tdfx_cfb16_putc,
putcs:tdfx_cfb16_putcs,
revc:tdfx_cfbX_revc,
cursor:tdfx_cfbX_cursor,
clear_margins:tdfx_cfbX_clear_margins,
fontwidthmask:FONTWIDTHRANGE(8, 12)
};
#endif
#ifdef FBCON_HAS_CFB24
static struct display_switch fbcon_banshee24 = {
setup: fbcon_cfb24_setup,
bmove: tdfx_cfbX_bmove,
clear: tdfx_cfb24_clear,
putc: tdfx_cfb24_putc,
putcs: tdfx_cfb24_putcs,
revc: tdfx_cfbX_revc,
cursor: tdfx_cfbX_cursor,
clear_margins: tdfx_cfbX_clear_margins,
fontwidthmask: FONTWIDTHRANGE(8, 12)
setup:fbcon_cfb24_setup,
bmove:tdfx_cfbX_bmove,
clear:tdfx_cfb24_clear,
putc:tdfx_cfb24_putc,
putcs:tdfx_cfb24_putcs,
revc:tdfx_cfbX_revc,
cursor:tdfx_cfbX_cursor,
clear_margins:tdfx_cfbX_clear_margins,
fontwidthmask:FONTWIDTHRANGE(8, 12)
};
#endif
#ifdef FBCON_HAS_CFB32
static struct display_switch fbcon_banshee32 = {
setup: fbcon_cfb32_setup,
bmove: tdfx_cfbX_bmove,
clear: tdfx_cfb32_clear,
putc: tdfx_cfb32_putc,
putcs: tdfx_cfb32_putcs,
revc: tdfx_cfbX_revc,
cursor: tdfx_cfbX_cursor,
clear_margins: tdfx_cfbX_clear_margins,
fontwidthmask: FONTWIDTHRANGE(8, 12)
setup:fbcon_cfb32_setup,
bmove:tdfx_cfbX_bmove,
clear:tdfx_cfb32_clear,
putc:tdfx_cfb32_putc,
putcs:tdfx_cfb32_putcs,
revc:tdfx_cfbX_revc,
cursor:tdfx_cfbX_cursor,
clear_margins:tdfx_cfbX_clear_margins,
fontwidthmask:FONTWIDTHRANGE(8, 12)
};
#endif
/* ------------------------------------------------------------------------- */
static void tdfxfb_set_par(const struct tdfxfb_par* par,
struct fb_info_tdfx* info) {
struct fb_info_tdfx* i = (struct fb_info_tdfx*)info;
static void tdfxfb_set_par(const struct tdfxfb_par *par,
struct fb_info_tdfx *info)
{
struct fb_info_tdfx *i = (struct fb_info_tdfx *) info;
struct banshee_reg reg;
u32 cpp;
u32 hd, hs, he, ht, hbs, hbe;
......@@ -1286,7 +1165,7 @@ static void tdfxfb_set_par(const struct tdfxfb_par* par,
memset(&reg, 0, sizeof(reg));
cpp = (par->bpp + 7)/8;
cpp = (par->bpp + 7) / 8;
wd = (par->hdispend >> 3) - 1;
......@@ -1354,9 +1233,7 @@ static void tdfxfb_set_par(const struct tdfxfb_par* par,
reg.crt[0x02] = hbs;
reg.crt[0x03] = 0x80 | (hbe & 0x1f);
reg.crt[0x04] = hs;
reg.crt[0x05] =
((hbe & 0x20) << 2) |
(he & 0x1f);
reg.crt[0x05] = ((hbe & 0x20) << 2) | (he & 0x1f);
reg.crt[0x06] = vt;
reg.crt[0x07] =
((vs & 0x200) >> 2) |
......@@ -1365,12 +1242,9 @@ static void tdfxfb_set_par(const struct tdfxfb_par* par,
0x10 |
((vbs & 0x100) >> 5) |
((vs & 0x100) >> 6) |
((vd & 0x100) >> 7) |
((vt & 0x100) >> 8);
((vd & 0x100) >> 7) | ((vt & 0x100) >> 8);
reg.crt[0x08] = 0x00;
reg.crt[0x09] =
0x40 |
((vbs & 0x200) >> 4);
reg.crt[0x09] = 0x40 | ((vbs & 0x200) >> 4);
reg.crt[0x0a] = 0x00;
reg.crt[0x0b] = 0x00;
reg.crt[0x0c] = 0x00;
......@@ -1378,9 +1252,7 @@ static void tdfxfb_set_par(const struct tdfxfb_par* par,
reg.crt[0x0e] = 0x00;
reg.crt[0x0f] = 0x00;
reg.crt[0x10] = vs;
reg.crt[0x11] =
(ve & 0x0f) |
0x20;
reg.crt[0x11] = (ve & 0x0f) | 0x20;
reg.crt[0x12] = vd;
reg.crt[0x13] = wd;
reg.crt[0x14] = 0x00;
......@@ -1394,19 +1266,16 @@ static void tdfxfb_set_par(const struct tdfxfb_par* par,
((hd & 0x100) >> 6) |
((hbs & 0x100) >> 4) |
((hbe & 0x40) >> 1) |
((hs & 0x100) >> 2) |
((he & 0x20) << 2));
((hs & 0x100) >> 2) | ((he & 0x20) << 2));
reg.ext[0x01] = (((vt & 0x400) >> 10) |
((vd & 0x400) >> 8) |
((vbs & 0x400) >> 6) |
((vbe & 0x400) >> 4));
((vbs & 0x400) >> 6) | ((vbe & 0x400) >> 4));
reg.vgainit0 =
VGAINIT0_8BIT_DAC |
VGAINIT0_EXT_ENABLE |
VGAINIT0_WAKEUP_3C3 |
VGAINIT0_ALT_READBACK |
VGAINIT0_EXTSHIFTOUT;
VGAINIT0_ALT_READBACK | VGAINIT0_EXTSHIFTOUT;
reg.vgainit1 = tdfx_inl(VGAINIT1) & 0x1fffff;
reg.vidcfg =
......@@ -1416,10 +1285,10 @@ static void tdfxfb_set_par(const struct tdfxfb_par* par,
((cpp - 1) << VIDCFG_PIXFMT_SHIFT) |
(cpp != 1 ? VIDCFG_CLUT_BYPASS : 0);
fb_info.cursor.enable=reg.vidcfg | VIDCFG_HWCURSOR_ENABLE;
fb_info.cursor.disable=reg.vidcfg;
fb_info.cursor.enable = reg.vidcfg | VIDCFG_HWCURSOR_ENABLE;
fb_info.cursor.disable = reg.vidcfg;
reg.stride = par->width*cpp;
reg.stride = par->width * cpp;
reg.cursloc = 0;
reg.cursc0 = 0;
......@@ -1427,7 +1296,7 @@ static void tdfxfb_set_par(const struct tdfxfb_par* par,
reg.curspataddr = fb_info.cursor.cursorimage;
reg.startaddr = par->baseline*reg.stride;
reg.startaddr = par->baseline * reg.stride;
reg.srcbase = reg.startaddr;
reg.dstbase = reg.startaddr;
......@@ -1436,7 +1305,7 @@ static void tdfxfb_set_par(const struct tdfxfb_par* par,
reg.dacmode &= ~DACMODE_2X;
reg.vidcfg &= ~VIDCFG_2X;
if(freq > i->max_pixclock/2) {
if (freq > i->max_pixclock / 2) {
freq = freq > i->max_pixclock ? i->max_pixclock : freq;
reg.dacmode |= DACMODE_2X;
reg.vidcfg |= VIDCFG_2X;
......@@ -1476,48 +1345,50 @@ static void tdfxfb_set_par(const struct tdfxfb_par* par,
}
static int tdfxfb_decode_var(const struct fb_var_screeninfo* var,
struct tdfxfb_par* par,
const struct fb_info_tdfx* info) {
struct fb_info_tdfx* i = (struct fb_info_tdfx*)info;
static int tdfxfb_decode_var(const struct fb_var_screeninfo *var,
struct tdfxfb_par *par,
const struct fb_info_tdfx *info)
{
struct fb_info_tdfx *i = (struct fb_info_tdfx *) info;
if(var->bits_per_pixel != 8 &&
if (var->bits_per_pixel != 8 &&
var->bits_per_pixel != 16 &&
var->bits_per_pixel != 24 &&
var->bits_per_pixel != 32) {
var->bits_per_pixel != 24 && var->bits_per_pixel != 32) {
DPRINTK("depth not supported: %u\n", var->bits_per_pixel);
return -EINVAL;
}
if((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) {
if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) {
DPRINTK("interlace not supported\n");
return -EINVAL;
}
if(var->xoffset) {
if (var->xoffset) {
DPRINTK("xoffset not supported\n");
return -EINVAL;
}
if(var->xres != var->xres_virtual) {
DPRINTK("virtual x resolution != physical x resolution not supported\n");
if (var->xres != var->xres_virtual) {
DPRINTK
("virtual x resolution != physical x resolution not supported\n");
return -EINVAL;
}
if(var->yres > var->yres_virtual) {
DPRINTK("virtual y resolution < physical y resolution not possible\n");
if (var->yres > var->yres_virtual) {
DPRINTK
("virtual y resolution < physical y resolution not possible\n");
return -EINVAL;
}
/* fixme: does Voodoo3 support interlace? Banshee doesn't */
if((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) {
if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) {
DPRINTK("interlace not supported\n");
return -EINVAL;
}
memset(par, 0, sizeof(struct tdfxfb_par));
switch(i->dev) {
switch (i->dev) {
case PCI_DEVICE_ID_3DFX_BANSHEE:
case PCI_DEVICE_ID_3DFX_VOODOO3:
case PCI_DEVICE_ID_3DFX_VOODOO5:
......@@ -1527,27 +1398,28 @@ static int tdfxfb_decode_var(const struct fb_var_screeninfo* var,
par->height_virt = var->yres_virtual;
par->bpp = var->bits_per_pixel;
par->ppitch = var->bits_per_pixel;
par->lpitch = par->width* ((par->ppitch+7)>>3);
par->lpitch = par->width * ((par->ppitch + 7) >> 3);
par->cmap_len = (par->bpp == 8) ? 256 : 16;
par->baseline = 0;
if(par->width < 320 || par->width > 2048) {
if (par->width < 320 || par->width > 2048) {
DPRINTK("width not supported: %u\n", par->width);
return -EINVAL;
}
if(par->height < 200 || par->height > 2048) {
if (par->height < 200 || par->height > 2048) {
DPRINTK("height not supported: %u\n", par->height);
return -EINVAL;
}
if(par->lpitch*par->height_virt > i->bufbase_size) {
if (par->lpitch * par->height_virt > i->bufbase_size) {
DPRINTK("no memory for screen (%ux%ux%u)\n",
par->width, par->height_virt, par->bpp);
return -EINVAL;
}
par->pixclock = PICOS2KHZ(var->pixclock);
if(par->pixclock > i->max_pixclock) {
DPRINTK("pixclock too high (%uKHz)\n", par->pixclock);
if (par->pixclock > i->max_pixclock) {
DPRINTK("pixclock too high (%uKHz)\n",
par->pixclock);
return -EINVAL;
}
......@@ -1561,21 +1433,21 @@ static int tdfxfb_decode_var(const struct fb_var_screeninfo* var,
par->vsyncend = par->vsyncsta + var->vsync_len;
par->vtotal = par->vsyncend + var->upper_margin;
if(var->sync & FB_SYNC_HOR_HIGH_ACT)
if (var->sync & FB_SYNC_HOR_HIGH_ACT)
par->video |= TDFXF_HSYNC_ACT_HIGH;
else
par->video |= TDFXF_HSYNC_ACT_LOW;
if(var->sync & FB_SYNC_VERT_HIGH_ACT)
if (var->sync & FB_SYNC_VERT_HIGH_ACT)
par->video |= TDFXF_VSYNC_ACT_HIGH;
else
par->video |= TDFXF_VSYNC_ACT_LOW;
if((var->vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE)
if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE)
par->video |= TDFXF_LINE_DOUBLE;
if(var->activate == FB_ACTIVATE_NOW)
if (var->activate == FB_ACTIVATE_NOW)
par->video |= TDFXF_VIDEO_ENABLE;
}
if(var->accel_flags & FB_ACCELF_TEXT)
if (var->accel_flags & FB_ACCELF_TEXT)
par->accel_flags = FB_ACCELF_TEXT;
else
par->accel_flags = 0;
......@@ -1583,9 +1455,10 @@ static int tdfxfb_decode_var(const struct fb_var_screeninfo* var,
return 0;
}
static int tdfxfb_encode_var(struct fb_var_screeninfo* var,
const struct tdfxfb_par* par,
const struct fb_info_tdfx* info) {
static int tdfxfb_encode_var(struct fb_var_screeninfo *var,
const struct tdfxfb_par *par,
const struct fb_info_tdfx *info)
{
struct fb_var_screeninfo v;
memset(&v, 0, sizeof(struct fb_var_screeninfo));
......@@ -1600,7 +1473,7 @@ static int tdfxfb_encode_var(struct fb_var_screeninfo* var,
v.vsync_len = par->vsyncend - par->vsyncsta;
v.upper_margin = par->vtotal - par->vsyncend;
v.bits_per_pixel = par->bpp;
switch(par->bpp) {
switch (par->bpp) {
case 8:
v.red.length = v.green.length = v.blue.length = 8;
break;
......@@ -1613,9 +1486,9 @@ static int tdfxfb_encode_var(struct fb_var_screeninfo* var,
v.blue.length = 5;
break;
case 24:
v.red.offset=16;
v.green.offset=8;
v.blue.offset=0;
v.red.offset = 16;
v.green.offset = 8;
v.blue.offset = 0;
v.red.length = v.green.length = v.blue.length = 8;
case 32:
v.red.offset = 16;
......@@ -1626,22 +1499,23 @@ static int tdfxfb_encode_var(struct fb_var_screeninfo* var,
}
v.height = v.width = -1;
v.pixclock = KHZ2PICOS(par->pixclock);
if((par->video & TDFXF_HSYNC_MASK) == TDFXF_HSYNC_ACT_HIGH)
if ((par->video & TDFXF_HSYNC_MASK) == TDFXF_HSYNC_ACT_HIGH)
v.sync |= FB_SYNC_HOR_HIGH_ACT;
if((par->video & TDFXF_VSYNC_MASK) == TDFXF_VSYNC_ACT_HIGH)
if ((par->video & TDFXF_VSYNC_MASK) == TDFXF_VSYNC_ACT_HIGH)
v.sync |= FB_SYNC_VERT_HIGH_ACT;
if(par->video & TDFXF_LINE_DOUBLE)
if (par->video & TDFXF_LINE_DOUBLE)
v.vmode = FB_VMODE_DOUBLE;
*var = v;
return 0;
}
static int tdfxfb_encode_fix(struct fb_fix_screeninfo* fix,
const struct tdfxfb_par* par,
const struct fb_info_tdfx* info) {
static int tdfxfb_encode_fix(struct fb_fix_screeninfo *fix,
const struct tdfxfb_par *par,
const struct fb_info_tdfx *info)
{
memset(fix, 0, sizeof(struct fb_fix_screeninfo));
switch(info->dev) {
switch (info->dev) {
case PCI_DEVICE_ID_3DFX_BANSHEE:
strcpy(fix->id, "3Dfx Banshee");
break;
......@@ -1664,8 +1538,7 @@ static int tdfxfb_encode_fix(struct fb_fix_screeninfo* fix,
fix->type_aux = 0;
fix->line_length = par->lpitch;
fix->visual = (par->bpp == 8)
? FB_VISUAL_PSEUDOCOLOR
: FB_VISUAL_DIRECTCOLOR;
? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_DIRECTCOLOR;
fix->xpanstep = 0;
fix->ypanstep = nopan ? 0 : 1;
......@@ -1675,12 +1548,12 @@ static int tdfxfb_encode_fix(struct fb_fix_screeninfo* fix,
}
static int tdfxfb_get_fix(struct fb_fix_screeninfo *fix,
int con,
struct fb_info *fb) {
const struct fb_info_tdfx *info = (struct fb_info_tdfx*)fb;
int con, struct fb_info *fb)
{
const struct fb_info_tdfx *info = (struct fb_info_tdfx *) fb;
struct tdfxfb_par par;
if(con == -1)
if (con == -1)
par = info->default_par;
else
tdfxfb_decode_var(&fb_display[con].var, &par, info);
......@@ -1689,11 +1562,11 @@ static int tdfxfb_get_fix(struct fb_fix_screeninfo *fix,
}
static int tdfxfb_get_var(struct fb_var_screeninfo *var,
int con,
struct fb_info *fb) {
const struct fb_info_tdfx *info = (struct fb_info_tdfx*)fb;
int con, struct fb_info *fb)
{
const struct fb_info_tdfx *info = (struct fb_info_tdfx *) fb;
if(con == -1)
if (con == -1)
tdfxfb_encode_var(var, &info->default_par, info);
else
*var = fb_display[con].var;
......@@ -1702,37 +1575,41 @@ static int tdfxfb_get_var(struct fb_var_screeninfo *var,
static void tdfxfb_set_dispsw(struct display *disp,
struct fb_info_tdfx *info,
int bpp,
int accel) {
int bpp, int accel)
{
if (disp->dispsw && disp->conp)
fb_con.con_cursor(disp->conp, CM_ERASE);
switch(bpp) {
switch (bpp) {
#ifdef FBCON_HAS_CFB8
case 8:
disp->dispsw = noaccel ? &fbcon_cfb8 : &fbcon_banshee8;
if (nohwcursor) fbcon_banshee8.cursor = NULL;
if (nohwcursor)
fbcon_banshee8.cursor = NULL;
break;
#endif
#ifdef FBCON_HAS_CFB16
case 16:
disp->dispsw = noaccel ? &fbcon_cfb16 : &fbcon_banshee16;
disp->dispsw_data = info->fbcon_cmap.cfb16;
if (nohwcursor) fbcon_banshee16.cursor = NULL;
if (nohwcursor)
fbcon_banshee16.cursor = NULL;
break;
#endif
#ifdef FBCON_HAS_CFB24
case 24:
disp->dispsw = noaccel ? &fbcon_cfb24 : &fbcon_banshee24;
disp->dispsw_data = info->fbcon_cmap.cfb24;
if (nohwcursor) fbcon_banshee24.cursor = NULL;
if (nohwcursor)
fbcon_banshee24.cursor = NULL;
break;
#endif
#ifdef FBCON_HAS_CFB32
case 32:
disp->dispsw = noaccel ? &fbcon_cfb32 : &fbcon_banshee32;
disp->dispsw_data = info->fbcon_cmap.cfb32;
if (nohwcursor) fbcon_banshee32.cursor = NULL;
if (nohwcursor)
fbcon_banshee32.cursor = NULL;
break;
#endif
default:
......@@ -1742,26 +1619,27 @@ static void tdfxfb_set_dispsw(struct display *disp,
}
static int tdfxfb_set_var(struct fb_var_screeninfo *var,
int con,
struct fb_info *fb) {
struct fb_info_tdfx *info = (struct fb_info_tdfx*)fb;
int con, struct fb_info *fb)
{
struct fb_info_tdfx *info = (struct fb_info_tdfx *) fb;
struct tdfxfb_par par;
struct display *display;
int oldxres, oldyres, oldvxres, oldvyres, oldbpp, oldaccel, accel, err;
int oldxres, oldyres, oldvxres, oldvyres, oldbpp, oldaccel, accel,
err;
int activate = var->activate;
int j,k;
int j, k;
if(con >= 0)
if (con >= 0)
display = &fb_display[con];
else
display = fb->disp; /* used during initialization */
if((err = tdfxfb_decode_var(var, &par, info)))
if ((err = tdfxfb_decode_var(var, &par, info)))
return err;
tdfxfb_encode_var(var, &par, info);
if((activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW) {
if ((activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW) {
oldxres = display->var.xres;
oldyres = display->var.yres;
oldvxres = display->var.xres_virtual;
......@@ -1769,7 +1647,7 @@ static int tdfxfb_set_var(struct fb_var_screeninfo *var,
oldbpp = display->var.bits_per_pixel;
oldaccel = display->var.accel_flags;
display->var = *var;
if(con < 0 ||
if (con < 0 ||
oldxres != var->xres ||
oldyres != var->yres ||
oldvxres != var->xres_virtual ||
......@@ -1791,13 +1669,14 @@ static int tdfxfb_set_var(struct fb_var_screeninfo *var,
accel = var->accel_flags & FB_ACCELF_TEXT;
tdfxfb_set_dispsw(display, info, par.bpp, accel);
if(nopan) display->scrollmode = SCROLL_YREDRAW;
if (nopan)
display->scrollmode = SCROLL_YREDRAW;
if (info->fb_info.changevar)
(*info->fb_info.changevar)(con);
(*info->fb_info.changevar) (con);
}
if (var->bits_per_pixel==8)
for(j = 0; j < 16; j++) {
if (var->bits_per_pixel == 8)
for (j = 0; j < 16; j++) {
k = color_table[j];
fb_info.palette[j].red = default_red[k];
fb_info.palette[j].green = default_grn[k];
......@@ -1805,17 +1684,16 @@ static int tdfxfb_set_var(struct fb_var_screeninfo *var,
}
del_timer(&(info->cursor.timer));
fb_info.cursor.state=CM_ERASE;
if(!info->fb_info.display_fg ||
info->fb_info.display_fg->vc_num == con ||
con < 0)
fb_info.cursor.state = CM_ERASE;
if (!info->fb_info.display_fg ||
info->fb_info.display_fg->vc_num == con || con < 0)
tdfxfb_set_par(&par, info);
if (!nohwcursor)
if (display && display->conp)
tdfxfb_createcursor( display );
info->cursor.redraw=1;
if(oldbpp != var->bits_per_pixel || con < 0) {
if((err = fb_alloc_cmap(&display->cmap, 0, 0)))
tdfxfb_createcursor(display);
info->cursor.redraw = 1;
if (oldbpp != var->bits_per_pixel || con < 0) {
if ((err = fb_alloc_cmap(&display->cmap, 0, 0)))
return err;
do_install_cmap(con, &(info->fb_info));
}
......@@ -1824,59 +1702,61 @@ static int tdfxfb_set_var(struct fb_var_screeninfo *var,
return 0;
}
static int tdfxfb_pan_display(struct fb_var_screeninfo* var,
int con,
struct fb_info* fb) {
struct fb_info_tdfx* i = (struct fb_info_tdfx*)fb;
static int tdfxfb_pan_display(struct fb_var_screeninfo *var,
int con, struct fb_info *fb)
{
struct fb_info_tdfx *i = (struct fb_info_tdfx *) fb;
if(nopan) return -EINVAL;
if(var->xoffset) return -EINVAL;
if(var->yoffset > var->yres_virtual) return -EINVAL;
if(nowrap &&
(var->yoffset + var->yres > var->yres_virtual)) return -EINVAL;
if (nopan)
return -EINVAL;
if (var->xoffset)
return -EINVAL;
if (var->yoffset > var->yres_virtual)
return -EINVAL;
if (nowrap && (var->yoffset + var->yres > var->yres_virtual))
return -EINVAL;
if (con == fb->currcon)
do_pan_var(var,i);
do_pan_var(var, i);
fb_display[con].var.xoffset=var->xoffset;
fb_display[con].var.yoffset=var->yoffset;
fb_display[con].var.xoffset = var->xoffset;
fb_display[con].var.yoffset = var->yoffset;
return 0;
}
static int tdfxfb_get_cmap(struct fb_cmap *cmap,
int kspc,
int con,
struct fb_info *fb) {
int kspc, int con, struct fb_info *fb)
{
struct fb_info_tdfx* i = (struct fb_info_tdfx*)fb;
struct display *d=(con<0) ? fb->disp : fb_display + con;
struct fb_info_tdfx *i = (struct fb_info_tdfx *) fb;
struct display *d = (con < 0) ? fb->disp : fb_display + con;
if(con == fb->currcon) {
if (con == fb->currcon) {
/* current console? */
return fb_get_cmap(cmap, kspc, tdfxfb_getcolreg, fb);
} else if(d->cmap.len) {
} else if (d->cmap.len) {
/* non default colormap? */
fb_copy_cmap(&d->cmap, cmap, kspc ? 0 : 2);
} else {
fb_copy_cmap(fb_default_cmap(i->current_par.cmap_len), cmap, kspc ? 0 : 2);
fb_copy_cmap(fb_default_cmap(i->current_par.cmap_len),
cmap, kspc ? 0 : 2);
}
return 0;
}
static int tdfxfb_set_cmap(struct fb_cmap *cmap,
int kspc,
int con,
struct fb_info *fb) {
struct display *d=(con<0) ? fb->disp : fb_display + con;
struct fb_info_tdfx *i = (struct fb_info_tdfx*)fb;
int cmap_len= (i->current_par.bpp == 8) ? 256 : 16;
if (d->cmap.len!=cmap_len) {
int kspc, int con, struct fb_info *fb)
{
struct display *d = (con < 0) ? fb->disp : fb_display + con;
struct fb_info_tdfx *i = (struct fb_info_tdfx *) fb;
int cmap_len = (i->current_par.bpp == 8) ? 256 : 16;
if (d->cmap.len != cmap_len) {
int err;
if((err = fb_alloc_cmap(&d->cmap, cmap_len, 0)))
if ((err = fb_alloc_cmap(&d->cmap, cmap_len, 0)))
return err;
}
if(con == fb->currcon) {
if (con == fb->currcon) {
/* current console? */
return fb_set_cmap(cmap, kspc, fb);
} else {
......@@ -1919,14 +1799,16 @@ static int __devinit tdfxfb_probe(struct pci_dev *pdev,
fb_info.regbase_phys = pci_resource_start(pdev, 0);
fb_info.regbase_size = 1 << 24;
fb_info.regbase_virt = ioremap_nocache(fb_info.regbase_phys, 1 << 24);
fb_info.regbase_virt =
ioremap_nocache(fb_info.regbase_phys, 1 << 24);
if (!fb_info.regbase_virt) {
printk(KERN_WARNING "fb: Can't remap %s register area.\n", name);
printk(KERN_WARNING "fb: Can't remap %s register area.\n",
name);
return -ENXIO;
}
fb_info.bufbase_phys = pci_resource_start (pdev, 1);
fb_info.bufbase_phys = pci_resource_start(pdev, 1);
if (!(fb_info.bufbase_size = do_lfb_size())) {
iounmap(fb_info.regbase_virt);
......@@ -1938,12 +1820,13 @@ static int __devinit tdfxfb_probe(struct pci_dev *pdev,
fb_info.bufbase_size);
if (!fb_info.regbase_virt) {
printk(KERN_WARNING "fb: Can't remap %s framebuffer.\n", name);
printk(KERN_WARNING "fb: Can't remap %s framebuffer.\n",
name);
iounmap(fb_info.regbase_virt);
return -ENXIO;
}
fb_info.iobase = pci_resource_start (pdev, 2);
fb_info.iobase = pci_resource_start(pdev, 2);
printk("fb: %s memory = %ldK\n", name, fb_info.bufbase_size >> 10);
......@@ -1965,7 +1848,7 @@ static int __devinit tdfxfb_probe(struct pci_dev *pdev,
init_timer(&fb_info.cursor.timer);
fb_info.cursor.timer.function = do_flashcursor;
fb_info.cursor.timer.data = (unsigned long)(&fb_info);
fb_info.cursor.timer.data = (unsigned long) (&fb_info);
fb_info.cursor.state = CM_ERASE;
spin_lock_init(&fb_info.DAClock);
......@@ -1988,7 +1871,7 @@ static int __devinit tdfxfb_probe(struct pci_dev *pdev,
var = default_mode[0].var;
noaccel ? (var.accel_flags &= ~FB_ACCELF_TEXT) :
(var.accel_flags |= FB_ACCELF_TEXT) ;
(var.accel_flags |= FB_ACCELF_TEXT);
if (tdfxfb_decode_var(&var, &fb_info.default_par, &fb_info)) {
/*
......@@ -1996,16 +1879,19 @@ static int __devinit tdfxfb_probe(struct pci_dev *pdev,
* line), so try the default
*/
printk(KERN_NOTICE "tdfxfb: can't decode the supplied video mode, using default\n");
printk(KERN_NOTICE
"tdfxfb: can't decode the supplied video mode, using default\n");
var = default_mode[0].var;
noaccel ? (var.accel_flags &= ~FB_ACCELF_TEXT) :
(var.accel_flags |= FB_ACCELF_TEXT) ;
(var.accel_flags |= FB_ACCELF_TEXT);
if (tdfxfb_decode_var(&var, &fb_info.default_par, &fb_info)) {
if (tdfxfb_decode_var
(&var, &fb_info.default_par, &fb_info)) {
/* this is getting really bad!... */
printk(KERN_WARNING "tdfxfb: can't decode default video mode\n");
printk(KERN_WARNING
"tdfxfb: can't decode default video mode\n");
return -ENXIO;
}
}
......@@ -2014,12 +1900,14 @@ static int __devinit tdfxfb_probe(struct pci_dev *pdev,
fb_info.disp.var = var;
if (tdfxfb_set_var(&var, -1, &fb_info.fb_info)) {
printk(KERN_WARNING "tdfxfb: can't set default video mode\n");
printk(KERN_WARNING
"tdfxfb: can't set default video mode\n");
return -ENXIO;
}
if (register_framebuffer(&fb_info.fb_info) < 0) {
printk(KERN_WARNING "tdfxfb: can't register framebuffer\n");
printk(KERN_WARNING
"tdfxfb: can't register framebuffer\n");
return -ENXIO;
}
......@@ -2045,7 +1933,8 @@ static void __devexit tdfxfb_remove(struct pci_dev *pdev)
#ifdef CONFIG_MTRR
if (!nomtrr) {
mtrr_del(fb_info.mtrr_idx, fb_info.bufbase_phys, fb_info.bufbase_size);
mtrr_del(fb_info.mtrr_idx, fb_info.bufbase_phys,
fb_info.bufbase_size);
printk("fb: MTRR's turned off\n");
}
#endif
......@@ -2076,24 +1965,24 @@ module_exit(tdfxfb_exit);
#ifndef MODULE
void tdfxfb_setup(char *options,
int *ints) {
char* this_opt;
void tdfxfb_setup(char *options, int *ints)
{
char *this_opt;
if(!options || !*options)
if (!options || !*options)
return;
while((this_opt = strsep(&options, ",")) != NULL) {
if(!*this_opt)
while ((this_opt = strsep(&options, ",")) != NULL) {
if (!*this_opt)
continue;
if(!strcmp(this_opt, "inverse")) {
if (!strcmp(this_opt, "inverse")) {
inverse = 1;
fb_invert_cmaps();
} else if(!strcmp(this_opt, "noaccel")) {
} else if (!strcmp(this_opt, "noaccel")) {
noaccel = nopan = nowrap = nohwcursor = 1;
} else if(!strcmp(this_opt, "nopan")) {
} else if (!strcmp(this_opt, "nopan")) {
nopan = 1;
} else if(!strcmp(this_opt, "nowrap")) {
} else if (!strcmp(this_opt, "nowrap")) {
nowrap = 1;
} else if (!strcmp(this_opt, "nohwcursor")) {
nohwcursor = 1;
......@@ -2110,26 +1999,28 @@ void tdfxfb_setup(char *options,
}
#endif
static int tdfxfb_switch_con(int con,
struct fb_info *fb) {
struct fb_info_tdfx *info = (struct fb_info_tdfx*)fb;
static int tdfxfb_switch_con(int con, struct fb_info *fb)
{
struct fb_info_tdfx *info = (struct fb_info_tdfx *) fb;
struct tdfxfb_par par;
int old_con = fb->currcon;
int set_par = 1;
/* Do we have to save the colormap? */
if (fb->currcon>=0)
if(fb_display[fb->currcon].cmap.len)
fb_get_cmap(&fb_display[fb->currcon].cmap, 1, tdfxfb_getcolreg, fb);
if (fb->currcon >= 0)
if (fb_display[fb->currcon].cmap.len)
fb_get_cmap(&fb_display[fb->currcon].cmap, 1,
tdfxfb_getcolreg, fb);
fb->currcon = con;
fb_display[fb->currcon].var.activate = FB_ACTIVATE_NOW;
tdfxfb_decode_var(&fb_display[con].var, &par, info);
if (old_con>=0 && vt_cons[old_con]->vc_mode!=KD_GRAPHICS) {
if (old_con >= 0 && vt_cons[old_con]->vc_mode != KD_GRAPHICS) {
/* check if we have to change video registers */
struct tdfxfb_par old_par;
tdfxfb_decode_var(&fb_display[old_con].var, &old_par, info);
if (!memcmp(&par,&old_par,sizeof(par)))
tdfxfb_decode_var(&fb_display[old_con].var, &old_par,
info);
if (!memcmp(&par, &old_par, sizeof(par)))
set_par = 0; /* avoid flicker */
}
if (set_par)
......@@ -2139,18 +2030,16 @@ static int tdfxfb_switch_con(int con,
fb_con.con_cursor(fb_display[con].conp, CM_ERASE);
del_timer(&(info->cursor.timer));
fb_info.cursor.state=CM_ERASE;
fb_info.cursor.state = CM_ERASE;
if (!nohwcursor)
if (fb_display[con].conp)
tdfxfb_createcursor( &fb_display[con] );
tdfxfb_createcursor(&fb_display[con]);
info->cursor.redraw=1;
info->cursor.redraw = 1;
tdfxfb_set_dispsw(&fb_display[con],
info,
par.bpp,
par.accel_flags & FB_ACCELF_TEXT);
info, par.bpp, par.accel_flags & FB_ACCELF_TEXT);
do_install_cmap(con, fb);
tdfxfb_updatevar(con, fb);
......@@ -2159,14 +2048,13 @@ static int tdfxfb_switch_con(int con,
}
/* 0 unblank, 1 blank, 2 no vsync, 3 no hsync, 4 off */
static int tdfxfb_blank(int blank,
struct fb_info *fb)
static int tdfxfb_blank(int blank, struct fb_info *fb)
{
u32 dacmode, state = 0, vgablank = 0;
dacmode = tdfx_inl(DACMODE);
switch(blank) {
switch (blank) {
case 0: /* Screen: On; HSync: On, VSync: On */
state = 0;
vgablank = 0;
......@@ -2193,31 +2081,32 @@ static int tdfxfb_blank(int blank,
dacmode |= state;
banshee_make_room(1);
tdfx_outl(DACMODE, dacmode);
if(vgablank)
if (vgablank)
vga_disable_video();
else
vga_enable_video();
return 0;
}
static int tdfxfb_updatevar(int con,
struct fb_info* fb) {
static int tdfxfb_updatevar(int con, struct fb_info *fb)
{
struct fb_info_tdfx* i = (struct fb_info_tdfx*)fb;
if ((con==fb->currcon) && (!nopan))
do_pan_var(&fb_display[con].var,i);
struct fb_info_tdfx *i = (struct fb_info_tdfx *) fb;
if ((con == fb->currcon) && (!nopan))
do_pan_var(&fb_display[con].var, i);
return 0;
}
static int tdfxfb_getcolreg(unsigned regno,
unsigned* red,
unsigned* green,
unsigned* blue,
unsigned* transp,
struct fb_info* fb) {
struct fb_info_tdfx* i = (struct fb_info_tdfx*)fb;
unsigned *red,
unsigned *green,
unsigned *blue,
unsigned *transp, struct fb_info *fb)
{
struct fb_info_tdfx *i = (struct fb_info_tdfx *) fb;
if (regno > i->current_par.cmap_len) return 1;
if (regno > i->current_par.cmap_len)
return 1;
*red = i->palette[regno].red;
*green = i->palette[regno].green;
......@@ -2231,49 +2120,50 @@ static int tdfxfb_setcolreg(unsigned regno,
unsigned red,
unsigned green,
unsigned blue,
unsigned transp,
struct fb_info* info) {
struct fb_info_tdfx* i = (struct fb_info_tdfx*)info;
unsigned transp, struct fb_info *info)
{
struct fb_info_tdfx *i = (struct fb_info_tdfx *) info;
#ifdef FBCON_HAS_CFB8
u32 rgbcol;
#endif
if (regno >= i->current_par.cmap_len) return 1;
if (regno >= i->current_par.cmap_len)
return 1;
i->palette[regno].red = red;
i->palette[regno].green = green;
i->palette[regno].blue = blue;
switch(i->current_par.bpp) {
switch (i->current_par.bpp) {
#ifdef FBCON_HAS_CFB8
case 8:
rgbcol=(((u32)red & 0xff00) << 8) |
(((u32)green & 0xff00) << 0) |
(((u32)blue & 0xff00) >> 8);
do_setpalentry(regno,rgbcol);
rgbcol = (((u32) red & 0xff00) << 8) |
(((u32) green & 0xff00) << 0) |
(((u32) blue & 0xff00) >> 8);
do_setpalentry(regno, rgbcol);
break;
#endif
#ifdef FBCON_HAS_CFB16
case 16:
i->fbcon_cmap.cfb16[regno] =
(((u32)red & 0xf800) >> 0) |
(((u32)green & 0xfc00) >> 5) |
(((u32)blue & 0xf800) >> 11);
(((u32) red & 0xf800) >> 0) |
(((u32) green & 0xfc00) >> 5) |
(((u32) blue & 0xf800) >> 11);
break;
#endif
#ifdef FBCON_HAS_CFB24
case 24:
i->fbcon_cmap.cfb24[regno] =
(((u32)red & 0xff00) << 8) |
(((u32)green & 0xff00) << 0) |
(((u32)blue & 0xff00) >> 8);
(((u32) red & 0xff00) << 8) |
(((u32) green & 0xff00) << 0) |
(((u32) blue & 0xff00) >> 8);
break;
#endif
#ifdef FBCON_HAS_CFB32
case 32:
i->fbcon_cmap.cfb32[regno] =
(((u32)red & 0xff00) << 8) |
(((u32)green & 0xff00) << 0) |
(((u32)blue & 0xff00) >> 8);
(((u32) red & 0xff00) << 8) |
(((u32) green & 0xff00) << 0) |
(((u32) blue & 0xff00) >> 8);
break;
#endif
default:
......@@ -2283,39 +2173,40 @@ static int tdfxfb_setcolreg(unsigned regno,
return 0;
}
static void tdfxfb_createcursorshape(struct display* p)
static void tdfxfb_createcursorshape(struct display *p)
{
unsigned int h,cu,cd;
unsigned int h, cu, cd;
h=fontheight(p);
cd=h;
if (cd >= 10) cd --;
fb_info.cursor.type=p->conp->vc_cursor_type & CUR_HWMASK;
h = fontheight(p);
cd = h;
if (cd >= 10)
cd--;
fb_info.cursor.type = p->conp->vc_cursor_type & CUR_HWMASK;
switch (fb_info.cursor.type) {
case CUR_NONE:
cu=cd;
cu = cd;
break;
case CUR_UNDERLINE:
cu=cd - 2;
cu = cd - 2;
break;
case CUR_LOWER_THIRD:
cu=(h * 2) / 3;
cu = (h * 2) / 3;
break;
case CUR_LOWER_HALF:
cu=h / 2;
cu = h / 2;
break;
case CUR_TWO_THIRDS:
cu=h / 3;
cu = h / 3;
break;
case CUR_BLOCK:
default:
cu=0;
cu = 0;
cd = h;
break;
}
fb_info.cursor.w=fontwidth(p);
fb_info.cursor.u=cu;
fb_info.cursor.d=cd;
fb_info.cursor.w = fontwidth(p);
fb_info.cursor.u = cu;
fb_info.cursor.d = cd;
}
static void tdfxfb_createcursor(struct display *p)
......@@ -2323,7 +2214,7 @@ static void tdfxfb_createcursor(struct display *p)
u8 *cursorbase;
u32 xline;
unsigned int i;
unsigned int h,to;
unsigned int h, to;
tdfxfb_createcursorshape(p);
xline = ~((1 << (32 - fb_info.cursor.w)) - 1);
......@@ -2332,33 +2223,33 @@ static void tdfxfb_createcursor(struct display *p)
xline = swab32(xline);
#endif
cursorbase=(u8*)fb_info.bufbase_virt;
h=fb_info.cursor.cursorimage;
cursorbase = (u8 *) fb_info.bufbase_virt;
h = fb_info.cursor.cursorimage;
to=fb_info.cursor.u;
to = fb_info.cursor.u;
for (i = 0; i < to; i++) {
writel(0, cursorbase+h);
writel(0, cursorbase+h+4);
writel(~0, cursorbase+h+8);
writel(~0, cursorbase+h+12);
writel(0, cursorbase + h);
writel(0, cursorbase + h + 4);
writel(~0, cursorbase + h + 8);
writel(~0, cursorbase + h + 12);
h += 16;
}
to = fb_info.cursor.d;
for (; i < to; i++) {
writel(xline, cursorbase+h);
writel(0, cursorbase+h+4);
writel(~0, cursorbase+h+8);
writel(~0, cursorbase+h+12);
writel(xline, cursorbase + h);
writel(0, cursorbase + h + 4);
writel(~0, cursorbase + h + 8);
writel(~0, cursorbase + h + 12);
h += 16;
}
for (; i < 64; i++) {
writel(0, cursorbase+h);
writel(0, cursorbase+h+4);
writel(~0, cursorbase+h+8);
writel(~0, cursorbase+h+12);
writel(0, cursorbase + h);
writel(0, cursorbase + h + 4);
writel(~0, cursorbase + h + 8);
writel(~0, cursorbase + h + 12);
h += 16;
}
}
......@@ -2366,11 +2257,9 @@ static void tdfxfb_createcursor(struct display *p)
static void tdfxfb_hwcursor_init(void)
{
unsigned int start;
start = (fb_info.bufbase_size-1024) & PAGE_MASK;
fb_info.bufbase_size=start;
fb_info.cursor.cursorimage=fb_info.bufbase_size;
start = (fb_info.bufbase_size - 1024) & PAGE_MASK;
fb_info.bufbase_size = start;
fb_info.cursor.cursorimage = fb_info.bufbase_size;
printk("tdfxfb: reserving 1024 bytes for the hwcursor at %p\n",
fb_info.regbase_virt+fb_info.cursor.cursorimage);
fb_info.regbase_virt + fb_info.cursor.cursorimage);
}
/*
* Frame buffer driver for Trident Blade and Image series
*
* Copyright 2001,2002 - Jani Monoses <jani@astechnix.ro>
*
* $Id: tridentfb.c,v 1.3 2002/02/25 20:09:41 marcelo Exp $
*
* CREDITS:(in order of appearance)
* skeletonfb.c by Geert Uytterhoeven and other fb code in drivers/video
* Special thanks ;) to Mattia Crivellini <tia@mclink.it>
* much inspired by the XFree86 4.1.0 Trident driver sources by Alan Hourihane
* the FreeVGA project
* Francesco Salvestrini <salvestrini@users.sf.net> XP support,code,suggestions
* NOTES:
* Tested on Compaq Presario 12XL300 with CyberBladei1
* Tested on Toshiba 1800-514 with CyberBladeXPAi1
* No monitors were harmed during the writing of this driver
* TODO:
* timing value tweaking so it looks good on every monitor in every mode
* test text acceleration for the Image series
* test DPMS stuff
*/
#include <linux/config.h>
#include <linux/module.h>
#include <linux/fb.h>
#include <linux/init.h>
#include <linux/pci.h>
#include <video/fbcon.h>
#include <video/fbcon-cfb8.h>
#include <video/fbcon-cfb16.h>
#include <video/fbcon-cfb24.h>
#include <video/fbcon-cfb32.h>
#include "tridentfb.h"
#define VERSION "0.6.9"
struct tridentfb_par {
struct fb_var_screeninfo var;
int bpp;
int hres;
int vres;
int linelength;
int vclk; //in MHz
int vtotal;
int vdispend;
int vsyncstart;
int vsyncend;
int vblankstart;
int vblankend;
int htotal;
int hdispend;
int hsyncstart;
int hsyncend;
int hblankstart;
int hblankend;
};
struct tridentfb_info {
struct fb_info_gen gen;
unsigned int fbmem_virt; //framebuffer virtual memory address
unsigned int fbmem; //framebuffer physical memory address
unsigned int memsize; //size of fbmem
unsigned int io; //io space address
unsigned int io_virt; //iospace virtual memory address
unsigned int nativex; //flat panel xres
struct tridentfb_par currentmode;
};
static struct fb_ops tridentfb_ops;
static struct tridentfb_info fb_info;
static struct display disp;
static struct { unsigned char red,green,blue,transp; } palette[256];
static struct fb_var_screeninfo default_var;
static char * tridentfb_name = "Trident";
static int family;
static int pci_id;
static int defaultaccel;
static int displaytype;
static int pseudo_pal[16];
/* defaults which are normally overriden by user values */
/* video mode */
static char * mode = "640x480";
static int bpp = 8;
static int noaccel;
static int accel;
static int center;
static int stretch;
static int fp;
static int crt;
static int memsize;
static int memdiff;
static int nativex;
MODULE_PARM(mode,"s");
MODULE_PARM(bpp,"i");
MODULE_PARM(center,"i");
MODULE_PARM(stretch,"i");
MODULE_PARM(noaccel,"i");
MODULE_PARM(accel,"i");
MODULE_PARM(memsize,"i");
MODULE_PARM(memdiff,"i");
MODULE_PARM(nativex,"i");
MODULE_PARM(fp,"i");
MODULE_PARM(crt,"i");
#define CRT 0x3D0 //CRTC registers offset for color display
#ifndef TRIDENT_MMIO
#define TRIDENT_MMIO 1
#endif
#if TRIDENT_MMIO
#define t_outb(val,reg) writeb(val,fb_info.io_virt + reg)
#define t_inb(reg) readb(fb_info.io_virt + reg)
#else
#define t_outb(val,reg) outb(val,reg)
#define t_inb(reg) inb(reg)
#endif
static struct accel_switch {
void (*init_accel)(int,int);
void (*wait_engine)(void);
void (*fill_rect)(int,int,int,int,int);
void (*copy_rect)(int,int,int,int,int,int);
} *acc;
#define writemmr(r,v) writel(v, fb_info.io_virt + r)
#define readmmr(r) readl(fb_info.io_virt + r)
/*
* Blade specific acceleration.Not XP's though those are
* unaccelerated.
*/
#define point(x,y) ((y)<<16|(x))
#define STA 0x2120
#define CMD 0x2144
#define ROP 0x2148
#define CLR 0x2160
#define SR1 0x2100
#define SR2 0x2104
#define DR1 0x2108
#define DR2 0x210C
#define REPL(x) x = x | x<<16
#define ROP_S 0xCC
static void blade_init_accel(int pitch,int bpp)
{
int v1 = (pitch>>3)<<20;
int tmp = 0,v2;
switch (bpp) {
case 8:tmp = 0;break;
case 15:tmp = 5;break;
case 16:tmp = 1;break;
case 24:
case 32:tmp = 2;break;
}
v2 = v1 | (tmp<<29);
writemmr(0x21C0,v2);
writemmr(0x21C4,v2);
writemmr(0x21B8,v2);
writemmr(0x21BC,v2);
writemmr(0x21D0,v1);
writemmr(0x21D4,v1);
writemmr(0x21C8,v1);
writemmr(0x21CC,v1);
writemmr(0x216C,0);
}
static void blade_wait_engine(void)
{
while(readmmr(STA) & 0xFA800000);
}
static void blade_fill_rect(int x,int y,int w,int h,int c)
{
writemmr(CLR,c);
writemmr(ROP,ROP_S);
writemmr(CMD,0x20000000|1<<19|1<<4|2<<2);
writemmr(DR1,point(x,y));
writemmr(DR2,point(x+w-1,y+h-1));
}
static void blade_copy_rect(int x1,int y1,int x2,int y2,int w,int h)
{
int s1,s2,d1,d2;
int direction = 2;
s1 = point(x1,y1);
s2 = point(x1+w-1,y1+h-1);
d1 = point(x2,y2);
d2 = point(x2+w-1,y2+h-1);
if ((y1 > y2) || ((y1 == y2) && (x1 >x2)))
direction = 0;
writemmr(ROP,ROP_S);
writemmr(CMD,0xE0000000|1<<19|1<<4|1<<2|direction);
writemmr(SR1,direction?s2:s1);
writemmr(SR2,direction?s1:s2);
writemmr(DR1,direction?d2:d1);
writemmr(DR2,direction?d1:d2);
}
static struct accel_switch accel_blade = {
blade_init_accel,
blade_wait_engine,
blade_fill_rect,
blade_copy_rect,
};
/*
* Image specific acceleration functions
*/
static void image_init_accel(int pitch,int bpp)
{
int tmp = 0;
switch (bpp) {
case 8:tmp = 0;break;
case 15:tmp = 5;break;
case 16:tmp = 1;break;
case 24:
case 32:tmp = 2;break;
}
writemmr(0x2120, 0xF0000000);
writemmr(0x2120, 0x40000000|tmp);
writemmr(0x2120, 0x80000000);
writemmr(0x2144, 0x00000000);
writemmr(0x2148, 0x00000000);
writemmr(0x2150, 0x00000000);
writemmr(0x2154, 0x00000000);
writemmr(0x2120, 0x60000000 |(pitch<<16) |pitch);
writemmr(0x216C, 0x00000000);
writemmr(0x2170, 0x00000000);
writemmr(0x217C, 0x00000000);
writemmr(0x2120, 0x10000000);
writemmr(0x2130, (2047 << 16) | 2047);
}
static void image_wait_engine(void)
{
while(readmmr(0x2164) & 0xF0000000);
}
static void image_fill_rect(int x,int y,int w,int h,int c)
{
writemmr(0x2120,0x80000000);
writemmr(0x2120,0x90000000|ROP_S);
writemmr(0x2144,c);
writemmr(DR1,point(x,y));
writemmr(DR2,point(x+w-1,y+h-1));
writemmr(0x2124,0x80000000|3<<22|1<<10|1<<9);
}
static void image_copy_rect(int x1,int y1,int x2,int y2,int w,int h)
{
int s1,s2,d1,d2;
int direction = 2;
s1 = point(x1,y1);
s2 = point(x1+w-1,y1+h-1);
d1 = point(x2,y2);
d2 = point(x2+w-1,y2+h-1);
if ((y1 > y2) || ((y1 == y2) && (x1 >x2)))
direction = 0;
writemmr(0x2120,0x80000000);
writemmr(0x2120,0x90000000|ROP_S);
writemmr(SR1,direction?s2:s1);
writemmr(SR2,direction?s1:s2);
writemmr(DR1,direction?d2:d1);
writemmr(DR2,direction?d1:d2);
writemmr(0x2124,0x80000000|1<<22|1<<10|1<<7|direction);
}
static struct accel_switch accel_image = {
image_init_accel,
image_wait_engine,
image_fill_rect,
image_copy_rect,
};
/*
* Accel functions called by the upper layers
*/
static void trident_bmove (struct display *p, int sy, int sx,
int dy, int dx, int height, int width)
{
sx *= fontwidth(p);
dx *= fontwidth(p);
width *= fontwidth(p);
sy *= fontheight(p);
dy *= fontheight(p);
height *= fontheight(p);
acc->copy_rect(sx,sy,dx,dy,width,height);
acc->wait_engine();
}
static void trident_clear_helper (int c, struct display *p,
int sy, int sx, int height, int width)
{
sx *= fontwidth(p);
sy *= fontheight(p);
width *= fontwidth(p);
height *= fontheight(p);
acc->fill_rect(sx,sy,width,height,c);
acc->wait_engine();
}
#ifdef FBCON_HAS_CFB8
static void trident_8bpp_clear (struct vc_data *conp, struct display *p,
int sy, int sx, int height, int width)
{
int c;
c = attr_bgcol_ec(p,conp) & 0xFF;
c |= c<<8;
c |= c<<16;
trident_clear_helper(c,p,sy,sx,height,width);
}
static struct display_switch trident_8bpp = {
setup: fbcon_cfb8_setup,
bmove: trident_bmove,
clear: trident_8bpp_clear,
putc: fbcon_cfb8_putc,
putcs: fbcon_cfb8_putcs,
revc: fbcon_cfb8_revc,
clear_margins: fbcon_cfb8_clear_margins,
fontwidthmask: FONTWIDTH (4) | FONTWIDTH (8) | FONTWIDTH (12) | FONTWIDTH (16)
};
#endif
#ifdef FBCON_HAS_CFB16
static void trident_16bpp_clear (struct vc_data *conp, struct display *p,
int sy, int sx, int height, int width)
{
int c;
c = ((u16*)p->dispsw_data)[attr_bgcol_ec(p,conp)];
c = c | c<<16;
trident_clear_helper(c,p,sy,sx,height,width);
}
static struct display_switch trident_16bpp = {
setup: fbcon_cfb16_setup,
bmove: trident_bmove,
clear: trident_16bpp_clear,
putc: fbcon_cfb16_putc,
putcs: fbcon_cfb16_putcs,
revc: fbcon_cfb16_revc,
clear_margins: fbcon_cfb16_clear_margins,
fontwidthmask: FONTWIDTH (4) | FONTWIDTH (8) | FONTWIDTH (12) | FONTWIDTH (16)
};
#endif
#ifdef FBCON_HAS_CFB32
static void trident_32bpp_clear (struct vc_data *conp, struct display *p,
int sy, int sx, int height, int width)
{
int c;
c = ((u32*)p->dispsw_data)[attr_bgcol_ec(p,conp)];
trident_clear_helper(c,p,sy,sx,height,width);
}
static struct display_switch trident_32bpp = {
setup: fbcon_cfb32_setup,
bmove: trident_bmove,
clear: trident_32bpp_clear,
putc: fbcon_cfb32_putc,
putcs: fbcon_cfb32_putcs,
revc: fbcon_cfb32_revc,
clear_margins: fbcon_cfb32_clear_margins,
fontwidthmask: FONTWIDTH (4) | FONTWIDTH (8) | FONTWIDTH (12) | FONTWIDTH (16)
};
#endif
/*
* Hardware access functions
*/
static inline unsigned char read3X4(int reg)
{
writeb(reg, fb_info.io_virt + CRT + 4);
return readb(fb_info.io_virt + CRT + 5);
}
static inline void write3X4(int reg, unsigned char val)
{
writeb(reg, fb_info.io_virt + CRT + 4);
writeb(val, fb_info.io_virt + CRT + 5);
}
static inline unsigned char read3C4(int reg)
{
t_outb(reg, 0x3C4);
return t_inb(0x3C5);
}
static inline void write3C4(int reg, unsigned char val)
{
t_outb(reg, 0x3C4);
t_outb(val, 0x3C5);
}
static inline unsigned char read3CE(int reg)
{
t_outb(reg, 0x3CE);
return t_inb(0x3CF);
}
static inline void writeAttr(int reg, unsigned char val)
{
readb(fb_info.io_virt + CRT + 0x0A); //flip-flop to index
t_outb(reg, 0x3C0);
t_outb(val, 0x3C0);
}
static inline unsigned char readAttr(int reg)
{
readb(fb_info.io_virt + CRT + 0x0A); //flip-flop to index
t_outb(reg, 0x3C0);
return t_inb(0x3C1);
}
static inline void write3CE(int reg, unsigned char val)
{
t_outb(reg, 0x3CE);
t_outb(val, 0x3CF);
}
#define unprotect_all() write3C4(Protection, 0x92);unprotect()
#define unprotect() write3C4(NewMode1,0xC2)
#define bios_reg(reg) write3CE(BiosReg, reg)
#define enable_mmio() outb(PCIReg, 0x3D4); \
outb(inb(0x3D5) | 0x01, 0x3D5)
#define crtc_unlock() write3X4(CRTVSyncEnd, read3X4(CRTVSyncEnd) & 0x7F)
/* Return flat panel's maximum x resolution */
static int __init get_nativex(void)
{
int x,y,tmp;
if (nativex)
return nativex;
tmp = (read3CE(VertStretch) >> 4) & 3;
/* detection broken on XPAi ??? misdetects 1024 for 800 */
if (pci_id == CYBERBLADEXPAi1 && tmp == 3)
tmp = 2;
switch (tmp) {
case 0:x = 1280;y = 1024;break;
case 1:x = 640;y = 480;break;
case 2:x = 1024;y = 768;break;
default:x = 800;y = 600;break;
}
output("%dx%d flat panel found\n", x, y);
return x;
}
/* Set pitch */
static void set_lwidth(int width)
{
write3X4(Offset, width & 0xFF);
write3X4(AddColReg, (read3X4(AddColReg) & 0xCF) | ((width & 0x300) >>4));
}
/* For resolutions smaller than FP resolution stretch */
static void screen_stretch(void)
{
write3CE(VertStretch,(read3CE(VertStretch) & 0x7C) | 1);
write3CE(HorStretch,(read3CE(HorStretch) & 0x7C) | 1);
}
/* For resolutions smaller than FP resolution center */
static void screen_center(void)
{
bios_reg(0); // no stretch
write3CE(VertStretch,(read3CE(VertStretch) & 0x7C) | 0x80);
write3CE(HorStretch,(read3CE(HorStretch) & 0x7C) | 0x80);
}
/* Address of first shown pixel in display memory */
static void set_screen_start(int base)
{
write3X4(StartAddrLow, base & 0xFF);
write3X4(StartAddrHigh, (base & 0xFF00) >>8);
write3X4(CRTCModuleTest, (read3X4(CRTCModuleTest) & 0xDF) | ((base & 0x10000) >>11));
write3X4(CRTHiOrd, (read3X4(CRTHiOrd) & 0xF8) | (base & 0xE0000) >> 17);
}
/* Use 20.12 fixed-point for NTSC value and frequency calculation */
#define calc_freq(n,m,k) ( (unsigned long)0xE517 * (n+8) / (m+2)*(1<<k) )
/* Set dotclock frequency */
static void set_vclk(int freq)
{
int m,n,k;
int f,fi,d,di;
unsigned char lo=0,hi=0;
d = 20;
for(k = 2;k>=0;k--)
for(m = 0;m<63;m++)
for(n = 0;n<128;n++) {
fi = calc_freq(n,m,k);
if ((di = abs(fi - freq)) < d) {
d = di;
f = fi;
lo = n;
hi = (k<<6) | m;
}
}
write3C4(ClockHigh,hi);
write3C4(ClockLow,lo);
debug("VCLK = %X %X\n",hi,lo);
}
/* Set number of lines for flat panels*/
static void set_number_of_lines(int lines)
{
int tmp = read3CE(CyberEnhance) & 0x8F;
if (lines > 768)
tmp |= 0x30;
else if (lines > 600)
tmp |= 0x20;
else if (lines > 480)
tmp |= 0x10;
write3CE(CyberEnhance, tmp);
}
/*
* If we see that FP is active we assume we have one.
* Otherwise we have a CRT display.User can override.
*/
static unsigned int __init get_displaytype(void)
{
if (fp)
return DISPLAY_FP;
if (crt)
return DISPLAY_CRT;
return (read3CE(FPConfig) & 0x10)?DISPLAY_FP:DISPLAY_CRT;
}
/* Try detecting the video memory size */
static unsigned int __init get_memsize(void)
{
unsigned char tmp;
unsigned int k;
/* If memory size provided by user */
if (memsize)
k = memsize * Kb;
else
switch (pci_id) {
case CYBER9525DVD:k = 2560 * Kb;break;
case CYBERBLADEXPAi1:k = 16 * Mb;break;
case CYBERBLADEXPm16:k = 16 * Mb;break;
case CYBERBLADEXPm8:k = 8 * Mb;break;
default:
tmp = read3X4(SPR) & 0x0F;
switch (tmp) {
case 3:k = 1 * Mb;break;
case 7:k = 2 * Mb;break;
case 15:k = 4 * Mb;break;
case 4:k = 8 * Mb;break;
default:k = 1 * Mb;
}
}
k -= memdiff * Kb;
output("framebuffer size = %d Kb\n", k/Kb);
return k;
}
/* Fill in fix */
static int trident_encode_fix(struct fb_fix_screeninfo *fix,
const void *par,
struct fb_info_gen *info)
{
struct tridentfb_info * i = (struct tridentfb_info *)info;
struct tridentfb_par * p = (struct tridentfb_par *)par;
debug("enter\n");
memset(fix, 0, sizeof(struct fb_fix_screeninfo));
strcpy(fix->id,tridentfb_name);
fix->smem_start = i->fbmem;
fix->smem_len = i->memsize;
fix->type = FB_TYPE_PACKED_PIXELS;
fix->type_aux = 0;
fix->visual = p->bpp==8 ? FB_VISUAL_PSEUDOCOLOR:FB_VISUAL_TRUECOLOR;
fix->xpanstep = fix->ywrapstep = 0;
fix->ypanstep = 1;
fix->line_length = p->linelength;
fix->mmio_start = 0;
fix->mmio_len = 0;
fix->accel = FB_ACCEL_NONE;
debug("exit\n");
return 0;
}
/* Fill in par from var */
static int trident_decode_var(const struct fb_var_screeninfo *var,
void *par,
struct fb_info_gen *info)
{
struct tridentfb_par * p = (struct tridentfb_par *)par;
struct tridentfb_info * i = (struct tridentfb_info *)info;
int vres,vfront,vback,vsync;
debug("enter\n");
p->var = *var;
p->bpp = var->bits_per_pixel;
if (p->bpp == 24 )
p->bpp = 32;
p->linelength = var->xres_virtual * p->bpp/8;
switch (p->bpp) {
case 8:
p->var.red.offset = 0;
p->var.green.offset = 0;
p->var.blue.offset = 0;
p->var.red.length = 6;
p->var.green.length = 6;
p->var.blue.length = 6;
break;
case 16:
p->var.red.offset = 11;
p->var.green.offset = 5;
p->var.blue.offset = 0;
p->var.red.length = 5;
p->var.green.length = 6;
p->var.blue.length = 5;
break;
case 32:
p->var.red.offset = 16;
p->var.green.offset = 8;
p->var.blue.offset = 0;
p->var.red.length = 8;
p->var.green.length = 8;
p->var.blue.length = 8;
break;
default:
return -EINVAL;
}
/* convert from picoseconds to MHz */
p->vclk = 1000000/var->pixclock;
if (p->bpp == 32)
p->vclk *=2;
p->hres = var->xres;
vres = p->vres = var->yres;
/* See if requested resolution is larger than flat panel */
if (p->hres > i->nativex && flatpanel) {
return -EINVAL;
}
/* See if requested resolution fits in available memory */
if (p->hres * p->vres * p->bpp/8 > i->memsize) {
return -EINVAL;
}
vfront = var->upper_margin;
vback = var->lower_margin;
vsync = var->vsync_len;
/* Compute horizontal and vertical VGA CRTC timing values */
if (var->vmode & FB_VMODE_INTERLACED) {
vres /= 2;
vfront /=2;
vback /=2;
vsync /=2;
}
if (var->vmode & FB_VMODE_DOUBLE) {
vres *= 2;
vfront *=2;
vback *=2;
vsync *=2;
}
p->htotal = (p->hres + var->left_margin + var->right_margin + var->hsync_len)/8 - 10;
p->hdispend = p->hres/8 - 1;
p->hsyncstart = (p->hres + var->right_margin)/8;
p->hsyncend = var->hsync_len/8;
p->hblankstart = p->hdispend + 1;
p->hblankend = p->htotal + 5;
p->vtotal = vres + vfront + vback + vsync - 2;
p->vdispend = vres - 1;
p->vsyncstart = vres + vback;
p->vsyncend = vsync;
p->vblankstart = vres;
p->vblankend = p->vtotal + 2;
debug("exit\n");
return 0;
}
/* Fill in var from info */
static int trident_encode_var(struct fb_var_screeninfo *var,
const void *par,
struct fb_info_gen *info)
{
struct tridentfb_par * p = (struct tridentfb_par *)par;
debug("enter\n");
*var = p->var;
var->bits_per_pixel = p->bpp;
debug("exit\n");
return 0;
}
/* Fill in par from hardware */
static void trident_get_par(void *par, struct fb_info_gen *info)
{
struct tridentfb_par * p = (struct tridentfb_par *)par;
struct tridentfb_info * i = (struct tridentfb_info *)info;
debug("enter\n");
*p = i->currentmode;
debug("exit\n");
}
/* Pan the display */
static int trident_pan_display(const struct fb_var_screeninfo *var,
struct fb_info_gen *info)
{
unsigned int offset;
struct tridentfb_info * i = (struct tridentfb_info *)info;
debug("enter\n");
offset = (var->xoffset + (var->yoffset * var->xres))
* var->bits_per_pixel/32;
i->currentmode.var.xoffset = var->xoffset;
i->currentmode.var.yoffset = var->yoffset;
set_screen_start(offset);
debug("exit\n");
return 0;
}
/* Set the hardware from par */
static void trident_set_par(const void *par, struct fb_info_gen *info)
{
struct tridentfb_par * p = (struct tridentfb_par *)par;
struct tridentfb_info * i = (struct tridentfb_info *)info;
unsigned char tmp;
debug("enter\n");
i->currentmode = *p;
unprotect_all();
crtc_unlock();
enable_mmio();
write3CE(CyberControl,8);
if (flatpanel && p->hres < i->nativex) {
/*
* on flat panels with native size larger
* than requested resolution decide whether
* we stretch or center
*/
t_outb(0xEB,0x3C2);
write3CE(CyberControl,0x81);
if (center) //|| (p->bpp==32 && pci_id == CYBERBLADEi1D))
screen_center();
else if (stretch)
screen_stretch();
} else {
t_outb(0x2B,0x3C2);
write3CE(CyberControl,8);
}
/* vertical timing values */
write3X4(CRTVTotal, p->vtotal & 0xFF);
write3X4(CRTVDispEnd, p->vdispend & 0xFF);
write3X4(CRTVSyncStart, p->vsyncstart & 0xFF);
write3X4(CRTVSyncEnd, (p->vsyncend & 0x0F));
write3X4(CRTVBlankStart, p->vblankstart & 0xFF);
write3X4(CRTVBlankEnd, 0/*p->vblankend & 0xFF*/);
/* horizontal timing values */
write3X4(CRTHTotal, p->htotal & 0xFF);
write3X4(CRTHDispEnd, p->hdispend & 0xFF);
write3X4(CRTHSyncStart, p->hsyncstart & 0xFF);
write3X4(CRTHSyncEnd, (p->hsyncend & 0x1F) | ((p->hblankend & 0x20)<<2));
write3X4(CRTHBlankStart, p->hblankstart & 0xFF);
write3X4(CRTHBlankEnd, 0/*(p->hblankend & 0x1F)*/);
/* higher bits of vertical timing values */
tmp = 0x10;
if (p->vtotal & 0x100) tmp |= 0x01;
if (p->vdispend & 0x100) tmp |= 0x02;
if (p->vsyncstart & 0x100) tmp |= 0x04;
if (p->vblankstart & 0x100) tmp |= 0x08;
if (p->vtotal & 0x200) tmp |= 0x20;
if (p->vdispend & 0x200) tmp |= 0x40;
if (p->vsyncstart & 0x200) tmp |= 0x80;
write3X4(CRTOverflow, tmp);
tmp = read3X4(CRTHiOrd) | 0x08; //line compare bit 10
if (p->vtotal & 0x400) tmp |= 0x80;
if (p->vblankstart & 0x400) tmp |= 0x40;
if (p->vsyncstart & 0x400) tmp |= 0x20;
if (p->vdispend & 0x400) tmp |= 0x10;
write3X4(CRTHiOrd, tmp);
write3X4(HorizOverflow, 0);
tmp = 0x40;
if (p->vblankstart & 0x200) tmp |= 0x20;
if (p->var.vmode & FB_VMODE_DOUBLE) tmp |= 0x80; //double scan for 200 line modes
write3X4(CRTMaxScanLine, tmp);
write3X4(CRTLineCompare,0xFF);
write3X4(CRTPRowScan,0);
write3X4(CRTModeControl,0xC3);
write3X4(LinearAddReg,0x20); //enable linear addressing
tmp = (p->var.vmode & FB_VMODE_INTERLACED) ? 0x84:0x80;
write3X4(CRTCModuleTest,tmp); //enable access extended memory
write3X4(GraphEngReg, 0x80); //enable GE for text acceleration
if (p->var.accel_flags & FB_ACCELF_TEXT)
acc->init_accel(p->hres,p->bpp);
switch (p->bpp) {
case 8:tmp=0;break;
case 16:tmp=5;break;
case 24:
/* tmp=0x29;break; */
/* seems like 24bpp is same as 32bpp when using vesafb */
case 32:tmp=9;break;
}
write3X4(PixelBusReg, tmp);
write3X4(InterfaceSel, 0x5B); //32bit internal data path
write3X4(DRAMControl, 0x30); //both IO,linear enable
write3X4(Performance, 0xBF);
write3X4(PCIReg,0x07); //MMIO & PCI read and write burst enable
set_vclk(p->vclk);
write3C4(0,3);
write3C4(1,1); //set char clock 8 dots wide
write3C4(2,0x0F); //enable 4 maps because needed in chain4 mode
write3C4(3,0);
write3C4(4,0x0E); //memory mode enable bitmaps ??
write3CE(MiscExtFunc,(p->bpp==32)?0x1A:0x12); //divide clock by 2 if 32bpp
//chain4 mode display and CPU path
write3CE(0x5,0x40); //no CGA compat,allow 256 col
write3CE(0x6,0x05); //graphics mode
write3CE(0x7,0x0F); //planes?
writeAttr(0x10,0x41); //graphics mode and support 256 color modes
writeAttr(0x12,0x0F); //planes
writeAttr(0x13,0); //horizontal pel panning
//colors
for(tmp = 0;tmp < 0x10;tmp++)
writeAttr(tmp,tmp);
readb(fb_info.io_virt + CRT + 0x0A); //flip-flop to index
t_outb(0x20, 0x3C0); //enable attr
switch (p->bpp) {
case 8: tmp = 0;break; //256 colors
case 15: tmp = 0x10;break;
case 16: tmp = 0x30;break; //hicolor
case 24: //truecolor
case 32: tmp = 0xD0;break;
}
t_inb(0x3C8);
t_inb(0x3C6);
t_inb(0x3C6);
t_inb(0x3C6);
t_inb(0x3C6);
t_outb(tmp,0x3C6);
t_inb(0x3C8);
if (flatpanel)
set_number_of_lines(p->vres);
set_lwidth(p->hres*p->bpp/(4*16));
trident_pan_display(&p->var,info);
debug("exit\n");
}
/* Get value of one color register */
static int trident_getcolreg(unsigned regno, unsigned *red,
unsigned *green, unsigned *blue,
unsigned *transp, struct fb_info *info)
{
struct tridentfb_info * i = (struct tridentfb_info *)info;
int m = i->currentmode.bpp==8?256:16;
debug("enter %d\n",regno);
if (regno >= m)
return 1;
*red = palette[regno].red;
*green = palette[regno].green;
*blue = palette[regno].blue;
*transp = palette[regno].transp;
debug("exit\n");
return 0;
}
/* Set one color register */
static int tridentfb_setcolreg(unsigned regno, unsigned red, unsigned green,
unsigned blue, unsigned transp,
struct fb_info *info)
{
struct tridentfb_info * i = (struct tridentfb_info *)info;
int bpp = i->currentmode.bpp;
int m = bpp==8?256:16;
debug("enter %d\n",regno);
if (regno >= m)
return 1;
palette[regno].red = red;
palette[regno].green = green;
palette[regno].blue = blue;
palette[regno].transp = transp;
if (bpp==8) {
t_outb(0xFF,0x3C6);
t_outb(regno,0x3C8);
t_outb(red>>10,0x3C9);
t_outb(green>>10,0x3C9);
t_outb(blue>>10,0x3C9);
} else
if (bpp == 16) /* RGB 565 */
((u16*)info->pseudo_palette)[regno] = (red & 0xF800) |
((green & 0xFC00) >> 5) | ((blue & 0xF800) >> 11);
else
if (bpp == 32) /* ARGB 8888 */
((u32*)info->pseudo_palette)[regno] =
((transp & 0xFF00) <<16) |
((red & 0xFF00) << 8) |
((green & 0xFF00)) |
((blue & 0xFF00)>>8);
debug("exit\n");
return 0;
}
/* Try blanking the screen.For flat panels it does nothing */
static int trident_blank(int blank_mode, struct fb_info_gen *info)
{
unsigned char PMCont,DPMSCont;
debug("enter\n");
if (flatpanel)
return 0;
t_outb(0x04,0x83C8); /* Read DPMS Control */
PMCont = t_inb(0x83C6) & 0xFC;
DPMSCont = read3CE(PowerStatus) & 0xFC;
switch (blank_mode)
{
case VESA_NO_BLANKING:
/* Screen: On, HSync: On, VSync: On */
PMCont |= 0x03;
DPMSCont |= 0x00;
break;
case VESA_HSYNC_SUSPEND:
/* Screen: Off, HSync: Off, VSync: On */
PMCont |= 0x02;
DPMSCont |= 0x01;
break;
case VESA_VSYNC_SUSPEND:
/* Screen: Off, HSync: On, VSync: Off */
PMCont |= 0x02;
DPMSCont |= 0x02;
break;
case VESA_POWERDOWN:
/* Screen: Off, HSync: Off, VSync: Off */
PMCont |= 0x00;
DPMSCont |= 0x03;
break;
}
write3CE(PowerStatus,DPMSCont);
t_outb(4,0x83C8);
t_outb(PMCont,0x83C6);
debug("exit\n");
return 0;
}
/* Set display switch used by console */
static void trident_set_disp(const void *par, struct display *disp,
struct fb_info_gen *info)
{
struct tridentfb_info * i = (struct tridentfb_info *)info;
struct fb_info * ii = (struct fb_info *)info;
struct tridentfb_par * p = (struct tridentfb_par *)par;
int isaccel = p->var.accel_flags & FB_ACCELF_TEXT;
info->info.screen_base = (char *)i->fbmem_virt;
debug("enter\n");
#ifdef FBCON_HAS_CFB8
if (p->bpp == 8 ) {
if (isaccel)
disp->dispsw = &trident_8bpp;
else
disp->dispsw = &fbcon_cfb8;
} else
#endif
#ifdef FBCON_HAS_CFB16
if (p->bpp == 16) {
if (isaccel)
disp->dispsw = &trident_16bpp;
else
disp->dispsw = &fbcon_cfb16;
disp->dispsw_data =ii->pseudo_palette; /* console palette */
} else
#endif
#ifdef FBCON_HAS_CFB32
if (p->bpp == 32) {
if (isaccel)
disp->dispsw = &trident_32bpp;
else
disp->dispsw = &fbcon_cfb32;
disp->dispsw_data =ii->pseudo_palette; /* console palette */
} else
#endif
disp->dispsw = &fbcon_dummy;
debug("exit\n");
}
static struct fbgen_hwswitch trident_hwswitch = {
NULL, /* detect not needed */
trident_encode_fix,
trident_decode_var,
trident_encode_var,
trident_get_par,
trident_set_par,
trident_getcolreg,
trident_pan_display,
trident_blank,
trident_set_disp
};
/* List of boards that we are trying to support */
static struct almost_supported_board {
int pci_id;
int family;
struct accel_switch * acc;
char* board_name;
int accel;
} asb[] __initdata = {
{ BLADE3D, BLADE, &accel_blade, "Blade3D", ACCEL },
{ CYBERBLADEi7, BLADE, &accel_blade, "CyberBladei7", ACCEL },
{ CYBERBLADEi7D, BLADE, &accel_blade, "CyberBladei7D", ACCEL },
{ CYBERBLADEi1, BLADE, &accel_blade, "CyberBladei1", ACCEL },
{ CYBERBLADEi1D, BLADE, &accel_blade, "CyberBladei1D", ACCEL },
{ CYBERBLADEAi1, BLADE, &accel_blade, "CyberBladeAi1", ACCEL },
{ CYBERBLADEAi1D, BLADE, &accel_blade, "CyberBladeAi1D", ACCEL },
{ CYBERBLADEE4, BLADE, &accel_blade, "CyberBladeE4", ACCEL },
{ IMAGE975, IMAGE, &accel_image, "IMAGE975", NOACCEL },
{ IMAGE985, IMAGE, &accel_image, "IMAGE985", NOACCEL },
{ CYBER9320, IMAGE, &accel_image, "Cyber9320", NOACCEL },
{ CYBER9388, IMAGE, &accel_image, "Cyber9388", NOACCEL },
{ CYBER9520, IMAGE, &accel_image, "Cyber9520", NOACCEL },
{ CYBER9525DVD, IMAGE, &accel_image, "Cyber9525DVD", NOACCEL },
{ CYBER9397, IMAGE, &accel_image, "Cyber9397", NOACCEL },
{ CYBER9397DVD, IMAGE, &accel_image, "Cyber9397DVD", NOACCEL },
{ CYBERBLADEXPAi1, XP, &accel_blade, "CyberBladeXPAi1", NOACCEL },
{ CYBERBLADEXPm8, XP, &accel_blade, "CyberBladeXPm8", NOACCEL },
{ CYBERBLADEXPm16, XP, &accel_blade, "CyberBladeXPm16", NOACCEL },
};
static __init int trident_find_board(void)
{
int i;
struct pci_dev * board;
for (i = 0;i < ARRAY_SIZE(asb);i++) {
if ((board = pci_find_device(PCI_VENDOR_ID_TRIDENT,
asb[i].pci_id,
NULL))) {
family = asb[i].family;
acc = asb[i].acc;
pci_id = asb[i].pci_id;
defaultaccel = asb[i].accel;
fb_info.io = pci_resource_start(board,1);
fb_info.fbmem = pci_resource_start(board,0);
output("%s board found\n", asb[i].board_name);
return 1;
}
}
output("No Trident board found\n");
return 0;
}
int __init tridentfb_init(void)
{
output("Trident framebuffer %s initializing\n", VERSION);
if (!trident_find_board())
return -1;
if (!request_mem_region(fb_info.io, TRIDENT_IOSIZE, "tridentfb")) {
debug("request_region failed!\n");
return -1;
};
fb_info.io_virt = (unsigned int)ioremap_nocache(fb_info.io, TRIDENT_IOSIZE);
if (!fb_info.io_virt) {
release_region(fb_info.io, TRIDENT_IOSIZE);
debug("ioremap failed\n");
return -1;
}
fb_info.memsize = get_memsize();
if (!request_mem_region(fb_info.fbmem, fb_info.memsize, "tridentfb")) {
debug("request_mem_region failed!\n");
return -1;
}
fb_info.fbmem_virt = (unsigned int)ioremap_nocache(fb_info.fbmem, fb_info.memsize);
if (!fb_info.fbmem_virt) {
release_mem_region(fb_info.fbmem, fb_info.memsize);
debug("ioremap failed\n");
return -1;
}
debug("Trident board found : mem = %X,io = %X, mem_v = %X, io_v = %X\n",
fb_info.fbmem, fb_info.io, fb_info.fbmem_virt, fb_info.io_virt);
fb_info.gen.parsize = sizeof (struct tridentfb_par);
fb_info.gen.fbhw = &trident_hwswitch;
strcpy(fb_info.gen.info.modename, tridentfb_name);
displaytype = get_displaytype();
if(flatpanel)
fb_info.nativex = get_nativex();
fb_info.gen.info.changevar = NULL;
fb_info.gen.info.node = NODEV;
fb_info.gen.info.fbops = &tridentfb_ops;
fb_info.gen.info.disp = &disp;
fb_info.gen.info.switch_con = &fbgen_switch;
fb_info.gen.info.updatevar = &fbgen_update_var;
fb_info.gen.info.flags = FBINFO_FLAG_DEFAULT;
fb_info.gen.info.fontname[0] = '\0';
fb_info.gen.info.pseudo_palette = pseudo_pal;
/* This should give a reasonable default video mode */
fb_find_mode(&default_var,&fb_info.gen.info,mode,NULL,0,NULL,bpp);
/*
* Unless user explicitly requires accel/noaccel use
* per chip defaults.Accel has priority over noaccel.
*/
if (accel)
defaultaccel = ACCEL;
else if (noaccel)
defaultaccel = NOACCEL;
if (defaultaccel == ACCEL)
default_var.accel_flags |= FB_ACCELF_TEXT;
else
default_var.accel_flags &= ~FB_ACCELF_TEXT;
trident_decode_var(&default_var, &fb_info.currentmode, &fb_info.gen);
fbgen_get_var(&disp.var, -1, &fb_info.gen.info);
default_var.activate |= FB_ACTIVATE_NOW;
fbgen_set_disp(-1, &fb_info.gen);
if (register_framebuffer(&fb_info.gen.info) < 0) {
printk("Could not register Trident framebuffer\n");
return -EINVAL;
}
output("fb%d: %s frame buffer device %dx%d-%dbpp\n",
GET_FB_IDX(fb_info.gen.info.node), fb_info.gen.info.modename,default_var.xres,
default_var.yres,default_var.bits_per_pixel);
return 0;
}
void __exit tridentfb_exit(void)
{
unregister_framebuffer(&fb_info.gen.info);
iounmap((void *)fb_info.io_virt);
iounmap((void *)fb_info.fbmem_virt);
}
/*
* Parse user specified options (`video=trident:')
* example:
* video=trident:800x600,bpp=16,noaccel
*/
int tridentfb_setup(char *options)
{
char * opt;
if (!options || !*options)
return 0;
while((opt=strsep(&options,",")) != NULL) {
if (!*opt) continue;
if (!strncmp(opt,"noaccel",7))
noaccel = 1;
else if (!strncmp(opt,"accel",5))
accel = 1;
else if (!strncmp(opt,"fp",2))
displaytype = DISPLAY_FP;
else if (!strncmp(opt,"crt",3))
displaytype = DISPLAY_CRT;
else if (!strncmp(opt,"bpp=",4))
bpp = simple_strtoul(opt+4,NULL,0);
else if (!strncmp(opt,"center",6))
center = 1;
else if (!strncmp(opt,"stretch",7))
stretch = 1;
else if (!strncmp(opt,"memsize=",8))
memsize = simple_strtoul(opt+8,NULL,0);
else if (!strncmp(opt,"memdiff=",8))
memdiff = simple_strtoul(opt+8,NULL,0);
else if (!strncmp(opt,"nativex=",8))
nativex = simple_strtoul(opt+8,NULL,0);
else
mode = opt;
}
return 0;
}
static struct fb_ops tridentfb_ops = {
fb_get_fix: fbgen_get_fix,
fb_get_var: fbgen_get_var,
fb_set_var: fbgen_set_var,
fb_get_cmap: fbgen_get_cmap,
fb_set_cmap: fbgen_set_cmap,
fb_setcolreg: tridentfb_setcolreg,
fb_pan_display: fbgen_pan_display,
};
#ifdef MODULE
module_init(tridentfb_init);
#endif
module_exit(tridentfb_exit);
MODULE_AUTHOR("Jani Monoses <jani@astechnix.ro>");
MODULE_DESCRIPTION("Framebuffer driver for Trident cards");
MODULE_LICENSE("GPL");
#ifndef TRIDENTFB_DEBUG
#define TRIDENTFB_DEBUG 0
#endif
#if TRIDENTFB_DEBUG
#define debug(f,a...) printk("%s:" f, __FUNCTION__ , ## a)
#else
#define debug(f,a...)
#endif
#define output(f, a...) printk("tridentfb: " f, ## a)
#define Kb (1024)
#define Mb (Kb*Kb)
/* PCI IDS of supported cards temporarily here */
#define CYBER9320 0x9320
#define CYBER9388 0x9388
#define CYBER9397 0x9397
#define CYBER9397DVD 0x939A
#define CYBER9520 0x9520
#define CYBER9525DVD 0x9525
#define IMAGE975 0x9750
#define IMAGE985 0x9850
#define BLADE3D 0x9880
#define CYBERBLADEE4 0x9540
#define CYBERBLADEi7 0x8400
#define CYBERBLADEi7D 0x8420
#define CYBERBLADEi1 0x8500
#define CYBERBLADEi1D 0x8520
#define CYBERBLADEAi1 0x8600
#define CYBERBLADEAi1D 0x8620
#define CYBERBLADEXPAi1 0x8820
#define CYBERBLADEXPm8 0x9910
#define CYBERBLADEXPm16 0x9930
/* acceleration families */
#define IMAGE 0
#define BLADE 1
#define XP 2
#define is_image() (family == IMAGE)
#define is_blade() (family == BLADE)
#define is_xp() (family == XP)
/* these defines are for 'lcd' variable */
#define LCD_STRETCH 0
#define LCD_CENTER 1
#define LCD_BIOS 2
/* display types */
#define DISPLAY_CRT 0
#define DISPLAY_FP 1
#define flatpanel (displaytype == DISPLAY_FP)
/* these are for defaultaccel variable */
#define ACCEL 1
#define NOACCEL 0
#define TRIDENT_IOSIZE 0x20000
#define NTSC 14.31818
#define PAL 17.73448
/* General Registers */
#define SPR 0x1F /* Software Programming Register (videoram) */
/* 3C4 */
#define RevisionID 0x09
#define OldOrNew 0x0B
#define ConfPort1 0x0C
#define ConfPort2 0x0C
#define NewMode2 0x0D
#define NewMode1 0x0E
#define Protection 0x11
#define MCLKLow 0x16
#define MCLKHigh 0x17
#define ClockLow 0x18
#define ClockHigh 0x19
#define SSetup 0x20
#define SKey 0x37
#define SPKey 0x57
/* 0x3x4 */
#define CRTHTotal 0x00
#define CRTHDispEnd 0x01
#define CRTHBlankStart 0x02
#define CRTHBlankEnd 0x03
#define CRTHSyncStart 0x04
#define CRTHSyncEnd 0x05
#define CRTVTotal 0x06
#define CRTVDispEnd 0x12
#define CRTVBlankStart 0x15
#define CRTVBlankEnd 0x16
#define CRTVSyncStart 0x10
#define CRTVSyncEnd 0x11
#define CRTOverflow 0x07
#define CRTPRowScan 0x08
#define CRTMaxScanLine 0x09
#define CRTModeControl 0x17
#define CRTLineCompare 0x18
/* 3x4 */
#define StartAddrHigh 0x0C
#define StartAddrLow 0x0D
#define Offset 0x13
#define Underline 0x14
#define CRTCMode 0x17
#define CRTCModuleTest 0x1E
#define FIFOControl 0x20
#define LinearAddReg 0x21
#define DRAMTiming 0x23
#define New32 0x23
#define RAMDACTiming 0x25
#define CRTHiOrd 0x27
#define AddColReg 0x29
#define InterfaceSel 0x2A
#define HorizOverflow 0x2B
#define GETest 0x2D
#define Performance 0x2F
#define GraphEngReg 0x36
#define I2C 0x37
#define PixelBusReg 0x38
#define PCIReg 0x39
#define DRAMControl 0x3A
#define MiscContReg 0x3C
#define CursorXLow 0x40
#define CursorXHigh 0x41
#define CursorYLow 0x42
#define CursorYHigh 0x43
#define CursorLocLow 0x44
#define CursorLocHigh 0x45
#define CursorXOffset 0x46
#define CursorYOffset 0x47
#define CursorFG1 0x48
#define CursorFG2 0x49
#define CursorFG3 0x4A
#define CursorFG4 0x4B
#define CursorBG1 0x4C
#define CursorBG2 0x4D
#define CursorBG3 0x4E
#define CursorBG4 0x4F
#define CursorControl 0x50
#define PCIRetry 0x55
#define PreEndControl 0x56
#define PreEndFetch 0x57
#define PCIMaster 0x60
#define Enhancement0 0x62
#define NewEDO 0x64
#define TVinterface 0xC0
#define TVMode 0xC1
#define ClockControl 0xCF
/* 3CE */
#define MiscExtFunc 0x0F
#define PowerStatus 0x23
#define MiscIntContReg 0x2F
#define CyberControl 0x30
#define CyberEnhance 0x31
#define FPConfig 0x33
#define VertStretch 0x52
#define HorStretch 0x53
#define BiosMode 0x5c
#define BiosReg 0x5d
......@@ -26,71 +26,28 @@
#include <asm/mtrr.h>
#include <video/fbcon.h>
#include <video/fbcon-cfb8.h>
#include <video/fbcon-cfb16.h>
#include <video/fbcon-cfb24.h>
#include <video/fbcon-cfb32.h>
#include <video/fbcon-mac.h>
#define dac_reg (0x3c8)
#define dac_val (0x3c9)
/* --------------------------------------------------------------------- */
/*
* card parameters
*/
/* card */
unsigned long video_base; /* physical addr */
int video_size;
char *video_vbase; /* mapped */
/* mode */
static int video_bpp;
static int video_width;
static int video_height;
static int video_height_virtual;
static int video_type = FB_TYPE_PACKED_PIXELS;
static int video_visual;
static int video_linelength;
static int video_cmap_len;
/* --------------------------------------------------------------------- */
static struct fb_var_screeninfo vesafb_defined = {
0,0,0,0, /* W,H, W, H (virtual) load xres,xres_virtual*/
0,0, /* virtual -> visible no offset */
8, /* depth -> load bits_per_pixel */
0, /* greyscale ? */
{0,0,0}, /* R */
{0,0,0}, /* G */
{0,0,0}, /* B */
{0,0,0}, /* transparency */
0, /* standard pixel format */
FB_ACTIVATE_NOW,
-1,-1,
0,
0L,0L,0L,0L,0L,
0L,0L,0, /* No sync info */
FB_VMODE_NONINTERLACED,
{0,0,0,0,0,0}
activate: FB_ACTIVATE_NOW,
height: -1,
width: -1,
vmode: FB_VMODE_NONINTERLACED,
};
static struct fb_fix_screeninfo vesafb_fix = {
id: "VESA VGA",
type: FB_TYPE_PACKED_PIXELS,
accel: FB_ACCEL_NONE,
};
static struct display disp;
static struct fb_info fb_info;
static struct { u_short blue, green, red, pad; } palette[256];
static union {
#ifdef FBCON_HAS_CFB16
u16 cfb16[16];
#endif
#ifdef FBCON_HAS_CFB24
u32 cfb24[16];
#endif
#ifdef FBCON_HAS_CFB32
u32 cfb32[16];
#endif
} fbcon_cmap;
static u32 pseudo_palette[17];
static int inverse = 0;
static int mtrr = 0;
......@@ -101,8 +58,6 @@ static unsigned short *pmi_base = 0;
static void (*pmi_start)(void);
static void (*pmi_pal)(void);
static struct display_switch vesafb_sw;
/* --------------------------------------------------------------------- */
static int vesafb_pan_display(struct fb_var_screeninfo *var, int con,
......@@ -119,7 +74,7 @@ static int vesafb_pan_display(struct fb_var_screeninfo *var, int con,
if ((ypan==1) && var->yoffset+var->yres > var->yres_virtual)
return -EINVAL;
offset = (var->yoffset * video_linelength + var->xoffset) / 4;
offset = (var->yoffset * info->fix.line_length + var->xoffset) / 4;
__asm__ __volatile__(
"call *(%%edi)"
......@@ -132,172 +87,6 @@ static int vesafb_pan_display(struct fb_var_screeninfo *var, int con,
return 0;
}
static int vesafb_update_var(int con, struct fb_info *info)
{
if (con == info->currcon && ypan) {
struct fb_var_screeninfo *var = &fb_display[info->currcon].var;
return vesafb_pan_display(var,con,info);
}
return 0;
}
static int vesafb_get_fix(struct fb_fix_screeninfo *fix, int con,
struct fb_info *info)
{
memset(fix, 0, sizeof(struct fb_fix_screeninfo));
strcpy(fix->id,"VESA VGA");
fix->smem_start=video_base;
fix->smem_len=video_size;
fix->type = video_type;
fix->visual = video_visual;
fix->xpanstep = 0;
fix->ypanstep = ypan ? 1 : 0;
fix->ywrapstep = (ypan>1) ? 1 : 0;
fix->line_length=video_linelength;
return 0;
}
static int vesafb_get_var(struct fb_var_screeninfo *var, int con,
struct fb_info *info)
{
if(con==-1)
memcpy(var, &vesafb_defined, sizeof(struct fb_var_screeninfo));
else
*var=fb_display[con].var;
return 0;
}
static void vesafb_set_disp(int con)
{
struct fb_fix_screeninfo fix;
struct display *display;
struct display_switch *sw;
if (con >= 0)
display = &fb_display[con];
else
display = &disp; /* used during initialization */
vesafb_get_fix(&fix, con, 0);
memset(display, 0, sizeof(struct display));
display->visual = fix.visual;
display->type = fix.type;
display->type_aux = fix.type_aux;
display->ypanstep = fix.ypanstep;
display->ywrapstep = fix.ywrapstep;
display->line_length = fix.line_length;
display->next_line = fix.line_length;
display->can_soft_blank = 0;
display->inverse = inverse;
vesafb_get_var(&display->var, -1, &fb_info);
switch (video_bpp) {
#ifdef FBCON_HAS_CFB8
case 8:
sw = &fbcon_cfb8;
break;
#endif
#ifdef FBCON_HAS_CFB16
case 15:
case 16:
sw = &fbcon_cfb16;
display->dispsw_data = fbcon_cmap.cfb16;
break;
#endif
#ifdef FBCON_HAS_CFB24
case 24:
sw = &fbcon_cfb24;
display->dispsw_data = fbcon_cmap.cfb24;
break;
#endif
#ifdef FBCON_HAS_CFB32
case 32:
sw = &fbcon_cfb32;
display->dispsw_data = fbcon_cmap.cfb32;
break;
#endif
default:
#ifdef FBCON_HAS_MAC
sw = &fbcon_mac;
break;
#else
sw = &fbcon_dummy;
return;
#endif
}
memcpy(&vesafb_sw, sw, sizeof(*sw));
display->dispsw = &vesafb_sw;
if (!ypan) {
display->scrollmode = SCROLL_YREDRAW;
vesafb_sw.bmove = fbcon_redraw_bmove;
}
}
static int vesafb_set_var(struct fb_var_screeninfo *var, int con,
struct fb_info *info)
{
static int first = 1;
if (var->xres != vesafb_defined.xres ||
var->yres != vesafb_defined.yres ||
var->xres_virtual != vesafb_defined.xres_virtual ||
var->yres_virtual > video_height_virtual ||
var->yres_virtual < video_height ||
var->xoffset ||
var->bits_per_pixel != vesafb_defined.bits_per_pixel ||
var->nonstd) {
if (first) {
printk(KERN_ERR "Vesafb does not support changing the video mode\n");
first = 0;
}
return -EINVAL;
}
if ((var->activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_TEST)
return 0;
if (ypan) {
if (vesafb_defined.yres_virtual != var->yres_virtual) {
vesafb_defined.yres_virtual = var->yres_virtual;
if (con != -1) {
fb_display[con].var = vesafb_defined;
info->changevar(con);
}
}
if (var->yoffset != vesafb_defined.yoffset)
return vesafb_pan_display(var,con,info);
return 0;
}
if (var->yoffset)
return -EINVAL;
return 0;
}
static int vesa_getcolreg(unsigned regno, unsigned *red, unsigned *green,
unsigned *blue, unsigned *transp,
struct fb_info *fb_info)
{
/*
* Read a single color register and split it into colors/transparent.
* Return != 0 for invalid regno.
*/
if (regno >= video_cmap_len)
return 1;
*red = palette[regno].red;
*green = palette[regno].green;
*blue = palette[regno].blue;
*transp = 0;
return 0;
}
#ifdef FBCON_HAS_CFB8
static void vesa_setpalette(int regno, unsigned red, unsigned green, unsigned blue)
{
struct { u_char blue, green, red, pad; } entry;
......@@ -325,11 +114,9 @@ static void vesa_setpalette(int regno, unsigned red, unsigned green, unsigned bl
}
}
#endif
static int vesafb_setcolreg(unsigned regno, unsigned red, unsigned green,
unsigned blue, unsigned transp,
struct fb_info *fb_info)
struct fb_info *info)
{
/*
* Set a single color register. The values supplied are
......@@ -338,85 +125,62 @@ static int vesafb_setcolreg(unsigned regno, unsigned red, unsigned green,
* != 0 for invalid regno.
*/
if (regno >= video_cmap_len)
if (regno >= info->cmap.len)
return 1;
palette[regno].red = red;
palette[regno].green = green;
palette[regno].blue = blue;
switch (video_bpp) {
#ifdef FBCON_HAS_CFB8
switch (info->var.bits_per_pixel) {
case 8:
vesa_setpalette(regno,red,green,blue);
break;
#endif
#ifdef FBCON_HAS_CFB16
case 15:
case 16:
if (vesafb_defined.red.offset == 10) {
if (info->var.red.offset == 10) {
/* 1:5:5:5 */
fbcon_cmap.cfb16[regno] =
((u32*) (info->pseudo_palette))[regno] =
((red & 0xf800) >> 1) |
((green & 0xf800) >> 6) |
((blue & 0xf800) >> 11);
} else {
/* 0:5:6:5 */
fbcon_cmap.cfb16[regno] =
((u32*) (info->pseudo_palette))[regno] =
((red & 0xf800) ) |
((green & 0xfc00) >> 5) |
((blue & 0xf800) >> 11);
}
break;
#endif
#ifdef FBCON_HAS_CFB24
case 24:
red >>= 8;
green >>= 8;
blue >>= 8;
fbcon_cmap.cfb24[regno] =
(red << vesafb_defined.red.offset) |
(green << vesafb_defined.green.offset) |
(blue << vesafb_defined.blue.offset);
((u32 *)(info->pseudo_palette))[regno] =
(red << info->var.red.offset) |
(green << info->var.green.offset) |
(blue << info->var.blue.offset);
break;
#endif
#ifdef FBCON_HAS_CFB32
case 32:
red >>= 8;
green >>= 8;
blue >>= 8;
fbcon_cmap.cfb32[regno] =
(red << vesafb_defined.red.offset) |
(green << vesafb_defined.green.offset) |
(blue << vesafb_defined.blue.offset);
((u32 *)(info->pseudo_palette))[regno] =
(red << info->var.red.offset) |
(green << info->var.green.offset) |
(blue << info->var.blue.offset);
break;
#endif
}
return 0;
}
static int vesafb_get_cmap(struct fb_cmap *cmap, int kspc, int con,
struct fb_info *info)
{
if (con == info->currcon) /* current console? */
return fb_get_cmap(cmap, kspc, vesa_getcolreg, info);
else if (fb_display[con].cmap.len) /* non default colormap? */
fb_copy_cmap(&fb_display[con].cmap, cmap, kspc ? 0 : 2);
else
fb_copy_cmap(fb_default_cmap(video_cmap_len),
cmap, kspc ? 0 : 2);
return 0;
}
static struct fb_ops vesafb_ops = {
owner: THIS_MODULE,
fb_get_fix: vesafb_get_fix,
fb_get_var: vesafb_get_var,
fb_set_var: vesafb_set_var,
fb_get_cmap: vesafb_get_cmap,
fb_get_fix: gen_get_fix,
fb_get_var: gen_get_var,
fb_set_var: gen_set_var,
fb_get_cmap: gen_get_cmap,
fb_set_cmap: gen_set_cmap,
fb_setcolreg: vesafb_setcolreg,
fb_pan_display: vesafb_pan_display,
fb_fillrect: cfb_fillrect,
fb_copyarea: cfb_copyarea,
fb_imageblit: cfb_imageblit,
};
int __init vesafb_setup(char *options)
......@@ -451,59 +215,46 @@ int __init vesafb_setup(char *options)
return 0;
}
static int vesafb_switch(int con, struct fb_info *info)
{
/* Do we have to save the colormap? */
if (fb_display[info->currcon].cmap.len)
fb_get_cmap(&fb_display[info->currcon].cmap, 1, vesa_getcolreg,
info);
info->currcon = con;
/* Install new colormap */
do_install_cmap(con, info);
vesafb_update_var(con,info);
return 1;
}
int __init vesafb_init(void)
{
int i,j;
int video_cmap_len;
int i;
if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
return -ENXIO;
video_base = screen_info.lfb_base;
video_bpp = screen_info.lfb_depth;
if (15 == video_bpp)
video_bpp = 16;
video_width = screen_info.lfb_width;
video_height = screen_info.lfb_height;
video_linelength = screen_info.lfb_linelength;
video_size = screen_info.lfb_size * 65536;
video_visual = (video_bpp == 8) ?
vesafb_fix.smem_start = screen_info.lfb_base;
vesafb_defined.bits_per_pixel = screen_info.lfb_depth;
if (15 == vesafb_defined.bits_per_pixel)
vesafb_defined.bits_per_pixel = 16;
vesafb_defined.xres = screen_info.lfb_width;
vesafb_defined.yres = screen_info.lfb_height;
vesafb_fix.line_length = screen_info.lfb_linelength;
vesafb_fix.smem_len = screen_info.lfb_size * 65536;
vesafb_fix.visual = (vesafb_defined.bits_per_pixel == 8) ?
FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR;
if (!request_mem_region(video_base, video_size, "vesafb")) {
if (!request_mem_region(vesafb_fix.smem_start, vesafb_fix.smem_len, "vesafb")) {
printk(KERN_WARNING
"vesafb: abort, cannot reserve video memory at 0x%lx\n",
video_base);
vesafb_fix.smem_start);
/* We cannot make this fatal. Sometimes this comes from magic
spaces our resource handlers simply don't know about */
}
video_vbase = ioremap(video_base, video_size);
if (!video_vbase) {
release_mem_region(video_base, video_size);
fb_info.screen_base = ioremap(vesafb_fix.smem_start, vesafb_fix.smem_len);
if (!fb_info.screen_base) {
release_mem_region(vesafb_fix.smem_start, vesafb_fix.smem_len);
printk(KERN_ERR
"vesafb: abort, cannot ioremap video memory 0x%x @ 0x%lx\n",
video_size, video_base);
vesafb_fix.smem_len, vesafb_fix.smem_start);
return -EIO;
}
printk(KERN_INFO "vesafb: framebuffer at 0x%lx, mapped to 0x%p, size %dk\n",
video_base, video_vbase, video_size/1024);
vesafb_fix.smem_start, fb_info.screen_base, vesafb_fix.smem_len/1024);
printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
video_width, video_height, video_bpp, video_linelength, screen_info.pages);
vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
if (screen_info.vesapm_seg) {
printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
......@@ -536,32 +287,27 @@ int __init vesafb_init(void)
}
}
vesafb_defined.xres=video_width;
vesafb_defined.yres=video_height;
vesafb_defined.xres_virtual=video_width;
vesafb_defined.yres_virtual=video_size / video_linelength;
vesafb_defined.bits_per_pixel=video_bpp;
if (ypan && vesafb_defined.yres_virtual > video_height) {
vesafb_defined.xres_virtual = vesafb_defined.xres;
vesafb_defined.yres_virtual = vesafb_fix.smem_len / vesafb_fix.line_length;
if (ypan && vesafb_defined.yres_virtual > vesafb_defined.yres) {
printk(KERN_INFO "vesafb: scrolling: %s using protected mode interface, yres_virtual=%d\n",
(ypan > 1) ? "ywrap" : "ypan",vesafb_defined.yres_virtual);
} else {
printk(KERN_INFO "vesafb: scrolling: redraw\n");
vesafb_defined.yres_virtual = video_height;
vesafb_defined.yres_virtual = vesafb_defined.yres;
ypan = 0;
}
video_height_virtual = vesafb_defined.yres_virtual;
/* some dummy values for timing to make fbset happy */
vesafb_defined.pixclock = 10000000 / video_width * 1000 / video_height;
vesafb_defined.left_margin = (video_width / 8) & 0xf8;
vesafb_defined.pixclock = 10000000 / vesafb_defined.xres * 1000 / vesafb_defined.yres;
vesafb_defined.left_margin = (vesafb_defined.xres / 8) & 0xf8;
vesafb_defined.right_margin = 32;
vesafb_defined.upper_margin = 16;
vesafb_defined.lower_margin = 4;
vesafb_defined.hsync_len = (video_width / 8) & 0xf8;
vesafb_defined.hsync_len = (vesafb_defined.xres / 8) & 0xf8;
vesafb_defined.vsync_len = 4;
if (video_bpp > 8) {
if (vesafb_defined.bits_per_pixel > 8) {
vesafb_defined.red.offset = screen_info.red_pos;
vesafb_defined.red.length = screen_info.red_size;
vesafb_defined.green.offset = screen_info.green_pos;
......@@ -585,48 +331,49 @@ int __init vesafb_init(void)
vesafb_defined.red.length = 6;
vesafb_defined.green.length = 6;
vesafb_defined.blue.length = 6;
for(i = 0; i < 16; i++) {
j = color_table[i];
palette[i].red = default_red[j];
palette[i].green = default_grn[j];
palette[i].blue = default_blu[j];
}
video_cmap_len = 256;
}
vesafb_fix.ypanstep = ypan ? 1 : 0;
vesafb_fix.ywrapstep = (ypan>1) ? 1 : 0;
/* request failure does not faze us, as vgacon probably has this
* region already (FIXME) */
request_region(0x3c0, 32, "vesafb");
if (mtrr) {
int temp_size = video_size;
int temp_size = vesafb_fix.smem_len;
/* Find the largest power-of-two */
while (temp_size & (temp_size - 1))
temp_size &= (temp_size - 1);
/* Try and find a power of two to add */
while (temp_size && mtrr_add(video_base, temp_size, MTRR_TYPE_WRCOMB, 1)==-EINVAL) {
while (temp_size && mtrr_add(vesafb_fix.smem_start, temp_size, MTRR_TYPE_WRCOMB, 1)==-EINVAL) {
temp_size >>= 1;
}
}
strcpy(fb_info.modename, "VESA VGA");
strcpy(fb_info.modename, vesafb_fix.id);
fb_info.changevar = NULL;
fb_info.node = NODEV;
fb_info.fbops = &vesafb_ops;
fb_info.screen_base = video_vbase;
fb_info.disp=&disp;
fb_info.var = vesafb_defined;
fb_info.fix = vesafb_fix;
fb_info.currcon = -1;
fb_info.switch_con=&vesafb_switch;
fb_info.updatevar=&vesafb_update_var;
fb_info.flags=FBINFO_FLAG_DEFAULT;
vesafb_set_disp(-1);
fb_info.disp = &disp;
fb_info.switch_con = gen_switch;
fb_info.updatevar = gen_update_var;
fb_info.pseudo_palette = pseudo_palette;
fb_info.flags = FBINFO_FLAG_DEFAULT;
fb_alloc_cmap(&fb_info.cmap, video_cmap_len, 0);
gen_set_disp(-1, &fb_info);
if (register_framebuffer(&fb_info)<0)
return -EINVAL;
printk(KERN_INFO "fb%d: %s frame buffer device\n",
GET_FB_IDX(fb_info.node), fb_info.modename);
GET_FB_IDX(fb_info.node), fb_info.fix.id);
return 0;
}
......
/*
* linux/drivers/video/vfb.c -- Virtual frame buffer device
*
* Copyright (C) 2002 James Simmons
*
* Copyright (C) 1997 Geert Uytterhoeven
*
* This file is subject to the terms and conditions of the GNU General Public
......@@ -22,15 +24,7 @@
#include <linux/fb.h>
#include <linux/init.h>
#include <video/fbcon.h>
#include <video/fbcon-mfb.h>
#include <video/fbcon-cfb2.h>
#include <video/fbcon-cfb4.h>
#include <video/fbcon-cfb8.h>
#include <video/fbcon-cfb16.h>
#include <video/fbcon-cfb24.h>
#include <video/fbcon-cfb32.h>
#include <linux/fbcon.h>
/*
* RAM we reserve for the frame buffer. This defines the maximum screen
......@@ -41,135 +35,109 @@
#define VIDEOMEMSIZE (1*1024*1024) /* 1 MB */
static u_long videomemory, videomemorysize = VIDEOMEMSIZE;
static void *videomemory;
static u_long videomemorysize = VIDEOMEMSIZE;
MODULE_PARM(videomemorysize, "l");
static struct display disp;
static const char *mode_option __initdata = NULL;
static struct fb_info fb_info;
static struct { u_char red, green, blue, pad; } palette[256];
static union {
#ifdef FBCON_HAS_CFB16
u16 cfb16[16];
#endif
#ifdef FBCON_HAS_CFB24
u32 cfb24[16];
#endif
#ifdef FBCON_HAS_CFB32
u32 cfb32[16];
#endif
} fbcon_cmap;
static char vfb_name[16] = "Virtual FB";
static struct fb_var_screeninfo vfb_default = {
/* 640x480, 8 bpp */
640, 480, 640, 480, 0, 0, 8, 0,
{0, 8, 0}, {0, 8, 0}, {0, 8, 0}, {0, 0, 0},
0, 0, -1, -1, 0, 20000, 64, 64, 32, 32, 64, 2,
0, FB_VMODE_NONINTERLACED
static u32 vfb_pseudo_palette[17];
static struct display disp;
static struct fb_var_screeninfo vfb_default __initdata = {
xres: 640,
yres: 480,
xres_virtual: 640,
yres_virtual: 480,
bits_per_pixel: 8,
red: { 0, 8, 0 },
green: { 0, 8, 0 },
blue: { 0, 8, 0 },
activate: FB_ACTIVATE_TEST,
height: -1,
width: -1,
pixclock: 20000,
left_margin: 64,
right_margin: 64,
upper_margin: 32,
lower_margin: 32,
hsync_len: 64,
vsync_len: 2,
vmode: FB_VMODE_NONINTERLACED,
};
static int vfb_enable = 0; /* disabled by default */
static struct fb_fix_screeninfo vfb_fix __initdata = {
id: "Virtual FB",
type: FB_TYPE_PACKED_PIXELS,
visual: FB_VISUAL_PSEUDOCOLOR,
xpanstep: 1,
ypanstep: 1,
ywrapstep: 1,
accel: FB_ACCEL_NONE,
};
static int vfb_enable __initdata = 0; /* disabled by default */
MODULE_PARM(vfb_enable, "i");
/*
* Interface used by the world
*/
int vfb_init(void);
int vfb_setup(char *);
int vfb_setup(char*);
static int vfb_get_fix(struct fb_fix_screeninfo *fix, int con,
struct fb_info *info);
static int vfb_get_var(struct fb_var_screeninfo *var, int con,
struct fb_info *info);
static int vfb_set_var(struct fb_var_screeninfo *var, int con,
static int vfb_check_var(struct fb_var_screeninfo *var,
struct fb_info *info);
static int vfb_set_par(struct fb_info *info);
static int vfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
u_int transp, struct fb_info *info);
static int vfb_pan_display(struct fb_var_screeninfo *var, int con,
static int vfb_pan_display(struct fb_var_screeninfo *var,
struct fb_info *info);
static int vfb_get_cmap(struct fb_cmap *cmap, int kspc, int con,
struct fb_info *info);
/*
* Interface to the low level console driver
*/
int vfb_init(void);
static int vfbcon_switch(int con, struct fb_info *info);
static int vfbcon_updatevar(int con, struct fb_info *info);
/*
* Internal routines
*/
static u_long get_line_length(int xres_virtual, int bpp);
static void vfb_encode_fix(struct fb_fix_screeninfo *fix,
struct fb_var_screeninfo *var);
static void set_color_bitfields(struct fb_var_screeninfo *var);
static int vfb_getcolreg(u_int regno, u_int *red, u_int *green, u_int *blue,
u_int *transp, struct fb_info *info);
static int vfb_mmap(struct fb_info *info, struct file *file,
struct vm_area_struct *vma);
static struct fb_ops vfb_ops = {
owner: THIS_MODULE,
fb_get_fix: vfb_get_fix,
fb_get_var: vfb_get_var,
fb_set_var: vfb_set_var,
fb_get_cmap: vfb_get_cmap,
fb_get_fix: gen_get_fix,
fb_get_var: gen_get_var,
fb_set_var: gen_set_var,
fb_get_cmap: gen_set_cmap,
fb_set_cmap: gen_set_cmap,
fb_check_var: vfb_check_var,
fb_set_par: vfb_set_par,
fb_setcolreg: vfb_setcolreg,
fb_pan_display: vfb_pan_display,
fb_fillrect: cfb_fillrect,
fb_copyarea: cfb_copyarea,
fb_imageblit: cfb_imageblit,
fb_mmap: vfb_mmap,
};
/*
* Get the Fixed Part of the Display
* Internal routines
*/
static int vfb_get_fix(struct fb_fix_screeninfo *fix, int con,
struct fb_info *info)
static u_long get_line_length(int xres_virtual, int bpp)
{
struct fb_var_screeninfo *var;
if (con == -1)
var = &vfb_default;
else
var = &fb_display[con].var;
vfb_encode_fix(fix, var);
return 0;
}
/*
* Get the User Defined Part of the Display
*/
u_long length;
static int vfb_get_var(struct fb_var_screeninfo *var, int con,
struct fb_info *info)
{
if (con == -1)
*var = vfb_default;
else
*var = fb_display[con].var;
set_color_bitfields(var);
return 0;
length = xres_virtual * bpp;
length = (length + 31) & ~31;
length >>= 3;
return (length);
}
/*
* Set the User Defined Part of the Display
* Setting the video mode has been split into two parts.
* First part, xxxfb_check_var, must not write anything
* to hardware, it should only verify and adjust var.
* This means it doesn't alter par but it does use hardware
* data from it to check this var.
*/
static int vfb_set_var(struct fb_var_screeninfo *var, int con,
static int vfb_check_var(struct fb_var_screeninfo *var,
struct fb_info *info)
{
int err, activate = var->activate;
int oldxres, oldyres, oldvxres, oldvyres, oldbpp;
u_long line_length;
struct display *display;
if (con >= 0)
display = &fb_display[con];
else
display = &disp; /* used during initialization */
/*
* FB_VMODE_CONUPDATE and FB_VMODE_SMOOTH_XPAN are equal!
* as FB_VMODE_SMOOTH_XPAN is only used internally
......@@ -177,8 +145,8 @@ static int vfb_set_var(struct fb_var_screeninfo *var, int con,
if (var->vmode & FB_VMODE_CONUPDATE) {
var->vmode |= FB_VMODE_YWRAP;
var->xoffset = display->var.xoffset;
var->yoffset = display->var.yoffset;
var->xoffset = info->var.xoffset;
var->yoffset = info->var.yoffset;
}
/*
......@@ -198,368 +166,316 @@ static int vfb_set_var(struct fb_var_screeninfo *var, int con,
var->bits_per_pixel = 8;
else if (var->bits_per_pixel <= 16)
var->bits_per_pixel = 16;
#if 0
/* fbcon doesn't support this (yet) */
else if (var->bits_per_pixel <= 24)
var->bits_per_pixel = 24;
else if (var->bits_per_pixel <= 32)
var->bits_per_pixel = 32;
#endif
else
return -EINVAL;
if (var->xres_virtual < var->xoffset + var->xres)
var->xres_virtual = var->xoffset + var->xres;
if (var->yres_virtual < var->yoffset + var->yres)
var->yres_virtual = var->yoffset + var->yres;
/*
* Memory limit
*/
line_length = get_line_length(var->xres_virtual, var->bits_per_pixel);
if (line_length*var->yres_virtual > videomemorysize)
line_length =
get_line_length(var->xres_virtual, var->bits_per_pixel);
if (line_length * var->yres_virtual > videomemorysize)
return -ENOMEM;
set_color_bitfields(var);
if ((activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW) {
oldxres = display->var.xres;
oldyres = display->var.yres;
oldvxres = display->var.xres_virtual;
oldvyres = display->var.yres_virtual;
oldbpp = display->var.bits_per_pixel;
display->var = *var;
if (oldxres != var->xres || oldyres != var->yres ||
oldvxres != var->xres_virtual || oldvyres != var->yres_virtual ||
oldbpp != var->bits_per_pixel) {
struct fb_fix_screeninfo fix;
vfb_encode_fix(&fix, var);
display->visual = fix.visual;
display->type = fix.type;
display->type_aux = fix.type_aux;
display->ypanstep = fix.ypanstep;
display->ywrapstep = fix.ywrapstep;
display->line_length = fix.line_length;
display->can_soft_blank = 1;
display->inverse = 0;
/*
* Now that we checked it we alter var. The reason being is that the video
* mode passed in might not work but slight changes to it might make it
* work. This way we let the user know what is acceptable.
*/
switch (var->bits_per_pixel) {
#ifdef FBCON_HAS_MFB
case 1:
display->dispsw = &fbcon_mfb;
case 8:
var->red.offset = 0;
var->red.length = 8;
var->green.offset = 0;
var->green.length = 8;
var->blue.offset = 0;
var->blue.length = 8;
var->transp.offset = 0;
var->transp.length = 0;
break;
#endif
#ifdef FBCON_HAS_CFB2
case 2:
display->dispsw = &fbcon_cfb2;
case 16: /* RGBA 5551 */
if (var->transp.length) {
var->red.offset = 0;
var->red.length = 5;
var->green.offset = 5;
var->green.length = 5;
var->blue.offset = 10;
var->blue.length = 5;
var->transp.offset = 15;
var->transp.length = 1;
} else { /* RGB 565 */
var->red.offset = 0;
var->red.length = 5;
var->green.offset = 5;
var->green.length = 6;
var->blue.offset = 11;
var->blue.length = 5;
var->transp.offset = 0;
var->transp.length = 0;
}
break;
#endif
#ifdef FBCON_HAS_CFB4
case 4:
display->dispsw = &fbcon_cfb4;
case 24: /* RGB 888 */
var->red.offset = 0;
var->red.length = 8;
var->green.offset = 8;
var->green.length = 8;
var->blue.offset = 16;
var->blue.length = 8;
var->transp.offset = 0;
var->transp.length = 0;
break;
case 32: /* RGBA 8888 */
var->red.offset = 0;
var->red.length = 8;
var->green.offset = 8;
var->green.length = 8;
var->blue.offset = 16;
var->blue.length = 8;
var->transp.offset = 24;
var->transp.length = 8;
break;
}
var->red.msb_right = 0;
var->green.msb_right = 0;
var->blue.msb_right = 0;
var->transp.msb_right = 0;
return 0;
}
/* This routine actually sets the video mode. It's in here where we
* the hardware state info->par and fix which can be affected by the
* change in par. For this driver it doesn't do much.
*/
static int vfb_set_par(struct fb_info *info)
{
info->fix.line_length = get_line_length(info->var.xres_virtual,
info->var.bits_per_pixel);
return 0;
}
/*
* Set a single color register. The values supplied are already
* rounded down to the hardware's capabilities (according to the
* entries in the var structure). Return != 0 for invalid regno.
*/
static int vfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
u_int transp, struct fb_info *info)
{
if (regno >= 256) /* no. of hw registers */
return 1;
/*
* Program hardware... do anything you want with transp
*/
/* grayscale works only partially under directcolor */
if (info->var.grayscale) {
/* grayscale = 0.30*R + 0.59*G + 0.11*B */
red = green = blue =
(red * 77 + green * 151 + blue * 28) >> 8;
}
/* Directcolor:
* var->{color}.offset contains start of bitfield
* var->{color}.length contains length of bitfield
* {hardwarespecific} contains width of RAMDAC
* cmap[X] is programmed to (X << red.offset) | (X << green.offset) | (X << blue.offset)
* RAMDAC[X] is programmed to (red, green, blue)
*
* Pseudocolor:
* uses offset = 0 && length = RAMDAC register width.
* var->{color}.offset is 0
* var->{color}.length contains widht of DAC
* cmap is not used
* RAMDAC[X] is programmed to (red, green, blue)
* Truecolor:
* does not use DAC. Usually 3 are present.
* var->{color}.offset contains start of bitfield
* var->{color}.length contains length of bitfield
* cmap is programmed to (red << red.offset) | (green << green.offset) |
* (blue << blue.offset) | (transp << transp.offset)
* RAMDAC does not exist
*/
#define CNVT_TOHW(val,width) ((((val)<<(width))+0x7FFF-(val))>>16)
switch (info->fix.visual) {
case FB_VISUAL_TRUECOLOR:
case FB_VISUAL_PSEUDOCOLOR:
red = CNVT_TOHW(red, info->var.red.length);
green = CNVT_TOHW(green, info->var.green.length);
blue = CNVT_TOHW(blue, info->var.blue.length);
transp = CNVT_TOHW(transp, info->var.transp.length);
break;
case FB_VISUAL_DIRECTCOLOR:
red = CNVT_TOHW(red, 8); /* expect 8 bit DAC */
green = CNVT_TOHW(green, 8);
blue = CNVT_TOHW(blue, 8);
/* hey, there is bug in transp handling... */
transp = CNVT_TOHW(transp, 8);
break;
#endif
#ifdef FBCON_HAS_CFB8
}
#undef CNVT_TOHW
/* Truecolor has hardware independent palette */
if (info->fix.visual == FB_VISUAL_TRUECOLOR) {
u32 v;
if (regno >= 16)
return 1;
v = (red << info->var.red.offset) |
(green << info->var.green.offset) |
(blue << info->var.blue.offset) |
(transp << info->var.transp.offset);
switch (info->var.bits_per_pixel) {
case 8:
display->dispsw = &fbcon_cfb8;
break;
#endif
#ifdef FBCON_HAS_CFB16
case 16:
display->dispsw = &fbcon_cfb16;
display->dispsw_data = fbcon_cmap.cfb16;
((u32 *) (info->pseudo_palette))[regno] = v;
break;
#endif
#ifdef FBCON_HAS_CFB24
case 24:
display->dispsw = &fbcon_cfb24;
display->dispsw_data = fbcon_cmap.cfb24;
break;
#endif
#ifdef FBCON_HAS_CFB32
case 32:
display->dispsw = &fbcon_cfb32;
display->dispsw_data = fbcon_cmap.cfb32;
break;
#endif
default:
display->dispsw = &fbcon_dummy;
((u32 *) (info->pseudo_palette))[regno] = v;
break;
}
if (fb_info.changevar)
(*fb_info.changevar)(con);
}
if (oldbpp != var->bits_per_pixel) {
if ((err = fb_alloc_cmap(&display->cmap, 0, 0)))
return err;
do_install_cmap(con, info);
}
return 0;
}
return 0;
}
/*
* Pan or Wrap the Display
*
* This call looks only at xoffset, yoffset and the FB_VMODE_YWRAP flag
*/
static int vfb_pan_display(struct fb_var_screeninfo *var, int con,
static int vfb_pan_display(struct fb_var_screeninfo *var,
struct fb_info *info)
{
if (var->vmode & FB_VMODE_YWRAP) {
if (var->yoffset < 0 ||
var->yoffset >= fb_display[con].var.yres_virtual ||
var->xoffset)
if (var->yoffset < 0
|| var->yoffset >= info->var.yres_virtual
|| var->xoffset)
return -EINVAL;
} else {
if (var->xoffset+fb_display[con].var.xres >
fb_display[con].var.xres_virtual ||
var->yoffset+fb_display[con].var.yres >
fb_display[con].var.yres_virtual)
if (var->xoffset + var->xres > info->var.xres_virtual ||
var->yoffset + var->yres > info->var.yres_virtual)
return -EINVAL;
}
fb_display[con].var.xoffset = var->xoffset;
fb_display[con].var.yoffset = var->yoffset;
info->var.xoffset = var->xoffset;
info->var.yoffset = var->yoffset;
if (var->vmode & FB_VMODE_YWRAP)
fb_display[con].var.vmode |= FB_VMODE_YWRAP;
info->var.vmode |= FB_VMODE_YWRAP;
else
fb_display[con].var.vmode &= ~FB_VMODE_YWRAP;
info->var.vmode &= ~FB_VMODE_YWRAP;
return 0;
}
/*
* Get the Colormap
* Most drivers don't need their own mmap function
*/
static int vfb_get_cmap(struct fb_cmap *cmap, int kspc, int con,
struct fb_info *info)
static int vfb_mmap(struct fb_info *info, struct file *file,
struct vm_area_struct *vma)
{
if (con == info->currcon) /* current console? */
return fb_get_cmap(cmap, kspc, vfb_getcolreg, info);
else if (fb_display[con].cmap.len) /* non default colormap? */
fb_copy_cmap(&fb_display[con].cmap, cmap, kspc ? 0 : 2);
else
fb_copy_cmap(fb_default_cmap(1<<fb_display[con].var.bits_per_pixel),
cmap, kspc ? 0 : 2);
return 0;
return -EINVAL;
}
int __init vfb_setup(char *options)
{
char *this_opt;
fb_info.fontname[0] = '\0';
vfb_enable = 1;
if (!options || !*options)
return 0;
return 1;
while ((this_opt = strsep(&options, ",")) != NULL) {
if (!strncmp(this_opt, "font:", 5))
strcpy(fb_info.fontname, this_opt+5);
if (!*this_opt)
continue;
if (!strncmp(this_opt, "disable", 7))
vfb_enable = 0;
}
return 0;
return 1;
}
/*
* Initialisation
*/
int __init vfb_init(void)
{
int retval;
if (!vfb_enable)
return -ENXIO;
if (!(videomemory = (u_long)vmalloc(videomemorysize)))
/*
* For real video cards we use ioremap.
*/
if (!(videomemory = vmalloc(videomemorysize)))
return -ENOMEM;
strcpy(fb_info.modename, vfb_name);
fb_info.changevar = NULL;
fb_info.node = NODEV;
fb_info.fbops = &vfb_ops;
fb_info.screen_base = (char *)videomemory;
fb_info.disp = &disp;
fb_info.currcon = -1;
fb_info.switch_con = &vfbcon_switch;
fb_info.updatevar = &vfbcon_updatevar;
fb_info.flags = FBINFO_FLAG_DEFAULT;
vfb_set_var(&vfb_default, -1, &fb_info);
if (register_framebuffer(&fb_info) < 0) {
vfree((void *)videomemory);
return -EINVAL;
}
printk(KERN_INFO "fb%d: Virtual frame buffer device, using %ldK of video memory\n",
GET_FB_IDX(fb_info.node), videomemorysize>>10);
return 0;
}
static int vfbcon_switch(int con, struct fb_info *info)
{
/* Do we have to save the colormap? */
if (fb_display[info->currcon].cmap.len)
fb_get_cmap(&fb_display[info->currcon].cmap, 1, vfb_getcolreg, info);
info->currcon = con;
/* Install new colormap */
do_install_cmap(con, info);
return 0;
}
/*
* Update the `var' structure (called by fbcon.c)
* VFB must clear memory to prevent kernel info
* leakage into userspace
* VGA-based drivers MUST NOT clear memory if
* they want to be able to take over vgacon
*/
memset(videomemory, 0, videomemorysize);
static int vfbcon_updatevar(int con, struct fb_info *info)
{
/* Nothing */
return 0;
}
static u_long get_line_length(int xres_virtual, int bpp)
{
u_long length;
length = xres_virtual*bpp;
length = (length+31)&-32;
length >>= 3;
return(length);
}
static void vfb_encode_fix(struct fb_fix_screeninfo *fix,
struct fb_var_screeninfo *var)
{
memset(fix, 0, sizeof(struct fb_fix_screeninfo));
strcpy(fix->id, vfb_name);
fix->smem_start = videomemory;
fix->smem_len = videomemorysize;
fix->type = FB_TYPE_PACKED_PIXELS;
fix->type_aux = 0;
switch (var->bits_per_pixel) {
case 1:
fix->visual = FB_VISUAL_MONO01;
break;
case 2:
case 4:
case 8:
fix->visual = FB_VISUAL_PSEUDOCOLOR;
break;
case 16:
case 24:
case 32:
fix->visual = FB_VISUAL_TRUECOLOR;
break;
}
fix->ywrapstep = 1;
fix->xpanstep = 1;
fix->ypanstep = 1;
fix->line_length = get_line_length(var->xres_virtual, var->bits_per_pixel);
}
static void set_color_bitfields(struct fb_var_screeninfo *var)
{
switch (var->bits_per_pixel) {
case 1:
case 8:
var->red.offset = 0;
var->red.length = 8;
var->green.offset = 0;
var->green.length = 8;
var->blue.offset = 0;
var->blue.length = 8;
var->transp.offset = 0;
var->transp.length = 0;
break;
case 16: /* RGB 565 */
var->red.offset = 0;
var->red.length = 5;
var->green.offset = 5;
var->green.length = 6;
var->blue.offset = 11;
var->blue.length = 5;
var->transp.offset = 0;
var->transp.length = 0;
break;
case 24: /* RGB 888 */
var->red.offset = 0;
var->red.length = 8;
var->green.offset = 8;
var->green.length = 8;
var->blue.offset = 16;
var->blue.length = 8;
var->transp.offset = 0;
var->transp.length = 0;
break;
case 32: /* RGBA 8888 */
var->red.offset = 0;
var->red.length = 8;
var->green.offset = 8;
var->green.length = 8;
var->blue.offset = 16;
var->blue.length = 8;
var->transp.offset = 24;
var->transp.length = 8;
break;
}
var->red.msb_right = 0;
var->green.msb_right = 0;
var->blue.msb_right = 0;
var->transp.msb_right = 0;
}
fb_info.screen_base = videomemory;
fb_info.node = NODEV;
fb_info.fbops = &vfb_ops;
retval = fb_find_mode(&fb_info.var, &fb_info, mode_option,
NULL, 0, NULL, 8);
/*
* Read a single color register and split it into
* colors/transparent. Return != 0 for invalid regno.
*/
if (!retval || (retval == 4))
fb_info.var = vfb_default;
fb_info.fix = vfb_fix;
fb_info.pseudo_palette = &vfb_pseudo_palette;
fb_info.flags = FBINFO_FLAG_DEFAULT;
static int vfb_getcolreg(u_int regno, u_int *red, u_int *green, u_int *blue,
u_int *transp, struct fb_info *info)
{
if (regno > 255)
return 1;
*red = (palette[regno].red<<8) | palette[regno].red;
*green = (palette[regno].green<<8) | palette[regno].green;
*blue = (palette[regno].blue<<8) | palette[regno].blue;
*transp = 0;
return 0;
}
strcpy(fb_info.modename, vesafb_fix.id);
fb_info.changevar = NULL;
fb_info.currcon = -1;
fb_info.disp = &disp;
fb_info.switch_con = gen_switch;
fb_info.updatevar = gen_update_var;
fb_alloc_cmap(&fb_info.cmap, 256, 0);
/*
* Set a single color register. The values supplied are already
* rounded down to the hardware's capabilities (according to the
* entries in the var structure). Return != 0 for invalid regno.
*/
if (register_framebuffer(&fb_info) < 0) {
vfree(videomemory);
return -EINVAL;
}
static int vfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
u_int transp, struct fb_info *info)
{
if (regno > 255)
return 1;
red >>= 8;
green >>= 8;
blue >>= 8;
palette[regno].red = red;
palette[regno].green = green;
palette[regno].blue = blue;
printk(KERN_INFO
"fb%d: Virtual frame buffer device, using %ldK of video memory\n",
GET_FB_IDX(fb_info.node), videomemorysize >> 10);
return 0;
}
#ifdef MODULE
MODULE_LICENSE("GPL");
int init_module(void)
{
return vfb_init();
}
void cleanup_module(void)
static void __exit vfb_cleanup(void)
{
unregister_framebuffer(&fb_info);
vfree((void *)videomemory);
vfree(videomemory);
}
module_init(vfb_init);
module_exit(vfb_cleanup);
MODULE_LICENSE("GPL");
#endif /* MODULE */
......@@ -93,7 +93,8 @@
#define FB_ACCEL_IGS_CYBER2010 34 /* CyberPro 2010 */
#define FB_ACCEL_IGS_CYBER5000 35 /* CyberPro 5000 */
#define FB_ACCEL_SIS_GLAMOUR 36 /* SiS 300/630/540 */
#define FB_ACCEL_3DLABS_PERMEDIA3 37 /* 3Dlabs Permedia 3 */
#define FB_ACCEL_ATI_RADEON 38 /* ATI Radeon family */
#define FB_ACCEL_NEOMAGIC_NM2070 90 /* NeoMagic NM2070 */
#define FB_ACCEL_NEOMAGIC_NM2090 91 /* NeoMagic NM2090 */
......@@ -169,6 +170,9 @@ struct fb_bitfield {
#define FB_VMODE_SMOOTH_XPAN 512 /* smooth xpan possible (internally used) */
#define FB_VMODE_CONUPDATE 512 /* don't update x/yoffset */
#define PICOS2KHZ(a) (1000000000UL/(a))
#define KHZ2PICOS(a) (1000000000UL/(a))
struct fb_var_screeninfo {
__u32 xres; /* visible resolution */
__u32 yres;
......
#ifndef _TDFX_H
#define _TDFX_H
/* membase0 register offsets */
#define STATUS 0x00
#define PCIINIT0 0x04
#define SIPMONITOR 0x08
#define LFBMEMORYCONFIG 0x0c
#define MISCINIT0 0x10
#define MISCINIT1 0x14
#define DRAMINIT0 0x18
#define DRAMINIT1 0x1c
#define AGPINIT 0x20
#define TMUGBEINIT 0x24
#define VGAINIT0 0x28
#define VGAINIT1 0x2c
#define DRAMCOMMAND 0x30
#define DRAMDATA 0x34
/* reserved 0x38 */
/* reserved 0x3c */
#define PLLCTRL0 0x40
#define PLLCTRL1 0x44
#define PLLCTRL2 0x48
#define DACMODE 0x4c
#define DACADDR 0x50
#define DACDATA 0x54
#define RGBMAXDELTA 0x58
#define VIDPROCCFG 0x5c
#define HWCURPATADDR 0x60
#define HWCURLOC 0x64
#define HWCURC0 0x68
#define HWCURC1 0x6c
#define VIDINFORMAT 0x70
#define VIDINSTATUS 0x74
#define VIDSERPARPORT 0x78
#define VIDINXDELTA 0x7c
#define VIDININITERR 0x80
#define VIDINYDELTA 0x84
#define VIDPIXBUFTHOLD 0x88
#define VIDCHRMIN 0x8c
#define VIDCHRMAX 0x90
#define VIDCURLIN 0x94
#define VIDSCREENSIZE 0x98
#define VIDOVRSTARTCRD 0x9c
#define VIDOVRENDCRD 0xa0
#define VIDOVRDUDX 0xa4
#define VIDOVRDUDXOFF 0xa8
#define VIDOVRDVDY 0xac
/* ... */
#define VIDOVRDVDYOFF 0xe0
#define VIDDESKSTART 0xe4
#define VIDDESKSTRIDE 0xe8
#define VIDINADDR0 0xec
#define VIDINADDR1 0xf0
#define VIDINADDR2 0xf4
#define VIDINSTRIDE 0xf8
#define VIDCUROVRSTART 0xfc
#define INTCTRL (0x00100000 + 0x04)
#define CLIP0MIN (0x00100000 + 0x08)
#define CLIP0MAX (0x00100000 + 0x0c)
#define DSTBASE (0x00100000 + 0x10)
#define DSTFORMAT (0x00100000 + 0x14)
#define SRCBASE (0x00100000 + 0x34)
#define COMMANDEXTRA_2D (0x00100000 + 0x38)
#define CLIP1MIN (0x00100000 + 0x4c)
#define CLIP1MAX (0x00100000 + 0x50)
#define SRCFORMAT (0x00100000 + 0x54)
#define SRCSIZE (0x00100000 + 0x58)
#define SRCXY (0x00100000 + 0x5c)
#define COLORBACK (0x00100000 + 0x60)
#define COLORFORE (0x00100000 + 0x64)
#define DSTSIZE (0x00100000 + 0x68)
#define DSTXY (0x00100000 + 0x6c)
#define COMMAND_2D (0x00100000 + 0x70)
#define LAUNCH_2D (0x00100000 + 0x80)
#define COMMAND_3D (0x00200000 + 0x120)
/* register bitfields (not all, only as needed) */
#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 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_3D_NOP 0x00
#define STATUS_RETRACE BIT(6)
#define STATUS_BUSY BIT(9)
#define MISCINIT1_CLUT_INV BIT(0)
#define MISCINIT1_2DBLOCK_DIS BIT(15)
#define DRAMINIT0_SGRAM_NUM BIT(26)
#define DRAMINIT0_SGRAM_TYPE BIT(27)
#define DRAMINIT1_MEM_SDRAM BIT(30)
#define VGAINIT0_VGA_DISABLE BIT(0)
#define VGAINIT0_EXT_TIMING BIT(1)
#define VGAINIT0_8BIT_DAC BIT(2)
#define VGAINIT0_EXT_ENABLE BIT(6)
#define VGAINIT0_WAKEUP_3C3 BIT(8)
#define VGAINIT0_LEGACY_DISABLE BIT(9)
#define VGAINIT0_ALT_READBACK BIT(10)
#define VGAINIT0_FAST_BLINK BIT(11)
#define VGAINIT0_EXTSHIFTOUT BIT(12)
#define VGAINIT0_DECODE_3C6 BIT(13)
#define VGAINIT0_SGRAM_HBLANK_DISABLE BIT(22)
#define VGAINIT1_MASK 0x1fffff
#define VIDCFG_VIDPROC_ENABLE BIT(0)
#define VIDCFG_CURS_X11 BIT(1)
#define VIDCFG_HALF_MODE BIT(4)
#define VIDCFG_DESK_ENABLE BIT(7)
#define VIDCFG_CLUT_BYPASS BIT(10)
#define VIDCFG_2X BIT(26)
#define VIDCFG_HWCURSOR_ENABLE BIT(27)
#define VIDCFG_PIXFMT_SHIFT 18
#define DACMODE_2X BIT(0)
/* VGA rubbish, need to change this for multihead support */
#define MISC_W 0x3c2
#define MISC_R 0x3cc
#define SEQ_I 0x3c4
#define SEQ_D 0x3c5
#define CRT_I 0x3d4
#define CRT_D 0x3d5
#define ATT_IW 0x3c0
#define IS1_R 0x3da
#define GRA_I 0x3ce
#define GRA_D 0x3cf
#ifdef __KERNEL__
struct banshee_reg {
/* VGA rubbish */
unsigned char att[21];
unsigned char crt[25];
unsigned char gra[ 9];
unsigned char misc[1];
unsigned char seq[ 5];
/* Banshee extensions */
unsigned char ext[2];
unsigned long vidcfg;
unsigned long vidpll;
unsigned long mempll;
unsigned long gfxpll;
unsigned long dacmode;
unsigned long vgainit0;
unsigned long vgainit1;
unsigned long screensize;
unsigned long stride;
unsigned long cursloc;
unsigned long curspataddr;
unsigned long cursc0;
unsigned long cursc1;
unsigned long startaddr;
unsigned long clip0min;
unsigned long clip0max;
unsigned long clip1min;
unsigned long clip1max;
unsigned long srcbase;
unsigned long dstbase;
unsigned long miscinit0;
};
struct tdfx_par {
u32 max_pixclock;
void *regbase_virt;
unsigned long iobase;
u32 baseline;
struct {
int w,u,d;
unsigned long enable,disable;
struct timer_list timer;
} hwcursor;
spinlock_t DAClock;
};
#endif /* __KERNEL__ */
#endif /* _TDFX_H */
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