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
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
|
/*
Voodoo Banshee driver version 1.0.2
Author: Daryll Strauss
Copyright: 1998,1999
*/
#ifndef _TDFX_H_
#define _TDFX_H_
#include <string.h>
#include <stdio.h>
#include "xf86PciInfo.h"
#include "xf86Pci.h"
#include "xf86DDC.h"
#include "xf86xv.h"
#include "tdfxdefs.h"
#ifndef XF86DRI
#undef TDFXDRI
#endif
#ifdef TDFXDRI
#include "xf86drm.h"
#include "sarea.h"
#define _XF86DRI_SERVER_
#include "dri.h"
#include "GL/glxint.h"
#include "tdfx_dri.h"
#include "tdfx_dripriv.h"
#endif
#define TDFX_VERSION 4000
#define TDFX_NAME "TDFX"
#define TDFX_DRIVER_NAME "tdfx"
#define TDFX_MAJOR_VERSION PACKAGE_VERSION_MAJOR
#define TDFX_MINOR_VERSION PACKAGE_VERSION_MINOR
#define TDFX_PATCHLEVEL PACKAGE_VERSION_PATCHLEVEL
/* Macros to aid source compatibilty between pci-rework and "classic" builds.
*/
#ifdef XSERVER_LIBPCIACCESS
#include <pciaccess.h>
#define DEVICE_ID(p) (p)->device_id
#define PCI_READ_LONG(value, offset, card_index) \
pci_device_cfg_read_u32(pTDFX->PciInfo[(card_index)], & (value), (offset))
#define PCI_WRITE_LONG(value, offset, card_index) \
pci_device_cfg_write_u32(pTDFX->PciInfo[(card_index)], (value), (offset))
#define PCI_IO_BASE(p, region) \
(p)->regions[region].base_addr
#define PCI_MEM_BASE(p, region) \
(p)->regions[region].base_addr
#else
#define DEVICE_ID(p) (p)->chipType
#define PCI_READ_LONG(value, offset, card_index) \
(value) = pciReadLong(pTDFX->PciTag[(card_index)], (offset))
#define PCI_WRITE_LONG(value, offset, card_index) \
pciWriteLong(pTDFX->PciTag[(card_index)], (offset), (value))
#define PCI_IO_BASE(p, region) \
(p)->ioBase[region]
#define PCI_MEM_BASE(p, region) \
(p)->memBase[region]
#endif
struct _TDFXRec;
typedef struct _TDFXRec *TDFXPtr;
#include "tdfx_priv.h"
extern void TDFXSwapContextFifo(ScreenPtr pScreen);
extern void TDFXLostContext(ScreenPtr pScreen);
extern Bool TDFXSetupSLI(ScrnInfoPtr pScrn, Bool sliEnable, int aaSamples);
extern Bool TDFXDisableSLI(TDFXPtr pTDFX);
#ifdef TDFXDRI
extern void FillPrivateDRI(TDFXPtr pTDFX, TDFXDRIPtr pTDFXDRI);
#endif
#if 0
/* These are not normally turned on. They are only included for debugging. */
#define TRACE 1
#define TRACEACCEL 1
#define TDFX_DEBUG_CMDS
#define TRACECURS 1
#define REGDEBUG 1
#define TRACEREG
#endif
#ifdef TRACE
#define TDFXTRACE ErrorF
#else
#define TDFXTRACE if(0) ErrorF
#endif
#ifdef TRACEACCEL
#define TDFXTRACEACCEL ErrorF
#else
#define TDFXTRACEACCEL if(0) ErrorF
#endif
#ifdef TRACECURS
#define TDFXTRACECURS ErrorF
#else
#define TDFXTRACECURS if(0) ErrorF
#endif
#ifdef TRACEREG
#define TDFXTRACEREG ErrorF
#else
#define TDFXTRACEREG if(0) ErrorF
#endif
#ifdef HAVE_XAA_H
#include "xaa.h"
#endif
#include "xf86fbman.h"
#include "xf86Cursor.h"
#include "compat-api.h"
typedef void (*TDFXWriteIndexedByteFunc)(TDFXPtr pTDFX, int addr,
char index, char value);
typedef char (*TDFXReadIndexedByteFunc)(TDFXPtr pTDFX, int addr,
char index);
typedef void (*TDFXWriteWordFunc)(TDFXPtr pTDFX, int addr, int value);
typedef int (*TDFXReadWordFunc)(TDFXPtr pTDFX, int addr);
typedef void (*TDFXWriteChipIndexedByteFunc)(TDFXPtr pTDFX, int chip,
int addr, char index, char value);
typedef char (*TDFXReadChipIndexedByteFunc)(TDFXPtr pTDFX, int chip,
int addr, char index);
typedef void (*TDFXWriteChipWordFunc)(TDFXPtr pTDFX, int chip,
int addr, int value);
typedef int (*TDFXReadChipWordFunc)(TDFXPtr pTDFX, int chip,
int addr);
typedef void (*TDFXSyncFunc)(ScrnInfoPtr pScrn);
typedef void (*TDFXBufferFunc)(TDFXPtr pTDFX, int which);
#if X_BYTE_ORDER == X_BIG_ENDIAN
typedef void (*TDFXWriteFifoFunc)(TDFXPtr pTDFX, int val);
#endif
typedef struct {
unsigned int vidcfg;
unsigned int vidpll;
unsigned int dacmode;
unsigned int vgainit0;
unsigned int vgainit1;
unsigned int miscinit0;
unsigned int miscinit1;
unsigned int screensize;
unsigned int stride;
unsigned int cursloc;
unsigned int startaddr;
unsigned int clip0min;
unsigned int clip0max;
unsigned int clip1min;
unsigned int clip1max;
unsigned int srcbaseaddr;
unsigned int dstbaseaddr;
unsigned char ExtVga[2];
unsigned int dactable[512];
} TDFXRegRec, *TDFXRegPtr;
typedef struct TextureData_t {
int contextid;
void *data;
struct TextureData_t *next;
} TextureData;
#define MAXCHIPS 4
#ifdef XSERVER_LIBPCIACCESS
enum tdfx_chips {
Banshee = 0,
Voodoo3_2000,
Voodoo3_3000,
Voodoo3_Unknown,
Voodoo5,
MAX_VOODOO_CARDS
};
#endif
typedef struct _TDFXRec {
#ifdef XSERVER_LIBPCIACCESS
enum tdfx_chips match_id;
void *MMIOBase[MAXCHIPS];
void *FbBase;
#else
unsigned char *MMIOBase[MAXCHIPS];
unsigned char *FbBase;
unsigned char *myFbBase;
#endif
unsigned long PIOBase[MAXCHIPS];
long FbMapSize;
int pixelFormat;
int stride;
int cpp;
int maxClip;
int MaxClock;
int ChipType;
#ifdef XSERVER_LIBPCIACCESS
struct pci_device *PciInfo[MAXCHIPS];
#else
pciVideoPtr PciInfo;
#endif
unsigned long LinearAddr[MAXCHIPS];
unsigned long MMIOAddr[MAXCHIPS];
EntityInfoPtr pEnt;
int numChips;
#ifndef XSERVER_PCIACCESS
PCITAG PciTag[MAXCHIPS];
#endif
Bool Primary;
int HasSGRAM;
int PciCnt;
int PrevDrawState;
int DrawState;
int Cmd;
int DashedLineSize;
BoxRec prevBlitDest;
TDFXRegRec SavedReg;
TDFXRegRec ModeReg;
#ifdef HAVE_XAA_H
XAAInfoRecPtr AccelInfoRec;
#endif
xf86CursorInfoPtr CursorInfoRec;
CloseScreenProcPtr CloseScreen;
Bool usePIO;
Bool NoAccel;
DGAModePtr DGAModes;
Bool DGAactive;
Bool initDone;
int DGAViewportStatus;
int cursorOffset;
int fbOffset;
int backOffset;
int depthOffset;
int texOffset;
int texSize;
TDFXWriteIndexedByteFunc writeControl;
TDFXReadIndexedByteFunc readControl;
TDFXWriteWordFunc writeLong;
TDFXReadWordFunc readLong;
TDFXWriteChipWordFunc writeChipLong;
TDFXReadChipWordFunc readChipLong;
TDFXSyncFunc sync;
#if X_BYTE_ORDER == X_BIG_ENDIAN
TDFXWriteFifoFunc writeFifo;
#endif
int syncDone;
int scanlineWidth;
unsigned char *scanlineColorExpandBuffers[2];
PROPDATA
#ifdef TDFXDRI
Bool directRenderingEnabled;
DRIInfoPtr pDRIInfo;
int drmSubFD;
int numVisualConfigs;
__GLXvisualConfig* pVisualConfigs;
TDFXConfigPrivPtr pVisualConfigsPriv;
TDFXRegRec DRContextRegs;
#endif
/* State for video */
FBAreaPtr offscreenYUVBuf;
int offscreenYUVBufWidth;
int offscreenYUVBufHeight;
/* This is a small register shadow. I'm only shadowing
* sst2dDstFmt
* sst2dSrcFmt
* If a real register shadow is ever needed we should probably
* shadow everything and make it happen automatically for every write. */
INT32 sst2DSrcFmtShadow;
INT32 sst2DDstFmtShadow;
int pixmapCacheLinesMin;
int pixmapCacheLinesMax;
FBAreaPtr reservedArea;
Bool ShowCache;
int videoKey;
void (*VideoTimerCallback)(ScrnInfoPtr, Time);
FBLinearPtr overlayBuffer;
FBLinearPtr overlayBuffer2; /* for double-buffering */
int whichOverlayBuffer; /* flip-flop */
FBAreaPtr textureBuffer;
Bool TextureXvideo;
XF86VideoAdaptorPtr overlayAdaptor;
XF86VideoAdaptorPtr textureAdaptor;
ScreenBlockHandlerProcPtr BlockHandler;
OptionInfoPtr Options;
ScreenWakeupHandlerProcPtr coreWakeupHandler;
ScreenBlockHandlerProcPtr coreBlockHandler;
I2CBusPtr pI2CBus;
} TDFXRec;
typedef struct {
RegionRec clip;
CARD32 colorKey;
int filterQuality;
CARD32 videoStatus;
Time offTime;
Time freeTime;
} TDFXPortPrivRec, *TDFXPortPrivPtr;
typedef struct {
PROPSAREADATA
int fifoOwner;
int CtxOwner;
int TexOwner;
} TDFXSAREAPriv;
#define TDFXPTR(p) ((TDFXPtr)((p)->driverPrivate))
#define DRAW_STATE_CLIPPING 0x1
#define DRAW_STATE_TRANSPARENT 0x2
#define DRAW_STATE_CLIP1CHANGED 0x4
#define TDFX_FRONT 0
#define TDFX_BACK 1
#define TDFX_DEPTH 2
#define TDFX2XCUTOFF 135000
extern Bool TDFXAccelInit(ScreenPtr pScreen);
extern Bool TDFXCursorInit(ScreenPtr pScreen);
extern void TDFXSync(ScrnInfoPtr pScrn);
extern Bool TDFXDRIScreenInit(ScreenPtr pScreen);
extern void TDFXDRICloseScreen(ScreenPtr pScreen);
extern Bool TDFXDRIFinishScreenInit(ScreenPtr pScreen);
extern Bool TDFXDGAInit(ScreenPtr pScreen);
extern void TDFXCursorGrabMemory(ScreenPtr pScreen);
extern void TDFXSetLFBConfig(TDFXPtr pTDFX);
extern void TDFXSendNOPFifo(ScrnInfoPtr pScrn);
extern Bool TDFXSwitchMode(SWITCH_MODE_ARGS_DECL);
extern void TDFXAdjustFrame(ADJUST_FRAME_ARGS_DECL);
extern void TDFXSetPIOAccess(TDFXPtr pTDFX);
extern void TDFXSetMMIOAccess(TDFXPtr pTDFX);
extern void TDFXWriteLongMMIO(TDFXPtr pTDFX, int addr, int val);
extern int TDFXReadLongMMIO(TDFXPtr pTDFX, int addr);
extern void TDFXWriteChipLongMMIO(TDFXPtr pTDFX, int chip, int addr, int val);
extern void TDFXNeedSync(ScrnInfoPtr pScrn);
extern void TDFXCheckSync(ScrnInfoPtr pScrn);
extern void TDFXFirstSync(ScrnInfoPtr pScrn);
extern void TDFXSetupForScreenToScreenCopy(ScrnInfoPtr pScrn, int xdir,
int ydir, int rop,
unsigned int planemask,
int trans_color);
extern void TDFXSubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, int srcX,
int srcY, int dstX, int dstY,
int w, int h);
extern void TDFXSetupForSolidFill(ScrnInfoPtr pScrn, int color, int rop,
unsigned int planemask);
extern void TDFXSubsequentSolidFillRect(ScrnInfoPtr pScrn, int x, int y,
int w, int h);
extern void TDFXSelectBuffer(TDFXPtr pTDFX, int which);
extern void TDFXInitVideo(ScreenPtr pScreen);
extern void TDFXCloseVideo(ScreenPtr pScreen);
#endif
|