open-src/app/xset/xsetfbpm.patch
author Alan Coopersmith <Alan.Coopersmith@Sun.COM>
Tue, 02 Mar 2010 13:31:46 -0800
changeset 919 425233ae7236
parent 371 d0a78a85764b
child 943 294f64612d23
permissions -rw-r--r--
6931307 Standardize Sun copyright & license notices in X gate on current format

# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
# 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, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice (including the next
# paragraph) 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
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 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.
Adds support for Sun's Frame Buffer Power Management (fbpm) extension

diff -urp -x '*~' -x '*.orig' xset.c xset.c
--- xset.c	2008-03-06 14:28:40.000000000 -0800
+++ xset.c	2008-03-19 09:53:30.880805000 -0700
@@ -74,6 +74,10 @@ in this Software without prior written a
 #endif
 #ifdef DPMSExtension
 # include <X11/extensions/dpms.h>
+# define FBPM /* need to check for fbpm.h in autoconf if we push upstream */
+# ifdef FBPM
+#  include <X11/extensions/fbpm.h>
+# endif
 # ifdef WIN32
 #  define BOOL wBOOL
 #  ifdef Status
@@ -650,6 +654,62 @@ main(int argc, char *argv[])
 	    }
 	}
 #endif /* DPMSExtension */
+#ifdef FBPM
+	else if (strcmp(arg, "+fbpm") == 0) {	/* turn on FBPM */
+	    int             dummy;
+
+	    if (FBPMQueryExtension(dpy, &dummy, &dummy)) {
+		FBPMEnable(dpy, 0);
+	    } else {
+		fprintf(stderr,
+			"server does not have extension for +fbpm option\n");
+	    }
+	} else if (strcmp(arg, "-fbpm") == 0) {	/* shut off FBPM	 */
+	    int             dummy;
+	    
+	    if (FBPMQueryExtension(dpy, &dummy, &dummy)) {
+		FBPMDisable(dpy);
+	    } else {
+		fprintf(stderr,
+			"server does not have extension for -fbpm option\n");
+	    }
+	} else if (strcmp(arg, "fbpm") == 0) {	/* planing for force fbpm */
+	    int             dummy;
+
+	    if ((i + 1) >= argc) {
+		usage("missing arguments to -fpbm", NULL);
+	    } else {
+		/*
+		 * we are skipping the word 'force'... just
+		 * check to make sure its there
+		 */
+		arg = nextarg(i, argv);
+		if (strcmp(arg, "force") != 0) {	/* ack ! */
+		    fprintf(stderr, "bad parameter %s [needs force]\n", arg);
+		    break;
+		}
+	    }
+	    i++;
+	    arg = nextarg(i, argv);
+	    i++;
+	    if (FBPMQueryExtension(dpy, &dummy, &dummy)) {
+		if (strcmp(arg, "on") == 0) {
+		    FBPMEnable(dpy, FBPMModeOn);
+		} else if (strcmp(arg, "standby") == 0) {
+		    FBPMEnable(dpy, FBPMModeStandby);
+		} else if (strcmp(arg, "suspend") == 0) {
+		    FBPMEnable(dpy, FBPMModeSuspend);
+		} else if (strcmp(arg, "off") == 0) {
+		    FBPMEnable(dpy, FBPMModeOff);
+		} else {
+		    fprintf(stderr, "bad parameter %s\n", arg);
+		}
+	    } else {
+		fprintf(stderr,
+			"server does not have extension for fbpm option\n");
+	    }
+	}
+#endif
 	else if (strcmp(arg, "s") == 0) {
 	    if (i >= argc) {
 		set_saver(dpy, ALL, 0);	/* Set everything to default  */
@@ -1421,6 +1481,46 @@ query(Display *dpy)
 	}
     }
 #endif
+#ifdef FBPM
+    {
+	int             dummy;
+	CARD16          standby, suspend, off;
+	BOOL            onoff;
+	CARD16          state;
+
+	printf("FBPM (Frame Buffer Power Management):\n");
+	if (FBPMQueryExtension(dpy, &dummy, &dummy)) {
+	    if (FBPMCapable(dpy)) {
+		FBPMInfo(dpy, &state, &onoff);
+		if (onoff) {
+		    printf("  FBPM is enabled\n");
+		    switch (state) {
+		    case FBPMModeOn:
+			printf("  Frame Buffer is on\n");
+			break;
+		    case FBPMModeStandby:
+			printf("  Frame Buffer is in standby\n");
+			break;
+		    case FBPMModeSuspend:
+			printf("  Frame Buffer is in suspend\n");
+			break;
+		    case FBPMModeOff:
+			printf("  Frame Buffer is off\n");
+			break;
+		    default:
+			printf("  Unrecognized response from server\n");
+		    }
+		} else {
+		    printf("  FBPM is disabled\n");
+		}
+	    } else {
+		printf("  System is not capable of FBPM\n");
+	    }
+	} else {
+	    printf("  Server does not have the FBPM Extension\n");
+	}
+    }
+#endif   
 #ifdef FONTCACHE
     {
 	int dummy;
@@ -1551,6 +1651,16 @@ usage(char *fmt, ...)
     fprintf(stderr, "\t      (also implicitly enables DPMS features) \n");
     fprintf(stderr, "\t      a timeout value of zero disables the mode \n");
 #endif
+#ifdef FBPM
+    fprintf(stderr, "    To control Frame Buffer Power Management (FBPM) features:\n");
+    fprintf(stderr, "\t-fbpm      Frame Buffer Power Management features off\n");
+    fprintf(stderr, "\t+fbpm      Frame Buffer Power Management features on\n");
+    fprintf(stderr, "\t fbpm force on     \n");
+    fprintf(stderr, "\t      force standby \n");
+    fprintf(stderr, "\t      force suspend \n");
+    fprintf(stderr, "\t      force off \n");
+    fprintf(stderr, "\t      (also implicitly enables FBPM features) \n");
+#endif  
 #ifdef FONTCACHE
     fprintf(stderr, "    To control font cache:\n");
     fprintf(stderr, "\t fc [hi-mark [low-mark [balance]]]\n");