[Pommed-commits] r339 - in trunk: . pommed pommed/mactel
jblache at alioth.debian.org
jblache at alioth.debian.org
Sun Jul 15 20:23:28 UTC 2007
Author: jblache
Date: 2007-07-15 20:23:28 +0000 (Sun, 15 Jul 2007)
New Revision: 339
Modified:
trunk/ChangeLog
trunk/pommed/ambient.h
trunk/pommed/mactel/ambient.c
Log:
Probe for the applesmc sysfs path in the ambien light handling code. The path has changed in 2.6.22 and includes a new component in the directory name (/sys/devices/platform/applesmc.768 on my machine).
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2007-07-15 20:22:32 UTC (rev 338)
+++ trunk/ChangeLog 2007-07-15 20:23:28 UTC (rev 339)
@@ -1,6 +1,10 @@
ChangeLog for pommed
--------------------
+version 1.8:
+ - pommed: probe for the applesmc sysfs path in the ambient light
+ handling code. The path has changed in Linux 2.6.22.
+
version 1.7:
- pommed: add partial support for the MacBookPro3,1 (Core2 Duo,
15" & 17", June 2007). New Apple IR receiver too. Missing nVidia
Modified: trunk/pommed/ambient.h
===================================================================
--- trunk/pommed/ambient.h 2007-07-15 20:22:32 UTC (rev 338)
+++ trunk/pommed/ambient.h 2007-07-15 20:23:28 UTC (rev 339)
@@ -8,9 +8,7 @@
#define KBD_AMBIENT_MIN 0
#define KBD_AMBIENT_MAX 255
-#ifndef __powerpc__
-# define KBD_AMBIENT_SENSOR "/sys/devices/platform/applesmc/light"
-#else
+#ifdef __powerpc__
/* I2C ioctl */
# define I2C_SLAVE 0x0703
Modified: trunk/pommed/mactel/ambient.c
===================================================================
--- trunk/pommed/mactel/ambient.c 2007-07-15 20:22:32 UTC (rev 338)
+++ trunk/pommed/mactel/ambient.c 2007-07-15 20:23:28 UTC (rev 339)
@@ -24,13 +24,20 @@
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <dirent.h>
#include <fcntl.h>
#include <string.h>
+#include <syslog.h>
+
#include "../pommed.h"
#include "../ambient.h"
+#define APPLESMC_SYSFS_BASE "/sys/devices/platform"
+static char smcpath[64];
+
+
struct _ambient_info ambient_info;
@@ -42,7 +49,7 @@
char buf[16];
char *p;
- fd = open(KBD_AMBIENT_SENSOR, O_RDONLY);
+ fd = open(smcpath, O_RDONLY);
if (fd < 0)
{
*r = -1;
@@ -88,6 +95,37 @@
void
ambient_init(int *r, int *l)
{
+ DIR *pdev;
+ struct dirent *pdevent;
+
+ int ret;
+
+ /* Probe for the applesmc sysfs path */
+ pdev = opendir(APPLESMC_SYSFS_BASE);
+ if (pdev != NULL)
+ {
+ while ((pdevent = readdir(pdev)))
+ {
+ if (pdevent->d_type != DT_DIR)
+ continue;
+
+ if (strstr(pdevent->d_name, "applesmc") == pdevent->d_name)
+ {
+ ret = snprintf(smcpath, sizeof(smcpath), "%s/%s/light",
+ APPLESMC_SYSFS_BASE, pdevent->d_name);
+
+ if ((ret < 0) || (ret >= sizeof(smcpath)))
+ logmsg(LOG_ERR, "Failed to build applesmc sysfs path");
+ else
+ logmsg(LOG_INFO, "Found applesmc at %s", smcpath);
+
+ break;
+ }
+ }
+
+ closedir(pdev);
+ }
+
ambient_get(r, l);
ambient_info.max = KBD_AMBIENT_MAX;
More information about the Pommed-commits
mailing list