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:
6c1379d35SAxel 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örflerstatic engine_token engineToken = { 1, B_2D_ACCELERATION, NULL };
1335db13eaSAxel Dörfler
1435db13eaSAxel Dörfler
15c1379d35SAxel Dörfleruint32
1635db13eaSAxel DörflerAccelerantEngineCount(void)
1735db13eaSAxel Dörfler{
1835db13eaSAxel Dörfler	return 1;
1935db13eaSAxel Dörfler}
2035db13eaSAxel Dörfler
2135db13eaSAxel Dörfler
22c1379d35SAxel Dörflerstatus_t
2335db13eaSAxel DörflerAcquireEngine(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
29c1379d35SAxel Dörfler	if (gInfo.sharedInfo->engineLock.Acquire() != B_OK)
30c1379d35SAxel Dörfler		return B_ERROR;
31c1379d35SAxel 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
42c1379d35SAxel Dörflerstatus_t
4335db13eaSAxel DörflerReleaseEngine(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
49c1379d35SAxel Dörfler	gInfo.sharedInfo->engineLock.Release();
5035db13eaSAxel Dörfler	return B_OK;
5135db13eaSAxel Dörfler}
5235db13eaSAxel Dörfler
5335db13eaSAxel Dörfler
54c1379d35SAxel Dörflervoid
5535db13eaSAxel DörflerWaitEngineIdle(void)
5635db13eaSAxel Dörfler{
5735db13eaSAxel Dörfler	gInfo.WaitIdleEmpty();	// wait until engine is completely idle
5835db13eaSAxel Dörfler}
5935db13eaSAxel Dörfler
6035db13eaSAxel Dörfler
61c1379d35SAxel Dörflerstatus_t
6235db13eaSAxel DörflerGetSyncToken(engine_token* et, sync_token* st)
6335db13eaSAxel Dörfler{
6435db13eaSAxel Dörfler	st->engine_id = et->engine_id;
65c1379d35SAxel Dörfler	st->counter = 0;
6635db13eaSAxel Dörfler	return B_OK;
6735db13eaSAxel Dörfler}
6835db13eaSAxel Dörfler
6935db13eaSAxel Dörfler
70c1379d35SAxel Dörflerstatus_t
7135db13eaSAxel DörflerSyncToToken(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