1091b52d5Sshatty /*
2091b52d5Sshatty Copyright 1999, Be Incorporated. All Rights Reserved.
3091b52d5Sshatty This file may be used under the terms of the Be Sample Code License.
4091b52d5Sshatty
5*2e66094aSRudolf Cornelissen other authors:
6*2e66094aSRudolf Cornelissen Mark Watson
7*2e66094aSRudolf Cornelissen Rudolf Cornelissen 3/2004
8091b52d5Sshatty */
9091b52d5Sshatty
10091b52d5Sshatty #define MODULE_BIT 0x10000000
11091b52d5Sshatty
12091b52d5Sshatty #include "acc_std.h"
13091b52d5Sshatty
14091b52d5Sshatty
15091b52d5Sshatty static engine_token gx00_engine_token = { 1, B_2D_ACCELERATION, NULL };
16091b52d5Sshatty
ACCELERANT_ENGINE_COUNT(void)17*2e66094aSRudolf Cornelissen uint32 ACCELERANT_ENGINE_COUNT(void)
18*2e66094aSRudolf Cornelissen {
19*2e66094aSRudolf Cornelissen /* we have one acceleration engine */
20091b52d5Sshatty return 1;
21091b52d5Sshatty }
22091b52d5Sshatty
ACQUIRE_ENGINE(uint32 capabilities,uint32 max_wait,sync_token * st,engine_token ** et)23*2e66094aSRudolf Cornelissen status_t ACQUIRE_ENGINE(uint32 capabilities, uint32 max_wait, sync_token *st, engine_token **et)
24*2e66094aSRudolf Cornelissen {
25091b52d5Sshatty /* acquire the shared benaphore */
26091b52d5Sshatty AQUIRE_BEN(si->engine.lock)
27091b52d5Sshatty /* sync if required */
28091b52d5Sshatty if (st) SYNC_TO_TOKEN(st);
29091b52d5Sshatty
30091b52d5Sshatty /* return an engine token */
31091b52d5Sshatty *et = &gx00_engine_token;
32091b52d5Sshatty return B_OK;
33091b52d5Sshatty }
34091b52d5Sshatty
RELEASE_ENGINE(engine_token * et,sync_token * st)35*2e66094aSRudolf Cornelissen status_t RELEASE_ENGINE(engine_token *et, sync_token *st)
36*2e66094aSRudolf Cornelissen {
37091b52d5Sshatty /* update the sync token, if any */
38*2e66094aSRudolf Cornelissen if (st) GET_SYNC_TOKEN(et,st);
39091b52d5Sshatty
40091b52d5Sshatty /* release the shared benaphore */
41091b52d5Sshatty RELEASE_BEN(si->engine.lock)
42091b52d5Sshatty return B_OK;
43091b52d5Sshatty }
44091b52d5Sshatty
WAIT_ENGINE_IDLE(void)45*2e66094aSRudolf Cornelissen void WAIT_ENGINE_IDLE(void)
46*2e66094aSRudolf Cornelissen {
47091b52d5Sshatty /*wait for the engine to be totally idle*/
48091b52d5Sshatty gx00_acc_wait_idle();
49091b52d5Sshatty }
50091b52d5Sshatty
GET_SYNC_TOKEN(engine_token * et,sync_token * st)51*2e66094aSRudolf Cornelissen status_t GET_SYNC_TOKEN(engine_token *et, sync_token *st)
52*2e66094aSRudolf Cornelissen {
53*2e66094aSRudolf Cornelissen /* engine count will always be zero: we don't support syncing to token (yet) */
54091b52d5Sshatty st->engine_id = et->engine_id;
55091b52d5Sshatty st->counter = si->engine.count;
56091b52d5Sshatty return B_OK;
57091b52d5Sshatty }
58091b52d5Sshatty
SYNC_TO_TOKEN(sync_token * st)59*2e66094aSRudolf Cornelissen status_t SYNC_TO_TOKEN(sync_token *st)
60*2e66094aSRudolf Cornelissen {
61*2e66094aSRudolf Cornelissen /* wait until the engine is totally idle: we don't support syncing to token (yet) */
62*2e66094aSRudolf Cornelissen /* note:
63*2e66094aSRudolf Cornelissen * AFAIK in order to be able to setup sync_to_token, we'd need a circular fifo
64*2e66094aSRudolf Cornelissen * buffer in (main) memory instead of directly programming the GPU fifo so we
65*2e66094aSRudolf Cornelissen * can tell (via a hardware maintained pointer into this circular fifo) where
66*2e66094aSRudolf Cornelissen * the acc engine is with executing commands! */
67091b52d5Sshatty WAIT_ENGINE_IDLE();
68091b52d5Sshatty
69091b52d5Sshatty return B_OK;
70091b52d5Sshatty }
71