Package: pbbuttonsd
Version: 0.7.5-2
Severity: wishlist

pbbuttonsd currently use legacy ioctl to get/set LCD backlight. It
requires that CONFIG_PMAC_BACKLIGHT_LEGACY is set on the kernel config,
which is not currently the case on debian powerpc kernel. I've asked
this option to be set in .config, but it's not really a good option,
because the preferred way to access this information is now sysfs.

I've sent a patch (which I'll attach to this BR) on pbbuttonsd mailing
list, and I open this BR to track down possible issues. If patch is
accepted, it would be nice to have it included in debian package until
upstream release a new version.

Regards,

-- Yves-Alexis Perez


-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable'), (1, 
'experimental')
Architecture: powerpc (ppc)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.18-1-powerpc
Locale: [EMAIL PROTECTED], [EMAIL PROTECTED] (charmap=ISO-8859-15)

Versions of packages pbbuttonsd depends on:
ii  hdparm                       6.6-1       tune hard disk parameters for high
ii  libasound2                   1.0.12-1    ALSA library
ii  libc6                        2.3.6.ds1-4 GNU C Library: Shared libraries
ii  libgcc1                      1:4.1.1-14  GCC support library
ii  libglib2.0-0                 2.12.3-2    The GLib library of C routines
ii  libstdc++6                   4.1.1-14    The GNU Standard C++ Library v3
ii  lsb-base                     3.1-15      Linux Standard Base 3.1 init scrip
ii  makedev                      2.3.1-83    creates device files in /dev
ii  udev                         0.100-2     /dev/ and hotplug management daemo

Versions of packages pbbuttonsd recommends:
pn  laptop-mode-tools             <none>     (no description available)

-- no debconf information
diff -ur pbbuttonsd-0.7.5/src/module_pmac.c pbbuttonsd-0.7.5.new/src/module_pmac.c
--- pbbuttonsd-0.7.5/src/module_pmac.c	2006-03-23 21:25:10.000000000 +0100
+++ pbbuttonsd-0.7.5.new/src/module_pmac.c	2006-09-27 17:38:07.000000000 +0200
@@ -81,6 +81,8 @@
 #if defined(DEBUG) && SIMUAMBIENT
 	int ambient;
 #endif
+	int fd_get_bright;	/* actual_brightness file */
+	int fd_set_bright;	/* brightness file */
 } modbase_pmac;
 
 int
@@ -878,12 +880,19 @@
 pmac_get_lcdbacklight ()
 {
 	struct moddata_pmac *base = &modbase_pmac;
-	long val = 0;
-		
-	if ((ioctl(base->fd_pmu, PMU_IOC_GET_BACKLIGHT, &val)) == -1)
-		return -1;
+	int val = 0,n=0;
+	char buf[4];
 
-	return (int) val;
+	base->fd_get_bright = open(GET_BRIGHT_FILE, O_RDONLY);
+	if(base->fd_get_bright < 0)
+		return -1;
+	n = read(base->fd_get_bright,buf,3);
+	close(base->fd_get_bright);
+	if(n < 0)
+		return -1;
+	buf[n] = 0;
+	val = atoi(buf);
+	return val/8;
 }
 
 void
@@ -891,12 +900,22 @@
 {
 	struct moddata_pmac *base = &modbase_pmac;
 	int ambient;
+	char buf[4];
 	
 	if (val == -1)   /* no backlight controller available */
 		return;
 	
+	base->fd_set_bright = open(SET_BRIGHT_FILE,O_WRONLY);
+	if (base->fd_set_bright < 0)
+		return;
+
 	ambient = getRawAmbient () - base->lcdfeedback;
-	ioctl(base->fd_pmu, PMU_IOC_SET_BACKLIGHT, &val);
+	
+	
+	sprintf(buf,"%d",val*8);
+	write(base->fd_set_bright,buf,strlen(buf));
+	close(base->fd_set_bright);
+	
 	base->lcdfeedback = val ? getRawAmbient () - ambient : 0;
 
 #if defined(DEBUG) && (TESTAMBIENT || SIMUAMBIENT)
diff -ur pbbuttonsd-0.7.5/src/module_pmac.h pbbuttonsd-0.7.5.new/src/module_pmac.h
--- pbbuttonsd-0.7.5/src/module_pmac.h	2006-01-22 21:16:07.000000000 +0100
+++ pbbuttonsd-0.7.5.new/src/module_pmac.h	2006-09-27 17:24:43.000000000 +0200
@@ -30,6 +30,9 @@
 #define DEFAULT_BATCYCLE	"/var/lib/pbbuttons/battery.cycle"
 #define PATH_FNMODE		"/sys/module/usbhid/parameters/pb_fnmode"
 
+#define GET_BRIGHT_FILE	"/sys/class/backlight/radeonbl0/actual_brightness"
+#define SET_BRIGHT_FILE	"/sys/class/backlight/radeonbl0/brightness"
+
 /* definitions for input device config */
 #define TRACKPAD_NOTAP_NAME	"notap"
 #define TRACKPAD_TAP_NAME	"tap"

Reply via email to