patch-2.3.21 linux/drivers/video/chipsfb.c

Next file: linux/drivers/video/controlfb.c
Previous file: linux/drivers/video/atyfb.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.20/linux/drivers/video/chipsfb.c linux/drivers/video/chipsfb.c
@@ -35,8 +35,8 @@
 #include <asm/io.h>
 #include <asm/prom.h>
 #include <asm/pci-bridge.h>
-#include <asm/adb.h>
-#include <asm/pmu.h>
+#include <linux/adb.h>
+#include <linux/pmu.h>
 
 #include <video/fbcon.h>
 #include <video/fbcon-cfb8.h>
@@ -103,9 +103,9 @@
 static struct fb_info_chips *all_chips;
 
 #ifdef CONFIG_PMAC_PBOOK
-int chips_sleep_notify(struct notifier_block *, unsigned long, void *);
-static struct notifier_block chips_sleep_notifier = {
-	chips_sleep_notify, NULL, 0
+int chips_sleep_notify(struct pmu_sleep_notifier *self, int when);
+static struct pmu_sleep_notifier chips_sleep_notifier = {
+	chips_sleep_notify, SLEEP_LEVEL_VIDEO,
 };
 #endif
 
@@ -329,8 +329,9 @@
 	out_8(p->io_base + 0x3c9, blue);
 
 #ifdef FBCON_HAS_CFB16
-	if (regno < 16)	p->fbcon_cfb16_cmap[regno] =
-		((red & 0xf8) << 7) | ((green & 0xf8) << 2) | ((blue & 0xf8) >> 3);
+	if (regno < 16)
+		p->fbcon_cfb16_cmap[regno] = ((red & 0xf8) << 7)
+			| ((green & 0xf8) << 2) | ((blue & 0xf8) >> 3);
 #endif
 
 	return 0;
@@ -638,8 +639,7 @@
 
 #ifdef CONFIG_PMAC_PBOOK
 	if (all_chips == NULL)
-		notifier_chain_register(&sleep_notifier_list,
-					&chips_sleep_notifier);
+		pmu_register_sleep_notifier(&chips_sleep_notifier);
 #endif /* CONFIG_PMAC_PBOOK */
 	p->next = all_chips;
 	all_chips = p;
@@ -705,15 +705,26 @@
  * and restore it when we wake up again.
  */
 int
-chips_sleep_notify(struct notifier_block *this, unsigned long code, void *x)
+chips_sleep_notify(struct pmu_sleep_notifier *self, int when)
 {
 	struct fb_info_chips *p;
 
 	for (p = all_chips; p != NULL; p = p->next) {
 		int nb = p->var.yres * p->fix.line_length;
+		int i;
 
-		switch (code) {
-		case PBOOK_SLEEP:
+		switch (when) {
+		case PBOOK_SLEEP_NOW:
+			chipsfb_blank(1, (struct fb_info *)p);
+			/* get the palette from the chip, Xpmac seems
+			   to set it directly in the chip */
+			for (i = 0; i < 256; ++i) {
+				out_8(p->io_base + 0x3c8, i);
+				udelay(1);
+				p->palette[i].red = in_8(p->io_base + 0x3c9);
+				p->palette[i].green = in_8(p->io_base + 0x3c9);
+				p->palette[i].blue = in_8(p->io_base + 0x3c9);
+			}
 			p->save_framebuffer = vmalloc(nb);
 			if (p->save_framebuffer)
 				memcpy(p->save_framebuffer,
@@ -726,9 +737,10 @@
 				vfree(p->save_framebuffer);
 				p->save_framebuffer = 0;
 			}
+			chipsfb_blank(0, (struct fb_info *)p);
 			break;
 		}
 	}
-	return NOTIFY_DONE;
+	return PBOOK_SLEEP_OK;
 }
 #endif /* CONFIG_PMAC_PBOOK */

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)