1 From 9aa87d67df2e59eea15f70c4e58f8bde10e5953b Mon Sep 17 00:00:00 2001
2 From: Harald Welte <laforge@openmoko.org>
3 Date: Wed, 8 Oct 2008 11:13:46 +0100
4 Subject: [PATCH] This patch adds a framebuffer notifier in order to detect
5 FB_BLANK events and switch the JBT6K74 LCM controller into
8 This has the potential of saving something like 50mW during screen blank.
10 Signed-off-by: Harald Welte <laforge@openmoko.org>
12 drivers/video/display/jbt6k74.c | 48 +++++++++++++++++++++++++++++++++++++++
13 1 files changed, 48 insertions(+), 0 deletions(-)
15 diff --git a/drivers/video/display/jbt6k74.c b/drivers/video/display/jbt6k74.c
16 index b406298..9570543 100644
17 --- a/drivers/video/display/jbt6k74.c
18 +++ b/drivers/video/display/jbt6k74.c
20 * Copyright (C) 2006-2007 by Openmoko, Inc.
21 * Author: Harald Welte <laforge@openmoko.org>,
22 * Stefan Schmidt <stefan@openmoko.org>
23 + * Copyright (C) 2008 by Harald Welte <laforge@openmoko.org>
24 * All rights reserved.
26 * This program is free software; you can redistribute it and/or
32 #include <linux/kernel.h>
33 #include <linux/types.h>
34 #include <linux/module.h>
36 #include <linux/platform_device.h>
37 #include <linux/delay.h>
38 #include <linux/jbt6k74.h>
39 +#include <linux/fb.h>
42 JBT_REG_SLEEP_IN = 0x10,
43 @@ -111,6 +114,7 @@ struct jbt_info {
44 enum jbt_state state, last_state;
45 struct spi_device *spi_dev;
46 struct mutex lock; /* protects tx_buf and reg_cache */
47 + struct notifier_block fb_notif;
51 @@ -548,6 +552,40 @@ static struct attribute_group jbt_attr_group = {
52 .attrs = jbt_sysfs_entries,
55 +static int fb_notifier_callback(struct notifier_block *self,
56 + unsigned long event, void *data)
58 + struct jbt_info *jbt;
59 + struct fb_event *evdata = data;
62 + if (event != FB_EVENT_BLANK && event != FB_EVENT_CONBLANK)
65 + fb_blank = *(int *)evdata->data;
66 + jbt = container_of(self, struct jbt_info, fb_notif);
69 + case FB_BLANK_UNBLANK:
70 + case FB_BLANK_NORMAL:
71 + jbt6k74_enter_state(jbt, JBT_STATE_NORMAL);
72 + jbt6k74_display_onoff(jbt, 1);
74 + case FB_BLANK_VSYNC_SUSPEND:
75 + case FB_BLANK_HSYNC_SUSPEND:
76 + /* FIXME: we disable SLEEP since it would result in
77 + * a visible artefact (white screen) before the backlight
78 + * is dimmed to a dark enough level */
79 + /* jbt6k74_enter_state(jbt, JBT_STATE_SLEEP); */
81 + case FB_BLANK_POWERDOWN:
82 + jbt6k74_enter_state(jbt, JBT_STATE_DEEP_STANDBY);
89 /* linux device model infrastructure */
91 static int __devinit jbt_probe(struct spi_device *spi)
92 @@ -595,8 +633,17 @@ static int __devinit jbt_probe(struct spi_device *spi)
96 + jbt->fb_notif.notifier_call = fb_notifier_callback;
97 + rc = fb_register_client(&jbt->fb_notif);
99 + dev_err(&spi->dev, "cannot register notifier\n");
106 + sysfs_remove_group(&spi->dev.kobj, &jbt_attr_group);
108 jbt6k74_display_onoff(jbt, 0);
110 @@ -615,6 +662,7 @@ static int __devexit jbt_remove(struct spi_device *spi)
111 /* We don't want to switch off the display in case the user
112 * accidentially onloads the module (whose use count normally is 0) */
114 + fb_unregister_client(&jbt->fb_notif);
115 sysfs_remove_group(&spi->dev.kobj, &jbt_attr_group);
116 dev_set_drvdata(&spi->dev, NULL);