1/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/glint_regs.h,v 1.36tsi Exp $ */
2
3/*
4 * glint register file
5 *
6 * Copyright by Stefan Dirsch, Dirk Hohndel, Alan Hourihane
7 * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk>
8 *          Dirk Hohndel, <hohndel@suse.de>
9 *          Stefan Dirsch, <sndirsch@suse.de>
10 *          Simon P., <sim@suse.de>
11 *
12 * this work is sponsored by S.u.S.E. GmbH, Fuerth, Elsa GmbH, Aachen and
13 * Siemens Nixdorf Informationssysteme
14 *
15 */
16
17#ifndef _GLINTREG_H_
18#define _GLINTREG_H_
19
20#include "compiler.h"
21
22/* The chips we know */
23#define PCI_CHIP_3DLABS_300SX					0x01
24#define PCI_CHIP_3DLABS_500TX					0x02
25#define PCI_CHIP_3DLABS_DELTA					0x03
26#define PCI_CHIP_3DLABS_PERMEDIA				0x04
27#define PCI_CHIP_3DLABS_MX					0x06
28#define PCI_CHIP_3DLABS_PERMEDIA2				0x07
29#define PCI_CHIP_3DLABS_GAMMA					0x08
30#define PCI_CHIP_3DLABS_PERMEDIA2V				0x09
31#define PCI_CHIP_3DLABS_PERMEDIA3				0x0A
32#define PCI_CHIP_3DLABS_PERMEDIA4				0x0C
33#define PCI_CHIP_3DLABS_R4					0x0D
34#define PCI_CHIP_3DLABS_GAMMA2					0x0E
35
36/* The boards we know */
37#define IS_GLORIAXXL	((pGlint->PciInfo->subsysVendor == 0x1048) && \
38			 (pGlint->PciInfo->subsysCard   == 0x0a42))
39
40#define IS_GLORIASYNERGY ((pGlint->PciInfo->subsysVendor == 0x1048) && \
41			 (pGlint->PciInfo->subsysCard   == 0x0a32))
42
43#define IS_GMX2000	((pGlint->PciInfo->subsysVendor == 0x3d3d) && \
44			 (pGlint->PciInfo->subsysCard   == 0x0106))
45
46#define IS_J2000	((pGlint->PciInfo->subsysVendor == 0x1097) && \
47			 (pGlint->PciInfo->subsysCard   == 0x3d32))
48
49#define IS_JPRO		((pGlint->PciInfo->subsysVendor == 0x1097) && \
50			 (pGlint->PciInfo->subsysCard   == 0x3db3))
51
52/* COMPAQ OEM VX1 PCI
53 *   subsys == 0x0121 if VGA is enabled
54 *   subsys == 0x000a if VGA has never been enabled
55 */
56#define IS_PCI_QVX1	(pGlint->PciInfo->subsysVendor == 0x3d3d &&  \
57                         ((pGlint->PciInfo->subsysCard == 0x0121) ||  \
58			  (pGlint->PciInfo->subsysCard == 0x000a)))
59
60/* COMPAQ OEM VX1 AGP
61 *   subsys == 0x0144 if VGA is enabled
62 *   subsys == 0x000c if VGA has never been enabled
63 */
64#define IS_AGP_QVX1	(pGlint->PciInfo->subsysVendor == 0x3d3d &&  \
65			 ((pGlint->PciInfo->subsysCard == 0x0144) ||  \
66			  (pGlint->PciInfo->subsysCard == 0x000c)))
67
68#define IS_QVX1		(IS_PCI_QVX1 || IS_AGP_QVX1)
69
70#define IS_ELSA_SYNERGY	((pGlint->PciInfo->subsysVendor == 0x1048) && \
71			 (pGlint->PciInfo->subsysCard   == 0x0a32))
72
73/* COMPAQ OEM Permedia 2V with VGA disable jumper - 0x13e9 ? */
74#define IS_QPM2V	((pGlint->PciInfo->subsysVendor == 0x13e9) && \
75			 ((pGlint->PciInfo->subsysCard == 0x0100) ||  \
76			  (pGlint->PciInfo->subsysCard == 0x0002)))
77
78/**********************************************
79*  GLINT 500TX Configuration Region Registers *
80***********************************************/
81
82/* Device Identification */
83#define CFGVendorId						0x0000
84#define PCI_VENDOR_3DLABS					0x3D3D
85#define PCI_VENDOR_TI						0x104C
86#define CFGDeviceId						0x0002
87
88#define CFGRevisionId						0x08
89#define CFGClassCode						0x09
90#define CFGHeaderType						0x0E
91
92/* Device Control/Status */
93#define CFGCommand							0x04
94#define CFGStatus							0x06
95
96/* Miscellaneous Functions */
97#define CFGBist								0x0f
98#define CFGLatTimer							0x0d
99#define CFGCacheLine							0x0c
100#define CFGMaxLat							0x3f
101#define CFGMinGrant							0x3e
102#define CFGIntPin							0x3d
103#define CFGIntLine							0x3c
104
105/* Base Adresses */
106#define CFGBaseAddr0							0x10
107#define CFGBaseAddr1							0x14
108#define CFGBaseAddr2							0x18
109#define CFGBaseAddr3							0x1C
110#define CFGBaseAddr4							0x20
111#define CFGRomAddr							0x30
112
113
114
115/**********************************
116 * GLINT 500TX Region 0 Registers *
117 **********************************/
118
119/* Control Status Registers */
120#define ResetStatus							0x0000
121#define IntEnable							0x0008
122#define IntFlags							0x0010
123#define InFIFOSpace							0x0018
124#define OutFIFOWords							0x0020
125#define DMAAddress							0x0028
126#define DMACount							0x0030
127#define ErrorFlags							0x0038
128#define VClkCtl								0x0040
129#define TestRegister							0x0048
130#define Aperture0							0x0050
131#define Aperture1							0x0058
132#define DMAControl							0x0060
133#define FIFODis								0x0068
134
135/* GLINT PerMedia Region 0 additional Registers */
136#define ChipConfig							0x0070
137#define   SCLK_SEL_MASK		(3 << 10)
138#define   SCLK_SEL_MCLK_HALF	(3 << 10)
139#define ByDMAControl							0x00D8
140
141/* GLINT 500TX LocalBuffer Registers */
142#define LBMemoryCtl							0x1000
143#define   LBNumBanksMask	0x00000001
144#define    LBNumBanks1		(0)
145#define    LBNumBanks2		(1)
146#define   LBPageSizeMask        0x00000006
147#define    LBPageSize256	(0<<1)
148#define    LBPageSize512	(1<<1)
149#define    LBPageSize1024	(2<<1)
150#define    LBPageSize2048	(3<<1)
151#define   LBRASCASLowMask	0x00000018
152#define    LBRASCASLow2		(0<<3)
153#define    LBRASCASLow3		(1<<3)
154#define    LBRASCASLow4		(2<<3)
155#define    LBRASCASLow5		(3<<3)
156#define   LBRASPrechargeMask	0x00000060
157#define    LBRASPrecharge2	(0<<5)
158#define    LBRASPrecharge3	(1<<5)
159#define    LBRASPrecharge4	(2<<5)
160#define    LBRASPrecharge5	(3<<5)
161#define   LBCASLowMask		0x00000180
162#define    LBCASLow1		(0<<7)
163#define    LBCASLow2		(1<<7)
164#define    LBCASLow3		(2<<7)
165#define    LBCASLow4		(3<<7)
166#define   LBPageModeMask	0x00000200
167#define    LBPageModeEnabled	(0<<9)
168#define    LBPageModeDisabled	(1<<9)
169#define   LBRefreshCountMask    0x0003fc00
170#define   LBRefreshCountShift   10
171
172#define LBMemoryEDO							0x1008
173#define   LBEDOMask		0x00000001
174#define    LBEDODisabled	(0)
175#define    LBEDOEnabled		(1)
176#define   LBEDOBankSizeMask	0x0000000e
177#define    LBEDOBankSizeDiabled	(0<<1)
178#define    LBEDOBankSize256K	(1<<1)
179#define    LBEDOBankSize512K	(2<<1)
180#define    LBEDOBankSize1M	(3<<1)
181#define    LBEDOBankSize2M	(4<<1)
182#define    LBEDOBankSize4M	(5<<1)
183#define    LBEDOBankSize8M	(6<<1)
184#define    LBEDOBankSize16M	(7<<1)
185#define   LBTwoPageDetectorMask	0x00000010
186#define    LBSinglePageDetector	(0<<4)
187#define    LBTwoPageDetector	(1<<4)
188
189/* GLINT PerMedia Memory Control Registers */
190#define PMReboot							0x1000
191#define PMRomControl							0x1040
192#define PMBootAddress							0x1080
193#define PMMemConfig							0x10C0
194#    define RowCharge8    1 << 10
195#    define TimeRCD8      1 <<  7
196#    define TimeRC8       0x6 << 3
197#    define TimeRP8       1
198#    define CAS3Latency8  0 << 16
199#    define BootAdress8   0x10
200#    define NumberBanks8  0x3 << 29
201#    define RefreshCount8 0x41 << 21
202#    define TimeRASMin8   1 << 13
203#    define DeadCycle8    1 << 17
204#    define BankDelay8    0 << 18
205#    define Burst1Cycle8  1 << 31
206#    define SDRAM8        0 << 4
207
208#    define RowCharge6    1 << 10
209#    define TimeRCD6      1 <<  7
210#    define TimeRC6       0x6 << 3
211#    define TimeRP6       0x2
212#    define CAS3Latency6  1 << 16
213#    define BootAdress6   0x60
214#    define NumberBanks6  0x2 << 29
215#    define RefreshCount6 0x41 << 21
216#    define TimeRASMin6   1 << 13
217#    define DeadCycle6    1 << 17
218#    define BankDelay6    0 << 18
219#    define Burst1Cycle6  1 << 31
220#    define SDRAM6        0 << 4
221
222#    define RowCharge4    0 << 10
223#    define TimeRCD4      0 <<  7
224#    define TimeRC4       0x4 << 3
225#    define TimeRP4       1
226#    define CAS3Latency4  0 << 16
227#    define BootAdress4   0x10
228#    define NumberBanks4  1 << 29
229#    define RefreshCount4 0x30 << 21
230#    define TimeRASMin4   1 << 13
231#    define DeadCycle4    0 << 17
232#    define BankDelay4    0 << 18
233#    define Burst1Cycle4  1 << 31
234#    define SDRAM4        0 << 4
235
236/* Permedia 2 Control */
237#define MemControl							0x1040
238
239#define PMBypassWriteMask						0x1100
240#define PMFramebufferWriteMask					        0x1140
241#define PMCount								0x1180
242
243/* Framebuffer Registers */
244#define FBMemoryCtl							0x1800
245#define FBModeSel							0x1808
246#define FBGCWrMask							0x1810
247#define FBGCColorLower							0x1818
248#define FBTXMemCtl							0x1820
249#define FBWrMaskk							0x1830
250#define FBGCColorUpper							0x1838
251
252/* Core FIFO */
253#define OutputFIFO							0x2000
254
255/* 500TX Internal Video Registers */
256#define VTGHLimit							0x3000
257#define VTGHSyncStart							0x3008
258#define VTGHSyncEnd							0x3010
259#define VTGHBlankEnd							0x3018
260#define VTGVLimit							0x3020
261#define VTGVSyncStart							0x3028
262#define VTGVSyncEnd							0x3030
263#define VTGVBlankEnd							0x3038
264#define VTGHGateStart							0x3040
265#define VTGHGateEnd							0x3048
266#define VTGVGateStart							0x3050
267#define VTGVGateEnd							0x3058
268#define VTGPolarity							0x3060
269#define VTGFrameRowAddr							0x3068
270#define VTGVLineNumber							0x3070
271#define VTGSerialClk							0x3078
272#define VTGModeCtl							0x3080
273
274/* Permedia Video Control Registers */
275#define PMScreenBase							0x3000
276#define PMScreenStride							0x3008
277#define PMHTotal							0x3010
278#define PMHgEnd								0x3018
279#define PMHbEnd								0x3020
280#define PMHsStart							0x3028
281#define PMHsEnd								0x3030
282#define PMVTotal							0x3038
283#define PMVbEnd								0x3040
284#define PMVsStart							0x3048
285#define PMVsEnd								0x3050
286#define PMVideoControl							0x3058
287#define PMInterruptLine							0x3060
288#define PMDDCData							0x3068
289#define   DataIn             						(1<<0)
290#define   ClkIn              						(1<<1)
291#define   DataOut            						(1<<2)
292#define   ClkOut             						(1<<3)
293#define PMLineCount							0x3070
294#define PMFifoControl							0x3078
295
296/* Permedia 2 RAMDAC Registers */
297#define PM2DACWriteAddress						0x4000
298#define PM2DACIndexReg							0x4000
299#define PM2DACData							0x4008
300#define PM2DACReadMask							0x4010
301#define PM2DACReadAddress						0x4018
302#define PM2DACCursorColorAddress				        0x4020
303#define PM2DACCursorColorData					        0x4028
304#define PM2DACIndexData							0x4050
305#define PM2DACCursorData						0x4058
306#define PM2DACCursorXLsb						0x4060
307#define PM2DACCursorXMsb						0x4068
308#define PM2DACCursorYLsb						0x4070
309#define PM2DACCursorYMsb						0x4078
310#define PM2DACCursorControl						0x06
311#define PM2DACIndexCMR							0x18
312#define   PM2DAC_TRUECOLOR				0x80
313#define   PM2DAC_RGB					0x20
314#define   PM2DAC_GRAPHICS				0x10
315#define   PM2DAC_PACKED					0x09
316#define   PM2DAC_8888					0x08
317#define   PM2DAC_565					0x06
318#define   PM2DAC_4444					0x05
319#define   PM2DAC_5551					0x04
320#define   PM2DAC_2321					0x03
321#define   PM2DAC_2320					0x02
322#define   PM2DAC_332					0x01
323#define   PM2DAC_CI8					0x00
324#define PM2DACIndexMDCR							0x19
325#define PM2DACIndexPalettePage					        0x1c
326#define PM2DACIndexMCR							0x1e
327#define PM2DACIndexClockAM						0x20
328#define PM2DACIndexClockAN						0x21
329#define PM2DACIndexClockAP						0x22
330#define PM2DACIndexClockBM						0x23
331#define PM2DACIndexClockBN						0x24
332#define PM2DACIndexClockBP						0x25
333#define PM2DACIndexClockCM						0x26
334#define PM2DACIndexClockCN						0x27
335#define PM2DACIndexClockCP						0x28
336#define PM2DACIndexClockStatus						0x29
337#define PM2DACIndexMemClockM						0x30
338#define PM2DACIndexMemClockN						0x31
339#define PM2DACIndexMemClockP						0x32
340#define PM2DACIndexMemClockStatus					0x33
341#define PM2DACIndexColorKeyControl					0x40
342#define PM2DACIndexColorKeyOverlay					0x41
343#define PM2DACIndexColorKeyRed						0x42
344#define PM2DACIndexColorKeyGreen					0x43
345#define PM2DACIndexColorKeyBlue						0x44
346
347/* Permedia 2V extensions */
348#define PM2VDACRDMiscControl						0x000
349#define PM2VDACRDSyncControl						0x001
350#define PM2VDACRDDACControl						0x002
351#define PM2VDACRDPixelSize						0x003
352#define PM2VDACRDColorFormat						0x004
353#define PM2VDACRDCursorMode						0x005
354#define PM2VDACRDCursorXLow						0x007
355#define PM2VDACRDCursorXHigh						0x008
356#define PM2VDACRDCursorYLow						0x009
357#define PM2VDACRDCursorYHigh						0x00A
358#define PM2VDACRDCursorHotSpotX						0x00B
359#define PM2VDACRDCursorHotSpotY						0x00C
360#define PM2VDACRDOverlayKey						0x00D
361#define PM2VDACRDPan							0x00E
362#define PM2VDACRDSense							0x00F
363#define PM2VDACRDCheckControl						0x018
364#define PM2VDACIndexClockControl					0x200
365#define PM2VDACRDDClk0PreScale						0x201
366#define PM2VDACRDDClk0FeedbackScale					0x202
367#define PM2VDACRDDClk0PostScale						0x203
368#define PM2VDACRDDClk1PreScale						0x204
369#define PM2VDACRDDClk1FeedbackScale					0x205
370#define PM2VDACRDDClk1PostScale						0x206
371#define PM2VDACRDMClkControl						0x20D
372#define PM2VDACRDMClkPreScale						0x20E
373#define PM2VDACRDMClkFeedbackScale					0x20F
374#define PM2VDACRDMClkPostScale						0x210
375#define PM2VDACRDCursorPalette						0x303
376#define PM2VDACRDCursorPattern						0x400
377#define PM2VDACIndexRegLow						0x4020
378#define PM2VDACIndexRegHigh						0x4028
379#define PM2VDACIndexData						0x4030
380#define PM2VDACRDIndexControl						0x4038
381
382/* Permedia 2 Video Streams Unit Registers */
383#define   VSBIntFlag            					(1<<8)
384#define   VSAIntFlag            					(1<<9)
385
386#define VSConfiguration							0x5800
387#define   VS_UnitMode_ROM						0
388#define   VS_UnitMode_AB8						3
389#define   VS_UnitMode_Mask						7
390#define   VS_GPBusMode_A        					(1<<3)
391#define   VS_HRefPolarityA      					(1<<9)
392#define   VS_VRefPolarityA      					(1<<10)
393#define   VS_VActivePolarityA   					(1<<11)
394#define   VS_UseFieldA          					(1<<12)
395#define   VS_FieldPolarityA						(1<<13)
396#define   VS_FieldEdgeA         					(1<<14)
397#define   VS_VActiveVBIA						(1<<15)
398#define   VS_InterlaceA         					(1<<16)
399#define   VS_ReverseDataA       					(1<<17)
400#define   VS_HRefPolarityB      					(1<<18)
401#define   VS_VRefPolarityB      					(1<<19)
402#define   VS_VActivePolarityB   					(1<<20)
403#define   VS_UseFieldB							(1<<21)
404#define   VS_FieldPolarityB						(1<<22)
405#define   VS_FieldEdgeB							(1<<23)
406#define   VS_VActiveVBIB						(1<<24)
407#define   VS_InterlaceB							(1<<25)
408#define   VS_ColorSpaceB_RGB						(1<<26)
409#define   VS_ReverseDataB						(1<<27)
410#define   VS_DoubleEdgeB						(1<<28)
411
412#define VSStatus							0x5808
413#define   VS_FieldOne0A							(1<<9)
414#define   VS_FieldOne1A							(1<<10)
415#define   VS_FieldOne2A							(1<<11)
416#define   VS_InvalidInterlaceA						(1<<12)
417#define   VS_FieldOne0B							(1<<17)
418#define   VS_FieldOne1B							(1<<18)
419#define   VS_FieldOne2B							(1<<19)
420#define   VS_InvalidInterlaceB						(1<<20)
421
422#define VSSerialBusControl						0x5810
423
424#define VSABase          						0x5900
425#define   VSA_Video             					(1<<0)
426#define   VSA_VBI               					(1<<1)
427#define   VSA_BufferCtl         					(1<<2)
428#define   VSA_MirrorX           					(1<<7)
429#define   VSA_MirrorY           					(1<<8)
430#define   VSA_Discard_None      					(0<<9)
431#define   VSA_Discard_FieldOne  					(1<<9)
432#define   VSA_Discard_FieldTwo  					(2<<9)
433#define   VSA_CombineFields     					(1<<11)
434#define   VSA_LockToStreamB     					(1<<12)
435#define VSBBase								0x5A00
436#define   VSB_Video             					(1<<0)
437#define   VSB_VBI               					(1<<1)
438#define   VSB_BufferCtl         					(1<<2)
439#define   VSB_CombineFields     					(1<<3)
440#define   VSB_RGBOrder          					(1<<11)
441#define   VSB_GammaCorrect      					(1<<12)
442#define   VSB_LockToStreamA     					(1<<13)
443
444#define VSControl							0x0000
445#define VSInterrupt            						0x0008
446#define VSCurrentLine          						0x0010
447#define VSVideoAddressHost     						0x0018
448#define VSVideoAddressIndex    						0x0020
449#define VSVideoAddress0        						0x0028
450#define VSVideoAddress1        						0x0030
451#define VSVideoAddress2        						0x0038
452#define VSVideoStride          						0x0040
453#define VSVideoStartLine       						0x0048
454#define VSVideoEndLine     						0x0050
455#define VSVideoStartData       						0x0058
456#define VSVideoEndData         						0x0060
457#define VSVBIAddressHost       						0x0068
458#define VSVBIAddressIndex      						0x0070
459#define VSVBIAddress0          						0x0078
460#define VSVBIAddress1          						0x0080
461#define VSVBIAddress2          						0x0088
462#define VSVBIStride            						0x0090
463#define VSVBIStartLine         						0x0098
464#define VSVBIEndLine           						0x00A0
465#define VSVBIStartData         						0x00A8
466#define VSVBIEndData           						0x00B0
467#define VSFifoControl          						0x00B8
468
469/**********************************
470 * GLINT Delta Region 0 Registers *
471 **********************************/
472
473/* Control Status Registers */
474#define DResetStatus							0x0800
475#define DIntEnable							0x0808
476#define DIntFlags							0x0810
477#define DErrorFlags							0x0838
478#define DTestRegister							0x0848
479#define DFIFODis							0x0868
480
481
482
483/**********************************
484 * GLINT Gamma Region 0 Registers *
485 **********************************/
486
487/* Control Status Registers */
488#define GInFIFOSpace							0x0018
489#define GDMAAddress							0x0028
490#define GDMACount							0x0030
491#define GDMAControl							0x0060
492#define GOutDMA								0x0080
493#define GOutDMACount							0x0088
494#define GResetStatus							0x0800
495#define GIntEnable							0x0808
496#define GIntFlags							0x0810
497#define GErrorFlags							0x0838
498#define GTestRegister							0x0848
499#define GFIFODis							0x0868
500
501#define GChipConfig							0x0870
502#define   GChipAGPCapable		1 << 0
503#define   GChipAGPSideband		1 << 1
504#define   GChipMultiGLINTApMask		3 << 19
505#define   GChipMultiGLINTAp_0M		0 << 19
506#define   GChipMultiGLINTAp_16M		1 << 19
507#define   GChipMultiGLINTAp_32M		2 << 19
508#define   GChipMultiGLINTAp_64M		3 << 19
509
510#define GCSRAperture							0x0878
511#define   GCSRSecondaryGLINTMapEn	1 << 0
512#define   GCSRBitSwap			1 << 1
513
514#define GPageTableAddr							0x0c00
515#define GPageTableLength						0x0c08
516#define GDelayTimer							0x0c38
517#define GCommandMode							0x0c40
518#define GCommandIntEnable						0x0c48
519#define GCommandIntFlags						0x0c50
520#define GCommandErrorFlags						0x0c58
521#define GCommandStatus							0x0c60
522#define GCommandFaultingAddr						0x0c68
523#define GVertexFaultingAddr						0x0c70
524#define GWriteFaultingAddr						0x0c88
525#define GFeedbackSelectCount						0x0c98
526#define GGammaProcessorMode						0x0cb8
527#define GVGAShadow							0x0d00
528#define GMultGLINTAperture						0x0d08
529#define GMultGLINT1							0x0d10
530#define GMultGLINT2							0x0d18
531
532/************************
533 * GLINT Core Registers *
534 ************************/
535
536#define GLINT_TAG(major,offset)			(((major) << 7) | ((offset) << 3))
537#define GLINT_TAG_ADDR(major,offset)	(0x8000 | GLINT_TAG((major),(offset)))
538
539#define UNIT_DISABLE							0
540#define UNIT_ENABLE							1
541
542#define StartXDom							GLINT_TAG_ADDR(0x00,0x00)
543#define dXDom								GLINT_TAG_ADDR(0x00,0x01)
544#define StartXSub							GLINT_TAG_ADDR(0x00,0x02)
545#define dXSub								GLINT_TAG_ADDR(0x00,0x03)
546#define StartY								GLINT_TAG_ADDR(0x00,0x04)
547#define dY									GLINT_TAG_ADDR(0x00,0x05)
548#define GLINTCount							GLINT_TAG_ADDR(0x00,0x06)
549#define Render								GLINT_TAG_ADDR(0x00,0x07)
550#	define AreaStippleEnable					0x00001
551#	define LineStippleEnable					0x00002
552#	define ResetLineStipple					0x00004
553#	define FastFillEnable						0x00008
554#	define PrimitiveLine						0
555#	define PrimitiveTrapezoid					0x00040
556#	define PrimitivePoint						0x00080
557#	define PrimitiveRectangle					0x000C0
558#	define AntialiasEnable         				0x00100
559#	define AntialiasingQuality     				0x00200
560#	define UsePointTable						0x00400
561#	define SyncOnBitMask						0x00800
562#	define SyncOnHostData						0x01000
563#	define TextureEnable           				0x02000
564#	define FogEnable               				0x04000
565#	define CoverageEnable						0x08000
566#	define SubPixelCorrectionEnable				0x10000
567#	define SpanOperation						0x40000
568#	define XPositive			1<<21
569#	define YPositive			1<<22
570
571
572#define ContinueNewLine							GLINT_TAG_ADDR(0x00,0x08)
573#define ContinueNewDom							GLINT_TAG_ADDR(0x00,0x09)
574#define ContinueNewSub							GLINT_TAG_ADDR(0x00,0x0a)
575#define Continue							GLINT_TAG_ADDR(0x00,0x0b)
576#define FlushSpan							GLINT_TAG_ADDR(0x00,0x0c)
577#define BitMaskPattern							GLINT_TAG_ADDR(0x00,0x0d)
578
579#define PointTable0							GLINT_TAG_ADDR(0x01,0x00)
580#define PointTable1							GLINT_TAG_ADDR(0x01,0x01)
581#define PointTable2							GLINT_TAG_ADDR(0x01,0x02)
582#define PointTable3							GLINT_TAG_ADDR(0x01,0x03)
583#define RasterizerMode							GLINT_TAG_ADDR(0x01,0x04)
584#define		RMMultiGLINT			1<<17
585#define		BitMaskPackingEachScanline	1<<9
586#define		ForceBackgroundColor		1<<6
587#define		InvertBitMask			1<<1
588#define YLimits								GLINT_TAG_ADDR(0x01,0x05)
589#define ScanLineOwnership						GLINT_TAG_ADDR(0x01,0x06)
590#define WaitForCompletion						GLINT_TAG_ADDR(0x01,0x07)
591#define PixelSize							GLINT_TAG_ADDR(0x01,0x08)
592#define XLimits								GLINT_TAG_ADDR(0x01,0x09) /* PM only */
593
594#define RectangleOrigin							GLINT_TAG_ADDR(0x01,0x0A) /* PM2 only */
595#define RectangleSize							GLINT_TAG_ADDR(0x01,0x0B) /* PM2 only */
596
597#define PackedDataLimits						GLINT_TAG_ADDR(0x02,0x0a) /* PM only */
598
599#define ScissorMode							GLINT_TAG_ADDR(0x03,0x00)
600#	define                                    	        SCI_USER          0x01
601#	define                                                 SCI_SCREEN        0x02
602#	define                                                 SCI_USERANDSCREEN 0x03
603
604#define ScissorMinXY						GLINT_TAG_ADDR(0x03,0x01)
605#define ScissorMaxXY						GLINT_TAG_ADDR(0x03,0x02)
606#define ScreenSize						GLINT_TAG_ADDR(0x03,0x03)
607#define AreaStippleMode						GLINT_TAG_ADDR(0x03,0x04)
608	/* 0:				*/
609	/* NoMirrorY			*/
610	/* NoMirrorX			*/
611	/* NoInvertPattern		*/
612	/* YAddress_1bit		*/
613	/* XAddress_1bit		*/
614	/* UNIT_DISABLE			*/
615
616#	define ASM_XAddress_2bit					1 << 1
617#	define ASM_XAddress_3bit					2 << 1
618#	define ASM_XAddress_4bit					3 << 1
619#	define ASM_XAddress_5bit					4 << 1
620#	define ASM_YAddress_2bit					1 << 4
621#	define ASM_YAddress_3bit					2 << 4
622#	define ASM_YAddress_4bit					3 << 4
623#	define ASM_YAddress_5bit					4 << 4
624#	define ASM_InvertPattern					1 << 17
625#	define ASM_MirrorX						1 << 18
626#	define ASM_MirrorY						1 << 19
627
628#define LineStippleMode						GLINT_TAG_ADDR(0x03,0x05)
629#define LoadLineStippleCounters					GLINT_TAG_ADDR(0x03,0x06)
630#define UpdateLineStippleCounters				GLINT_TAG_ADDR(0x03,0x07)
631#define SaveLineStippleState					GLINT_TAG_ADDR(0x03,0x08)
632#define WindowOrigin						GLINT_TAG_ADDR(0x03,0x09)
633
634#define AreaStipplePattern0					GLINT_TAG_ADDR(0x04,0x00)
635#define AreaStipplePattern1					GLINT_TAG_ADDR(0x04,0x01)
636#define AreaStipplePattern2					GLINT_TAG_ADDR(0x04,0x02)
637#define AreaStipplePattern3					GLINT_TAG_ADDR(0x04,0x03)
638#define AreaStipplePattern4					GLINT_TAG_ADDR(0x04,0x04)
639#define AreaStipplePattern5					GLINT_TAG_ADDR(0x04,0x05)
640#define AreaStipplePattern6					GLINT_TAG_ADDR(0x04,0x06)
641#define AreaStipplePattern7					GLINT_TAG_ADDR(0x04,0x07)
642
643#define TextureAddressMode					GLINT_TAG_ADDR(0x07,0x00)
644#define SStart							GLINT_TAG_ADDR(0x07,0x01)
645#define dSdx							GLINT_TAG_ADDR(0x07,0x02)
646#define dSdyDom							GLINT_TAG_ADDR(0x07,0x03)
647#define TStart							GLINT_TAG_ADDR(0x07,0x04)
648#define dTdx							GLINT_TAG_ADDR(0x07,0x05)
649#define dTdyDom							GLINT_TAG_ADDR(0x07,0x06)
650#define QStart							GLINT_TAG_ADDR(0x07,0x07)
651#define dQdx							GLINT_TAG_ADDR(0x07,0x08)
652#define dQdyDom							GLINT_TAG_ADDR(0x07,0x09)
653#define LOD							GLINT_TAG_ADDR(0x07,0x0A)
654#define dSdy							GLINT_TAG_ADDR(0x07,0x0B)
655#define dTdy							GLINT_TAG_ADDR(0x07,0x0C)
656#define dQdy							GLINT_TAG_ADDR(0x07,0x0D)
657
658#define TextureReadMode						GLINT_TAG_ADDR(0x09,0x00)
659#define TextureFormat						GLINT_TAG_ADDR(0x09,0x01)
660#  define Texture_4_Components 3 << 3
661#  define Texture_Texel        0
662
663#define TextureCacheControl					GLINT_TAG_ADDR(0x09,0x02)
664#  define TextureCacheControlEnable     2
665#  define TextureCacheControlInvalidate 1
666
667#define GLINTBorderColor					GLINT_TAG_ADDR(0x09,0x05)
668
669#define TexelLUTIndex						GLINT_TAG_ADDR(0x09,0x08)
670#define TexelLUTData						GLINT_TAG_ADDR(0x09,0x09)
671#define TexelLUTAddress						GLINT_TAG_ADDR(0x09,0x0A)
672#define TexelLUTTransfer					GLINT_TAG_ADDR(0x09,0x0B)
673#define TextureFilterMode					GLINT_TAG_ADDR(0x09,0x0C)
674#define TextureChromaUpper					GLINT_TAG_ADDR(0x09,0x0D)
675#define TextureChromaLower					GLINT_TAG_ADDR(0x09,0x0E)
676
677#define TxBaseAddr0						GLINT_TAG_ADDR(0x0A,0x00)
678#define TxBaseAddr1						GLINT_TAG_ADDR(0x0A,0x01)
679#define TxBaseAddr2						GLINT_TAG_ADDR(0x0A,0x02)
680#define TxBaseAddr3						GLINT_TAG_ADDR(0x0A,0x03)
681#define TxBaseAddr4						GLINT_TAG_ADDR(0x0A,0x04)
682#define TxBaseAddr5						GLINT_TAG_ADDR(0x0A,0x05)
683#define TxBaseAddr6						GLINT_TAG_ADDR(0x0A,0x06)
684#define TxBaseAddr7						GLINT_TAG_ADDR(0x0A,0x07)
685#define TxBaseAddr8						GLINT_TAG_ADDR(0x0A,0x08)
686#define TxBaseAddr9						GLINT_TAG_ADDR(0x0A,0x09)
687#define TxBaseAddr10						GLINT_TAG_ADDR(0x0A,0x0A)
688#define TxBaseAddr11						GLINT_TAG_ADDR(0x0A,0x0B)
689
690#define PMTextureBaseAddress					GLINT_TAG_ADDR(0x0b,0x00)
691#define PMTextureMapFormat					GLINT_TAG_ADDR(0x0b,0x01)
692#define PMTextureDataFormat					GLINT_TAG_ADDR(0x0b,0x02)
693
694#define Texel0							GLINT_TAG_ADDR(0x0c,0x00)
695#define Texel1							GLINT_TAG_ADDR(0x0c,0x01)
696#define Texel2							GLINT_TAG_ADDR(0x0c,0x02)
697#define Texel3							GLINT_TAG_ADDR(0x0c,0x03)
698#define Texel4							GLINT_TAG_ADDR(0x0c,0x04)
699#define Texel5							GLINT_TAG_ADDR(0x0c,0x05)
700#define Texel6							GLINT_TAG_ADDR(0x0c,0x06)
701#define Texel7							GLINT_TAG_ADDR(0x0c,0x07)
702#define Interp0							GLINT_TAG_ADDR(0x0c,0x08)
703#define Interp1							GLINT_TAG_ADDR(0x0c,0x09)
704#define Interp2							GLINT_TAG_ADDR(0x0c,0x0a)
705#define Interp3							GLINT_TAG_ADDR(0x0c,0x0b)
706#define Interp4							GLINT_TAG_ADDR(0x0c,0x0c)
707#define TextureFilter						GLINT_TAG_ADDR(0x0c,0x0d)
708#define PMTextureReadMode					GLINT_TAG_ADDR(0x0c,0x0e)
709#define TexelLUTMode						GLINT_TAG_ADDR(0x0c,0x0f)
710
711#define TextureColorMode					GLINT_TAG_ADDR(0x0d,0x00)
712#  define TextureTypeOpenGL 0
713#  define TextureTypeApple  1 << 4
714#  define TextureKsDDA      1 << 5 /* only Apple-Mode */
715#  define TextureKdDDA      1 << 6 /* only Apple-Mode */
716
717#define TextureEnvColor						GLINT_TAG_ADDR(0x0d,0x01)
718#define FogMode							GLINT_TAG_ADDR(0x0d,0x02)
719	/* 0:				*/
720	/* FOG RGBA			*/
721	/* UNIT_DISABLE			*/
722
723#	define FOG_CI							0x0002
724
725#define FogColor							GLINT_TAG_ADDR(0x0d,0x03)
726#define FStart								GLINT_TAG_ADDR(0x0d,0x04)
727#define dFdx								GLINT_TAG_ADDR(0x0d,0x05)
728#define dFdyDom								GLINT_TAG_ADDR(0x0d,0x06)
729#define KsStart								GLINT_TAG_ADDR(0x0d,0x09)
730#define dKsdx								GLINT_TAG_ADDR(0x0d,0x0a)
731#define dKsdyDom							GLINT_TAG_ADDR(0x0d,0x0b)
732#define KdStart								GLINT_TAG_ADDR(0x0d,0x0c)
733#define dKdStart							GLINT_TAG_ADDR(0x0d,0x0d)
734#define dKddyDom							GLINT_TAG_ADDR(0x0d,0x0e)
735
736#define RStart								GLINT_TAG_ADDR(0x0f,0x00)
737#define dRdx								GLINT_TAG_ADDR(0x0f,0x01)
738#define dRdyDom								GLINT_TAG_ADDR(0x0f,0x02)
739#define GStart								GLINT_TAG_ADDR(0x0f,0x03)
740#define dGdx								GLINT_TAG_ADDR(0x0f,0x04)
741#define dGdyDom								GLINT_TAG_ADDR(0x0f,0x05)
742#define BStart								GLINT_TAG_ADDR(0x0f,0x06)
743#define dBdx								GLINT_TAG_ADDR(0x0f,0x07)
744#define dBdyDom								GLINT_TAG_ADDR(0x0f,0x08)
745#define AStart								GLINT_TAG_ADDR(0x0f,0x09)
746#define dAdx								GLINT_TAG_ADDR(0x0f,0x0a)
747#define dAdyDom								GLINT_TAG_ADDR(0x0f,0x0b)
748#define ColorDDAMode							GLINT_TAG_ADDR(0x0f,0x0c)
749	/* 0:					*/
750#	define CDDA_FlatShading			                0
751	/* UNIT_DISABLE			*/
752#	define CDDA_GouraudShading					0x0002
753
754
755#define ConstantColor						GLINT_TAG_ADDR(0x0f,0x0d)
756#define GLINTColor						GLINT_TAG_ADDR(0x0f,0x0e)
757#define AlphaTestMode						GLINT_TAG_ADDR(0x10,0x00)
758#define AntialiasMode						GLINT_TAG_ADDR(0x10,0x01)
759#define AlphaBlendMode						GLINT_TAG_ADDR(0x10,0x02)
760	/* 0:					*/
761	/* SrcZERO				*/
762	/* DstZERO				*/
763	/* ColorFormat8888			*/
764	/* AlphaBuffer present			*/
765	/* ColorOrderBGR			*/
766	/* TypeOpenGL				*/
767	/* DstFBData				*/
768	/* UNIT_DISABLE				*/
769
770#	define ABM_SrcONE					1 << 1
771#	define ABM_SrcDST_COLOR				2 << 1
772#	define ABM_SrcONE_MINUS_DST_COLOR			3 << 1
773#	define ABM_SrcSRC_ALPHA				4 << 1
774#	define ABM_SrcONE_MINUS_SRC_ALPHA			5 << 1
775#	define ABM_SrcDST_ALPHA				6 << 1
776#	define ABM_SrcONE_MINUS_DST_ALPHA			7 << 1
777#	define ABM_SrcSRC_ALPHA_SATURATE			8 << 1
778#	define ABM_DstONE					1 << 5
779#	define ABM_DstSRC_COLOR				2 << 5
780#	define ABM_DstONE_MINUS_SRC_COLOR			3 << 5
781#	define ABM_DstSRC_ALPHA				4 << 5
782#	define ABM_DstONE_MINUS_SRC_ALPHA			5 << 5
783#	define ABM_DstDST_ALPHA				6 << 5
784#	define ABM_DstONE_MINUS_DST_ALPHA			7 << 5
785#	define ABM_ColorFormat5555				1 << 8
786#	define ABM_ColorFormat4444				2 << 8
787#	define ABM_ColorFormat4444_Front			3 << 8
788#	define ABM_ColorFormat4444_Back			4 << 8
789#	define ABM_ColorFormat332_Front			5 << 8
790#	define ABM_ColorFormat332_Back				6 << 8
791#	define ABM_ColorFormat121_Front			7 << 8
792#	define ABM_ColorFormat121_Back				8 << 8
793#	define ABM_ColorFormat555_Back				13 << 8
794#	define ABM_ColorFormat_CI8				14 << 8
795#	define ABM_ColorFormat_CI4				15 << 8
796#	define ABM_NoAlphaBuffer				0x1000
797#	define ABM_ColorOrderRGB				0x2000
798#	define ABM_TypeQuickDraw3D				0x4000
799#	define ABM_DstFBSourceData				0x8000
800
801#define DitherMode						GLINT_TAG_ADDR(0x10,0x03)
802	/* 0:					*/
803	/* ColorOrder BGR		*/
804	/* AlphaDitherDefault	*/
805	/* ColorFormat8888		*/
806	/* TruncateMode 		*/
807	/* DitherDisable		*/
808	/* UNIT_DISABLE			*/
809
810#	define DTM_DitherEnable				1 << 1
811#	define DTM_ColorFormat5555				1 << 2
812#	define DTM_ColorFormat4444				2 << 2
813#	define DTM_ColorFormat4444_Front			3 << 2
814#	define DTM_ColorFormat4444_Back			4 << 2
815#	define DTM_ColorFormat332_Front			5 << 2
816#	define DTM_ColorFormat332_Back				6 << 2
817#	define DTM_ColorFormat121_Front			7 << 2
818#	define DTM_ColorFormat121_Back				8 << 2
819#	define DTM_ColorFormat555_Back				13 << 2
820#	define DTM_ColorFormat_CI8				14 << 2
821#	define DTM_ColorFormat_CI4				15 << 2
822#	define DTM_ColorOrderRGB				1 << 10
823#	define DTM_NoAlphaDither				1 << 14
824#	define DTM_RoundMode					1 << 15
825
826#define FBSoftwareWriteMask					GLINT_TAG_ADDR(0x10,0x04)
827#define LogicalOpMode						GLINT_TAG_ADDR(0x10,0x05)
828#	define Use_ConstantFBWriteData 0x40
829
830
831#define FBWriteData						GLINT_TAG_ADDR(0x10,0x06)
832#define RouterMode						GLINT_TAG_ADDR(0x10,0x08)
833#	define ROUTER_Depth_Texture 1
834#	define ROUTER_Texture_Depth 0
835
836
837#define LBReadMode						GLINT_TAG_ADDR(0x11,0x00)
838	/* 0:				*/
839	/* SrcNoRead			*/
840	/* DstNoRead			*/
841	/* DataLBDefault		*/
842	/* WinTopLeft			*/
843	/* NoPatch			*/
844	/* ScanlineInterval1 		*/
845
846#	define LBRM_SrcEnable						1 << 9
847#	define LBRM_DstEnable						1 << 10
848#	define LBRM_DataLBStencil					1 << 16
849#	define LBRM_DataLBDepth					2 << 16
850#	define LBRM_WinBottomLeft					1 << 18
851#	define LBRM_DoPatch						1 << 19
852
853#	define LBRM_ScanlineInt2					1 << 20
854#	define LBRM_ScanlineInt4					2 << 20
855#	define LBRM_ScanlineInt8					3 << 20
856
857
858#define LBReadFormat						GLINT_TAG_ADDR(0x11,0x01)
859#	define LBRF_DepthWidth15   0x03  /* only permedia */
860#	define LBRF_DepthWidth16   0x00
861#	define LBRF_DepthWidth24   0x01
862#	define LBRF_DepthWidth32   0x02
863
864#	define LBRF_StencilWidth0  (0 << 2)
865#	define LBRF_StencilWidth4  (1 << 2)
866#	define LBRF_StencilWidth8  (2 << 2)
867
868#	define LBRF_StencilPos16   (0 << 4)
869#	define LBRF_StencilPos20   (1 << 4)
870#	define LBRF_StencilPos24   (2 << 4)
871#	define LBRF_StencilPos28   (3 << 4)
872#	define LBRF_StencilPos32   (4 << 4)
873
874#	define LBRF_FrameCount0    (0 << 7)
875#	define LBRF_FrameCount4    (1 << 7)
876#	define LBRF_FrameCount8    (2 << 7)
877
878#	define LBRF_FrameCountPos16  (0 << 9)
879#	define LBRF_FrameCountPos20  (1 << 9)
880#	define LBRF_FrameCountPos24  (2 << 9)
881#	define LBRF_FrameCountPos28  (3 << 9)
882#	define LBRF_FrameCountPos32  (4 << 9)
883#	define LBRF_FrameCountPos36  (5 << 9)
884#	define LBRF_FrameCountPos40  (6 << 9)
885
886#	define LBRF_GIDWidth0 (0 << 12)
887#	define LBRF_GIDWidth4 (1 << 12)
888
889#	define LBRF_GIDPos16  (0 << 13)
890#	define LBRF_GIDPos20  (1 << 13)
891#	define LBRF_GIDPos24  (2 << 13)
892#	define LBRF_GIDPos28  (3 << 13)
893#	define LBRF_GIDPos32  (4 << 13)
894#	define LBRF_GIDPos36  (5 << 13)
895#	define LBRF_GIDPos40  (6 << 13)
896#	define LBRF_GIDPos44  (7 << 13)
897#	define LBRF_GIDPos48  (8 << 13)
898
899#	define LBRF_Compact32  (1 << 17)
900
901
902
903#define LBSourceOffset						GLINT_TAG_ADDR(0x11,0x02)
904#define LBStencil						GLINT_TAG_ADDR(0x11,0x05)
905#define LBDepth							GLINT_TAG_ADDR(0x11,0x06)
906#define LBWindowBase						GLINT_TAG_ADDR(0x11,0x07)
907#define LBWriteMode						GLINT_TAG_ADDR(0x11,0x08)
908#	define LBWM_WriteEnable				0x1
909#	define LBWM_UpLoad_LBDepth				0x2
910#	define LBWM_UpLoad_LBStencil				0x4
911
912#define LBWriteFormat						GLINT_TAG_ADDR(0x11,0x09)
913
914
915#define TextureData						GLINT_TAG_ADDR(0x11,0x0d)
916#define TextureDownloadOffset					GLINT_TAG_ADDR(0x11,0x0e)
917#define LBWindowOffset						GLINT_TAG_ADDR(0x11,0x0f)
918
919#define GLINTWindow						GLINT_TAG_ADDR(0x13,0x00)
920#	define GWIN_UnitEnable          (1 << 0)
921#	define GWIN_ForceLBUpdate       (1 << 3)
922#	define GWIN_LBUpdateSourceREG   (1 << 4)
923#	define GWIN_LBUpdateSourceLB    (0 << 4)
924#	define GWIN_StencilFCP          (1 << 17)
925#	define GWIN_DepthFCP            (1 << 18)
926#	define GWIN_OverrideWriteFilter (1 << 19)
927
928	/* ??? is this needed, set by permedia (2) modules */
929#	define GWIN_DisableLBUpdate    0x40000
930
931#define StencilMode						GLINT_TAG_ADDR(0x13,0x01)
932#define StencilData						GLINT_TAG_ADDR(0x13,0x02)
933#define GLINTStencil						GLINT_TAG_ADDR(0x13,0x03)
934#define DepthMode						GLINT_TAG_ADDR(0x13,0x04)
935	/* 0:				*/
936	/* WriteDisable			*/
937	/* SrcCompFragment		*/
938	/* CompFuncNEVER		*/
939	/* UNIT_DISABLE			*/
940
941#	define DPM_WriteEnable					1 << 1
942#	define DPM_SrcCompLBData				1 << 2
943#	define DPM_SrcCompDregister				2 << 2
944#	define DPM_SrcCompLBSourceData				3 << 2
945#	define DPM_CompFuncLESS				1 << 4
946#	define DPM_CompFuncEQUAL				2 << 4
947#	define DPM_CompFuncLESS_OR_EQ				3 << 4
948#	define DPM_CompFuncGREATER				4 << 4
949#	define DPM_CompFuncNOT_EQ				5 << 4
950#	define DPM_CompFuncGREATER_OR_EQ			6 << 4
951#	define DPM_CompFuncALWAYS				7 << 4
952
953#define GLINTDepth						GLINT_TAG_ADDR(0x13,0x05)
954#define ZStartU							GLINT_TAG_ADDR(0x13,0x06)
955#define ZStartL							GLINT_TAG_ADDR(0x13,0x07)
956#define dZdxU							GLINT_TAG_ADDR(0x13,0x08)
957#define dZdxL							GLINT_TAG_ADDR(0x13,0x09)
958#define dZdyDomU						GLINT_TAG_ADDR(0x13,0x0a)
959#define dZdyDomL						GLINT_TAG_ADDR(0x13,0x0b)
960#define FastClearDepth						GLINT_TAG_ADDR(0x13,0x0c)
961
962#define FBReadMode						GLINT_TAG_ADDR(0x15,0x00)
963	/* 0:				*/
964	/* SrcNoRead			*/
965	/* DstNoRead			*/
966	/* DataFBDefault		*/
967	/* WinTopLeft			*/
968	/* ScanlineInterval1 		*/
969
970#	define FBRM_SrcEnable					1 << 9
971#	define FBRM_DstEnable					1 << 10
972#	define FBRM_DataFBColor				1 << 15
973#	define FBRM_WinBottomLeft				1 << 16
974#	define FBRM_Packed					1 << 19
975#	define FBRM_ScanlineInt2				1 << 23
976#	define FBRM_ScanlineInt4				2 << 23
977#	define FBRM_ScanlineInt8				3 << 23
978
979
980#define FBSourceOffset						GLINT_TAG_ADDR(0x15,0x01)
981#define FBPixelOffset						GLINT_TAG_ADDR(0x15,0x02)
982#define FBColor							GLINT_TAG_ADDR(0x15,0x03)
983#define FBData							GLINT_TAG_ADDR(0x15,0x04)
984#define FBSourceData						GLINT_TAG_ADDR(0x15,0x05)
985
986#define FBWindowBase						GLINT_TAG_ADDR(0x15,0x06)
987#define FBWriteMode						GLINT_TAG_ADDR(0x15,0x07)
988	/* 0:			*/
989	/* FBWM_NoColorUpload	*/
990	/* FBWM_WriteDisable	*/
991#	define FBWM_WriteEnable				1
992#	define FBWM_UploadColor				1 << 3
993/* Permedia3 extensions */
994#	define FBWM_Enable0					1 << 12
995
996#define FBHardwareWriteMask					GLINT_TAG_ADDR(0x15,0x08)
997#define FBBlockColor						GLINT_TAG_ADDR(0x15,0x09)
998#define FBReadPixel						GLINT_TAG_ADDR(0x15,0x0a) /* PM */
999#define PatternRamMode						GLINT_TAG_ADDR(0x15,0x0f)
1000
1001#define PatternRamData0						GLINT_TAG_ADDR(0x16,0x00)
1002#define PatternRamData1						GLINT_TAG_ADDR(0x16,0x01)
1003#define PatternRamData2						GLINT_TAG_ADDR(0x16,0x02)
1004#define PatternRamData3						GLINT_TAG_ADDR(0x16,0x03)
1005#define PatternRamData4						GLINT_TAG_ADDR(0x16,0x04)
1006#define PatternRamData5						GLINT_TAG_ADDR(0x16,0x05)
1007#define PatternRamData6						GLINT_TAG_ADDR(0x16,0x06)
1008#define PatternRamData7						GLINT_TAG_ADDR(0x16,0x07)
1009
1010#define FilterMode						GLINT_TAG_ADDR(0x18,0x00)
1011	/* 0:				*/
1012	/* CullDepthTags		*/
1013	/* CullDepthData		*/
1014	/* CullStencilTags		*/
1015	/* CullStencilData		*/
1016	/* CullColorTag			*/
1017	/* CullColorData		*/
1018	/* CullSyncTag			*/
1019	/* CullSyncData			*/
1020	/* CullStatisticTag		*/
1021	/* CullStatisticData		*/
1022
1023#	define FM_PassDepthTags					0x0010
1024#	define FM_PassDepthData					0x0020
1025#	define FM_PassStencilTags					0x0040
1026#	define FM_PassStencilData					0x0080
1027#	define FM_PassColorTag						0x0100
1028#	define FM_PassColorData					0x0200
1029#	define FM_PassSyncTag						0x0400
1030#	define FM_PassSyncData						0x0800
1031#	define FM_PassStatisticTag					0x1000
1032#	define FM_PassStatisticData					0x2000
1033
1034#define	Sync_tag							0x0188
1035
1036#define StatisticMode						GLINT_TAG_ADDR(0x18,0x01)
1037#define MinRegion						GLINT_TAG_ADDR(0x18,0x02)
1038#define MaxRegion						GLINT_TAG_ADDR(0x18,0x03)
1039#define ResetPickResult						GLINT_TAG_ADDR(0x18,0x04)
1040#define MitHitRegion						GLINT_TAG_ADDR(0x18,0x05)
1041#define MaxHitRegion						GLINT_TAG_ADDR(0x18,0x06)
1042#define PickResult						GLINT_TAG_ADDR(0x18,0x07)
1043#define GlintSync						GLINT_TAG_ADDR(0x18,0x08)
1044
1045#define FBBlockColorU						GLINT_TAG_ADDR(0x18,0x0d)
1046#define FBBlockColorL						GLINT_TAG_ADDR(0x18,0x0e)
1047#define SuspendUntilFrameBlank					GLINT_TAG_ADDR(0x18,0x0f)
1048
1049#define KsRStart						GLINT_TAG_ADDR(0x19,0x00)
1050#define dKsRdx							GLINT_TAG_ADDR(0x19,0x01)
1051#define dKsRdyDom						GLINT_TAG_ADDR(0x19,0x02)
1052#define KsGStart						GLINT_TAG_ADDR(0x19,0x03)
1053#define dKsGdx							GLINT_TAG_ADDR(0x19,0x04)
1054#define dKsGdyDom						GLINT_TAG_ADDR(0x19,0x05)
1055#define KsBStart						GLINT_TAG_ADDR(0x19,0x06)
1056#define dKsBdx							GLINT_TAG_ADDR(0x19,0x07)
1057#define dKsBdyDom						GLINT_TAG_ADDR(0x19,0x08)
1058
1059#define KdRStart						GLINT_TAG_ADDR(0x1A,0x00)
1060#define dKdRdx							GLINT_TAG_ADDR(0x1A,0x01)
1061#define dKdRdyDom						GLINT_TAG_ADDR(0x1A,0x02)
1062#define KdGStart						GLINT_TAG_ADDR(0x1A,0x03)
1063#define dKdGdx							GLINT_TAG_ADDR(0x1A,0x04)
1064#define dKdGdyDom						GLINT_TAG_ADDR(0x1A,0x05)
1065#define KdBStart						GLINT_TAG_ADDR(0x1A,0x06)
1066#define dKdBdx							GLINT_TAG_ADDR(0x1A,0x07)
1067#define dKdBdyDom						GLINT_TAG_ADDR(0x1A,0x08)
1068
1069#define FBSourceBase						GLINT_TAG_ADDR(0x1B,0x00)
1070#define FBSourceDelta						GLINT_TAG_ADDR(0x1B,0x01)
1071#define Config							GLINT_TAG_ADDR(0x1B,0x02)
1072#define		CFBRM_SrcEnable		1<<0
1073#define		CFBRM_DstEnable		1<<1
1074#define		CFBRM_Packed		1<<2
1075#define		CWM_Enable		1<<3
1076#define		CCDDA_Enable		1<<4
1077#define		CLogOp_Enable		1<<5
1078#define ContextDump                                             GLINT_TAG_ADDR(0x1B,0x08)
1079#define ContextRestore                                          GLINT_TAG_ADDR(0x1B,0x09)
1080#define ContextData                                             GLINT_TAG_ADDR(0x1B,0x0a)
1081
1082#define TexelLUT0						GLINT_TAG_ADDR(0x1D,0x00)
1083#define TexelLUT1						GLINT_TAG_ADDR(0x1D,0x01)
1084#define TexelLUT2						GLINT_TAG_ADDR(0x1D,0x02)
1085#define TexelLUT3						GLINT_TAG_ADDR(0x1D,0x03)
1086#define TexelLUT4						GLINT_TAG_ADDR(0x1D,0x04)
1087#define TexelLUT5						GLINT_TAG_ADDR(0x1D,0x05)
1088#define TexelLUT6						GLINT_TAG_ADDR(0x1D,0x06)
1089#define TexelLUT7						GLINT_TAG_ADDR(0x1D,0x07)
1090#define TexelLUT8						GLINT_TAG_ADDR(0x1D,0x08)
1091#define TexelLUT9						GLINT_TAG_ADDR(0x1D,0x09)
1092#define TexelLUT10						GLINT_TAG_ADDR(0x1D,0x0A)
1093#define TexelLUT11						GLINT_TAG_ADDR(0x1D,0x0B)
1094#define TexelLUT12						GLINT_TAG_ADDR(0x1D,0x0C)
1095#define TexelLUT13						GLINT_TAG_ADDR(0x1D,0x0D)
1096#define TexelLUT14						GLINT_TAG_ADDR(0x1D,0x0E)
1097#define TexelLUT15						GLINT_TAG_ADDR(0x1D,0x0F)
1098
1099#define YUVMode                                                 GLINT_TAG_ADDR(0x1E,0x00)
1100#define ChromaUpper                                             GLINT_TAG_ADDR(0x1E,0x01)
1101#define ChromaLower                                             GLINT_TAG_ADDR(0x1E,0x02)
1102#define ChromaTestMode                                          GLINT_TAG_ADDR(0x1E,0x03)
1103
1104
1105/******************************
1106 * GLINT Delta Core Registers *
1107 ******************************/
1108
1109#define V0FixedTag	GLINT_TAG_ADDR(0x20,0x00)
1110#define V1FixedTag	GLINT_TAG_ADDR(0x21,0x00)
1111#define V2FixedTag	GLINT_TAG_ADDR(0x22,0x00)
1112#define V0FloatTag	GLINT_TAG_ADDR(0x23,0x00)
1113#define V1FloatTag	GLINT_TAG_ADDR(0x24,0x00)
1114#define V2FloatTag	GLINT_TAG_ADDR(0x25,0x00)
1115
1116#define VPAR_s		0x00
1117#define VPAR_t		0x08
1118#define VPAR_q		0x10
1119#define VPAR_Ks		0x18
1120#define VPAR_Kd		0x20
1121
1122/* have changed colors in ramdac !
1123#define VPAR_R		0x28
1124#define VPAR_G		0x30
1125#define VPAR_B		0x38
1126#define VPAR_A		0x40
1127*/
1128#define VPAR_B		0x28
1129#define VPAR_G		0x30
1130#define VPAR_R		0x38
1131#define VPAR_A		0x40
1132
1133#define VPAR_f		0x48
1134
1135#define VPAR_x		0x50
1136#define VPAR_y		0x58
1137#define VPAR_z		0x60
1138
1139#define DeltaModeTag						GLINT_TAG_ADDR(0x26,0x00)
1140	/* 0:				*/
1141	/* GLINT_300SX			*/
1142
1143	/* DeltaMode Register Bit Field Assignments */
1144#	define DM_GLINT_300SX					0x0000
1145#	define DM_GLINT_500TX					0x0001
1146#	define DM_PERMEDIA					0x0002
1147#	define DM_Depth_16BPP					(1 << 2)
1148#	define DM_Depth_24BPP					(2 << 2)
1149#	define DM_Depth_32BPP					(3 << 2)
1150#	define DM_FogEnable					0x0010
1151#	define DM_TextureEnable				0x0020
1152#	define DM_SmoothShadingEnable				0x0040
1153#	define DM_DepthEnable					0x0080
1154#	define DM_SpecularTextureEnable			0x0100
1155#	define DM_DiffuseTextureEnable				0x0200
1156#	define DM_SubPixelCorrectionEnable			0x0400
1157#	define DM_DiamondExit					0x0800
1158#	define DM_NoDraw					0x1000
1159#	define DM_ClampEnable					0x2000
1160#	define DM_ClampedTexParMode				0x4000
1161#	define DM_NormalizedTexParMode				0xC000
1162
1163
1164#	define DDCMD_AreaStrippleEnable                        0x0001
1165#	define DDCMD_LineStrippleEnable                        0x0002
1166#	define DDCMD_ResetLineStripple                         1 << 2
1167#	define DDCMD_FastFillEnable                            1 << 3
1168        /*  2 Bits reserved */
1169#	define DDCMD_PrimitiveType_Point                       2 << 6
1170#	define DDCMD_PrimitiveType_Line                        0 << 6
1171#	define DDCMD_PrimitiveType_Trapezoid                   1 << 6
1172#	define DDCMD_AntialiasEnable				1 << 8
1173#	define DDCMD_AntialiasingQuality			1 << 9
1174#	define DDCMD_UsePointTable                             1 << 10
1175#	define DDCMD_SyncOnBitMask                             1 << 11
1176#	define DDCMD_SyncOnHostDate                            1 << 12
1177#	define DDCMD_TextureEnable			        1 << 13
1178#	define DDCMD_FogEnable                                 1 << 14
1179#	define DDCMD_CoverageEnable                            1 << 15
1180#	define DDCMD_SubPixelCorrectionEnable                  1 << 16
1181
1182
1183
1184#define DrawTriangle						GLINT_TAG_ADDR(0x26,0x01)
1185#define RepeatTriangle						GLINT_TAG_ADDR(0x26,0x02)
1186#define DrawLine01						GLINT_TAG_ADDR(0x26,0x03)
1187#define DrawLine10						GLINT_TAG_ADDR(0x26,0x04)
1188#define RepeatLine						GLINT_TAG_ADDR(0x26,0x05)
1189#define BroadcastMask						GLINT_TAG_ADDR(0x26,0x0F)
1190
1191/* Permedia 3 - Accelerator Extensions */
1192#define FillRectanglePosition					0x8348
1193#define FillRender2D						0x8350
1194#define FBDstReadBufAddr0					0xAE80
1195#define FBDstReadBufOffset0					0xAEA0
1196#define FBDstReadBufWidth0					0xAEC0
1197#define FBDstReadMode						0xAEE0
1198#define		FBDRM_Enable0		1<<8
1199#define		FBDRM_Blocking		1<<24
1200#define FBDstReadEnables					0xAEE8
1201#define FBSrcReadMode						0xAF00
1202#define		FBSRM_Blocking		1<<11
1203#define FBSrcReadBufAddr					0xAF08
1204#define FBSrcReadBufOffset0					0xAF10
1205#define FBSrcReadBufWidth					0xAF18
1206#define FBWriteBufAddr0						0xB000
1207#define FBWriteBufOffset0					0xB020
1208#define FBWriteBufWidth0					0xB040
1209#define FBBlockColorBack					0xB0A0
1210#define ForegroundColor						0xB0C0
1211#define BackgroundColor						0xB0C8
1212#define RectanglePosition					0xB600
1213#define Render2D						0xB640
1214
1215/*  Colorformats */
1216#define BGR555  1
1217#define BGR565  16
1218#define CI8     14
1219#define CI4     15
1220
1221#ifdef DEBUG
1222#define GLINT_WRITE_REG(v,r)					\
1223	GLINT_VERB_WRITE_REG(pGlint,v,r,__FILE__,__LINE__)
1224#define GLINT_READ_REG(r)					\
1225	GLINT_VERB_READ_REG(pGlint,r,__FILE__,__LINE__)
1226#else
1227
1228#define GLINT_WRITE_REG(v,r) \
1229	MMIO_OUT32(pGlint->IOBase + pGlint->IOOffset,(unsigned long)(r), (v))
1230#define GLINT_READ_REG(r) \
1231	MMIO_IN32(pGlint->IOBase + pGlint->IOOffset,(unsigned long)(r))
1232
1233#endif /* DEBUG */
1234
1235#define GLINT_WAIT(n)						\
1236do{								\
1237	if (pGlint->InFifoSpace>=(n))				\
1238	    pGlint->InFifoSpace -= (n);				\
1239	else {							\
1240	    int tmp;						\
1241	    while((tmp=GLINT_READ_REG(InFIFOSpace))<(n));	\
1242	    /* Clamp value due to bugs in PM3 */		\
1243	    if (tmp > pGlint->FIFOSize)				\
1244		tmp = pGlint->FIFOSize;				\
1245	    pGlint->InFifoSpace = tmp - (n);			\
1246	}							\
1247}while(0)
1248
1249#define GLINTDACDelay(x) do {                                   \
1250        int delay = x;                                          \
1251	while(delay--){(void)GLINT_READ_REG(InFIFOSpace);};     \
1252	} while(0)
1253
1254#define GLINT_MASK_WRITE_REG(v,m,r)				\
1255	GLINT_WRITE_REG((GLINT_READ_REG(r)&(m))|(v),r)
1256
1257#define GLINT_SLOW_WRITE_REG(v,r)				\
1258do{								\
1259	mem_barrier();						\
1260	GLINT_WAIT(pGlint->FIFOSize);		     		\
1261	mem_barrier();						\
1262        GLINT_WRITE_REG(v,r);					\
1263}while(0)
1264
1265#define GLINT_SET_INDEX(index)					\
1266do{								\
1267	GLINT_SLOW_WRITE_REG(((index)>>8)&0xff,PM2VDACIndexRegHigh);	\
1268	GLINT_SLOW_WRITE_REG((index)&0xff,PM2VDACIndexRegLow);	\
1269} while(0)
1270
1271#define REPLICATE(r)						\
1272{								\
1273	if (pScrn->bitsPerPixel == 16) {			\
1274		r &= 0xFFFF;					\
1275		r |= (r<<16);					\
1276	} else							\
1277	if (pScrn->bitsPerPixel == 8) { 			\
1278		r &= 0xFF;					\
1279		r |= (r<<8);					\
1280		r |= (r<<16);					\
1281	}							\
1282}
1283
1284#ifndef XF86DRI
1285#define LOADROP(rop)						\
1286{								\
1287	if (pGlint->ROP != rop)	{				\
1288		GLINT_WRITE_REG(rop<<1|UNIT_ENABLE, LogicalOpMode);	\
1289		pGlint->ROP = rop;				\
1290	}							\
1291}
1292#else
1293#define LOADROP(rop) \
1294	{				\
1295		GLINT_WRITE_REG(rop<<1|UNIT_ENABLE, LogicalOpMode);	\
1296		pGlint->ROP = rop;				\
1297	}
1298#endif
1299
1300#define CHECKCLIPPING						\
1301{								\
1302	if (pGlint->ClippingOn) {				\
1303		pGlint->ClippingOn = FALSE;			\
1304		GLINT_WAIT(1);					\
1305		GLINT_WRITE_REG(0, ScissorMode);		\
1306	}							\
1307}
1308
1309#ifndef XF86DRI
1310#define DO_PLANEMASK(planemask)					\
1311{ 								\
1312	if (planemask != pGlint->planemask) {			\
1313		pGlint->planemask = planemask;			\
1314		REPLICATE(planemask); 				\
1315		GLINT_WRITE_REG(planemask, FBHardwareWriteMask);\
1316	}							\
1317}
1318#else
1319#define DO_PLANEMASK(planemask)					\
1320	{							\
1321		pGlint->planemask = planemask;			\
1322		REPLICATE(planemask); 				\
1323		GLINT_WRITE_REG(planemask, FBHardwareWriteMask);\
1324	}
1325#endif
1326
1327/* Permedia Save/Restore functions */
1328
1329#define STOREREG(address,value) 				\
1330    	pReg->glintRegs[address >> 3] = value;
1331
1332#define SAVEREG(address) 					\
1333    	pReg->glintRegs[address >> 3] = GLINT_READ_REG(address);
1334
1335#define RESTOREREG(address) 					\
1336    	GLINT_SLOW_WRITE_REG(pReg->glintRegs[address >> 3], address);
1337
1338#define STOREDAC(address,value)					\
1339    	pReg->DacRegs[address] = value;
1340
1341#define P2VOUT(address)						\
1342    Permedia2vOutIndReg(pScrn, address, 0x00, pReg->DacRegs[address]);
1343
1344#define P2VIN(address)						\
1345    pReg->DacRegs[address] = Permedia2vInIndReg(pScrn, address);
1346
1347/* RamDac Save/Restore functions, used by external DAC's */
1348
1349#define STORERAMDAC(address,value)				\
1350    	ramdacReg->DacRegs[address] = value;
1351
1352/* Multi Chip access */
1353
1354#define ACCESSCHIP1()						\
1355    pGlint->IOOffset = 0;
1356
1357#define ACCESSCHIP2()						\
1358    pGlint->IOOffset = 0x10000;
1359
1360#endif
1361