summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Jackson <ajax@redhat.com>2017-03-24 12:30:57 -0400
committerAdam Jackson <ajax@redhat.com>2017-03-27 15:59:42 -0400
commit7f1ef9289d974fc2bacc968ae0b5d7714382cb9e (patch)
tree33d7e28931d3d8d7db698ce06a736f01de7075bb
parent8ed0b00fceb34cdb54a0ea113c3cdff3b4c9e7e1 (diff)
dix: Lift DPMS to a screen hook
Following on from the previous change, this adds a DPMS hook to the ScreenRec and uses that to infer DPMS support. As a result we can drop the dpms stub code from Xext. Signed-off-by: Adam Jackson <ajax@redhat.com> Reviewed-by: Eric Anholt <eric@anholt.net>
-rw-r--r--Xext/Makefile.am4
-rw-r--r--Xext/dpms.c64
-rw-r--r--Xext/dpmsstubs.c47
-rw-r--r--hw/dmx/dmxdpms.c69
-rw-r--r--hw/dmx/dmxdpms.h3
-rw-r--r--hw/dmx/dmxscrinit.c14
-rw-r--r--hw/kdrive/src/kdrive.c12
-rw-r--r--hw/vfb/Makefile.am1
-rw-r--r--hw/xfree86/common/xf86DPMS.c89
-rw-r--r--hw/xnest/Makefile.am6
-rw-r--r--hw/xwayland/Makefile.am1
-rw-r--r--hw/xwin/Makefile.am1
-rw-r--r--include/scrnintstr.h3
13 files changed, 114 insertions, 200 deletions
diff --git a/Xext/Makefile.am b/Xext/Makefile.am
index 1ceb9803d..32a27eba8 100644
--- a/Xext/Makefile.am
+++ b/Xext/Makefile.am
@@ -1,4 +1,4 @@
-noinst_LTLIBRARIES = libXext.la libXextdpmsstubs.la libXvidmode.la
+noinst_LTLIBRARIES = libXext.la libXvidmode.la
AM_CFLAGS = $(DIX_CFLAGS)
@@ -96,8 +96,6 @@ endif
libXext_la_SOURCES = $(BUILTIN_SRCS)
libXext_la_LIBADD = $(BUILTIN_LIBS)
-libXextdpmsstubs_la_SOURCES = dpmsstubs.c
-
# XVidMode extension
libXvidmode_la_SOURCES = vidmode.c
diff --git a/Xext/dpms.c b/Xext/dpms.c
index 291dad023..abc67ef1f 100644
--- a/Xext/dpms.c
+++ b/Xext/dpms.c
@@ -40,6 +40,70 @@ Equipment Corporation.
#include <X11/extensions/dpmsproto.h>
#include "dpmsproc.h"
#include "extinit.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+
+Bool
+DPMSSupported(void)
+{
+ int i;
+
+ /* For each screen, check if DPMS is supported */
+ for (i = 0; i < screenInfo.numScreens; i++)
+ if (screenInfo.screens[i]->DPMS != NULL)
+ return TRUE;
+
+ for (i = 0; i < screenInfo.numGPUScreens; i++)
+ if (screenInfo.gpuscreens[i]->DPMS != NULL)
+ return TRUE;
+
+ return FALSE;
+}
+
+static Bool
+isUnblank(int mode)
+{
+ switch (mode) {
+ case SCREEN_SAVER_OFF:
+ case SCREEN_SAVER_FORCER:
+ return TRUE;
+ case SCREEN_SAVER_ON:
+ case SCREEN_SAVER_CYCLE:
+ return FALSE;
+ default:
+ return TRUE;
+ }
+}
+
+int
+DPMSSet(ClientPtr client, int level)
+{
+ int rc, i;
+
+ DPMSPowerLevel = level;
+
+ if (level != DPMSModeOn) {
+ if (isUnblank(screenIsSaved)) {
+ rc = dixSaveScreens(client, SCREEN_SAVER_FORCER, ScreenSaverActive);
+ if (rc != Success)
+ return rc;
+ }
+ } else if (!isUnblank(screenIsSaved)) {
+ rc = dixSaveScreens(client, SCREEN_SAVER_OFF, ScreenSaverReset);
+ if (rc != Success)
+ return rc;
+ }
+
+ for (i = 0; i < screenInfo.numScreens; i++)
+ if (screenInfo.screens[i]->DPMS != NULL)
+ screenInfo.screens[i]->DPMS(screenInfo.screens[i], level);
+
+ for (i = 0; i < screenInfo.numGPUScreens; i++)
+ if (screenInfo.gpuscreens[i]->DPMS != NULL)
+ screenInfo.gpuscreens[i]->DPMS(screenInfo.gpuscreens[i], level);
+
+ return Success;
+}
static int
ProcDPMSGetVersion(ClientPtr client)
diff --git a/Xext/dpmsstubs.c b/Xext/dpmsstubs.c
deleted file mode 100644
index f05d1e9f9..000000000
--- a/Xext/dpmsstubs.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/*****************************************************************
-
-Copyright (c) 1996 Digital Equipment Corporation, Maynard, Massachusetts.
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
-BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
-IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of Digital Equipment Corporation
-shall not be used in advertising or otherwise to promote the sale, use or other
-dealings in this Software without prior written authorization from Digital
-Equipment Corporation.
-
-******************************************************************/
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "dpmsproc.h"
-
-#define FALSE 0
-
-Bool
-DPMSSupported(void)
-{
- return FALSE;
-}
-
-int
-DPMSSet(ClientPtr client, int level)
-{
- return Success;
-}
diff --git a/hw/dmx/dmxdpms.c b/hw/dmx/dmxdpms.c
index d53a3d998..15a2cbd8d 100644
--- a/hw/dmx/dmxdpms.c
+++ b/hw/dmx/dmxdpms.c
@@ -53,10 +53,7 @@
#include "windowstr.h" /* For screenIsSaved */
#include <X11/extensions/dpms.h>
-static unsigned long dpmsGeneration = 0;
-static Bool dpmsSupported = TRUE;
-
-static void
+static int
_dmxDPMSInit(DMXScreenInfo * dmxScreen)
{
int event_base, error_base;
@@ -65,14 +62,9 @@ _dmxDPMSInit(DMXScreenInfo * dmxScreen)
BOOL state;
const char *monitor;
- if (dpmsGeneration != serverGeneration) {
- dpmsSupported = TRUE; /* On unless a backend doesn't support it */
- dpmsGeneration = serverGeneration;
- }
-
#ifdef DPMSExtension
if (DPMSDisabledSwitch)
- dpmsSupported = FALSE; /* -dpms turns off */
+ return FALSE;
#endif
dmxScreen->dpmsCapable = 0;
@@ -80,25 +72,21 @@ _dmxDPMSInit(DMXScreenInfo * dmxScreen)
if (!dmxScreen->beDisplay) {
dmxLogOutput(dmxScreen,
"Cannot determine if DPMS supported (detached screen)\n");
- dpmsSupported = FALSE;
- return;
+ return FALSE;
}
if (!DPMSQueryExtension(dmxScreen->beDisplay, &event_base, &error_base)) {
dmxLogOutput(dmxScreen, "DPMS not supported\n");
- dpmsSupported = FALSE;
- return;
+ return FALSE;
}
if (!DPMSGetVersion(dmxScreen->beDisplay, &major, &minor)) {
dmxLogOutput(dmxScreen, "DPMS not supported\n");
- dpmsSupported = FALSE;
- return;
+ return FALSE;
}
if (!DPMSCapable(dmxScreen->beDisplay)) {
dmxLogOutput(dmxScreen, "DPMS %d.%d (not DPMS capable)\n",
major, minor);
- dpmsSupported = FALSE;
- return;
+ return FALSE;
}
DPMSInfo(dmxScreen->beDisplay, &level, &state);
@@ -134,20 +122,22 @@ _dmxDPMSInit(DMXScreenInfo * dmxScreen)
"DPMS %d.%d (%s, %s, %d %d %d)\n",
major, minor, monitor, state ? "enabled" : "disabled",
standby, suspend, off);
+ return TRUE;
}
/** Initialize DPMS support. We save the current settings and turn off
* DPMS. The settings are restored in #dmxDPMSTerm. */
-void
+int
dmxDPMSInit(DMXScreenInfo * dmxScreen)
{
int interval, preferBlanking, allowExposures;
/* Turn off DPMS */
- _dmxDPMSInit(dmxScreen);
+ if (!_dmxDPMSInit(dmxScreen))
+ return FALSE;
if (!dmxScreen->beDisplay)
- return;
+ return FALSE;
/* Turn off screen saver */
XGetScreenSaver(dmxScreen->beDisplay, &dmxScreen->savedTimeout, &interval,
@@ -156,6 +146,7 @@ dmxDPMSInit(DMXScreenInfo * dmxScreen)
preferBlanking, allowExposures);
XResetScreenSaver(dmxScreen->beDisplay);
dmxSync(dmxScreen, FALSE);
+ return TRUE;
}
/** Terminate DPMS support on \a dmxScreen. We restore the settings
@@ -199,38 +190,12 @@ dmxDPMSWakeup(void)
}
#ifdef DPMSExtension
-/** This is called on each server generation. It should determine if
- * DPMS is supported on all of the backends and, if so, return TRUE. */
-Bool
-DPMSSupported(void)
-{
- return dpmsSupported;
-}
-
-/** This is used by clients (e.g., xset) to set the DPMS level. */
-int
-DPMSSet(ClientPtr client, int level)
+void
+dmxDPMSBackend(DMXScreenInfo *dmxScreen, int level)
{
- int i;
-
- if (!dpmsSupported)
- return Success;
-
- if (level < 0)
- level = DPMSModeOn;
- if (level > 3)
- level = DPMSModeOff;
-
- DPMSPowerLevel = level;
-
- for (i = 0; i < dmxNumScreens; i++) {
- DMXScreenInfo *dmxScreen = &dmxScreens[i];
-
- if (dmxScreen->beDisplay) {
- DPMSForceLevel(dmxScreen->beDisplay, level);
- dmxSync(dmxScreen, FALSE);
- }
+ if (dmxScreen->beDisplay) {
+ DPMSForceLevel(dmxScreen->beDisplay, level);
+ dmxSync(dmxScreen, FALSE);
}
- return Success;
}
#endif
diff --git a/hw/dmx/dmxdpms.h b/hw/dmx/dmxdpms.h
index 772fa2f11..8c4fe9d4f 100644
--- a/hw/dmx/dmxdpms.h
+++ b/hw/dmx/dmxdpms.h
@@ -36,7 +36,8 @@
#ifndef _DMXDPMS_H_
#define _DMXDPMS_H_
-extern void dmxDPMSInit(DMXScreenInfo * dmxScreen);
+extern int dmxDPMSInit(DMXScreenInfo * dmxScreen);
extern void dmxDPMSTerm(DMXScreenInfo * dmxScreen);
extern void dmxDPMSWakeup(void); /* Call when input is processed */
+extern void dmxDPMSBackend(DMXScreenInfo *dmxScreen, int level);
#endif
diff --git a/hw/dmx/dmxscrinit.c b/hw/dmx/dmxscrinit.c
index e441dceef..ae095e300 100644
--- a/hw/dmx/dmxscrinit.c
+++ b/hw/dmx/dmxscrinit.c
@@ -75,6 +75,17 @@ DevPrivateKeyRec dmxColormapPrivateKeyRec;
DevPrivateKeyRec dmxPictPrivateKeyRec;
DevPrivateKeyRec dmxGlyphSetPrivateKeyRec;
+#ifdef DPMSExtension
+static void
+dmxDPMS(ScreenPtr pScreen, int level)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxDPMSBackend(dmxScreen, level);
+}
+#else
+#define dmxDPMS NULL
+#endif
+
/** Initialize the parts of screen \a idx that require access to the
* back-end server. */
void
@@ -103,7 +114,8 @@ dmxBEScreenInit(ScreenPtr pScreen)
pScreen->blackPixel = dmxScreen->beBlackPixel;
/* Handle screen savers and DPMS on the backend */
- dmxDPMSInit(dmxScreen);
+ if (dmxDPMSInit(dmxScreen))
+ pScreen->DPMS = dmxDPMS;
/* Create root window for screen */
mask = CWBackPixel | CWEventMask | CWColormap | CWOverrideRedirect;
diff --git a/hw/kdrive/src/kdrive.c b/hw/kdrive/src/kdrive.c
index b2b499669..5d2f403d6 100644
--- a/hw/kdrive/src/kdrive.c
+++ b/hw/kdrive/src/kdrive.c
@@ -1193,18 +1193,6 @@ OsVendorFatalError(const char *f, va_list args)
{
}
-int
-DPMSSet(ClientPtr client, int level)
-{
- return Success;
-}
-
-Bool
-DPMSSupported(void)
-{
- return FALSE;
-}
-
/* These stubs can be safely removed once we can
* split input and GPU parts in hotplug.h et al. */
#ifdef CONFIG_UDEV_KMS
diff --git a/hw/vfb/Makefile.am b/hw/vfb/Makefile.am
index f0f9fee47..70333976c 100644
--- a/hw/vfb/Makefile.am
+++ b/hw/vfb/Makefile.am
@@ -16,7 +16,6 @@ XVFB_LIBS = \
@XVFB_LIBS@ \
$(MAIN_LIB) \
$(XSERVER_LIBS) \
- $(top_builddir)/Xext/libXextdpmsstubs.la \
$(top_builddir)/Xi/libXistubs.la
Xvfb_LDADD = $(XVFB_LIBS) $(XVFB_SYS_LIBS) $(XSERVER_SYS_LIBS)
diff --git a/hw/xfree86/common/xf86DPMS.c b/hw/xfree86/common/xf86DPMS.c
index a5324e0b1..ee495483e 100644
--- a/hw/xfree86/common/xf86DPMS.c
+++ b/hw/xfree86/common/xf86DPMS.c
@@ -47,6 +47,19 @@
#include "xf86VGAarbiter.h"
#endif
+#ifdef DPMSExtension
+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
xf86DPMSInit(ScreenPtr pScreen, DPMSSetProcPtr set, int flags)
{
@@ -69,84 +82,10 @@ xf86DPMSInit(ScreenPtr pScreen, DPMSSetProcPtr set, int flags)
if (enabled) {
xf86DrvMsg(pScreen->myNum, enabled_from, "DPMS enabled\n");
pScrn->DPMSSet = set;
+ pScreen->DPMS = xf86DPMS;
}
return TRUE;
#else
return FALSE;
#endif
}
-
-#ifdef DPMSExtension
-
-static void
-DPMSSetScreen(ScrnInfoPtr pScrn, int level)
-{
- if (pScrn->DPMSSet && 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 (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)
-{
- return pScrn->DPMSSet != NULL;
-}
-
-/*
- * DPMSSupported --
- * Return TRUE if any screen supports DPMS.
- */
-Bool
-DPMSSupported(void)
-{
- int i;
-
- /* 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 */
diff --git a/hw/xnest/Makefile.am b/hw/xnest/Makefile.am
index eb550c0f7..c77da6412 100644
--- a/hw/xnest/Makefile.am
+++ b/hw/xnest/Makefile.am
@@ -45,7 +45,6 @@ SRCS = Args.c \
XNEST_LIBS = \
@XNEST_LIBS@ \
- $(top_builddir)/Xext/libXextdpmsstubs.la \
$(top_builddir)/Xi/libXistubs.la
Xnest_SOURCES = $(SRCS)
@@ -57,10 +56,5 @@ Xnest_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
EXTRA_DIST = icon \
screensaver
-# -UDPMSExtension for miinitext? can't put into
-# OS_DEFINES???
-# EXT_DEFINES???
-# ICONFIGFILES -- SpecialCObjectRule
-
relink:
$(AM_V_at)rm -f Xnest$(EXEEXT) && $(MAKE) Xnest$(EXEEXT)
diff --git a/hw/xwayland/Makefile.am b/hw/xwayland/Makefile.am
index a3c9fce48..770e87f9b 100644
--- a/hw/xwayland/Makefile.am
+++ b/hw/xwayland/Makefile.am
@@ -18,7 +18,6 @@ Xwayland_SOURCES = \
xwayland-cvt.c \
xwayland-vidmode.c \
xwayland.h \
- $(top_srcdir)/Xext/dpmsstubs.c \
$(top_srcdir)/Xi/stubs.c \
$(top_srcdir)/mi/miinitext.c
diff --git a/hw/xwin/Makefile.am b/hw/xwin/Makefile.am
index 0846230b0..e71240a79 100644
--- a/hw/xwin/Makefile.am
+++ b/hw/xwin/Makefile.am
@@ -138,7 +138,6 @@ XWIN_SYS_LIBS += -ldxguid
XWIN_LIBS += \
$(top_builddir)/pseudoramiX/libPseudoramiX.la \
- $(top_builddir)/Xext/libXextdpmsstubs.la \
$(top_builddir)/Xi/libXistubs.la
XWin_DEPENDENCIES = \
diff --git a/include/scrnintstr.h b/include/scrnintstr.h
index f174549c4..207289a91 100644
--- a/include/scrnintstr.h
+++ b/include/scrnintstr.h
@@ -400,6 +400,8 @@ typedef WindowPtr (*XYToWindowProcPtr)(ScreenPtr pScreen,
typedef int (*NameWindowPixmapProcPtr)(WindowPtr, PixmapPtr, CARD32);
+typedef void (*DPMSProcPtr)(ScreenPtr pScreen, int level);
+
/* Wrapping Screen procedures
There are a few modules in the X server which dynamically add and
@@ -657,6 +659,7 @@ typedef struct _Screen {
ReplaceScanoutPixmapProcPtr ReplaceScanoutPixmap;
XYToWindowProcPtr XYToWindow;
+ DPMSProcPtr DPMS;
} ScreenRec;
static inline RegionPtr