xref: /haiku/src/add-ons/accelerants/s3/engine.cpp (revision 746cac055adc6ac3308c7bc2d29040fb95689cc9)
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
7 */
8 
9 #include "accel.h"
10 
11 
12 static engine_token engineToken = { 1, B_2D_ACCELERATION, NULL };
13 
14 
15 uint32
16 AccelerantEngineCount(void)
17 {
18 	return 1;
19 }
20 
21 
22 status_t
23 AcquireEngine(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 	// Acquire the shared benaphore.
30 	AQUIRE_BEN(gInfo.sharedInfo->engine.lock)
31 	// Sync if required.
32 	if (st)
33 		SyncToToken(st);
34 
35 	// Return an engine token.
36 	*et = &engineToken;
37 	return B_OK;
38 }
39 
40 
41 status_t
42 ReleaseEngine(engine_token* et, sync_token* st)
43 {
44 	// Update the sync token, if any.
45 	if (st)
46 		GetSyncToken(et, st);
47 
48 	// Release the shared benaphore.
49 	RELEASE_BEN(gInfo.sharedInfo->engine.lock)
50 	return B_OK;
51 }
52 
53 
54 void
55 WaitEngineIdle(void)
56 {
57 	gInfo.WaitIdleEmpty();	// wait until engine is completely idle
58 }
59 
60 
61 status_t
62 GetSyncToken(engine_token* et, sync_token* st)
63 {
64 	// Engine count will always be zero: we don't support syncing to token (yet).
65 	st->engine_id = et->engine_id;
66 	st->counter = gInfo.sharedInfo->engine.count;
67 	return B_OK;
68 }
69 
70 
71 status_t
72 SyncToToken(sync_token* st)
73 {
74 	(void)st;		// avoid compiler warning for unused arg
75 
76 	WaitEngineIdle();
77 	return B_OK;
78 }
79 
80