Commit 115f4504 authored by James Simmons's avatar James Simmons

Removed currcon and other console related code. Very little is now left.

parent 5916159c
...@@ -75,13 +75,11 @@ anakinfb_init(void) ...@@ -75,13 +75,11 @@ anakinfb_init(void)
memset(&fb_info, 0, sizeof(struct fb_info)); memset(&fb_info, 0, sizeof(struct fb_info));
fb_info.node = NODEV; fb_info.node = NODEV;
fb_info.currcon = -1;
fb_info.flags = FBINFO_FLAG_DEFAULT; fb_info.flags = FBINFO_FLAG_DEFAULT;
fb_info.fbops = &anakinfb_ops; fb_info.fbops = &anakinfb_ops;
fb_info.var = anakinfb_var; fb_info.var = anakinfb_var;
fb_info.fix = anakinfb_fix; fb_info.fix = anakinfb_fix;
strcpy(fb_info.fontname, "VGA8x16"); strcpy(fb_info.fontname, "VGA8x16");
fb_info.updatevar = gen_update_var;
if (!(request_mem_region(VGA_START, VGA_SIZE, "vga"))) if (!(request_mem_region(VGA_START, VGA_SIZE, "vga")))
return -ENOMEM; return -ENOMEM;
if (fb_info.screen_base = ioremap(VGA_START, VGA_SIZE)) { if (fb_info.screen_base = ioremap(VGA_START, VGA_SIZE)) {
......
...@@ -264,13 +264,11 @@ int __init clps711xfb_init(void) ...@@ -264,13 +264,11 @@ int __init clps711xfb_init(void)
memset(cfb, 0, sizeof(*cfb)); memset(cfb, 0, sizeof(*cfb));
memset((void *)PAGE_OFFSET, 0, 0x14000); memset((void *)PAGE_OFFSET, 0, 0x14000);
cfb->currcon = -1;
strcpy(cfb->fix.id, "clps7111"); strcpy(cfb->fix.id, "clps7111");
cfb->screen_base = (void *)PAGE_OFFSET; cfb->screen_base = (void *)PAGE_OFFSET;
cfb->fix.smem_start = PAGE_OFFSET; cfb->fix.smem_start = PAGE_OFFSET;
cfb->fix.smem_len = 0x14000; cfb->fix.smem_len = 0x14000;
cfb->fix.type = FB_TYPE_PACKED_PIXELS; cfb->fix.type = FB_TYPE_PACKED_PIXELS;
cfb->var.xres = 640; cfb->var.xres = 640;
cfb->var.xres_virtual = 640; cfb->var.xres_virtual = 640;
...@@ -283,7 +281,6 @@ int __init clps711xfb_init(void) ...@@ -283,7 +281,6 @@ int __init clps711xfb_init(void)
cfb->var.width = -1; cfb->var.width = -1;
cfb->fbops = &clps7111fb_ops; cfb->fbops = &clps7111fb_ops;
cfb->updatevar = gen_update_var;
cfb->flags = FBINFO_FLAG_DEFAULT; cfb->flags = FBINFO_FLAG_DEFAULT;
fb_alloc_cmap(&cfb->cmap, CMAP_SIZE, 0); fb_alloc_cmap(&cfb->cmap, CMAP_SIZE, 0);
......
...@@ -235,10 +235,8 @@ unsigned long __init dnfb_init(unsigned long mem_start) ...@@ -235,10 +235,8 @@ unsigned long __init dnfb_init(unsigned long mem_start)
int err; int err;
fb_info.fontname[0] = 0; fb_info.fontname[0] = 0;
fb_info.updatevar = gen_update_var;
fb_info.node = NODEV; fb_info.node = NODEV;
fb_info.fbops = &dn_fb_ops; fb_info.fbops = &dn_fb_ops;
fb_info.currcon = -1;
fb_info.fix = dnfb_fix; fb_info.fix = dnfb_fix;
fb_info.var = dnfb_var; fb_info.var = dnfb_var;
fb_info.screen_base = (u_char *) fb_info.fix.smem_start; fb_info.screen_base = (u_char *) fb_info.fix.smem_start;
......
...@@ -105,10 +105,9 @@ void fbcon_vga_planes_setup(struct display *p) ...@@ -105,10 +105,9 @@ void fbcon_vga_planes_setup(struct display *p)
void fbcon_vga_planes_bmove(struct display *p, int sy, int sx, int dy, int dx, void fbcon_vga_planes_bmove(struct display *p, int sy, int sx, int dy, int dx,
int height, int width) int height, int width)
{ {
char *src; struct fb_info *info = p->fb_info;
char *dest; char *dest, *src;
int line_ofs; int line_ofs, x;
int x;
setmode(1); setmode(1);
setop(0); setop(0);
...@@ -119,9 +118,9 @@ void fbcon_vga_planes_bmove(struct display *p, int sy, int sx, int dy, int dx, ...@@ -119,9 +118,9 @@ void fbcon_vga_planes_bmove(struct display *p, int sy, int sx, int dy, int dx,
height *= fontheight(p); height *= fontheight(p);
if (dy < sy || (dy == sy && dx < sx)) { if (dy < sy || (dy == sy && dx < sx)) {
line_ofs = p->fb_info->fix.line_length - width; line_ofs = info->fix.line_length - width;
dest = p->fb_info->screen_base + dx + dy * p->fb_info->fix.line_length; dest = info->screen_base + dx + dy * info->fix.line_length;
src = p->fb_info->screen_base + sx + sy * p->fb_info->fix.line_length; src = info->screen_base + sx + sy * info->fix.line_length;
while (height--) { while (height--) {
for (x = 0; x < width; x++) { for (x = 0; x < width; x++) {
readb(src); readb(src);
...@@ -133,9 +132,9 @@ void fbcon_vga_planes_bmove(struct display *p, int sy, int sx, int dy, int dx, ...@@ -133,9 +132,9 @@ void fbcon_vga_planes_bmove(struct display *p, int sy, int sx, int dy, int dx,
dest += line_ofs; dest += line_ofs;
} }
} else { } else {
line_ofs = p->fb_info->fix.line_length - width; line_ofs = info->fix.line_length - width;
dest = p->fb_info->screen_base + dx + width + (dy + height - 1) * p->fb_info->fix.line_length; dest = info->screen_base + dx + width + (dy + height - 1) * info->fix.line_length;
src = p->fb_info->screen_base + sx + width + (sy + height - 1) * p->fb_info->fix.line_length; src = info->screen_base + sx + width + (sy + height - 1) * info->fix.line_length;
while (height--) { while (height--) {
for (x = 0; x < width; x++) { for (x = 0; x < width; x++) {
dest--; dest--;
...@@ -177,137 +176,48 @@ void fbcon_vga_planes_clear(struct vc_data *conp, struct display *p, int sy, int ...@@ -177,137 +176,48 @@ void fbcon_vga_planes_clear(struct vc_data *conp, struct display *p, int sy, int
} }
} }
void fbcon_ega_planes_putc(struct vc_data *conp, struct display *p, int c, int yy, int xx) void fbcon_accel_putc(struct vc_data *vc, struct display *p, int c, int yy,
{ int xx)
int fg = attr_fgcol(p,c);
int bg = attr_bgcol(p,c);
int y;
u8 *cdat = p->fontdata + (c & p->charmask) * fontheight(p);
char *where = p->fb_info->screen_base + xx + yy * p->fb_info->fix.line_length * fontheight(p);
setmode(0);
setop(0);
setsr(0xf);
setcolor(bg);
selectmask();
setmask(0xff);
for (y = 0; y < fontheight(p); y++, where += p->fb_info->fix.line_length)
rmw(where);
where -= p->fb_info->fix.line_length * y;
setcolor(fg);
selectmask();
for (y = 0; y < fontheight(p); y++, where += p->fb_info->fix.line_length)
if (cdat[y]) {
setmask(cdat[y]);
rmw(where);
}
}
void fbcon_vga_planes_putc(struct vc_data *conp, struct display *p, int c, int yy, int xx)
{
int fg = attr_fgcol(p,c);
int bg = attr_bgcol(p,c);
int y;
u8 *cdat = p->fontdata + (c & p->charmask) * fontheight(p);
char *where = p->fb_info->screen_base + xx + yy * p->fb_info->fix.line_length * fontheight(p);
setmode(2);
setop(0);
setsr(0xf);
setcolor(fg);
selectmask();
setmask(0xff);
writeb(bg, where);
rmb();
readb(where); /* fill latches */
setmode(3);
wmb();
for (y = 0; y < fontheight(p); y++, where += p->fb_info->fix.line_length)
writeb(cdat[y], where);
wmb();
}
/* 28.50 in my test */
void fbcon_ega_planes_putcs(struct vc_data *conp, struct display *p, const unsigned short *s,
int count, int yy, int xx)
{ {
u16 c = scr_readw(s); struct fb_info *info = p->fb_info;
int fg = attr_fgcol(p, c); unsigned short charmask = p->charmask;
int bg = attr_bgcol(p, c); unsigned int width = ((fontwidth(p)+7)>>3);
struct fb_image image;
char *where;
int n; image.fg_color = attr_fgcol(p, c);
image.bg_color = attr_bgcol(p, c);
setmode(2); image.dx = xx * fontwidth(p);
setop(0); image.dy = yy * fontheight(p);
selectmask(); image.width = fontwidth(p);
image.height = fontheight(p);
setmask(0xff); image.depth = 1;
where = p->fb_info->screen_base + xx + yy * p->fb_info->fix.line_length * fontheight(p); image.data = p->fontdata + (c & charmask)*fontheight(p)*width;
writeb(bg, where);
rmb(); info->fbops->fb_imageblit(info, &image);
readb(where); /* fill latches */
wmb();
selectmask();
for (n = 0; n < count; n++) {
int c = scr_readw(s++) & p->charmask;
u8 *cdat = p->fontdata + c * fontheight(p);
u8 *end = cdat + fontheight(p);
while (cdat < end) {
outb(*cdat++, GRAPHICS_DATA_REG);
wmb();
writeb(fg, where);
where += p->fb_info->fix.line_length;
}
where += 1 - p->fb_info->fix.line_length * fontheight(p);
}
wmb();
} }
/* 6.96 in my test */ void fbcon_accel_putcs(struct vc_data *vc, struct display *p,
void fbcon_vga_planes_putcs(struct vc_data *conp, struct display *p, const unsigned short *s, const unsigned short *s, int count, int yy, int xx)
int count, int yy, int xx)
{ {
u16 c = scr_readw(s); struct fb_info *info = p->fb_info;
int fg = attr_fgcol(p, c); unsigned short charmask = p->charmask;
int bg = attr_bgcol(p, c); unsigned int width = ((fontwidth(p)+7)>>3);
struct fb_image image;
char *where;
int n; image.fg_color = attr_fgcol(p, *s);
image.bg_color = attr_bgcol(p, *s);
setmode(2); image.dx = xx * fontwidth(p);
setop(0); image.dy = yy * fontheight(p);
setsr(0xf); image.width = fontwidth(p);
setcolor(fg); image.height = fontheight(p);
selectmask(); image.depth = 1;
setmask(0xff); while (count--) {
where = p->fb_info->screen_base + xx + yy * p->fb_info->fix.line_length * fontheight(p); image.data = p->fontdata +
writeb(bg, where); (scr_readw(s++) & charmask) * fontheight(p) * width;
rmb(); info->fbops->fb_imageblit(info, &image);
readb(where); /* fill latches */ image.dx += fontwidth(p);
setmode(3); }
wmb();
for (n = 0; n < count; n++) {
int y;
int c = scr_readw(s++) & p->charmask;
u8 *cdat = p->fontdata + (c & p->charmask) * fontheight(p);
for (y = 0; y < fontheight(p); y++, cdat++) {
writeb (*cdat, where);
where += p->fb_info->fix.line_length;
}
where += 1 - p->fb_info->fix.line_length * fontheight(p);
}
wmb();
} }
void fbcon_vga_planes_revc(struct display *p, int xx, int yy) void fbcon_vga_planes_revc(struct display *p, int xx, int yy)
...@@ -332,18 +242,8 @@ struct display_switch fbcon_vga_planes = { ...@@ -332,18 +242,8 @@ struct display_switch fbcon_vga_planes = {
setup: fbcon_vga_planes_setup, setup: fbcon_vga_planes_setup,
bmove: fbcon_vga_planes_bmove, bmove: fbcon_vga_planes_bmove,
clear: fbcon_vga_planes_clear, clear: fbcon_vga_planes_clear,
putc: fbcon_vga_planes_putc, putc: fbcon_accel_putc,
putcs: fbcon_vga_planes_putcs, putcs: fbcon_accel_putcs,
revc: fbcon_vga_planes_revc,
fontwidthmask: FONTWIDTH(8)
};
struct display_switch fbcon_ega_planes = {
setup: fbcon_vga_planes_setup,
bmove: fbcon_vga_planes_bmove,
clear: fbcon_vga_planes_clear,
putc: fbcon_ega_planes_putc,
putcs: fbcon_ega_planes_putcs,
revc: fbcon_vga_planes_revc, revc: fbcon_vga_planes_revc,
fontwidthmask: FONTWIDTH(8) fontwidthmask: FONTWIDTH(8)
}; };
...@@ -369,14 +269,8 @@ EXPORT_SYMBOL(fbcon_vga_planes); ...@@ -369,14 +269,8 @@ EXPORT_SYMBOL(fbcon_vga_planes);
EXPORT_SYMBOL(fbcon_vga_planes_setup); EXPORT_SYMBOL(fbcon_vga_planes_setup);
EXPORT_SYMBOL(fbcon_vga_planes_bmove); EXPORT_SYMBOL(fbcon_vga_planes_bmove);
EXPORT_SYMBOL(fbcon_vga_planes_clear); EXPORT_SYMBOL(fbcon_vga_planes_clear);
EXPORT_SYMBOL(fbcon_vga_planes_putc);
EXPORT_SYMBOL(fbcon_vga_planes_putcs);
EXPORT_SYMBOL(fbcon_vga_planes_revc); EXPORT_SYMBOL(fbcon_vga_planes_revc);
EXPORT_SYMBOL(fbcon_ega_planes);
EXPORT_SYMBOL(fbcon_ega_planes_putc);
EXPORT_SYMBOL(fbcon_ega_planes_putcs);
/* /*
* Overrides for Emacs so that we follow Linus's tabbing style. * Overrides for Emacs so that we follow Linus's tabbing style.
* --------------------------------------------------------------------------- * ---------------------------------------------------------------------------
......
...@@ -749,6 +749,7 @@ register_framebuffer(struct fb_info *fb_info) ...@@ -749,6 +749,7 @@ register_framebuffer(struct fb_info *fb_info)
if (!registered_fb[i]) if (!registered_fb[i])
break; break;
fb_info->node = mk_kdev(FB_MAJOR, i); fb_info->node = mk_kdev(FB_MAJOR, i);
fb_info->currcon = -1;
registered_fb[i] = fb_info; registered_fb[i] = fb_info;
if (!fb_ever_opened[i]) { if (!fb_ever_opened[i]) {
struct module *owner = fb_info->fbops->owner; struct module *owner = fb_info->fbops->owner;
......
...@@ -268,8 +268,6 @@ int __init fm2fb_init(void) ...@@ -268,8 +268,6 @@ int __init fm2fb_init(void)
fb_info.flags = FBINFO_FLAG_DEFAULT; fb_info.flags = FBINFO_FLAG_DEFAULT;
/* The below feilds will go away !!!! */ /* The below feilds will go away !!!! */
fb_info.currcon = -1;
fb_info.updatevar = gen_update_var;
fb_alloc_cmap(&fb_info.cmap, 16, 0); fb_alloc_cmap(&fb_info.cmap, 16, 0);
if (register_framebuffer(&fb_info) < 0) if (register_framebuffer(&fb_info) < 0)
......
...@@ -243,9 +243,7 @@ int __init g364fb_init(void) ...@@ -243,9 +243,7 @@ int __init g364fb_init(void)
fb_info.fix = fb_fix; fb_info.fix = fb_fix;
fb_info.flags = FBINFO_FLAG_DEFAULT; fb_info.flags = FBINFO_FLAG_DEFAULT;
fb_info.currcon = -1;
fb_info.fontname[0] = '\0'; fb_info.fontname[0] = '\0';
fb_info.updatevar = gen_update_var;
fb_alloc_cmap(&fb_info.cmap, 255, 0); fb_alloc_cmap(&fb_info.cmap, 255, 0);
if (register_framebuffer(&fb_info) < 0) if (register_framebuffer(&fb_info) < 0)
......
...@@ -162,8 +162,6 @@ int __init hitfb_init(void) ...@@ -162,8 +162,6 @@ int __init hitfb_init(void)
fb_info.pseudo_palette = pseudo_palette; fb_info.pseudo_palette = pseudo_palette;
fb_info.flags = FBINFO_FLAG_DEFAULT; fb_info.flags = FBINFO_FLAG_DEFAULT;
fb_info.currcon = -1;
fb_info.updatevar = gen_update_var;
fb_info.screen_base = (void *) hitfb_fix.smem_start; fb_info.screen_base = (void *) hitfb_fix.smem_start;
size = (fb_info.var.bits_per_pixel == 8) ? 256 : 16; size = (fb_info.var.bits_per_pixel == 8) ? 256 : 16;
......
...@@ -158,9 +158,6 @@ int __init hpfb_init_one(unsigned long base) ...@@ -158,9 +158,6 @@ int __init hpfb_init_one(unsigned long base)
fb_info.fix = hpfb_fix; fb_info.fix = hpfb_fix;
fb_info.screen_base = (char *)hpfb_fix.smem_start; // FIXME fb_info.screen_base = (char *)hpfb_fix.smem_start; // FIXME
/* The below feilds will go away !!!! */
fb_info.currcon = -1;
fb_info.updatevar = gen_update_var;
fb_alloc_cmap(&fb_info.cmap, 256, 0); fb_alloc_cmap(&fb_info.cmap, 256, 0);
if (register_framebuffer(&fb_info) < 0) if (register_framebuffer(&fb_info) < 0)
......
...@@ -530,9 +530,7 @@ static void __init offb_init_fb(const char *name, const char *full_name, ...@@ -530,9 +530,7 @@ static void __init offb_init_fb(const char *name, const char *full_name,
info->screen_base = ioremap(address, fix->smem_len); info->screen_base = ioremap(address, fix->smem_len);
info->par = par; info->par = par;
info->pseudo_palette = (void *) (info + 1); info->pseudo_palette = (void *) (info + 1);
info->currcon = -1;
info->fontname[0] = '\0'; info->fontname[0] = '\0';
info->updatevar = gen_update_var;
info->flags = FBINFO_FLAG_DEFAULT; info->flags = FBINFO_FLAG_DEFAULT;
fb_alloc_cmap(&info->cmap, 256, 0); fb_alloc_cmap(&info->cmap, 256, 0);
......
...@@ -36,8 +36,6 @@ ...@@ -36,8 +36,6 @@
#include <asm/dec/tc.h> #include <asm/dec/tc.h>
#include "pmag-ba-fb.h" #include "pmag-ba-fb.h"
#include <video/fbcon.h>
struct pmag_ba_ramdac_regs { struct pmag_ba_ramdac_regs {
unsigned char addr_low; unsigned char addr_low;
unsigned char pad0[3]; unsigned char pad0[3];
......
...@@ -112,8 +112,6 @@ int q40fb_init(void) ...@@ -112,8 +112,6 @@ int q40fb_init(void)
fb_info.screen_base = (char *) q40fb_fix.smem_start; fb_info.screen_base = (char *) q40fb_fix.smem_start;
/* The below feilds will go away !!!! */ /* The below feilds will go away !!!! */
fb_info.currcon = -1;
fb_info.updatevar = gen_update_var;
fb_alloc_cmap(&fb_info.cmap, 16, 0); fb_alloc_cmap(&fb_info.cmap, 16, 0);
master_outb(3, DISPLAY_CONTROL_REG); master_outb(3, DISPLAY_CONTROL_REG);
......
...@@ -719,8 +719,6 @@ int __init sgivwfb_init(void) ...@@ -719,8 +719,6 @@ int __init sgivwfb_init(void)
fb_info.fbops = &sgivwfb_ops; fb_info.fbops = &sgivwfb_ops;
fb_info.pseudo_palette = pseudo_palette; fb_info.pseudo_palette = pseudo_palette;
fb_info.par = &default_par; fb_info.par = &default_par;
fb_info.currcon = -1;
fb_info.updatevar = gen_update_var;
fb_info.flags = FBINFO_FLAG_DEFAULT; fb_info.flags = FBINFO_FLAG_DEFAULT;
fb_info.screen_base = fb_info.screen_base =
......
...@@ -418,15 +418,6 @@ int __init xxxfb_init(void) ...@@ -418,15 +418,6 @@ int __init xxxfb_init(void)
info.flags = FBINFO_FLAG_DEFAULT; info.flags = FBINFO_FLAG_DEFAULT;
info.par = current_par; 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;
/* /*
* This should give a reasonable default video mode. The following is * This should give a reasonable default video mode. The following is
* done when we can set a video mode. * done when we can set a video mode.
......
...@@ -1074,11 +1074,6 @@ static int __devinit tdfxfb_probe(struct pci_dev *pdev, ...@@ -1074,11 +1074,6 @@ static int __devinit tdfxfb_probe(struct pci_dev *pdev,
info->pseudo_palette = (void *)(info->par + 1); info->pseudo_palette = (void *)(info->par + 1);
info->flags = FBINFO_FLAG_DEFAULT; info->flags = FBINFO_FLAG_DEFAULT;
/* The below fields will go away !!!! */
strcpy(info->modename, info->fix.id);
info->currcon = -1;
info->updatevar = gen_update_var;
if (!mode_option) if (!mode_option)
mode_option = "640x480@60"; mode_option = "640x480@60";
......
...@@ -292,12 +292,10 @@ int __init tx3912fb_init(void) ...@@ -292,12 +292,10 @@ int __init tx3912fb_init(void)
return -ENOMEM; return -ENOMEM;
fb_info.node = NODEV; fb_info.node = NODEV;
fb_info.currcon = -1;
fb_info.fbops = &tx3912fb_ops; fb_info.fbops = &tx3912fb_ops;
fb_info.var = tx3912fb_var; fb_info.var = tx3912fb_var;
fb_info.fix = tx3912fb_fix; fb_info.fix = tx3912fb_fix;
fb_info.pseudo_palette = pseudo_palette; fb_info.pseudo_palette = pseudo_palette;
fb_info.updatevar = gen_update_var;
fb_info.flags = FBINFO_FLAG_DEFAULT; fb_info.flags = FBINFO_FLAG_DEFAULT;
/* Clear the framebuffer */ /* Clear the framebuffer */
......
...@@ -348,7 +348,6 @@ int __init vesafb_init(void) ...@@ -348,7 +348,6 @@ int __init vesafb_init(void)
fb_info.fbops = &vesafb_ops; fb_info.fbops = &vesafb_ops;
fb_info.var = vesafb_defined; fb_info.var = vesafb_defined;
fb_info.fix = vesafb_fix; fb_info.fix = vesafb_fix;
fb_info.currcon = -1;
fb_info.updatevar = gen_update_var; fb_info.updatevar = gen_update_var;
fb_info.pseudo_palette = pseudo_palette; fb_info.pseudo_palette = pseudo_palette;
fb_info.flags = FBINFO_FLAG_DEFAULT; fb_info.flags = FBINFO_FLAG_DEFAULT;
......
...@@ -439,9 +439,6 @@ int __init vfb_init(void) ...@@ -439,9 +439,6 @@ int __init vfb_init(void)
fb_info.pseudo_palette = &vfb_pseudo_palette; fb_info.pseudo_palette = &vfb_pseudo_palette;
fb_info.flags = FBINFO_FLAG_DEFAULT; fb_info.flags = FBINFO_FLAG_DEFAULT;
fb_info.currcon = -1;
fb_info.updatevar = gen_update_var;
fb_alloc_cmap(&fb_info.cmap, 256, 0); fb_alloc_cmap(&fb_info.cmap, 256, 0);
if (register_framebuffer(&fb_info) < 0) { if (register_framebuffer(&fb_info) < 0) {
......
...@@ -27,10 +27,22 @@ ...@@ -27,10 +27,22 @@
#include <video/fbcon.h> #include <video/fbcon.h>
#include <video/fbcon-vga-planes.h> #include <video/fbcon-vga-planes.h>
#include <video/fbcon-vga.h>
#include <video/fbcon-cfb4.h>
#include <video/fbcon-cfb8.h>
#include "vga.h" #include "vga.h"
#define dac_reg (0x3c8) #define GRAPHICS_ADDR_REG 0x3ce /* Graphics address register. */
#define dac_val (0x3c9) #define GRAPHICS_DATA_REG 0x3cf /* Graphics data register. */
#define SET_RESET_INDEX 0 /* Set/Reset Register index. */
#define ENABLE_SET_RESET_INDEX 1 /* Enable Set/Reset Register index. */
#define DATA_ROTATE_INDEX 3 /* Data Rotate Register index. */
#define GRAPHICS_MODE_INDEX 5 /* Graphics Mode Register index. */
#define BIT_MASK_INDEX 8 /* Bit Mask Register index. */
#define dac_reg (VGA_PEL_IW)
#define dac_val (VGA_PEL_D)
#define VGA_FB_PHYS 0xA0000 #define VGA_FB_PHYS 0xA0000
#define VGA_FB_PHYS_LEN 65536 #define VGA_FB_PHYS_LEN 65536
...@@ -41,11 +53,9 @@ ...@@ -41,11 +53,9 @@
* card parameters * card parameters
*/ */
static struct vga16fb_info { static struct fb_info vga16fb;
struct fb_info fb_info;
char *video_vbase; /* 0xa0000 map address */ static struct vga16fb_par {
int isVGA;
/* structure holding original VGA register settings when the /* structure holding original VGA register settings when the
screen is blanked */ screen is blanked */
struct { struct {
...@@ -62,145 +72,246 @@ static struct vga16fb_info { ...@@ -62,145 +72,246 @@ static struct vga16fb_info {
unsigned char ModeControl; /* CRT-Controller:17h */ unsigned char ModeControl; /* CRT-Controller:17h */
unsigned char ClockingMode; /* Seq-Controller:01h */ unsigned char ClockingMode; /* Seq-Controller:01h */
} vga_state; } vga_state;
int palette_blanked, vesa_blanked, mode, isVGA;
int palette_blanked; u8 misc, pel_msk, vss, clkdiv;
int vesa_blanked;
} vga16fb;
struct vga16fb_par {
u8 crtc[VGA_CRT_C]; u8 crtc[VGA_CRT_C];
u8 atc[VGA_ATT_C]; } vga16_par;
u8 gdc[VGA_GFX_C];
u8 seq[VGA_SEQ_C];
u8 misc;
u8 vss;
struct fb_var_screeninfo var;
};
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
static struct fb_var_screeninfo vga16fb_defined = { static struct fb_var_screeninfo vga16fb_defined = {
640,480,640,480,/* W,H, W, H (virtual) load xres,xres_virtual*/ .xres = 640,
0,0, /* virtual -> visible no offset */ .yres = 480,
4, /* depth -> load bits_per_pixel */ .xres_virtual = 640,
0, /* greyscale ? */ .yres_virtual = 480,
{0,0,0}, /* R */ .bits_per_pixel = 4,
{0,0,0}, /* G */ .activate = FB_ACTIVATE_NOW,
{0,0,0}, /* B */ .height = -1,
{0,0,0}, /* transparency */ .width = -1,
0, /* standard pixel format */ .pixclock = 39721,
FB_ACTIVATE_NOW, .left_margin = 48,
-1,-1, .right_margin = 16,
0, .upper_margin = 39,
39721, 48, 16, 39, 8, .lower_margin = 8,
96, 2, 0, /* No sync info */ .hsync_len = 96,
FB_VMODE_NONINTERLACED, .vsync_len = 2,
{0,0,0,0,0,0} .vmode = FB_VMODE_NONINTERLACED,
};
/* name should not depend on EGA/VGA */
static struct fb_fix_screeninfo vga16fb_fix __initdata = {
.id = "VGA16 VGA",
.smem_start = VGA_FB_PHYS,
.smem_len = VGA_FB_PHYS_LEN,
.type = FB_TYPE_VGA_PLANES,
.type_aux = FB_AUX_VGA_PLANES_VGA4,
.visual = FB_VISUAL_PSEUDOCOLOR,
.xpanstep = 8,
.ypanstep = 1,
.line_length = 640/8,
.accel = FB_ACCEL_NONE
}; };
static struct display disp; static struct display disp;
static struct { u_short blue, green, red, pad; } palette[256];
/* --------------------------------------------------------------------- */ /* The VGA's weird architecture often requires that we read a byte and
write a byte to the same location. It doesn't matter *what* byte
we write, however. This is because all the action goes on behind
the scenes in the VGA's 32-bit latch register, and reading and writing
video memory just invokes latch behavior.
To avoid race conditions (is this necessary?), reading and writing
the memory byte should be done with a single instruction. One
suitable instruction is the x86 bitwise OR. The following
read-modify-write routine should optimize to one such bitwise
OR. */
static inline void rmw(volatile char *p)
{
readb(p);
writeb(1, p);
}
static void vga16fb_pan_var(struct fb_info *info, struct fb_var_screeninfo *var) /* Set the Graphics Mode Register. Bits 0-1 are write mode, bit 3 is
read mode. */
static inline void setmode(int mode)
{ {
u32 pos = (var->xres_virtual * var->yoffset + var->xoffset) >> 3; outb(GRAPHICS_MODE_INDEX, GRAPHICS_ADDR_REG);
outb(VGA_CRTC_START_HI, VGA_CRT_IC); outb(mode, GRAPHICS_DATA_REG);
outb(pos >> 8, VGA_CRT_DC);
outb(VGA_CRTC_START_LO, VGA_CRT_IC);
outb(pos & 0xFF, VGA_CRT_DC);
#if 0
/* if someone supports xoffset in bit resolution */
inb(VGA_IS1_RC); /* reset flip-flop */
outb(VGA_ATC_PEL, VGA_ATT_IW);
outb(xoffset & 7, VGA_ATT_IW);
inb(VGA_IS1_RC);
outb(0x20, VGA_ATT_IW);
#endif
} }
static int vga16fb_update_var(int con, struct fb_info *info) /* Select the Bit Mask Register. */
static inline void selectmask(void)
{ {
vga16fb_pan_var(info, &fb_display[con].var); outb(BIT_MASK_INDEX, GRAPHICS_ADDR_REG);
return 0;
} }
static int vga16fb_get_fix(struct fb_fix_screeninfo *fix, int con, /* Set the value of the Bit Mask Register. It must already have been
struct fb_info *info) selected with selectmask(). */
static inline void setmask(int mask)
{ {
struct display *p; outb(mask, GRAPHICS_DATA_REG);
}
if (con < 0) /* Set the Data Rotate Register. Bits 0-2 are rotate count, bits 3-4
p = &disp; are logical operation (0=NOP, 1=AND, 2=OR, 3=XOR). */
else static inline void setop(int op)
p = fb_display + con; {
outb(DATA_ROTATE_INDEX, GRAPHICS_ADDR_REG);
memset(fix, 0, sizeof(struct fb_fix_screeninfo)); outb(op, GRAPHICS_DATA_REG);
strcpy(fix->id,"VGA16 VGA"); }
fix->smem_start = VGA_FB_PHYS; /* Set the Enable Set/Reset Register. The code here always uses value
fix->smem_len = VGA_FB_PHYS_LEN; 0xf for this register. */
fix->type = FB_TYPE_VGA_PLANES; static inline void setsr(int sr)
fix->visual = FB_VISUAL_PSEUDOCOLOR; {
fix->xpanstep = 8; outb(ENABLE_SET_RESET_INDEX, GRAPHICS_ADDR_REG);
fix->ypanstep = 1; outb(sr, GRAPHICS_DATA_REG);
fix->ywrapstep = 0;
fix->line_length = p->var.xres_virtual / 8;
return 0;
} }
static int vga16fb_get_var(struct fb_var_screeninfo *var, int con, /* Set the Set/Reset Register. */
struct fb_info *info) static inline void setcolor(int color)
{ {
if(con==-1) outb(SET_RESET_INDEX, GRAPHICS_ADDR_REG);
memcpy(var, &vga16fb_defined, sizeof(struct fb_var_screeninfo)); outb(color, GRAPHICS_DATA_REG);
}
/* Set the value in the Graphics Address Register. */
static inline void setindex(int index)
{
outb(index, GRAPHICS_ADDR_REG);
}
static void vga16fb_pan_var(struct fb_info *info,
struct fb_var_screeninfo *var)
{
struct display *p;
u32 xoffset, pos;
p = (info->currcon < 0) ? info->disp : fb_display + info->currcon;
xoffset = var->xoffset;
if (info->var.bits_per_pixel == 8) {
pos = (info->var.xres_virtual * var->yoffset + xoffset) >> 2;
} else if (info->var.bits_per_pixel == 0) {
int fh = fontheight(p);
if (!fh) fh = 16;
pos = (info->var.xres_virtual * (var->yoffset / fh) + xoffset) >> 3;
} else {
if (info->var.nonstd)
xoffset--;
pos = (info->var.xres_virtual * var->yoffset + xoffset) >> 3;
}
vga_io_wcrt(VGA_CRTC_START_HI, pos >> 8);
vga_io_wcrt(VGA_CRTC_START_LO, pos & 0xFF);
/* if we support CFB4, then we must! support xoffset with pixel granularity */
/* if someone supports xoffset in bit resolution */
vga_io_r(VGA_IS1_RC); /* reset flip-flop */
vga_io_w(VGA_ATT_IW, VGA_ATC_PEL);
if (var->bits_per_pixel == 8)
vga_io_w(VGA_ATT_IW, (xoffset & 3) << 1);
else else
*var=fb_display[con].var; vga_io_w(VGA_ATT_IW, xoffset & 7);
vga_io_r(VGA_IS1_RC);
vga_io_w(VGA_ATT_IW, 0x20);
}
static int vga16fb_update_var(int con, struct fb_info *info)
{
vga16fb_pan_var(info, &info->var);
return 0; return 0;
} }
static void vga16fb_set_disp(int con, struct vga16fb_info *info) static void vga16fb_update_fix(struct fb_info *info)
{
if (info->var.bits_per_pixel == 4) {
if (info->var.nonstd) {
info->fix.type = FB_TYPE_PACKED_PIXELS;
info->fix.line_length = info->var.xres_virtual / 2;
} else {
info->fix.type = FB_TYPE_VGA_PLANES;
info->fix.type_aux = FB_AUX_VGA_PLANES_VGA4;
info->fix.line_length = info->var.xres_virtual / 8;
}
} else if (info->var.bits_per_pixel == 0) {
info->fix.type = FB_TYPE_TEXT;
info->fix.type_aux = FB_AUX_TEXT_CGA;
info->fix.line_length = info->var.xres_virtual / 4;
} else { /* 8bpp */
if (info->var.nonstd) {
info->fix.type = FB_TYPE_VGA_PLANES;
info->fix.type_aux = FB_AUX_VGA_PLANES_CFB8;
info->fix.line_length = info->var.xres_virtual / 4;
} else {
info->fix.type = FB_TYPE_PACKED_PIXELS;
info->fix.line_length = info->var.xres_virtual;
}
}
}
static void vga16fb_set_disp(int con, struct fb_info *info)
{ {
struct fb_fix_screeninfo fix; struct vga16fb_par *par = (struct vga16fb_par *) info->par;
struct display *display; struct display *display;
if (con < 0) display = (con < 0) ? info->disp : fb_display + con;
display = &disp;
else
display = fb_display + con;
if (con != info->currcon) {
vga16fb_get_fix(&fix, con, &info->fb_info); display->dispsw = &fbcon_dummy;
return;
display->visual = fix.visual; }
display->type = fix.type;
display->type_aux = fix.type_aux; if (info->fix.visual == FB_VISUAL_PSEUDOCOLOR ||
display->ypanstep = fix.ypanstep; info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
display->ywrapstep = fix.ywrapstep; display->can_soft_blank = info->fbops->fb_blank ? 1 : 0;
display->line_length = fix.line_length; display->dispsw_data = NULL;
display->next_line = fix.line_length; } else {
display->can_soft_blank = 0;
display->dispsw_data = info->pseudo_palette;
}
display->var = info->var;
vga16fb_update_fix(info);
display->next_line = info->fix.line_length;
display->can_soft_blank = 1; display->can_soft_blank = 1;
display->inverse = 0; display->inverse = 0;
if (info->isVGA) switch (info->fix.type) {
display->dispsw = &fbcon_vga_planes; #ifdef FBCON_HAS_VGA_PLANES
else case FB_TYPE_VGA_PLANES:
display->dispsw = &fbcon_ega_planes; if (info->fix.type_aux == FB_AUX_VGA_PLANES_VGA4) {
display->scrollmode = SCROLL_YREDRAW; display->dispsw = &fbcon_vga_planes;
} } else
display->dispsw = &fbcon_vga8_planes;
static void vga16fb_encode_var(struct fb_var_screeninfo *var, break;
const struct vga16fb_par *par, #endif
const struct vga16fb_info *info) #ifdef FBCON_HAS_VGA
{ case FB_TYPE_TEXT:
*var = par->var; display->dispsw = &fbcon_vga;
break;
#endif
default: /* only FB_TYPE_PACKED_PIXELS */
switch (info->var.bits_per_pixel) {
#ifdef FBCON_HAS_CFB4
case 4:
display->dispsw = &fbcon_cfb4;
break;
#endif
#ifdef FBCON_HAS_CFB8
case 8:
display->dispsw = &fbcon_cfb8;
break;
#endif
default:
display->dispsw = &fbcon_dummy;
}
break;
}
} }
static void vga16fb_clock_chip(struct vga16fb_par *par, static void vga16fb_clock_chip(struct vga16fb_par *par,
unsigned int pixclock, unsigned int pixclock,
const struct vga16fb_info *info) const struct fb_info *info,
int mul, int div)
{ {
static struct { static struct {
u32 pixclock; u32 pixclock;
...@@ -214,6 +325,7 @@ static void vga16fb_clock_chip(struct vga16fb_par *par, ...@@ -214,6 +325,7 @@ static void vga16fb_clock_chip(struct vga16fb_par *par,
{ 0 /* bad */, 0x00, 0x00}}; { 0 /* bad */, 0x00, 0x00}};
int err; int err;
pixclock = (pixclock * mul) / div;
best = vgaclocks; best = vgaclocks;
err = pixclock - best->pixclock; err = pixclock - best->pixclock;
if (err < 0) err = -err; if (err < 0) err = -err;
...@@ -228,25 +340,90 @@ static void vga16fb_clock_chip(struct vga16fb_par *par, ...@@ -228,25 +340,90 @@ static void vga16fb_clock_chip(struct vga16fb_par *par,
} }
} }
par->misc |= best->misc; par->misc |= best->misc;
par->seq[VGA_SEQ_CLOCK_MODE] |= best->seq_clock_mode; par->clkdiv = best->seq_clock_mode;
par->var.pixclock = best->pixclock; pixclock = (best->pixclock * div) / mul;
} }
#define FAIL(X) return -EINVAL #define FAIL(X) return -EINVAL
static int vga16fb_decode_var(const struct fb_var_screeninfo *var, #define MODE_SKIP4 1
struct vga16fb_par *par, #define MODE_8BPP 2
const struct vga16fb_info *info) #define MODE_CFB 4
#define MODE_TEXT 8
static int vga16fb_check_var(struct fb_var_screeninfo *var,
struct fb_info *info)
{ {
#ifdef FBCON_HAS_VGA
struct display *p = (info->currcon < 0) ? info->disp : (fb_display + info->currcon);
#endif
struct vga16fb_par *par = (struct vga16fb_par *) info->par;
u32 xres, right, hslen, left, xtotal; u32 xres, right, hslen, left, xtotal;
u32 yres, lower, vslen, upper, ytotal; u32 yres, lower, vslen, upper, ytotal;
u32 vxres, xoffset, vyres, yoffset; u32 vxres, xoffset, vyres, yoffset;
u32 pos; u32 pos;
u8 r7, rMode; u8 r7, rMode;
int i; int shift;
int mode;
if (var->bits_per_pixel != 4) u32 maxmem;
par->pel_msk = 0xFF;
if (var->bits_per_pixel == 4) {
if (var->nonstd) {
#ifdef FBCON_HAS_CFB4
if (!par->isVGA)
return -EINVAL;
shift = 3;
mode = MODE_SKIP4 | MODE_CFB;
maxmem = 16384;
par->pel_msk = 0x0F;
#else
return -EINVAL;
#endif
} else {
#ifdef FBCON_HAS_VGA_PLANES
shift = 3;
mode = 0;
maxmem = 65536;
#else
return -EINVAL;
#endif
}
} else if (var->bits_per_pixel == 8) {
if (!par->isVGA)
return -EINVAL; /* no support on EGA */
shift = 2;
if (var->nonstd) {
#ifdef FBCON_HAS_VGA_PLANES
mode = MODE_8BPP | MODE_CFB;
maxmem = 65536;
#else
return -EINVAL;
#endif
} else {
#ifdef FBCON_HAS_CFB8
mode = MODE_SKIP4 | MODE_8BPP | MODE_CFB;
maxmem = 16384;
#else
return -EINVAL;
#endif
}
}
#ifdef FBCON_HAS_VGA
else if (var->bits_per_pixel == 0) {
int fh;
shift = 3;
mode = MODE_TEXT;
fh = fontheight(p);
if (!fh)
fh = 16;
maxmem = 32768 * fh;
}
#endif
else
return -EINVAL; return -EINVAL;
xres = (var->xres + 7) & ~7; xres = (var->xres + 7) & ~7;
vxres = (var->xres_virtual + 0xF) & ~0xF; vxres = (var->xres_virtual + 0xF) & ~0xF;
xoffset = (var->xoffset + 7) & ~7; xoffset = (var->xoffset + 7) & ~7;
...@@ -259,18 +436,18 @@ static int vga16fb_decode_var(const struct fb_var_screeninfo *var, ...@@ -259,18 +436,18 @@ static int vga16fb_decode_var(const struct fb_var_screeninfo *var,
if (xres + xoffset > vxres) if (xres + xoffset > vxres)
xoffset = vxres - xres; xoffset = vxres - xres;
par->var.xres = xres; var->xres = xres;
par->var.right_margin = right; var->right_margin = right;
par->var.hsync_len = hslen; var->hsync_len = hslen;
par->var.left_margin = left; var->left_margin = left;
par->var.xres_virtual = vxres; var->xres_virtual = vxres;
par->var.xoffset = xoffset; var->xoffset = xoffset;
xres >>= 3; xres >>= shift;
right >>= 3; right >>= shift;
hslen >>= 3; hslen >>= shift;
left >>= 3; left >>= shift;
vxres >>= 3; vxres >>= shift;
xtotal = xres + right + hslen + left; xtotal = xres + right + hslen + left;
if (xtotal >= 256) if (xtotal >= 256)
FAIL("xtotal too big"); FAIL("xtotal too big");
...@@ -299,19 +476,19 @@ static int vga16fb_decode_var(const struct fb_var_screeninfo *var, ...@@ -299,19 +476,19 @@ static int vga16fb_decode_var(const struct fb_var_screeninfo *var,
if (yres > vyres) if (yres > vyres)
vyres = yres; vyres = yres;
if (vxres * vyres > 65536) { if (vxres * vyres > maxmem) {
vyres = 65536 / vxres; vyres = maxmem / vxres;
if (vyres < yres) if (vyres < yres)
return -ENOMEM; return -ENOMEM;
} }
if (yoffset + yres > vyres) if (yoffset + yres > vyres)
yoffset = vyres - yres; yoffset = vyres - yres;
par->var.yres = yres; var->yres = yres;
par->var.lower_margin = lower; var->lower_margin = lower;
par->var.vsync_len = vslen; var->vsync_len = vslen;
par->var.upper_margin = upper; var->upper_margin = upper;
par->var.yres_virtual = vyres; var->yres_virtual = vyres;
par->var.yoffset = yoffset; var->yoffset = yoffset;
if (var->vmode & FB_VMODE_DOUBLE) { if (var->vmode & FB_VMODE_DOUBLE) {
yres <<= 1; yres <<= 1;
...@@ -339,12 +516,13 @@ static int vga16fb_decode_var(const struct fb_var_screeninfo *var, ...@@ -339,12 +516,13 @@ static int vga16fb_decode_var(const struct fb_var_screeninfo *var,
if (ytotal & 0x200) r7 |= 0x20; if (ytotal & 0x200) r7 |= 0x20;
par->crtc[VGA_CRTC_PRESET_ROW] = 0; par->crtc[VGA_CRTC_PRESET_ROW] = 0;
par->crtc[VGA_CRTC_MAX_SCAN] = 0x40; /* 1 scanline, no linecmp */ par->crtc[VGA_CRTC_MAX_SCAN] = 0x40; /* 1 scanline, no linecmp */
par->var.vmode = var->vmode;
if (var->vmode & FB_VMODE_DOUBLE) if (var->vmode & FB_VMODE_DOUBLE)
par->crtc[VGA_CRTC_MAX_SCAN] |= 0x80; par->crtc[VGA_CRTC_MAX_SCAN] |= 0x80;
par->crtc[VGA_CRTC_CURSOR_START] = 0x20; par->crtc[VGA_CRTC_CURSOR_START] = 0x20;
par->crtc[VGA_CRTC_CURSOR_END] = 0x00; par->crtc[VGA_CRTC_CURSOR_END] = 0x00;
pos = yoffset * vxres + (xoffset >> 3); if ((mode & (MODE_CFB | MODE_8BPP)) == MODE_CFB)
xoffset--;
pos = yoffset * vxres + (xoffset >> shift);
par->crtc[VGA_CRTC_START_HI] = pos >> 8; par->crtc[VGA_CRTC_START_HI] = pos >> 8;
par->crtc[VGA_CRTC_START_LO] = pos & 0xFF; par->crtc[VGA_CRTC_START_LO] = pos & 0xFF;
par->crtc[VGA_CRTC_CURSOR_HI] = 0x00; par->crtc[VGA_CRTC_CURSOR_HI] = 0x00;
...@@ -372,170 +550,236 @@ static int vga16fb_decode_var(const struct fb_var_screeninfo *var, ...@@ -372,170 +550,236 @@ static int vga16fb_decode_var(const struct fb_var_screeninfo *var,
if (vxres >= 512) if (vxres >= 512)
FAIL("vxres too long"); FAIL("vxres too long");
par->crtc[VGA_CRTC_OFFSET] = vxres >> 1; par->crtc[VGA_CRTC_OFFSET] = vxres >> 1;
par->crtc[VGA_CRTC_UNDERLINE] = 0x1F; if (mode & MODE_SKIP4)
par->crtc[VGA_CRTC_MODE] = rMode | 0xE3; par->crtc[VGA_CRTC_UNDERLINE] = 0x5F; /* 256, cfb8 */
else
par->crtc[VGA_CRTC_UNDERLINE] = 0x1F; /* 16, vgap */
par->crtc[VGA_CRTC_MODE] = rMode | ((mode & MODE_TEXT) ? 0xA3 : 0xE3);
par->crtc[VGA_CRTC_LINE_COMPARE] = 0xFF; par->crtc[VGA_CRTC_LINE_COMPARE] = 0xFF;
par->crtc[VGA_CRTC_OVERFLOW] = r7; par->crtc[VGA_CRTC_OVERFLOW] = r7;
par->vss = 0x00; /* 3DA */ par->vss = 0x00; /* 3DA */
for (i = 0x00; i < 0x10; i++) par->misc = 0xE3; /* enable CPU, ports 0x3Dx, positive sync */
par->atc[i] = i;
par->atc[VGA_ATC_MODE] = 0x81;
par->atc[VGA_ATC_OVERSCAN] = 0x00; /* 0 for EGA, 0xFF for VGA */
par->atc[VGA_ATC_PLANE_ENABLE] = 0x0F;
par->atc[VGA_ATC_PEL] = xoffset & 7;
par->atc[VGA_ATC_COLOR_PAGE] = 0x00;
par->misc = 0xC3; /* enable CPU, ports 0x3Dx, positive sync */
par->var.sync = var->sync;
if (var->sync & FB_SYNC_HOR_HIGH_ACT) if (var->sync & FB_SYNC_HOR_HIGH_ACT)
par->misc &= ~0x40; par->misc &= ~0x40;
if (var->sync & FB_SYNC_VERT_HIGH_ACT) if (var->sync & FB_SYNC_VERT_HIGH_ACT)
par->misc &= ~0x80; par->misc &= ~0x80;
par->seq[VGA_SEQ_CLOCK_MODE] = 0x01; par->mode = mode;
par->seq[VGA_SEQ_PLANE_WRITE] = 0x0F;
par->seq[VGA_SEQ_CHARACTER_MAP] = 0x00; if (mode & MODE_8BPP)
par->seq[VGA_SEQ_MEMORY_MODE] = 0x06; /* pixel clock == vga clock / 2 */
vga16fb_clock_chip(par, var->pixclock, info, 1, 2);
par->gdc[VGA_GFX_SR_VALUE] = 0x00; else
par->gdc[VGA_GFX_SR_ENABLE] = 0x0F; /* pixel clock == vga clock */
par->gdc[VGA_GFX_COMPARE_VALUE] = 0x00; vga16fb_clock_chip(par, var->pixclock, info, 1, 1);
par->gdc[VGA_GFX_DATA_ROTATE] = 0x20;
par->gdc[VGA_GFX_PLANE_READ] = 0;
par->gdc[VGA_GFX_MODE] = 0x00;
par->gdc[VGA_GFX_MISC] = 0x05;
par->gdc[VGA_GFX_COMPARE_MASK] = 0x0F;
par->gdc[VGA_GFX_BIT_MASK] = 0xFF;
vga16fb_clock_chip(par, var->pixclock, info);
par->var.bits_per_pixel = 4;
par->var.grayscale = var->grayscale;
par->var.red.offset = par->var.green.offset = par->var.blue.offset =
par->var.transp.offset = 0;
par->var.red.length = par->var.green.length = par->var.blue.length =
(info->isVGA) ? 6 : 2;
par->var.transp.length = 0;
par->var.nonstd = 0;
par->var.activate = FB_ACTIVATE_NOW;
par->var.height = -1;
par->var.width = -1;
par->var.accel_flags = 0;
var->red.offset = var->green.offset = var->blue.offset =
var->transp.offset = 0;
var->red.length = var->green.length = var->blue.length =
(par->isVGA) ? 6 : 2;
var->transp.length = 0;
var->activate = FB_ACTIVATE_NOW;
var->height = -1;
var->width = -1;
var->accel_flags = 0;
return 0; return 0;
} }
#undef FAIL #undef FAIL
static int vga16fb_set_par(const struct vga16fb_par *par, static void vga16fb_load_font(struct display* p) {
struct vga16fb_info *info) int chars;
unsigned char* font;
unsigned char* dest;
if (!p || !p->fontdata)
return;
chars = 256;
font = p->fontdata;
dest = vga16fb.screen_base;
vga_io_wseq(0x00, 0x01);
vga_io_wseq(VGA_SEQ_PLANE_WRITE, 0x04);
vga_io_wseq(VGA_SEQ_MEMORY_MODE, 0x07);
vga_io_wseq(0x00, 0x03);
vga_io_wgfx(VGA_GFX_MODE, 0x00);
vga_io_wgfx(VGA_GFX_MISC, 0x04);
while (chars--) {
int i;
for (i = fontheight(p); i > 0; i--)
writeb(*font++, dest++);
dest += 32 - fontheight(p);
}
vga_io_wseq(0x00, 0x01);
vga_io_wseq(VGA_SEQ_PLANE_WRITE, 0x03);
vga_io_wseq(VGA_SEQ_MEMORY_MODE, 0x03);
vga_io_wseq(0x00, 0x03);
vga_io_wgfx(VGA_GFX_MODE, 0x10);
vga_io_wgfx(VGA_GFX_MISC, 0x06);
}
static int vga16fb_set_par(struct fb_info *info)
{ {
int i; struct vga16fb_par *par = (struct vga16fb_par *) info->par;
struct display *p = (info->currcon < 0) ? info->disp : (fb_display + info->currcon);
u8 gdc[VGA_GFX_C];
u8 seq[VGA_SEQ_C];
u8 atc[VGA_ATT_C];
int fh, i;
seq[VGA_SEQ_CLOCK_MODE] = 0x01 | par->clkdiv;
if (par->mode & MODE_TEXT)
seq[VGA_SEQ_PLANE_WRITE] = 0x03;
else
seq[VGA_SEQ_PLANE_WRITE] = 0x0F;
seq[VGA_SEQ_CHARACTER_MAP] = 0x00;
if (par->mode & MODE_TEXT)
seq[VGA_SEQ_MEMORY_MODE] = 0x03;
else if (par->mode & MODE_SKIP4)
seq[VGA_SEQ_MEMORY_MODE] = 0x0E;
else
seq[VGA_SEQ_MEMORY_MODE] = 0x06;
gdc[VGA_GFX_SR_VALUE] = 0x00;
gdc[VGA_GFX_SR_ENABLE] = 0x00;
gdc[VGA_GFX_COMPARE_VALUE] = 0x00;
gdc[VGA_GFX_DATA_ROTATE] = 0x00;
gdc[VGA_GFX_PLANE_READ] = 0;
if (par->mode & MODE_TEXT) {
gdc[VGA_GFX_MODE] = 0x10;
gdc[VGA_GFX_MISC] = 0x06;
} else {
if (par->mode & MODE_CFB)
gdc[VGA_GFX_MODE] = 0x40;
else
gdc[VGA_GFX_MODE] = 0x00;
gdc[VGA_GFX_MISC] = 0x05;
}
gdc[VGA_GFX_COMPARE_MASK] = 0x0F;
gdc[VGA_GFX_BIT_MASK] = 0xFF;
for (i = 0x00; i < 0x10; i++)
atc[i] = i;
if (par->mode & MODE_TEXT)
atc[VGA_ATC_MODE] = 0x04;
else if (par->mode & MODE_8BPP)
atc[VGA_ATC_MODE] = 0x41;
else
atc[VGA_ATC_MODE] = 0x81;
atc[VGA_ATC_OVERSCAN] = 0x00; /* 0 for EGA, 0xFF for VGA */
atc[VGA_ATC_PLANE_ENABLE] = 0x0F;
if (par->mode & MODE_8BPP)
atc[VGA_ATC_PEL] = (info->var.xoffset & 3) << 1;
else
atc[VGA_ATC_PEL] = info->var.xoffset & 7;
atc[VGA_ATC_COLOR_PAGE] = 0x00;
if (par->mode & MODE_TEXT) {
fh = fontheight(p);
if (!fh)
fh = 16;
par->crtc[VGA_CRTC_MAX_SCAN] = (par->crtc[VGA_CRTC_MAX_SCAN]
& ~0x1F) | (fh - 1);
}
outb(inb(VGA_MIS_R) | 0x01, VGA_MIS_W); vga_io_w(VGA_MIS_W, vga_io_r(VGA_MIS_R) | 0x01);
/* Enable graphics register modification */ /* Enable graphics register modification */
if (!info->isVGA) { if (!par->isVGA) {
outb(0x00, EGA_GFX_E0); vga_io_w(EGA_GFX_E0, 0x00);
outb(0x01, EGA_GFX_E1); vga_io_w(EGA_GFX_E1, 0x01);
} }
/* update misc output register */ /* update misc output register */
outb(par->misc, VGA_MIS_W); vga_io_w(VGA_MIS_W, par->misc);
/* synchronous reset on */ /* synchronous reset on */
outb(0x00, VGA_SEQ_I); vga_io_wseq(0x00, 0x01);
outb(0x01, VGA_SEQ_D);
if (par->isVGA)
vga_io_w(VGA_PEL_MSK, par->pel_msk);
/* write sequencer registers */ /* write sequencer registers */
outb(1, VGA_SEQ_I); vga_io_wseq(VGA_SEQ_CLOCK_MODE, seq[VGA_SEQ_CLOCK_MODE] | 0x20);
outb(par->seq[1] | 0x20, VGA_SEQ_D);
for (i = 2; i < VGA_SEQ_C; i++) { for (i = 2; i < VGA_SEQ_C; i++) {
outb(i, VGA_SEQ_I); vga_io_wseq(i, seq[i]);
outb(par->seq[i], VGA_SEQ_D);
} }
/* synchronous reset off */ /* synchronous reset off */
outb(0x00, VGA_SEQ_I); vga_io_wseq(0x00, 0x03);
outb(0x03, VGA_SEQ_D);
/* deprotect CRT registers 0-7 */ /* deprotect CRT registers 0-7 */
outb(0x11, VGA_CRT_IC); vga_io_wcrt(VGA_CRTC_V_SYNC_END, par->crtc[VGA_CRTC_V_SYNC_END]);
outb(par->crtc[0x11], VGA_CRT_DC);
/* write CRT registers */ /* write CRT registers */
for (i = 0; i < VGA_CRT_C; i++) { for (i = 0; i < VGA_CRTC_REGS; i++) {
outb(i, VGA_CRT_IC); vga_io_wcrt(i, par->crtc[i]);
outb(par->crtc[i], VGA_CRT_DC);
} }
/* write graphics controller registers */ /* write graphics controller registers */
for (i = 0; i < VGA_GFX_C; i++) { for (i = 0; i < VGA_GFX_C; i++) {
outb(i, VGA_GFX_I); vga_io_wgfx(i, gdc[i]);
outb(par->gdc[i], VGA_GFX_D);
} }
/* write attribute controller registers */ /* write attribute controller registers */
for (i = 0; i < VGA_ATT_C; i++) { for (i = 0; i < VGA_ATT_C; i++) {
inb_p(VGA_IS1_RC); /* reset flip-flop */ vga_io_r(VGA_IS1_RC); /* reset flip-flop */
outb_p(i, VGA_ATT_IW); vga_io_wattr(i, atc[i]);
outb_p(par->atc[i], VGA_ATT_IW);
} }
if (par->mode & MODE_TEXT)
vga16fb_load_font(p);
/* Wait for screen to stabilize. */ /* Wait for screen to stabilize. */
mdelay(50); mdelay(50);
outb(0x01, VGA_SEQ_I); vga_io_wseq(VGA_SEQ_CLOCK_MODE, seq[VGA_SEQ_CLOCK_MODE]);
outb(par->seq[1], VGA_SEQ_D);
inb(VGA_IS1_RC); vga_io_r(VGA_IS1_RC);
outb(0x20, VGA_ATT_IW); vga_io_w(VGA_ATT_IW, 0x20);
return 0; return 0;
} }
static int vga16fb_set_var(struct fb_var_screeninfo *var, int con, static int vga16fb_set_var(struct fb_var_screeninfo *var, int con,
struct fb_info *fb) struct fb_info *info)
{ {
struct vga16fb_info *info = (struct vga16fb_info*)fb;
struct vga16fb_par par;
struct display *display; struct display *display;
int err; int err;
if (con < 0) if (con < 0)
display = fb->disp; display = info->disp;
else else
display = fb_display + con; display = fb_display + con;
if ((err = vga16fb_decode_var(var, &par, info)) != 0) if ((err = vga16fb_check_var(var, info)) != 0)
return err; return err;
vga16fb_encode_var(var, &par, info);
if ((var->activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_TEST)
return 0;
if ((var->activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW) { if ((var->activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW) {
u32 oldxres, oldyres, oldvxres, oldvyres, oldbpp; u32 oldxres, oldyres, oldvxres, oldvyres, oldbpp, oldnonstd;
oldxres = display->var.xres; oldxres = info->var.xres;
oldyres = display->var.yres; oldyres = info->var.yres;
oldvxres = display->var.xres_virtual; oldvxres = info->var.xres_virtual;
oldvyres = display->var.yres_virtual; oldvyres = info->var.yres_virtual;
oldbpp = display->var.bits_per_pixel; oldbpp = info->var.bits_per_pixel;
oldnonstd = info->var.nonstd;
display->var = *var; info->var = *var;
if (oldxres != var->xres || oldyres != var->yres || if (con == info->currcon)
oldvxres != var->xres_virtual || oldvyres != var->yres_virtual || vga16fb_set_par(info);
oldbpp != var->bits_per_pixel) {
vga16fb_set_disp(con, info); vga16fb_set_disp(con, info);
if (info->fb_info.changevar) if (oldxres != var->xres ||
info->fb_info.changevar(con); oldyres != var->yres ||
oldvxres != var->xres_virtual ||
oldvyres != var->yres_virtual ||
oldbpp != var->bits_per_pixel ||
oldnonstd != var->nonstd) {
if (info->changevar)
info->changevar(con);
} }
if (con == info->fb_info.currcon)
vga16fb_set_par(&par, info);
} }
return 0; return 0;
} }
...@@ -544,31 +788,13 @@ static void ega16_setpalette(int regno, unsigned red, unsigned green, unsigned b ...@@ -544,31 +788,13 @@ static void ega16_setpalette(int regno, unsigned red, unsigned green, unsigned b
static unsigned char map[] = { 000, 001, 010, 011 }; static unsigned char map[] = { 000, 001, 010, 011 };
int val; int val;
val = map[red>>14] | ((map[green>>14]) << 1) | ((map[blue>>14]) << 2);
inb_p(0x3DA); /* ! 0x3BA */
outb_p(regno, 0x3C0);
outb_p(val, 0x3C0);
inb_p(0x3DA); /* some clones need it */
outb_p(0x20, 0x3C0); /* unblank screen */
}
static int vga16_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 >= 16) if (regno >= 16)
return 1; return;
val = map[red>>14] | ((map[green>>14]) << 1) | ((map[blue>>14]) << 2);
*red = palette[regno].red; vga_io_r(VGA_IS1_RC); /* ! 0x3BA */
*green = palette[regno].green; vga_io_wattr(regno, val);
*blue = palette[regno].blue; vga_io_r(VGA_IS1_RC); /* some clones need it */
*transp = 0; vga_io_w(VGA_ATT_IW, 0x20); /* unblank screen */
return 0;
} }
static void vga16_setpalette(int regno, unsigned red, unsigned green, unsigned blue) static void vga16_setpalette(int regno, unsigned red, unsigned green, unsigned blue)
...@@ -581,8 +807,9 @@ static void vga16_setpalette(int regno, unsigned red, unsigned green, unsigned b ...@@ -581,8 +807,9 @@ static void vga16_setpalette(int regno, unsigned red, unsigned green, unsigned b
static int vga16fb_setcolreg(unsigned regno, unsigned red, unsigned green, static int vga16fb_setcolreg(unsigned regno, unsigned red, unsigned green,
unsigned blue, unsigned transp, unsigned blue, unsigned transp,
struct fb_info *fb_info) struct fb_info *info)
{ {
struct vga16fb_par *par = (struct vga16fb_par *) info->par;
int gray; int gray;
/* /*
...@@ -592,53 +819,35 @@ static int vga16fb_setcolreg(unsigned regno, unsigned red, unsigned green, ...@@ -592,53 +819,35 @@ static int vga16fb_setcolreg(unsigned regno, unsigned red, unsigned green,
* != 0 for invalid regno. * != 0 for invalid regno.
*/ */
if (regno >= 16) if (regno >= 256)
return 1; return 1;
palette[regno].red = red; if (info->currcon < 0)
palette[regno].green = green; gray = info->disp->var.grayscale;
palette[regno].blue = blue;
if (fb_info->currcon < 0)
gray = disp.var.grayscale;
else else
gray = fb_display[fb_info->currcon].var.grayscale; gray = fb_display[info->currcon].var.grayscale;
if (gray) { if (gray) {
/* gray = 0.30*R + 0.59*G + 0.11*B */ /* gray = 0.30*R + 0.59*G + 0.11*B */
red = green = blue = (red * 77 + green * 151 + blue * 28) >> 8; red = green = blue = (red * 77 + green * 151 + blue * 28) >> 8;
} }
if (((struct vga16fb_info *) fb_info)->isVGA) if (par->isVGA)
vga16_setpalette(regno,red,green,blue); vga16_setpalette(regno,red,green,blue);
else else
ega16_setpalette(regno,red,green,blue); ega16_setpalette(regno,red,green,blue);
return 0;
}
static int vga16fb_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, vga16_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(16),
cmap, kspc ? 0 : 2);
return 0; return 0;
} }
static int vga16fb_pan_display(struct fb_var_screeninfo *var, int con, static int vga16fb_pan_display(struct fb_var_screeninfo *var, int con,
struct fb_info *info) struct fb_info *info)
{ {
if (var->xoffset + fb_display[con].var.xres > fb_display[con].var.xres_virtual || if (var->xoffset + info->var.xres > info->var.xres_virtual ||
var->yoffset + fb_display[con].var.yres > fb_display[con].var.yres_virtual) var->yoffset + info->var.yres > info->var.yres_virtual)
return -EINVAL; return -EINVAL;
if (con == info->currcon) if (con == info->currcon)
vga16fb_pan_var(info, var); vga16fb_pan_var(info, var);
fb_display[con].var.xoffset = var->xoffset; info->var.xoffset = var->xoffset;
fb_display[con].var.yoffset = var->yoffset; info->var.yoffset = var->yoffset;
fb_display[con].var.vmode &= ~FB_VMODE_YWRAP; info->var.vmode &= ~FB_VMODE_YWRAP;
return 0; return 0;
} }
...@@ -646,59 +855,49 @@ static int vga16fb_pan_display(struct fb_var_screeninfo *var, int con, ...@@ -646,59 +855,49 @@ static int vga16fb_pan_display(struct fb_var_screeninfo *var, int con,
blanking code was originally by Huang shi chao, and modified by blanking code was originally by Huang shi chao, and modified by
Christoph Rimek (chrimek@toppoint.de) and todd j. derr Christoph Rimek (chrimek@toppoint.de) and todd j. derr
(tjd@barefoot.org) for Linux. */ (tjd@barefoot.org) for Linux. */
#define attrib_port 0x3c0 #define attrib_port VGA_ATC_IW
#define seq_port_reg 0x3c4 #define seq_port_reg VGA_SEQ_I
#define seq_port_val 0x3c5 #define seq_port_val VGA_SEQ_D
#define gr_port_reg 0x3ce #define gr_port_reg VGA_GFX_I
#define gr_port_val 0x3cf #define gr_port_val VGA_GFX_D
#define video_misc_rd 0x3cc #define video_misc_rd VGA_MIS_R
#define video_misc_wr 0x3c2 #define video_misc_wr VGA_MIS_W
#define vga_video_port_reg 0x3d4 #define vga_video_port_reg VGA_CRT_IC
#define vga_video_port_val 0x3d5 #define vga_video_port_val VGA_CRT_DC
static void vga_vesa_blank(struct vga16fb_info *info, int mode) static void vga_vesa_blank(struct vga16fb_par *par, int mode)
{ {
unsigned char SeqCtrlIndex; unsigned char SeqCtrlIndex;
unsigned char CrtCtrlIndex; unsigned char CrtCtrlIndex;
cli(); //cli();
SeqCtrlIndex = inb_p(seq_port_reg); SeqCtrlIndex = vga_io_r(seq_port_reg);
CrtCtrlIndex = inb_p(vga_video_port_reg); CrtCtrlIndex = vga_io_r(vga_video_port_reg);
/* save original values of VGA controller registers */ /* save original values of VGA controller registers */
if(!info->vesa_blanked) { if(!par->vesa_blanked) {
info->vga_state.CrtMiscIO = inb_p(video_misc_rd); par->vga_state.CrtMiscIO = vga_io_r(video_misc_rd);
sti(); //sti();
outb_p(0x00,vga_video_port_reg); /* HorizontalTotal */ par->vga_state.HorizontalTotal = vga_io_rcrt(0x00); /* HorizontalTotal */
info->vga_state.HorizontalTotal = inb_p(vga_video_port_val); par->vga_state.HorizDisplayEnd = vga_io_rcrt(0x01); /* HorizDisplayEnd */
outb_p(0x01,vga_video_port_reg); /* HorizDisplayEnd */ par->vga_state.StartHorizRetrace = vga_io_rcrt(0x04); /* StartHorizRetrace */
info->vga_state.HorizDisplayEnd = inb_p(vga_video_port_val); par->vga_state.EndHorizRetrace = vga_io_rcrt(0x05); /* EndHorizRetrace */
outb_p(0x04,vga_video_port_reg); /* StartHorizRetrace */ par->vga_state.Overflow = vga_io_rcrt(0x07); /* Overflow */
info->vga_state.StartHorizRetrace = inb_p(vga_video_port_val); par->vga_state.StartVertRetrace = vga_io_rcrt(0x10); /* StartVertRetrace */
outb_p(0x05,vga_video_port_reg); /* EndHorizRetrace */ par->vga_state.EndVertRetrace = vga_io_rcrt(0x11); /* EndVertRetrace */
info->vga_state.EndHorizRetrace = inb_p(vga_video_port_val); par->vga_state.ModeControl = vga_io_rcrt(0x17); /* ModeControl */
outb_p(0x07,vga_video_port_reg); /* Overflow */ par->vga_state.ClockingMode = vga_io_rseq(0x01); /* ClockingMode */
info->vga_state.Overflow = inb_p(vga_video_port_val);
outb_p(0x10,vga_video_port_reg); /* StartVertRetrace */
info->vga_state.StartVertRetrace = inb_p(vga_video_port_val);
outb_p(0x11,vga_video_port_reg); /* EndVertRetrace */
info->vga_state.EndVertRetrace = inb_p(vga_video_port_val);
outb_p(0x17,vga_video_port_reg); /* ModeControl */
info->vga_state.ModeControl = inb_p(vga_video_port_val);
outb_p(0x01,seq_port_reg); /* ClockingMode */
info->vga_state.ClockingMode = inb_p(seq_port_val);
} }
/* assure that video is enabled */ /* assure that video is enabled */
/* "0x20" is VIDEO_ENABLE_bit in register 01 of sequencer */ /* "0x20" is VIDEO_ENABLE_bit in register 01 of sequencer */
cli(); //cli();
outb_p(0x01,seq_port_reg); vga_io_wseq(0x01, par->vga_state.ClockingMode | 0x20);
outb_p(info->vga_state.ClockingMode | 0x20,seq_port_val);
/* test for vertical retrace in process.... */ /* test for vertical retrace in process.... */
if ((info->vga_state.CrtMiscIO & 0x80) == 0x80) if ((par->vga_state.CrtMiscIO & 0x80) == 0x80)
outb_p(info->vga_state.CrtMiscIO & 0xef,video_misc_wr); vga_io_w(video_misc_wr, par->vga_state.CrtMiscIO & 0xef);
/* /*
* Set <End of vertical retrace> to minimum (0) and * Set <End of vertical retrace> to minimum (0) and
...@@ -711,7 +910,7 @@ static void vga_vesa_blank(struct vga16fb_info *info, int mode) ...@@ -711,7 +910,7 @@ static void vga_vesa_blank(struct vga16fb_info *info, int mode)
outb_p(0x11,vga_video_port_reg); /* EndVertRetrace */ outb_p(0x11,vga_video_port_reg); /* EndVertRetrace */
outb_p(0x40,vga_video_port_val); /* minimum (bits 0..3) */ outb_p(0x40,vga_video_port_val); /* minimum (bits 0..3) */
outb_p(0x07,vga_video_port_reg); /* Overflow */ outb_p(0x07,vga_video_port_reg); /* Overflow */
outb_p(info->vga_state.Overflow | 0x84,vga_video_port_val); /* bits 9,10 of vert. retrace */ outb_p(par->vga_state.Overflow | 0x84,vga_video_port_val); /* bits 9,10 of vert. retrace */
} }
if (mode & VESA_HSYNC_SUSPEND) { if (mode & VESA_HSYNC_SUSPEND) {
...@@ -729,44 +928,44 @@ static void vga_vesa_blank(struct vga16fb_info *info, int mode) ...@@ -729,44 +928,44 @@ static void vga_vesa_blank(struct vga16fb_info *info, int mode)
/* restore both index registers */ /* restore both index registers */
outb_p(SeqCtrlIndex,seq_port_reg); outb_p(SeqCtrlIndex,seq_port_reg);
outb_p(CrtCtrlIndex,vga_video_port_reg); outb_p(CrtCtrlIndex,vga_video_port_reg);
sti(); //sti();
} }
static void vga_vesa_unblank(struct vga16fb_info *info) static void vga_vesa_unblank(struct vga16fb_par *par)
{ {
unsigned char SeqCtrlIndex; unsigned char SeqCtrlIndex;
unsigned char CrtCtrlIndex; unsigned char CrtCtrlIndex;
cli(); //cli();
SeqCtrlIndex = inb_p(seq_port_reg); SeqCtrlIndex = vga_io_r(seq_port_reg);
CrtCtrlIndex = inb_p(vga_video_port_reg); CrtCtrlIndex = vga_io_r(vga_video_port_reg);
/* restore original values of VGA controller registers */ /* restore original values of VGA controller registers */
outb_p(info->vga_state.CrtMiscIO,video_misc_wr); vga_io_w(video_misc_wr, par->vga_state.CrtMiscIO);
outb_p(0x00,vga_video_port_reg); /* HorizontalTotal */ /* HorizontalTotal */
outb_p(info->vga_state.HorizontalTotal,vga_video_port_val); vga_io_wcrt(0x00, par->vga_state.HorizontalTotal);
outb_p(0x01,vga_video_port_reg); /* HorizDisplayEnd */ /* HorizDisplayEnd */
outb_p(info->vga_state.HorizDisplayEnd,vga_video_port_val); vga_io_wcrt(0x01, par->vga_state.HorizDisplayEnd);
outb_p(0x04,vga_video_port_reg); /* StartHorizRetrace */ /* StartHorizRetrace */
outb_p(info->vga_state.StartHorizRetrace,vga_video_port_val); vga_io_wcrt(0x04, par->vga_state.StartHorizRetrace);
outb_p(0x05,vga_video_port_reg); /* EndHorizRetrace */ /* EndHorizRetrace */
outb_p(info->vga_state.EndHorizRetrace,vga_video_port_val); vga_io_wcrt(0x05, par->vga_state.EndHorizRetrace);
outb_p(0x07,vga_video_port_reg); /* Overflow */ /* Overflow */
outb_p(info->vga_state.Overflow,vga_video_port_val); vga_io_wcrt(0x07, par->vga_state.Overflow);
outb_p(0x10,vga_video_port_reg); /* StartVertRetrace */ /* StartVertRetrace */
outb_p(info->vga_state.StartVertRetrace,vga_video_port_val); vga_io_wcrt(0x10, par->vga_state.StartVertRetrace);
outb_p(0x11,vga_video_port_reg); /* EndVertRetrace */ /* EndVertRetrace */
outb_p(info->vga_state.EndVertRetrace,vga_video_port_val); vga_io_wcrt(0x11, par->vga_state.EndVertRetrace);
outb_p(0x17,vga_video_port_reg); /* ModeControl */ /* ModeControl */
outb_p(info->vga_state.ModeControl,vga_video_port_val); vga_io_wcrt(0x17, par->vga_state.ModeControl);
outb_p(0x01,seq_port_reg); /* ClockingMode */ /* ClockingMode */
outb_p(info->vga_state.ClockingMode,seq_port_val); vga_io_wseq(0x01, par->vga_state.ClockingMode);
/* restore index/control registers */ /* restore index/control registers */
outb_p(SeqCtrlIndex,seq_port_reg); vga_io_w(seq_port_reg, SeqCtrlIndex);
outb_p(CrtCtrlIndex,vga_video_port_reg); vga_io_w(vga_video_port_reg, CrtCtrlIndex);
sti(); //sti();
} }
static void vga_pal_blank(void) static void vga_pal_blank(void)
...@@ -782,50 +981,96 @@ static void vga_pal_blank(void) ...@@ -782,50 +981,96 @@ static void vga_pal_blank(void)
} }
/* 0 unblank, 1 blank, 2 no vsync, 3 no hsync, 4 off */ /* 0 unblank, 1 blank, 2 no vsync, 3 no hsync, 4 off */
static int vga16fb_blank(int blank, struct fb_info *fb_info) static int vga16fb_blank(int blank, struct fb_info *info)
{ {
struct vga16fb_info *info = (struct vga16fb_info*)fb_info; struct vga16fb_par *par = (struct vga16fb_par *) info->par;
switch (blank) { switch (blank) {
case 0: /* Unblank */ case 0: /* Unblank */
if (info->vesa_blanked) { if (par->vesa_blanked) {
vga_vesa_unblank(info); vga_vesa_unblank(par);
info->vesa_blanked = 0; par->vesa_blanked = 0;
} }
if (info->palette_blanked) { if (par->palette_blanked) {
do_install_cmap(fb_info->currcon, fb_info); do_install_cmap(info->currcon, info);
info->palette_blanked = 0; par->palette_blanked = 0;
} }
break; break;
case 1: /* blank */ case 1: /* blank */
vga_pal_blank(); vga_pal_blank();
info->palette_blanked = 1; par->palette_blanked = 1;
break; break;
default: /* VESA blanking */ default: /* VESA blanking */
vga_vesa_blank(info, blank-1); vga_vesa_blank(par, blank-1);
info->vesa_blanked = 1; par->vesa_blanked = 1;
break; break;
} }
return 0; return 0;
} }
void vga16fb_imageblit(struct fb_info *info, struct fb_image *image)
{
char *where = info->screen_base + (image->dx/image->width) + image->dy * info->fix.line_length;
struct vga16fb_par *par = (struct vga16fb_par *) info->par;
u8 *cdat = image->data;
int y;
if (par->isVGA) {
setmode(2);
setop(0);
setsr(0xf);
setcolor(image->fg_color);
selectmask();
setmask(0xff);
writeb(image->bg_color, where);
rmb();
readb(where); /* fill latches */
setmode(3);
wmb();
for (y = 0; y < image->height; y++, where += info->fix.line_length)
writeb(cdat[y], where);
wmb();
} else {
setmode(0);
setop(0);
setsr(0xf);
setcolor(image->bg_color);
selectmask();
setmask(0xff);
for (y = 0; y < image->height; y++, where += info->fix.line_length)
rmw(where);
where -= info->fix.line_length * y;
setcolor(image->fg_color);
selectmask();
for (y = 0; y < image->height; y++, where += info->fix.line_length)
if (cdat[y]) {
setmask(cdat[y]);
rmw(where);
}
}
}
static struct fb_ops vga16fb_ops = { static struct fb_ops vga16fb_ops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.fb_get_fix = vga16fb_get_fix, .fb_set_var = vga16fb_set_var,
.fb_get_var = vga16fb_get_var, .fb_check_var = vga16fb_check_var,
.fb_set_var = vga16fb_set_var, .fb_set_par = vga16fb_set_par,
.fb_get_cmap = vga16fb_get_cmap, .fb_get_cmap = gen_get_cmap,
.fb_set_cmap = gen_set_cmap, .fb_set_cmap = gen_set_cmap,
.fb_setcolreg = vga16fb_setcolreg, .fb_setcolreg = vga16fb_setcolreg,
.fb_pan_display =vga16fb_pan_display, .fb_pan_display = vga16fb_pan_display,
.fb_blank = vga16fb_blank, .fb_blank = vga16fb_blank,
.fb_imageblit = vga16fb_imageblit,
}; };
int vga16fb_setup(char *options) int vga16fb_setup(char *options)
{ {
char *this_opt; char *this_opt;
vga16fb.fb_info.fontname[0] = '\0'; vga16fb.fontname[0] = '\0';
if (!options || !*options) if (!options || !*options)
return 0; return 0;
...@@ -834,95 +1079,70 @@ int vga16fb_setup(char *options) ...@@ -834,95 +1079,70 @@ int vga16fb_setup(char *options)
if (!*this_opt) continue; if (!*this_opt) continue;
if (!strncmp(this_opt, "font:", 5)) if (!strncmp(this_opt, "font:", 5))
strcpy(vga16fb.fb_info.fontname, this_opt+5); strcpy(vga16fb.fontname, this_opt+5);
} }
return 0; return 0;
} }
static int vga16fb_switch(int con, struct fb_info *fb)
{
struct vga16fb_par par;
struct vga16fb_info *info = (struct vga16fb_info*)fb;
/* Do we have to save the colormap? */
if (fb_display[fb->currcon].cmap.len)
fb_get_cmap(&fb_display[fb->currcon].cmap, 1, vga16_getcolreg,
fb);
fb->currcon = con;
vga16fb_decode_var(&fb_display[con].var, &par, info);
vga16fb_set_par(&par, info);
vga16fb_set_disp(con, info);
/* Install new colormap */
do_install_cmap(con, fb);
/* vga16fb_update_var(con, fb); */
return 1;
}
int __init vga16fb_init(void) int __init vga16fb_init(void)
{ {
int i,j; int i;
printk(KERN_DEBUG "vga16fb: initializing\n"); printk(KERN_DEBUG "vga16fb: initializing\n");
/* XXX share VGA_FB_PHYS region with vgacon */ /* XXX share VGA_FB_PHYS region with vgacon */
vga16fb.video_vbase = ioremap(VGA_FB_PHYS, VGA_FB_PHYS_LEN); vga16fb.screen_base = ioremap(VGA_FB_PHYS, VGA_FB_PHYS_LEN);
if (!vga16fb.video_vbase) { if (!vga16fb.screen_base) {
printk(KERN_ERR "vga16fb: unable to map device\n"); printk(KERN_ERR "vga16fb: unable to map device\n");
return -ENOMEM; return -ENOMEM;
} }
printk(KERN_INFO "vga16fb: mapped to 0x%p\n", vga16fb.video_vbase); printk(KERN_INFO "vga16fb: mapped to 0x%p\n", vga16fb.screen_base);
vga16fb.isVGA = ORIG_VIDEO_ISVGA; vga16_par.isVGA = ORIG_VIDEO_ISVGA;
vga16fb.palette_blanked = 0; vga16_par.palette_blanked = 0;
vga16fb.vesa_blanked = 0; vga16_par.vesa_blanked = 0;
i = vga16fb.isVGA? 6 : 2; i = vga16_par.isVGA? 6 : 2;
vga16fb_defined.red.length = i; vga16fb_defined.red.length = i;
vga16fb_defined.green.length = i; vga16fb_defined.green.length = i;
vga16fb_defined.blue.length = i; vga16fb_defined.blue.length = i;
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];
}
/* XXX share VGA I/O region with vgacon and others */ /* XXX share VGA I/O region with vgacon and others */
disp.var = vga16fb_defined; disp.var = vga16fb_defined;
/* name should not depend on EGA/VGA */ /* name should not depend on EGA/VGA */
strcpy(vga16fb.fb_info.modename, "VGA16 VGA"); strcpy(vga16fb.modename, "VGA16 VGA");
vga16fb.fb_info.changevar = NULL; vga16fb.changevar = NULL;
vga16fb.fb_info.node = NODEV; vga16fb.node = NODEV;
vga16fb.fb_info.fbops = &vga16fb_ops; vga16fb.fbops = &vga16fb_ops;
vga16fb.fb_info.screen_base = vga16fb.video_vbase; vga16fb.var = vga16fb_defined;
vga16fb.fb_info.disp=&disp; vga16fb.fix = vga16fb_fix;
vga16fb.fb_info.currcon = -1; vga16fb.par = &vga16_par;
vga16fb.fb_info.switch_con=&vga16fb_switch; vga16fb.disp = &disp;
vga16fb.fb_info.updatevar=&vga16fb_update_var; vga16fb.currcon = -1;
vga16fb.fb_info.flags=FBINFO_FLAG_DEFAULT; vga16fb.switch_con = gen_switch;
vga16fb.updatevar=&vga16fb_update_var;
vga16fb.flags=FBINFO_FLAG_DEFAULT;
vga16fb_set_disp(-1, &vga16fb); vga16fb_set_disp(-1, &vga16fb);
if (register_framebuffer(&vga16fb.fb_info)<0) { if (register_framebuffer(&vga16fb) < 0) {
iounmap(vga16fb.video_vbase); iounmap(vga16fb.screen_base);
return -EINVAL; return -EINVAL;
} }
printk(KERN_INFO "fb%d: %s frame buffer device\n", printk(KERN_INFO "fb%d: %s frame buffer device\n",
GET_FB_IDX(vga16fb.fb_info.node), vga16fb.fb_info.modename); GET_FB_IDX(vga16fb.node), vga16fb.modename);
return 0; return 0;
} }
static void __exit vga16fb_exit(void) static void __exit vga16fb_exit(void)
{ {
unregister_framebuffer(&vga16fb.fb_info); unregister_framebuffer(&vga16fb);
iounmap(vga16fb.video_vbase); iounmap(vga16fb.screen_base);
/* XXX unshare VGA regions */ /* XXX unshare VGA regions */
} }
......
...@@ -364,8 +364,6 @@ struct fb_info { ...@@ -364,8 +364,6 @@ struct fb_info {
char fontname[40]; /* default font name */ char fontname[40]; /* default font name */
devfs_handle_t devfs_handle; /* Devfs handle for new name */ devfs_handle_t devfs_handle; /* Devfs handle for new name */
devfs_handle_t devfs_lhandle; /* Devfs handle for compat. symlink */ devfs_handle_t devfs_lhandle; /* Devfs handle for compat. symlink */
int (*updatevar)(int, struct fb_info*);
/* tell fb to update the vars */
void *pseudo_palette; /* Fake palette of 16 colors and void *pseudo_palette; /* Fake palette of 16 colors and
the cursor's color for non the cursor's color for non
palette mode */ palette mode */
......
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