status_t CloneAccelerant(void* data) { // Initialize a copy of the accelerant as a clone. Argument data points to // a copy of the data which was returned by GetAccelerantCloneInfo(). TRACE("Enter CloneAccelerant()\n"); char path[MAXPATHLEN] = "/dev/"; strcat(path, (const char*)data); gInfo.deviceFileDesc = open(path, B_READ_WRITE); // open the device if (gInfo.deviceFileDesc < 0) return errno; gInfo.bAccelerantIsClone = true; status_t result = InitCommon(gInfo.deviceFileDesc); if (result != B_OK) { close(gInfo.deviceFileDesc); return result; } result = gInfo.modeListArea = clone_area("ATI cloned display_modes", (void**) &gInfo.modeList, B_ANY_ADDRESS, B_READ_AREA, gInfo.sharedInfo->modeArea); if (result < 0) { UninitCommon(); close(gInfo.deviceFileDesc); return result; } TRACE("Leave CloneAccelerant()\n"); return B_OK; }
void UninitAccelerant(void) { delete_area(gInfo.modeListArea); gInfo.modeList = NULL; UninitCommon(); if (gInfo.bAccelerantIsClone) close(gInfo.deviceFileDesc); }
status_t InitAccelerant(int fileDesc) { // Initialize the accelerant. fileDesc is the file handle of the device // (in /dev/graphics) that has been opened by the app_server. TRACE("Enter InitAccelerant()\n"); gInfo.bAccelerantIsClone = false; // indicate this is primary accelerant status_t result = InitCommon(fileDesc); if (result == B_OK) { SharedInfo& si = *gInfo.sharedInfo; TRACE("Vendor ID: 0x%X, Device ID: 0x%X\n", si.vendorID, si.deviceID); // Ensure that InitAccelerant is executed just once (copies should be clones) if (si.bAccelerantInUse) { result = B_NOT_ALLOWED; } else { result = TDFX_Init(); // perform init related to current chip if (result == B_OK) { result = si.engineLock.Init("3DFX engine lock"); if (result == B_OK) result = si.overlayLock.Init("3DFX overlay lock"); if (result == B_OK) { TDFX_ShowCursor(false); // ensure that this function won't be executed again // (copies should be clones) si.bAccelerantInUse = true; } } } if (result != B_OK) UninitCommon(); } TRACE("Leave InitAccelerant(), result: 0x%X\n", result); return result; }