Commit 83f7182b authored by James Simmons's avatar James Simmons

Grabbed the PPC drivers and in the process of porting to the latest api. Can...

Grabbed the PPC drivers and in the process of porting to the latest api. Can now use driver specific read and write functions   
parent 9cec4024
......@@ -26,7 +26,7 @@ obj-$(CONFIG_FB_PM3) += pm3fb.o
obj-$(CONFIG_FB_APOLLO) += dnfb.o cfbfillrect.o cfbimgblt.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_ATY128) += aty128fb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
obj-$(CONFIG_FB_RADEON) += radeonfb.o
obj-$(CONFIG_FB_NEOMAGIC) += neofb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
obj-$(CONFIG_FB_IGA) += igafb.o
......
......@@ -21,6 +21,9 @@
* - Convert to new framebuffer API,
* fix colormap setting at 16 bits/pixel (565)
*
* Paul Mundt
* - PCI hotplug
*
* Based off of Geert's atyfb.c and vfb.c.
*
* TODO:
......@@ -81,12 +84,6 @@
#include <asm/btext.h>
#endif /* CONFIG_BOOTX_TEXT */
#include <video/fbcon.h>
#include <video/fbcon-cfb8.h>
#include <video/fbcon-cfb16.h>
#include <video/fbcon-cfb24.h>
#include <video/fbcon-cfb32.h>
#ifdef CONFIG_MTRR
#include <asm/mtrr.h>
#endif
......@@ -326,7 +323,6 @@ struct aty128fb_par {
struct fb_info_aty128 {
struct fb_info fb_info;
struct display disp;
struct aty128fb_par par;
u32 pseudo_palette[17];
struct fb_info_aty128 *next;
......@@ -354,11 +350,11 @@ static int aty128fb_check_var(struct fb_var_screeninfo *var,
static int aty128fb_set_par(struct fb_info *info);
static int aty128fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
u_int transp, struct fb_info *info);
static int aty128fb_pan_display(struct fb_var_screeninfo *var, int con,
static int aty128fb_pan_display(struct fb_var_screeninfo *var,
struct fb_info *fb);
static int aty128fb_blank(int blank, struct fb_info *fb);
static int aty128fb_ioctl(struct inode *inode, struct file *file, u_int cmd,
u_long arg, int con, struct fb_info *info);
u_long arg, struct fb_info *info);
static int aty128fb_sync(struct fb_info *info);
/*
......@@ -393,7 +389,6 @@ static u32 depth_to_dst(u32 depth);
static struct fb_ops aty128fb_ops = {
.owner = THIS_MODULE,
.fb_set_var = gen_set_var,
.fb_check_var = aty128fb_check_var,
.fb_set_par = aty128fb_set_par,
.fb_setcolreg = aty128fb_setcolreg,
......@@ -1337,8 +1332,7 @@ aty128fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
* Pan or Wrap the Display
*/
static int
aty128fb_pan_display(struct fb_var_screeninfo *var, int con,
struct fb_info *fb)
aty128fb_pan_display(struct fb_var_screeninfo *var, struct fb_info *fb)
{
struct aty128fb_par *par = fb->par;
u32 xoffset, yoffset;
......@@ -1680,7 +1674,6 @@ aty128_pci_register(struct pci_dev *pdev,
par = &lump->par;
info->par = par;
info->disp = &lump->disp;
info->fix = aty128fb_fix;
info->pseudo_palette = lump->pseudo_palette;
......@@ -1715,13 +1708,13 @@ aty128_pci_register(struct pci_dev *pdev,
}
#if !defined(CONFIG_PPC) && !defined(__sparc__)
if (!(bios_seg = aty128find_ROM(info)))
if (!(bios_seg = aty128find_ROM()))
printk(KERN_INFO "aty128fb: Rage128 BIOS not located. "
"Guessing...\n");
else {
printk(KERN_INFO "aty128fb: Rage128 BIOS located at "
"segment %4.4X\n", (unsigned int)bios_seg);
aty128_get_pllinfo(info, bios_seg);
aty128_get_pllinfo(par, bios_seg);
}
#endif
aty128_timings(par);
......@@ -1734,9 +1727,9 @@ aty128_pci_register(struct pci_dev *pdev,
#ifdef CONFIG_MTRR
if (mtrr) {
info->mtrr.vram = mtrr_add(info->fix.smem_start,
info->vram_size, MTRR_TYPE_WRCOMB, 1);
info->mtrr.vram_valid = 1;
par->mtrr.vram = mtrr_add(info->fix.smem_start,
par->vram_size, MTRR_TYPE_WRCOMB, 1);
par->mtrr.vram_valid = 1;
/* let there be speed */
printk(KERN_INFO "aty128fb: Rage128 MTRR set to ON\n");
}
......@@ -1813,10 +1806,8 @@ static char * __init aty128find_ROM(void)
iounmap(rom_base);
continue;
}
return rom_base;
}
return NULL;
}
......@@ -2036,7 +2027,7 @@ aty128fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
#define FBIO_ATY128_SET_MIRROR _IOW('@', 2, sizeof(__u32*))
static int aty128fb_ioctl(struct inode *inode, struct file *file, u_int cmd,
u_long arg, int con, struct fb_info *info)
u_long arg, struct fb_info *info)
{
#ifdef CONFIG_PMAC_PBOOK
struct aty128fb_par *par = info->par;
......
......@@ -121,8 +121,8 @@ config FBCON_ADVANCED
config FBCON_ACCEL
tristate "Hardware acceleration support" if FBCON_ADVANCED
depends on FRAMEBUFFER_CONSOLE
default m if !FBCON_ADVANCED && FB_NEOMAGIC!=y && !FB_VESA && !FB_FM2 && FB_HIT!=y && !FB_HP300 && !FB_Q40 && !FB_ANAKIN && !FB_G364 && FB_VIRTUAL!=y && !FB_CLPS711X && !FB_PMAG_BA && !FB_PMAGB_B && FB_3DFX!=y && !FB_TX3912 && !FB_MAXINE && !FB_APOLLO && FB_ATY!=y && !FB_MAC && FB_RIVA!=y && FB_HGA!=y && !FB_OF && FB_SGIVW!=y && FB_VGA16!=y && (FB_NEOMAGIC=m || FB_HIT=m || FB_VIRTUAL=m || FB_3DFX=m || FB_RIVA=m || FB_SGIVW=m || FB_HGA=m)
default y if !FBCON_ADVANCED && (FB_NEOMAGIC=y || FB_VESA || FB_FM2 || FB_HIT=y || FB_HP300 || FB_Q40 || FB_ANAKIN || FB_G364 || FB_VIRTUAL=y || FB_CLPS711X || FB_PMAG_BA || FB_PMAGB_B || FB_3DFX=y || FB_TX3912 || FB_MAXINE || FB_APOLLO || FB_ATY=y || FB_MAC || FB_RIVA=y || FB_OF || FB_SGIVW=y || FB_HGA=y || FB_VGA16)
default m if !FBCON_ADVANCED && FB_NEOMAGIC!=y && !FB_VESA && !FB_FM2 && FB_HIT!=y && !FB_HP300 && !FB_Q40 && !FB_ANAKIN && !FB_G364 && FB_VIRTUAL!=y && !FB_CLPS711X && !FB_PMAG_BA && !FB_PMAGB_B && FB_3DFX!=y && !FB_TX3912 && !FB_MAXINE && !FB_APOLLO && FB_ATY!=y && FB_ATY128!=y && !FB_MAC && FB_RIVA!=y && FB_HGA!=y && !FB_OF && FB_SGIVW!=y && FB_VGA16!=y && (FB_NEOMAGIC=m || FB_HIT=m || FB_VIRTUAL=m || FB_3DFX=m || FB_RIVA=m || FB_SGIVW=m || FB_HGA=m || FB_ATY128=m)
default y if !FBCON_ADVANCED && (FB_NEOMAGIC=y || FB_VESA || FB_FM2 || FB_HIT=y || FB_HP300 || FB_Q40 || FB_ANAKIN || FB_G364 || FB_VIRTUAL=y || FB_CLPS711X || FB_PMAG_BA || FB_PMAGB_B || FB_3DFX=y || FB_TX3912 || FB_MAXINE || FB_APOLLO || FB_ATY=y || FB_ATY128=y || FB_MAC || FB_RIVA=y || FB_OF || FB_SGIVW=y || FB_HGA=y || FB_VGA16)
config FBCON_AFB
tristate "Amiga bitplanes support" if FBCON_ADVANCED
......
......@@ -97,11 +97,9 @@ static inline int VAR_MATCH(struct fb_var_screeninfo *x, struct fb_var_screeninf
struct fb_info_control {
struct fb_info info;
struct display display;
struct display display; /* Will disappear */
struct fb_par_control par;
struct {
__u8 red, green, blue;
} palette[256];
u32 pseudo_palette[17];
struct cmap_regs *cmap_regs;
unsigned long cmap_regs_phys;
......@@ -118,14 +116,6 @@ struct fb_info_control {
int control_use_bank2;
unsigned long total_vram;
unsigned char vram_attr;
union {
#ifdef FBCON_HAS_CFB16
u16 cfb16[16];
#endif
#ifdef FBCON_HAS_CFB32
u32 cfb32[16];
#endif
} fbcon_cmap;
};
/* control register access macro */
......@@ -136,33 +126,15 @@ struct fb_info_control {
/*
* struct fb_ops
*/
static int control_get_fix(struct fb_fix_screeninfo *fix, int con,
struct fb_info *info);
static int control_get_var(struct fb_var_screeninfo *var, int con,
struct fb_info *info);
static int control_set_var(struct fb_var_screeninfo *var, int con,
struct fb_info *info);
static int control_pan_display(struct fb_var_screeninfo *var, int con,
struct fb_info *info);
static int control_get_cmap(struct fb_cmap *cmap, int kspc, int con,
static int controlfb_pan_display(struct fb_var_screeninfo *var, int con,
struct fb_info *info);
static int controlfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
u_int transp, struct fb_info *info);
static int controlfb_blank(int blank_mode, struct fb_info *info);
static int control_mmap(struct fb_info *info, struct file *file,
static int controlfb_mmap(struct fb_info *info, struct file *file,
struct vm_area_struct *vma);
/*
* low level fbcon ops
*/
static int controlfb_switch(int con, struct fb_info *info);
static int controlfb_updatevar(int con, struct fb_info *info);
/*
* low level cmap set/get ops
*/
static int controlfb_getcolreg(u_int regno, u_int *red, u_int *green,
u_int *blue, u_int *transp, struct fb_info *info);
static int controlfb_set_par (struct fb_info *info);
static int controlfb_check_var (struct fb_var_screeninfo *var, struct fb_info *info);
/*
* inititialization
......@@ -170,13 +142,6 @@ static int controlfb_getcolreg(u_int regno, u_int *red, u_int *green,
int control_init(void);
void control_setup(char *);
/*
* low level fbcon revc ops
*/
static void control_cfb16_revc(struct display *p, int xx, int yy);
static void control_cfb32_revc(struct display *p, int xx, int yy);
/******************** Prototypes for internal functions **********************/
static void set_control_clock(unsigned char *params);
......@@ -184,10 +149,6 @@ static int init_control(struct fb_info_control *p);
static void control_set_hardware(struct fb_info_control *p,
struct fb_par_control *par);
static int control_of_init(struct device_node *dp);
static void control_par_to_fix(struct fb_par_control *par,
struct fb_fix_screeninfo *fix, struct fb_info_control *p);
static void control_set_dispsw(struct display *disp, int cmode,
struct fb_info_control *p);
static void find_vram_size(struct fb_info_control *p);
static int read_control_sense(struct fb_info_control *p);
static int calc_clock_params(unsigned long clk, unsigned char *param);
......@@ -195,13 +156,6 @@ static int control_var_to_par(struct fb_var_screeninfo *var,
struct fb_par_control *par, const struct fb_info *fb_info);
static inline void control_par_to_var(struct fb_par_control *par,
struct fb_var_screeninfo *var);
static void control_par_to_fix(struct fb_par_control *par,
struct fb_fix_screeninfo *fix, struct fb_info_control *p);
static void control_par_to_display(struct fb_par_control *par,
struct display *disp, struct fb_fix_screeninfo *fix,
struct fb_info_control *p);
static void control_set_dispsw(struct display *disp, int cmode,
struct fb_info_control *p);
static void control_init_info(struct fb_info *info, struct fb_info_control *p);
static void control_cleanup(void);
......@@ -217,15 +171,18 @@ static int default_cmode __initdata = CMODE_NVRAM;
static struct fb_ops controlfb_ops = {
.owner = THIS_MODULE,
.fb_get_fix = control_get_fix,
.fb_get_var = control_get_var,
.fb_set_var = control_set_var,
.fb_get_cmap = control_get_cmap,
.fb_set_var = gen_set_var,
.fb_check_var = controlfb_check_var,
.fb_set_par = controlfb_set_par,
.fb_get_cmap = gen_get_cmap,
.fb_set_cmap = gen_set_cmap,
.fb_setcolreg = controlfb_setcolreg,
.fb_pan_display =control_pan_display,
.fb_pan_display = controlfb_pan_display,
.fb_blank = controlfb_blank,
.fb_mmap = control_mmap,
.fb_mmap = controlfb_mmap,
.fb_fillrect = cfb_fillrect,
.fb_copyarea = cfb_copyarea,
.fb_imageblit = cfb_imageblit,
};
......@@ -251,87 +208,48 @@ void cleanup_module(void)
}
#endif
/*********** Providing our information to the user ************/
static int control_get_fix(struct fb_fix_screeninfo *fix, int con,
struct fb_info *info)
/*
* Checks a var structure
*/
static int controlfb_check_var (struct fb_var_screeninfo *var, struct fb_info *info)
{
struct fb_info_control *p = (struct fb_info_control *) info;
if(con == -1) {
control_par_to_fix(&p->par, fix, p);
} else {
struct fb_par_control par;
int err;
control_var_to_par(&fb_display[con].var, &par, info);
control_par_to_fix(&par, fix, p);
}
return 0;
}
static int control_get_var(struct fb_var_screeninfo *var, int con,
struct fb_info *info)
{
struct fb_info_control *p = (struct fb_info_control *) info;
err = control_var_to_par(var, &par, info);
if (err)
return err;
control_par_to_var(&par, var);
if(con == -1) {
control_par_to_var(&p->par, var);
} else {
*var = fb_display[con].var;
}
return 0;
}
/*
* Sets everything according to var
* Applies current var to display
*/
static int control_set_var(struct fb_var_screeninfo *var, int con,
struct fb_info *info)
static int controlfb_set_par (struct fb_info *info)
{
struct fb_info_control *p = (struct fb_info_control *) info;
struct display *disp;
struct fb_par_control par;
int depthchange, err;
int activate = var->activate;
int err;
if((err = control_var_to_par(var, &par, info))) {
if (con < 0)
printk (KERN_ERR "control_set_var: error calling"
if((err = control_var_to_par(&info->var, &par, info))) {
printk (KERN_ERR "controlfb_set_par: error calling"
" control_var_to_par: %d.\n", err);
return err;
}
control_par_to_var(&par, var);
if ((activate & FB_ACTIVATE_MASK) != FB_ACTIVATE_NOW)
return 0;
disp = (con >= 0) ? &fb_display[con] : info->disp;
depthchange = (disp->var.bits_per_pixel != var->bits_per_pixel);
if(!VAR_MATCH(&disp->var, var)) {
struct fb_fix_screeninfo fix;
control_par_to_fix(&par, &fix, p);
control_par_to_display(&par, disp, &fix, p);
if(info->changevar)
(*info->changevar)(con);
} else
disp->var = *var;
if (con == info->currcon) {
control_set_hardware(p, &par);
if(depthchange) {
if((err = fb_alloc_cmap(&disp->cmap, 0, 0)))
return err;
do_install_cmap(con, info);
}
}
info->fix.visual = (p->par.cmode == CMODE_8) ?
FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_DIRECTCOLOR;
info->fix.line_length = p->par.pitch;
info->fix.xpanstep = 32 >> p->par.cmode;
info->fix.ypanstep = 1;
return 0;
}
/*
* Set screen start address according to var offset values
*/
......@@ -347,7 +265,7 @@ static inline void set_screen_start(int xoffset, int yoffset,
}
static int control_pan_display(struct fb_var_screeninfo *var, int con,
static int controlfb_pan_display(struct fb_var_screeninfo *var, int con,
struct fb_info *info)
{
unsigned int xoffset, hstep;
......@@ -369,48 +287,30 @@ static int control_pan_display(struct fb_var_screeninfo *var, int con,
return 0;
}
static int control_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, controlfb_getcolreg, info);
if (fb_display[con].cmap.len) /* non default colormap? */
fb_copy_cmap(&fb_display[con].cmap, cmap, kspc ? 0: 2);
else {
int size = fb_display[con].var.bits_per_pixel == 16 ? 32 : 256;
fb_copy_cmap(fb_default_cmap(size), cmap, kspc ? 0 : 2);
}
return 0;
}
/*
* Private mmap since we want to have a different caching on the framebuffer
* for controlfb.
* Note there's no locking in here; it's done in fb_mmap() in fbmem.c.
*/
static int control_mmap(struct fb_info *info, struct file *file,
static int controlfb_mmap(struct fb_info *info, struct file *file,
struct vm_area_struct *vma)
{
struct fb_ops *fb = info->fbops;
struct fb_fix_screeninfo fix;
struct fb_var_screeninfo var;
unsigned long off, start;
u32 len;
fb->fb_get_fix(&fix, PROC_CONSOLE(info), info);
off = vma->vm_pgoff << PAGE_SHIFT;
/* frame buffer memory */
start = fix.smem_start;
len = PAGE_ALIGN((start & ~PAGE_MASK)+fix.smem_len);
start = info->fix.smem_start;
len = PAGE_ALIGN((start & ~PAGE_MASK)+info->fix.smem_len);
if (off >= len) {
/* memory mapped io */
off -= len;
fb->fb_get_var(&var, PROC_CONSOLE(info), info);
if (var.accel_flags)
if (info->var.accel_flags)
return -EINVAL;
start = fix.mmio_start;
len = PAGE_ALIGN((start & ~PAGE_MASK)+fix.mmio_len);
start = info->fix.mmio_start;
len = PAGE_ALIGN((start & ~PAGE_MASK)+info->fix.mmio_len);
pgprot_val(vma->vm_page_prot) |= _PAGE_NO_CACHE|_PAGE_GUARDED;
} else {
/* framebuffer */
......@@ -428,44 +328,6 @@ static int control_mmap(struct fb_info *info, struct file *file,
return 0;
}
/******************** End of controlfb_ops implementation ******************/
/*
* low level fbcon ops
*/
static int controlfb_switch(int con, struct fb_info *info)
{
struct fb_info_control *p = (struct fb_info_control *)info;
struct fb_par_control par;
if (info->currcon >= 0 && fb_display[info->currcon].cmap.len)
fb_get_cmap(&fb_display[info->currcon].cmap, 1, controlfb_getcolreg,
info);
info->currcon = con;
fb_display[con].var.activate = FB_ACTIVATE_NOW;
control_var_to_par(&fb_display[con].var, &par, info);
control_set_hardware(p, &par);
control_set_dispsw(&fb_display[con], par.cmode, p);
do_install_cmap(con, info);
return 1;
}
static int controlfb_updatevar(int con, struct fb_info *info)
{
struct fb_var_screeninfo *var = &fb_display[con].var;
struct fb_info_control *p = (struct fb_info_control *) info;
set_screen_start(var->xoffset, var->yoffset, p);
return 0;
}
static int controlfb_blank(int blank_mode, struct fb_info *info)
{
struct fb_info_control *p = (struct fb_info_control *) info;
......@@ -498,30 +360,10 @@ static int controlfb_blank(int blank_mode, struct fb_info *info)
return 0;
}
/*
* low level cmap set/get ops
*/
static int controlfb_getcolreg(u_int regno, u_int *red, u_int *green,
u_int *blue, u_int *transp, struct fb_info *info)
{
struct fb_info_control *p = (struct fb_info_control *) info;
if (regno > 255)
return 1;
*red = (p->palette[regno].red<<8) | p->palette[regno].red;
*green = (p->palette[regno].green<<8) | p->palette[regno].green;
*blue = (p->palette[regno].blue<<8) | p->palette[regno].blue;
*transp = 0;
return 0;
}
static int controlfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
u_int transp, struct fb_info *info)
{
struct fb_info_control *p = (struct fb_info_control *) info;
u_int i;
__u8 r, g, b;
if (regno > 255)
......@@ -531,32 +373,34 @@ static int controlfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
g = green >> 8;
b = blue >> 8;
p->palette[regno].red = r;
p->palette[regno].green = g;
p->palette[regno].blue = b;
out_8(&p->cmap_regs->addr, regno); /* tell clut what addr to fill */
out_8(&p->cmap_regs->lut, r); /* send one color channel at */
out_8(&p->cmap_regs->lut, g); /* a time... */
out_8(&p->cmap_regs->lut, b);
if (regno < 16)
if (regno < 16) {
int i;
switch (p->par.cmode) {
#ifdef FBCON_HAS_CFB16
case CMODE_16:
p->fbcon_cmap.cfb16[regno] = (regno << 10) | (regno << 5) | regno;
((u16 *) (info->pseudo_palette))[regno] =
(regno << 10) | (regno << 5) | regno;
break;
#endif
#ifdef FBCON_HAS_CFB32
case CMODE_32:
i = (regno << 8) | regno;
p->fbcon_cmap.cfb32[regno] = (i << 16) | i;
((u32 *) (info->pseudo_palette))[regno] =
(i << 16) | i;
break;
#endif
}
}
return 0;
}
/******************** End of controlfb_ops implementation ******************/
static void set_control_clock(unsigned char *params)
{
#ifdef CONFIG_ADB_CUDA
......@@ -580,6 +424,7 @@ static int __init init_control(struct fb_info_control *p)
{
int full, sense, vmode, cmode, vyres;
struct fb_var_screeninfo var;
int rc;
printk(KERN_INFO "controlfb: ");
......@@ -613,6 +458,10 @@ static int __init init_control(struct fb_info_control *p)
}
}
/* Initialize info structure */
control_init_info(&p->info, p);
/* Setup default var */
if (mac_vmode_to_var(vmode, cmode, &var) < 0) {
/* This shouldn't happen! */
printk("mac_vmode_to_var(%d, %d,) failed\n", vmode, cmode);
......@@ -631,22 +480,18 @@ static int __init init_control(struct fb_info_control *p)
if (vyres > var.yres)
var.yres_virtual = vyres;
control_init_info(&p->info, p);
p->info.currcon = -1;
/* Apply default var */
p->info.var = var;
var.activate = FB_ACTIVATE_NOW;
if (control_set_var(&var, -1, &p->info) < 0) {
if (vmode != VMODE_640_480_60 || cmode != CMODE_8)
rc = gen_set_var(&var, -1, &p->info);
if (rc && (vmode != VMODE_640_480_60 || cmode != CMODE_8))
goto try_again;
printk(KERN_ERR "controlfb: initilization failed\n");
return -ENXIO;
}
p->info.flags = FBINFO_FLAG_DEFAULT;
/* Register with fbdev layer */
if (register_framebuffer(&p->info) < 0)
return -ENXIO;
printk(KERN_INFO "fb%d: control display adapter\n", minor(p->info.node));
printk(KERN_INFO "fb%d: control display adapter\n", GET_FB_IDX(p->info.node));
return 0;
}
......@@ -820,7 +665,7 @@ static int __init control_of_init(struct device_node *dp)
printk(KERN_ERR "expecting 2 address for control (got %d)", dp->n_addrs);
return -ENXIO;
}
p = kmalloc(sizeof(*p), GFP_ATOMIC);
p = kmalloc(sizeof(*p), GFP_KERNEL);
if (p == 0)
return -ENXIO;
control_fb = p; /* save it for cleanups */
......@@ -1164,171 +1009,41 @@ static void control_par_to_var(struct fb_par_control *par, struct fb_var_screeni
var->pixclock >>= par->regvals.clock_params[2];
}
/*
* init fix according to given par
*/
static void control_par_to_fix(struct fb_par_control *par, struct fb_fix_screeninfo *fix,
struct fb_info_control *p)
{
memset(fix, 0, sizeof(*fix));
strcpy(fix->id, "control");
fix->mmio_start = p->control_regs_phys;
fix->mmio_len = sizeof(struct control_regs);
fix->type = FB_TYPE_PACKED_PIXELS;
fix->xpanstep = 32 >> par->cmode;
fix->ypanstep = 1;
fix->smem_start = p->frame_buffer_phys + CTRLFB_OFF;
fix->smem_len = p->total_vram - CTRLFB_OFF;
fix->visual = (par->cmode == CMODE_8) ?
FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_DIRECTCOLOR;
fix->line_length = par->pitch;
}
/*
* initialize a portion of struct display which low level driver is responsible
* for.
*/
static void control_par_to_display(struct fb_par_control *par,
struct display *disp, struct fb_fix_screeninfo *fix, struct fb_info_control *p)
{
disp->type = fix->type;
disp->can_soft_blank = 1;
disp->scrollmode = SCROLL_YNOMOVE | SCROLL_YNOPARTIAL;
disp->ypanstep = fix->ypanstep;
disp->ywrapstep = fix->ywrapstep;
control_par_to_var(par, &disp->var);
p->info.screen_base = (char *) p->frame_buffer + CTRLFB_OFF;
disp->visual = fix->visual;
disp->line_length = fix->line_length;
control_set_dispsw(disp, par->cmode, p);
}
/*
* our own _revc() routines since generic routines don't work for DIRECT Color
* devices like control
*/
static void control_cfb16_revc(struct display *p, int xx, int yy)
{
u8 *dest;
int bytes = p->next_line, rows;
dest = p->fb_info->screen_base + yy * fontheight(p) * bytes + xx * fontwidth(p)*2;
for (rows = fontheight(p); rows--; dest += bytes) {
switch (fontwidth(p)) {
case 16:
((u32 *)dest)[6] ^= 0x3def3def; ((u32 *)dest)[7] ^= 0x3def3def;
/* FALL THROUGH */
case 12:
((u32 *)dest)[4] ^= 0x3def3def; ((u32 *)dest)[5] ^= 0x3def3def;
/* FALL THROUGH */
case 8:
((u32 *)dest)[2] ^= 0x3def3def; ((u32 *)dest)[3] ^= 0x3def3def;
/* FALL THROUGH */
case 4:
((u32 *)dest)[0] ^= 0x3def3def; ((u32 *)dest)[1] ^= 0x3def3def;
}
}
}
static void control_cfb32_revc(struct display *p, int xx, int yy)
{
u8 *dest;
int bytes = p->next_line, rows;
dest = p->fb_info->screen_base + yy * fontheight(p) * bytes + xx * fontwidth(p) * 4;
for (rows = fontheight(p); rows--; dest += bytes) {
switch (fontwidth(p)) {
case 16:
((u32 *)dest)[12] ^= 0x0f0f0f0f; ((u32 *)dest)[13] ^= 0x0f0f0f0f;
((u32 *)dest)[14] ^= 0x0f0f0f0f; ((u32 *)dest)[15] ^= 0x0f0f0f0f;
/* FALL THROUGH */
case 12:
((u32 *)dest)[8] ^= 0x0f0f0f0f; ((u32 *)dest)[9] ^= 0x0f0f0f0f;
((u32 *)dest)[10] ^= 0x0f0f0f0f; ((u32 *)dest)[11] ^= 0x0f0f0f0f;
/* FALL THROUGH */
case 8:
((u32 *)dest)[4] ^= 0x0f0f0f0f; ((u32 *)dest)[5] ^= 0x0f0f0f0f;
((u32 *)dest)[6] ^= 0x0f0f0f0f; ((u32 *)dest)[7] ^= 0x0f0f0f0f;
/* FALL THROUGH */
case 4:
((u32 *)dest)[0] ^= 0x0f0f0f0f; ((u32 *)dest)[1] ^= 0x0f0f0f0f;
((u32 *)dest)[2] ^= 0x0f0f0f0f; ((u32 *)dest)[3] ^= 0x0f0f0f0f;
/* FALL THROUGH */
}
}
}
static struct display_switch control_cfb16 = {
setup: fbcon_cfb16_setup,
bmove: fbcon_cfb16_bmove,
clear: fbcon_cfb16_clear,
putc: fbcon_cfb16_putc,
putcs: fbcon_cfb16_putcs,
revc: control_cfb16_revc,
clear_margins: fbcon_cfb16_clear_margins,
fontwidthmask: FONTWIDTH(4)|FONTWIDTH(8)|FONTWIDTH(12)|FONTWIDTH(16)
};
static struct display_switch control_cfb32 = {
setup: fbcon_cfb32_setup,
bmove: fbcon_cfb32_bmove,
clear: fbcon_cfb32_clear,
putc: fbcon_cfb32_putc,
putcs: fbcon_cfb32_putcs,
revc: control_cfb32_revc,
clear_margins: fbcon_cfb32_clear_margins,
fontwidthmask: FONTWIDTH(4)|FONTWIDTH(8)|FONTWIDTH(12)|FONTWIDTH(16)
};
/*
* Set struct dispsw according to given cmode
*/
static void control_set_dispsw(struct display *disp, int cmode, struct fb_info_control *p)
{
switch (cmode) {
#ifdef FBCON_HAS_CFB8
case CMODE_8:
disp->dispsw = &fbcon_cfb8;
break;
#endif
#ifdef FBCON_HAS_CFB16
case CMODE_16:
disp->dispsw = &control_cfb16;
disp->dispsw_data = p->fbcon_cmap.cfb16;
break;
#endif
#ifdef FBCON_HAS_CFB32
case CMODE_32:
disp->dispsw = &control_cfb32;
disp->dispsw_data = p->fbcon_cmap.cfb32;
break;
#endif
default:
disp->dispsw = &fbcon_dummy;
break;
}
}
/*
* Set misc info vars for this driver
*/
static void __init control_init_info(struct fb_info *info, struct fb_info_control *p)
{
/* Fill fb_info */
strcpy(info->modename, "control");
info->currcon = -1;
info->par = &p->par;
info->node = NODEV;
info->fbops = &controlfb_ops;
info->disp = &p->display;
strcpy(info->fontname, fontname);
info->pseudo_palette = p->pseudo_palette;
info->flags = FBINFO_FLAG_DEFAULT;
strncpy (info->fontname, fontname, sizeof (info->fontname));
info->fontname[sizeof (info->fontname) - 1] = 0;
info->changevar = NULL;
info->display_fg = NULL;
info->screen_base = (char *) p->frame_buffer + CTRLFB_OFF;
info->changevar = NULL;
info->switch_con = &controlfb_switch;
info->updatevar = &controlfb_updatevar;
info->switch_con = gen_switch;
info->updatevar = gen_update_var;
fb_alloc_cmap(&info->cmap, 256, 0);
/* Fill fix common fields */
strcpy(info->fix.id, "control");
info->fix.mmio_start = p->control_regs_phys;
info->fix.mmio_len = sizeof(struct control_regs);
info->fix.type = FB_TYPE_PACKED_PIXELS;
info->fix.smem_start = p->frame_buffer_phys + CTRLFB_OFF;
info->fix.smem_len = p->total_vram - CTRLFB_OFF;
info->fix.ywrapstep = 0;
info->fix.type_aux = 0;
info->fix.accel = FB_ACCEL_NONE;
}
......
......@@ -402,6 +402,9 @@ fb_read(struct file *file, char *buf, size_t count, loff_t *ppos)
if (!info || ! info->screen_base)
return -ENODEV;
if (info->fbops->fb_read)
return info->fbops->fb_read(file, buf, count, ppos);
if (p >= info->fix.smem_len)
return 0;
if (count >= info->fix.smem_len)
......@@ -432,6 +435,9 @@ fb_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
if (!info || !info->screen_base)
return -ENODEV;
if (info->fbops->fb_write)
return info->fbops->fb_write(file, buf, count, ppos);
if (p > info->fix.smem_len)
return -ENOSPC;
if (count >= info->fix.smem_len)
......
......@@ -772,7 +772,7 @@ set_imstt_regvals (struct fb_info_imstt *p, u_int bpp)
static inline void
set_offset (struct display *disp, struct fb_info_imstt *p)
{
__u32 off = disp->var.yoffset * (disp->line_length >> 3)
__u32 off = disp->var.yoffset * (p->info.fix.line_length >> 3)
+ ((disp->var.xoffset * (disp->var.bits_per_pixel >> 3)) >> 3);
out_le32(&p->dc_regs[SSR], off);
}
......@@ -1020,7 +1020,7 @@ imsttfbcon_bmove (struct display *disp, int sy, int sx, int dy, int dx, int heig
width *= Bpp;
width--;
line_pitch = disp->line_length;
line_pitch = p->info.fix.line_length;
bltctl = 0x05;
sp = line_pitch << 16;
cnt = height << 16;
......@@ -1068,7 +1068,7 @@ imsttfbcon_clear (struct vc_data *conp, struct display *disp,
bgc |= (bgc << 16);
Bpp = disp->var.bits_per_pixel >> 3,
line_pitch = disp->line_length;
line_pitch = p->info.fix.line_length;
sy *= fontheight(disp);
sy *= line_pitch;
......@@ -1099,7 +1099,7 @@ imsttfbcon_revc (struct display *disp, int sx, int sy)
__u32 Bpp, line_pitch, height, width;
Bpp = disp->var.bits_per_pixel >> 3,
line_pitch = disp->line_length;
line_pitch = p->info.fix.line_length;
height = fontheight(disp);
width = fontwidth(disp) * Bpp;
......@@ -1246,28 +1246,6 @@ imsttfb_setcolreg (u_int regno, u_int red, u_int green, u_int blue,
return 0;
}
static int
imsttfb_get_fix (struct fb_fix_screeninfo *fix, int con, struct fb_info *info)
{
struct fb_info_imstt *p = (struct fb_info_imstt *)info;
struct fb_var_screeninfo *var = &fb_display[con].var;
*fix = p->fix;
fix->visual = var->bits_per_pixel == 8 ? FB_VISUAL_PSEUDOCOLOR
: FB_VISUAL_DIRECTCOLOR;
fix->line_length = var->xres * (var->bits_per_pixel >> 3);
return 0;
}
static int
imsttfb_get_var (struct fb_var_screeninfo *var, int con, struct fb_info *info)
{
*var = fb_display[con].var;
return 0;
}
static void
set_dispsw (struct display *disp, struct fb_info_imstt *p)
{
......@@ -1354,16 +1332,7 @@ set_disp (struct display *disp, struct fb_info_imstt *p)
set_dispsw(disp, p);
disp->visual = disp->var.bits_per_pixel == 8 ? FB_VISUAL_PSEUDOCOLOR
: FB_VISUAL_DIRECTCOLOR;
disp->visual = p->fix.visual;
disp->type = p->fix.type;
disp->type_aux = p->fix.type_aux;
disp->line_length = disp->var.xres * (disp->var.bits_per_pixel >> 3);
disp->can_soft_blank = 1;
disp->inverse = inverse;
disp->ypanstep = 1;
disp->ywrapstep = 0;
if (accel) {
disp->scrollmode = SCROLL_YNOMOVE;
if (disp->var.yres == disp->var.yres_virtual) {
......@@ -1625,8 +1594,6 @@ static struct pci_driver imsttfb_pci_driver = {
static struct fb_ops imsttfb_ops = {
.owner = THIS_MODULE,
.fb_get_fix = imsttfb_get_fix,
.fb_get_var = imsttfb_get_var,
.fb_set_var = imsttfb_set_var,
.fb_get_cmap = imsttfb_get_cmap,
.fb_set_cmap = gen_set_cmap,
......@@ -1814,9 +1781,10 @@ init_imstt(struct fb_info_imstt *p)
return;
}
i = GET_FB_IDX(p->info.node);
tmp = (in_le32(&p->dc_regs[SSTATUS]) & 0x0f00) >> 8;
printk("fb%u: %s frame buffer; %uMB vram; chip version %u\n",
minor(p->info.node), p->fix.id, p->total_vram >> 20, tmp);
i, p->fix.id, p->total_vram >> 20, tmp);
}
static int __devinit
......
......@@ -58,14 +58,14 @@ struct fb_par_platinum {
};
struct fb_info_platinum {
struct fb_info fb_info;
struct display disp;
struct fb_par_platinum default_par;
struct fb_par_platinum current_par;
struct fb_info info;
struct display display; /* Will disappear */
struct fb_par_platinum par;
struct {
__u8 red, green, blue;
} palette[256];
u32 pseudo_palette[17];
volatile struct cmap_regs *cmap_regs;
unsigned long cmap_regs_phys;
......@@ -80,42 +80,17 @@ struct fb_info_platinum {
unsigned long total_vram;
int clktype;
int dactype;
union {
#ifdef FBCON_HAS_CFB16
u16 cfb16[16];
#endif
#ifdef FBCON_HAS_CFB32
u32 cfb32[16];
#endif
} fbcon_cmap;
};
/*
* Frame buffer device API
*/
static int platinum_get_fix(struct fb_fix_screeninfo *fix, int con,
struct fb_info *fb);
static int platinum_get_var(struct fb_var_screeninfo *var, int con,
struct fb_info *fb);
static int platinum_set_var(struct fb_var_screeninfo *var, int con,
struct fb_info *fb);
static int platinum_get_cmap(struct fb_cmap *cmap, int kspc, int con,
struct fb_info *info);
static int platinum_set_cmap(struct fb_cmap *cmap, int kspc, int con,
struct fb_info *info);
static int platinum_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
u_int transp, struct fb_info *fb);
static int platinum_blank(int blank, struct fb_info *fb);
/*
* Interface to the low level console driver
*/
static int platinum_switch(int con, struct fb_info *fb);
static int platinum_updatevar(int con, struct fb_info *fb);
static int platinumfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
u_int transp, struct fb_info *info);
static int platinumfb_blank(int blank_mode, struct fb_info *info);
static int platinumfb_set_par (struct fb_info *info);
static int platinumfb_check_var (struct fb_var_screeninfo *var, struct fb_info *info);
/*
* internal functions
......@@ -125,21 +100,14 @@ static void platinum_of_init(struct device_node *dp);
static inline int platinum_vram_reqd(int video_mode, int color_mode);
static int read_platinum_sense(struct fb_info_platinum *info);
static void set_platinum_clock(struct fb_info_platinum *info);
static void platinum_set_par(const struct fb_par_platinum *par, struct fb_info_platinum *info);
static void platinum_set_hardware(struct fb_info_platinum *info,
const struct fb_par_platinum *par);
static int platinum_par_to_var(struct fb_var_screeninfo *var,
const struct fb_par_platinum *par,
const struct fb_info_platinum *info);
static int platinum_var_to_par(const struct fb_var_screeninfo *var,
struct fb_par_platinum *par,
const struct fb_info_platinum *info);
static int platinum_encode_fix(struct fb_fix_screeninfo *fix,
const struct fb_par_platinum *par,
const struct fb_info_platinum *info);
static void platinum_set_dispsw(struct display *disp,
struct fb_info_platinum *info, int cmode,
int accel);
static int platinum_getcolreg(u_int regno, u_int *red, u_int *green, u_int *blue,
u_int *transp, struct fb_info *fb);
/*
* Interface used by the world
......@@ -150,202 +118,65 @@ int platinum_setup(char*);
static struct fb_ops platinumfb_ops = {
.owner = THIS_MODULE,
.fb_get_fix = platinum_get_fix,
.fb_get_var = platinum_get_var,
.fb_set_var = platinum_set_var,
.fb_get_cmap = platinum_get_cmap,
.fb_set_cmap = platinum_set_cmap,
.fb_setcolreg = platinum_setcolreg,
.fb_blank = platinum_blank,
.fb_set_var = gen_set_var,
.fb_check_var = platinumfb_check_var,
.fb_set_par = platinumfb_set_par,
.fb_get_cmap = gen_get_cmap,
.fb_set_cmap = gen_set_cmap,
.fb_setcolreg = platinumfb_setcolreg,
.fb_blank = platinumfb_blank,
.fb_fillrect = cfb_fillrect,
.fb_copyarea = cfb_copyarea,
.fb_imageblit = cfb_imageblit,
};
static int platinum_get_fix(struct fb_fix_screeninfo *fix, int con,
struct fb_info *fb)
{
const struct fb_info_platinum *info = (struct fb_info_platinum *)fb;
struct fb_par_platinum par;
if (con == -1)
par = info->default_par;
else
platinum_var_to_par(&fb_display[con].var, &par, info);
platinum_encode_fix(fix, &par, info);
return 0;
}
static int platinum_get_var(struct fb_var_screeninfo *var, int con,
struct fb_info *fb)
{
const struct fb_info_platinum *info = (struct fb_info_platinum *)fb;
if (con == -1)
platinum_par_to_var(var, &info->default_par, info);
else
*var = fb_display[con].var;
return 0;
}
static void platinum_set_dispsw(struct display *disp,
struct fb_info_platinum *info, int cmode,
int accel)
{
switch(cmode) {
#ifdef FBCON_HAS_CFB8
case CMODE_8:
disp->dispsw = &fbcon_cfb8;
break;
#endif
#ifdef FBCON_HAS_CFB16
case CMODE_16:
disp->dispsw = &fbcon_cfb16;
disp->dispsw_data = info->fbcon_cmap.cfb16;
break;
#endif
#ifdef FBCON_HAS_CFB32
case CMODE_32:
disp->dispsw = &fbcon_cfb32;
disp->dispsw_data = info->fbcon_cmap.cfb32;
break;
#endif
default:
disp->dispsw = &fbcon_dummy;
break;
}
}
static int platinum_set_var(struct fb_var_screeninfo *var, int con,
struct fb_info *fb)
/*
* Checks a var structure
*/
static int platinumfb_check_var (struct fb_var_screeninfo *var, struct fb_info *info)
{
struct fb_info_platinum *info = (struct fb_info_platinum *) fb;
struct fb_info_platinum *p = (struct fb_info_platinum *) info;
struct fb_par_platinum par;
struct display *display;
int oldxres, oldyres, oldvxres, oldvyres, oldbpp, err;
int activate = var->activate;
struct platinum_regvals *init;
display = (con >= 0) ? &fb_display[con] : fb->disp;
if((err = platinum_var_to_par(var, &par, info))) {
printk(KERN_ERR "platinum_set_var: error calling platinum_var_to_par: %d.\n", err);
return err;
}
platinum_par_to_var(var, &par, info);
if ((activate & FB_ACTIVATE_MASK) != FB_ACTIVATE_NOW) {
printk(KERN_INFO "platinum_set_var: Not activating.\n");
return 0;
}
init = platinum_reg_init[par.vmode-1];
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 || oldyres != var->yres_virtual ||
oldbpp != var->bits_per_pixel) {
struct fb_fix_screeninfo fix;
platinum_encode_fix(&fix, &par, info);
info->fb_info.screen_base = (char *) info->frame_buffer + init->fb_offset + 0x20;
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;
platinum_set_dispsw(display, info, par.cmode, 0);
display->scrollmode = SCROLL_YREDRAW;
if (info->fb_info.changevar)
(*info->fb_info.changevar)(con);
}
if (!info->fb_info.display_fg ||
info->fb_info.display_fg->vc_num == con)
platinum_set_par(&par, info);
int err;
if (oldbpp != var->bits_per_pixel) {
if ((err = fb_alloc_cmap(&display->cmap, 0, 0)))
err = platinum_var_to_par(var, &par, p);
if (err)
return err;
do_install_cmap(con, &info->fb_info);
}
platinum_par_to_var(var, &par, p);
return 0;
}
static int platinum_get_cmap(struct fb_cmap *cmap, int kspc, int con,
struct fb_info *info)
{
if (!info->display_fg ||
info->display_fg->vc_num == con) /* current console? */
return fb_get_cmap(cmap, kspc, platinum_getcolreg, info);
if (fb_display[con].cmap.len) /* non default colormap? */
fb_copy_cmap(&fb_display[con].cmap, cmap, kspc ? 0 : 2);
else {
int size = fb_display[con].var.bits_per_pixel == 16 ? 32 : 256;
fb_copy_cmap(fb_default_cmap(size), cmap, kspc ? 0 : 2);
}
return 0;
}
static int platinum_set_cmap(struct fb_cmap *cmap, int kspc, int con,
struct fb_info *info)
/*
* Applies current var to display
*/
static int platinumfb_set_par (struct fb_info *info)
{
struct fb_info_platinum *p = (struct fb_info_platinum *) info;
struct platinum_regvals *init;
struct fb_par_platinum par;
int err;
struct display *disp;
if (con >= 0)
disp = &fb_display[con];
else
disp = info->disp;
if (!disp->cmap.len) { /* no colormap allocated? */
int size = disp->var.bits_per_pixel == 16 ? 32 : 256;
if ((err = fb_alloc_cmap(&disp->cmap, size, 0)))
if((err = platinum_var_to_par(&info->var, &par, p))) {
printk (KERN_ERR "platinumfb_set_par: error calling"
" platinum_var_to_par: %d.\n", err);
return err;
}
if (!info->display_fg ||
info->display_fg->vc_num == con) /* current console? */
return fb_set_cmap(cmap, kspc, info);
else
fb_copy_cmap(cmap, &disp->cmap, kspc ? 0 : 1);
return 0;
}
platinum_set_hardware(p, &par);
static int platinum_switch(int con, struct fb_info *fb)
{
struct fb_info_platinum *info = (struct fb_info_platinum *) fb;
struct fb_par_platinum par;
if (fb_display[fb->currcon].cmap.len)
fb_get_cmap(&fb_display[fb->currcon].cmap, 1, platinum_getcolreg,
fb);
fb->currcon = con;
platinum_var_to_par(&fb_display[con].var, &par, info);
platinum_set_par(&par, info);
platinum_set_dispsw(&fb_display[con], info, par.cmode, 0);
do_install_cmap(con, fb);
init = platinum_reg_init[p->par.vmode-1];
return 1;
}
info->screen_base = (char *) p->frame_buffer + init->fb_offset + 0x20;
info->fix.smem_start = (p->frame_buffer_phys) + init->fb_offset + 0x20;
info->fix.visual = (p->par.cmode == CMODE_8) ?
FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_DIRECTCOLOR;
info->fix.line_length = vmode_attrs[p->par.vmode-1].hres * (1<<p->par.cmode) + 0x20;
static int platinum_updatevar(int con, struct fb_info *fb)
{
printk(KERN_ERR "platinum_updatevar is doing nothing yet.\n");
return 0;
}
static int platinum_blank(int blank, struct fb_info *fb)
static int platinumfb_blank(int blank, struct fb_info *fb)
{
/*
* Blank the screen if blank_mode != 0, else unblank. If blank == NULL
......@@ -375,26 +206,11 @@ static int platinum_blank(int blank, struct fb_info *fb)
return 0;
}
static int platinum_getcolreg(u_int regno, u_int *red, u_int *green,
u_int *blue, u_int *transp, struct fb_info *fb)
static int platinumfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
u_int transp, struct fb_info *info)
{
struct fb_info_platinum *info = (struct fb_info_platinum *) fb;
if (regno > 255)
return 1;
*red = (info->palette[regno].red<<8) | info->palette[regno].red;
*green = (info->palette[regno].green<<8) | info->palette[regno].green;
*blue = (info->palette[regno].blue<<8) | info->palette[regno].blue;
*transp = 0;
return 0;
}
static int platinum_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
u_int transp, struct fb_info *fb)
{
struct fb_info_platinum *info = (struct fb_info_platinum *) fb;
volatile struct cmap_regs *cmap_regs = info->cmap_regs;
struct fb_info_platinum *p = (struct fb_info_platinum *) info;
volatile struct cmap_regs *cmap_regs = p->cmap_regs;
if (regno > 255)
return 1;
......@@ -403,23 +219,30 @@ static int platinum_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
green >>= 8;
blue >>= 8;
info->palette[regno].red = red;
info->palette[regno].green = green;
info->palette[regno].blue = blue;
p->palette[regno].red = red;
p->palette[regno].green = green;
p->palette[regno].blue = blue;
out_8(&cmap_regs->addr, regno); /* tell clut what addr to fill */
out_8(&cmap_regs->lut, red); /* send one color channel at */
out_8(&cmap_regs->lut, green); /* a time... */
out_8(&cmap_regs->lut, blue);
if(regno < 16) {
#ifdef FBCON_HAS_CFB16
info->fbcon_cmap.cfb16[regno] = (regno << 10) | (regno << 5) | (regno << 0);
#endif
#ifdef FBCON_HAS_CFB32
info->fbcon_cmap.cfb32[regno] = (regno << 24) | (regno << 16) | (regno << 8) | regno;
#endif
if (regno < 16) {
int i;
switch (p->par.cmode) {
case CMODE_16:
((u16 *) (info->pseudo_palette))[regno] =
(regno << 10) | (regno << 5) | regno;
break;
case CMODE_32:
i = (regno << 8) | regno;
((u32 *) (info->pseudo_palette))[regno] =
(i << 16) | i;
break;
}
}
return 0;
}
......@@ -439,7 +262,7 @@ static void set_platinum_clock(struct fb_info_platinum *info)
volatile struct cmap_regs *cmap_regs = info->cmap_regs;
struct platinum_regvals *init;
init = platinum_reg_init[info->current_par.vmode-1];
init = platinum_reg_init[info->par.vmode-1];
STORE_D2(6, 0xc6);
out_8(&cmap_regs->addr,3+32);
......@@ -461,7 +284,7 @@ static void set_platinum_clock(struct fb_info_platinum *info)
/* Now how about actually saying, Make it so! */
/* Some things in here probably don't need to be done each time. */
static void platinum_set_par(const struct fb_par_platinum *par, struct fb_info_platinum *info)
static void platinum_set_hardware(struct fb_info_platinum *info, const struct fb_par_platinum *par)
{
volatile struct platinum_regs *platinum_regs = info->platinum_regs;
volatile struct cmap_regs *cmap_regs = info->cmap_regs;
......@@ -469,7 +292,7 @@ static void platinum_set_par(const struct fb_par_platinum *par, struct fb_info_p
int i;
int vmode, cmode;
info->current_par = *par;
info->par = *par;
vmode = par->vmode;
cmode = par->cmode;
......@@ -509,15 +332,52 @@ static void platinum_set_par(const struct fb_par_platinum *par, struct fb_info_p
out_be32(&platinum_regs->reg[24].r, 0); /* turn display on */
}
/*
* Set misc info vars for this driver
*/
static void __init platinum_init_info(struct fb_info *info, struct fb_info_platinum *p)
{
/* Fill fb_info */
strcpy(info->modename, "platinum");
info->currcon = -1;
info->par = &p->par;
info->node = NODEV;
info->fbops = &platinumfb_ops;
info->disp = &p->display;
info->pseudo_palette = p->pseudo_palette;
info->flags = FBINFO_FLAG_DEFAULT;
strncpy (info->fontname, fontname, sizeof (info->fontname));
info->fontname[sizeof (info->fontname) - 1] = 0;
info->changevar = NULL;
info->display_fg = NULL;
info->screen_base = (char *) p->frame_buffer + 0x20;
info->changevar = NULL;
info->switch_con = gen_switch;
info->updatevar = gen_update_var;
fb_alloc_cmap(&info->cmap, 256, 0);
/* Fill fix common fields */
strcpy(info->fix.id, "platinum");
info->fix.mmio_start = p->platinum_regs_phys;
info->fix.mmio_len = 0x1000;
info->fix.type = FB_TYPE_PACKED_PIXELS;
info->fix.smem_start = p->frame_buffer_phys + 0x20; /* will be updated later */
info->fix.smem_len = p->total_vram - 0x20;
info->fix.ywrapstep = 0;
info->fix.xpanstep = 0;
info->fix.ypanstep = 0;
info->fix.type_aux = 0;
info->fix.accel = FB_ACCEL_NONE;
}
static int __init init_platinum(struct fb_info_platinum *info)
static int __init init_platinum(struct fb_info_platinum *p)
{
struct fb_var_screeninfo var;
struct display *disp;
int sense;
int j,k;
int sense, rc;
sense = read_platinum_sense(info);
sense = read_platinum_sense(p);
printk(KERN_INFO "Monitor sense value = 0x%x, ", sense);
if (default_vmode == VMODE_NVRAM) {
......@@ -538,44 +398,40 @@ static int __init init_platinum(struct fb_info_platinum *info)
/*
* Reduce the pixel size if we don't have enough VRAM.
*/
while(default_cmode > CMODE_8 && platinum_vram_reqd(default_vmode, default_cmode) > info->total_vram)
while(default_cmode > CMODE_8 && platinum_vram_reqd(default_vmode, default_cmode) > p->total_vram)
default_cmode--;
printk("using video mode %d and color mode %d.\n", default_vmode, default_cmode);
mac_vmode_to_var(default_vmode, default_cmode, &var);
if (platinum_var_to_par(&var, &info->default_par, info)) {
printk(KERN_ERR "platinumfb: can't set default video mode\n");
return 0;
/* Setup default var */
if (mac_vmode_to_var(default_vmode, default_cmode, &var) < 0) {
/* This shouldn't happen! */
printk("mac_vmode_to_var(%d, %d,) failed\n", default_vmode, default_cmode);
try_again:
default_vmode = VMODE_640_480_60;
default_cmode = CMODE_8;
if (mac_vmode_to_var(default_vmode, default_cmode, &var) < 0) {
printk(KERN_ERR "platinumfb: mac_vmode_to_var() failed\n");
return -ENXIO;
}
disp = &info->disp;
strcpy(info->fb_info.modename, "platinum");
info->fb_info.node = NODEV;
info->fb_info.fbops = &platinumfb_ops;
info->fb_info.disp = disp;
info->fb_info.currcon = -1;
strcpy(info->fb_info.fontname, fontname);
info->fb_info.changevar = NULL;
info->fb_info.switch_con = &platinum_switch;
info->fb_info.updatevar = &platinum_updatevar;
info->fb_info.flags = FBINFO_FLAG_DEFAULT;
for (j = 0; j < 16; j++) {
k = color_table[j];
info->palette[j].red = default_red[k];
info->palette[j].green = default_grn[k];
info->palette[j].blue = default_blu[k];
}
platinum_set_var(&var, -1, &info->fb_info);
if (register_framebuffer(&info->fb_info) < 0)
/* Initialize info structure */
platinum_init_info(&p->info, p);
/* Apply default var */
p->info.var = var;
var.activate = FB_ACTIVATE_NOW;
rc = gen_set_var(&var, -1, &p->info);
if (rc && (default_vmode != VMODE_640_480_60 || default_cmode != CMODE_8))
goto try_again;
/* Register with fbdev layer */
if (register_framebuffer(&p->info) < 0)
return 0;
printk(KERN_INFO "fb%d: platinum frame buffer device\n",
minor(info->fb_info.node));
GET_FB_IDX(p->info.node));
return 1;
}
......@@ -761,33 +617,6 @@ static int platinum_par_to_var(struct fb_var_screeninfo *var,
return mac_vmode_to_var(par->vmode, par->cmode, var);
}
static int platinum_encode_fix(struct fb_fix_screeninfo *fix,
const struct fb_par_platinum *par,
const struct fb_info_platinum *info)
{
struct platinum_regvals *init;
init = platinum_reg_init[par->vmode-1];
memset(fix, 0, sizeof(*fix));
strcpy(fix->id, "platinum");
fix->smem_start = (info->frame_buffer_phys) + init->fb_offset + 0x20;
fix->smem_len = (u32) info->total_vram;
fix->mmio_start = (info->platinum_regs_phys);
fix->mmio_len = 0x1000;
fix->type = FB_TYPE_PACKED_PIXELS;
fix->type_aux = 0;
fix->ywrapstep = 0;
fix->xpanstep = 0;
fix->ypanstep = 0;
fix->visual = (par->cmode == CMODE_8) ?
FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_DIRECTCOLOR;
fix->line_length = vmode_attrs[par->vmode-1].hres * (1<<par->cmode) + 0x20;
return 0;
}
/*
* Parse user speficied options (`video=platinumfb:')
*/
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -127,10 +127,6 @@ struct fb_info_valkyrie {
int valkyriefb_init(void);
int valkyriefb_setup(char*);
static int valkyrie_get_fix(struct fb_fix_screeninfo *fix, int con,
struct fb_info *info);
static int valkyrie_get_var(struct fb_var_screeninfo *var, int con,
struct fb_info *info);
static int valkyrie_set_var(struct fb_var_screeninfo *var, int con,
struct fb_info *info);
static int valkyrie_get_cmap(struct fb_cmap *cmap, int kspc, int con,
......@@ -157,8 +153,6 @@ static void valkyrie_init_fix(struct fb_fix_screeninfo *fix, struct fb_info_valk
static struct fb_ops valkyriefb_ops = {
.owner = THIS_MODULE,
.fb_get_fix = valkyrie_get_fix,
.fb_get_var = valkyrie_get_var,
.fb_set_var = valkyrie_set_var,
.fb_get_cmap = valkyrie_get_cmap,
.fb_set_cmap = gen_set_cmap,
......@@ -169,24 +163,6 @@ static struct fb_ops valkyriefb_ops = {
static int valkyriefb_getcolreg(u_int regno, u_int *red, u_int *green,
u_int *blue, u_int *transp, struct fb_info *info);
static int valkyrie_get_fix(struct fb_fix_screeninfo *fix, int con,
struct fb_info *info)
{
struct fb_info_valkyrie *cp = (struct fb_info_valkyrie *) info;
*fix = cp->fix;
return 0;
}
static int valkyrie_get_var(struct fb_var_screeninfo *var, int con,
struct fb_info *info)
{
struct fb_info_valkyrie *cp = (struct fb_info_valkyrie *) info;
*var = cp->var;
return 0;
}
/* Sets everything according to var */
static int valkyrie_set_var(struct fb_var_screeninfo *var, int con,
struct fb_info *info)
......@@ -471,7 +447,7 @@ static void __init init_valkyrie(struct fb_info_valkyrie *p)
return;
}
printk(KERN_INFO "fb%d: valkyrie frame buffer device\n", minor(p->info.node));
printk(KERN_INFO "fb%d: valkyrie frame buffer device\n", GET_FB_IDX(p->info.node));
}
static void valkyrie_set_par(const struct fb_par_valkyrie *par,
......@@ -705,7 +681,6 @@ static void valkyrie_par_to_fix(struct fb_par_valkyrie *par,
static void valkyrie_init_display(struct display *disp)
{
memset(disp, 0, sizeof(*disp));
disp->type = /* fix->type */ FB_TYPE_PACKED_PIXELS;
disp->can_soft_blank = can_soft_blank;
disp->scrollmode = SCROLL_YREDRAW;
}
......@@ -714,8 +689,6 @@ static void valkyrie_par_to_display(struct fb_par_valkyrie *par,
struct display *disp, struct fb_fix_screeninfo *fix, struct fb_info_valkyrie *p)
{
disp->var = p->var;
disp->visual = fix->visual;
disp->line_length = fix->line_length;
if(disp->scrollmode != SCROLL_YREDRAW) {
printk(KERN_ERR "Scroll mode not YREDRAW in valkyrie_par_to_display\n");
......
......@@ -301,12 +301,12 @@ struct fbcursor {
#define ROP_XOR 1
struct fb_copyarea {
__u32 sx; /* screen-relative */
__u32 sy;
__u32 dx;
__u32 dy;
__u32 width;
__u32 height;
__u32 sx;
__u32 sy;
};
struct fb_fillrect {
......
#ifndef __LINUX_RADEONFB_H__
#define __LINUX_RADEONFB_H__
#include <asm/ioctl.h>
#include <asm/types.h>
#define ATY_RADEON_LCD_ON 0x00000001
#define ATY_RADEON_CRT_ON 0x00000002
#define FBIO_RADEON_GET_MIRROR _IOR('@', 3, sizeof(__u32*))
#define FBIO_RADEON_SET_MIRROR _IOW('@', 4, sizeof(__u32*))
#endif
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