1 /* 2 * Copyright 2007-2012 Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT license. 4 * 5 * Authors: 6 * Gerald Zajac 7 */ 8 9 10 #include "accelerant.h" 11 #include "i810_regs.h" 12 13 14 static engine_token sEngineToken = { 1, B_2D_ACCELERATION, NULL }; 15 16 17 uint32 18 AccelerantEngineCount(void) 19 { 20 return 1; 21 } 22 23 24 status_t 25 AcquireEngine(uint32 capabilities, uint32 maxWait, 26 sync_token* syncToken, engine_token** engineToken) 27 { 28 (void)capabilities; // avoid compiler warning for unused arg 29 (void)maxWait; // avoid compiler warning for unused arg 30 31 if (gInfo.sharedInfo->engineLock.Acquire() != B_OK) 32 return B_ERROR; 33 34 if (syncToken) 35 SyncToToken(syncToken); 36 37 *engineToken = &sEngineToken; 38 return B_OK; 39 } 40 41 42 status_t 43 ReleaseEngine(engine_token* engineToken, sync_token* syncToken) 44 { 45 if (syncToken) 46 GetSyncToken(engineToken, syncToken); 47 48 gInfo.sharedInfo->engineLock.Release(); 49 return B_OK; 50 } 51 52 53 void 54 WaitEngineIdle(void) 55 { 56 // Wait until engine is idle. 57 58 int k = 10000000; 59 60 while ((INREG16(INST_DONE) & 0x7B) != 0x7B && k > 0) 61 k--; 62 } 63 64 65 status_t 66 GetSyncToken(engine_token* engineToken, sync_token* syncToken) 67 { 68 syncToken->engine_id = engineToken->engine_id; 69 syncToken->counter = 0; 70 return B_OK; 71 } 72 73 74 status_t 75 SyncToToken(sync_token* syncToken) 76 { 77 (void)syncToken; 78 // avoid compiler warning for unused arg 79 80 WaitEngineIdle(); 81 return B_OK; 82 } 83