BTRFS: Implement BTree::Path and change _Find.
[haiku.git] / src / add-ons / accelerants / intel_810 / i810_dpms.cpp
blobf49361d80547b0851674955684ff28eed8e7035f
1 /*
2 * Copyright 2012 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT license.
5 * Authors:
6 * Gerald Zajac
7 */
9 /*!
10 Haiku Intel-810 video driver was adapted from the X.org intel driver which
11 has the following copyright.
13 Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
14 All Rights Reserved.
18 #include "accelerant.h"
19 #include "i810_regs.h"
22 #define DPMS_SYNC_SELECT 0x5002
23 #define H_SYNC_OFF 0x02
24 #define V_SYNC_OFF 0x08
27 uint32
28 I810_DPMSCapabilities(void)
30 // Return DPMS modes supported by this device.
32 return B_DPMS_ON | B_DPMS_STAND_BY | B_DPMS_SUSPEND | B_DPMS_OFF;
36 uint32
37 I810_GetDPMSMode(void)
39 // Return the current DPMS mode.
41 uint32 tmp = INREG8(DPMS_SYNC_SELECT) & (H_SYNC_OFF | V_SYNC_OFF);
42 uint32 mode;
44 if (tmp == 0 )
45 mode = B_DPMS_ON;
46 else if (tmp == H_SYNC_OFF)
47 mode = B_DPMS_STAND_BY;
48 else if (tmp == V_SYNC_OFF)
49 mode = B_DPMS_SUSPEND;
50 else
51 mode = B_DPMS_OFF;
53 TRACE("I810_DPMSMode() mode: %d\n", mode);
54 return mode;
58 status_t
59 I810_SetDPMSMode(uint32 dpmsMode)
61 // Set the display into one of the Display Power Management modes,
62 // and return B_OK if successful, else return B_ERROR.
64 TRACE("I810_SetDPMSMode() mode: %d\n", dpmsMode);
66 uint8 seq01 = ReadSeqReg(1) & ~0x20;
67 uint8 dpmsSyncSelect = 0;
69 switch (dpmsMode) {
70 case B_DPMS_ON:
71 // Screen: On; HSync: On, VSync: On.
72 break;
74 case B_DPMS_STAND_BY:
75 // Screen: Off; HSync: Off, VSync: On.
76 seq01 |= 0x20;
77 dpmsSyncSelect = H_SYNC_OFF;
78 break;
80 case B_DPMS_SUSPEND:
81 // Screen: Off; HSync: On, VSync: Off.
82 seq01 |= 0x20;
83 dpmsSyncSelect = V_SYNC_OFF;
84 break;
86 case B_DPMS_OFF:
87 // Screen: Off; HSync: Off, VSync: Off.
88 seq01 |= 0x20;
89 dpmsSyncSelect = H_SYNC_OFF | V_SYNC_OFF;
90 break;
92 default:
93 TRACE("Invalid DPMS mode %d\n", dpmsMode);
94 return B_ERROR;
97 WriteSeqReg(1, seq01); // turn the screen on/off
98 OUTREG8(DPMS_SYNC_SELECT, dpmsSyncSelect); // set DPMS mode
100 return B_OK;