Package: gnome-power-manager
Version: 2.22.1-1
Severity: normal
Tags: patch


Hi

On EeePC when you press Fn-F4 hardware automatically sets brightness one
step higher, but also emits an ACPI event. Hardware like this has HAL 
property "laptop_panel.brightness_in_hardware" set to "True" to notify
software like g-p-m that they shouldn't touch brightness settings on
ACPI events.

However g-p-m doesn't respect this and will in some cases make changes
to the brightness setting that contradict the firmware (there seemed to
be some support for "brightness_in_hardware" in 2.15, but it was removed
in later versions).

The specific problem I'm having is on Eee PC where pressing the
brightness hotkeys will sometimes make g-p-m mess up the brightness
setting (the "current_hw != brightness->priv->last_set_hw" check doesn't
seem to work in all cases - maybe there's a race condition with the
hardware). But I'm guessing this could also cause problems on other laptops.

I'm attaching a patch that fixes this problem for me. It basically
reintroduces code that was removed since version 2.15.

Best regards
Tomaz

-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)

Kernel: Linux 2.6.23-1-686 (SMP w/1 CPU core)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages gnome-power-manager depends on:
ii  gconf2                 2.22.0-1          GNOME configuration database syste
ii  hal                    0.5.11~rc2-1      Hardware Abstraction Layer
ii  libart-2.0-2           2.3.20-1          Library of functions for 2D graphi
ii  libatk1.0-0            1.22.0-1          The ATK accessibility toolkit
ii  libbonobo2-0           2.22.0-1          Bonobo CORBA interfaces library
ii  libbonoboui2-0         2.22.0-1          The Bonobo UI library
ii  libc6                  2.7-10            GNU C Library: Shared libraries
ii  libcairo2              1.6.4-1+b1        The Cairo 2D vector graphics libra
ii  libdbus-1-3            1.2.1-2           simple interprocess messaging syst
ii  libdbus-glib-1-2       0.74-2            simple interprocess messaging syst
ii  libfontconfig1         2.5.0-2           generic font configuration library
ii  libfreetype6           2.3.5-1+b1        FreeType 2 font engine, shared lib
ii  libgconf2-4            2.22.0-1          GNOME configuration database syste
ii  libglade2-0            1:2.6.2-1         library to load .glade files at ru
ii  libglib2.0-0           2.16.3-2          The GLib library of C routines
ii  libgnome-keyring0      2.22.1-1          GNOME keyring services library
ii  libgnome2-0            2.20.1.1-1        The GNOME 2 library - runtime file
ii  libgnomecanvas2-0      2.20.1.1-1        A powerful object-oriented display
ii  libgnomeui-0           2.20.1.1-1        The GNOME 2 libraries (User Interf
ii  libgnomevfs2-0         1:2.22.0-2        GNOME Virtual File System (runtime
ii  libgstreamer0.10-0     0.10.19-3         Core GStreamer libraries and eleme
ii  libgtk2.0-0            2.12.9-3          The GTK+ graphical user interface 
ii  libhal1                0.5.11~rc2-1      Hardware Abstraction Layer - share
ii  libice6                2:1.0.4-1         X11 Inter-Client Exchange library
ii  libnotify1 [libnotify1 0.4.4-3           sends desktop notifications to a n
ii  liborbit2              1:2.14.12-0.1     libraries for ORBit2 - a CORBA ORB
ii  libpanel-applet2-0     2.20.3-3          library for GNOME Panel applets
ii  libpango1.0-0          1.20.2-2          Layout and rendering of internatio
ii  libpixman-1-0          0.10.0-2          pixel-manipulation library for X a
ii  libpng12-0             1.2.27-1          PNG library - runtime
ii  libpopt0               1.10-3            lib for parsing cmdline parameters
ii  libsm6                 2:1.0.3-1+b1      X11 Session Management library
ii  libwnck22              2.22.1-1          Window Navigator Construction Kit 
ii  libx11-6               2:1.0.3-7         X11 client-side library
ii  libxcursor1            1:1.1.9-1         X cursor management library
ii  libxext6               2:1.0.4-1         X11 miscellaneous extension librar
ii  libxfixes3             1:4.0.3-2         X11 miscellaneous 'fixes' extensio
ii  libxi6                 2:1.1.3-1         X11 Input extension library
ii  libxinerama1           2:1.0.3-1         X11 Xinerama extension library
ii  libxml2                2.6.32.dfsg-2     GNOME XML library
ii  libxrandr2             2:1.2.2-1         X11 RandR extension library
ii  libxrender1            1:0.9.4-1         X Rendering Extension client libra
ii  notification-daemon    0.3.7-1+b1        a daemon that displays passive pop
ii  zlib1g                 1:1.2.3.3.dfsg-12 compression library - runtime

gnome-power-manager recommends no packages.

-- no debconf information
diff -ru gnome-power-manager-2.22.1.orig/src/gpm-brightness-lcd.c gnome-power-manager-2.22.1/src/gpm-brightness-lcd.c
--- gnome-power-manager-2.22.1.orig/src/gpm-brightness-lcd.c	2008-03-10 22:49:46.000000000 +0100
+++ gnome-power-manager-2.22.1/src/gpm-brightness-lcd.c	2008-05-02 18:49:20.000000000 +0200
@@ -53,6 +53,9 @@
 
 struct GpmBrightnessLcdPrivate
 {
+	/* true if hardware automatically sets brightness in response to
+	 * key press events */
+	gboolean		 does_own_updates;
 	guint			 last_set_hw;		/* hardware */
 	guint			 level_std_hw;
 	guint			 levels;
@@ -335,7 +338,8 @@
 	gpm_brightness_lcd_get_hw (brightness, &current_hw);
 
 	/* the panel has been updated in firmware */
-	if (current_hw != brightness->priv->last_set_hw) {
+	if (current_hw != brightness->priv->last_set_hw || 
+            brightness->priv->does_own_updates) {
 		brightness->priv->last_set_hw = current_hw;
 	} else {
 		/* macbook pro has a bazzillion brightness levels, be a bit clever */
@@ -375,7 +379,8 @@
 	gpm_brightness_lcd_get_hw (brightness, &current_hw);
 
 	/* the panel has been updated in firmware */
-	if (current_hw != brightness->priv->last_set_hw) {
+	if (current_hw != brightness->priv->last_set_hw ||
+            brightness->priv->does_own_updates) {
 		gpm_brightness_lcd_get_hw (brightness, &brightness->priv->last_set_hw);
 	} else {
 		/* macbook pro has a bazzillion brightness levels, be a bit clever */
@@ -471,6 +476,7 @@
 	gchar **names;
 	HalGManager *manager;
 	HalGDevice *device;
+	gboolean res;
 
 	brightness->priv = GPM_BRIGHTNESS_LCD_GET_PRIVATE (brightness);
 
@@ -497,6 +503,24 @@
 	if (brightness->priv->levels == 0 || brightness->priv->levels > 256) {
 		gpm_warning ("Laptop panel levels are invalid!");
 	}
+
+	/* Check if hardware handles brightness changes automatically */
+	res = hal_gdevice_get_bool (device, 
+				    "laptop_panel.brightness_in_hardware",
+			            &brightness->priv->does_own_updates, NULL);
+
+	if (!res) {
+		brightness->priv->does_own_updates = FALSE;
+		gpm_debug ("laptop_panel.brightness_in_hardware not found. "
+			   "Assuming false");
+	} else {
+		if (brightness->priv->does_own_updates) {
+			gpm_debug ("laptop_panel.brightness_in_hardware: True");
+		} else {
+			gpm_debug ("laptop_panel.brightness_in_hardware: False");
+		}
+	}
+
 	g_object_unref (device);
 
 	/* get a managed proxy */

Reply via email to