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