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 TextureTypeOpenGL 0
716 #  define TextureTypeApple  1 << 4
717 #  define TextureKsDDA      1 << 5 /* only Apple-Mode */
718 #  define TextureKdDDA      1 << 6 /* only Apple-Mode */
719 
720 #define TextureEnvColor						GLINT_TAG_ADDR(0x0d,0x01)
721 #define FogMode							GLINT_TAG_ADDR(0x0d,0x02)
722 	/* 0:				*/
723 	/* FOG RGBA			*/
724 	/* UNIT_DISABLE			*/
725 
726 #	define FOG_CI							0x0002
727 
728 #define FogColor							GLINT_TAG_ADDR(0x0d,0x03)
729 #define FStart								GLINT_TAG_ADDR(0x0d,0x04)
730 #define dFdx								GLINT_TAG_ADDR(0x0d,0x05)
731 #define dFdyDom								GLINT_TAG_ADDR(0x0d,0x06)
732 #define KsStart								GLINT_TAG_ADDR(0x0d,0x09)
733 #define dKsdx								GLINT_TAG_ADDR(0x0d,0x0a)
734 #define dKsdyDom							GLINT_TAG_ADDR(0x0d,0x0b)
735 #define KdStart								GLINT_TAG_ADDR(0x0d,0x0c)
736 #define dKdStart							GLINT_TAG_ADDR(0x0d,0x0d)
737 #define dKddyDom							GLINT_TAG_ADDR(0x0d,0x0e)
738 
739 #define RStart								GLINT_TAG_ADDR(0x0f,0x00)
740 #define dRdx								GLINT_TAG_ADDR(0x0f,0x01)
741 #define dRdyDom								GLINT_TAG_ADDR(0x0f,0x02)
742 #define GStart								GLINT_TAG_ADDR(0x0f,0x03)
743 #define dGdx								GLINT_TAG_ADDR(0x0f,0x04)
744 #define dGdyDom								GLINT_TAG_ADDR(0x0f,0x05)
745 #define BStart								GLINT_TAG_ADDR(0x0f,0x06)
746 #define dBdx								GLINT_TAG_ADDR(0x0f,0x07)
747 #define dBdyDom								GLINT_TAG_ADDR(0x0f,0x08)
748 #define AStart								GLINT_TAG_ADDR(0x0f,0x09)
749 #define dAdx								GLINT_TAG_ADDR(0x0f,0x0a)
750 #define dAdyDom								GLINT_TAG_ADDR(0x0f,0x0b)
751 #define ColorDDAMode							GLINT_TAG_ADDR(0x0f,0x0c)
752 	/* 0:					*/
753 #	define CDDA_FlatShading			                0
754 	/* UNIT_DISABLE			*/
755 #	define CDDA_GouraudShading					0x0002
756 
757 
758 #define ConstantColor						GLINT_TAG_ADDR(0x0f,0x0d)
759 #define GLINTColor						GLINT_TAG_ADDR(0x0f,0x0e)
760 #define AlphaTestMode						GLINT_TAG_ADDR(0x10,0x00)
761 #define AntialiasMode						GLINT_TAG_ADDR(0x10,0x01)
762 #define AlphaBlendMode						GLINT_TAG_ADDR(0x10,0x02)
763 	/* 0:					*/
764 	/* SrcZERO				*/
765 	/* DstZERO				*/
766 	/* ColorFormat8888			*/
767 	/* AlphaBuffer present			*/
768 	/* ColorOrderBGR			*/
769 	/* TypeOpenGL				*/
770 	/* DstFBData				*/
771 	/* UNIT_DISABLE				*/
772 
773 #	define ABM_SrcONE					1 << 1
774 #	define ABM_SrcDST_COLOR				2 << 1
775 #	define ABM_SrcONE_MINUS_DST_COLOR			3 << 1
776 #	define ABM_SrcSRC_ALPHA				4 << 1
777 #	define ABM_SrcONE_MINUS_SRC_ALPHA			5 << 1
778 #	define ABM_SrcDST_ALPHA				6 << 1
779 #	define ABM_SrcONE_MINUS_DST_ALPHA			7 << 1
780 #	define ABM_SrcSRC_ALPHA_SATURATE			8 << 1
781 #	define ABM_DstONE					1 << 5
782 #	define ABM_DstSRC_COLOR				2 << 5
783 #	define ABM_DstONE_MINUS_SRC_COLOR			3 << 5
784 #	define ABM_DstSRC_ALPHA				4 << 5
785 #	define ABM_DstONE_MINUS_SRC_ALPHA			5 << 5
786 #	define ABM_DstDST_ALPHA				6 << 5
787 #	define ABM_DstONE_MINUS_DST_ALPHA			7 << 5
788 #	define ABM_ColorFormat5555				1 << 8
789 #	define ABM_ColorFormat4444				2 << 8
790 #	define ABM_ColorFormat4444_Front			3 << 8
791 #	define ABM_ColorFormat4444_Back			4 << 8
792 #	define ABM_ColorFormat332_Front			5 << 8
793 #	define ABM_ColorFormat332_Back				6 << 8
794 #	define ABM_ColorFormat121_Front			7 << 8
795 #	define ABM_ColorFormat121_Back				8 << 8
796 #	define ABM_ColorFormat555_Back				13 << 8
797 #	define ABM_ColorFormat_CI8				14 << 8
798 #	define ABM_ColorFormat_CI4				15 << 8
799 #	define ABM_NoAlphaBuffer				0x1000
800 #	define ABM_ColorOrderRGB				0x2000
801 #	define ABM_TypeQuickDraw3D				0x4000
802 #	define ABM_DstFBSourceData				0x8000
803 
804 #define DitherMode						GLINT_TAG_ADDR(0x10,0x03)
805 	/* 0:					*/
806 	/* ColorOrder BGR		*/
807 	/* AlphaDitherDefault	*/
808 	/* ColorFormat8888		*/
809 	/* TruncateMode 		*/
810 	/* DitherDisable		*/
811 	/* UNIT_DISABLE			*/
812 
813 #	define DTM_DitherEnable				1 << 1
814 #	define DTM_ColorFormat5555				1 << 2
815 #	define DTM_ColorFormat4444				2 << 2
816 #	define DTM_ColorFormat4444_Front			3 << 2
817 #	define DTM_ColorFormat4444_Back			4 << 2
818 #	define DTM_ColorFormat332_Front			5 << 2
819 #	define DTM_ColorFormat332_Back				6 << 2
820 #	define DTM_ColorFormat121_Front			7 << 2
821 #	define DTM_ColorFormat121_Back				8 << 2
822 #	define DTM_ColorFormat555_Back				13 << 2
823 #	define DTM_ColorFormat_CI8				14 << 2
824 #	define DTM_ColorFormat_CI4				15 << 2
825 #	define DTM_ColorOrderRGB				1 << 10
826 #	define DTM_NoAlphaDither				1 << 14
827 #	define DTM_RoundMode					1 << 15
828 
829 #define FBSoftwareWriteMask					GLINT_TAG_ADDR(0x10,0x04)
830 #define LogicalOpMode						GLINT_TAG_ADDR(0x10,0x05)
831 #	define Use_ConstantFBWriteData 0x40
832 
833 
834 #define FBWriteData						GLINT_TAG_ADDR(0x10,0x06)
835 #define RouterMode						GLINT_TAG_ADDR(0x10,0x08)
836 #	define ROUTER_Depth_Texture 1
837 #	define ROUTER_Texture_Depth 0
838 
839 
840 #define LBReadMode						GLINT_TAG_ADDR(0x11,0x00)
841 	/* 0:				*/
842 	/* SrcNoRead			*/
843 	/* DstNoRead			*/
844 	/* DataLBDefault		*/
845 	/* WinTopLeft			*/
846 	/* NoPatch			*/
847 	/* ScanlineInterval1 		*/
848 
849 #	define LBRM_SrcEnable						1 << 9
850 #	define LBRM_DstEnable						1 << 10
851 #	define LBRM_DataLBStencil					1 << 16
852 #	define LBRM_DataLBDepth					2 << 16
853 #	define LBRM_WinBottomLeft					1 << 18
854 #	define LBRM_DoPatch						1 << 19
855 
856 #	define LBRM_ScanlineInt2					1 << 20
857 #	define LBRM_ScanlineInt4					2 << 20
858 #	define LBRM_ScanlineInt8					3 << 20
859 
860 
861 #define LBReadFormat						GLINT_TAG_ADDR(0x11,0x01)
862 #	define LBRF_DepthWidth15   0x03  /* only permedia */
863 #	define LBRF_DepthWidth16   0x00
864 #	define LBRF_DepthWidth24   0x01
865 #	define LBRF_DepthWidth32   0x02
866 
867 #	define LBRF_StencilWidth0  (0 << 2)
868 #	define LBRF_StencilWidth4  (1 << 2)
869 #	define LBRF_StencilWidth8  (2 << 2)
870 
871 #	define LBRF_StencilPos16   (0 << 4)
872 #	define LBRF_StencilPos20   (1 << 4)
873 #	define LBRF_StencilPos24   (2 << 4)
874 #	define LBRF_StencilPos28   (3 << 4)
875 #	define LBRF_StencilPos32   (4 << 4)
876 
877 #	define LBRF_FrameCount0    (0 << 7)
878 #	define LBRF_FrameCount4    (1 << 7)
879 #	define LBRF_FrameCount8    (2 << 7)
880 
881 #	define LBRF_FrameCountPos16  (0 << 9)
882 #	define LBRF_FrameCountPos20  (1 << 9)
883 #	define LBRF_FrameCountPos24  (2 << 9)
884 #	define LBRF_FrameCountPos28  (3 << 9)
885 #	define LBRF_FrameCountPos32  (4 << 9)
886 #	define LBRF_FrameCountPos36  (5 << 9)
887 #	define LBRF_FrameCountPos40  (6 << 9)
888 
889 #	define LBRF_GIDWidth0 (0 << 12)
890 #	define LBRF_GIDWidth4 (1 << 12)
891 
892 #	define LBRF_GIDPos16  (0 << 13)
893 #	define LBRF_GIDPos20  (1 << 13)
894 #	define LBRF_GIDPos24  (2 << 13)
895 #	define LBRF_GIDPos28  (3 << 13)
896 #	define LBRF_GIDPos32  (4 << 13)
897 #	define LBRF_GIDPos36  (5 << 13)
898 #	define LBRF_GIDPos40  (6 << 13)
899 #	define LBRF_GIDPos44  (7 << 13)
900 #	define LBRF_GIDPos48  (8 << 13)
901 
902 #	define LBRF_Compact32  (1 << 17)
903 
904 
905 
906 #define LBSourceOffset						GLINT_TAG_ADDR(0x11,0x02)
907 #define LBStencil						GLINT_TAG_ADDR(0x11,0x05)
908 #define LBDepth							GLINT_TAG_ADDR(0x11,0x06)
909 #define LBWindowBase						GLINT_TAG_ADDR(0x11,0x07)
910 #define LBWriteMode						GLINT_TAG_ADDR(0x11,0x08)
911 #	define LBWM_WriteEnable				0x1
912 #	define LBWM_UpLoad_LBDepth				0x2
913 #	define LBWM_UpLoad_LBStencil				0x4
914 
915 #define LBWriteFormat						GLINT_TAG_ADDR(0x11,0x09)
916 
917 
918 #define TextureData						GLINT_TAG_ADDR(0x11,0x0d)
919 #define TextureDownloadOffset					GLINT_TAG_ADDR(0x11,0x0e)
920 #define LBWindowOffset						GLINT_TAG_ADDR(0x11,0x0f)
921 
922 #define GLINTWindow						GLINT_TAG_ADDR(0x13,0x00)
923 #	define GWIN_UnitEnable          (1 << 0)
924 #	define GWIN_ForceLBUpdate       (1 << 3)
925 #	define GWIN_LBUpdateSourceREG   (1 << 4)
926 #	define GWIN_LBUpdateSourceLB    (0 << 4)
927 #	define GWIN_StencilFCP          (1 << 17)
928 #	define GWIN_DepthFCP            (1 << 18)
929 #	define GWIN_OverrideWriteFilter (1 << 19)
930 
931 	/* ??? is this needed, set by permedia (2) modules */
932 #	define GWIN_DisableLBUpdate    0x40000
933 
934 #define StencilMode						GLINT_TAG_ADDR(0x13,0x01)
935 #define StencilData						GLINT_TAG_ADDR(0x13,0x02)
936 #define GLINTStencil						GLINT_TAG_ADDR(0x13,0x03)
937 #define DepthMode						GLINT_TAG_ADDR(0x13,0x04)
938 	/* 0:				*/
939 	/* WriteDisable			*/
940 	/* SrcCompFragment		*/
941 	/* CompFuncNEVER		*/
942 	/* UNIT_DISABLE			*/
943 
944 #	define DPM_WriteEnable					1 << 1
945 #	define DPM_SrcCompLBData				1 << 2
946 #	define DPM_SrcCompDregister				2 << 2
947 #	define DPM_SrcCompLBSourceData				3 << 2
948 #	define DPM_CompFuncLESS				1 << 4
949 #	define DPM_CompFuncEQUAL				2 << 4
950 #	define DPM_CompFuncLESS_OR_EQ				3 << 4
951 #	define DPM_CompFuncGREATER				4 << 4
952 #	define DPM_CompFuncNOT_EQ				5 << 4
953 #	define DPM_CompFuncGREATER_OR_EQ			6 << 4
954 #	define DPM_CompFuncALWAYS				7 << 4
955 
956 #define GLINTDepth						GLINT_TAG_ADDR(0x13,0x05)
957 #define ZStartU							GLINT_TAG_ADDR(0x13,0x06)
958 #define ZStartL							GLINT_TAG_ADDR(0x13,0x07)
959 #define dZdxU							GLINT_TAG_ADDR(0x13,0x08)
960 #define dZdxL							GLINT_TAG_ADDR(0x13,0x09)
961 #define dZdyDomU						GLINT_TAG_ADDR(0x13,0x0a)
962 #define dZdyDomL						GLINT_TAG_ADDR(0x13,0x0b)
963 #define FastClearDepth						GLINT_TAG_ADDR(0x13,0x0c)
964 
965 #define FBReadMode						GLINT_TAG_ADDR(0x15,0x00)
966 	/* 0:				*/
967 	/* SrcNoRead			*/
968 	/* DstNoRead			*/
969 	/* DataFBDefault		*/
970 	/* WinTopLeft			*/
971 	/* ScanlineInterval1 		*/
972 
973 #	define FBRM_SrcEnable					1 << 9
974 #	define FBRM_DstEnable					1 << 10
975 #	define FBRM_DataFBColor				1 << 15
976 #	define FBRM_WinBottomLeft				1 << 16
977 #	define FBRM_Packed					1 << 19
978 #	define FBRM_ScanlineInt2				1 << 23
979 #	define FBRM_ScanlineInt4				2 << 23
980 #	define FBRM_ScanlineInt8				3 << 23
981 
982 
983 #define FBSourceOffset						GLINT_TAG_ADDR(0x15,0x01)
984 #define FBPixelOffset						GLINT_TAG_ADDR(0x15,0x02)
985 #define FBColor							GLINT_TAG_ADDR(0x15,0x03)
986 #define FBData							GLINT_TAG_ADDR(0x15,0x04)
987 #define FBSourceData						GLINT_TAG_ADDR(0x15,0x05)
988 
989 #define FBWindowBase						GLINT_TAG_ADDR(0x15,0x06)
990 #define FBWriteMode						GLINT_TAG_ADDR(0x15,0x07)
991 	/* 0:			*/
992 	/* FBWM_NoColorUpload	*/
993 	/* FBWM_WriteDisable	*/
994 #	define FBWM_WriteEnable				1
995 #	define FBWM_UploadColor				1 << 3
996 /* Permedia3 extensions */
997 #	define FBWM_Enable0					1 << 12
998 
999 #define FBHardwareWriteMask					GLINT_TAG_ADDR(0x15,0x08)
1000 #define FBBlockColor						GLINT_TAG_ADDR(0x15,0x09)
1001 #define FBReadPixel						GLINT_TAG_ADDR(0x15,0x0a) /* PM */
1002 #define PatternRamMode						GLINT_TAG_ADDR(0x15,0x0f)
1003 
1004 #define PatternRamData0						GLINT_TAG_ADDR(0x16,0x00)
1005 #define PatternRamData1						GLINT_TAG_ADDR(0x16,0x01)
1006 #define PatternRamData2						GLINT_TAG_ADDR(0x16,0x02)
1007 #define PatternRamData3						GLINT_TAG_ADDR(0x16,0x03)
1008 #define PatternRamData4						GLINT_TAG_ADDR(0x16,0x04)
1009 #define PatternRamData5						GLINT_TAG_ADDR(0x16,0x05)
1010 #define PatternRamData6						GLINT_TAG_ADDR(0x16,0x06)
1011 #define PatternRamData7						GLINT_TAG_ADDR(0x16,0x07)
1012 
1013 #define FilterMode						GLINT_TAG_ADDR(0x18,0x00)
1014 	/* 0:				*/
1015 	/* CullDepthTags		*/
1016 	/* CullDepthData		*/
1017 	/* CullStencilTags		*/
1018 	/* CullStencilData		*/
1019 	/* CullColorTag			*/
1020 	/* CullColorData		*/
1021 	/* CullSyncTag			*/
1022 	/* CullSyncData			*/
1023 	/* CullStatisticTag		*/
1024 	/* CullStatisticData		*/
1025 
1026 #	define FM_PassDepthTags					0x0010
1027 #	define FM_PassDepthData					0x0020
1028 #	define FM_PassStencilTags					0x0040
1029 #	define FM_PassStencilData					0x0080
1030 #	define FM_PassColorTag						0x0100
1031 #	define FM_PassColorData					0x0200
1032 #	define FM_PassSyncTag						0x0400
1033 #	define FM_PassSyncData						0x0800
1034 #	define FM_PassStatisticTag					0x1000
1035 #	define FM_PassStatisticData					0x2000
1036 
1037 #define	Sync_tag							0x0188
1038 
1039 #define StatisticMode						GLINT_TAG_ADDR(0x18,0x01)
1040 #define MinRegion						GLINT_TAG_ADDR(0x18,0x02)
1041 #define MaxRegion						GLINT_TAG_ADDR(0x18,0x03)
1042 #define ResetPickResult						GLINT_TAG_ADDR(0x18,0x04)
1043 #define MitHitRegion						GLINT_TAG_ADDR(0x18,0x05)
1044 #define MaxHitRegion						GLINT_TAG_ADDR(0x18,0x06)
1045 #define PickResult						GLINT_TAG_ADDR(0x18,0x07)
1046 #define GlintSync						GLINT_TAG_ADDR(0x18,0x08)
1047 
1048 #define FBBlockColorU						GLINT_TAG_ADDR(0x18,0x0d)
1049 #define FBBlockColorL						GLINT_TAG_ADDR(0x18,0x0e)
1050 #define SuspendUntilFrameBlank					GLINT_TAG_ADDR(0x18,0x0f)
1051 
1052 #define KsRStart						GLINT_TAG_ADDR(0x19,0x00)
1053 #define dKsRdx							GLINT_TAG_ADDR(0x19,0x01)
1054 #define dKsRdyDom						GLINT_TAG_ADDR(0x19,0x02)
1055 #define KsGStart						GLINT_TAG_ADDR(0x19,0x03)
1056 #define dKsGdx							GLINT_TAG_ADDR(0x19,0x04)
1057 #define dKsGdyDom						GLINT_TAG_ADDR(0x19,0x05)
1058 #define KsBStart						GLINT_TAG_ADDR(0x19,0x06)
1059 #define dKsBdx							GLINT_TAG_ADDR(0x19,0x07)
1060 #define dKsBdyDom						GLINT_TAG_ADDR(0x19,0x08)
1061 
1062 #define KdRStart						GLINT_TAG_ADDR(0x1A,0x00)
1063 #define dKdRdx							GLINT_TAG_ADDR(0x1A,0x01)
1064 #define dKdRdyDom						GLINT_TAG_ADDR(0x1A,0x02)
1065 #define KdGStart						GLINT_TAG_ADDR(0x1A,0x03)
1066 #define dKdGdx							GLINT_TAG_ADDR(0x1A,0x04)
1067 #define dKdGdyDom						GLINT_TAG_ADDR(0x1A,0x05)
1068 #define KdBStart						GLINT_TAG_ADDR(0x1A,0x06)
1069 #define dKdBdx							GLINT_TAG_ADDR(0x1A,0x07)
1070 #define dKdBdyDom						GLINT_TAG_ADDR(0x1A,0x08)
1071 
1072 #define FBSourceBase						GLINT_TAG_ADDR(0x1B,0x00)
1073 #define FBSourceDelta						GLINT_TAG_ADDR(0x1B,0x01)
1074 #define Config							GLINT_TAG_ADDR(0x1B,0x02)
1075 #define		CFBRM_SrcEnable		1<<0
1076 #define		CFBRM_DstEnable		1<<1
1077 #define		CFBRM_Packed		1<<2
1078 #define		CWM_Enable		1<<3
1079 #define		CCDDA_Enable		1<<4
1080 #define		CLogOp_Enable		1<<5
1081 #define ContextDump                                             GLINT_TAG_ADDR(0x1B,0x08)
1082 #define ContextRestore                                          GLINT_TAG_ADDR(0x1B,0x09)
1083 #define ContextData                                             GLINT_TAG_ADDR(0x1B,0x0a)
1084 
1085 #define TexelLUT0						GLINT_TAG_ADDR(0x1D,0x00)
1086 #define TexelLUT1						GLINT_TAG_ADDR(0x1D,0x01)
1087 #define TexelLUT2						GLINT_TAG_ADDR(0x1D,0x02)
1088 #define TexelLUT3						GLINT_TAG_ADDR(0x1D,0x03)
1089 #define TexelLUT4						GLINT_TAG_ADDR(0x1D,0x04)
1090 #define TexelLUT5						GLINT_TAG_ADDR(0x1D,0x05)
1091 #define TexelLUT6						GLINT_TAG_ADDR(0x1D,0x06)
1092 #define TexelLUT7						GLINT_TAG_ADDR(0x1D,0x07)
1093 #define TexelLUT8						GLINT_TAG_ADDR(0x1D,0x08)
1094 #define TexelLUT9						GLINT_TAG_ADDR(0x1D,0x09)
1095 #define TexelLUT10						GLINT_TAG_ADDR(0x1D,0x0A)
1096 #define TexelLUT11						GLINT_TAG_ADDR(0x1D,0x0B)
1097 #define TexelLUT12						GLINT_TAG_ADDR(0x1D,0x0C)
1098 #define TexelLUT13						GLINT_TAG_ADDR(0x1D,0x0D)
1099 #define TexelLUT14						GLINT_TAG_ADDR(0x1D,0x0E)
1100 #define TexelLUT15						GLINT_TAG_ADDR(0x1D,0x0F)
1101 
1102 #define YUVMode                                                 GLINT_TAG_ADDR(0x1E,0x00)
1103 #define ChromaUpper                                             GLINT_TAG_ADDR(0x1E,0x01)
1104 #define ChromaLower                                             GLINT_TAG_ADDR(0x1E,0x02)
1105 #define ChromaTestMode                                          GLINT_TAG_ADDR(0x1E,0x03)
1106 
1107 
1108 /******************************
1109  * GLINT Delta Core Registers *
1110  ******************************/
1111 
1112 #define V0FixedTag	GLINT_TAG_ADDR(0x20,0x00)
1113 #define V1FixedTag	GLINT_TAG_ADDR(0x21,0x00)
1114 #define V2FixedTag	GLINT_TAG_ADDR(0x22,0x00)
1115 #define V0FloatTag	GLINT_TAG_ADDR(0x23,0x00)
1116 #define V1FloatTag	GLINT_TAG_ADDR(0x24,0x00)
1117 #define V2FloatTag	GLINT_TAG_ADDR(0x25,0x00)
1118 
1119 #define VPAR_s		0x00
1120 #define VPAR_t		0x08
1121 #define VPAR_q		0x10
1122 #define VPAR_Ks		0x18
1123 #define VPAR_Kd		0x20
1124 
1125 /* have changed colors in ramdac !
1126 #define VPAR_R		0x28
1127 #define VPAR_G		0x30
1128 #define VPAR_B		0x38
1129 #define VPAR_A		0x40
1130 */
1131 #define VPAR_B		0x28
1132 #define VPAR_G		0x30
1133 #define VPAR_R		0x38
1134 #define VPAR_A		0x40
1135 
1136 #define VPAR_f		0x48
1137 
1138 #define VPAR_x		0x50
1139 #define VPAR_y		0x58
1140 #define VPAR_z		0x60
1141 
1142 #define DeltaModeTag						GLINT_TAG_ADDR(0x26,0x00)
1143 	/* 0:				*/
1144 	/* GLINT_300SX			*/
1145 
1146 	/* DeltaMode Register Bit Field Assignments */
1147 #	define DM_GLINT_300SX					0x0000
1148 #	define DM_GLINT_500TX					0x0001
1149 #	define DM_PERMEDIA					0x0002
1150 #	define DM_Depth_16BPP					(1 << 2)
1151 #	define DM_Depth_24BPP					(2 << 2)
1152 #	define DM_Depth_32BPP					(3 << 2)
1153 #	define DM_FogEnable					0x0010
1154 #	define DM_TextureEnable				0x0020
1155 #	define DM_SmoothShadingEnable				0x0040
1156 #	define DM_DepthEnable					0x0080
1157 #	define DM_SpecularTextureEnable			0x0100
1158 #	define DM_DiffuseTextureEnable				0x0200
1159 #	define DM_SubPixelCorrectionEnable			0x0400
1160 #	define DM_DiamondExit					0x0800
1161 #	define DM_NoDraw					0x1000
1162 #	define DM_ClampEnable					0x2000
1163 #	define DM_ClampedTexParMode				0x4000
1164 #	define DM_NormalizedTexParMode				0xC000
1165 
1166 
1167 #	define DDCMD_AreaStrippleEnable                        0x0001
1168 #	define DDCMD_LineStrippleEnable                        0x0002
1169 #	define DDCMD_ResetLineStripple                         1 << 2
1170 #	define DDCMD_FastFillEnable                            1 << 3
1171         /*  2 Bits reserved */
1172 #	define DDCMD_PrimitiveType_Point                       2 << 6
1173 #	define DDCMD_PrimitiveType_Line                        0 << 6
1174 #	define DDCMD_PrimitiveType_Trapezoid                   1 << 6
1175 #	define DDCMD_AntialiasEnable				1 << 8
1176 #	define DDCMD_AntialiasingQuality			1 << 9
1177 #	define DDCMD_UsePointTable                             1 << 10
1178 #	define DDCMD_SyncOnBitMask                             1 << 11
1179 #	define DDCMD_SyncOnHostDate                            1 << 12
1180 #	define DDCMD_TextureEnable			        1 << 13
1181 #	define DDCMD_FogEnable                                 1 << 14
1182 #	define DDCMD_CoverageEnable                            1 << 15
1183 #	define DDCMD_SubPixelCorrectionEnable                  1 << 16
1184 
1185 
1186 
1187 #define DrawTriangle						GLINT_TAG_ADDR(0x26,0x01)
1188 #define RepeatTriangle						GLINT_TAG_ADDR(0x26,0x02)
1189 #define DrawLine01						GLINT_TAG_ADDR(0x26,0x03)
1190 #define DrawLine10						GLINT_TAG_ADDR(0x26,0x04)
1191 #define RepeatLine						GLINT_TAG_ADDR(0x26,0x05)
1192 #define BroadcastMask						GLINT_TAG_ADDR(0x26,0x0F)
1193 
1194 /* Permedia 3 - Accelerator Extensions */
1195 #define FillRectanglePosition					0x8348
1196 #define FillRender2D						0x8350
1197 #define FBDstReadBufAddr0					0xAE80
1198 #define FBDstReadBufOffset0					0xAEA0
1199 #define FBDstReadBufWidth0					0xAEC0
1200 #define FBDstReadMode						0xAEE0
1201 #define		FBDRM_Enable0		1<<8
1202 #define		FBDRM_Blocking		1<<24
1203 #define FBDstReadEnables					0xAEE8
1204 #define FBSrcReadMode						0xAF00
1205 #define		FBSRM_Blocking		1<<11
1206 #define FBSrcReadBufAddr					0xAF08
1207 #define FBSrcReadBufOffset0					0xAF10
1208 #define FBSrcReadBufWidth					0xAF18
1209 #define FBWriteBufAddr0						0xB000
1210 #define FBWriteBufOffset0					0xB020
1211 #define FBWriteBufWidth0					0xB040
1212 #define FBBlockColorBack					0xB0A0
1213 #define ForegroundColor						0xB0C0
1214 #define BackgroundColor						0xB0C8
1215 #define RectanglePosition					0xB600
1216 #define Render2D						0xB640
1217 
1218 /*  Colorformats */
1219 #define BGR555  1
1220 #define BGR565  16
1221 #define CI8     14
1222 #define CI4     15
1223 
1224 #ifdef DEBUG
1225 #define GLINT_WRITE_REG(v,r)					\
1226 	GLINT_VERB_WRITE_REG(pGlint,v,r,__FILE__,__LINE__)
1227 #define GLINT_READ_REG(r)					\
1228 	GLINT_VERB_READ_REG(pGlint,r,__FILE__,__LINE__)
1229 #else
1230 
1231 #define GLINT_WRITE_REG(v,r) \
1232 	MMIO_OUT32(pGlint->IOBase + pGlint->IOOffset,(unsigned long)(r), (v))
1233 #define GLINT_READ_REG(r) \
1234 	MMIO_IN32(pGlint->IOBase + pGlint->IOOffset,(unsigned long)(r))
1235 
1236 #endif /* DEBUG */
1237 
1238 #define GLINT_WAIT(n)						\
1239 do{								\
1240 	if (pGlint->InFifoSpace>=(n))				\
1241 	    pGlint->InFifoSpace -= (n);				\
1242 	else {							\
1243 	    int tmp;						\
1244 	    while((tmp=GLINT_READ_REG(InFIFOSpace))<(n));	\
1245 	    /* Clamp value due to bugs in PM3 */		\
1246 	    if (tmp > pGlint->FIFOSize)				\
1247 		tmp = pGlint->FIFOSize;				\
1248 	    pGlint->InFifoSpace = tmp - (n);			\
1249 	}							\
1250 }while(0)
1251 
1252 #define GLINTDACDelay(x) do {                                   \
1253         int delay = x;                                          \
1254         unsigned char tmp;                                      \
1255 	while(delay--){tmp = GLINT_READ_REG(InFIFOSpace);};     \
1256 	} while(0)
1257 
1258 #define GLINT_MASK_WRITE_REG(v,m,r)				\
1259 	GLINT_WRITE_REG((GLINT_READ_REG(r)&(m))|(v),r)
1260 
1261 #define GLINT_SLOW_WRITE_REG(v,r)				\
1262 do{								\
1263 	mem_barrier();						\
1264 	GLINT_WAIT(pGlint->FIFOSize);		     		\
1265 	mem_barrier();						\
1266         GLINT_WRITE_REG(v,r);					\
1267 }while(0)
1268 
1269 #define GLINT_SET_INDEX(index)					\
1270 do{								\
1271 	GLINT_SLOW_WRITE_REG(((index)>>8)&0xff,PM2VDACIndexRegHigh);	\
1272 	GLINT_SLOW_WRITE_REG((index)&0xff,PM2VDACIndexRegLow);	\
1273 } while(0)
1274 
1275 #define REPLICATE(r)						\
1276 {								\
1277 	if (pScrn->bitsPerPixel == 16) {			\
1278 		r &= 0xFFFF;					\
1279 		r |= (r<<16);					\
1280 	} else							\
1281 	if (pScrn->bitsPerPixel == 8) { 			\
1282 		r &= 0xFF;					\
1283 		r |= (r<<8);					\
1284 		r |= (r<<16);					\
1285 	}							\
1286 }
1287 
1288 #define LOADROP(rop)						\
1289 {								\
1290 	if (pGlint->ROP != rop)	{				\
1291 		GLINT_WRITE_REG(rop<<1|UNIT_ENABLE, LogicalOpMode);	\
1292 		pGlint->ROP = rop;				\
1293 	}							\
1294 }
1295 
1296 #define CHECKCLIPPING						\
1297 {								\
1298 	if (pGlint->ClippingOn) {				\
1299 		pGlint->ClippingOn = FALSE;			\
1300 		GLINT_WAIT(1);					\
1301 		GLINT_WRITE_REG(0, ScissorMode);		\
1302 	}							\
1303 }
1304 
1305 #define DO_PLANEMASK(planemask)					\
1306 { 								\
1307 	if (planemask != pGlint->planemask) {			\
1308 		pGlint->planemask = planemask;			\
1309 		REPLICATE(planemask); 				\
1310 		GLINT_WRITE_REG(planemask, FBHardwareWriteMask);\
1311 	}							\
1312 }
1313 
1314 /* Permedia Save/Restore functions */
1315 
1316 #define STOREREG(address,value) 				\
1317     	pReg->glintRegs[address >> 3] = value;
1318 
1319 #define SAVEREG(address) 					\
1320     	pReg->glintRegs[address >> 3] = GLINT_READ_REG(address);
1321 
1322 #define RESTOREREG(address) 					\
1323     	GLINT_SLOW_WRITE_REG(pReg->glintRegs[address >> 3], address);
1324 
1325 #define STOREDAC(address,value)					\
1326     	pReg->DacRegs[address] = value;
1327 
1328 #define P2VOUT(address)						\
1329     Permedia2vOutIndReg(pScrn, address, 0x00, pReg->DacRegs[address]);
1330 
1331 #define P2VIN(address)						\
1332     pReg->DacRegs[address] = Permedia2vInIndReg(pScrn, address);
1333 
1334 /* RamDac Save/Restore functions, used by external DAC's */
1335 
1336 #define STORERAMDAC(address,value)				\
1337     	ramdacReg->DacRegs[address] = value;
1338 
1339 /* Multi Chip access */
1340 
1341 #define ACCESSCHIP1()						\
1342     pGlint->IOOffset = 0;
1343 
1344 #define ACCESSCHIP2()						\
1345     pGlint->IOOffset = 0x10000;
1346 
1347 #endif
1348