]> Joshua Wise's Git repositories - netwatch.git/blame - hardware/video/tnt2.c
Slightly permute the USB_LEGKEY stuff.
[netwatch.git] / hardware / video / tnt2.c
CommitLineData
98e930a2
JP
1/* tnt2.c
2 * NVidia TNT2 driver.
3 * NetWatch system management mode administration console
4 *
5 * Copyright (c) 2008 Jacob Potter and Joshua Wise. All rights reserved.
6 * This program is free software; you can redistribute and/or modify it under
7 * the terms found in the file LICENSE in the root of this source tree.
8 *
9 */
10
34a7d0d2
JW
11#include <minilib.h>
12#include <io.h>
13#include <pci.h>
14#include <output.h>
15#include <fb.h>
e8f20fe7 16#include <paging.h>
cdde55f5 17#include <text.h>
34a7d0d2 18
66cd7e82 19#include "generic.h"
0a9d0188 20
34a7d0d2
JW
21static void tnt2_getvmode(void *priv);
22
23static struct fbdevice tnt2_fb = {
24 .getvmode = &tnt2_getvmode,
25};
26
27static unsigned int vgard(unsigned char a)
28{
c77a83d6 29 outb(0x3D4, a);
34a7d0d2
JW
30 return (unsigned int)inb(0x3D5);
31}
32
33static void tnt2_getvmode(void *priv)
34{
35 tnt2_fb.curmode.xres = (vgard(0x1) + 1) * 8;
36 tnt2_fb.curmode.yres = (vgard(0x12) | (vgard(0x7) & 2) << 7 | (vgard(0x7) & 0x40) << 3) + 1;
37 switch (vgard(0x28))
38 {
c77a83d6 39 case 3:
34a7d0d2
JW
40 tnt2_fb.curmode.format = FB_RGB888;
41 tnt2_fb.curmode.bytestride = 4;
42 tnt2_fb.curmode.text = 0;
0a9d0188 43 tnt2_fb.checksum_rect = checksum_rect_generic32;
66cd7e82 44 tnt2_fb.copy_pixels = copy_pixels_generic32;
34a7d0d2
JW
45 break;
46 case 0:
47 tnt2_fb.curmode.text = 1;
66cd7e82
JW
48 tnt2_fb.checksum_rect = text_checksum;
49 tnt2_fb.copy_pixels = text_render;
34a7d0d2
JW
50 break;
51 default:
c77a83d6 52 tnt2_fb.curmode.text = 1;
66cd7e82
JW
53 tnt2_fb.checksum_rect = text_checksum;
54 tnt2_fb.copy_pixels = text_render;
c77a83d6 55 outputf("Unknown TNT2 format %x", vgard(0x28));
34a7d0d2
JW
56 break;
57 }
58}
59
60static int tnt2_probe(struct pci_dev *pci, void *data)
61{
e8f20fe7
JW
62 unsigned int p;
63
34a7d0d2
JW
64 if (pci->bars[1].type != PCI_BAR_MEMORY32)
65 {
66 output("TNT2 BAR1 is not memory32?");
67 return 0;
68 }
e8f20fe7
JW
69
70 /* Map 32M of memory. */
71 for (p = 0; p < 32; p += 4)
72 addmap_4m(0x40000000 + p*1024*1024, pci->bars[1].addr + p*1024*1024);
73 tnt2_fb.fbaddr = (void *)0x40000000;
74
34a7d0d2 75 fb = &tnt2_fb;
e8f20fe7 76 outputf("Found TNT2 with FB at %08x, mapped to %08x", pci->bars[1].addr, tnt2_fb.fbaddr);
34a7d0d2
JW
77 return 1;
78}
79
80static struct pci_id tnt2_pci[] = {
81 {0x10DE, 0x0028, "TNT2", "RIVA TNT2"}
82};
83
84struct pci_driver tnt2_driver = {
85 .name = "tnt2",
86 .probe = tnt2_probe,
87 .ids = tnt2_pci,
88 .id_count = sizeof(tnt2_pci)/sizeof(tnt2_pci[0]),
89};
This page took 0.029754 seconds and 4 git commands to generate.