2 #include "../port/lib.h"
7 #include "../port/error.h"
16 * Matrox Millennium and Matrox Millennium II.
17 * Matrox MGA-2064W, MGA-2164W 3D graphics accelerators.
18 * Texas Instruments Tvp3026 RAMDAC.
22 /* pci chip manufacturer */
25 /* pci chip device ids */
32 mga2164wenable(VGAscr* scr)
40 if(p == nil || p->vid != MATROX)
43 if(p->did == MGA2064){
44 scr->mmio = vmap(p->mem[0].bar&~0x0F, p->mem[0].size);
47 addvgaseg("mga2164wmmio", p->mem[0].bar&~0x0F, p->mem[0].size);
48 vgalinearaddr(scr, p->mem[1].bar&~0x0F, 8*MB);
50 scr->mmio = vmap(p->mem[1].bar&~0x0F, p->mem[1].size);
53 addvgaseg("mga2164wmmio", p->mem[1].bar&~0x0F, p->mem[1].size);
54 vgalinearaddr(scr, p->mem[0].bar&~0x0F, 16*MB);
57 addvgaseg("mga2164wscreen", scr->paddr, scr->apsize);
61 Index = 0x00, /* Index */
62 Data = 0x0A, /* Data */
64 CaddrW = 0x04, /* Colour Write Address */
65 Cdata = 0x05, /* Colour Data */
67 Cctl = 0x09, /* Direct Cursor Control */
68 Cram = 0x0B, /* Cursor Ram Data */
69 Cxlsb = 0x0C, /* Cursor X LSB */
70 Cxmsb = 0x0D, /* Cursor X MSB */
71 Cylsb = 0x0E, /* Cursor Y LSB */
72 Cymsb = 0x0F, /* Cursor Y MSB */
74 Icctl = 0x06, /* Indirect Cursor Control */
78 tvp3026disable(VGAscr* scr)
84 tvp3026 = (uchar*)scr->mmio+0x3C00;
87 * Make sure cursor is off
88 * and direct control enabled.
90 *(tvp3026+Index) = Icctl;
91 *(tvp3026+Data) = 0x90;
92 *(tvp3026+Cctl) = 0x00;
96 tvp3026load(VGAscr* scr, Cursor* curs)
103 tvp3026 = (uchar*)scr->mmio+0x3C00;
106 * Make sure cursor is off by initialising the cursor
107 * control to defaults.
108 * Write to the indirect control register to make sure
109 * direct register is enabled and upper 2 bits of cursor
111 * Put 0 in index register for lower 8 bits of cursor RAM address.
114 *(tvp3026+Index) = 0;
117 * Initialise the 64x64 cursor RAM array. There are 2 planes,
118 * p0 and p1. Data is written 8 pixels per byte, with p0 in the
119 * first 512 bytes of the array and p1 in the second.
120 * The cursor is set in 3-colour mode which gives the following
124 * 0 1 cursor colour 0
125 * 1 0 cursor colour 1
126 * 1 1 cursor colour 2
127 * Put the cursor into the top-left of the 64x64 array.
128 * The 0,0 cursor point is bottom-right, so positioning will
129 * have to take that into account.
131 for(y = 0; y < 64; y++){
132 for(x = 0; x < 64/8; x++){
133 if(x < 16/8 && y < 16)
134 *(tvp3026+Cram) = curs->clr[x+y*2];
136 *(tvp3026+Cram) = 0x00;
139 for(y = 0; y < 64; y++){
140 for(x = 0; x < 64/8; x++){
141 if(x < 16/8 && y < 16)
142 *(tvp3026+Cram) = curs->set[x+y*2];
144 *(tvp3026+Cram) = 0x00;
149 * Initialise the cursor hotpoint
150 * and enable the cursor in 3-colour mode.
152 scr->offset.x = 64+curs->offset.x;
153 scr->offset.y = 64+curs->offset.y;
154 *(tvp3026+Cctl) = 0x01;
158 tvp3026move(VGAscr* scr, Point p)
165 tvp3026 = (uchar*)scr->mmio+0x3C00;
167 x = p.x+scr->offset.x;
168 y = p.y+scr->offset.y;
170 *(tvp3026+Cxlsb) = x & 0xFF;
171 *(tvp3026+Cxmsb) = (x>>8) & 0x0F;
172 *(tvp3026+Cylsb) = y & 0xFF;
173 *(tvp3026+Cymsb) = (y>>8) & 0x0F;
179 tvp3026enable(VGAscr* scr)
186 tvp3026 = (uchar*)scr->mmio+0x3C00;
192 * cursor colour 1 (white),
193 * cursor colour 2, 3 (black).
195 *(tvp3026+CaddrW) = 0x00;
196 for(i = 0; i < 6; i++)
197 *(tvp3026+Cdata) = Pwhite;
198 for(i = 0; i < 6; i++)
199 *(tvp3026+Cdata) = Pblack;
202 * Load, locate and enable the
203 * 64x64 cursor in 3-colour mode.
205 tvp3026load(scr, &cursor);
206 tvp3026move(scr, ZP);
207 *(tvp3026+Cctl) = 0x01;
210 VGAdev vgamga2164wdev = {
213 mga2164wenable, /* enable */
219 VGAcur vgamga2164wcur = {