Bug#281952: additional /proc/device-tree patch for this issue. ...

Sven Luther Sven Luther <sven.luther@wanadoo.fr>, 281952@bugs.debian.org
Tue, 18 Jan 2005 20:09:46 +0100


--cNdxnHkX5QqsyA0e
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline

Hello, please find here attached two files :

  1) pmu_fix.patch : a new version of the 08 patch, with the change attached,
  take it with a grain of salt since i had hunk offset when applying 08 alone.

  2) pmu_fix.diff : the diff between the old version and the new one.

As you see, the crux of this patch is to check for the existence of a via-pmu
device in the firmware provided device-tree. I believe that this way we will
catch all instances of machines which have a /dev/pmu (checked in the 2.6.8
kernel source tree, the sole of importance for this case and powerpc), over
the previous hacky powerbook detection scheme.

Hope this help and you will find time to fix this soon.

Friendly,

Sven Luther

--cNdxnHkX5QqsyA0e
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: attachment; filename="pmu_fix.diff"

diff -ur control-center-2.8.1/gnome-settings-daemon/actions/acme-fb-level.c control-center-2.8.1-patched/gnome-settings-daemon/actions/acme-fb-level.c
--- control-center-2.8.1/gnome-settings-daemon/actions/acme-fb-level.c	2005-01-18 19:43:23.606666320 +0100
+++ control-center-2.8.1-patched/gnome-settings-daemon/actions/acme-fb-level.c	2005-01-18 19:44:48.055828096 +0100
@@ -143,7 +143,7 @@
 	AcmeFblevel *self;
 	int fd, foo;
 
-	if (acme_fblevel_is_powerbook () == FALSE) {
+	if (g_file_test ("/proc/device-tree/aliases/via-pmu", G_FILE_TEST_EXISTS) == FALSE) {
 		return NULL;
 	}
 
@@ -177,24 +177,3 @@
 	self->_priv->pmu_fd = fd;
 	return self;
 }
-
-gboolean
-acme_fblevel_is_powerbook (void)
-{
-	FILE *fd;
-	char str[2048];
-	gboolean found = FALSE;
-
-	fd = fopen ("/proc/cpuinfo", "r");
-	while (!feof (fd) && found == FALSE)
-	{
-		fread (str, 1, 2048, fd);
-		if (strstr (str, "NewWorld") != NULL)
-			found = TRUE;
-	}
-
-	fclose (fd);
-
-	return found;
-}
-

--cNdxnHkX5QqsyA0e
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: attachment; filename="pmu_fix.patch"

diff -ur control-center-2.8.1-orig/gnome-settings-daemon/actions/acme-fb-level.c control-center-2.8.1-patched/gnome-settings-daemon/actions/acme-fb-level.c
--- control-center-2.8.1-orig/gnome-settings-daemon/actions/acme-fb-level.c	2004-09-10 04:34:57.000000000 +0200
+++ control-center-2.8.1-patched/gnome-settings-daemon/actions/acme-fb-level.c	2005-01-18 19:44:48.055828096 +0100
@@ -31,6 +31,7 @@
 #include <linux/fb.h>
 #include <linux/pmu.h>
 #include <errno.h>
+#include <libgnome/gnome-i18n.h>
 
 #ifndef FBIOBLANK
 #define FBIOBLANK      0x4611          /* 0 or vesa-level+1 */
@@ -84,6 +85,17 @@
 	return;
 }
 
+GQuark
+acme_fblevel_error_quark (void)
+{
+	static GQuark quark = 0;
+
+	if (quark == 0)
+		quark = g_quark_from_string ("acme-fblevel-quark");
+
+	return quark;
+}
+
 int
 acme_fblevel_get_level (AcmeFblevel *self)
 {
@@ -126,16 +138,23 @@
 }
 
 AcmeFblevel *
-acme_fblevel_new (void)
+acme_fblevel_new (GError **error)
 {
 	AcmeFblevel *self;
 	int fd, foo;
 
-	if (g_file_test ("/dev/pmu", G_FILE_TEST_EXISTS) == FALSE)
+	if (g_file_test ("/proc/device-tree/aliases/via-pmu", G_FILE_TEST_EXISTS) == FALSE) {
 		return NULL;
+	}
+
 
-	if (acme_fblevel_is_powerbook () == FALSE)
+	if (g_file_test ("/dev/pmu", G_FILE_TEST_EXISTS) == FALSE) {
+		*error = g_error_new_literal (ACME_FBLEVEL_ERROR,
+					      ACME_FBLEVEL_ERROR_NO_PMU_DEVICE,
+					      _("No '/dev/pmu' device found"));
 		return NULL;
+	}
+
 
 	self = ACME_FBLEVEL (g_object_new (ACME_TYPE_FBLEVEL, NULL));
 	/* This function switches the kernel backlight control off.
@@ -147,31 +166,14 @@
 	 * Notice nicked from pbbuttons*/
 	fd  = open ("/dev/pmu", O_RDWR);
 	/* We can't emit the signal yet, the signal isn't connected! */
-	if (fd < 0)
+	if (fd < 0) {
+		*error = g_error_new_literal (ACME_FBLEVEL_ERROR,
+					      ACME_FBLEVEL_ERROR_WRONG_PERMS,
+					      _("No permission to open '/dev/pmu' device"));
 		return NULL;
+	}
 
 	foo = ioctl(fd, PMU_IOC_GRAB_BACKLIGHT, 0);
 	self->_priv->pmu_fd = fd;
 	return self;
 }
