Subversion Repositories shark

Rev

Rev 54 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
54 pj 1
/* VGAlib version 1.2 - (c) 1993 Tommy Frandsen                    */
2
/*                                                                 */
3
/* This library is free software; you can redistribute it and/or   */
4
/* modify it without any restrictions. This library is distributed */
5
/* in the hope that it will be useful, but without any warranty.   */
6
 
7
/* Multi-chipset support Copyright 1993 Harm Hanemaayer */
8
/* partially copyrighted (C) 1993 by Hartmut Schirmer */
9
 
10
 
11
#include <stdlib.h>             /* for NULL */
12
#include "vga.h"
13
#include "libvga.h"
14
#include "driver.h"
15
 
16
/* BIOS mode 0Dh - 320x200x16 */
17
static const unsigned char g320x200x16_regs[60] =
18
{
19
  0x2D, 0x27, 0x28, 0x90, 0x2B, 0x80, 0xBF, 0x1F, 0x00, 0xC0, 0x00, 0x00,
20
  0x00, 0x00, 0x00, 0x00, 0x9C, 0x8E, 0x8F, 0x14, 0x00, 0x96, 0xB9, 0xE3,
21
  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B,
22
    0x0C, 0x0D, 0x0E, 0x0F, 0x01, 0x00, 0x0F, 0x00, 0x00,
23
    0x00, 0x0F, 0x00, 0x20, 0x00, 0x00, 0x05, 0x0F, 0xFF,
24
    0x03, 0x09, 0x0F, 0x00, 0x06,
25
    0x63
26
};
27
 
28
/* BIOS mode 0Eh - 640x200x16 */
29
static const unsigned char g640x200x16_regs[60] =
30
{
31
  0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0xBF, 0x1F, 0x00, 0xC0, 0x00, 0x00,
32
  0x00, 0x00, 0x00, 0x00, 0x9C, 0x8E, 0x8F, 0x28, 0x00, 0x96, 0xB9, 0xE3,
33
  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B,
34
    0x0C, 0x0D, 0x0E, 0x0F, 0x01, 0x00, 0x0F, 0x00, 0x00,
35
    0x00, 0x0F, 0x00, 0x20, 0x00, 0x00, 0x05, 0x0F, 0xFF,
36
    0x03, 0x01, 0x0F, 0x00, 0x06,
37
    0x63
38
};
39
 
40
/* BIOS mode 10h - 640x350x16 */
41
static const unsigned char g640x350x16_regs[60] =
42
{
43
  0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0xBF, 0x1F, 0x00, 0x40, 0x00, 0x00,
44
  0x00, 0x00, 0x00, 0x00, 0x83, 0x85, 0x5D, 0x28, 0x0F, 0x63, 0xBA, 0xE3,
45
  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B,
46
    0x0C, 0x0D, 0x0E, 0x0F, 0x01, 0x00, 0x0F, 0x00, 0x00,
47
    0x00, 0x0F, 0x00, 0x20, 0x00, 0x00, 0x05, 0x0F, 0xFF,
48
    0x03, 0x01, 0x0F, 0x00, 0x06,
49
    0xA3
50
};
51
 
52
/* BIOS mode 12h - 640x480x16 */
53
static const unsigned char g640x480x16_regs[60] =
54
{
55
  0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0x0B, 0x3E, 0x00, 0x40, 0x00, 0x00,
56
  0x00, 0x00, 0x00, 0x00, 0xEA, 0x8C, 0xDF, 0x28, 0x00, 0xE7, 0x04, 0xE3,
57
  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B,
58
    0x0C, 0x0D, 0x0E, 0x0F, 0x01, 0x00, 0x0F, 0x00, 0x00,
59
    0x00, 0x0F, 0x00, 0x20, 0x00, 0x00, 0x05, 0x0F, 0xFF,
60
    0x03, 0x01, 0x0F, 0x00, 0x06,
61
    0xE3
62
};
63
 
64
/* BIOS mode 13h - 320x200x256 */
65
static const unsigned char g320x200x256_regs[60] =
66
{
67
  0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0xBF, 0x1F, 0x00, 0x41, 0x00, 0x00,
68
  0x00, 0x00, 0x00, 0x00, 0x9C, 0x8E, 0x8F, 0x28, 0x40, 0x96, 0xB9, 0xA3,
69
  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B,
70
    0x0C, 0x0D, 0x0E, 0x0F, 0x41, 0x00, 0x0F, 0x00, 0x00,
71
    0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF,
72
    0x03, 0x01, 0x0F, 0x00, 0x0E,
73
    0x63
74
};
75
 
76
/* non-BIOS mode - 320x240x256 */
77
static const unsigned char g320x240x256_regs[60] =
78
{
79
  0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0x0D, 0x3E, 0x00, 0x41, 0x00, 0x00,
80
  0x00, 0x00, 0x00, 0x00, 0xEA, 0xAC, 0xDF, 0x28, 0x00, 0xE7, 0x06, 0xE3,
81
  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B,
82
    0x0C, 0x0D, 0x0E, 0x0F, 0x41, 0x00, 0x0F, 0x00, 0x00,
83
    0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF,
84
    0x03, 0x01, 0x0F, 0x00, 0x06,
85
    0xE3
86
};
87
 
