xref: /haiku/src/add-ons/accelerants/ati/engine.cpp (revision 80829ec813241c9a702a45e39929286f13c55093)
1*80829ec8SRene Gollent /*
2*80829ec8SRene Gollent 	Copyright 1999, Be Incorporated.   All Rights Reserved.
3*80829ec8SRene Gollent 	This file may be used under the terms of the Be Sample Code License.
4*80829ec8SRene Gollent 
5*80829ec8SRene Gollent 	Other authors:
6*80829ec8SRene Gollent 	Gerald Zajac 2007-2008
7*80829ec8SRene Gollent */
8*80829ec8SRene Gollent 
9*80829ec8SRene Gollent #include "accelerant.h"
10*80829ec8SRene Gollent 
11*80829ec8SRene Gollent 
12*80829ec8SRene Gollent static engine_token engineToken = { 1, B_2D_ACCELERATION, NULL };
13*80829ec8SRene Gollent 
14*80829ec8SRene Gollent 
15*80829ec8SRene Gollent uint32
AccelerantEngineCount(void)16*80829ec8SRene Gollent AccelerantEngineCount(void)
17*80829ec8SRene Gollent {
18*80829ec8SRene Gollent 	return 1;
19*80829ec8SRene Gollent }
20*80829ec8SRene Gollent 
21*80829ec8SRene Gollent 
22*80829ec8SRene Gollent status_t
AcquireEngine(uint32 capabilities,uint32 max_wait,sync_token * st,engine_token ** et)23*80829ec8SRene Gollent AcquireEngine(uint32 capabilities, uint32 max_wait,
24*80829ec8SRene Gollent 						sync_token* st, engine_token** et)
25*80829ec8SRene Gollent {
26*80829ec8SRene Gollent 	(void)capabilities;	// avoid compiler warning for unused arg
27*80829ec8SRene Gollent 	(void)max_wait;		// avoid compiler warning for unused arg
28*80829ec8SRene Gollent 
29*80829ec8SRene Gollent 	if (gInfo.sharedInfo->engineLock.Acquire() != B_OK)
30*80829ec8SRene Gollent 		return B_ERROR;
31*80829ec8SRene Gollent 
32*80829ec8SRene Gollent 	// Sync if required.
33*80829ec8SRene Gollent 	if (st)
34*80829ec8SRene Gollent 		SyncToToken(st);
35*80829ec8SRene Gollent 
36*80829ec8SRene Gollent 	// Return an engine token.
37*80829ec8SRene Gollent 	*et = &engineToken;
38*80829ec8SRene Gollent 	return B_OK;
39*80829ec8SRene Gollent }
40*80829ec8SRene Gollent 
41*80829ec8SRene Gollent 
42*80829ec8SRene Gollent status_t
ReleaseEngine(engine_token * et,sync_token * st)43*80829ec8SRene Gollent ReleaseEngine(engine_token* et, sync_token* st)
44*80829ec8SRene Gollent {
45*80829ec8SRene Gollent 	// Update the sync token, if any.
46*80829ec8SRene Gollent 	if (st)
47*80829ec8SRene Gollent 		GetSyncToken(et, st);
48*80829ec8SRene Gollent 
49*80829ec8SRene Gollent 	gInfo.sharedInfo->engineLock.Release();
50*80829ec8SRene Gollent 	return B_OK;
51*80829ec8SRene Gollent }
52*80829ec8SRene Gollent 
53*80829ec8SRene Gollent 
54*80829ec8SRene Gollent void
WaitEngineIdle(void)55*80829ec8SRene Gollent WaitEngineIdle(void)
56*80829ec8SRene Gollent {
57*80829ec8SRene Gollent 	gInfo.WaitForIdle();	// wait until engine is completely idle
58*80829ec8SRene Gollent }
59*80829ec8SRene Gollent 
60*80829ec8SRene Gollent 
61*80829ec8SRene Gollent status_t
GetSyncToken(engine_token * et,sync_token * st)62*80829ec8SRene Gollent GetSyncToken(engine_token* et, sync_token* st)
63*80829ec8SRene Gollent {
64*80829ec8SRene Gollent 	st->engine_id = et->engine_id;
65*80829ec8SRene Gollent 	st->counter = 0;
66*80829ec8SRene Gollent 	return B_OK;
67*80829ec8SRene Gollent }
68*80829ec8SRene Gollent 
69*80829ec8SRene Gollent 
70*80829ec8SRene Gollent status_t
SyncToToken(sync_token * st)71*80829ec8SRene Gollent SyncToToken(sync_token* st)
72*80829ec8SRene Gollent {
73*80829ec8SRene Gollent 	(void)st;		// avoid compiler warning for unused arg
74*80829ec8SRene Gollent 
75*80829ec8SRene Gollent 	WaitEngineIdle();
76*80829ec8SRene Gollent 	return B_OK;
77*80829ec8SRene Gollent }
78*80829ec8SRene Gollent 
79