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	Gerald Zajac 2007-2008
7*/
8
9#include "accel.h"
10
11
12static engine_token engineToken = { 1, B_2D_ACCELERATION, NULL };
13
14
15uint32
16AccelerantEngineCount(void)
17{
18	return 1;
19}
20
21
22status_t
23AcquireEngine(uint32 capabilities, uint32 max_wait,
24						sync_token* st, engine_token** et)
25{
26	(void)capabilities;	// avoid compiler warning for unused arg
27	(void)max_wait;		// avoid compiler warning for unused arg
28
29	if (gInfo.sharedInfo->engineLock.Acquire() != B_OK)
30		return B_ERROR;
31
32	// Sync if required.
33	if (st)
34		SyncToToken(st);
35
36	// Return an engine token.
37	*et = &engineToken;
38	return B_OK;
39}
40
41
42status_t
43ReleaseEngine(engine_token* et, sync_token* st)
44{
45	// Update the sync token, if any.
46	if (st)
47		GetSyncToken(et, st);
48
49	gInfo.sharedInfo->engineLock.Release();
50	return B_OK;
51}
52
53
54void
55WaitEngineIdle(void)
56{
57	gInfo.WaitIdleEmpty();	// wait until engine is completely idle
58}
59
60
61status_t
62GetSyncToken(engine_token* et, sync_token* st)
63{
64	st->engine_id = et->engine_id;
65	st->counter = 0;
66	return B_OK;
67}
68
69
70status_t
71SyncToToken(sync_token* st)
72{
73	(void)st;		// avoid compiler warning for unused arg
74
75	WaitEngineIdle();
76	return B_OK;
77}
78
79