summaryrefslogtreecommitdiff
path: root/sys/src/cmd/aux/vga/i81x.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@gmx.de>2013-01-02 01:19:51 +0100
committercinap_lenrek <cinap_lenrek@gmx.de>2013-01-02 01:19:51 +0100
commit2a1b43ad98f0c7e75a1ccc9c2468540cddd0b859 (patch)
tree064d76827a3f48d0a504ae100353090367866df6 /sys/src/cmd/aux/vga/i81x.c
parent0e4fc14f7e3de742e45b489d497f052199f390dd (diff)
vga: make kernel vga drivers more stupid
previously, we had to maintain 3 sets of pci vid/did's: 1) in /lib/vgadb for detection 2) in the userspace driver in aux/vga 3) in the kernel mode driver this change makes the kernel mode driver more dumb in the cases where possible. we let userspace do the pci enumeration and if needed, it can set the pci address of the vga card. kernel mode drivers can assume to get the right pci device passed in scr->pci for enable() and linear() functions and just do very basic sanity checking before mapping framebuffer and mmio regions. vgalinearpciid() was removed as userspace is responsible to pick pci device. theres a new vgactl message "pcidev" where userspace can set the bus address. we initialize scr->pci in vgareset() to the first pci graphics card found. this should cover cases when an old aux/vga binary is used that doesnt use the new pcidev message. userspace drivers will now use the pci device that got a match from /lib/vgadb and skip ther own enumeration. this way, vga cards can be made to work by simply adding an entry in vgadb with no need to modify userspace or kernelspace drivers. this is not always possible if the driver derives information from the specific card model.
Diffstat (limited to 'sys/src/cmd/aux/vga/i81x.c')
-rw-r--r--sys/src/cmd/aux/vga/i81x.c45
1 files changed, 22 insertions, 23 deletions
diff --git a/sys/src/cmd/aux/vga/i81x.c b/sys/src/cmd/aux/vga/i81x.c
index b1fdf74be..9ee726b33 100644
--- a/sys/src/cmd/aux/vga/i81x.c
+++ b/sys/src/cmd/aux/vga/i81x.c
@@ -25,7 +25,7 @@ typedef struct {
static void
snarf(Vga* vga, Ctlr* ctlr)
{
- int f, i;
+ int i;
uchar *mmio;
ulong *rp;
Pcidev *p;
@@ -33,31 +33,30 @@ snarf(Vga* vga, Ctlr* ctlr)
if(vga->private == nil){
vga->private = alloc(sizeof(I81x));
- p = nil;
- while((p = pcimatch(p, 0x8086, 0)) != nil) {
- switch(p->did) {
- default:
- continue;
- case 0x7121: /* Vanilla 82810 */
- case 0x7123: /* 810-DC100, DELL OptiPlex GX100 */
- case 0x7125: /* 82810E */
- case 0x1102: /* 82815 FSB limited to 100MHz */
- case 0x1112: /* 82815 no AGP */
- case 0x1132: /* 82815 fully featured Solano */
- case 0x3577: /* IBM R31 uses intel 830M chipset */
- vga->f[1] = 230000000; /* MAX speed of internal DAC (Hz)*/
+ p = vga->pci;
+ if(p == nil){
+ while((p = pcimatch(p, 0x8086, 0)) != nil) {
+ switch(p->did) {
+ default:
+ continue;
+ case 0x7121: /* Vanilla 82810 */
+ case 0x7123: /* 810-DC100, DELL OptiPlex GX100 */
+ case 0x7125: /* 82810E */
+ case 0x1102: /* 82815 FSB limited to 100MHz */
+ case 0x1112: /* 82815 no AGP */
+ case 0x1132: /* 82815 fully featured Solano */
+ case 0x3577: /* IBM R31 uses intel 830M chipset */
+ break;
+ }
break;
}
- break;
+ if(p == nil)
+ error("%s: Intel 81x graphics function not found\n", ctlr->name);
}
- if(p == nil)
- error("%s: Intel 81x graphics function not found\n", ctlr->name);
-
- if((f = open("#v/vgactl", OWRITE)) < 0)
- error("%s: can't open vgactl\n", ctlr->name);
- if(write(f, "type i81x", 9) != 9)
- error("%s: can't set type\n", ctlr->name);
- close(f);
+ vga->f[1] = 230000000; /* MAX speed of internal DAC (Hz)*/
+
+ vgactlpci(p);
+ vgactlw("type", "i81x");
mmio = segattach(0, "i81xmmio", 0, p->mem[1].size);
if(mmio == (void*)-1)