1 /* 2 Haiku S3 Virge driver adapted from the X.org Virge driver. 3 4 Copyright (C) 1994-1999 The XFree86 Project, Inc. All Rights Reserved. 5 6 Copyright 2007-2008 Haiku, Inc. All rights reserved. 7 Distributed under the terms of the MIT license. 8 9 Authors: 10 Gerald Zajac 2007-2008 11 */ 12 13 14 #include "accel.h" 15 #include "virge.h" 16 17 18 19 uint32 20 Virge_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 29 Virge_GetDPMSMode(void) 30 { 31 // Return the current DPMS mode. 32 33 // Note: I do not know whether the following code is correctly reading 34 // the current DPMS mode. I'm assuming that reading back the bits that 35 // were set by function Virge_SetDPMSMode will give the current DPMS mode. 36 37 uint32 mode = B_DPMS_ON; 38 39 switch (ReadSeqReg(0x0d) & 0x70) { 40 case 0: 41 mode = B_DPMS_ON; 42 break; 43 case 0x10: 44 mode = B_DPMS_STAND_BY; 45 break; 46 case 0x40: 47 mode = B_DPMS_SUSPEND; 48 break; 49 case 0x50: 50 mode = B_DPMS_OFF; 51 break; 52 default: 53 TRACE("Unknown DPMS mode, reg sr0D: 0x%X\n", ReadSeqReg(0x0d)); 54 } 55 56 TRACE("Virge_GetDPMSMode() mode: %d\n", mode); 57 return mode; 58 } 59 60 61 status_t 62 Virge_SetDPMSMode(uint32 dpmsMode) 63 { 64 // Set the display into one of the Display Power Management modes, 65 // and return B_OK if successful, else return B_ERROR. 66 67 TRACE("Virge_SetDPMSMode() mode: %d\n", dpmsMode); 68 69 WriteSeqReg(0x08, 0x06); // unlock extended sequencer regs 70 71 uint8 sr0D = ReadSeqReg(0x0d) & 0x03; 72 73 switch (dpmsMode) { 74 case B_DPMS_ON: 75 break; 76 case B_DPMS_STAND_BY: 77 sr0D |= 0x10; 78 break; 79 case B_DPMS_SUSPEND: 80 sr0D |= 0x40; 81 break; 82 case B_DPMS_OFF: 83 sr0D |= 0x50; 84 break; 85 default: 86 TRACE("Invalid DPMS mode %d\n", dpmsMode); 87 return B_ERROR; 88 } 89 90 WriteSeqReg(0x0d, sr0D); 91 92 return B_OK; 93 } 94