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 */
36 p = pcimatch(nil, MATROX, MGA2164AGP);
38 p = pcimatch(nil, MATROX, MGA2164);
40 p = pcimatch(nil, MATROX, MGA2064);
46 mga2164wenable(VGAscr* scr)
57 if(p->did == MGA2064){
58 scr->mmio = vmap(p->mem[0].bar&~0x0F, p->mem[0].size);
61 addvgaseg("mga2164wmmio", p->mem[0].bar&~0x0F, p->mem[0].size);
62 vgalinearaddr(scr, p->mem[1].bar&~0x0F, 8*MB);
64 scr->mmio = vmap(p->mem[1].bar&~0x0F, p->mem[1].size);
67 addvgaseg("mga2164wmmio", p->mem[1].bar&~0x0F, p->mem[1].size);
68 vgalinearaddr(scr, p->mem[0].bar&~0x0F, 16*MB);
71 addvgaseg("mga2164wscreen", scr->paddr, scr->apsize);
75 Index = 0x00, /* Index */
76 Data = 0x0A, /* Data */
78 CaddrW = 0x04, /* Colour Write Address */
79 Cdata = 0x05, /* Colour Data */
81 Cctl = 0x09, /* Direct Cursor Control */
82 Cram = 0x0B, /* Cursor Ram Data */
83 Cxlsb = 0x0C, /* Cursor X LSB */
84 Cxmsb = 0x0D, /* Cursor X MSB */
85 Cylsb = 0x0E, /* Cursor Y LSB */
86 Cymsb = 0x0F, /* Cursor Y MSB */
88 Icctl = 0x06, /* Indirect Cursor Control */
92 tvp3026disable(VGAscr* scr)
98 tvp3026 = (uchar*)scr->mmio+0x3C00;
101 * Make sure cursor is off
102 * and direct control enabled.
104 *(tvp3026+Index) = Icctl;
105 *(tvp3026+Data) = 0x90;
106 *(tvp3026+Cctl) = 0x00;
110 tvp3026load(VGAscr* scr, Cursor* curs)
117 tvp3026 = (uchar*)scr->mmio+0x3C00;
120 * Make sure cursor is off by initialising the cursor
121 * control to defaults.
122 * Write to the indirect control register to make sure
123 * direct register is enabled and upper 2 bits of cursor
125 * Put 0 in index register for lower 8 bits of cursor RAM address.
128 *(tvp3026+Index) = 0;
131 * Initialise the 64x64 cursor RAM array. There are 2 planes,
132 * p0 and p1. Data is written 8 pixels per byte, with p0 in the
133 * first 512 bytes of the array and p1 in the second.
134 * The cursor is set in 3-colour mode which gives the following
138 * 0 1 cursor colour 0
139 * 1 0 cursor colour 1
140 * 1 1 cursor colour 2
141 * Put the cursor into the top-left of the 64x64 array.
142 * The 0,0 cursor point is bottom-right, so positioning will
143 * have to take that into account.
145 for(y = 0; y < 64; y++){
146 for(x = 0; x < 64/8; x++){
147 if(x < 16/8 && y < 16)
148 *(tvp3026+Cram) = curs->clr[x+y*2];
150 *(tvp3026+Cram) = 0x00;
153 for(y = 0; y < 64; y++){
154 for(x = 0; x < 64/8; x++){
155 if(x < 16/8 && y < 16)
156 *(tvp3026+Cram) = curs->set[x+y*2];
158 *(tvp3026+Cram) = 0x00;
163 * Initialise the cursor hotpoint
164 * and enable the cursor in 3-colour mode.
166 scr->offset.x = 64+curs->offset.x;
167 scr->offset.y = 64+curs->offset.y;
168 *(tvp3026+Cctl) = 0x01;
172 tvp3026move(VGAscr* scr, Point p)
179 tvp3026 = (uchar*)scr->mmio+0x3C00;
181 x = p.x+scr->offset.x;
182 y = p.y+scr->offset.y;
184 *(tvp3026+Cxlsb) = x & 0xFF;
185 *(tvp3026+Cxmsb) = (x>>8) & 0x0F;
186 *(tvp3026+Cylsb) = y & 0xFF;
187 *(tvp3026+Cymsb) = (y>>8) & 0x0F;
193 tvp3026enable(VGAscr* scr)
200 tvp3026 = (uchar*)scr->mmio+0x3C00;
206 * cursor colour 1 (white),
207 * cursor colour 2, 3 (black).
209 *(tvp3026+CaddrW) = 0x00;
210 for(i = 0; i < 6; i++)
211 *(tvp3026+Cdata) = Pwhite;
212 for(i = 0; i < 6; i++)
213 *(tvp3026+Cdata) = Pblack;
216 * Load, locate and enable the
217 * 64x64 cursor in 3-colour mode.
219 tvp3026load(scr, &arrow);
220 tvp3026move(scr, ZP);
221 *(tvp3026+Cctl) = 0x01;
224 VGAdev vgamga2164wdev = {
227 mga2164wenable, /* enable */
233 VGAcur vgamga2164wcur = {