88
/* non-BIOS mode - 320x400x256 */
89
static const unsigned char g320x400x256_regs[60] =
90
{
91
  0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0xBF, 0x1F, 0x00, 0x40, 0x00, 0x00,
92
  0x00, 0x00, 0x00, 0x00, 0x9C, 0x8E, 0x8F, 0x28, 0x00, 0x96, 0xB9, 0xE3,
93
  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B,
94
    0x0C, 0x0D, 0x0E, 0x0F, 0x41, 0x00, 0x0F, 0x00, 0x00,
95
    0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF,
96
    0x03, 0x01, 0x0F, 0x00, 0x06,
97
    0x63
98
};
99
 
100
/* non-BIOS mode - 360x480x256 */
101
static const unsigned char g360x480x256_regs[60] =
102
{
103
  0x6B, 0x59, 0x5A, 0x8E, 0x5E, 0x8A, 0x0D, 0x3E, 0x00, 0x40, 0x00, 0x00,
104
  0x00, 0x00, 0x00, 0x00, 0xEA, 0xAC, 0xDF, 0x2D, 0x00, 0xE7, 0x06, 0xE3,
105
  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B,
106
    0x0C, 0x0D, 0x0E, 0x0F, 0x41, 0x00, 0x0F, 0x00, 0x00,
107
    0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF,
108
    0x03, 0x01, 0x0F, 0x00, 0x06,
109
    0xE7
110
};
111
 
112
/* monochrome mode based on BIOS mode 12h - 640x480x2 */
113
#define g640x480x2_regs g640x480x16_regs
114
 
115
/* non BIOS mode - 720x348x2 based on mode 10h */
116
static const unsigned char g720x348x2_regs[60] =
117
{
118
  0x6B, 0x59, 0x5A, 0x8E, 0x5E, 0x8A, 0xBF, 0x1F, 0x00, 0x40, 0x00, 0x00,
119
  0x00, 0x00, 0x00, 0x00, 0x83, 0x85, 0x5D, 0x2D, 0x0F, 0x63, 0xBA, 0xE3,
120
  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B,
121
    0x0C, 0x0D, 0x0E, 0x0F, 0x01, 0x00, 0x0F, 0x00, 0x00,
122
    0x00, 0x0F, 0x00, 0x20, 0x00, 0x00, 0x05, 0x0F, 0xFF,
123
    0x03, 0x01, 0x0F, 0x00, 0x06,
124
    0xA7
125
};
126
 
127
/* non-BIOS mode - 400x300x256 - added by Ark 28-JAN-2001 */
128
static const unsigned char g400x300x256X_regs[60] =
129
{
130
  0x71, 0x63, 0x64, 0x92, 0x65, 0x82, 0x46, 0x1F, 0x00, 0x40, 0x00, 0x00,
131
  0x00, 0x00, 0x00, 0x00, 0x31, 0x80, 0x2B, 0x32, 0x00, 0x2F, 0x44, 0xE3,
132
  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B,
133
    0x0C, 0x0D, 0x0E, 0x0F, 0x41, 0x00, 0x0F, 0x00, 0x00,
134
    0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF,
135
    0x03, 0x01, 0x0F, 0x00, 0x06,
136
    0xA7
137
};
138
 
139
 
140
/* Mode table */
141
static ModeTable vga_modes[] =
142
{
143
/* *INDENT-OFF* */
144
    OneModeEntry(640x480x2),
145
    OneModeEntry(720x348x2),
146
    OneModeEntry(320x200x16),
147
    OneModeEntry(640x200x16),
148
    OneModeEntry(640x350x16),
149
    OneModeEntry(640x480x16),
150
    OneModeEntry(320x200x256),
151
    OneModeEntry(320x240x256),
152
    OneModeEntry(320x400x256),
153
    OneModeEntry(360x480x256),
154
    OneModeEntry(400x300x256X),
155
#ifdef G720x350x16
156
    OneModeEntry(720x350x16),
157
#endif
158
    END_OF_MODE_TABLE
159
/* *INDENT-ON* */
160
};
161
 
162
 
163
/* Fill in chipset-specific modeinfo */
164
 
165
static void getmodeinfo(int mode, vga_modeinfo * modeinfo)
166
{
167
    if (modeinfo->bytesperpixel == 1) {         /* 320x200x256 linear mode */
168
        modeinfo->maxpixels = 65536;
169
        modeinfo->startaddressrange = 0xffff;
170
    } else
171
        switch (modeinfo->colors) {
172
        case 16:                /* 4-plane 16 color mode */
173
            modeinfo->maxpixels = 65536 * 8;
174
            modeinfo->startaddressrange = 0x7ffff;
175
            break;
176
        case 256:               /* 4-plane 256 color mode */
177
            modeinfo->maxpixels = 65536 * 4;
178
            modeinfo->startaddressrange = 0x3ffff;
179
            break;
180
        }
181
    modeinfo->maxlogicalwidth = 2040;
182
    modeinfo->haveblit = 0;
183
    modeinfo->flags &= ~(IS_INTERLACED | HAVE_RWPAGE);
184
}
185
 
