[ifxmips] many more code cleanups for checkpatch.pl, most flagged as errors
[openwrt.git] / target / linux / s3c24xx / patches-2.6.24 / 1295-This-patch-adds-a-framebuffer-notifier-in-order-to-d.patch
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
6 its power saving mode.
7
8 This has the potential of saving something like 50mW during screen blank.
9
10 Signed-off-by: Harald Welte <laforge@openmoko.org>
11 ---
12 drivers/video/display/jbt6k74.c | 48 +++++++++++++++++++++++++++++++++++++++
13 1 files changed, 48 insertions(+), 0 deletions(-)
14
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
19 @@ -3,6 +3,7 @@
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.
25 *
26 * This program is free software; you can redistribute it and/or
27 @@ -21,6 +22,7 @@
28 * MA 02111-1307 USA
29 *
30 */
31 +
32 #include <linux/kernel.h>
33 #include <linux/types.h>
34 #include <linux/module.h>
35 @@ -28,6 +30,7 @@
36 #include <linux/platform_device.h>
37 #include <linux/delay.h>
38 #include <linux/jbt6k74.h>
39 +#include <linux/fb.h>
40
41 enum jbt_register {
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;
48 u16 tx_buf[8];
49 u16 reg_cache[0xEE];
50 int have_resumed;
51 @@ -548,6 +552,40 @@ static struct attribute_group jbt_attr_group = {
52 .attrs = jbt_sysfs_entries,
53 };
54
55 +static int fb_notifier_callback(struct notifier_block *self,
56 + unsigned long event, void *data)
57 +{
58 + struct jbt_info *jbt;
59 + struct fb_event *evdata = data;
60 + int fb_blank;
61 +
62 + if (event != FB_EVENT_BLANK && event != FB_EVENT_CONBLANK)
63 + return 0;
64 +
65 + fb_blank = *(int *)evdata->data;
66 + jbt = container_of(self, struct jbt_info, fb_notif);
67 +
68 + switch (fb_blank) {
69 + case FB_BLANK_UNBLANK:
70 + case FB_BLANK_NORMAL:
71 + jbt6k74_enter_state(jbt, JBT_STATE_NORMAL);
72 + jbt6k74_display_onoff(jbt, 1);
73 + break;
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); */
80 + break;
81 + case FB_BLANK_POWERDOWN:
82 + jbt6k74_enter_state(jbt, JBT_STATE_DEEP_STANDBY);
83 + break;
84 + }
85 +
86 + return 0;
87 +}
88 +
89 /* linux device model infrastructure */
90
91 static int __devinit jbt_probe(struct spi_device *spi)
92 @@ -595,8 +633,17 @@ static int __devinit jbt_probe(struct spi_device *spi)
93 goto err_off;
94 }
95
96 + jbt->fb_notif.notifier_call = fb_notifier_callback;
97 + rc = fb_register_client(&jbt->fb_notif);
98 + if (rc < 0) {
99 + dev_err(&spi->dev, "cannot register notifier\n");
100 + goto err_sysfs;
101 + }
102 +
103 return 0;
104
105 +err_sysfs:
106 + sysfs_remove_group(&spi->dev.kobj, &jbt_attr_group);
107 err_off:
108 jbt6k74_display_onoff(jbt, 0);
109 err_standby:
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) */
113
114 + fb_unregister_client(&jbt->fb_notif);
115 sysfs_remove_group(&spi->dev.kobj, &jbt_attr_group);
116 dev_set_drvdata(&spi->dev, NULL);
117 kfree(jbt);
118 --
119 1.5.6.5
120
This page took 0.045697 seconds and 5 git commands to generate.