1 /*
2 Copyright 2010 Haiku, Inc. All rights reserved.
3 Distributed under the terms of the MIT license.
4
5 Authors:
6 Gerald Zajac 2010
7 */
8
9
10 #include "accelerant.h"
11 #include "3dfx.h"
12
13
14
15 #define H_SYNC_OFF BIT(3)
16 #define V_SYNC_OFF BIT(1)
17
18
19 uint32
TDFX_DPMSCapabilities(void)20 TDFX_DPMSCapabilities(void)
21 {
22 // Return DPMS modes supported by this device.
23
24 return B_DPMS_ON | B_DPMS_STAND_BY | B_DPMS_SUSPEND | B_DPMS_OFF;
25 }
26
27
28 uint32
TDFX_GetDPMSMode(void)29 TDFX_GetDPMSMode(void)
30 {
31 // Return the current DPMS mode.
32
33 uint32 tmp = INREG32(DAC_MODE) & (H_SYNC_OFF | V_SYNC_OFF);
34 uint32 mode;
35
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;
44
45 TRACE("TDFX_DPMSMode() mode: %d\n", mode);
46 return mode;
47 }
48
49
50 status_t
TDFX_SetDPMSMode(uint32 dpmsMode)51 TDFX_SetDPMSMode(uint32 dpmsMode)
52 {
53 // Set the display into one of the Display Power Management modes,
54 // and return B_OK if successful, else return B_ERROR.
55
56 TRACE("TDFX_SetDPMSMode() mode: %d\n", dpmsMode);
57
58 uint32 dacMode = INREG32(DAC_MODE) & ~(H_SYNC_OFF | V_SYNC_OFF);
59
60 switch (dpmsMode) {
61 case B_DPMS_ON:
62 // Screen: On; HSync: On, VSync: On.
63 break;
64
65 case B_DPMS_STAND_BY:
66 // Screen: Off; HSync: Off, VSync: On.
67 dacMode |= H_SYNC_OFF;
68 break;
69
70 case B_DPMS_SUSPEND:
71 // Screen: Off; HSync: On, VSync: Off.
72 dacMode |= V_SYNC_OFF;
73 break;
74
75 case B_DPMS_OFF:
76 // Screen: Off; HSync: Off, VSync: Off.
77 dacMode |= H_SYNC_OFF | V_SYNC_OFF;
78 break;
79
80 default:
81 TRACE("Invalid DPMS mode %d\n", dpmsMode);
82 return B_ERROR;
83 }
84
85 OUTREG32(DAC_MODE, dacMode);
86 return B_OK;
87 }
88