diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2019-07-27 07:57:27 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2019-07-27 07:57:27 +0000 |
commit | d4a0bed4b91da9de86c311c7fef9a8aa9a6f500c (patch) | |
tree | a1b439049dee87bc951e190db93f5bbe8b43b0b5 /xserver/hw/xfree86/common/xf86DPMS.c | |
parent | b6bc775539a31f663f9e22ce3ccaf0aa96adf3b6 (diff) |
Update to xserver 1.20.5. Tested by jsg@
Diffstat (limited to 'xserver/hw/xfree86/common/xf86DPMS.c')
-rw-r--r-- | xserver/hw/xfree86/common/xf86DPMS.c | 163 |
1 files changed, 18 insertions, 145 deletions
diff --git a/xserver/hw/xfree86/common/xf86DPMS.c b/xserver/hw/xfree86/common/xf86DPMS.c index 2b5a3ed1e..ee495483e 100644 --- a/xserver/hw/xfree86/common/xf86DPMS.c +++ b/xserver/hw/xfree86/common/xf86DPMS.c @@ -48,10 +48,16 @@ #endif #ifdef DPMSExtension -static DevPrivateKeyRec DPMSKeyRec; -static DevPrivateKey DPMSKey; -static Bool DPMSClose(ScreenPtr pScreen); -static int DPMSCount = 0; +static void +xf86DPMS(ScreenPtr pScreen, int level) +{ + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); + if (pScrn->DPMSSet && pScrn->vtSema) { + xf86VGAarbiterLock(pScrn); + pScrn->DPMSSet(pScrn, level, 0); + xf86VGAarbiterUnlock(pScrn); + } +} #endif Bool @@ -59,160 +65,27 @@ xf86DPMSInit(ScreenPtr pScreen, DPMSSetProcPtr set, int flags) { #ifdef DPMSExtension ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); - DPMSPtr pDPMS; void *DPMSOpt; - MessageType enabled_from; + MessageType enabled_from = X_DEFAULT; + Bool enabled = TRUE; - DPMSKey = &DPMSKeyRec; - - if (!dixRegisterPrivateKey(&DPMSKeyRec, PRIVATE_SCREEN, sizeof(DPMSRec))) - return FALSE; - - pDPMS = dixLookupPrivate(&pScreen->devPrivates, DPMSKey); - pScrn->DPMSSet = set; - pDPMS->Flags = flags; DPMSOpt = xf86FindOption(pScrn->options, "dpms"); if (DPMSDisabledSwitch) { enabled_from = X_CMDLINE; - DPMSEnabled = FALSE; + enabled = FALSE; } else if (DPMSOpt) { enabled_from = X_CONFIG; - DPMSEnabled = xf86CheckBoolOption(pScrn->options, "dpms", FALSE); + enabled = xf86CheckBoolOption(pScrn->options, "dpms", FALSE); xf86MarkOptionUsed(DPMSOpt); } - else { - enabled_from = X_DEFAULT; - DPMSEnabled = TRUE; - } - if (DPMSEnabled) + if (enabled) { xf86DrvMsg(pScreen->myNum, enabled_from, "DPMS enabled\n"); - pDPMS->Enabled = DPMSEnabled; - pDPMS->CloseScreen = pScreen->CloseScreen; - pScreen->CloseScreen = DPMSClose; - DPMSCount++; + pScrn->DPMSSet = set; + pScreen->DPMS = xf86DPMS; + } return TRUE; #else return FALSE; #endif } - -#ifdef DPMSExtension - -static Bool -DPMSClose(ScreenPtr pScreen) -{ - DPMSPtr pDPMS; - ScrnInfoPtr pScrn; - /* This shouldn't happen */ - if (DPMSKey == NULL) - return FALSE; - - pDPMS = dixLookupPrivate(&pScreen->devPrivates, DPMSKey); - - /* This shouldn't happen */ - if (!pDPMS) - return FALSE; - - pScreen->CloseScreen = pDPMS->CloseScreen; - pScrn = xf86ScreenToScrn(pScreen); - /* - * Turn on DPMS when shutting down. If this function can be used - * depends on the order the driver wraps things. If this is called - * after the driver has shut down everything the driver will have - * to deal with this internally. - */ - if (pScrn->vtSema && pScrn->DPMSSet) { - pScrn->DPMSSet(pScrn, DPMSModeOn, 0); - } - - if (--DPMSCount == 0) - DPMSKey = NULL; - return pScreen->CloseScreen(pScreen); -} - -static void -DPMSSetScreen(ScrnInfoPtr pScrn, int level) -{ - ScreenPtr pScreen = xf86ScrnToScreen(pScrn); - DPMSPtr pDPMS = dixLookupPrivate(&pScreen->devPrivates, DPMSKey); - - if (pDPMS && pScrn->DPMSSet && pDPMS->Enabled && pScrn->vtSema) { - xf86VGAarbiterLock(pScrn); - pScrn->DPMSSet(pScrn, level, 0); - xf86VGAarbiterUnlock(pScrn); - } -} - -/* - * DPMSSet -- - * Device dependent DPMS mode setting hook. This is called whenever - * the DPMS mode is to be changed. - */ -int -DPMSSet(ClientPtr client, int level) -{ - int rc, i; - - DPMSPowerLevel = level; - - if (DPMSKey == NULL) - return Success; - - if (level != DPMSModeOn) { - if (xf86IsUnblank(screenIsSaved)) { - rc = dixSaveScreens(client, SCREEN_SAVER_FORCER, ScreenSaverActive); - if (rc != Success) - return rc; - } - } else if (!xf86IsUnblank(screenIsSaved)) { - rc = dixSaveScreens(client, SCREEN_SAVER_OFF, ScreenSaverReset); - if (rc != Success) - return rc; - } - - /* For each screen, set the DPMS level */ - for (i = 0; i < xf86NumScreens; i++) { - DPMSSetScreen(xf86Screens[i], level); - } - for (i = 0; i < xf86NumGPUScreens; i++) { - DPMSSetScreen(xf86GPUScreens[i], level); - } - return Success; -} - -static Bool -DPMSSupportedOnScreen(ScrnInfoPtr pScrn) -{ - ScreenPtr pScreen = xf86ScrnToScreen(pScrn); - DPMSPtr pDPMS = dixLookupPrivate(&pScreen->devPrivates, DPMSKey); - - return pDPMS && pScrn->DPMSSet; -} - -/* - * DPMSSupported -- - * Return TRUE if any screen supports DPMS. - */ -Bool -DPMSSupported(void) -{ - int i; - - if (DPMSKey == NULL) { - return FALSE; - } - - /* For each screen, check if DPMS is supported */ - for (i = 0; i < xf86NumScreens; i++) { - if (DPMSSupportedOnScreen(xf86Screens[i])) - return TRUE; - } - for (i = 0; i < xf86NumGPUScreens; i++) { - if (DPMSSupportedOnScreen(xf86GPUScreens[i])) - return TRUE; - } - return FALSE; -} - -#endif /* DPMSExtension */ |