186
static void nothing(void)
187
{
188
}
189
 
190
static int saveregs(unsigned char regs[])
191
{
192
    return 0;
193
}
194
 
195
static void setregs(const unsigned char regs[], int mode)
196
{
197
}
198
 
199
/* Return nonzero if mode available */
200
 
201
static int modeavailable(int mode)
202
{
203
    const unsigned char *regs;
204
 
205
    regs = LOOKUPMODE(vga_modes, mode);
206
    if (regs != NULL && regs != DISABLE_MODE)
207
        return STDVGADRV;
208
    return 0;
209
}
210
 
211
 
212
/* Set a mode */
213
 
214
static int lastmode;
215
 
216
static int setmode(int mode, int prv_mode)
217
{
218
/* standard VGA driver: setmode */
219
    const unsigned char *regs;
220
 
221
    if (mode == TEXT)
222
        return 0;               /* Do nothing. */
223
 
224
    regs = LOOKUPMODE(vga_modes, mode);
225
    if (regs == NULL || regs == DISABLE_MODE)
226
        return 1;
227
    lastmode = mode;
228
    __svgalib_setregs(regs);
229
    return 0;
230
}
231
 
232
/* Set display start */
233
 
234
static void setdisplaystart(int address)
235
{
236
    vga_modeinfo *modeinfo;
237
    modeinfo = vga_getmodeinfo(lastmode);
238
    if (modeinfo->bytesperpixel == 0)   /* not 320x200x256 linear */
239
        switch (modeinfo->colors) {
240
        case 16:                /* planar 16-color mode */
241
            __svgalib_outatt(0x33,(__svgalib_inatt(0x33)&0xf0) | (address & 7));
242
            /* write sa0-2 to bits 0-2 */
243
            address >>= 3;
244
            break;
245
        case 256:               /* planar 256-color mode */
246
            /* write sa0-1 to bits 1-2 */
247
            __svgalib_outatt(0x33,(__svgalib_inatt(0x33)&0xf0) | ((address & 3)<<1) );
248
            address >>= 2;
249
            break;
250
        }
251
    __svgalib_outcrtc(0x0d, address & 0x00ff);
252
    __svgalib_outcrtc(0x0c, (address & 0xff00) >> 8);
253
}
254
 
255
static void setlogicalwidth(int width)
256
{
257
    __svgalib_outcrtc(0x13, width >> 3);
258
}
259
 
260
static int vgadrv_init(int, int, int);
261
 
262
static int vga_test(void)
263
{
264
    unsigned char save, back;
265
 
266
    /* Check if a DAC is present */
267
    save = port_in(PEL_IW);
268
    __svgalib_delay();
269
    outb(PEL_IW, ~save);
270
    __svgalib_delay();
271
    back = port_in(PEL_IW);
272
    __svgalib_delay();
273
    outb(PEL_IW, save);
274
    save = ~save;
275
    if (back == save) {
276
        vgadrv_init(0, 0, 0);
277
        return 1;
278
    }
279
    return 0;
280
}
281
 
282
 
283
DriverSpecs __svgalib_vga_driverspecs =
284
{                               /* standard VGA */
285
    saveregs,
286
    setregs,
287
    nothing,                    /* unlock */
288
    nothing,                    /* lock */
289
    vga_test,
290
    vgadrv_init,
291
    (void (*)(int)) nothing,    /* __svgalib_setpage */
292
    (void (*)(int)) nothing,    /* __svgalib_setrdpage */
293
    (void (*)(int)) nothing,    /* __svgalib_setwrpage */
294
    setmode,
295
    modeavailable,
296
    setdisplaystart,
297
    setlogicalwidth,
298
    getmodeinfo,
299
    0,                          /* bitblt */
300
    0,                          /* imageblt */
301
    0,                          /* fillblt */
302
    0,                          /* hlinelistblt */
303
    0,                          /* bltwait */
304
    0,                          /* extset */
305
    0,
306
    0,                          /* linear */
307
    NULL,                       /* Accelspecs */
308
    NULL,                       /* Emulation */
309
};
310
 
311
/* Initialize chipset (called after detection) */
312
 
313
static int vgadrv_init(int force, int par1, int par2)
314
{
315
    if (__svgalib_driver_report)
81 giacomo 316
        cprintf("Using VGA driver.\n");
54 pj 317
    __svgalib_driverspecs = &__svgalib_vga_driverspecs;
318
    __svgalib_banked_mem_base=0xa0000;
319
    __svgalib_banked_mem_size=0x10000;
320
 
321
    return 0;
322
}