summaryrefslogtreecommitdiff
path: root/src/geode_dcon.c
diff options
context:
space:
mode:
authorJordan Crouse <jordan.crouse@amd.com>2008-06-10 12:08:53 -0600
committerJordan Crouse <jordan.crouse@amd.com>2008-06-10 14:18:54 -0600
commit2fc546c0d129fe7d3edee6b0cbfd530de33e2209 (patch)
treea0c61280f087c577b5e9568a8f72bd22ea265ba8 /src/geode_dcon.c
parent489546dfd2dd295db63f31e123b0073a6fa330a9 (diff)
geode: Bring over the DCON detection code from the OLPC tree
Diffstat (limited to 'src/geode_dcon.c')
-rw-r--r--src/geode_dcon.c47
1 files changed, 46 insertions, 1 deletions
diff --git a/src/geode_dcon.c b/src/geode_dcon.c
index 27cad18..fc887f7 100644
--- a/src/geode_dcon.c
+++ b/src/geode_dcon.c
@@ -35,11 +35,56 @@
#include "geode.h"
#include <unistd.h>
+#include <fcntl.h>
+
+#define DCON_SLEEP_FILE "/sys/devices/platform/dcon/sleep"
static Bool
dcon_present(void)
{
- return access("/sys/devices/platform/dcon", F_OK) == 0;
+ static int _dval = -1;
+
+ if (_dval == -1)
+ _dval = (access("/sys/devices/platform/dcon", F_OK) == 0);
+
+ return (Bool) _dval;
+}
+
+int
+DCONDPMSSet(ScrnInfoPtr pScrni, int mode, int flags)
+{
+ static int failed = -1;
+ int fd;
+ char value[1];
+
+ if (failed == -1)
+ failed = !dcon_present();
+
+ if (failed)
+ return 0;
+
+ fd = open(DCON_SLEEP_FILE, O_WRONLY);
+
+ if (fd < 0) {
+ failed = 1;
+ return 0;
+ }
+
+ switch (mode) {
+ case DPMSModeOn:
+ value[0] = '0';
+ break;
+ case DPMSModeStandby:
+ case DPMSModeSuspend:
+ case DPMSModeOff:
+ value[0] = '1';
+ break;
+ }
+
+ write(fd, value, sizeof(value));
+ close(fd);
+
+ return 1;
}
Bool