1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
|
/**********************************************************************
Copyright 1998, 1999 by Precision Insight, Inc., Cedar Park, Texas.
All Rights Reserved
Permission to use, copy, modify, distribute, and sell this software and
its documentation for any purpose is hereby granted without fee,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of Precision Insight not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission. Precision Insight
and its suppliers make no representations about the suitability of this
software for any purpose. It is provided "as is" without express or
implied warranty.
PRECISION INSIGHT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
**********************************************************************/
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo.h,v 1.23tsi Exp $ */
/*
* The original Precision Insight driver for
* XFree86 v.3.3 has been sponsored by Red Hat.
*
* Authors:
* Jens Owen (jens@tungstengraphics.com)
* Kevin E. Martin (kevin@precisioninsight.com)
*
* Port to Xfree86 v.4.0
* 1998, 1999 by Egbert Eich (Egbert.Eich@Physik.TU-Darmstadt.DE)
*/
#include <string.h>
/* All drivers should typically include these */
#include "xf86.h"
#include "xf86_OSproc.h"
/* Everything using inb/outb, etc needs "compiler.h" */
#include "compiler.h"
#include "xaa.h"
#include "xaalocal.h" /* XAA internals as we replace some of XAA */
#include "xaaWrapper.h"
#include "xf86Cursor.h"
#include "shadowfb.h"
#include "vbe.h"
/* Needed by the Shadow Framebuffer */
#include "shadow.h"
/* Drivers that need to access the PCI config space directly need this */
#include "xf86Pci.h"
#include "xf86i2c.h"
#include "xf86xv.h"
#include <X11/extensions/Xv.h>
/*
* Driver data structures.
*/
#include "neo_reg.h"
#include "neo_macros.h"
/* Supported chipsets */
typedef enum {
NM2070,
NM2090,
NM2093,
NM2097,
NM2160,
NM2200,
NM2230,
NM2360,
NM2380
} NEOType;
/* function prototypes */
extern Bool NEOSwitchMode(int scrnIndex, DisplayModePtr mode, int flags);
extern void NEOAdjustFrame(int scrnIndex, int x, int y, int flags);
/* in neo_2070.c */
extern Bool Neo2070AccelInit(ScreenPtr pScreen);
/* in neo_2090.c */
extern Bool Neo2090AccelInit(ScreenPtr pScreen);
/* in neo_2097.c */
extern Bool Neo2097AccelInit(ScreenPtr pScreen);
/* in neo_2200.c */
extern Bool Neo2200AccelInit(ScreenPtr pScreen);
/* in neo_cursor.c */
extern Bool NeoCursorInit(ScreenPtr pScrn);
extern void NeoShowCursor(ScrnInfoPtr pScrn);
extern void NeoHideCursor(ScrnInfoPtr pScrn);
/* in neo_bank.c */
int NEOSetReadWrite(ScreenPtr pScreen, int bank);
int NEOSetWrite(ScreenPtr pScreen, int bank);
int NEOSetRead(ScreenPtr pScreen, int bank);
/* in neo_i2c.c */
extern Bool neo_I2CInit(ScrnInfoPtr pScrn);
/* in neo_shadow.c */
void neoShadowUpdate (ScreenPtr pScreen, shadowBufPtr pBuf);
void neoPointerMoved(int index, int x, int y);
void neoRefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox);
void neoRefreshArea8(ScrnInfoPtr pScrn, int num, BoxPtr pbox);
void neoRefreshArea16(ScrnInfoPtr pScrn, int num, BoxPtr pbox);
void neoRefreshArea24(ScrnInfoPtr pScrn, int num, BoxPtr pbox);
void neoRefreshArea32(ScrnInfoPtr pScrn, int num, BoxPtr pbox);
/* in neo_dga.c */
Bool NEODGAInit(ScreenPtr pScreen);
/* in neo_video.c */
extern void NEOInitVideo(ScreenPtr pScreen);
extern void NEOResetVideo(ScrnInfoPtr pScrn);
/* shadow regs */
#define NEO_EXT_CR_MAX 0x85
#define NEO_EXT_GR_MAX 0xC7
typedef struct {
unsigned char CR[NEO_EXT_CR_MAX+1];
unsigned char GR[NEO_EXT_GR_MAX+1];
} regSaveRec, *regSavePtr;
/* registers */
typedef struct {
unsigned char GeneralLockReg;
unsigned char ExtCRTDispAddr;
unsigned char ExtCRTOffset;
unsigned char SysIfaceCntl1;
unsigned char SysIfaceCntl2;
unsigned char ExtColorModeSelect;
unsigned char SingleAddrPage;
unsigned char DualAddrPage;
unsigned char biosMode;
unsigned char PanelDispCntlReg1;
unsigned char PanelDispCntlReg2;
unsigned char PanelDispCntlReg3;
unsigned char PanelVertCenterReg1;
unsigned char PanelVertCenterReg2;
unsigned char PanelVertCenterReg3;
unsigned char PanelVertCenterReg4;
unsigned char PanelVertCenterReg5;
unsigned char PanelHorizCenterReg1;
unsigned char PanelHorizCenterReg2;
unsigned char PanelHorizCenterReg3;
unsigned char PanelHorizCenterReg4;
unsigned char PanelHorizCenterReg5;
unsigned char Sequencer1;
Bool ProgramVCLK;
unsigned char VCLK3NumeratorLow;
unsigned char VCLK3NumeratorHigh;
unsigned char VCLK3Denominator;
unsigned char VerticalExt;
regSavePtr reg;
} NeoRegRec, *NeoRegPtr;
typedef struct {
/* Hardware cursor address */
unsigned int CursorAddress;
Bool UseHWCursor;
Bool NoCursorMode;
unsigned char CursTemp[1024];
/* Boundaries of the pixmap cache */
unsigned int cacheStart;
unsigned int cacheEnd;
/* Blitter */
unsigned int tmpBltCntlFlags;
unsigned int BltCntlFlags;
unsigned int BltModeFlags;
unsigned int ColorShiftAmt;
unsigned int Pitch;
unsigned int PixelWidth;
unsigned int PlaneMask;
int CPUToScreenColorExpandFill_x;
int CPUToScreenColorExpandFill_y;
int CPUToScreenColorExpandFill_w;
int CPUToScreenColorExpandFill_h;
int CPUToScreenColorExpandFill_skipleft;
} NEOACLRec, *NEOACLPtr;
#define NEOACLPTR(p) &((NEOPtr)((p)->driverPrivate))->Accel
/* globals */
typedef struct neoRec
{
int NeoChipset;
pciVideoPtr PciInfo;
PCITAG PciTag;
EntityInfoPtr pEnt;
XAAInfoRecPtr AccelInfoRec;
NEOACLRec Accel;
unsigned long NeoMMIOAddr;
unsigned long NeoLinearAddr;
unsigned char* NeoMMIOBase;
unsigned long NeoMMIOAddr2;
unsigned char* NeoMMIOBase2;
unsigned char* NeoFbBase;
long NeoFbMapSize;
unsigned long vgaIOBase;
DGAModePtr DGAModes;
int numDGAModes;
Bool DGAactive;
int DGAViewportStatus;
/* ??? */
int NeoFifoCount;
/* cursor */
int NeoCursorMem;
Bool NeoHWCursorShown;
Bool NeoHWCursorInitialized;
xf86CursorInfoPtr CursorInfo;
int NeoCursorOffset;
int NeoCursorPrevX;
int NeoCursorPrevY;
unsigned char *NeoCursorImage;
/* Panels size */
int NeoPanelWidth;
int NeoPanelHeight;
/* options */
OptionInfoPtr Options;
Bool noLinear;
Bool noAccel;
Bool noAccelSet;
Bool swCursor;
Bool noMMIO;
Bool internDisp;
Bool externDisp;
Bool noLcdStretch;
Bool shadowFB;
Bool lcdCenter;
Bool onPciBurst;
Bool progLcdRegs;
Bool progLcdStretch;
Bool progLcdStretchOpt;
Bool overrideValidate;
Bool strangeLockups;
/* registers */
NeoRegRec NeoModeReg;
NeoRegRec NeoSavedReg;
/* proc pointer */
CloseScreenProcPtr CloseScreen;
I2CBusPtr I2C;
vbeInfoPtr pVbe;
unsigned char * ShadowPtr;
int ShadowPitch;
RefreshAreaFuncPtr refreshArea;
void (*PointerMoved)(int index, int x, int y);
int rotate;
Bool showcache;
Bool video;
double videoHZoom;
double videoVZoom;
XF86VideoAdaptorPtr overlayAdaptor;
int overlay;
int overlay_offset;
int videoKey;
int interlace;
SyncFunc accelSync;
} NEORec, *NEOPtr;
typedef struct {
int x_res;
int y_res;
int mode;
} biosMode;
/* The privates of the NEO driver */
#define NEOPTR(p) ((NEOPtr)((p)->driverPrivate))
/* I/O register offsets */
#define GRAX 0x3CE
/* vga IO functions */
#define VGArCR(index) (*hwp->readCrtc)(hwp, index)
#define VGAwCR(index, val) (*hwp->writeCrtc)(hwp, index, val)
#define VGArGR(index) (*hwp->readGr)(hwp, index)
#define VGAwGR(index, val) (*hwp->writeGr)(hwp, index, val)
#define VGArSR(index) (*hwp->readSeq)(hwp, index)
#define VGAwSR(index, val) (*hwp->writeSeq)(hwp, index, val)
/* memory mapped register access macros */
#define INREG8(addr) MMIO_IN8(nPtr->NeoMMIOBase, addr)
#define INREG16(addr) MMIO_IN16(nPtr->NeoMMIOBase, addr)
#define INREG(addr) MMIO_IN32(nPtr->NeoMMIOBase, addr)
#define OUTREG8(addr, val) MMIO_OUT8(nPtr->NeoMMIOBase, addr, val)
#define OUTREG16(addr, val) MMIO_OUT16(nPtr->NeoMMIOBase, addr, val)
#define OUTREG(addr, val) MMIO_OUT32(nPtr->NeoMMIOBase, addr, val)
/* This swizzle macro is to support the manipulation of cursor masks when
* the sprite moves off the left edge of the display. This code is
* platform specific, and is known to work with 32bit little endian machines
*/
#define SWIZZLE32(__b) { \
((unsigned char *)&__b)[0] = byte_reversed[((unsigned char *)&__b)[0]]; \
((unsigned char *)&__b)[1] = byte_reversed[((unsigned char *)&__b)[1]]; \
((unsigned char *)&__b)[2] = byte_reversed[((unsigned char *)&__b)[2]]; \
((unsigned char *)&__b)[3] = byte_reversed[((unsigned char *)&__b)[3]]; \
}
#define PROBED_NM2070 0x01
#define PROBED_NM2090 0x42
#define PROBED_NM2093 0x43
#define PROBED_NM2097 0x83
#define PROBED_NM2160 0x44
#define PROBED_NM2200 0x45
|