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 other authors: 6 Mark Watson 7 Rudolf Cornelissen 3/2004-12/2004 8 */ 9 10 /* 11 note: 12 attempting DMA on NV40 and higher because without it I can't get it going ATM. 13 Later on this can become a nv.settings switch, and maybe later we can even 14 forget about non-DMA completely (depends on 3D acceleration attempts). 15 */ 16 17 #define MODULE_BIT 0x10000000 18 19 #include "acc_std.h" 20 21 22 static engine_token nv_engine_token = { 1, B_2D_ACCELERATION, NULL }; 23 24 uint32 ACCELERANT_ENGINE_COUNT(void) 25 { 26 /* we have one acceleration engine */ 27 return 1; 28 } 29 30 status_t ACQUIRE_ENGINE(uint32 capabilities, uint32 max_wait, sync_token *st, engine_token **et) 31 { 32 /* acquire the shared benaphore */ 33 AQUIRE_BEN(si->engine.lock) 34 /* sync if required */ 35 if (st) SYNC_TO_TOKEN(st); 36 37 /* make sure all needed engine cmd's are mapped to the FIFO */ 38 if (si->ps.card_arch < NV40A) 39 nv_acc_assert_fifo(); 40 41 /* return an engine token */ 42 *et = &nv_engine_token; 43 return B_OK; 44 } 45 46 status_t RELEASE_ENGINE(engine_token *et, sync_token *st) 47 { 48 /* update the sync token, if any */ 49 if (st) GET_SYNC_TOKEN(et,st); 50 51 /* release the shared benaphore */ 52 RELEASE_BEN(si->engine.lock) 53 return B_OK; 54 } 55 56 void WAIT_ENGINE_IDLE(void) 57 { 58 /*wait for the engine to be totally idle*/ 59 if (si->ps.card_arch < NV40A) 60 nv_acc_wait_idle(); 61 else 62 nv_acc_wait_idle_dma(); 63 } 64 65 status_t GET_SYNC_TOKEN(engine_token *et, sync_token *st) 66 { 67 /* engine count will always be zero: we don't support syncing to token (yet) */ 68 st->engine_id = et->engine_id; 69 st->counter = si->engine.count; 70 return B_OK; 71 } 72 73 status_t SYNC_TO_TOKEN(sync_token *st) 74 { 75 /* wait until the engine is totally idle: we don't support syncing to token (yet) */ 76 /* note: 77 * AFAIK in order to be able to setup sync_to_token, we'd need a circular fifo 78 * buffer in (main) memory instead of directly programming the GPU fifo so we 79 * can tell (via a hardware maintained pointer into this circular fifo) where 80 * the acc engine is with executing commands! */ 81 WAIT_ENGINE_IDLE(); 82 83 return B_OK; 84 } 85