-
-gboolean
-acme_fblevel_is_powerbook (void)
-{
-	FILE *fd;
-	char str[2048];
-	gboolean found = FALSE;
-
-	fd = fopen ("/proc/cpuinfo", "r");
-	while (!feof (fd) && found == FALSE)
-	{
-		fread (str, 1, 2048, fd);
-		if (strstr (str, "PowerBook") != NULL)
-			found = TRUE;
-	}
-
-	fclose (fd);
-
-	return found;
-}
-
Seulement dans control-center-2.8.1-patched/gnome-settings-daemon/actions: acme-fb-level.c.orig
diff -ur control-center-2.8.1-orig/gnome-settings-daemon/actions/acme-fb-level.h control-center-2.8.1-patched/gnome-settings-daemon/actions/acme-fb-level.h
--- control-center-2.8.1-orig/gnome-settings-daemon/actions/acme-fb-level.h	2004-01-13 16:57:36.000000000 +0100
+++ control-center-2.8.1-patched/gnome-settings-daemon/actions/acme-fb-level.h	2005-01-18 19:43:30.080682120 +0100
@@ -29,9 +29,12 @@
 #define ACME_IS_FBLEVEL(obj)		(G_TYPE_CHECK_INSTANCE_TYPE ((obj), ACME_TYPE_FBLEVEL))
 #define ACME_FBLEVEL_GET_CLASS(obj)	(G_TYPE_INSTANCE_GET_CLASS ((obj), ACME_TYPE_FBLEVEL, AcmeFblevelClass))
 
+#define ACME_FBLEVEL_ERROR		(acme_fblevel_error_quark ())
+
 typedef struct AcmeFblevelPrivate AcmeFblevelPrivate;
 typedef struct AcmeFblevel AcmeFblevel;
 typedef struct AcmeFblevelClass AcmeFblevelClass;
+typedef enum   AcmeFblevelError	AcmeFblevelError;
 
 struct AcmeFblevel {
 	GObject parent;
@@ -44,12 +47,19 @@
 	GObjectClass parent;
 };
 
+enum AcmeFblevelError {
+	ACME_FBLEVEL_ERROR_NO_PMU_DEVICE,
+	ACME_FBLEVEL_ERROR_NO_POWERBOOK,
+	ACME_FBLEVEL_ERROR_WRONG_PERMS
+};
+
 GType acme_fblevel_get_type			(void);
+GQuark acme_fblevel_error_quark			(void);
 int acme_fblevel_get_level			(AcmeFblevel *self);
 void acme_fblevel_set_level			(AcmeFblevel *self, int val);
 gboolean acme_fblevel_get_dim			(AcmeFblevel *self);
 void acme_fblevel_set_dim			(AcmeFblevel *self,
 						 gboolean val);
-AcmeFblevel *acme_fblevel_new			(void);
+AcmeFblevel *acme_fblevel_new			(GError **error);
 gboolean acme_fblevel_is_powerbook		(void);
 
diff -ur control-center-2.8.1-orig/gnome-settings-daemon/gnome-settings-multimedia-keys.c control-center-2.8.1-patched/gnome-settings-daemon/gnome-settings-multimedia-keys.c
--- control-center-2.8.1-orig/gnome-settings-daemon/gnome-settings-multimedia-keys.c	2004-10-09 03:52:01.000000000 +0200
+++ control-center-2.8.1-patched/gnome-settings-daemon/gnome-settings-multimedia-keys.c	2005-01-18 19:43:30.151671328 +0100
@@ -133,26 +133,6 @@
 	}
 }
 
-#ifdef USE_FBLEVEL
-static char*
-permission_problem_string (const char *file)
-{
-	return g_strdup_printf (_("Permissions on the file %s are broken\n"), file);
-}
-
-static void
-fblevel_problem_cb (void)
-{
-	char *msg;
-
-	msg = permission_problem_string ("/dev/pmu");
-	acme_error (msg);
-	g_free (msg);
-
-	return;
-}
-#endif
-
 static char *images[] = {
 	PIXMAPSDIR "/gnome-speakernotes-muted.png",
 	PIXMAPSDIR "/gnome-speakernotes.png",
@@ -913,6 +893,7 @@
 {
 	GSList *l;
 	Acme   *acme;
+	GError *err = NULL;
 
 	acme = g_new0 (Acme, 1);
 	acme->xml = NULL;
@@ -932,11 +913,10 @@
 
 #ifdef USE_FBLEVEL
 	/* initialise Frame Buffer level handler */
-	if (acme_fblevel_is_powerbook () != FALSE)
-	{
-		acme->levobj = acme_fblevel_new();
-		if (acme->levobj == NULL)
-			fblevel_problem_cb ();
+	acme->levobj = acme_fblevel_new (&err);
+	if (acme->levobj == NULL && err != NULL) {
+		g_critical(err->message);
+		g_error_free (err);
 	}
 #endif
 
Seulement dans control-center-2.8.1-patched/gnome-settings-daemon: gnome-settings-multimedia-keys.c.orig

--cNdxnHkX5QqsyA0e--