135db13eaSAxel Dörfler /*
235db13eaSAxel Dörfler Copyright 1999, Be Incorporated. All Rights Reserved.
335db13eaSAxel Dörfler This file may be used under the terms of the Be Sample Code License.
435db13eaSAxel Dörfler
535db13eaSAxel Dörfler Other authors:
6*c1379d35SAxel Dörfler Gerald Zajac 2007-2008
735db13eaSAxel Dörfler */
835db13eaSAxel Dörfler
935db13eaSAxel Dörfler #include "accel.h"
1035db13eaSAxel Dörfler
1135db13eaSAxel Dörfler
1235db13eaSAxel Dörfler static engine_token engineToken = { 1, B_2D_ACCELERATION, NULL };
1335db13eaSAxel Dörfler
1435db13eaSAxel Dörfler
1535db13eaSAxel Dörfler uint32
AccelerantEngineCount(void)1635db13eaSAxel Dörfler AccelerantEngineCount(void)
1735db13eaSAxel Dörfler {
1835db13eaSAxel Dörfler return 1;
1935db13eaSAxel Dörfler }
2035db13eaSAxel Dörfler
2135db13eaSAxel Dörfler
2235db13eaSAxel Dörfler status_t
AcquireEngine(uint32 capabilities,uint32 max_wait,sync_token * st,engine_token ** et)2335db13eaSAxel Dörfler AcquireEngine(uint32 capabilities, uint32 max_wait,
2435db13eaSAxel Dörfler sync_token* st, engine_token** et)
2535db13eaSAxel Dörfler {
2635db13eaSAxel Dörfler (void)capabilities; // avoid compiler warning for unused arg
2735db13eaSAxel Dörfler (void)max_wait; // avoid compiler warning for unused arg
2835db13eaSAxel Dörfler
29*c1379d35SAxel Dörfler if (gInfo.sharedInfo->engineLock.Acquire() != B_OK)
30*c1379d35SAxel Dörfler return B_ERROR;
31*c1379d35SAxel Dörfler
3235db13eaSAxel Dörfler // Sync if required.
3335db13eaSAxel Dörfler if (st)
3435db13eaSAxel Dörfler SyncToToken(st);
3535db13eaSAxel Dörfler
3635db13eaSAxel Dörfler // Return an engine token.
3735db13eaSAxel Dörfler *et = &engineToken;
3835db13eaSAxel Dörfler return B_OK;
3935db13eaSAxel Dörfler }
4035db13eaSAxel Dörfler
4135db13eaSAxel Dörfler
4235db13eaSAxel Dörfler status_t
ReleaseEngine(engine_token * et,sync_token * st)4335db13eaSAxel Dörfler ReleaseEngine(engine_token* et, sync_token* st)
4435db13eaSAxel Dörfler {
4535db13eaSAxel Dörfler // Update the sync token, if any.
4635db13eaSAxel Dörfler if (st)
4735db13eaSAxel Dörfler GetSyncToken(et, st);
4835db13eaSAxel Dörfler
49*c1379d35SAxel Dörfler gInfo.sharedInfo->engineLock.Release();
5035db13eaSAxel Dörfler return B_OK;
5135db13eaSAxel Dörfler }
5235db13eaSAxel Dörfler
5335db13eaSAxel Dörfler
5435db13eaSAxel Dörfler void
WaitEngineIdle(void)5535db13eaSAxel Dörfler WaitEngineIdle(void)
5635db13eaSAxel Dörfler {
5735db13eaSAxel Dörfler gInfo.WaitIdleEmpty(); // wait until engine is completely idle
5835db13eaSAxel Dörfler }
5935db13eaSAxel Dörfler
6035db13eaSAxel Dörfler
6135db13eaSAxel Dörfler status_t
GetSyncToken(engine_token * et,sync_token * st)6235db13eaSAxel Dörfler GetSyncToken(engine_token* et, sync_token* st)
6335db13eaSAxel Dörfler {
6435db13eaSAxel Dörfler st->engine_id = et->engine_id;
65*c1379d35SAxel Dörfler st->counter = 0;
6635db13eaSAxel Dörfler return B_OK;
6735db13eaSAxel Dörfler }
6835db13eaSAxel Dörfler
6935db13eaSAxel Dörfler
7035db13eaSAxel Dörfler status_t
SyncToToken(sync_token * st)7135db13eaSAxel Dörfler SyncToToken(sync_token* st)
7235db13eaSAxel Dörfler {
7335db13eaSAxel Dörfler (void)st; // avoid compiler warning for unused arg
7435db13eaSAxel Dörfler
7535db13eaSAxel Dörfler WaitEngineIdle();
7635db13eaSAxel Dörfler return B_OK;
7735db13eaSAxel Dörfler }
7835db13eaSAxel Dörfler
79