changeset 327:f3f77cbd58f3 trunk

[svn] Add support for Apple PMU front LED to Rocklight. Tested on PowerBook 5,9; works but is rather slow to update.
author chainsaw
date Sat, 02 Dec 2006 18:17:14 -0800
parents 90a843d02970
children a4d2caa1da63
files ChangeLog configure.ac mk/rules.mk.in src/rocklight/Makefile src/rocklight/apple_pmu.c
diffstat 5 files changed, 67 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Dec 02 14:43:27 2006 -0800
+++ b/ChangeLog	Sat Dec 02 18:17:14 2006 -0800
@@ -1,3 +1,12 @@
+2006-12-02 22:43:27 +0000  William Pitcock <nenolod@nenolod.net>
+  revision [716]
+  - some OSes use macros for some f*() functions, therefore make sure we 
+    properly cast our opaque data to a FILE* struct.
+  
+  trunk/src/stdio/stdio.c |   57 ++++++++++++++++++++++++++++++++++++++----------
+  1 file changed, 46 insertions(+), 11 deletions(-)
+
+
 2006-12-01 08:03:10 +0000  William Pitcock <nenolod@nenolod.net>
   revision [714]
   - disable the playlist when loading = false.
--- a/configure.ac	Sat Dec 02 14:43:27 2006 -0800
+++ b/configure.ac	Sat Dec 02 18:17:14 2006 -0800
@@ -341,9 +341,13 @@
         AC_SUBST(LIBNMS_SRC)
 fi
 
-dnl *** ThinkLight support
+dnl *** Rocklight
 
-AC_CHECK_FILE([/proc/acpi/ibm/light], [VISUALIZATION_PLUGINS="$VISUALIZATION_PLUGINS rocklight"])
+AC_CHECK_FILE([/proc/acpi/ibm/light], [VISUALIZATION_PLUGINS="$VISUALIZATION_PLUGINS rocklight"
+				       LEDCODE=thinklight.c])
+AC_CHECK_FILE([/sys/class/leds/pmu-front-led/brightness], [VISUALIZATION_PLUGINS="$VISUALIZATION_PLUGINS rocklight"
+				       			   LEDCODE=apple_pmu.c])
+AC_SUBST(LEDCODE)
 
 dnl *** LIRC client libraries
 
--- a/mk/rules.mk.in	Sat Dec 02 14:43:27 2006 -0800
+++ b/mk/rules.mk.in	Sat Dec 02 18:17:14 2006 -0800
@@ -194,6 +194,7 @@
 JACK_CFLAGS ?= @JACK_CFLAGS@
 JACK_LIBS ?= @JACK_LIBS@
 LDFLAGS ?= @LDFLAGS@
+LEDCODE ?= @LEDCODE@
 LIBBEEP_MAJOR_VERSION ?= @LIBBEEP_MAJOR_VERSION@
 LIBBEEP_MICRO_VERSION ?= @LIBBEEP_MICRO_VERSION@
 LIBBEEP_MINOR_VERSION ?= @LIBBEEP_MINOR_VERSION@
--- a/src/rocklight/Makefile	Sat Dec 02 14:43:27 2006 -0800
+++ b/src/rocklight/Makefile	Sat Dec 02 18:17:14 2006 -0800
@@ -7,7 +7,7 @@
 
 LIBADD = $(GTK_LIBS)
 
-SOURCES = rocklight.c thinklight.c
+SOURCES = rocklight.c $(LEDCODE)
 
 OBJECTS = ${SOURCES:.c=.o}
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/rocklight/apple_pmu.c	Sat Dec 02 18:17:14 2006 -0800
@@ -0,0 +1,50 @@
+/***************************************************************************
+ *            apple_pmu.c
+ *
+ *  Sun Dec 03 01:07:42 2006
+ *  Copyright  2006  Tony 'Chainsaw' Vroon
+ *  chainsaw@gentoo.org
+ ****************************************************************************/
+
+/*
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+ 
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+int thinklight_open(void) {
+	return open("/sys/class/leds/pmu-front-led/brightness",O_RDWR);
+}
+
+void thinklight_close(int fd) {
+	close(fd);	
+}
+
+int thinklight_set(int fd, int state) {
+	return write(fd,state?"255\n":"0\n",state?2:4);
+}
+
+int thinklight_get(int fd) {
+	char buf[256];
+	int ret=read(fd,&buf,sizeof(buf));
+	
+	if(atoi(buf) == 255)
+		return 1;
+	else
+		return 0;
+}