xref: /haiku/src/add-ons/accelerants/et6x00/EngineManagment.c (revision 8731383444bd7e453833f844e32f7b5136079df2)
1*87313834SIngo Weinhold /*****************************************************************************\
2*87313834SIngo Weinhold  * Tseng Labs ET6000, ET6100 and ET6300 graphics driver for BeOS 5.
3*87313834SIngo Weinhold  * Copyright (c) 2003-2004, Evgeniy Vladimirovich Bobkov.
4*87313834SIngo Weinhold \*****************************************************************************/
5*87313834SIngo Weinhold 
6*87313834SIngo Weinhold #include "GlobalData.h"
7*87313834SIngo Weinhold #include "generic.h"
8*87313834SIngo Weinhold 
9*87313834SIngo Weinhold 
10*87313834SIngo Weinhold /*****************************************************************************/
11*87313834SIngo Weinhold static engine_token et6000EngineToken = {1, B_2D_ACCELERATION, NULL};
12*87313834SIngo Weinhold /*****************************************************************************/
ACCELERANT_ENGINE_COUNT(void)13*87313834SIngo Weinhold uint32 ACCELERANT_ENGINE_COUNT(void) {
14*87313834SIngo Weinhold     return 1;
15*87313834SIngo Weinhold }
16*87313834SIngo Weinhold /*****************************************************************************/
ACQUIRE_ENGINE(uint32 capabilities,uint32 max_wait,sync_token * st,engine_token ** et)17*87313834SIngo Weinhold status_t ACQUIRE_ENGINE(uint32 capabilities,
18*87313834SIngo Weinhold                         uint32 max_wait,
19*87313834SIngo Weinhold                         sync_token *st,
20*87313834SIngo Weinhold                         engine_token **et)
21*87313834SIngo Weinhold {
22*87313834SIngo Weinhold     /* acquire the shared benaphore */
23*87313834SIngo Weinhold     AQUIRE_BEN(si->engine.lock)
24*87313834SIngo Weinhold     /* sync if required */
25*87313834SIngo Weinhold     if (st) SYNC_TO_TOKEN(st);
26*87313834SIngo Weinhold 
27*87313834SIngo Weinhold     /* return an engine token */
28*87313834SIngo Weinhold     *et = &et6000EngineToken;
29*87313834SIngo Weinhold     return B_OK;
30*87313834SIngo Weinhold }
31*87313834SIngo Weinhold /*****************************************************************************/
RELEASE_ENGINE(engine_token * et,sync_token * st)32*87313834SIngo Weinhold status_t RELEASE_ENGINE(engine_token *et, sync_token *st) {
33*87313834SIngo Weinhold     /* update the sync token, if any */
34*87313834SIngo Weinhold     if (st) {
35*87313834SIngo Weinhold 	st->engine_id = et->engine_id;
36*87313834SIngo Weinhold 	st->counter = si->engine.count;
37*87313834SIngo Weinhold     }
38*87313834SIngo Weinhold 
39*87313834SIngo Weinhold     /* release the shared benaphore */
40*87313834SIngo Weinhold     RELEASE_BEN(si->engine.lock)
41*87313834SIngo Weinhold     return B_OK;
42*87313834SIngo Weinhold }
43*87313834SIngo Weinhold /*****************************************************************************/
WAIT_ENGINE_IDLE(void)44*87313834SIngo Weinhold void WAIT_ENGINE_IDLE(void) {
45*87313834SIngo Weinhold     et6000aclWaitIdle();
46*87313834SIngo Weinhold     /* note our current possition */
47*87313834SIngo Weinhold     si->engine.lastIdle = si->engine.count;
48*87313834SIngo Weinhold }
49*87313834SIngo Weinhold /*****************************************************************************/
GET_SYNC_TOKEN(engine_token * et,sync_token * st)50*87313834SIngo Weinhold status_t GET_SYNC_TOKEN(engine_token *et, sync_token *st) {
51*87313834SIngo Weinhold     st->engine_id = et->engine_id;
52*87313834SIngo Weinhold     st->counter = si->engine.count;
53*87313834SIngo Weinhold     return B_OK;
54*87313834SIngo Weinhold }
55*87313834SIngo Weinhold /*****************************************************************************/
SYNC_TO_TOKEN(sync_token * st)56*87313834SIngo Weinhold status_t SYNC_TO_TOKEN(sync_token *st) {
57*87313834SIngo Weinhold     WAIT_ENGINE_IDLE();
58*87313834SIngo Weinhold     si->engine.lastIdle = st->counter;
59*87313834SIngo Weinhold     return B_OK;
60*87313834SIngo Weinhold }
61*87313834SIngo Weinhold /*****************************************************************************/
62