2 #include "../port/lib.h"
7 #include "../port/error.h"
16 clgd542xpageset(VGAscr*, int page)
21 if(vgaxi(Seqx, 0x07) & 0xF0)
23 gr09 = vgaxi(Grx, 0x09);
24 if(vgaxi(Grx, 0x0B) & 0x20){
25 vgaxo(Grx, 0x09, page<<2);
29 vgaxo(Grx, 0x09, page<<4);
37 clgd542xpage(VGAscr* scr, int page)
40 clgd542xpageset(scr, page);
41 unlock(&scr->devlock);
45 clgd542xlinear(VGAscr* scr, int, int)
47 vgalinearpciid(scr, 0x1013, 0);
51 clgd542xdisable(VGAscr*)
55 sr12 = vgaxi(Seqx, 0x12);
56 vgaxo(Seqx, 0x12, sr12 & ~0x01);
60 clgd542xenable(VGAscr* scr)
68 sr12 = vgaxi(Seqx, 0x12);
69 vgaxo(Seqx, 0x12, sr12 & ~0x01);
73 * Can't call setcolor here as cursor is already locked.
75 vgaxo(Seqx, 0x12, sr12|0x02);
84 vgaxo(Seqx, 0x12, sr12);
87 switch(vgaxi(Crtx, 0x27) & ~0x03){
89 case 0x88: /* CL-GD5420 */
90 case 0x8C: /* CL-GD5422 */
91 case 0x94: /* CL-GD5424 */
92 case 0x80: /* CL-GD5425 */
93 case 0x90: /* CL-GD5426 */
94 case 0x98: /* CL-GD5427 */
95 case 0x9C: /* CL-GD5429 */
97 * The BIOS leaves the memory size in Seq0A, bits 4 and 3.
98 * See Technical Reference Manual Appendix E1, Section 1.3.2.
100 * The storage area for the 64x64 cursors is the last 16Kb of
103 mem = (vgaxi(Seqx, 0x0A)>>3) & 0x03;
106 case 0xA0: /* CL-GD5430 */
107 case 0xA8: /* CL-GD5434 */
108 case 0xAC: /* CL-GD5436 */
109 case 0xB8: /* CL-GD5446 */
110 case 0x30: /* CL-GD7543 */
112 * Attempt to intuit the memory size from the DRAM control
113 * register. Minimum is 512KB.
114 * If DRAM bank switching is on then there's double.
116 x = vgaxi(Seqx, 0x0F);
122 case 0xBC: /* CL-GD5480 */
123 mem = 2; /* 1024 = 256<<2 */
124 x = vgaxi(Seqx, 0x0F);
125 if((x & 0x18) == 0x18){
126 mem <<= 1; /* 2048 = 256<<3 */
128 mem <<= 2; /* 2048 = 256<<4 */
130 if(vgaxi(Seqx, 0x17) & 0x80)
134 default: /* uh, ah dunno */
137 scr->storage = ((256<<mem)-16)*1024;
140 * Set the current cursor to index 0
141 * and turn the 64x64 cursor on.
143 vgaxo(Seqx, 0x13, 0);
144 vgaxo(Seqx, 0x12, sr12|0x05);
148 clgd542xinitcursor(VGAscr* scr, int xo, int yo, int index)
155 * Is linear addressing turned on? This will determine
156 * how we access the cursor storage.
158 seq07 = vgaxi(Seqx, 0x07);
163 opage = clgd542xpageset(scr, scr->storage>>16);
164 p += (scr->storage & 0xFFFF);
170 for(y = yo; y < 16; y++){
172 p1 = scr->set[2*y+1];
174 p0 = (p0<<xo)|(p1>>(8-xo));
180 for(x = 16; x < 64; x += 8)
183 p0 = scr->clr[2*y]|scr->set[2*y];
184 p1 = scr->clr[2*y+1]|scr->set[2*y+1];
186 p0 = (p0<<xo)|(p1>>(8-xo));
192 for(x = 16; x < 64; x += 8)
196 for(x = 0; x < 64; x += 8){
204 clgd542xpageset(scr, opage);
205 unlock(&scr->devlock);
210 clgd542xload(VGAscr* scr, Cursor* curs)
215 * Disable the cursor.
217 sr12 = vgaxi(Seqx, 0x12);
218 vgaxo(Seqx, 0x12, sr12 & ~0x01);
220 memmove(&scr->Cursor, curs, sizeof(Cursor));
221 clgd542xinitcursor(scr, 0, 0, 0);
226 vgaxo(Seqx, 0x13, 0);
227 vgaxo(Seqx, 0x12, sr12|0x05);
231 clgd542xmove(VGAscr* scr, Point p)
233 int index, x, xo, y, yo;
236 if((x = p.x+scr->offset.x) < 0){
242 if((y = p.y+scr->offset.y) < 0){
250 clgd542xinitcursor(scr, xo, yo, 1);
253 vgaxo(Seqx, 0x13, index<<2);
255 vgaxo(Seqx, 0x10|((x & 0x07)<<5), (x>>3) & 0xFF);
256 vgaxo(Seqx, 0x11|((y & 0x07)<<5), (y>>3) & 0xFF);
261 VGAdev vgaclgd542xdev = {
270 VGAcur vgaclgd542xcur = {