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