add support for target 3c24xx (more known as Openmoko GTA02 "Freerunner") and merge...
[openwrt.git] / target / linux / s3c24xx / patches / 0211-change-backlight-level-not-forced-up-on-resume.patch.patch
1 From d7b66b10fd485219e211b6de14fcb5e6a5266c6a Mon Sep 17 00:00:00 2001
2 From: Andy Green <andy@openmoko.com>
3 Date: Fri, 25 Jul 2008 23:06:19 +0100
4 Subject: [PATCH] change-backlight-level-not-forced-up-on-resume.patch
5
6 We at least always enabled backlight on resume, this patch
7 changes us to set backlight back to last requested backlight
8 brightness level on resume.  Note it means that you can
9 resume with screen blanked, but it should come back if that
10 happened with touchscreen action as usual.
11
12 /sys/class/backlight/pcf50633-bl/actual_brightness
13 and
14 /sys/class/backlight/pcf50633-bl/brightness
15
16 seem to agree after resume when reportedly they didn't before.
17
18 Signed-off-by: Andy Green <andy@openmoko.com>
19 ---
20  drivers/i2c/chips/pcf50633.c |   28 +++++++++++++++++-----------
21  1 files changed, 17 insertions(+), 11 deletions(-)
22
23 diff --git a/drivers/i2c/chips/pcf50633.c b/drivers/i2c/chips/pcf50633.c
24 index 1074b94..fea2f38 100644
25 --- a/drivers/i2c/chips/pcf50633.c
26 +++ b/drivers/i2c/chips/pcf50633.c
27 @@ -1874,16 +1874,12 @@ static int pcf50633bl_get_intensity(struct backlight_device *bd)
28         return intensity & 0x3f;
29  }
30  
31 -static int pcf50633bl_set_intensity(struct backlight_device *bd)
32 +static int __pcf50633bl_set_intensity(struct pcf50633_data *pcf, int intensity)
33  {
34 -       struct pcf50633_data *pcf = bl_get_data(bd);
35 -       int intensity = bd->props.brightness;
36         int old_intensity = reg_read(pcf, PCF50633_REG_LEDOUT);
37         u_int8_t ledena = 2;
38         int ret;
39  
40 -       dev_info(&pcf->client.dev, "pcf50633bl_set_intensity\n");
41 -
42         if (!(reg_read(pcf, PCF50633_REG_LEDENA) & 1))
43                 old_intensity = 0;
44  
45 @@ -1891,7 +1887,8 @@ static int pcf50633bl_set_intensity(struct backlight_device *bd)
46             (bd->props.fb_blank != FB_BLANK_UNBLANK))
47                 intensity = 0;
48  
49 -       /* The PCF50633 cannot handle LEDOUT = 0 (datasheet p60)
50 +       /*
51 +        * The PCF50633 cannot handle LEDOUT = 0 (datasheet p60)
52          * if seen, you have to re-enable the LED unit
53          */
54  
55 @@ -1912,6 +1909,18 @@ static int pcf50633bl_set_intensity(struct backlight_device *bd)
56         return ret;
57  }
58  
59 +static int pcf50633bl_set_intensity(struct backlight_device *bd)
60 +{
61 +       struct pcf50633_data *pcf = bl_get_data(bd);
62 +       int intensity = bd->props.brightness;
63 +
64 +       if ((bd->props.power != FB_BLANK_UNBLANK) ||
65 +           (bd->props.fb_blank != FB_BLANK_UNBLANK))
66 +               intensity = 0;
67 +
68 +       return __pcf50633bl_set_intensity(pcf, intensity);
69 +}
70 +
71  static struct backlight_ops pcf50633bl_ops = {
72         .get_brightness = pcf50633bl_get_intensity,
73         .update_status  = pcf50633bl_set_intensity,
74 @@ -2501,11 +2510,8 @@ void pcf50633_backlight_resume(struct pcf50633_data *pcf)
75         /* platform defines resume ramp speed */
76         reg_write(pcf, PCF50633_REG_LEDDIM,
77                                        pcf->pdata->resume_backlight_ramp_speed);
78 -       reg_write(pcf, PCF50633_REG_LEDOUT, pcf->standby_regs.misc[
79 -                                  PCF50633_REG_LEDOUT - PCF50633_REG_AUTOOUT]);
80 -       /* we force the backlight on in fact */
81 -       reg_write(pcf, PCF50633_REG_LEDENA, pcf->standby_regs.misc[
82 -                              PCF50633_REG_LEDENA - PCF50633_REG_AUTOOUT] | 1);
83 +
84 +       __pcf50633bl_set_intensity(pcf, pcf->backlight->props.brightness);
85  }
86  EXPORT_SYMBOL_GPL(pcf50633_backlight_resume);
87  
88 -- 
89 1.5.6.3
90