1 /* 2 * Copyright 2012 Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT license. 4 * 5 * Authors: 6 * Gerald Zajac 7 */ 8 9 /*! 10 Haiku Intel-810 video driver was adapted from the X.org intel driver which 11 has the following copyright. 12 13 Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. 14 All Rights Reserved. 15 */ 16 17 18 #include "accelerant.h" 19 #include "i810_regs.h" 20 21 22 #define DPMS_SYNC_SELECT 0x5002 23 #define H_SYNC_OFF 0x02 24 #define V_SYNC_OFF 0x08 25 26 27 uint32 28 I810_DPMSCapabilities(void) 29 { 30 // Return DPMS modes supported by this device. 31 32 return B_DPMS_ON | B_DPMS_STAND_BY | B_DPMS_SUSPEND | B_DPMS_OFF; 33 } 34 35 36 uint32 37 I810_GetDPMSMode(void) 38 { 39 // Return the current DPMS mode. 40 41 uint32 tmp = INREG8(DPMS_SYNC_SELECT) & (H_SYNC_OFF | V_SYNC_OFF); 42 uint32 mode; 43 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; 52 53 TRACE("I810_DPMSMode() mode: %d\n", mode); 54 return mode; 55 } 56 57 58 status_t 59 I810_SetDPMSMode(uint32 dpmsMode) 60 { 61 // Set the display into one of the Display Power Management modes, 62 // and return B_OK if successful, else return B_ERROR. 63 64 TRACE("I810_SetDPMSMode() mode: %d\n", dpmsMode); 65 66 uint8 seq01 = ReadSeqReg(1) & ~0x20; 67 uint8 dpmsSyncSelect = 0; 68 69 switch (dpmsMode) { 70 case B_DPMS_ON: 71 // Screen: On; HSync: On, VSync: On. 72 break; 73 74 case B_DPMS_STAND_BY: 75 // Screen: Off; HSync: Off, VSync: On. 76 seq01 |= 0x20; 77 dpmsSyncSelect = H_SYNC_OFF; 78 break; 79 80 case B_DPMS_SUSPEND: 81 // Screen: Off; HSync: On, VSync: Off. 82 seq01 |= 0x20; 83 dpmsSyncSelect = V_SYNC_OFF; 84 break; 85 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; 91 92 default: 93 TRACE("Invalid DPMS mode %d\n", dpmsMode); 94 return B_ERROR; 95 } 96 97 WriteSeqReg(1, seq01); // turn the screen on/off 98 OUTREG8(DPMS_SYNC_SELECT, dpmsSyncSelect); // set DPMS mode 99 100 return B_OK; 101 } 102