xref: /haiku/src/add-ons/accelerants/3dfx/engine.cpp (revision 7749d0bb0c358a3279b1b9cc76d8376e900130a5)
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-2010
7 */
8 
9 #include "accelerant.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 	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 
42 status_t
43 ReleaseEngine(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 
54 void
55 WaitEngineIdle(void)
56 {
57 	TDFX_WaitForIdle();	// wait until engine is completely idle
58 }
59 
60 
61 status_t
62 GetSyncToken(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 
70 status_t
71 SyncToToken(sync_token* st)
72 {
73 	(void)st;		// avoid compiler warning for unused arg
74 
75 	WaitEngineIdle();
76 	return B_OK;
77 }
78 
79