1*35db13eaSAxel Dörfler /* 2*35db13eaSAxel Dörfler Copyright 1999, Be Incorporated. All Rights Reserved. 3*35db13eaSAxel Dörfler This file may be used under the terms of the Be Sample Code License. 4*35db13eaSAxel Dörfler 5*35db13eaSAxel Dörfler Other authors: 6*35db13eaSAxel Dörfler Gerald Zajac 2007 7*35db13eaSAxel Dörfler */ 8*35db13eaSAxel Dörfler 9*35db13eaSAxel Dörfler #include "accel.h" 10*35db13eaSAxel Dörfler 11*35db13eaSAxel Dörfler 12*35db13eaSAxel Dörfler static engine_token engineToken = { 1, B_2D_ACCELERATION, NULL }; 13*35db13eaSAxel Dörfler 14*35db13eaSAxel Dörfler 15*35db13eaSAxel Dörfler uint32 16*35db13eaSAxel Dörfler AccelerantEngineCount(void) 17*35db13eaSAxel Dörfler { 18*35db13eaSAxel Dörfler return 1; 19*35db13eaSAxel Dörfler } 20*35db13eaSAxel Dörfler 21*35db13eaSAxel Dörfler 22*35db13eaSAxel Dörfler status_t 23*35db13eaSAxel Dörfler AcquireEngine(uint32 capabilities, uint32 max_wait, 24*35db13eaSAxel Dörfler sync_token* st, engine_token** et) 25*35db13eaSAxel Dörfler { 26*35db13eaSAxel Dörfler (void)capabilities; // avoid compiler warning for unused arg 27*35db13eaSAxel Dörfler (void)max_wait; // avoid compiler warning for unused arg 28*35db13eaSAxel Dörfler 29*35db13eaSAxel Dörfler // Acquire the shared benaphore. 30*35db13eaSAxel Dörfler AQUIRE_BEN(gInfo.sharedInfo->engine.lock) 31*35db13eaSAxel Dörfler // Sync if required. 32*35db13eaSAxel Dörfler if (st) 33*35db13eaSAxel Dörfler SyncToToken(st); 34*35db13eaSAxel Dörfler 35*35db13eaSAxel Dörfler // Return an engine token. 36*35db13eaSAxel Dörfler *et = &engineToken; 37*35db13eaSAxel Dörfler return B_OK; 38*35db13eaSAxel Dörfler } 39*35db13eaSAxel Dörfler 40*35db13eaSAxel Dörfler 41*35db13eaSAxel Dörfler status_t 42*35db13eaSAxel Dörfler ReleaseEngine(engine_token* et, sync_token* st) 43*35db13eaSAxel Dörfler { 44*35db13eaSAxel Dörfler // Update the sync token, if any. 45*35db13eaSAxel Dörfler if (st) 46*35db13eaSAxel Dörfler GetSyncToken(et, st); 47*35db13eaSAxel Dörfler 48*35db13eaSAxel Dörfler // Release the shared benaphore. 49*35db13eaSAxel Dörfler RELEASE_BEN(gInfo.sharedInfo->engine.lock) 50*35db13eaSAxel Dörfler return B_OK; 51*35db13eaSAxel Dörfler } 52*35db13eaSAxel Dörfler 53*35db13eaSAxel Dörfler 54*35db13eaSAxel Dörfler void 55*35db13eaSAxel Dörfler WaitEngineIdle(void) 56*35db13eaSAxel Dörfler { 57*35db13eaSAxel Dörfler gInfo.WaitIdleEmpty(); // wait until engine is completely idle 58*35db13eaSAxel Dörfler } 59*35db13eaSAxel Dörfler 60*35db13eaSAxel Dörfler 61*35db13eaSAxel Dörfler status_t 62*35db13eaSAxel Dörfler GetSyncToken(engine_token* et, sync_token* st) 63*35db13eaSAxel Dörfler { 64*35db13eaSAxel Dörfler // Engine count will always be zero: we don't support syncing to token (yet). 65*35db13eaSAxel Dörfler st->engine_id = et->engine_id; 66*35db13eaSAxel Dörfler st->counter = gInfo.sharedInfo->engine.count; 67*35db13eaSAxel Dörfler return B_OK; 68*35db13eaSAxel Dörfler } 69*35db13eaSAxel Dörfler 70*35db13eaSAxel Dörfler 71*35db13eaSAxel Dörfler status_t 72*35db13eaSAxel Dörfler SyncToToken(sync_token* st) 73*35db13eaSAxel Dörfler { 74*35db13eaSAxel Dörfler (void)st; // avoid compiler warning for unused arg 75*35db13eaSAxel Dörfler 76*35db13eaSAxel Dörfler WaitEngineIdle(); 77*35db13eaSAxel Dörfler return B_OK; 78*35db13eaSAxel Dörfler } 79*35db13eaSAxel Dörfler 80