]> Joshua Wise's Git repositories - netwatch.git/blob - video/tnt2.c
rfb negotiation now works
[netwatch.git] / video / tnt2.c
1 #include <minilib.h>
2 #include <io.h>
3 #include <pci.h>
4 #include <output.h>
5 #include <fb.h>
6
7 static void tnt2_getvmode(void *priv);
8
9 static struct fbdevice tnt2_fb = {
10         .getvmode = &tnt2_getvmode,
11 };
12
13 static unsigned int vgard(unsigned char a)
14 {
15         outb(0x3D4, a);
16         return (unsigned int)inb(0x3D5);
17 }
18
19 static void tnt2_getvmode(void *priv)
20 {
21         tnt2_fb.curmode.xres = (vgard(0x1) + 1) * 8;
22         tnt2_fb.curmode.yres = (vgard(0x12) | (vgard(0x7) & 2) << 7 | (vgard(0x7) & 0x40) << 3) + 1;
23         switch (vgard(0x28))
24         {
25         case 3:
26                 tnt2_fb.curmode.format = FB_RGB888;
27                 tnt2_fb.curmode.bytestride = 4;
28                 tnt2_fb.curmode.text = 0;
29                 break;
30         case 0:
31                 tnt2_fb.curmode.text = 1;
32                 break;
33         default:
34                 tnt2_fb.curmode.text = 1;
35                 outputf("Unknown TNT2 format %x", vgard(0x28));
36                 break;
37         }
38 }
39
40 static int tnt2_probe(struct pci_dev *pci, void *data)
41 {
42         if (pci->bars[1].type != PCI_BAR_MEMORY32)
43         {
44                 output("TNT2 BAR1 is not memory32?");
45                 return 0;
46         }
47         tnt2_fb.fbaddr = (void *)pci->bars[1].addr;
48         fb = &tnt2_fb;
49         outputf("Found TNT2 with FB at %08x", tnt2_fb.fbaddr);
50         return 1;
51 }
52
53 static struct pci_id tnt2_pci[] = {
54         {0x10DE, 0x0028, "TNT2", "RIVA TNT2"}
55 };
56
57 struct pci_driver tnt2_driver = {
58         .name     = "tnt2",
59         .probe    = tnt2_probe,
60         .ids      = tnt2_pci,
61         .id_count = sizeof(tnt2_pci)/sizeof(tnt2_pci[0]),
62 };
This page took 0.030308 seconds and 4 git commands to generate.