[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: best kernel config on PowerBook G4 12" 1.33GHz



Djoumé SALVETTI <salvetti@crans.org> writes:
> Le mercredi 10/20/04 Basile STARYNKEVITCH <basile@starynkevitch.net> a écrit :
>>   have the LCD back light be turned off when the cover is closed
>
> AFAIK there is still troubles with nvidia driver, I used offb with a
> dirty patch (see attached) to make it working.


Here is, attached, the same patch modified so that it applies cleanly
on 2.6.9.
--- orig/drivers/video/offb.c	2004-10-21 14:08:48.880840848 +0200
+++ dest/drivers/video/offb.c	2004-10-21 14:09:07.522006960 +0200
@@ -29,10 +29,19 @@
 #include <asm/io.h>
 #include <asm/prom.h>
 
+#ifdef CONFIG_PMAC_BACKLIGHT
+#include <asm/backlight.h>
+#endif
+
 #ifdef CONFIG_PPC32
 #include <asm/bootx.h>
 #endif
 
+#ifdef CONFIG_ADB_PMU
+#include <linux/adb.h>
+#include <linux/pmu.h>
+#endif
+
 #include "macmodes.h"
 
 /* Supported palette hacks */
@@ -75,6 +84,23 @@
 extern boot_infos_t *boot_infos;
 #endif
 
+#ifdef CONFIG_PMAC_BACKLIGHT
+static int nv_set_backlight_enable(int on, int level, void *data);
+static int nv_set_backlight_level(int level, void *data)
+{
+	return nv_set_backlight_enable(1, level, data);
+}
+static struct backlight_controller nv_backlight_controller = {
+	nv_set_backlight_enable,
+	nv_set_backlight_level,
+};
+static int nv_set_backlight_init(void);
+static int nv_sleep_notify(struct notifier_block *self, unsigned long, void *);
+static struct notifier_block nv_nb = {
+	nv_sleep_notify, NULL, 0,
+};
+#endif
+
 static void offb_init_nodriver(struct device_node *);
 static void offb_init_fb(const char *name, const char *full_name,
 			 int width, int height, int depth, int pitch,
@@ -549,9 +575,82 @@
 		return;
 	}
 
+#ifdef CONFIG_PMAC_BACKLIGHT
+	if (strncmp(name, "NVDA,", 5) == 0) {
+	  nv_set_backlight_init();
+	}
+#endif
+  
 	printk(KERN_INFO "fb%d: Open Firmware frame buffer device on %s\n",
 	       info->node, full_name);
 }
 
+#ifdef CONFIG_PMAC_BACKLIGHT
+#define MMIO_BASE 0x91000000
+#define MMIO_SIZE 0x01000000
+
+static int nv_bk_level;
+
+volatile unsigned int *nv_mmio, *nv_pmc, *nv_pcrt;
+
+static int nv_set_backlight_enable(int on, int level, void *data)
+{
+	unsigned int tmp_pmc, tmp_pcrt;
+
+	tmp_pmc = nv_pmc[0x10F0/4] & 0x0000FFFF;
+	tmp_pcrt = nv_pcrt[0x081C/4];
+	nv_bk_level = level;
+	if (level == 0) { on = 0; }
+	if (on) {
+		tmp_pmc |= (1 << 31); // backlight bit
+		switch(level) {
+			case 15:
+				tmp_pmc |= 0x05340000; break;
+			default:
+				tmp_pmc |= (341 + (level * 53)) << 16;
+		}
+	} else {
+		tmp_pcrt &= 0xFFFFFFFC;
+	}
+	nv_pmc[0x10F0/4] = tmp_pmc;
+	nv_pcrt[0x081C/4] = tmp_pcrt;
+
+	return (0);
+}
+
+static int nv_set_backlight_init()
+{
+	nv_mmio = (unsigned int *)ioremap(MMIO_BASE, MMIO_SIZE);
+	if (!nv_mmio) {
+		printk("nv_backlight: cannot map memory map io\n");
+		return (-1);
+	}
+	nv_pmc		= nv_mmio + 0x00000000/4;
+	nv_pcrt		= nv_mmio + 0x00600000/4;
+
+	register_backlight_controller(&nv_backlight_controller, NULL, "mnca");
+
+	fb_register_client(&nv_nb);
+
+	return (0);
+}
+
+static int nv_sleep_notify(struct notifier_block *self, 
+			   unsigned long when, void *p)
+{
+	printk("nv_sleep_notify: ");
+	switch(when) {
+	case FB_EVENT_SUSPEND:
+		printk("sleep now\n");
+		break;
+	case FB_EVENT_RESUME:
+		printk("wakeup %d\n", nv_bk_level);
+		nv_set_backlight_enable(1, nv_bk_level, NULL);
+		break;
+	}
+	return PBOOK_SLEEP_OK;
+}
+#endif
+
 module_init(offb_init);
 MODULE_LICENSE("GPL");
Ciao,
-- 
  intrigeri <intrigeri@squat.net>
  gnupg key 0xCA80A0D2 @ keys.indymedia.org
  [ Who wants a world in which the guarantee that we shall not ]
  [  die of starvation entails the risk of dying of boredom ?  ]

Attachment: pgp4nSoLMstHt.pgp
Description: PGP signature


Reply to: