disable debug
[AROS.git] / workbench / hidds / nvidia / riva_hw.h
blob1342391ca4c8cbdaeaab2c43f6a38bb327c98626
1 /***************************************************************************\
2 |* *|
3 |* Copyright 1993-1999 NVIDIA, Corporation. All rights reserved. *|
4 |* *|
5 |* NOTICE TO USER: The source code is copyrighted under U.S. and *|
6 |* international laws. Users and possessors of this source code are *|
7 |* hereby granted a nonexclusive, royalty-free copyright license to *|
8 |* use this code in individual and commercial software. *|
9 |* *|
10 |* Any use of this source code must include, in the user documenta- *|
11 |* tion and internal comments to the code, notices to the end user *|
12 |* as follows: *|
13 |* *|
14 |* Copyright 1993-1999 NVIDIA, Corporation. All rights reserved. *|
15 |* *|
16 |* NVIDIA, CORPORATION MAKES NO REPRESENTATION ABOUT THE SUITABILITY *|
17 |* OF THIS SOURCE CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" *|
18 |* WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND. NVIDIA, CORPOR- *|
19 |* ATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOURCE CODE, *|
20 |* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGE- *|
21 |* MENT, AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL *|
22 |* NVIDIA, CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT, INCI- *|
23 |* DENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RE- *|
24 |* SULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION *|
25 |* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF *|
26 |* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE CODE. *|
27 |* *|
28 |* U.S. Government End Users. This source code is a "commercial *|
29 |* item," as that term is defined at 48 C.F.R. 2.101 (OCT 1995), *|
30 |* consisting of "commercial computer software" and "commercial *|
31 |* computer software documentation," as such terms are used in *|
32 |* 48 C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Govern- *|
33 |* ment only as a commercial end item. Consistent with 48 C.F.R. *|
34 |* 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), *|
35 |* all U.S. Government End Users acquire the source code with only *|
36 |* those rights set forth herein. *|
37 |* *|
38 \***************************************************************************/
40 #ifndef __RIVA_HW_H__
41 #define __RIVA_HW_H__
42 #define RIVA_SW_VERSION 0x00010003
44 #include <exec/types.h>
46 #define mem_barrier() /* eps */
49 * Define supported architectures.
51 #define NV_ARCH_03 0x03
52 #define NV_ARCH_04 0x04
53 #define NV_ARCH_10 0x10
54 #define NV_ARCH_20 0x20
55 #define NV_ARCH_30 0x30
56 #define NV_ARCH_40 0x40
58 /***************************************************************************\
59 * *
60 * FIFO registers. *
61 * *
62 \***************************************************************************/
65 * Raster OPeration. Windows style ROP3.
67 typedef volatile struct
69 ULONG reserved00[4];
70 #if AROS_BIG_ENDIAN
71 ULONG FifoFree;
72 #else
73 UWORD FifoFree;
74 UWORD Nop;
75 #endif
76 ULONG reserved01[0x0BB];
77 ULONG Rop3;
78 } RivaRop;
80 * 8X8 Monochrome pattern.
82 typedef volatile struct
84 ULONG reserved00[4];
85 #if AROS_BIG_ENDIAN
86 ULONG FifoFree;
87 #else
88 UWORD FifoFree;
89 UWORD Nop;
90 #endif
91 ULONG reserved01[0x0BD];
92 ULONG Shape;
93 ULONG reserved03[0x001];
94 ULONG Color0;
95 ULONG Color1;
96 ULONG Monochrome[2];
97 } RivaPattern;
99 * Scissor clip rectangle.
101 typedef volatile struct
103 ULONG reserved00[4];
104 #if AROS_BIG_ENDIAN
105 ULONG FifoFree;
106 #else
107 UWORD FifoFree;
108 UWORD Nop;
109 #endif
110 ULONG reserved01[0x0BB];
111 ULONG TopLeft;
112 ULONG WidthHeight;
113 } RivaClip;
115 * 2D filled rectangle.
117 typedef volatile struct
119 ULONG reserved00[4];
120 #if AROS_BIG_ENDIAN
121 ULONG FifoFree;
122 #else
123 UWORD FifoFree;
124 UWORD Nop[1];
125 #endif
126 ULONG reserved01[0x0BC];
127 ULONG Color;
128 ULONG reserved03[0x03E];
129 ULONG TopLeft;
130 ULONG WidthHeight;
131 } RivaRectangle;
133 * 2D screen-screen BLT.
135 typedef volatile struct
137 ULONG reserved00[4];
138 #if AROS_BIG_ENDIAN
139 ULONG FifoFree;
140 #else
141 UWORD FifoFree;
142 UWORD Nop;
143 #endif
144 ULONG reserved01[0x0BB];
145 ULONG TopLeftSrc;
146 ULONG TopLeftDst;
147 ULONG WidthHeight;
148 } RivaScreenBlt;
150 * 2D pixel BLT.
152 typedef volatile struct
154 ULONG reserved00[4];
155 #if AROS_BIG_ENDIAN
156 ULONG FifoFree;
157 #else
158 UWORD FifoFree;
159 UWORD Nop[1];
160 #endif
161 ULONG reserved01[0x0BC];
162 ULONG TopLeft;
163 ULONG WidthHeight;
164 ULONG WidthHeightIn;
165 ULONG reserved02[0x03C];
166 ULONG Pixels;
167 } RivaPixmap;
169 * Filled rectangle combined with monochrome expand. Useful for glyphs.
171 typedef volatile struct
173 ULONG reserved00[4];
174 #if AROS_BIG_ENDIAN
175 ULONG FifoFree;
176 #else
177 UWORD FifoFree;
178 UWORD Nop;
179 #endif
180 ULONG reserved01[0x0BB];
181 ULONG reserved03[(0x040)-1];
182 ULONG Color1A;
183 struct
185 ULONG TopLeft;
186 ULONG WidthHeight;
187 } UnclippedRectangle[64];
188 ULONG reserved04[(0x080)-3];
189 struct
191 ULONG TopLeft;
192 ULONG BottomRight;
193 } ClipB;
194 ULONG Color1B;
195 struct
197 ULONG TopLeft;
198 ULONG BottomRight;
199 } ClippedRectangle[64];
200 ULONG reserved05[(0x080)-5];
201 struct
203 ULONG TopLeft;
204 ULONG BottomRight;
205 } ClipC;
206 ULONG Color1C;
207 ULONG WidthHeightC;
208 ULONG PointC;
209 ULONG MonochromeData1C;
210 ULONG reserved06[(0x080)+121];
211 struct
213 ULONG TopLeft;
214 ULONG BottomRight;
215 } ClipD;
216 ULONG Color1D;
217 ULONG WidthHeightInD;
218 ULONG WidthHeightOutD;
219 ULONG PointD;
220 ULONG MonochromeData1D;
221 ULONG reserved07[(0x080)+120];
222 struct
224 ULONG TopLeft;
225 ULONG BottomRight;
226 } ClipE;
227 ULONG Color0E;
228 ULONG Color1E;
229 ULONG WidthHeightInE;
230 ULONG WidthHeightOutE;
231 ULONG PointE;
232 ULONG MonochromeData01E;
233 } RivaBitmap;
235 * 2D line.
237 typedef volatile struct
239 ULONG reserved00[4];
240 #if AROS_BIG_ENDIAN
241 ULONG FifoFree;
242 #else
243 UWORD FifoFree;
244 UWORD Nop[1];
245 #endif
246 ULONG reserved01[0x0BC];
247 ULONG Color; /* source color 0304-0307*/
248 ULONG Reserved02[0x03e];
249 struct { /* start aliased methods in array 0400- */
250 ULONG point0; /* y_x S16_S16 in pixels 0- 3*/
251 ULONG point1; /* y_x S16_S16 in pixels 4- 7*/
252 } Lin[16]; /* end of aliased methods in array -047f*/
253 struct { /* start aliased methods in array 0480- */
254 ULONG point0X; /* in pixels, 0 at left 0- 3*/
255 ULONG point0Y; /* in pixels, 0 at top 4- 7*/
256 ULONG point1X; /* in pixels, 0 at left 8- b*/
257 ULONG point1Y; /* in pixels, 0 at top c- f*/
258 } Lin32[8]; /* end of aliased methods in array -04ff*/
259 ULONG PolyLin[32]; /* y_x S16_S16 in pixels 0500-057f*/
260 struct { /* start aliased methods in array 0580- */
261 ULONG x; /* in pixels, 0 at left 0- 3*/
262 ULONG y; /* in pixels, 0 at top 4- 7*/
263 } PolyLin32[16]; /* end of aliased methods in array -05ff*/
264 struct { /* start aliased methods in array 0600- */
265 ULONG color; /* source color 0- 3*/
266 ULONG point; /* y_x S16_S16 in pixels 4- 7*/
267 } ColorPolyLin[16]; /* end of aliased methods in array -067f*/
268 } RivaLine;
270 * 2D/3D surfaces
272 typedef volatile struct
274 ULONG reserved00[4];
275 #if AROS_BIG_ENDIAN
276 ULONG FifoFree;
277 #else
278 UWORD FifoFree;
279 UWORD Nop;
280 #endif
281 ULONG reserved01[0x0BE];
282 ULONG Offset;
283 } RivaSurface;
285 typedef volatile struct
287 ULONG reserved00[4];
288 #if AROS_BIG_ENDIAN
289 ULONG FifoFree;
290 #else
291 UWORD FifoFree;
292 UWORD Nop;
293 #endif
294 ULONG reserved01[0x0BB];
295 ULONG SurfaceFormat;
296 ULONG SurfacePitch;
297 ULONG OffsetSrc;
298 ULONG OffsetDst;
299 } RivaSurface2;
301 typedef volatile struct
303 ULONG reserved00[4];
304 #if AROS_BIG_ENDIAN
305 ULONG FifoFree;
306 #else
307 UWORD FifoFree;
308 UWORD Nop;
309 #endif
310 ULONG reserved01[0x0BD];
311 ULONG Pitch;
312 ULONG RenderBufferOffset;
313 ULONG ZBufferOffset;
314 } RivaSurface3D;
316 /***************************************************************************\
318 * Virtualized RIVA H/W interface. *
320 \***************************************************************************/
322 #define FP_ENABLE 1
323 #define FP_DITHER 2
325 #if 0
326 struct _riva_hw_inst;
327 struct _riva_hw_state;
329 * Virtialized chip interface. Makes RIVA 128 and TNT look alike.
331 typedef struct _riva_hw_inst
334 * Chip specific settings.
336 ULONG Architecture;
337 ULONG Version;
338 ULONG Chipset;
339 ULONG CrystalFreqKHz;
340 ULONG RamAmountKBytes;
341 ULONG MaxVClockFreqKHz;
342 ULONG RamBandwidthKBytesPerSec;
343 ULONG EnableIRQ;
344 ULONG IO;
345 ULONG VBlankBit;
346 ULONG FifoFreeCount;
347 ULONG FifoEmptyCount;
348 ULONG CursorStart;
349 ULONG flatPanel;
350 Bool twoHeads;
352 * Non-FIFO registers.
354 volatile ULONG *PCRTC0;
355 volatile ULONG *PCRTC;
356 volatile ULONG *PRAMDAC0;
357 volatile ULONG *PFB;
358 volatile ULONG *PFIFO;
359 volatile ULONG *PGRAPH;
360 volatile ULONG *PEXTDEV;
361 volatile ULONG *PTIMER;
362 volatile ULONG *PMC;
363 volatile ULONG *PRAMIN;
364 volatile ULONG *FIFO;
365 volatile ULONG *CURSOR;
366 volatile U008 *PCIO0;
367 volatile U008 *PCIO;
368 volatile U008 *PVIO;
369 volatile U008 *PDIO0;
370 volatile U008 *PDIO;
371 volatile ULONG *PRAMDAC;
373 * Common chip functions.
375 int (*Busy)(struct _riva_hw_inst *);
376 void (*CalcStateExt)(struct _riva_hw_inst *,struct _riva_hw_state *,int,int,int,int,int,int);
377 void (*LoadStateExt)(struct _riva_hw_inst *,struct _riva_hw_state *);
378 void (*UnloadStateExt)(struct _riva_hw_inst *,struct _riva_hw_state *);
379 void (*SetStartAddress)(struct _riva_hw_inst *,ULONG);
380 int (*ShowHideCursor)(struct _riva_hw_inst *,int);
381 void (*LockUnlock)(struct _riva_hw_inst *, int);
383 * Current extended mode settings.
385 struct _riva_hw_state *CurrentState;
387 * FIFO registers.
389 RivaRop *Rop;
390 RivaPattern *Patt;
391 RivaClip *Clip;
392 RivaPixmap *Pixmap;
393 RivaScreenBlt *Blt;
394 RivaBitmap *Bitmap;
395 RivaLine *Line;
396 RivaSurface2 *Surface;
397 } RIVA_HW_INST;
399 * Extended mode state information.
401 typedef struct _riva_hw_state
403 ULONG bpp;
404 ULONG width;
405 ULONG height;
406 ULONG interlace;
407 ULONG repaint0;
408 ULONG repaint1;
409 ULONG screen;
410 ULONG scale;
411 ULONG dither;
412 ULONG extra;
413 ULONG pixel;
414 ULONG horiz;
415 ULONG arbitration0;
416 ULONG arbitration1;
417 ULONG vpll;
418 ULONG vpll2;
419 ULONG vpllB;
420 ULONG vpll2B;
421 ULONG pllsel;
422 ULONG general;
423 ULONG crtcOwner;
424 ULONG head;
425 ULONG head2;
426 ULONG config;
427 ULONG cursorConfig;
428 ULONG cursor0;
429 ULONG cursor1;
430 ULONG cursor2;
431 ULONG offset;
432 ULONG pitch;
433 } RIVA_HW_STATE;
434 #endif
436 * FIFO Free Count. Should attempt to yield processor if RIVA is busy.
439 #define RIVA_FIFO_FREE(hwinst,hwptr,cnt) \
441 while ((hwinst).FifoFreeCount < (cnt)) { \
442 mem_barrier(); \
443 mem_barrier(); \
444 (hwinst).FifoFreeCount = (hwinst).hwptr->FifoFree >> 2; \
446 (hwinst).FifoFreeCount -= (cnt); \
448 #define RIVA_BUSY(hwinst) \
450 mem_barrier(); \
451 while ((hwinst).Busy(&(hwinst))); \
453 #endif /* __RIVA_HW_H__ */