diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2008-12-04 04:16:53 +0000 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2008-12-04 04:16:53 +0000 |
commit | 1616e66e553226b6882033c4f033bb4326557752 (patch) | |
tree | c50990e97612866946c45008700c5e9c4efbad4a | |
parent | dcf28c277e8b976de246f7e68f41b70dd672cc59 (diff) | |
download | rockbox-1616e66e553226b6882033c4f033bb4326557752.tar.gz rockbox-1616e66e553226b6882033c4f033bb4326557752.zip |
Gigabeat S: Turn off backlight LED supply after a 2-second delay and save a little power. Hardware fading required keeping supply enabled during fade out. Let fade happen at poweroff (might as well~~~).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19322 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | firmware/export/config-gigabeat-s.h | 10 | ||||
-rw-r--r-- | firmware/target/arm/imx31/gigabeat-s/backlight-imx31.c | 33 | ||||
-rw-r--r-- | firmware/target/arm/imx31/gigabeat-s/backlight-target.h | 2 | ||||
-rw-r--r-- | firmware/target/arm/imx31/gigabeat-s/lcd-imx31.c | 17 | ||||
-rw-r--r-- | firmware/target/arm/imx31/gigabeat-s/power-imx31.c | 9 |
5 files changed, 58 insertions, 13 deletions
diff --git a/firmware/export/config-gigabeat-s.h b/firmware/export/config-gigabeat-s.h index f0e9e92a04..72b1cb76a8 100644 --- a/firmware/export/config-gigabeat-s.h +++ b/firmware/export/config-gigabeat-s.h | |||
@@ -76,9 +76,17 @@ | |||
76 | SAMPR_CAP_24 | SAMPR_CAP_22 | SAMPR_CAP_16 | \ | 76 | SAMPR_CAP_24 | SAMPR_CAP_22 | SAMPR_CAP_16 | \ |
77 | SAMPR_CAP_12 | SAMPR_CAP_11 | SAMPR_CAP_8) | 77 | SAMPR_CAP_12 | SAMPR_CAP_11 | SAMPR_CAP_8) |
78 | 78 | ||
79 | /* Define this if your LCD can be put to sleep. */ | ||
80 | #define HAVE_LCD_SLEEP | ||
81 | /* We don't use a setting but a fixed delay after the backlight has | ||
82 | * turned off */ | ||
83 | #define LCD_SLEEP_TIMEOUT (2*HZ) | ||
84 | |||
79 | #ifndef BOOTLOADER | 85 | #ifndef BOOTLOADER |
80 | /* Not for bootloader */ | 86 | #if 0 |
87 | /* Define this if your LCD can be enabled/disabled */ | ||
81 | #define HAVE_LCD_ENABLE | 88 | #define HAVE_LCD_ENABLE |
89 | #endif | ||
82 | 90 | ||
83 | #define HAVE_BACKLIGHT_BRIGHTNESS | 91 | #define HAVE_BACKLIGHT_BRIGHTNESS |
84 | 92 | ||
diff --git a/firmware/target/arm/imx31/gigabeat-s/backlight-imx31.c b/firmware/target/arm/imx31/gigabeat-s/backlight-imx31.c index db6de3e71e..8b4459c3a9 100644 --- a/firmware/target/arm/imx31/gigabeat-s/backlight-imx31.c +++ b/firmware/target/arm/imx31/gigabeat-s/backlight-imx31.c | |||
@@ -67,7 +67,7 @@ static const struct | |||
67 | 67 | ||
68 | /* Bits always combined with ramping bits */ | 68 | /* Bits always combined with ramping bits */ |
69 | #define MC13783_LED_CONTROL0_BITS \ | 69 | #define MC13783_LED_CONTROL0_BITS \ |
70 | (MC13783_LEDEN | MC13783_BOOSTEN | MC13783_ABMODE_MONCH_LEDMD1234 | \ | 70 | (MC13783_BOOSTEN | MC13783_ABMODE_MONCH_LEDMD1234 | \ |
71 | MC13783_ABREF_400MV) | 71 | MC13783_ABREF_400MV) |
72 | 72 | ||
73 | static struct mutex backlight_mutex; /* Block brightness change while | 73 | static struct mutex backlight_mutex; /* Block brightness change while |
@@ -83,7 +83,8 @@ bool _backlight_init(void) | |||
83 | mutex_init(&backlight_mutex); | 83 | mutex_init(&backlight_mutex); |
84 | 84 | ||
85 | /* Set default LED register value */ | 85 | /* Set default LED register value */ |
86 | mc13783_write(MC13783_LED_CONTROL0, MC13783_LED_CONTROL0_BITS); | 86 | mc13783_write(MC13783_LED_CONTROL0, |
87 | MC13783_LED_CONTROL0_BITS | MC13783_LEDEN); | ||
87 | 88 | ||
88 | #ifdef HAVE_BACKLIGHT_BRIGHTNESS | 89 | #ifdef HAVE_BACKLIGHT_BRIGHTNESS |
89 | /* Our PWM and I-Level is different than retailos (but same apparent | 90 | /* Our PWM and I-Level is different than retailos (but same apparent |
@@ -125,8 +126,13 @@ void _backlight_on(void) | |||
125 | 126 | ||
126 | mutex_lock(&backlight_mutex); | 127 | mutex_lock(&backlight_mutex); |
127 | 128 | ||
128 | /* Set/clear LEDRAMPUP bit, clear LEDRAMPDOWN bit */ | 129 | #ifdef HAVE_LCD_SLEEP |
129 | data[0] = MC13783_LED_CONTROL0_BITS; | 130 | backlight_lcd_sleep_countdown(false); /* stop counter */ |
131 | #endif | ||
132 | |||
133 | /* Set/clear LEDRAMPUP bit, clear LEDRAMPDOWN bit, | ||
134 | * Ensure LED supply is on. */ | ||
135 | data[0] = MC13783_LED_CONTROL0_BITS | MC13783_LEDEN; | ||
130 | 136 | ||
131 | if (!backlight_on_status) | 137 | if (!backlight_on_status) |
132 | data[0] |= led_ramp_mask & MC13783_LEDMDRAMPUP; | 138 | data[0] |= led_ramp_mask & MC13783_LEDMDRAMPUP; |
@@ -150,7 +156,7 @@ void _backlight_on(void) | |||
150 | 156 | ||
151 | void _backlight_off(void) | 157 | void _backlight_off(void) |
152 | { | 158 | { |
153 | uint32_t ctrl0 = MC13783_LED_CONTROL0_BITS; | 159 | uint32_t ctrl0 = MC13783_LED_CONTROL0_BITS | MC13783_LEDEN; |
154 | 160 | ||
155 | mutex_lock(&backlight_mutex); | 161 | mutex_lock(&backlight_mutex); |
156 | 162 | ||
@@ -169,6 +175,11 @@ void _backlight_off(void) | |||
169 | mc13783_write_masked(MC13783_LED_CONTROL2, MC13783_LEDMDDCw(0), | 175 | mc13783_write_masked(MC13783_LED_CONTROL2, MC13783_LEDMDDCw(0), |
170 | MC13783_LEDMDDC); | 176 | MC13783_LEDMDDC); |
171 | 177 | ||
178 | #ifdef HAVE_LCD_SLEEP | ||
179 | /* Disable lcd after fade completes (when lcd_sleep timeout expires) */ | ||
180 | backlight_lcd_sleep_countdown(true); /* start countdown */ | ||
181 | #endif | ||
182 | |||
172 | mutex_unlock(&backlight_mutex); | 183 | mutex_unlock(&backlight_mutex); |
173 | } | 184 | } |
174 | 185 | ||
@@ -192,3 +203,15 @@ void _backlight_set_brightness(int brightness) | |||
192 | mutex_unlock(&backlight_mutex); | 203 | mutex_unlock(&backlight_mutex); |
193 | } | 204 | } |
194 | #endif /* HAVE_BACKLIGHT_BRIGHTNESS */ | 205 | #endif /* HAVE_BACKLIGHT_BRIGHTNESS */ |
206 | |||
207 | #ifdef HAVE_LCD_SLEEP | ||
208 | /* Turn off LED supply */ | ||
209 | void _backlight_lcd_sleep(void) | ||
210 | { | ||
211 | mutex_lock(&backlight_mutex); | ||
212 | |||
213 | mc13783_clear(MC13783_LED_CONTROL0, MC13783_LEDEN); | ||
214 | |||
215 | mutex_unlock(&backlight_mutex); | ||
216 | } | ||
217 | #endif | ||
diff --git a/firmware/target/arm/imx31/gigabeat-s/backlight-target.h b/firmware/target/arm/imx31/gigabeat-s/backlight-target.h index 3c378fc7c2..2ae1372815 100644 --- a/firmware/target/arm/imx31/gigabeat-s/backlight-target.h +++ b/firmware/target/arm/imx31/gigabeat-s/backlight-target.h | |||
@@ -32,4 +32,6 @@ void _backlight_on(void); | |||
32 | void _backlight_off(void); | 32 | void _backlight_off(void); |
33 | void _backlight_set_brightness(int brightness); | 33 | void _backlight_set_brightness(int brightness); |
34 | 34 | ||
35 | void _backlight_lcd_sleep(void); | ||
36 | |||
35 | #endif /* BACKLIGHT_TARGET_H */ | 37 | #endif /* BACKLIGHT_TARGET_H */ |
diff --git a/firmware/target/arm/imx31/gigabeat-s/lcd-imx31.c b/firmware/target/arm/imx31/gigabeat-s/lcd-imx31.c index 14d83bf138..5ebc3bd573 100644 --- a/firmware/target/arm/imx31/gigabeat-s/lcd-imx31.c +++ b/firmware/target/arm/imx31/gigabeat-s/lcd-imx31.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include "lcd.h" | 25 | #include "lcd.h" |
26 | #include "kernel.h" | 26 | #include "kernel.h" |
27 | #include "lcd-target.h" | 27 | #include "lcd-target.h" |
28 | #include "backlight-target.h" | ||
28 | 29 | ||
29 | #define LCDADDR(x, y) (&lcd_framebuffer[(y)][(x)]) | 30 | #define LCDADDR(x, y) (&lcd_framebuffer[(y)][(x)]) |
30 | 31 | ||
@@ -42,13 +43,6 @@ extern struct viewport* current_vp; | |||
42 | extern void lcd_copy_buffer_rect(fb_data *dst, const fb_data *src, | 43 | extern void lcd_copy_buffer_rect(fb_data *dst, const fb_data *src, |
43 | int width, int height); | 44 | int width, int height); |
44 | 45 | ||
45 | #if 0 | ||
46 | bool lcd_enabled() | ||
47 | { | ||
48 | return lcd_on; | ||
49 | } | ||
50 | #endif | ||
51 | |||
52 | /* LCD init */ | 46 | /* LCD init */ |
53 | void lcd_init_device(void) | 47 | void lcd_init_device(void) |
54 | { | 48 | { |
@@ -94,6 +88,14 @@ void lcd_update_rect(int x, int y, int width, int height) | |||
94 | } | 88 | } |
95 | } | 89 | } |
96 | 90 | ||
91 | #ifdef HAVE_LCD_SLEEP | ||
92 | void lcd_sleep(void) | ||
93 | { | ||
94 | _backlight_lcd_sleep(); | ||
95 | } | ||
96 | #endif /* HAVE_LCD_SLEEP */ | ||
97 | |||
98 | #if 0 | ||
97 | void lcd_enable(bool state) | 99 | void lcd_enable(bool state) |
98 | { | 100 | { |
99 | (void)state; | 101 | (void)state; |
@@ -103,6 +105,7 @@ bool lcd_enabled(void) | |||
103 | { | 105 | { |
104 | return true; | 106 | return true; |
105 | } | 107 | } |
108 | #endif | ||
106 | 109 | ||
107 | /* Update the display. | 110 | /* Update the display. |
108 | This must be called after all other LCD functions that change the display. */ | 111 | This must be called after all other LCD functions that change the display. */ |
diff --git a/firmware/target/arm/imx31/gigabeat-s/power-imx31.c b/firmware/target/arm/imx31/gigabeat-s/power-imx31.c index 62f9982dd5..de7f5800e6 100644 --- a/firmware/target/arm/imx31/gigabeat-s/power-imx31.c +++ b/firmware/target/arm/imx31/gigabeat-s/power-imx31.c | |||
@@ -81,9 +81,18 @@ bool ide_powered(void) | |||
81 | 81 | ||
82 | void power_off(void) | 82 | void power_off(void) |
83 | { | 83 | { |
84 | /* Cut backlight */ | ||
85 | _backlight_off(); | ||
86 | |||
87 | /* Let it fade */ | ||
88 | sleep(5*HZ/4); | ||
89 | |||
90 | /* Set user off mode */ | ||
84 | mc13783_set(MC13783_POWER_CONTROL0, MC13783_USEROFFSPI); | 91 | mc13783_set(MC13783_POWER_CONTROL0, MC13783_USEROFFSPI); |
85 | 92 | ||
93 | /* Wait for power cut */ | ||
86 | disable_interrupt(IRQ_FIQ_STATUS); | 94 | disable_interrupt(IRQ_FIQ_STATUS); |
95 | |||
87 | while (1); | 96 | while (1); |
88 | } | 97 | } |
89 | 98 | ||