2 * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sub license,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial portions
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19 * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
28 #if 0 /* DEBUG is use in VIA DRI code as a flag */
29 /* #define DEBUG_PRINT */
40 #include "xf86Resources.h"
41 #include "xf86_ansic.h"
43 #include "xf86PciInfo.h"
44 #include "xf86_OSproc.h"
46 #include "xf86Cursor.h"
47 #include "mipointer.h"
65 #include "via_gpioi2c.h"
70 #define _XF86DRI_SERVER_
73 #include "GL/glxint.h"
79 #include "GL/internal/dri_interface.h"
83 /* _SOLO : copied from via_bios.h */
84 /* System Memory CLK */
85 #define VIA_MEM_SDR66 0x00
86 #define VIA_MEM_SDR100 0x01
87 #define VIA_MEM_SDR133 0x02
88 #define VIA_MEM_DDR200 0x03
89 #define VIA_MEM_DDR266 0x04
90 #define VIA_MEM_DDR333 0x05
91 #define VIA_MEM_DDR400 0x06
93 #define DRIVER_NAME "via"
94 #define DRIVER_VERSION "4.1.0"
95 #define VERSION_MAJOR 4
96 #define VERSION_MINOR 1
98 #define VIA_VERSION ((VERSION_MAJOR<<24) | (VERSION_MINOR<<16) | PATCHLEVEL)
100 #define VGAIN8(addr) MMIO_IN8(pVia->MapBase+0x8000, addr)
101 #define VGAIN16(addr) MMIO_IN16(pVia->MapBase+0x8000, addr)
102 #define VGAIN(addr) MMIO_IN32(pVia->MapBase+0x8000, addr)
104 #define VGAOUT8(addr, val) MMIO_OUT8(pVia->MapBase+0x8000, addr, val)
105 #define VGAOUT16(addr, val) MMIO_OUT16(pVia->MapBase+0x8000, addr, val)
106 #define VGAOUT(addr, val) MMIO_OUT32(pVia->MapBase+0x8000, addr, val)
108 #define INREG(addr) MMIO_IN32(pVia->MapBase, addr)
109 #define OUTREG(addr, val) MMIO_OUT32(pVia->MapBase, addr, val)
110 #define INREG16(addr) MMIO_IN16(pVia->MapBase, addr)
111 #define OUTREG16(addr, val) MMIO_OUT16(pVia->MapBase, addr, val)
113 #define VIA_PIXMAP_CACHE_SIZE (256 * 1024)
114 #define VIA_CURSOR_SIZE (4 * 1024)
115 #define VIA_VQ_SIZE (256 * 1024)
118 unsigned int mode
, refresh
, resMode
;
119 int countWidthByQWord
;
120 int offsetWidthByQWord
;
121 unsigned char SR08
, SR0A
, SR0F
;
123 /* extended Sequencer registers */
124 unsigned char SR10
, SR11
, SR12
, SR13
,SR14
,SR15
,SR16
;
125 unsigned char SR17
, SR18
, SR19
, SR1A
,SR1B
,SR1C
,SR1D
,SR1E
;
126 unsigned char SR1F
, SR20
, SR21
, SR22
,SR23
,SR24
,SR25
,SR26
;
127 unsigned char SR27
, SR28
, SR29
, SR2A
,SR2B
,SR2C
,SR2D
,SR2E
;
128 unsigned char SR2F
, SR30
, SR31
, SR32
,SR33
,SR34
,SR40
,SR41
;
129 unsigned char SR42
, SR43
, SR44
, SR45
,SR46
,SR47
;
133 /* extended CRTC registers */
134 unsigned char CR13
, CR30
, CR31
, CR32
, CR33
, CR34
, CR35
, CR36
;
135 unsigned char CR37
, CR38
, CR39
, CR3A
, CR40
, CR41
, CR42
, CR43
;
136 unsigned char CR44
, CR45
, CR46
, CR47
, CR48
, CR49
, CR4A
;
137 unsigned char CRTCRegs
[83];
138 unsigned char TVRegs
[0xCF];
139 unsigned char TVRegs2
[0xCF];
140 /* unsigned char LCDRegs[0x40];*/
142 } VIARegRec
, *VIARegPtr
;
145 typedef struct _VIA
{
149 xf86CursorInfoPtr CursorInfoRec
;
151 VIAModeInfoPtr VIAModeList
;
154 int Bpp
, Bpl
, ScissB
;
157 unsigned long videoRambytes
;
165 /* These are physical addresses. */
166 unsigned long FrameBufferBase
;
167 unsigned long MmioBase
;
169 /* These are linear addresses. */
170 unsigned char* MapBase
;
171 unsigned char* VidMapBase
;
172 unsigned char* BltBase
;
173 unsigned char* MapBaseDense
;
174 unsigned char* FBBase
;
175 unsigned char* FBStart
;
177 int PrimaryVidMapped
;
179 int minClock
, maxClock
;
180 int MCLK
, REFCLK
, LCDclk
;
183 /* Here are all the Options */
194 CloseScreenProcPtr CloseScreen
;
204 /* Support for shadowFB and rotation */
205 unsigned char* ShadowPtr
;
207 void (*PointerMoved
)(int index
, int x
, int y
);
209 /* Support for XAA acceleration */
211 XAAInfoRecPtr AccelInfoRec
;
215 uint32_t SavedFgColor
;
216 uint32_t SavedBgColor
;
217 uint32_t SavedPattern0
;
218 uint32_t SavedPattern1
;
219 uint32_t SavedPatternAddr
;
222 /* Support for Int10 processing */
223 xf86Int10InfoPtr pInt10
;
226 VIABIOSInfoPtr pBIOSInfo
;
227 VGABIOSVERPtr pBIOSVer
;
230 /* Support for DGA */
232 /*DGAModePtr DGAModes;*/
234 int DGAViewportStatus
;
236 /* The various wait handlers. */
237 int (*myWaitIdle
)(struct _VIA
*);
252 /* Capture information */
253 VIACAPINFO CapInfo
[2]; /* 2 capture information */
257 uint32_t Cap0_Deinterlace;
258 uint32_t Cap1_Deinterlace;
262 int Capture_OverScanOff;
263 int NoMPEGHQV_VFilter;
266 int directRenderingEnabled
;
269 int numVisualConfigs
;
270 __GLXvisualConfig
* pVisualConfigs
;
271 VIAConfigPrivPtr pVisualConfigsPriv
;
272 unsigned long agpHandle
;
273 unsigned long registerHandle
;
275 unsigned char *agpBase
;
276 unsigned int agpSize
;
281 unsigned long agpHandle
;
282 unsigned long registerHandle
;
283 unsigned long agpAddr
;
284 unsigned char *agpBase
;
285 unsigned int agpSize
;
290 uint16_t ActiveDevice
; /* if SAMM, non-equal pBIOSInfo->ActiveDevice */
291 unsigned char *CursorImage
;
296 unsigned char MemClk
;
297 int EnableExtendedFIFO
;
298 VIADRIPtr devPrivate
;
302 /* Shortcuts. These depend on a local symbol "pVia". */
304 #define WaitIdle() pVia->myWaitIdle(pVia)
305 #define VIAPTR(p) ((VIAPtr)((p)->driverPrivate))
307 #endif /* _VIA_DRIVER_H */