]> Joshua Wise's Git repositories - netwatch.git/blame - video/tnt2.c
Merge branch 'master' of /storage/git/netwatch
[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>
6
7static void tnt2_getvmode(void *priv);
8
9static struct fbdevice tnt2_fb = {
10 .getvmode = &tnt2_getvmode,
11};
12
13static unsigned int vgard(unsigned char a)
14{
c77a83d6 15 outb(0x3D4, a);
34a7d0d2
JW
16 return (unsigned int)inb(0x3D5);
17}
18
19static 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 {
c77a83d6 25 case 3:
34a7d0d2
JW
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:
c77a83d6
JW
34 tnt2_fb.curmode.text = 1;
35 outputf("Unknown TNT2 format %x", vgard(0x28));
34a7d0d2
JW
36 break;
37 }
38}
39
40static 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
53static struct pci_id tnt2_pci[] = {
54 {0x10DE, 0x0028, "TNT2", "RIVA TNT2"}
55};
56
57struct 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.029506 seconds and 4 git commands to generate.