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