BTRFS: Implement BTree::Path and change _Find.
[haiku.git] / src / add-ons / accelerants / 3dfx / 3dfx_dpms.cpp
blob30adbd4f36bbf44debfd4c22a9c14569bba8de0f
1 /*
2 Copyright 2010 Haiku, Inc. All rights reserved.
3 Distributed under the terms of the MIT license.
5 Authors:
6 Gerald Zajac 2010
7 */
10 #include "accelerant.h"
11 #include "3dfx.h"
15 #define H_SYNC_OFF BIT(3)
16 #define V_SYNC_OFF BIT(1)
19 uint32
20 TDFX_DPMSCapabilities(void)
22 // Return DPMS modes supported by this device.
24 return B_DPMS_ON | B_DPMS_STAND_BY | B_DPMS_SUSPEND | B_DPMS_OFF;
28 uint32
29 TDFX_GetDPMSMode(void)
31 // Return the current DPMS mode.
33 uint32 tmp = INREG32(DAC_MODE) & (H_SYNC_OFF | V_SYNC_OFF);
34 uint32 mode;
36 if (tmp == 0 )
37 mode = B_DPMS_ON;
38 else if (tmp == H_SYNC_OFF)
39 mode = B_DPMS_STAND_BY;
40 else if (tmp == V_SYNC_OFF)
41 mode = B_DPMS_SUSPEND;
42 else
43 mode = B_DPMS_OFF;
45 TRACE("TDFX_DPMSMode() mode: %d\n", mode);
46 return mode;
50 status_t
51 TDFX_SetDPMSMode(uint32 dpmsMode)
53 // Set the display into one of the Display Power Management modes,
54 // and return B_OK if successful, else return B_ERROR.
56 TRACE("TDFX_SetDPMSMode() mode: %d\n", dpmsMode);
58 uint32 dacMode = INREG32(DAC_MODE) & ~(H_SYNC_OFF | V_SYNC_OFF);
60 switch (dpmsMode) {
61 case B_DPMS_ON:
62 // Screen: On; HSync: On, VSync: On.
63 break;
65 case B_DPMS_STAND_BY:
66 // Screen: Off; HSync: Off, VSync: On.
67 dacMode |= H_SYNC_OFF;
68 break;
70 case B_DPMS_SUSPEND:
71 // Screen: Off; HSync: On, VSync: Off.
72 dacMode |= V_SYNC_OFF;
73 break;
75 case B_DPMS_OFF:
76 // Screen: Off; HSync: Off, VSync: Off.
77 dacMode |= H_SYNC_OFF | V_SYNC_OFF;
78 break;
80 default:
81 TRACE("Invalid DPMS mode %d\n", dpmsMode);
82 return B_ERROR;
85 OUTREG32(DAC_MODE, dacMode);
86 return B_OK;