Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Removing ambient sensor support

  • Loading branch information...
commit 8d021b178dfb1e2d08f197214fff461f22582514 1 parent 361b17f
@bytbox authored
View
3  ChangeLog
@@ -1,6 +1,9 @@
ChangeLog for pommed
--------------------
+Version 1.41lw:
+ - pommed: remove ambient sensor support
+
version 1.40lw:
- pommed: remove dbus support
- gpomme: remove
View
4 README.md
@@ -1,8 +1,8 @@
About pommed-light
------------------
-This is a stripped-down version of pommed with client and dbus support removed,
-optimized for use with dwm and the like.
+This is a stripped-down version of pommed with client, dbus, and ambient light
+sensor support removed, optimized for use with dwm and the like.
README for pommed
-----------------
View
12 pommed/Makefile
@@ -27,7 +27,7 @@ OFLIB ?=
SOURCES = pommed.c cd_eject.c evdev.c conffile.c audio.c \
evloop.c power.c beep.c video.c \
sysfs_backlight.c pmac/pmu.c \
- pmac/kbd_backlight.c pmac/ambient.c
+ pmac/kbd_backlight.c
OF_SOURCES = pmac/ofapi/of_externals.c pmac/ofapi/of_internals.c \
pmac/ofapi/of_standard.c
@@ -63,7 +63,7 @@ SOURCES = pommed.c cd_eject.c evdev.c conffile.c audio.c \
sysfs_backlight.c \
mactel/x1600_backlight.c mactel/gma950_backlight.c \
mactel/nv8600mgt_backlight.c \
- mactel/kbd_backlight.c mactel/ambient.c mactel/acpi.c
+ mactel/kbd_backlight.c mactel/acpi.c
endif
OBJS = $(SOURCES:%.c=%.o)
@@ -92,9 +92,7 @@ video.o: video.c video.h pommed.h
sysfs_backlight.o: sysfs_backlight.c pommed.h lcd_backlight.h conffile.h
# PowerMac-specific files
-pmac/kbd_backlight.o: pmac/kbd_backlight.c kbd_auto.c kbd_backlight.h evloop.h pommed.h ambient.h conffile.h
-
-pmac/ambient.o: pmac/ambient.c ambient.h pommed.h
+pmac/kbd_backlight.o: pmac/kbd_backlight.c kbd_auto.c kbd_backlight.h evloop.h pommed.h conffile.h
pmac/pmu.o: pmac/pmu.c power.h
@@ -116,9 +114,7 @@ mactel/gma950_backlight.o: mactel/gma950_backlight.c pommed.h lcd_backlight.h co
mactel/nv8600mgt_backlight.o: mactel/nv8600mgt_backlight.c pommed.h lcd_backlight.h conffile.h
-mactel/kbd_backlight.o: mactel/kbd_backlight.c kbd_auto.c kbd_backlight.h evloop.h pommed.h ambient.h conffile.h
-
-mactel/ambient.o: mactel/ambient.c ambient.h pommed.h
+mactel/kbd_backlight.o: mactel/kbd_backlight.c kbd_auto.c kbd_backlight.h evloop.h pommed.h conffile.h
mactel/acpi.o: mactel/acpi.c power.h
View
46 pommed/ambient.h
@@ -1,46 +0,0 @@
-/*
- * pommed - ambient.h
- */
-
-#ifndef __AMBIENT_H__
-#define __AMBIENT_H__
-
-#define KBD_AMBIENT_MIN 0
-#define KBD_AMBIENT_MAX 255
-
-#ifdef __powerpc__
-/* I2C ioctl */
-# define I2C_SLAVE 0x0703
-
-# define ADB_DEVICE "/dev/adb"
-# define ADB_BUFFER_SIZE 32
-
-struct _lmu_info
-{
- unsigned int lmuaddr; /* i2c bus address */
- char i2cdev[16]; /* i2c bus device */
-};
-
-extern struct _lmu_info lmu_info;
-
-#endif /* !__powerpc__ */
-
-
-struct _ambient_info
-{
- int left;
- int right;
- int max;
-};
-
-extern struct _ambient_info ambient_info;
-
-
-void
-ambient_get(int *r, int *l);
-
-void
-ambient_init(int *r, int *l);
-
-
-#endif /* !__AMBIENT_H__ */
View
47 pommed/kbd_auto.c
@@ -98,51 +98,6 @@ kbd_backlight_inhibit_toggle(int mask)
kbd_backlight_inhibit_set(mask);
}
-
-void
-kbd_backlight_ambient_check(void)
-{
- int amb_r, amb_l;
-
- ambient_get(&amb_r, &amb_l);
-
- if ((amb_r < 0) || (amb_l < 0))
- return;
-
- kbd_bck_info.r_sens = amb_r;
- kbd_bck_info.l_sens = amb_l;
-
- /* Inhibited */
- if (kbd_bck_info.inhibit)
- return;
-
- if ((amb_r < kbd_cfg.on_thresh) && (amb_l < kbd_cfg.on_thresh))
- {
- logdebug("Ambient light lower threshold reached\n");
-
- /* backlight already on */
- if (kbd_backlight_get() > KBD_BACKLIGHT_OFF)
- return;
-
- /* turn on backlight */
- kbd_bck_info.auto_on = 1;
-
- kbd_backlight_set(kbd_cfg.auto_lvl, KBD_AUTO);
- }
- else if (kbd_bck_info.auto_on)
- {
- if ((amb_r > kbd_cfg.off_thresh) || (amb_l > kbd_cfg.off_thresh))
- {
- logdebug("Ambient light upper threshold reached\n");
-
- kbd_bck_info.auto_on = 0;
-
- kbd_backlight_set(KBD_BACKLIGHT_OFF, KBD_AUTO);
- }
- }
-}
-
-
static void
kbd_auto_process(int id, uint64_t ticks)
{
@@ -150,8 +105,6 @@ kbd_auto_process(int id, uint64_t ticks)
kbd_bck_info.idle += KBD_TIMEOUT;
if ((kbd_cfg.idle > 0) && (kbd_bck_info.idle > 1000 * kbd_cfg.idle))
kbd_backlight_inhibit_set(KBD_INHIBIT_IDLE);
-
- kbd_backlight_ambient_check();
}
View
3  pommed/kbd_backlight.h
@@ -104,8 +104,5 @@ kbd_backlight_inhibit_clear(int mask);
void
kbd_backlight_inhibit_toggle(int mask);
-void
-kbd_backlight_ambient_check(void);
-
#endif /* !__KBD_BACKLIGHT_H__ */
View
167 pommed/mactel/ambient.c
@@ -1,167 +0,0 @@
-/*
- * pommed - Apple laptops hotkeys handler daemon
- *
- * Copyright (C) 2006-2007 Julien BLACHE <jb@jblache.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; version 2 of the License.
- *
- * 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 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 <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <dirent.h>
-#include <fcntl.h>
-#include <string.h>
-#include <errno.h>
-
-#include <syslog.h>
-
-#include "../pommed.h"
-#include "../ambient.h"
-
-
-#define HWMON_SYSFS_BASE "/sys/class/hwmon"
-static char *smcpath;
-
-
-struct _ambient_info ambient_info;
-
-
-void
-ambient_get(int *r, int *l)
-{
- int fd;
- int ret;
- char buf[16];
- char *p;
-
- if (!smcpath)
- goto out_error;
-
- fd = open(smcpath, O_RDONLY);
- if (fd < 0)
- goto out_error;
-
- ret = read(fd, buf, 16);
-
- close(fd);
-
- if ((ret <= 0) || (ret > 15))
- goto out_error;
-
- buf[strlen(buf)] = '\0';
-
- p = strchr(buf, ',');
- *p++ = '\0';
- *r = atoi(p);
-
- p = buf + 1;
- *l = atoi(p);
-
- logdebug("Ambient light: right %d, left %d\n", *r, *l);
-
- ambient_info.right = *r;
- ambient_info.left = *l;
-
- return;
-
- out_error:
- *r = -1;
- *l = -1;
-
- ambient_info.right = 0;
- ambient_info.left = 0;
-}
-
-
-void
-ambient_init(int *r, int *l)
-{
- char devpath[PATH_MAX];
- char devname[9];
- char *p;
- DIR *pdev;
- struct dirent *pdevent;
- int fd;
- int ret;
-
- smcpath = NULL;
-
- /* Probe for the applesmc sysfs path */
- pdev = opendir(HWMON_SYSFS_BASE);
- if (pdev != NULL)
- {
- while ((pdevent = readdir(pdev)))
- {
- if (pdevent->d_name[0] == '.')
- continue;
-
- ret = snprintf(devpath, sizeof(devpath), HWMON_SYSFS_BASE "/%s/device/name", pdevent->d_name);
- if ((ret < 0) || (ret >= sizeof(devpath)))
- {
- logmsg(LOG_WARNING, "Failed to build hwmon probe path");
- continue;
- }
-
- fd = open(devpath, O_RDONLY);
- if (fd < 0)
- {
- logmsg(LOG_ERR, "Could not open %s: %s", devpath, strerror(errno));
- continue;
- }
-
- memset(devname, 0, sizeof(devname));
- ret = read(fd, devname, sizeof(devname) - 1);
- close(fd);
-
- if (ret != (sizeof(devname) - 1))
- continue;
-
- if (strcmp(devname, "applesmc") == 0)
- {
- p = strrchr(devpath, '/');
- *p = '\0';
-
- logmsg(LOG_INFO, "Found applesmc at %s", devpath);
-
- smcpath = realpath(devpath, NULL);
- if (!smcpath)
- {
- logmsg(LOG_ERR, "Could not dereference applesmc device path: %s\n", strerror(errno));
- break;
- }
-
- logmsg(LOG_INFO, "Dereferenced applesmc to %s", smcpath);
-
- smcpath = realloc(smcpath, strlen(smcpath) + 1 + 6);
- if (!smcpath)
- break;
-
- strcat(smcpath, "/light");
-
- break;
- }
- }
-
- closedir(pdev);
- }
-
- ambient_get(r, l);
-
- ambient_info.max = KBD_AMBIENT_MAX;
- ambient_info.left = *l;
- ambient_info.right = *r;
-}
View
7 pommed/mactel/kbd_backlight.c
@@ -35,7 +35,6 @@
#include "../evloop.h"
#include "../conffile.h"
#include "../kbd_backlight.h"
-#include "../ambient.h"
struct _kbd_bck_info kbd_bck_info;
@@ -243,10 +242,6 @@ kbd_backlight_init(void)
kbd_bck_info.level = 0;
- ambient_info.left = 0;
- ambient_info.right = 0;
- ambient_info.max = 0;
-
return;
}
@@ -256,8 +251,6 @@ kbd_backlight_init(void)
kbd_bck_info.max = KBD_BACKLIGHT_MAX;
- ambient_init(&kbd_bck_info.r_sens, &kbd_bck_info.l_sens);
-
kbd_auto_init();
}
View
195 pommed/pmac/ambient.c
@@ -1,195 +0,0 @@
-/*
- * pommed - Apple laptops hotkeys handler daemon
- *
- * Copyright (C) 2006-2007 Julien BLACHE <jb@jblache.org>
- * Copyright (C) 2006 Yves-Alexis Perez <corsac@corsac.net>
- *
- * 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; version 2 of the License.
- *
- * 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 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 <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <string.h>
-
-#include <errno.h>
-#include <syslog.h>
-#include <sys/ioctl.h>
-
-#include <linux/adb.h>
-
-#include "../pommed.h"
-#include "../ambient.h"
-
-
-struct _ambient_info ambient_info;
-
-
-#define LMU_AMBIENT_MAX_RAW 1600
-
-#define PMU_AMBIENT_MAX_RAW 2048
-
-
-static void
-lmu_ambient_get(int *r, int *l)
-{
- int fd;
- int ret;
- char buf[4];
-
- fd = open(lmu_info.i2cdev, O_RDONLY);
- if (fd < 0)
- {
- *r = -1;
- *l = -1;
-
- ambient_info.right = 0;
- ambient_info.left = 0;
-
- logmsg(LOG_ERR, "Could not open i2c device %s: %s", lmu_info.i2cdev, strerror(errno));
- return;
- }
-
- ret = ioctl(fd, I2C_SLAVE, lmu_info.lmuaddr);
- if (ret < 0)
- {
- close(fd);
-
- *r = -1;
- *l = -1;
-
- ambient_info.right = 0;
- ambient_info.left = 0;
-
- logmsg(LOG_ERR, "ioctl failed on %s: %s", lmu_info.i2cdev, strerror(errno));
-
- return;
- }
-
- ret = read(fd, buf, 4);
- if (ret != 4)
- {
- close(fd);
-
- *r = -1;
- *l = -1;
-
- ambient_info.right = 0;
- ambient_info.left = 0;
-
- return;
- }
- close(fd);
-
- /* found in pbbuttonsd.conf */
- *r = (int) (((buf[0] << 8) | buf[1]) * KBD_AMBIENT_MAX) / LMU_AMBIENT_MAX_RAW;
- *l = (int) (((buf[2] << 8) | buf[3]) * KBD_AMBIENT_MAX) / LMU_AMBIENT_MAX_RAW;
-
- logdebug("Ambient light: right %d, left %d\n", *r, *l);
-
- ambient_info.right = *r;
- ambient_info.left = *l;
-}
-
-static void
-pmu_ambient_get(int *r, int *l)
-{
- int fd;
- int ret;
- char buf[ADB_BUFFER_SIZE];
-
- fd = open(ADB_DEVICE, O_RDWR);
- if (fd < 0)
- {
- *r = -1;
- *l = -1;
-
- ambient_info.right = 0;
- ambient_info.left = 0;
-
- logmsg(LOG_ERR, "Could not open ADB device %s: %s", ADB_DEVICE, strerror(errno));
- return;
- }
-
- buf[0] = PMU_PACKET;
- buf[1] = 0x4f; /* PMU command */
- buf[2] = 1;
-
- ret = write(fd, buf, 3);
- if (ret != 3)
- {
- *r = -1;
- *l = -1;
-
- ambient_info.right = 0;
- ambient_info.left = 0;
-
- logmsg(LOG_ERR, "Could not send PMU command: %s", strerror(errno));
- close(fd);
- return;
- }
-
- ret = read(fd, buf, ADB_BUFFER_SIZE);
- if (ret != 5)
- {
- *r = -1;
- *l = -1;
-
- ambient_info.right = 0;
- ambient_info.left = 0;
-
- logmsg(LOG_ERR, "Could not read PMU reply: %s", strerror(errno));
- close(fd);
- return;
- }
-
- close(fd);
-
- /* Taken from pbbuttonsd */
- *l = (int) (((buf[2] << 8) | buf[1]) * KBD_AMBIENT_MAX) / PMU_AMBIENT_MAX_RAW;
- *r = (int) (((buf[4] << 8) | buf[3]) * KBD_AMBIENT_MAX) / PMU_AMBIENT_MAX_RAW;
-
- logdebug("Ambient light: right %d, left %d\n", *r, *l);
-
- ambient_info.right = *r;
- ambient_info.left = *l;
-}
-
-void
-ambient_get(int *r, int *l)
-{
- if ((mops->type == MACHINE_POWERBOOK_58)
- || (mops->type == MACHINE_POWERBOOK_59))
- {
- pmu_ambient_get(r, l);
- }
- else
- {
- lmu_ambient_get(r, l);
- }
-}
-
-
-void
-ambient_init(int *r, int *l)
-{
- ambient_get(r, l);
-
- ambient_info.max = KBD_AMBIENT_MAX;
- ambient_info.left = *l;
- ambient_info.right = *r;
-}
View
7 pommed/pmac/kbd_backlight.c
@@ -43,7 +43,6 @@
#include "../evloop.h"
#include "../conffile.h"
#include "../kbd_backlight.h"
-#include "../ambient.h"
#define SYSFS_I2C_BASE "/sys/class/i2c-dev"
@@ -336,10 +335,6 @@ kbd_backlight_init(void)
kbd_bck_info.level = 0;
- ambient_info.left = 0;
- ambient_info.right = 0;
- ambient_info.max = 0;
-
return;
}
@@ -350,8 +345,6 @@ kbd_backlight_init(void)
kbd_bck_info.max = KBD_BACKLIGHT_MAX;
- ambient_init(&kbd_bck_info.r_sens, &kbd_bck_info.l_sens);
-
kbd_auto_init();
}
Please sign in to comment.
Something went wrong with that request. Please try again.