Bug 64591 - pbbuttonsd ambient light sensor fix
Bug#: 64591 Product:  Gentoo Linux Version: 2004.0 Platform: PPC
OS/Version: Linux Status: RESOLVED Severity: normal Priority: P2
Resolution: UPSTREAM Assigned To: ppc@gentoo.org Reported By: jrray@jrray.org
Component: Applications
URL: 
Summary: pbbuttonsd ambient light sensor fix
Keywords:  
Status Whiteboard: 
Opened: 2004-09-18 22:21 0000
Description:   Opened: 2004-09-18 22:21 0000
On my new 15" powerbook g4, pbbuttonsd fails to properly detect the correct i2c
device for the ambient light sensor and also the keyboard illumination
controls.

Both the unmasked 0.6.1 and masked 0.6.5 versions have the same problem.  When
it goes to detect which device to use, it starts with dev 0 and works up. 
/dev/i2c-0 looks valid but the ambient light sensor always reports a light
level of 0.

When I change the code so that it starts searching at dev 1, it discovers the
correct device at /dev/i2c-4.  The ambient light sensor reports valid data and
the keyboard illumination works properly.

E.g.:

diff -rNu pbbuttonsd-0.6.5/src/module_pmac.c
pbbuttonsd-0.6.5-jrray/src/module_pmac.c
--- pbbuttonsd-0.6.5/src/module_pmac.c  2004-09-08 13:01:41.000000000 -0700
+++ pbbuttonsd-0.6.5-jrray/src/module_pmac.c    2004-09-18 21:26:35.431804672
-0700
@@ -979,7 +979,7 @@
        char i2cdevice[20], buf[4];
        int n, fd, rc = -E_NOCHAR;

-       for(n=0; n < 256; n++) {
+       for(n=1; n < 256; n++) {
                snprintf(i2cdevice, 19, "/dev/i2c-%d", n );
                if ((fd = open (i2cdevice, O_RDWR)) >= 0 ) {
                        if (ioctl (fd, I2C_SLAVE, LMU_ADDR) >= 0 ) {

Based on this mailing list thread:
http://lists.debian.org/debian-powerpc/2004/01/msg00546.html

It seems that some powerbooks require /dev/i2c-4 and some require /dev/i2c-0. 
The pbbuttonsd code should probably be modified to make this a
user-configurable option.

- Robert

------- Comment #1 From Douglas Russell (RETIRED) 2004-09-20 05:02:42 0000 -------
This should be reported upstream.

------- Comment #2 From Pieter Van den Abeele 2004-09-22 14:40:11 0000 -------
Puggy, can you apply this one-line patch in cvs and report upstream?

------- Comment #3 From J Robert Ray 2004-09-23 00:13:55 0000 -------
I'm fairly certain that applying my patch will break pbbuttonsd for some people
while fixing it for others.  The upstream developer will probably know better
how to fix it for everyone.

------- Comment #4 From Pieter Van den Abeele 2004-09-24 15:25:51 0000 -------
I've pointed the upstream developer to this bug & patch. Thnxs for the
feedback.

------- Comment #5 From Pieter Van den Abeele 2004-09-25 04:17:32 0000 -------
Created an attachment (id=40364) [details]
upstream patch

Upstream test request

------- Comment #6 From Lars Weiler (RETIRED) 2004-10-05 19:29:57 0000 -------
I added the patch as long as it is not resolved upstream.