1 /* 2 Copyright 1999, Be Incorporated. All Rights Reserved. 3 This file may be used under the terms of the Be Sample Code License. 4 5 modification to call G400 functions and mess-ups - Mark Watson 6 */ 7 8 #define MODULE_BIT 0x10000000 9 10 #include "acc_std.h" 11 12 13 static engine_token nv_engine_token = { 1, B_2D_ACCELERATION, NULL }; 14 15 uint32 ACCELERANT_ENGINE_COUNT(void) { 16 return 1; 17 } 18 19 status_t ACQUIRE_ENGINE(uint32 capabilities, uint32 max_wait, sync_token *st, engine_token **et) { 20 /* acquire the shared benaphore */ 21 AQUIRE_BEN(si->engine.lock) 22 /* sync if required */ 23 if (st) SYNC_TO_TOKEN(st); 24 25 /* return an engine token */ 26 *et = &nv_engine_token; 27 return B_OK; 28 } 29 30 status_t RELEASE_ENGINE(engine_token *et, sync_token *st) { 31 /* update the sync token, if any */ 32 if (st) { 33 GET_SYNC_TOKEN(et,st); 34 } 35 36 /* release the shared benaphore */ 37 RELEASE_BEN(si->engine.lock) 38 return B_OK; 39 } 40 41 void WAIT_ENGINE_IDLE(void) { 42 uint32 count; 43 /*wait for the engine to be totally idle*/ 44 count = si->engine.count; 45 nv_acc_wait_idle(); 46 47 si->engine.last_idle = count; 48 } 49 50 status_t GET_SYNC_TOKEN(engine_token *et, sync_token *st) { 51 si->engine.count+=4; 52 st->engine_id = et->engine_id; 53 st->counter = si->engine.count; 54 return B_OK; 55 } 56 57 status_t SYNC_TO_TOKEN(sync_token *st) { 58 /* a quick out */ 59 if (st->counter <= si->engine.last_idle) return B_OK; 60 61 /* another quick out! */ 62 if ((st->counter >0xFFFFFFF) && (si->engine.last_idle <0xFFFF)) return B_OK; /*for when counter wraps*/ 63 64 /* If not we have to wait :-(*/ 65 WAIT_ENGINE_IDLE(); 66 67 return B_OK; 68 } 69