]> Joshua Wise's Git repositories - netwatch.git/blame - video/tnt2.c
some changes for gcc4
[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>
cdde55f5 7#include <text.h>
34a7d0d2 8
66cd7e82 9#include "generic.h"
0a9d0188 10
34a7d0d2
JW
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{
c77a83d6 19 outb(0x3D4, a);
34a7d0d2
JW
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 {
c77a83d6 29 case 3:
34a7d0d2
JW
30 tnt2_fb.curmode.format = FB_RGB888;
31 tnt2_fb.curmode.bytestride = 4;
32 tnt2_fb.curmode.text = 0;
0a9d0188 33 tnt2_fb.checksum_rect = checksum_rect_generic32;
66cd7e82 34 tnt2_fb.copy_pixels = copy_pixels_generic32;
34a7d0d2
JW
35 break;
36 case 0:
37 tnt2_fb.curmode.text = 1;
66cd7e82
JW
38 tnt2_fb.checksum_rect = text_checksum;
39 tnt2_fb.copy_pixels = text_render;
34a7d0d2
JW
40 break;
41 default:
c77a83d6 42 tnt2_fb.curmode.text = 1;
66cd7e82
JW
43 tnt2_fb.checksum_rect = text_checksum;
44 tnt2_fb.copy_pixels = text_render;
c77a83d6 45 outputf("Unknown TNT2 format %x", vgard(0x28));
34a7d0d2
JW
46 break;
47 }
48}
49
50static int tnt2_probe(struct pci_dev *pci, void *data)
51{
e8f20fe7
JW
52 unsigned int p;
53
34a7d0d2
JW
54 if (pci->bars[1].type != PCI_BAR_MEMORY32)
55 {
56 output("TNT2 BAR1 is not memory32?");
57 return 0;
58 }
e8f20fe7
JW
59
60 /* Map 32M of memory. */
61 for (p = 0; p < 32; p += 4)
62 addmap_4m(0x40000000 + p*1024*1024, pci->bars[1].addr + p*1024*1024);
63 tnt2_fb.fbaddr = (void *)0x40000000;
64
34a7d0d2 65 fb = &tnt2_fb;
e8f20fe7 66 outputf("Found TNT2 with FB at %08x, mapped to %08x", pci->bars[1].addr, tnt2_fb.fbaddr);
34a7d0d2
JW
67 return 1;
68}
69
70static struct pci_id tnt2_pci[] = {
71 {0x10DE, 0x0028, "TNT2", "RIVA TNT2"}
72};
73
74struct pci_driver tnt2_driver = {
75 .name = "tnt2",
76 .probe = tnt2_probe,
77 .ids = tnt2_pci,
78 .id_count = sizeof(tnt2_pci)/sizeof(tnt2_pci[0]),
79};
This page took 0.029114 seconds and 4 git commands to generate.