997b2e41a702d02464a388e80a463ea98925be25
[mesa.git] / src / mesa / drivers / dri / unichrome / server / via_driver.h
1 /* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/via/via_driver.h,v 1.7 2003/11/06 18:38:11 tsi Exp $ */
2 /*
3 * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
4 * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sub license,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice (including the
14 * next paragraph) shall be included in all copies or substantial portions
15 * of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
20 * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 * DEALINGS IN THE SOFTWARE.
24 */
25
26 #ifndef _VIA_DRIVER_H
27 #define _VIA_DRIVER_H
28
29 #if 0 /* DEBUG is use in VIA DRI code as a flag */
30 /* #define DEBUG_PRINT */
31 #ifdef DEBUG_PRINT
32 #define DEBUG(x) x
33 #else
34 #define DEBUG(x)
35 #endif
36 #endif
37
38 #if 0
39 #include "vgaHW.h"
40 #include "xf86.h"
41 #include "xf86Resources.h"
42 #include "xf86_ansic.h"
43 #include "xf86Pci.h"
44 #include "xf86PciInfo.h"
45 #include "xf86_OSproc.h"
46 #include "compiler.h"
47 #include "xf86Cursor.h"
48 #include "mipointer.h"
49 #include "micmap.h"
50
51 #define USE_FB
52 #ifdef USE_FB
53 #include "fb.h"
54 #else
55 #include "cfb.h"
56 #include "cfb16.h"
57 #include "cfb32.h"
58 #endif
59
60 #include "xf86cmap.h"
61 #include "vbe.h"
62 #include "xaa.h"
63
64 #include "via_regs.h"
65 #include "via_bios.h"
66 #include "via_gpioi2c.h"
67 #include "via_priv.h"
68 #include "ginfo.h"
69
70 #ifdef XF86DRI
71 #define _XF86DRI_SERVER_
72 #include "sarea.h"
73 #include "dri.h"
74 #include "GL/glxint.h"
75 #include "via_dri.h"
76 #endif
77 #else
78 #include "via_regs.h"
79
80 #include "GL/internal/dri_interface.h"
81 #include "via_dri.h"
82 #endif
83
84 /* _SOLO : copied from via_bios.h */
85 /* System Memory CLK */
86 #define VIA_MEM_SDR66 0x00
87 #define VIA_MEM_SDR100 0x01
88 #define VIA_MEM_SDR133 0x02
89 #define VIA_MEM_DDR200 0x03
90 #define VIA_MEM_DDR266 0x04
91 #define VIA_MEM_DDR333 0x05
92 #define VIA_MEM_DDR400 0x06
93
94 #define DRIVER_NAME "via"
95 #define DRIVER_VERSION "4.1.0"
96 #define VERSION_MAJOR 4
97 #define VERSION_MINOR 1
98 #define PATCHLEVEL 41
99 #define VIA_VERSION ((VERSION_MAJOR<<24) | (VERSION_MINOR<<16) | PATCHLEVEL)
100
101 #define VGAIN8(addr) MMIO_IN8(pVia->MapBase+0x8000, addr)
102 #define VGAIN16(addr) MMIO_IN16(pVia->MapBase+0x8000, addr)
103 #define VGAIN(addr) MMIO_IN32(pVia->MapBase+0x8000, addr)
104
105 #define VGAOUT8(addr, val) MMIO_OUT8(pVia->MapBase+0x8000, addr, val)
106 #define VGAOUT16(addr, val) MMIO_OUT16(pVia->MapBase+0x8000, addr, val)
107 #define VGAOUT(addr, val) MMIO_OUT32(pVia->MapBase+0x8000, addr, val)
108
109 #define INREG(addr) MMIO_IN32(pVia->MapBase, addr)
110 #define OUTREG(addr, val) MMIO_OUT32(pVia->MapBase, addr, val)
111 #define INREG16(addr) MMIO_IN16(pVia->MapBase, addr)
112 #define OUTREG16(addr, val) MMIO_OUT16(pVia->MapBase, addr, val)
113
114 #define VIA_PIXMAP_CACHE_SIZE (256 * 1024)
115 #define VIA_CURSOR_SIZE (4 * 1024)
116 #define VIA_VQ_SIZE (256 * 1024)
117
118 typedef struct {
119 unsigned int mode, refresh, resMode;
120 int countWidthByQWord;
121 int offsetWidthByQWord;
122 unsigned char SR08, SR0A, SR0F;
123
124 /* extended Sequencer registers */
125 unsigned char SR10, SR11, SR12, SR13,SR14,SR15,SR16;
126 unsigned char SR17, SR18, SR19, SR1A,SR1B,SR1C,SR1D,SR1E;
127 unsigned char SR1F, SR20, SR21, SR22,SR23,SR24,SR25,SR26;
128 unsigned char SR27, SR28, SR29, SR2A,SR2B,SR2C,SR2D,SR2E;
129 unsigned char SR2F, SR30, SR31, SR32,SR33,SR34,SR40,SR41;
130 unsigned char SR42, SR43, SR44, SR45,SR46,SR47;
131
132 unsigned char Clock;
133
134 /* extended CRTC registers */
135 unsigned char CR13, CR30, CR31, CR32, CR33, CR34, CR35, CR36;
136 unsigned char CR37, CR38, CR39, CR3A, CR40, CR41, CR42, CR43;
137 unsigned char CR44, CR45, CR46, CR47, CR48, CR49, CR4A;
138 unsigned char CRTCRegs[83];
139 unsigned char TVRegs[0xCF];
140 unsigned char TVRegs2[0xCF];
141 /* unsigned char LCDRegs[0x40];*/
142
143 } VIARegRec, *VIARegPtr;
144
145
146 typedef struct _VIA {
147 VIARegRec SavedReg;
148 VIARegRec ModeReg;
149 #if 0
150 xf86CursorInfoPtr CursorInfoRec;
151 int stateMode;
152 VIAModeInfoPtr VIAModeList;
153 #endif
154 int ModeStructInit;
155 int Bpp, Bpl, ScissB;
156 unsigned PlaneMask;
157
158 unsigned long videoRambytes;
159 int videoRamKbytes;
160 int FBFreeStart;
161 int FBFreeEnd;
162 int CursorStart;
163 int VQStart;
164 int VQEnd;
165
166 /* These are physical addresses. */
167 unsigned long FrameBufferBase;
168 unsigned long MmioBase;
169
170 /* These are linear addresses. */
171 unsigned char* MapBase;
172 unsigned char* VidMapBase;
173 unsigned char* BltBase;
174 unsigned char* MapBaseDense;
175 unsigned char* FBBase;
176 unsigned char* FBStart;
177
178 int PrimaryVidMapped;
179 int dacSpeedBpp;
180 int minClock, maxClock;
181 int MCLK, REFCLK, LCDclk;
182 double refclk_fact;
183
184 /* Here are all the Options */
185 int VQEnable;
186 int pci_burst;
187 int NoPCIRetry;
188 int hwcursor;
189 int NoAccel;
190 int shadowFB;
191 int NoDDCValue;
192 int rotate;
193
194 #if 0
195 CloseScreenProcPtr CloseScreen;
196 pciVideoPtr PciInfo;
197 PCITAG PciTag;
198 #endif
199 int Chipset;
200 int ChipId;
201 int ChipRev;
202 /*vbeInfoPtr pVbe;*/
203 int EntityIndex;
204
205 /* Support for shadowFB and rotation */
206 unsigned char* ShadowPtr;
207 int ShadowPitch;
208 void (*PointerMoved)(int index, int x, int y);
209
210 /* Support for XAA acceleration */
211 #if 0
212 XAAInfoRecPtr AccelInfoRec;
213 xRectangle Rect;
214 #endif
215 u_int32_t SavedCmd;
216 u_int32_t SavedFgColor;
217 u_int32_t SavedBgColor;
218 u_int32_t SavedPattern0;
219 u_int32_t SavedPattern1;
220 u_int32_t SavedPatternAddr;
221
222 #if 0
223 /* Support for Int10 processing */
224 xf86Int10InfoPtr pInt10;
225
226 /* BIOS Info Ptr */
227 VIABIOSInfoPtr pBIOSInfo;
228 VGABIOSVERPtr pBIOSVer;
229 #endif
230
231 /* Support for DGA */
232 int numDGAModes;
233 /*DGAModePtr DGAModes;*/
234 int DGAactive;
235 int DGAViewportStatus;
236
237 /* The various wait handlers. */
238 int (*myWaitIdle)(struct _VIA*);
239
240 #if 0
241 /* I2C & DDC */
242 I2CBusPtr I2C_Port1;
243 I2CBusPtr I2C_Port2;
244 xf86MonPtr DDC1;
245 xf86MonPtr DDC2;
246 #endif
247
248 /* MHS */
249 int IsSecondary;
250 int HasSecondary;
251
252 #if 0
253 /* Capture information */
254 VIACAPINFO CapInfo[2]; /* 2 capture information */
255 #endif
256
257 /*
258 u_int32_t Cap0_Deinterlace;
259 u_int32_t Cap1_Deinterlace;
260
261 int Cap0_FieldSwap;
262 int NoCap0_HFilter;
263 int Capture_OverScanOff;
264 int NoMPEGHQV_VFilter;
265 */
266 #ifdef XF86DRI
267 int directRenderingEnabled;
268 DRIInfoPtr pDRIInfo;
269 int drmFD;
270 int numVisualConfigs;
271 __GLXvisualConfig* pVisualConfigs;
272 VIAConfigPrivPtr pVisualConfigsPriv;
273 unsigned long agpHandle;
274 unsigned long registerHandle;
275 u_int32_t agpAddr;
276 unsigned char *agpBase;
277 unsigned int agpSize;
278 int IsPCI;
279 int drixinerama;
280 #else
281 int drmFD;
282 unsigned long agpHandle;
283 unsigned long registerHandle;
284 unsigned long agpAddr;
285 unsigned char *agpBase;
286 unsigned int agpSize;
287 int IsPCI;
288 #endif
289
290 int V4LEnabled;
291 u_int16_t ActiveDevice; /* if SAMM, non-equal pBIOSInfo->ActiveDevice */
292 unsigned char *CursorImage;
293 u_int32_t CursorFG;
294 u_int32_t CursorBG;
295 u_int32_t CursorMC;
296
297 unsigned char MemClk;
298 int EnableExtendedFIFO;
299 VIADRIPtr devPrivate;
300 } VIARec, *VIAPtr;
301
302
303 /* Shortcuts. These depend on a local symbol "pVia". */
304
305 #define WaitIdle() pVia->myWaitIdle(pVia)
306 #define VIAPTR(p) ((VIAPtr)((p)->driverPrivate))
307
308 #endif /* _VIA_DRIVER_H */
309