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	Mark Watson
7	Rudolf Cornelissen 3/2004
8*/
9
10#define MODULE_BIT 0x10000000
11
12#include "acc_std.h"
13
14
15static engine_token nm_engine_token = { 1, B_2D_ACCELERATION, NULL };
16
17uint32 ACCELERANT_ENGINE_COUNT(void)
18{
19	/* we have one acceleration engine */
20	return 1;
21}
22
23status_t ACQUIRE_ENGINE(uint32 capabilities, uint32 max_wait, sync_token *st, engine_token **et)
24{
25	/* acquire the shared benaphore */
26	AQUIRE_BEN(si->engine.lock)
27	/* sync if required */
28	if (st) SYNC_TO_TOKEN(st);
29
30	/* return an engine token */
31	*et = &nm_engine_token;
32	return B_OK;
33}
34
35status_t RELEASE_ENGINE(engine_token *et, sync_token *st)
36{
37	/* update the sync token, if any */
38	if (st) GET_SYNC_TOKEN(et,st);
39
40	/* release the shared benaphore */
41	RELEASE_BEN(si->engine.lock)
42	return B_OK;
43}
44
45void WAIT_ENGINE_IDLE(void)
46{
47	/*wait for the engine to be totally idle*/
48	nm_acc_wait_idle();
49}
50
51status_t GET_SYNC_TOKEN(engine_token *et, sync_token *st)
52{
53	/* engine count will always be zero: we don't support syncing to token (yet) */
54	st->engine_id = et->engine_id;
55	st->counter = si->engine.count;
56	return B_OK;
57}
58
59status_t SYNC_TO_TOKEN(sync_token *st)
60{
61	/* wait until the engine is totally idle: we don't support syncing to token (yet) */
62	/* note:
63	 * AFAIK in order to be able to setup sync_to_token, we'd need a circular fifo
64	 * buffer in (main) memory instead of directly programming the GPU fifo so we
65	 * can tell (via a hardware maintained pointer into this circular fifo) where
66	 * the acc engine is with executing commands! */
67	WAIT_ENGINE_IDLE();
68
69	return B_OK;
70}
71