105b261ecSmrg/* 205b261ecSmrg * Copyright (c) 1997-2003 by The XFree86 Project, Inc. 305b261ecSmrg * 405b261ecSmrg * Permission is hereby granted, free of charge, to any person obtaining a 505b261ecSmrg * copy of this software and associated documentation files (the "Software"), 605b261ecSmrg * to deal in the Software without restriction, including without limitation 705b261ecSmrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 805b261ecSmrg * and/or sell copies of the Software, and to permit persons to whom the 905b261ecSmrg * Software is furnished to do so, subject to the following conditions: 1005b261ecSmrg * 1105b261ecSmrg * The above copyright notice and this permission notice shall be included in 1205b261ecSmrg * all copies or substantial portions of the Software. 1305b261ecSmrg * 1405b261ecSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1505b261ecSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1605b261ecSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 1705b261ecSmrg * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 1805b261ecSmrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 1905b261ecSmrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 2005b261ecSmrg * OTHER DEALINGS IN THE SOFTWARE. 2105b261ecSmrg * 2205b261ecSmrg * Except as contained in this notice, the name of the copyright holder(s) 2305b261ecSmrg * and author(s) shall not be used in advertising or otherwise to promote 2405b261ecSmrg * the sale, use or other dealings in this Software without prior written 2505b261ecSmrg * authorization from the copyright holder(s) and author(s). 2605b261ecSmrg */ 2705b261ecSmrg 2805b261ecSmrg/* 2905b261ecSmrg * This file contains the DPMS functions required by the extension. 3005b261ecSmrg */ 3105b261ecSmrg 3205b261ecSmrg#ifdef HAVE_XORG_CONFIG_H 3305b261ecSmrg#include <xorg-config.h> 3405b261ecSmrg#endif 3505b261ecSmrg 3605b261ecSmrg#include <X11/X.h> 3705b261ecSmrg#include "os.h" 3805b261ecSmrg#include "globals.h" 3935c4bbdfSmrg#include "windowstr.h" 4005b261ecSmrg#include "xf86.h" 4105b261ecSmrg#include "xf86Priv.h" 4205b261ecSmrg#ifdef DPMSExtension 436747b715Smrg#include <X11/extensions/dpmsconst.h> 4405b261ecSmrg#include "dpmsproc.h" 4505b261ecSmrg#endif 4635c4bbdfSmrg#ifdef XSERVER_LIBPCIACCESS 476747b715Smrg#include "xf86VGAarbiter.h" 4835c4bbdfSmrg#endif 4905b261ecSmrg 5005b261ecSmrg#ifdef DPMSExtension 511b5d61b8Smrgstatic void 521b5d61b8Smrgxf86DPMS(ScreenPtr pScreen, int level) 531b5d61b8Smrg{ 541b5d61b8Smrg ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); 551b5d61b8Smrg if (pScrn->DPMSSet && pScrn->vtSema) { 561b5d61b8Smrg xf86VGAarbiterLock(pScrn); 571b5d61b8Smrg pScrn->DPMSSet(pScrn, level, 0); 581b5d61b8Smrg xf86VGAarbiterUnlock(pScrn); 591b5d61b8Smrg } 601b5d61b8Smrg} 6105b261ecSmrg#endif 6205b261ecSmrg 636747b715SmrgBool 6405b261ecSmrgxf86DPMSInit(ScreenPtr pScreen, DPMSSetProcPtr set, int flags) 6505b261ecSmrg{ 6605b261ecSmrg#ifdef DPMSExtension 6735c4bbdfSmrg ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); 6835c4bbdfSmrg void *DPMSOpt; 691b5d61b8Smrg MessageType enabled_from = X_DEFAULT; 701b5d61b8Smrg Bool enabled = TRUE; 7105b261ecSmrg 7205b261ecSmrg DPMSOpt = xf86FindOption(pScrn->options, "dpms"); 736747b715Smrg if (DPMSDisabledSwitch) { 7435c4bbdfSmrg enabled_from = X_CMDLINE; 751b5d61b8Smrg enabled = FALSE; 766747b715Smrg } 776747b715Smrg else if (DPMSOpt) { 7835c4bbdfSmrg enabled_from = X_CONFIG; 791b5d61b8Smrg enabled = xf86CheckBoolOption(pScrn->options, "dpms", FALSE); 8035c4bbdfSmrg xf86MarkOptionUsed(DPMSOpt); 816747b715Smrg } 821b5d61b8Smrg if (enabled) { 8335c4bbdfSmrg xf86DrvMsg(pScreen->myNum, enabled_from, "DPMS enabled\n"); 841b5d61b8Smrg pScrn->DPMSSet = set; 851b5d61b8Smrg pScreen->DPMS = xf86DPMS; 861b5d61b8Smrg } 8705b261ecSmrg return TRUE; 8805b261ecSmrg#else 8905b261ecSmrg return FALSE; 9005b261ecSmrg#endif 9105b261ecSmrg} 92