1 |
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * Copyright (c) 1997,1998 The XFree86 Project, Inc.
|
---|
5 | *
|
---|
6 | * Loosely based on code bearing the following copyright:
|
---|
7 | *
|
---|
8 | * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
|
---|
9 | *
|
---|
10 | * Author: Dirk Hohndel
|
---|
11 | */
|
---|
12 |
|
---|
13 | #ifndef _VGAHW_H
|
---|
14 | #define _VGAHW_H
|
---|
15 |
|
---|
16 | #include <X11/X.h>
|
---|
17 | #include "misc.h"
|
---|
18 | #include "input.h"
|
---|
19 | #include "scrnintstr.h"
|
---|
20 | #include "colormapst.h"
|
---|
21 |
|
---|
22 | #include "xf86str.h"
|
---|
23 | #include "xf86Pci.h"
|
---|
24 |
|
---|
25 | #include "xf86DDC.h"
|
---|
26 |
|
---|
27 | #include "globals.h"
|
---|
28 | #include <X11/extensions/dpmsconst.h>
|
---|
29 |
|
---|
30 | extern _X_EXPORT int vgaHWGetIndex(void);
|
---|
31 |
|
---|
32 | /*
|
---|
33 | * access macro
|
---|
34 | */
|
---|
35 | #define VGAHWPTR(p) ((vgaHWPtr)((p)->privates[vgaHWGetIndex()].ptr))
|
---|
36 |
|
---|
37 | /* Standard VGA registers */
|
---|
38 | #define VGA_ATTR_INDEX 0x3C0
|
---|
39 | #define VGA_ATTR_DATA_W 0x3C0
|
---|
40 | #define VGA_ATTR_DATA_R 0x3C1
|
---|
41 | #define VGA_IN_STAT_0 0x3C2 /* read */
|
---|
42 | #define VGA_MISC_OUT_W 0x3C2 /* write */
|
---|
43 | #define VGA_ENABLE 0x3C3
|
---|
44 | #define VGA_SEQ_INDEX 0x3C4
|
---|
45 | #define VGA_SEQ_DATA 0x3C5
|
---|
46 | #define VGA_DAC_MASK 0x3C6
|
---|
47 | #define VGA_DAC_READ_ADDR 0x3C7
|
---|
48 | #define VGA_DAC_WRITE_ADDR 0x3C8
|
---|
49 | #define VGA_DAC_DATA 0x3C9
|
---|
50 | #define VGA_FEATURE_R 0x3CA /* read */
|
---|
51 | #define VGA_MISC_OUT_R 0x3CC /* read */
|
---|
52 | #define VGA_GRAPH_INDEX 0x3CE
|
---|
53 | #define VGA_GRAPH_DATA 0x3CF
|
---|
54 |
|
---|
55 | #define VGA_IOBASE_MONO 0x3B0
|
---|
56 | #define VGA_IOBASE_COLOR 0x3D0
|
---|
57 |
|
---|
58 | #define VGA_CRTC_INDEX_OFFSET 0x04
|
---|
59 | #define VGA_CRTC_DATA_OFFSET 0x05
|
---|
60 | #define VGA_IN_STAT_1_OFFSET 0x0A /* read */
|
---|
61 | #define VGA_FEATURE_W_OFFSET 0x0A /* write */
|
---|
62 |
|
---|
63 | /* default number of VGA registers stored internally */
|
---|
64 | #define VGA_NUM_CRTC 25
|
---|
65 | #define VGA_NUM_SEQ 5
|
---|
66 | #define VGA_NUM_GFX 9
|
---|
67 | #define VGA_NUM_ATTR 21
|
---|
68 |
|
---|
69 | /* Flags for vgaHWSave() and vgaHWRestore() */
|
---|
70 | #define VGA_SR_MODE 0x01
|
---|
71 | #define VGA_SR_FONTS 0x02
|
---|
72 | #define VGA_SR_CMAP 0x04
|
---|
73 | #define VGA_SR_ALL (VGA_SR_MODE | VGA_SR_FONTS | VGA_SR_CMAP)
|
---|
74 |
|
---|
75 | /* Defaults for the VGA memory window */
|
---|
76 | #define VGA_DEFAULT_PHYS_ADDR 0xA0000
|
---|
77 | #define VGA_DEFAULT_MEM_SIZE (64 * 1024)
|
---|
78 |
|
---|
79 | /*
|
---|
80 | * vgaRegRec contains settings of standard VGA registers.
|
---|
81 | */
|
---|
82 | typedef struct {
|
---|
83 | unsigned char MiscOutReg; /* */
|
---|
84 | unsigned char *CRTC; /* Crtc Controller */
|
---|
85 | unsigned char *Sequencer; /* Video Sequencer */
|
---|
86 | unsigned char *Graphics; /* Video Graphics */
|
---|
87 | unsigned char *Attribute; /* Video Atribute */
|
---|
88 | unsigned char DAC[768]; /* Internal Colorlookuptable */
|
---|
89 | unsigned char numCRTC; /* number of CRTC registers, def=VGA_NUM_CRTC */
|
---|
90 | unsigned char numSequencer; /* number of seq registers, def=VGA_NUM_SEQ */
|
---|
91 | unsigned char numGraphics; /* number of gfx registers, def=VGA_NUM_GFX */
|
---|
92 | unsigned char numAttribute; /* number of attr registers, def=VGA_NUM_ATTR */
|
---|
93 | } vgaRegRec, *vgaRegPtr;
|
---|
94 |
|
---|
95 | typedef struct _vgaHWRec *vgaHWPtr;
|
---|
96 |
|
---|
97 | typedef void (*vgaHWWriteIndexProcPtr)(vgaHWPtr hwp, CARD8 indx, CARD8 value);
|
---|
98 | typedef CARD8 (*vgaHWReadIndexProcPtr)(vgaHWPtr hwp, CARD8 indx);
|
---|
99 | typedef void (*vgaHWWriteProcPtr)(vgaHWPtr hwp, CARD8 value);
|
---|
100 | typedef CARD8 (*vgaHWReadProcPtr)(vgaHWPtr hwp);
|
---|
101 | typedef void (*vgaHWMiscProcPtr)(vgaHWPtr hwp);
|
---|
102 |
|
---|
103 |
|
---|
104 | /*
|
---|
105 | * vgaHWRec contains per-screen information required by the vgahw module.
|
---|
106 | *
|
---|
107 | * Note, the palette referred to by the paletteEnabled, enablePalette and
|
---|
108 | * disablePalette is the 16-entry (+overscan) EGA-compatible palette accessed
|
---|
109 | * via the first 17 attribute registers and not the main 8-bit palette.
|
---|
110 | */
|
---|
111 | typedef struct _vgaHWRec {
|
---|
112 | pointer Base; /* Address of "VGA" memory */
|
---|
113 | int MapSize; /* Size of "VGA" memory */
|
---|
114 | unsigned long MapPhys; /* phys location of VGA mem */
|
---|
115 | int IOBase; /* I/O Base address */
|
---|
116 | CARD8 * MMIOBase; /* Pointer to MMIO start */
|
---|
117 | int MMIOOffset; /* base + offset + vgareg
|
---|
118 | = mmioreg */
|
---|
119 | pointer FontInfo1; /* save area for fonts in
|
---|
120 | plane 2 */
|
---|
121 | pointer FontInfo2; /* save area for fonts in
|
---|
122 | plane 3 */
|
---|
123 | pointer TextInfo; /* save area for text */
|
---|
124 | vgaRegRec SavedReg; /* saved registers */
|
---|
125 | vgaRegRec ModeReg; /* register settings for
|
---|
126 | current mode */
|
---|
127 | Bool ShowOverscan;
|
---|
128 | Bool paletteEnabled;
|
---|
129 | Bool cmapSaved;
|
---|
130 | ScrnInfoPtr pScrn;
|
---|
131 | vgaHWWriteIndexProcPtr writeCrtc;
|
---|
132 | vgaHWReadIndexProcPtr readCrtc;
|
---|
133 | vgaHWWriteIndexProcPtr writeGr;
|
---|
134 | vgaHWReadIndexProcPtr readGr;
|
---|
135 | vgaHWReadProcPtr readST00;
|
---|
136 | vgaHWReadProcPtr readST01;
|
---|
137 | vgaHWReadProcPtr readFCR;
|
---|
138 | vgaHWWriteProcPtr writeFCR;
|
---|
139 | vgaHWWriteIndexProcPtr writeAttr;
|
---|
140 | vgaHWReadIndexProcPtr readAttr;
|
---|
141 | vgaHWWriteIndexProcPtr writeSeq;
|
---|
142 | vgaHWReadIndexProcPtr readSeq;
|
---|
143 | vgaHWWriteProcPtr writeMiscOut;
|
---|
144 | vgaHWReadProcPtr readMiscOut;
|
---|
145 | vgaHWMiscProcPtr enablePalette;
|
---|
146 | vgaHWMiscProcPtr disablePalette;
|
---|
147 | vgaHWWriteProcPtr writeDacMask;
|
---|
148 | vgaHWReadProcPtr readDacMask;
|
---|
149 | vgaHWWriteProcPtr writeDacWriteAddr;
|
---|
150 | vgaHWWriteProcPtr writeDacReadAddr;
|
---|
151 | vgaHWWriteProcPtr writeDacData;
|
---|
152 | vgaHWReadProcPtr readDacData;
|
---|
153 | pointer ddc;
|
---|
154 | IOADDRESS PIOOffset; /* offset + vgareg
|
---|
155 | = pioreg */
|
---|
156 | vgaHWReadProcPtr readEnable;
|
---|
157 | vgaHWWriteProcPtr writeEnable;
|
---|
158 | struct pci_device *dev;
|
---|
159 | } vgaHWRec;
|
---|
160 |
|
---|
161 | /* Some macros that VGA drivers can use in their ChipProbe() function */
|
---|
162 | #define VGAHW_GET_IOBASE() ((inb(VGA_MISC_OUT_R) & 0x01) ? \
|
---|
163 | VGA_IOBASE_COLOR : VGA_IOBASE_MONO)
|
---|
164 |
|
---|
165 | #define OVERSCAN 0x11 /* Index of OverScan register */
|
---|
166 |
|
---|
167 | /* Flags that define how overscan correction should take place */
|
---|
168 | #define KGA_FIX_OVERSCAN 1 /* overcan correction required */
|
---|
169 | #define KGA_ENABLE_ON_ZERO 2 /* if possible enable display at beginning */
|
---|
170 | /* of next scanline/frame */
|
---|
171 | #define KGA_BE_TOT_DEC 4 /* always fix problem by setting blank end */
|
---|
172 | /* to total - 1 */
|
---|
173 | #define BIT_PLANE 3 /* Which plane we write to in mono mode */
|
---|
174 | #define BITS_PER_GUN 6
|
---|
175 | #define COLORMAP_SIZE 256
|
---|
176 |
|
---|
177 | #if defined(__powerpc__) || defined(__arm__) || defined(__s390__)
|
---|
178 | #define DACDelay(hw) /* No legacy VGA support */
|
---|
179 | #else
|
---|
180 | #define DACDelay(hw) \
|
---|
181 | do { \
|
---|
182 | (void)inb((hw)->PIOOffset + (hw)->IOBase + VGA_IN_STAT_1_OFFSET); \
|
---|
183 | (void)inb((hw)->PIOOffset + (hw)->IOBase + VGA_IN_STAT_1_OFFSET); \
|
---|
184 | } while (0)
|
---|
185 | #endif
|
---|
186 |
|
---|
187 | /* Function Prototypes */
|
---|
188 |
|
---|
189 | /* vgaHW.c */
|
---|
190 |
|
---|
191 | typedef void vgaHWProtectProc(ScrnInfoPtr, Bool);
|
---|
192 | typedef void vgaHWBlankScreenProc(ScrnInfoPtr, Bool);
|
---|
193 |
|
---|
194 | extern _X_EXPORT void vgaHWSetStdFuncs(vgaHWPtr hwp);
|
---|
195 | extern _X_EXPORT void vgaHWSetMmioFuncs(vgaHWPtr hwp, CARD8 *base, int offset);
|
---|
196 | extern _X_EXPORT void vgaHWProtect(ScrnInfoPtr pScrn, Bool on);
|
---|
197 | extern _X_EXPORT vgaHWProtectProc *vgaHWProtectWeak(void);
|
---|
198 | extern _X_EXPORT Bool vgaHWSaveScreen(ScreenPtr pScreen, int mode);
|
---|
199 | extern _X_EXPORT void vgaHWBlankScreen(ScrnInfoPtr pScrn, Bool on);
|
---|
200 | extern _X_EXPORT vgaHWBlankScreenProc *vgaHWBlankScreenWeak(void);
|
---|
201 | extern _X_EXPORT void vgaHWSeqReset(vgaHWPtr hwp, Bool start);
|
---|
202 | extern _X_EXPORT void vgaHWRestoreFonts(ScrnInfoPtr scrninfp, vgaRegPtr restore);
|
---|
203 | extern _X_EXPORT void vgaHWRestoreMode(ScrnInfoPtr scrninfp, vgaRegPtr restore);
|
---|
204 | extern _X_EXPORT void vgaHWRestoreColormap(ScrnInfoPtr scrninfp, vgaRegPtr restore);
|
---|
205 | extern _X_EXPORT void vgaHWRestore(ScrnInfoPtr scrninfp, vgaRegPtr restore, int flags);
|
---|
206 | extern _X_EXPORT void vgaHWSaveFonts(ScrnInfoPtr scrninfp, vgaRegPtr save);
|
---|
207 | extern _X_EXPORT void vgaHWSaveMode(ScrnInfoPtr scrninfp, vgaRegPtr save);
|
---|
208 | extern _X_EXPORT void vgaHWSaveColormap(ScrnInfoPtr scrninfp, vgaRegPtr save);
|
---|
209 | extern _X_EXPORT void vgaHWSave(ScrnInfoPtr scrninfp, vgaRegPtr save, int flags);
|
---|
210 | extern _X_EXPORT Bool vgaHWInit(ScrnInfoPtr scrnp, DisplayModePtr mode);
|
---|
211 | extern _X_EXPORT Bool vgaHWSetRegCounts(ScrnInfoPtr scrp, int numCRTC, int numSequencer,
|
---|
212 | int numGraphics, int numAttribute);
|
---|
213 | extern _X_EXPORT Bool vgaHWCopyReg(vgaRegPtr dst, vgaRegPtr src);
|
---|
214 | extern _X_EXPORT Bool vgaHWGetHWRec(ScrnInfoPtr scrp);
|
---|
215 | extern _X_EXPORT void vgaHWFreeHWRec(ScrnInfoPtr scrp);
|
---|
216 | extern _X_EXPORT Bool vgaHWMapMem(ScrnInfoPtr scrp);
|
---|
217 | extern _X_EXPORT void vgaHWUnmapMem(ScrnInfoPtr scrp);
|
---|
218 | extern _X_EXPORT void vgaHWGetIOBase(vgaHWPtr hwp);
|
---|
219 | extern _X_EXPORT void vgaHWLock(vgaHWPtr hwp);
|
---|
220 | extern _X_EXPORT void vgaHWUnlock(vgaHWPtr hwp);
|
---|
221 | extern _X_EXPORT void vgaHWEnable(vgaHWPtr hwp);
|
---|
222 | extern _X_EXPORT void vgaHWDisable(vgaHWPtr hwp);
|
---|
223 | extern _X_EXPORT void vgaHWDPMSSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags);
|
---|
224 | extern _X_EXPORT Bool vgaHWHandleColormaps(ScreenPtr pScreen);
|
---|
225 | extern _X_EXPORT void vgaHWddc1SetSpeed(ScrnInfoPtr pScrn, xf86ddcSpeed speed);
|
---|
226 | extern _X_EXPORT CARD32 vgaHWHBlankKGA(DisplayModePtr mode, vgaRegPtr regp, int nBits,
|
---|
227 | unsigned int Flags);
|
---|
228 | extern _X_EXPORT CARD32 vgaHWVBlankKGA(DisplayModePtr mode, vgaRegPtr regp, int nBits,
|
---|
229 | unsigned int Flags);
|
---|
230 | extern _X_EXPORT Bool vgaHWAllocDefaultRegs(vgaRegPtr regp);
|
---|
231 |
|
---|
232 | extern _X_EXPORT DDC1SetSpeedProc vgaHWddc1SetSpeedWeak(void);
|
---|
233 | extern _X_EXPORT SaveScreenProcPtr vgaHWSaveScreenWeak(void);
|
---|
234 |
|
---|
235 | #endif /* _VGAHW_H */
|
---|