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