1 | /* $Id: init.c,v 1.2 2001-09-05 14:31:00 bird Exp $ */
|
---|
2 | /*
|
---|
3 | ** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
|
---|
4 | ** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
|
---|
5 | ** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
|
---|
6 | ** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE
|
---|
7 | ** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com).
|
---|
8 | ** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
|
---|
9 | ** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
|
---|
10 | ** FULL TEXT OF THE NON-WARRANTY PROVISIONS.
|
---|
11 | **
|
---|
12 | ** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
|
---|
13 | ** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
|
---|
14 | ** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
|
---|
15 | ** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
|
---|
16 | ** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
|
---|
17 | ** THE UNITED STATES.
|
---|
18 | **
|
---|
19 | ** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
|
---|
20 | **
|
---|
21 | **
|
---|
22 | ** $Revision: 1.2 $
|
---|
23 | ** $Date: 2001-09-05 14:31:00 $
|
---|
24 | **
|
---|
25 | */
|
---|
26 |
|
---|
27 |
|
---|
28 | #include "init.h"
|
---|
29 | #include "fxinit.h"
|
---|
30 |
|
---|
31 | #include <stdio.h>
|
---|
32 | #include <stdlib.h>
|
---|
33 |
|
---|
34 | #if defined(__WATCOMC__)
|
---|
35 | #define _inp inp
|
---|
36 | #define _outp outp
|
---|
37 | #define _outpw outpw
|
---|
38 | #endif
|
---|
39 | #if defined(__linux__)
|
---|
40 |
|
---|
41 | #define _inp(port) pioInByte(port)
|
---|
42 | #define _outp(port, data) pioOutByte(port, data)
|
---|
43 | #define _outpw(port, data) pioOutWord(port, data);
|
---|
44 |
|
---|
45 | #endif
|
---|
46 |
|
---|
47 | #include "init96/init96.h"
|
---|
48 | #include <sst1init.h>
|
---|
49 |
|
---|
50 | #ifdef _WIN32
|
---|
51 | #define _WIN32_LEAN_AND_MEAN_
|
---|
52 | #include <windows.h>
|
---|
53 | #endif
|
---|
54 |
|
---|
55 | #include <fxpci.h>
|
---|
56 | #include <gdebug.h>
|
---|
57 |
|
---|
58 | extern PciRegister PCI_VENDOR_ID;
|
---|
59 | extern PciRegister PCI_DEVICE_ID;
|
---|
60 |
|
---|
61 |
|
---|
62 | /*-------------------------------------------------------------------
|
---|
63 | Module Constants
|
---|
64 | -------------------------------------------------------------------*/
|
---|
65 |
|
---|
66 |
|
---|
67 | static InitContext
|
---|
68 | contexts[NUM_3DFX_PRODUCTS]; /* pool of device contexts */
|
---|
69 | InitContext
|
---|
70 | *context; /* Current device context */
|
---|
71 | static InitDeviceInfo
|
---|
72 | hwInfo[INIT_MAX_DEVICES]; /* Info for all supported devices */
|
---|
73 | static FxU32
|
---|
74 | numDevicesInSystem, /* Number of supported devices. */
|
---|
75 | numSst1s; /* # SST1s in system */
|
---|
76 | static FxBool
|
---|
77 | libInitialized; /* Well, has it been? */
|
---|
78 |
|
---|
79 | /*-------------------------------------------------------------------
|
---|
80 | Function: initEnumHardware
|
---|
81 | Date: 10/9
|
---|
82 | Implementor(s): jdt
|
---|
83 | Library: init
|
---|
84 | Description:
|
---|
85 | Calls a user supplied function on an initialized InitDeviceInfo
|
---|
86 | structure for each device in the system. Calls a user supplied
|
---|
87 | callback repeatedly for each device in the system. The callback
|
---|
88 | can stop the enumeration cycle by return a value of FXTRUE.
|
---|
89 | Arguments:
|
---|
90 | cb - callback function of type INitHWEnumCallback which is called on
|
---|
91 | an initialzied InitDeviceInfo structure
|
---|
92 | Return:
|
---|
93 | none
|
---|
94 | -------------------------------------------------------------------*/
|
---|
95 | void
|
---|
96 | initEnumHardware( InitHWEnumCallback *cb )
|
---|
97 | {
|
---|
98 | FxU32 busLocation;
|
---|
99 | FxU32 device;
|
---|
100 | if ( !libInitialized ) {
|
---|
101 |
|
---|
102 | /* When initializing the Library snoop out all 3Dfx devices
|
---|
103 | and fill a static data structure with pertinant data. */
|
---|
104 |
|
---|
105 | numDevicesInSystem = 0;
|
---|
106 | numSst1s = 0;
|
---|
107 | if ( !pciOpen() ) return;
|
---|
108 | for( busLocation = 0; busLocation < MAX_PCI_DEVICES; busLocation++ ) {
|
---|
109 | if ( pciDeviceExists( busLocation ) ) {
|
---|
110 | FxU32 vId, dId;
|
---|
111 | pciGetConfigData( PCI_VENDOR_ID, busLocation, &vId );
|
---|
112 | pciGetConfigData( PCI_DEVICE_ID, busLocation, &dId );
|
---|
113 |
|
---|
114 | GDBG_INFO((80, "initEnumHardware: Vendor: 0x%x Device: 0x%x\n", vId, dId));
|
---|
115 |
|
---|
116 | #if defined( SST1 )
|
---|
117 | if ( (vId == TDFXVID) &&
|
---|
118 | (dId == SST1DID) ) { /* Detect SST1 */
|
---|
119 | FxU32 *base;
|
---|
120 | sst1DeviceInfoStruct info;
|
---|
121 |
|
---|
122 | /* Scanline interleave must be two boards back to back
|
---|
123 | if there is a second board in the system,
|
---|
124 | and the previous board was SLI, then this is the slave */
|
---|
125 | if ( numDevicesInSystem > 0 ) {
|
---|
126 | if ( hwInfo[numDevicesInSystem-1].hwClass==INIT_VOODOO &&
|
---|
127 | hwInfo[numDevicesInSystem-1].hwDep.vgInfo.sliDetect ) {
|
---|
128 |
|
---|
129 | hwInfo[numDevicesInSystem-1].hwDep.vgInfo.slaveBaseAddr =
|
---|
130 | (FxU32)sst1InitMapBoard( numSst1s );
|
---|
131 | hwInfo[numDevicesInSystem-1].regs.hwDep.VGRegDesc.slavePtr =
|
---|
132 | (FxU32*)hwInfo[numDevicesInSystem-1].hwDep.vgInfo.slaveBaseAddr;
|
---|
133 | numSst1s++;
|
---|
134 | continue;
|
---|
135 |
|
---|
136 | }
|
---|
137 | }
|
---|
138 |
|
---|
139 | hwInfo[numDevicesInSystem].vendorID = (FxU16) vId;
|
---|
140 | hwInfo[numDevicesInSystem].deviceID = (FxU16) dId;
|
---|
141 | hwInfo[numDevicesInSystem].devNumber = numDevicesInSystem;
|
---|
142 | hwInfo[numDevicesInSystem].hwClass = INIT_VOODOO;
|
---|
143 |
|
---|
144 | /* On SST-1 We Have to Initialize the Registers
|
---|
145 | to Discover the configuration of the board */
|
---|
146 | #if 0
|
---|
147 | base = sst1InitMapBoard( numSst1s );
|
---|
148 | sst1InitRegisters( base );
|
---|
149 | #else
|
---|
150 | base = (FxU32*)initMapBoard(numSst1s);
|
---|
151 | #endif
|
---|
152 | sst1InitGetDeviceInfo( base, &info );
|
---|
153 |
|
---|
154 | hwInfo[numDevicesInSystem].hwDep.vgInfo.vgBaseAddr = (FxU32) base;
|
---|
155 | hwInfo[numDevicesInSystem].hwDep.vgInfo.pfxRev = info.fbiRevision;
|
---|
156 | hwInfo[numDevicesInSystem].hwDep.vgInfo.pfxRam = info.fbiMemSize;
|
---|
157 | hwInfo[numDevicesInSystem].hwDep.vgInfo.nTFX = info.numberTmus;
|
---|
158 | hwInfo[numDevicesInSystem].hwDep.vgInfo.tfxRev = info.tmuRevision;
|
---|
159 | hwInfo[numDevicesInSystem].hwDep.vgInfo.tfxRam = info.tmuMemSize[0];
|
---|
160 | hwInfo[numDevicesInSystem].hwDep.vgInfo.sliDetect = info.sstSliDetect;
|
---|
161 | hwInfo[numDevicesInSystem].hwDep.vgInfo.slaveBaseAddr = 0;
|
---|
162 | hwInfo[numDevicesInSystem].regs.hwDep.VGRegDesc.baseAddress = base;
|
---|
163 | hwInfo[numDevicesInSystem].regs.hwDep.VGRegDesc.slavePtr = 0;
|
---|
164 |
|
---|
165 | numSst1s++;
|
---|
166 | numDevicesInSystem++;
|
---|
167 | }
|
---|
168 | #elif defined(SST96)
|
---|
169 | #define IS_CHIP(name) (vId == name##VID && dId == name##DID)
|
---|
170 |
|
---|
171 | if (IS_CHIP(AT3D) ||
|
---|
172 | IS_CHIP(MCRX)) {
|
---|
173 |
|
---|
174 | if (IS_CHIP(MCRX)) {
|
---|
175 | /* In the case of Macronix, look for 3d4/3f[2] == 1, as
|
---|
176 | they set that bit when we're attached. */
|
---|
177 | FxU8 regVal;
|
---|
178 | _outp(0x3d4, 0x3f);
|
---|
179 | regVal = _inp(0x3d5);
|
---|
180 |
|
---|
181 | if (!(regVal & (1 << 2))) /* we're not there */
|
---|
182 | continue;
|
---|
183 | }
|
---|
184 |
|
---|
185 | hwInfo[numDevicesInSystem].vendorID = (FxU16) vId;
|
---|
186 | hwInfo[numDevicesInSystem].deviceID = (FxU16) dId;
|
---|
187 | hwInfo[numDevicesInSystem].devNumber = numDevicesInSystem;
|
---|
188 | hwInfo[numDevicesInSystem].hwClass = INIT_VG96;
|
---|
189 |
|
---|
190 | /* SST-96 initialization also retrieves board configuration info */
|
---|
191 | #if 0
|
---|
192 | init96MapBoard(&hwInfo[numDevicesInSystem].regs,
|
---|
193 | &hwInfo[numDevicesInSystem].hwDep.vg96Info,
|
---|
194 | (FxU16) vId, (FxU16) dId);
|
---|
195 | #else
|
---|
196 | initMapBoard(numDevicesInSystem);
|
---|
197 | #endif
|
---|
198 |
|
---|
199 | hwInfo[numDevicesInSystem].hwDep.vg96Info.vgaBaseAddr =
|
---|
200 | (FxU32)hwInfo[numDevicesInSystem].regs.hwDep.VG96RegDesc.partnerRegPtr;
|
---|
201 | hwInfo[numDevicesInSystem].hwDep.vg96Info.vg96BaseAddr =
|
---|
202 | (FxU32)hwInfo[numDevicesInSystem].regs.hwDep.VG96RegDesc.baseAddress;
|
---|
203 |
|
---|
204 | numDevicesInSystem++;
|
---|
205 | }
|
---|
206 | #else
|
---|
207 | # error "Do hardware enumeration for this chip!"
|
---|
208 | #endif
|
---|
209 | }
|
---|
210 | }
|
---|
211 |
|
---|
212 |
|
---|
213 | /* Sanity Check for SLI detection */
|
---|
214 | for( device = 0; device < numDevicesInSystem; device++ ) {
|
---|
215 | if ( hwInfo[device].hwClass == INIT_VOODOO &&
|
---|
216 | hwInfo[device].hwDep.vgInfo.sliDetect &&
|
---|
217 | hwInfo[device].hwDep.vgInfo.slaveBaseAddr == 0 ) {
|
---|
218 | hwInfo[device].hwDep.vgInfo.sliDetect = FXFALSE;
|
---|
219 | }
|
---|
220 | }
|
---|
221 |
|
---|
222 | /* Initialize all drivers */
|
---|
223 | vgDriverInit( &contexts[INIT_VOODOO] );
|
---|
224 | vg96DriverInit( &contexts[INIT_VG96] );
|
---|
225 | h3DriverInit( &contexts[INIT_H3] );
|
---|
226 |
|
---|
227 |
|
---|
228 | /* Mark the library as initialized */
|
---|
229 | libInitialized = FXTRUE;
|
---|
230 | }
|
---|
231 |
|
---|
232 | if ( cb ) {
|
---|
233 | for( device = 0; device < numDevicesInSystem; device++ ) {
|
---|
234 | cb( &hwInfo[device] );
|
---|
235 | }
|
---|
236 | }
|
---|
237 | return;
|
---|
238 | } /* initEnumHardware */
|
---|
239 |
|
---|
240 | volatile FxU32*
|
---|
241 | initMapBoard(const FxU32 boardNum)
|
---|
242 | {
|
---|
243 | volatile FxU32* retVal = NULL;
|
---|
244 | FxBool okP = (boardNum < INIT_MAX_DEVICES);
|
---|
245 |
|
---|
246 | if (okP) {
|
---|
247 | InitDeviceInfo* infoP = (hwInfo + boardNum);
|
---|
248 | const FxU32 vId = infoP->vendorID;
|
---|
249 | const FxU32 dId = infoP->deviceID;
|
---|
250 |
|
---|
251 | #if defined(SST1)
|
---|
252 | okP = ((vId == TDFXVID) &&
|
---|
253 | (dId == SST1DID));
|
---|
254 |
|
---|
255 | if (okP) {
|
---|
256 | retVal = sst1InitMapBoard(boardNum);
|
---|
257 | sst1InitRegisters((FxU32*)retVal);
|
---|
258 | }
|
---|
259 | #elif defined(SST96)
|
---|
260 | okP = (IS_CHIP(AT3D) ||
|
---|
261 | IS_CHIP(MCRX));
|
---|
262 |
|
---|
263 | if (okP) {
|
---|
264 | init96MapBoard(&infoP->regs, &infoP->hwDep.vg96Info,
|
---|
265 | (FxU16)vId, (FxU16)dId);
|
---|
266 | retVal = infoP->regs.hwDep.VG96RegDesc.baseAddress;
|
---|
267 | }
|
---|
268 | #else
|
---|
269 | #error "Need to define initMapBoard for this chip!"
|
---|
270 | #endif /* HW Check */
|
---|
271 | }
|
---|
272 |
|
---|
273 | return retVal;
|
---|
274 | }
|
---|
275 |
|
---|
276 |
|
---|
277 | /*-------------------------------------------------------------------
|
---|
278 | Function: initClose
|
---|
279 | Date: 10/17
|
---|
280 | Implementor(s): jdt
|
---|
281 | Library: init
|
---|
282 | Description:
|
---|
283 | Unmap all hardware and set library to unitialized state
|
---|
284 | Arguments:
|
---|
285 | none
|
---|
286 | Return:
|
---|
287 | none
|
---|
288 | -------------------------------------------------------------------*/
|
---|
289 | void initClose( void ) {
|
---|
290 | if ( libInitialized ) {
|
---|
291 | unsigned i;
|
---|
292 | for ( i = 0; i < numDevicesInSystem; i++ ) {
|
---|
293 | /* Insert unmap code here */ /* FIXME!!!! */
|
---|
294 | }
|
---|
295 | pciClose();
|
---|
296 | libInitialized = FXFALSE;
|
---|
297 | }
|
---|
298 | } /* initClose */
|
---|
299 |
|
---|
300 | /*-------------------------------------------------------------------
|
---|
301 | Function: initGetDeviceInfo
|
---|
302 | Date: 10/9
|
---|
303 | Implementor(s): jdt
|
---|
304 | Library: init
|
---|
305 | Description:
|
---|
306 | Fills a user supplied area of memory with information describing
|
---|
307 | the a 3Dfx device. The device is identified on the bus by the unique
|
---|
308 | devNumber assigned by the library and revealed to the user through
|
---|
309 | initEnumHardware.
|
---|
310 | Arguments:
|
---|
311 | devNumber - number identifying device in system
|
---|
312 | info - pointer to user memory to be filled with dev info
|
---|
313 | Return:
|
---|
314 | FXTRUE - succeed
|
---|
315 | FXFALSE - one or both parameters invalid
|
---|
316 | -------------------------------------------------------------------*/
|
---|
317 | FxBool
|
---|
318 | initGetDeviceInfo( FxU32 devNumber, InitDeviceInfo *info )
|
---|
319 | {
|
---|
320 | FxBool rv;
|
---|
321 |
|
---|
322 | if ( devNumber < numDevicesInSystem ) {
|
---|
323 | *info = hwInfo[devNumber];
|
---|
324 | rv = FXTRUE;
|
---|
325 | } else {
|
---|
326 | rv = FXFALSE;
|
---|
327 | }
|
---|
328 | return rv;
|
---|
329 | } /* initGetDeviceInfo */
|
---|
330 |
|
---|
331 |
|
---|
332 | /*-------------------------------------------------------------------
|
---|
333 | Function: initDeviceSelect
|
---|
334 | Date: 10/9
|
---|
335 | Implementor(s): jdt
|
---|
336 | Library: init
|
---|
337 | Description:
|
---|
338 | Selects a 3Dfx device ( potentially from among many in the system ) and
|
---|
339 | initializes the internal init driver functions with behavior appropriate
|
---|
340 | to the type of the selected device.
|
---|
341 | Arguments:
|
---|
342 | devNumber - unique number assigned to each device by initEnumHardware
|
---|
343 | Return:
|
---|
344 | FXTRUE - success
|
---|
345 | FXFALSE - invalide device number
|
---|
346 | -------------------------------------------------------------------*/
|
---|
347 |
|
---|
348 | FxBool
|
---|
349 | initDeviceSelect( FxU32 devNumber )
|
---|
350 | {
|
---|
351 | FxBool rv = FXFALSE;
|
---|
352 |
|
---|
353 | if ( devNumber < numDevicesInSystem ) {
|
---|
354 | context = &contexts[hwInfo[devNumber].hwClass];
|
---|
355 | context->info = hwInfo[devNumber];
|
---|
356 | rv = FXTRUE;
|
---|
357 | }
|
---|
358 |
|
---|
359 | return rv;
|
---|
360 |
|
---|
361 | }/* initDeviceSelect */
|
---|
362 |
|
---|
363 | /*-------------------------------------------------------------------
|
---|
364 | Function: initSetWriteMethod
|
---|
365 | Date: 10/17
|
---|
366 | Implementor(s): jdt
|
---|
367 | Library: init
|
---|
368 | Description:
|
---|
369 | Sets up a register write method that respects the fifo conventions
|
---|
370 | of the hardware.
|
---|
371 | Arguments:
|
---|
372 | wcb - callback to be used to do direct writes from init code
|
---|
373 | Return:
|
---|
374 | none
|
---|
375 | -------------------------------------------------------------------*/
|
---|
376 | void initSetWriteMethod( InitWriteCallback *wcb ) {
|
---|
377 | if ( context )
|
---|
378 | context->writeMethod = wcb;
|
---|
379 | return;
|
---|
380 | } /* initSetWriteMethod */
|
---|
381 |
|
---|
382 |
|
---|
383 |
|
---|
384 | /*-------------------------------------------------------------------
|
---|
385 | Function: initSetVideo
|
---|
386 | Date: 10/9
|
---|
387 | Implementor(s): jdt, murali
|
---|
388 | Library: init
|
---|
389 | Description:
|
---|
390 | This will initialize the video, and allocate color and aux buffers
|
---|
391 | prior to rendering.
|
---|
392 | Arguments:
|
---|
393 | hwnd - pointer to a window handle or null. If NULL, then
|
---|
394 | the application window handle will be inferred though
|
---|
395 | the GetActiveWindow() api.
|
---|
396 | resolution - either one of the pre-defined glide resolutions,
|
---|
397 | or GR_RESOLUTION_NONE, in which case the window
|
---|
398 | size is inferred from the size application window
|
---|
399 | refresh - requested fullscreen refresh rate, ignored in a window
|
---|
400 | format - requested ccolor format for glide packed color values
|
---|
401 | origin - location of coordinate origin either upper left or
|
---|
402 | lower right
|
---|
403 | nColBuffers - number of color buffers to attempt to allocate
|
---|
404 | 0 - meaningless
|
---|
405 | 1 - allocate a front buffer only
|
---|
406 | 2 - allocate a front and back buffer
|
---|
407 | 3 - allocate a front, back, aux buffer for tripple buffering
|
---|
408 | nAuxBuffers - number of aux buffers to attempt to allocate
|
---|
409 | 0 - no alpha or z buffers
|
---|
410 | 1 - allocate one aux buffer for alpha/depth buffering
|
---|
411 | 2 - allocate on depth and one alpha buffer ( unsup )
|
---|
412 | xres - x resolution return val ( for user windows )
|
---|
413 | yres - y resolution return val ( for user windows )
|
---|
414 | fbStride - stride in pixels of frame buffer
|
---|
415 | Return:
|
---|
416 | FXTRUE - all resources requested where allocated
|
---|
417 | FXFALSE - some or all resources were not available. By comparing
|
---|
418 | desc before and after call, the user can determine which
|
---|
419 | resources were denied.
|
---|
420 | -------------------------------------------------------------------*/
|
---|
421 | FxBool initSetVideo( FxU32 hWnd,
|
---|
422 | GrScreenResolution_t sRes,
|
---|
423 | GrScreenRefresh_t vRefresh,
|
---|
424 | InitColorFormat_t cFormat,
|
---|
425 | InitOriginLocation_t yOrigin,
|
---|
426 | int nColBuffers,
|
---|
427 | int nAuxBuffers,
|
---|
428 | int *xres,
|
---|
429 | int *yres,
|
---|
430 | int *fbStride,
|
---|
431 | sst1VideoTimingStruct *vidTimings) {
|
---|
432 | FxBool rv;
|
---|
433 | if ( context ) {
|
---|
434 | rv = context->setVideo( hWnd, sRes, vRefresh, cFormat,
|
---|
435 | yOrigin, nColBuffers, nAuxBuffers,
|
---|
436 | xres, yres, fbStride, vidTimings);
|
---|
437 | } else {
|
---|
438 | rv = FXFALSE;
|
---|
439 | }
|
---|
440 | return rv;
|
---|
441 | } /* initSetVideo */
|
---|
442 |
|
---|
443 |
|
---|
444 | /*-------------------------------------------------------------------
|
---|
445 | Function: initRestoreVideo
|
---|
446 | Date: 10/16
|
---|
447 | Implementor(s): jdt
|
---|
448 | Library: init
|
---|
449 | Description:
|
---|
450 | Restore video to its state prior to initSetVideo
|
---|
451 | Arguments:
|
---|
452 | none
|
---|
453 | Return:
|
---|
454 | none
|
---|
455 | -------------------------------------------------------------------*/
|
---|
456 | void initRestoreVideo( void ) {
|
---|
457 | if ( context )
|
---|
458 | context->restoreVideo();
|
---|
459 | } /* initRestoreVideo */
|
---|
460 |
|
---|
461 | /*-------------------------------------------------------------------
|
---|
462 | Function: initEnableTransport
|
---|
463 | Date: 10/17
|
---|
464 | Implementor(s): jdt
|
---|
465 | Library: init
|
---|
466 | Description:
|
---|
467 | Enable the command transport mechanism for the underlying
|
---|
468 | hardware and return information about accessing the transport
|
---|
469 | to the caller
|
---|
470 | Arguments:
|
---|
471 | info - data structure describing state of transport
|
---|
472 | Return:
|
---|
473 | FXTRUE - successfully enabled the command transport
|
---|
474 | FXFALSE - failed ot enable the command transport
|
---|
475 | -------------------------------------------------------------------*/
|
---|
476 | FxBool initEnableTransport( InitFIFOData *info ) {
|
---|
477 | FxBool rv;
|
---|
478 | if ( context ) {
|
---|
479 | rv = context->enableTransport( info );
|
---|
480 | } else {
|
---|
481 | rv = FXFALSE;
|
---|
482 | }
|
---|
483 | return rv;
|
---|
484 | } /* initEnableTransport */
|
---|
485 |
|
---|
486 | /*-------------------------------------------------------------------
|
---|
487 | Function: initDisableTransport
|
---|
488 | Date: 10/17
|
---|
489 | Implementor(s): jdt
|
---|
490 | Library: init
|
---|
491 | Description:
|
---|
492 | Return transport control to reset state
|
---|
493 | Arguments:
|
---|
494 | none
|
---|
495 | Return:
|
---|
496 | none
|
---|
497 | -------------------------------------------------------------------*/
|
---|
498 | void initDisableTransport( void ) {
|
---|
499 | if ( context )
|
---|
500 | context->disableTransport();
|
---|
501 | } /* initDisableTransport */
|
---|
502 |
|
---|
503 | /*-------------------------------------------------------------------
|
---|
504 | Function: initSwapBuffers
|
---|
505 | Date: 10/9
|
---|
506 | Implementor(s): jdt, murali
|
---|
507 | Library: init
|
---|
508 | Description:
|
---|
509 | Initiate a buffer swap.
|
---|
510 | Arguments:
|
---|
511 | code - code describing type of swap, wether to sync to vretrace, how
|
---|
512 | many vretraces to wait, etc.
|
---|
513 | -------------------------------------------------------------------*/
|
---|
514 | void initSwapBuffers( FxU32 code ) {
|
---|
515 | if ( context )
|
---|
516 | context->swapBuffers( code );
|
---|
517 | } /* initSwapBuffers */
|
---|
518 |
|
---|
519 | /*-------------------------------------------------------------------
|
---|
520 | Function: initStatus
|
---|
521 | Date: 10/9
|
---|
522 | Implementor(s): jdt
|
---|
523 | Library: init
|
---|
524 | Description:
|
---|
525 | Returns the status word from the hardware
|
---|
526 | Arguments:
|
---|
527 | none
|
---|
528 | Return:
|
---|
529 | 32-bit status word ( chip specific )
|
---|
530 | -------------------------------------------------------------------*/
|
---|
531 | FxU32 initStatus( void ) {
|
---|
532 | FxU32 rv;
|
---|
533 | if ( context ) {
|
---|
534 | rv = context->status();
|
---|
535 | } else {
|
---|
536 | rv = 0;
|
---|
537 | }
|
---|
538 | return rv;
|
---|
539 | } /* initStatus */
|
---|
540 |
|
---|
541 | /*-------------------------------------------------------------------
|
---|
542 | Function: initBusy
|
---|
543 | Date: 10/9
|
---|
544 | Implementor(s): jdt
|
---|
545 | Library: init
|
---|
546 | Description:
|
---|
547 | return true if hardware is busy rendering
|
---|
548 | Arguments:
|
---|
549 | none
|
---|
550 | Return:
|
---|
551 | FXTRUE - if busy
|
---|
552 | FXFALSE - if idle
|
---|
553 | -------------------------------------------------------------------*/
|
---|
554 | FxBool initBusy( void ) {
|
---|
555 | FxBool rv;
|
---|
556 | if ( context ) {
|
---|
557 | rv = context->busy();
|
---|
558 | } else {
|
---|
559 | rv = FXTRUE;
|
---|
560 | }
|
---|
561 | return rv;
|
---|
562 | } /* initBusy */
|
---|
563 |
|
---|
564 | /*-------------------------------------------------------------------
|
---|
565 | Function: initIdle
|
---|
566 | Date: 10/9
|
---|
567 | Implementor(s): jdt
|
---|
568 | Library: init
|
---|
569 | Description:
|
---|
570 | Returns only when graphics pipeline is completely idle.
|
---|
571 | May hang software if hardware is permanently busy.
|
---|
572 | Arguments:
|
---|
573 | none
|
---|
574 | Return:
|
---|
575 | none
|
---|
576 | -------------------------------------------------------------------*/
|
---|
577 | void initIdle( void ) {
|
---|
578 | if ( context )
|
---|
579 | context->idle();
|
---|
580 | } /* initIdle */
|
---|
581 |
|
---|
582 | /*-------------------------------------------------------------------
|
---|
583 | Function: initGetBufferPtr
|
---|
584 | Date: 2/25
|
---|
585 | Implementor(s): jdt
|
---|
586 | Library: Init
|
---|
587 | Description:
|
---|
588 | Get the current pointer to a particular buffer
|
---|
589 | Arguments:
|
---|
590 | buffer - which buffer to get pointer to
|
---|
591 | Return:
|
---|
592 | integer pointer
|
---|
593 | -------------------------------------------------------------------*/
|
---|
594 | void *initGetBufferPtr( InitBuffer_t buffer, int *strideBytes ) {
|
---|
595 | if ( context )
|
---|
596 | return context->getBufferPtr( buffer, strideBytes );
|
---|
597 | else
|
---|
598 | return 0;
|
---|
599 | } /* initGetBufferPtr */
|
---|
600 |
|
---|
601 | /*-------------------------------------------------------------------
|
---|
602 | Function: initRenderBuffer
|
---|
603 | Date: 2/25
|
---|
604 | Implementor(s): jdt
|
---|
605 | Library: init
|
---|
606 | Description:
|
---|
607 | Sets the current render buffer
|
---|
608 | Arguments:
|
---|
609 | buffer - which buffer to render to ( front or back )
|
---|
610 | Return:
|
---|
611 | none
|
---|
612 | -------------------------------------------------------------------*/
|
---|
613 | void initRenderBuffer( InitBuffer_t buffer ) {
|
---|
614 | if ( context ) context->renderBuffer( buffer );
|
---|
615 | return;
|
---|
616 | } /* initRenderBuffer */
|
---|
617 |
|
---|
618 | /*-------------------------------------------------------------------
|
---|
619 | Function: initOrigin
|
---|
620 | Date: 2/25
|
---|
621 | Implementor(s): jdt
|
---|
622 | Library: init
|
---|
623 | Description:
|
---|
624 | Set the yorigin
|
---|
625 | Arguments:
|
---|
626 | origin - origin designation
|
---|
627 | Return:
|
---|
628 | none
|
---|
629 | -------------------------------------------------------------------*/
|
---|
630 | void initOrigin( InitOriginLocation_t origin ) {
|
---|
631 | if ( context ) context->origin( origin );
|
---|
632 | return;
|
---|
633 | } /* initOrigin */
|
---|
634 |
|
---|
635 | /*-------------------------------------------------------------------
|
---|
636 | Function:initIOCtl
|
---|
637 | Date: 10/9
|
---|
638 | Implementor(s): jdt
|
---|
639 | Library: init
|
---|
640 | Description:
|
---|
641 | CYA function so that emergency functionality may be added w/o
|
---|
642 | corrupting dll interface
|
---|
643 | Arguments:
|
---|
644 | token - describes IOCTL function
|
---|
645 | argument - pointer to arguments
|
---|
646 | Return:
|
---|
647 | none
|
---|
648 | -------------------------------------------------------------------*/
|
---|
649 | void initIOCtl( FxU32 token, void *argument ) {
|
---|
650 | if ( context )
|
---|
651 | context->ioCtl( token, argument );
|
---|
652 | } /* initIOCtl */
|
---|
653 |
|
---|
654 | /*-------------------------------------------------------------------
|
---|
655 | Function: initControl
|
---|
656 | Date: 10/9
|
---|
657 | Implementor(s): murali
|
---|
658 | Library: init
|
---|
659 | Description:
|
---|
660 | This will re-attach new buffers for the rendering context, used
|
---|
661 | typically only in a windowing system where buffers need to move
|
---|
662 | and resize. Also, implicitly detach old associated buffers.
|
---|
663 | Arguments:
|
---|
664 | XXX
|
---|
665 | Return:
|
---|
666 | FXTRUE - all resources requested where allocated
|
---|
667 | FXFALSE - some or all resources were not available. By comparing
|
---|
668 | desc before and after call, the user can determine which
|
---|
669 | resources were denied.
|
---|
670 | -------------------------------------------------------------------*/
|
---|
671 | FxBool initControl( FxU32 code)
|
---|
672 | {
|
---|
673 |
|
---|
674 | FxBool rv;
|
---|
675 |
|
---|
676 | GDBG_INFO((80, "initControl: code = %d, context=%.08x\n", code, context));
|
---|
677 | if ( context ) {
|
---|
678 | rv = context->control( code );
|
---|
679 | } else {
|
---|
680 | rv = FXFALSE;
|
---|
681 | }
|
---|
682 | return rv;
|
---|
683 | } /* initControl */
|
---|
684 |
|
---|
685 | /*-------------------------------------------------------------------
|
---|
686 | Function: initWrapFIFO
|
---|
687 | Date: 13-Feb-97
|
---|
688 | Implementor(s): dow
|
---|
689 | Library: init
|
---|
690 | Description:
|
---|
691 | Reset the command transport when the fifo is full
|
---|
692 | Arguments:
|
---|
693 | pointer to fifo data
|
---|
694 | Return:
|
---|
695 | none
|
---|
696 | -------------------------------------------------------------------*/
|
---|
697 | FxBool initWrapFIFO(InitFIFOData *fifoData) {
|
---|
698 | if ( context )
|
---|
699 | return context->wrapFIFO(fifoData);
|
---|
700 | else
|
---|
701 | return FXFALSE;
|
---|
702 | } /* initWrapFIFO */
|
---|
703 |
|
---|
704 | /*-------------------------------------------------------------------
|
---|
705 | Function: initGamma
|
---|
706 | Date: 10/9
|
---|
707 | Implementor(s): jdt
|
---|
708 | Library: init
|
---|
709 | Description:
|
---|
710 | SST-1 holdover function which initializes the gamma table in some
|
---|
711 | video hardware to normalize monitor brightness
|
---|
712 | Arguments:
|
---|
713 | gamma - floating point gamma correction factor
|
---|
714 | Return:
|
---|
715 | none
|
---|
716 | -------------------------------------------------------------------*/
|
---|
717 | void initGamma( double gamma ) {
|
---|
718 | if ( context )
|
---|
719 | context->gamma( gamma );
|
---|
720 | } /* initGamma */
|
---|
721 |
|
---|
722 | /*-------------------------------------------------------------------
|
---|
723 | Function: initSliPciOwner
|
---|
724 | Date: 10/9
|
---|
725 | Implementor(s): jdt
|
---|
726 | Library: init
|
---|
727 | Description:
|
---|
728 | Do some voodoo(tm) to change the owner of the PCI bus in an SLI
|
---|
729 | configuration
|
---|
730 | Arguments:
|
---|
731 | regbase - ask scott sellers
|
---|
732 | owner - ask scott sellers
|
---|
733 | Return:
|
---|
734 | none
|
---|
735 | -------------------------------------------------------------------*/
|
---|
736 | void initSliPciOwner( FxU32 *regbase, FxU32 owner ) {
|
---|
737 | if ( context )
|
---|
738 | context->sliPciOwner( regbase, owner );
|
---|
739 | } /* initSliPciOwner */
|
---|
740 |
|
---|
741 |
|
---|
742 | /*-------------------------------------------------------------------
|
---|
743 | Function: initNumBoardsInSystem
|
---|
744 | Date: 19970813
|
---|
745 | Implementor(s): pgj
|
---|
746 | Library: init
|
---|
747 | Description:
|
---|
748 | Computes the number of boards compatible with the hardware the init
|
---|
749 | library is compiled for, i.e. this will count either the number
|
---|
750 | of VG xor Rush cards present.
|
---|
751 | Return:
|
---|
752 | number of boards found
|
---|
753 | -------------------------------------------------------------------*/
|
---|
754 | FxU32 initNumBoardsInSystem(void)
|
---|
755 | {
|
---|
756 | FxU32 numBoards, j, n;
|
---|
757 |
|
---|
758 | if(getenv(("SST_BOARDS"))) {
|
---|
759 | numBoards = atoi(getenv(("SST_BOARDS")));
|
---|
760 | } else {
|
---|
761 | numBoards = 0;
|
---|
762 | #if defined(SST1)
|
---|
763 | for(j=0; j<INIT_MAX_DEVICES; j++) {
|
---|
764 | if(pciFindCardMulti(TDFXVID, SST1DID, &n, j)) numBoards++;
|
---|
765 | }
|
---|
766 | #elif defined(SST96)
|
---|
767 | for(j=0; j<INIT_MAX_DEVICES; j++) {
|
---|
768 | if(pciFindCardMulti(AT3DVID, AT3DDID, &n, j)) numBoards++;
|
---|
769 | if(pciFindCardMulti(MCRXVID, MCRXDID, &n, j)) numBoards++;
|
---|
770 | }
|
---|
771 | #else
|
---|
772 | # error "initNumBoardsInSystem: unknown device!!!"
|
---|
773 | #endif
|
---|
774 | }
|
---|
775 | return(numBoards);
|
---|
776 | } /* end initNumBoardsInSystem() */
|
---|
777 |
|
---|
778 | /*-------------------------------------------------------------------
|
---|
779 | Function: initGammaRGB
|
---|
780 | Date: Mar-2-98
|
---|
781 | Implementor(s): atai
|
---|
782 | Library: init
|
---|
783 | Description:
|
---|
784 | initialize Gamma table givin RGB value
|
---|
785 | Arguments:
|
---|
786 | Return:
|
---|
787 | none
|
---|
788 | -------------------------------------------------------------------*/
|
---|
789 | FxBool initGammaRGB( double r, double g, double b ) {
|
---|
790 | if ( context )
|
---|
791 | return context->gammaRGB( r, g, b );
|
---|
792 | return FXFALSE;
|
---|
793 | } /* initGammaRGB */
|
---|
794 |
|
---|
795 | /*-------------------------------------------------------------------
|
---|
796 | Function: initGammaTable
|
---|
797 | Date: Mar-2-98
|
---|
798 | Implementor(s): atai
|
---|
799 | Library: init
|
---|
800 | Description:
|
---|
801 | initialize Gamma table givin RGB table
|
---|
802 | Arguments:
|
---|
803 | Return:
|
---|
804 | none
|
---|
805 | -------------------------------------------------------------------*/
|
---|
806 | FxBool initGammaTable(FxU32 nentries, FxU32 *r, FxU32 *g, FxU32 *b) {
|
---|
807 | if ( context )
|
---|
808 | return context->initGammaTable( nentries, r, g, b );
|
---|
809 | return FXFALSE;
|
---|
810 | } /* initGammaTable */
|
---|
811 |
|
---|
812 | /*-------------------------------------------------------------------
|
---|
813 | Function: initFindVideoTimingStruct
|
---|
814 | Date: Mar-2-98
|
---|
815 | Implementor(s): atai
|
---|
816 | Library: init
|
---|
817 | Description:
|
---|
818 | find video timing structure
|
---|
819 | Arguments:
|
---|
820 | Return:
|
---|
821 | none
|
---|
822 | -------------------------------------------------------------------*/
|
---|
823 | sst1VideoTimingStruct *initFindVideoTimingStruct(GrScreenResolution_t sRes, GrScreenRefresh_t vRefresh) {
|
---|
824 | if ( context )
|
---|
825 | return context->findVidTimingStruct( sRes, vRefresh );
|
---|
826 | return NULL;
|
---|
827 | } /* initGamma */
|
---|
828 |
|
---|