From 24722904a4e32dec0e8f844314aef49936ae03e1 Mon Sep 17 00:00:00 2001 From: Rudolf Cornelissen Date: Sun, 10 Jul 2005 17:44:46 +0000 Subject: [PATCH] added via accelerant, a copy of skeleton driver yet. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13582 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../accelerants/via/EngineManagement.c | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 src/add-ons/accelerants/via/EngineManagement.c diff --git a/src/add-ons/accelerants/via/EngineManagement.c b/src/add-ons/accelerants/via/EngineManagement.c new file mode 100644 index 0000000000..3078796c9f --- /dev/null +++ b/src/add-ons/accelerants/via/EngineManagement.c @@ -0,0 +1,70 @@ +/* + Copyright 1999, Be Incorporated. All Rights Reserved. + This file may be used under the terms of the Be Sample Code License. + + other authors: + Mark Watson + Rudolf Cornelissen 3/2004 +*/ + +#define MODULE_BIT 0x10000000 + +#include "acc_std.h" + + +static engine_token eng_engine_token = { 1, B_2D_ACCELERATION, NULL }; + +uint32 ACCELERANT_ENGINE_COUNT(void) +{ + /* we have one acceleration engine */ + return 1; +} + +status_t ACQUIRE_ENGINE(uint32 capabilities, uint32 max_wait, sync_token *st, engine_token **et) +{ + /* acquire the shared benaphore */ + AQUIRE_BEN(si->engine.lock) + /* sync if required */ + if (st) SYNC_TO_TOKEN(st); + + /* return an engine token */ + *et = &eng_engine_token; + return B_OK; +} + +status_t RELEASE_ENGINE(engine_token *et, sync_token *st) +{ + /* update the sync token, if any */ + if (st) GET_SYNC_TOKEN(et,st); + + /* release the shared benaphore */ + RELEASE_BEN(si->engine.lock) + return B_OK; +} + +void WAIT_ENGINE_IDLE(void) +{ + /*wait for the engine to be totally idle*/ + eng_acc_wait_idle(); +} + +status_t GET_SYNC_TOKEN(engine_token *et, sync_token *st) +{ + /* engine count will always be zero: we don't support syncing to token (yet) */ + st->engine_id = et->engine_id; + st->counter = si->engine.count; + return B_OK; +} + +status_t SYNC_TO_TOKEN(sync_token *st) +{ + /* wait until the engine is totally idle: we don't support syncing to token (yet) */ + /* note: + * AFAIK in order to be able to setup sync_to_token, we'd need a circular fifo + * buffer in (main) memory instead of directly programming the GPU fifo so we + * can tell (via a hardware maintained pointer into this circular fifo) where + * the acc engine is with executing commands! */ + WAIT_ENGINE_IDLE(); + + return B_OK; +}