]> Joshua Wise's Git repositories - netwatch.git/blob - video/tnt2.c
73a3d0b6eafd484a61f5a68a9a0a4d7febc8ca97
[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(a, 0x3D4);
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 4:
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                 outputf("Unknown TNT2 format %d", vgard(0x28));
35                 break;
36         }
37 }
38
39 static int tnt2_probe(struct pci_dev *pci, void *data)
40 {
41         if (pci->bars[1].type != PCI_BAR_MEMORY32)
42         {
43                 output("TNT2 BAR1 is not memory32?");
44                 return 0;
45         }
46         tnt2_fb.fbaddr = (void *)pci->bars[1].addr;
47         fb = &tnt2_fb;
48         outputf("Found TNT2 with FB at %08x", tnt2_fb.fbaddr);
49         return 1;
50 }
51
52 static struct pci_id tnt2_pci[] = {
53         {0x10DE, 0x0028, "TNT2", "RIVA TNT2"}
54 };
55
56 struct pci_driver tnt2_driver = {
57         .name     = "tnt2",
58         .probe    = tnt2_probe,
59         .ids      = tnt2_pci,
60         .id_count = sizeof(tnt2_pci)/sizeof(tnt2_pci[0]),
61 };
This page took 0.019066 seconds and 2 git commands to generate.