[PATCH 3/5] FBCON: Add a powerup and powerdown API calls for runtime fbdev control

Jordan Crouse jordan.crouse at amd.com
Wed Apr 25 20:31:32 EDT 2007


From: Jordan Crouse <jordan.crouse at amd.com>

Allow optional fb_powerup() and fb_powerdown() hooks to allow entities
to turn on and turn off the framebuffer devices during runtime.

Signed-off-by: Jordan Crouse <jordan.crouse at amd.com>
---

 drivers/video/fbmem.c |   39 +++++++++++++++++++++++++++++++++++++++
 include/linux/fb.h    |    9 +++++++++
 2 files changed, 48 insertions(+), 0 deletions(-)

diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index 2822526..7b36843 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -734,6 +734,45 @@ static void try_to_load(int fb)
 #endif /* CONFIG_KMOD */
 
 int
+fb_powerup(struct fb_info *info)
+{
+	int ret = 0;
+
+	if (!info || info->state == FBINFO_STATE_RUNNING)
+		return 0;
+
+	if (info->fbops->fb_powerup)
+		ret = info->fbops->fb_powerup(info);
+
+	if (!ret)
+		fb_set_suspend(info, 0);
+
+	return ret;
+}
+
+int
+fb_powerdown(struct fb_info *info)
+{
+	int ret = 0;
+
+	if (!info || info->state == FBINFO_STATE_SUSPENDED)
+		return 0;
+
+	/* Tell everybody that the fbdev is going down */
+	fb_set_suspend(info, 1);
+
+	if (info->fbops->fb_powerdown)
+		ret = info->fbops->fb_powerdown(info);
+
+	/* If the power down failed, then un-notify */
+
+	if (ret)
+		fb_set_suspend(info, 0);
+
+	return ret;
+}
+
+int
 fb_pan_display(struct fb_info *info, struct fb_var_screeninfo *var)
 {
 	struct fb_fix_screeninfo *fix = &info->fix;
diff --git a/include/linux/fb.h b/include/linux/fb.h
index be913ec..41ddc29 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -634,6 +634,12 @@ struct fb_ops {
 
 	/* restore saved state */
 	void (*fb_restore_state)(struct fb_info *info);
+
+	/* Shut down the graphics engine to save power */
+	int (*fb_powerdown)(struct fb_info *info);
+
+	/* Power it back up */
+	int (*fb_powerup)(struct fb_info *info);
 };
 
 #ifdef CONFIG_FB_TILEBLITTING
@@ -895,6 +901,9 @@ extern int fb_get_color_depth(struct fb_var_screeninfo *var,
 extern int fb_get_options(char *name, char **option);
 extern int fb_new_modelist(struct fb_info *info);
 
+extern int fb_powerdown(struct fb_info *info);
+extern int fb_powerup(struct fb_info *info);
+
 extern struct fb_info *registered_fb[FB_MAX];
 extern int num_registered_fb;
 





More information about the Devel mailing list