]> Joshua Wise's Git repositories - netwatch.git/blame - video/tnt2.c
Be a little bit quieter, and consequentially be a lot bit faster.
[netwatch.git] / video / tnt2.c
CommitLineData
34a7d0d2
JW
1#include <minilib.h>
2#include <io.h>
3#include <pci.h>
4#include <output.h>
5#include <fb.h>
e8f20fe7 6#include <paging.h>
34a7d0d2
JW
7
8static void tnt2_getvmode(void *priv);
9
10static struct fbdevice tnt2_fb = {
11 .getvmode = &tnt2_getvmode,
12};
13
14static unsigned int vgard(unsigned char a)
15{
c77a83d6 16 outb(0x3D4, a);
34a7d0d2
JW
17 return (unsigned int)inb(0x3D5);
18}
19
20static 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 {
c77a83d6 26 case 3:
34a7d0d2
JW
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:
c77a83d6
JW
35 tnt2_fb.curmode.text = 1;
36 outputf("Unknown TNT2 format %x", vgard(0x28));
34a7d0d2
JW
37 break;
38 }
39}
40
41static int tnt2_probe(struct pci_dev *pci, void *data)
42{
e8f20fe7
JW
43 unsigned int p;
44
34a7d0d2
JW
45 if (pci->bars[1].type != PCI_BAR_MEMORY32)
46 {
47 output("TNT2 BAR1 is not memory32?");
48 return 0;
49 }
e8f20fe7
JW
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
34a7d0d2 56 fb = &tnt2_fb;
e8f20fe7 57 outputf("Found TNT2 with FB at %08x, mapped to %08x", pci->bars[1].addr, tnt2_fb.fbaddr);
34a7d0d2
JW
58 return 1;
59}
60
61static struct pci_id tnt2_pci[] = {
62 {0x10DE, 0x0028, "TNT2", "RIVA TNT2"}
63};
64
65struct 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.032706 seconds and 4 git commands to generate.