comparison src/rocklight/apple_pmu.c @ 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
children
comparison
equal deleted inserted replaced
326:90a843d02970 327:f3f77cbd58f3
1 /***************************************************************************
2 * apple_pmu.c
3 *
4 * Sun Dec 03 01:07:42 2006
5 * Copyright 2006 Tony 'Chainsaw' Vroon
6 * chainsaw@gentoo.org
7 ****************************************************************************/
8
9 /*
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Library General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 */
24
25 #include <sys/types.h>
26 #include <sys/stat.h>
27 #include <fcntl.h>
28 #include <unistd.h>
29
30 int thinklight_open(void) {
31 return open("/sys/class/leds/pmu-front-led/brightness",O_RDWR);
32 }
33
34 void thinklight_close(int fd) {
35 close(fd);
36 }
37
38 int thinklight_set(int fd, int state) {
39 return write(fd,state?"255\n":"0\n",state?2:4);
40 }
41
42 int thinklight_get(int fd) {
43 char buf[256];
44 int ret=read(fd,&buf,sizeof(buf));
45
46 if(atoi(buf) == 255)
47 return 1;
48 else
49 return 0;
50 }